GTK2.ComboBox()->set_active_iter() bug

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

GTK2.ComboBox()->set_active_iter() bug

larcky
Hi everyone
I've been messing about with this for some time but think I finally found a fix.  The following creates a little GUI with button and combo box.  Pressing the button should select the first element in the combo box but doesn't - it just blanks it out as if the selection were out-of-bounds.



GTK2.ListStore ls;
object cb;

void pick_first()
{
    cb->set_active_iter( ls->get_iter_first() );

} // pick_first()

int main( int argc, array argv )
{
    GTK2.setup_gtk();
    object w = GTK2.Window( GTK2.WINDOW_TOPLEVEL );
    GTK2.Vbox my_vbox = GTK2.Vbox( 0, 0 );
    GTK2.Button b = GTK2.Button( "Pick the first" );
    ls = GTK2.ListStore( ({ "string" }) );
    cb = GTK2.ComboBox( ls );
    GTK2.CellRendererText crt = GTK2.CellRendererText();
    cb->pack_start( crt, 0 )->add_attribute( crt, "text", 0 );
   
    // Fill combobox with values.
    array(string) drinks = ({ "lemonade", "orange juice", "coffee", "wine" });
    foreach ( drinks, string s )
    {
        GTK2.TreeIter iter = ls->append();
        ls->set_row( iter, ({ s }) );
    } // foreach

    my_vbox->pack_start( b, 1, 1, 0 );
    my_vbox->pack_start( cb, 1, 1, 0 );
    w->add( my_vbox );
    w->show_all();
    b->signal_connect( "clicked", pick_first );
    w->signal_connect( "destroy", lambda(){ exit(0); }, 0 );
    GTK2.main();

    return 0;

} // main()



The attached patch seems to fix it.  I altered an argument slightly by copying and pasting from a similar function that I knew worked (- that's as far as my debugging skills extend ;)
Best wishes,
larcky
mydiff.txt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GTK2.ComboBox()->set_active_iter() bug

Lance Dillon-2




----- Original Message ----

> From: larcky <[hidden email]>
> To: [hidden email]
> Sent: Sun, November 20, 2011 1:51:56 PM
> Subject: GTK2.ComboBox()->set_active_iter() bug
>
> Hi everyone
> I've been messing about with this for some time but think I  finally found a
> fix.  The following creates a little GUI with button and  combo box.
> Pressing the button should select the first element in the combo  box but
> doesn't - it just blanks it out as if the selection were  out-of-bounds.
>
>
>
> The attached patch /seems/ to fix it.  I altered an  argument slightly by
> copying and pasting from a similar function that I knew  worked (- that's as
> far as my debugging skills extend ;)
> Best  wishes,
> larcky
> http://pike.1058338.n5.nabble.com/file/n5008625/mydiff.txt  mydiff.txt
>
> --

Sounds good to me.  I just applied and committed the patch.  Looks like it was
something that just got missed during a fix some time back.  Looks like I also
missed gtktreeviewcolumn, so I fixed that too.

Fixed in 7.8 and 7.9.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GTK2.ComboBox()->set_active_iter() bug

larcky
Lance Dillon-2 wrote
Sounds good to me.  I just applied and committed the patch.  Looks like it was
something that just got missed during a fix some time back.  Looks like I also
missed gtktreeviewcolumn, so I fixed that too.
Fixed in 7.8 and 7.9.
Hi, thanks.  I think there's a similar problem in GTK2.TreeView()->set_cursor().  I don't have a short example to hand but I was using it to select the first element in a treeview automatically and it gave this error message:

Gtk-CRITICAL **: gtk_tree_view_set_cursor_on_cell: assertion `path != NULL' failed

But it works with the following patch
mydiff.txt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GTK2.ComboBox()->set_active_iter() bug

Lance Dillon-2




----- Original Message ----

> From: larcky <[hidden email]>
> To: [hidden email]
> Sent: Mon, November 21, 2011 10:37:08 AM
> Subject: Re: GTK2.ComboBox()->set_active_iter() bug
>
>
> Lance Dillon-2 wrote
> >
> > Sounds good to me.  I just  applied and committed the patch.  Looks like it
> > was
> >  something that just got missed during a fix some time back.  Looks like  I
> > also
> > missed gtktreeviewcolumn, so I fixed that too.
> >  Fixed in 7.8 and 7.9.
> >
> Hi, thanks.  I think there's a similar  problem in
> GTK2.TreeView()->set_cursor().  I don't have a short  example to hand but I
> was using it to select the first element in a treeview  automatically and it
> gave this error message:
>
> Gtk-CRITICAL **:  gtk_tree_view_set_cursor_on_cell: assertion `path != NULL'
> failed
>
> But  it works with the following patch
> http://pike.1058338.n5.nabble.com/file/n5010839/mydiff.txt mydiff.txt
>

Yes, both this and the previous one were because GtkTreePath (and GtkTreeIter)
are not GObject's, so get_gobject (which kind of auto-detects the type) doesn't
work.  We need to use get_pg2object() which gets the data based on the type
passed.

I updated 7.8 and 7.9 for all instances of GtkTreePath, gtkcellview.pre,
gtkiconview.pre, gtktreedragdest.pre, gtktreedragsource.pre, and
gtktreeview.pre, a lot more insances in gtktreeview.pre than just set_cursor().

Thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GTK2.ComboBox()->set_active_iter() bug

larcky
Lance Dillon-2 wrote
Yes, both this and the previous one were because GtkTreePath (and GtkTreeIter)
are not GObject's, so get_gobject (which kind of auto-detects the type) doesn't
work.  We need to use get_pg2object() which gets the data based on the type
passed.
Aha, so that's what they do :)

I updated 7.8 and 7.9 for all instances of GtkTreePath, gtkcellview.pre,
gtkiconview.pre, gtktreedragdest.pre, gtktreedragsource.pre, and
gtktreeview.pre, a lot more insances in gtktreeview.pre than just set_cursor().
Thanks for that, but are you sure the 7.9 changes went through?  They're not coming in
with 'git pull'.
Regards, larcky


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: GTK2.ComboBox()->set_active_iter() bug

Lance Dillon-2
You're right, I forgot to push it.



----- Original Message ----

> From: larcky <[hidden email]>
> To: [hidden email]
> Sent: Tue, November 22, 2011 12:39:29 AM
> Subject: Re: GTK2.ComboBox()->set_active_iter() bug
>
>
> Lance Dillon-2 wrote
> >
> > Yes, both this and the previous one  were because GtkTreePath (and
> > GtkTreeIter)
> > are not GObject's,  so get_gobject (which kind of auto-detects the type)
> > doesn't
> >  work.  We need to use get_pg2object() which gets the data based on  the
> > type
> > passed.
> Aha, so that's what they do :)
>
>
> I  updated 7.8 and 7.9 for all instances of GtkTreePath, gtkcellview.pre,
> >  gtkiconview.pre, gtktreedragdest.pre, gtktreedragsource.pre, and
> >  gtktreeview.pre, a lot more insances in gtktreeview.pre than just
> >  set_cursor().
> Thanks for that, but are you sure the 7.9 changes went  through?  They're not
> coming in
> with 'git pull'.
> Regards,  larcky
>
>
>
>
> --
> View this message in context:  
>http://pike.1058338.n5.nabble.com/GTK2-ComboBox-set-active-iter-bug-tp5008625p5012572.html
>
> Sent  from the Pike - User mailing list archive at Nabble.com.
>
>

Loading...