Quantcast

GtkExpander label widgets (using buttons as)

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

GtkExpander label widgets (using buttons as)

David Caldwell
I have a GtkExpander and I set its label widget to an hbox to which I added a
label and 2 buttons. They all display nicely, but the buttons don't work
properly. When I click on them it activates the expander instead of the buttons
themselves. Actually, a couple of the button's top and bottom rows of pixles
will respond to mouse clicks, but none of the center area does. Is this supposed
to work?

Thanks,
  David


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GtkExpander label widgets (using buttons as)

tristan.van.berkom
David Caldwell wrote:
> I have a GtkExpander and I set its label widget to an hbox to which I added a
> label and 2 buttons. They all display nicely, but the buttons don't work
> properly. When I click on them it activates the expander instead of the buttons
> themselves. Actually, a couple of the button's top and bottom rows of pixles
> will respond to mouse clicks, but none of the center area does. Is this supposed
> to work?

I would think so...
     actually; when I try out your described setup in the glade3 builder;
it definitly worsforme, I wonder if that is only due to the gui builder
environment.

Can you reproduce this misbehaviour in a brief code segment and post it ?
maybe I (or someone else for that matter) can tell you if something is
wrong with your code or maybe we can better pinpoint a bug in GTK+ that way.

Cheers,
                         -Tristan

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GtkExpander label widgets (using buttons as)

David Caldwell
Tristan Van Berkom <tristan.van.berkom <at> gmail.com> writes:

> David Caldwell wrote:
>
> > I have a GtkExpander and I set its label widget to an hbox to
> > which I added a label and 2 buttons. They all display nicely, but
> > the buttons don't work properly. When I click on them it activates
> > the expander instead of the buttons themselves. Actually, a couple
> > of the button's top and bottom rows of pixles will respond to
> > mouse clicks, but none of the center area does. Is this supposed
> > to work?
>
> I would think so...
>      actually; when I try out your described setup in the glade3
> builder; it definitly worsforme, I wonder if that is only due to the
> gui builder environment.

Actually, this code is not directly from glade-2, but created on the
fly via some code orginally adapted from glade (I basically changed
the variable names, and c99-ified it). I'm using stock gtk from Fedora
Core 4 and don't appear to have glade3.

> Can you reproduce this misbehaviour in a brief code segment and post
> it ?

Here is the snippet that creates the expander:

    GtkWidget *expander = gtk_expander_new(NULL);
    gtk_expander_set_expanded(GTK_EXPANDER(expander), TRUE);
    gtk_box_pack_start(GTK_BOX(plots), expander, FALSE, FALSE, 0);
   
    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
    gtk_expander_set_label_widget(GTK_EXPANDER(expander), hbox);

    GtkLabel *label = GTK_LABEL(gtk_label_new(plotname));
    gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), TRUE, TRUE, 0);
    gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE);

    GtkWidget *edit_button = gtk_button_new_with_mnemonic("Edit");
    gtk_box_pack_start(GTK_BOX(hbox), edit_button, FALSE, FALSE, 0);
    gtk_widget_set_sensitive(edit_button, TRUE);
    g_signal_connect(edit_button, "clicked",
                     G_CALLBACK(EditPlot),
                     (gpointer)p);

    GtkWidget *delete_button = gtk_button_new_with_mnemonic("Delete");
    gtk_box_pack_start(GTK_BOX(hbox), delete_button, FALSE, FALSE, 0);
    gtk_widget_set_sensitive(delete_button, TRUE);
    g_signal_connect(delete_button, "clicked",
                     G_CALLBACK(DeletePlot),
                     (gpointer)p);

    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(expander), vbox);
    // ... put some junk in the vbox

> maybe I (or someone else for that matter) can tell you if something
> is wrong with your code or maybe we can better pinpoint a bug in
> GTK+ that way.

Any help you could provide would be greatly appreciated.

Thanks,
  David

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GtkExpander label widgets (using buttons as)

David Caldwell
David Caldwell <david <at> porkrind.org> writes:

> Tristan Van Berkom <tristan.van.berkom <at> gmail.com> writes:
>
> > David Caldwell wrote:
> >
> > > I have a GtkExpander and I set its label widget to an hbox to
> > > which I added a label and 2 buttons. They all display nicely, but
> > > the buttons don't work properly.

> > Can you reproduce this misbehaviour in a brief code segment and post
> > it ?

My last snippet was perhaps too snipped. Here is a complete program you should
just be able to compile up and test.

// -*- compile-command: "cc -g -std=gnu99 `pkg-config gtk+-2.0 --cflags --libs`
-o test test.c" -*-

#include <gtk/gtk.h>
#include <stdio.h>

void clicked(GtkButton *button, void *which)
{
    printf("%s clicked\n", which);
}

int main(int argc, char **argv)
{
    gtk_init (&argc, &argv); // could technically do autolist_add(main_init,
gtk_init); but it wouldnt buy me anything

    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    GtkWidget *vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window), vbox1);

    GtkWidget *expander = gtk_expander_new(NULL);
    gtk_expander_set_expanded(GTK_EXPANDER(expander), TRUE);
    gtk_box_pack_start(GTK_BOX(vbox1), expander, FALSE, FALSE, 0);

    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
    gtk_expander_set_label_widget(GTK_EXPANDER(expander), hbox);

    GtkLabel *label = GTK_LABEL(gtk_label_new("The Label"));
    gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), TRUE, TRUE, 0);
    gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE);

    GtkWidget *edit_button = gtk_button_new_with_mnemonic("Edit");
    gtk_box_pack_start(GTK_BOX(hbox), edit_button, FALSE, FALSE, 0);
    gtk_widget_set_sensitive(edit_button, TRUE);
    g_signal_connect(edit_button, "clicked",
                     G_CALLBACK(clicked),
                     (gpointer)"Edit");

    GtkWidget *delete_button = gtk_button_new_with_mnemonic("Delete");
    gtk_box_pack_start(GTK_BOX(hbox), delete_button, FALSE, FALSE, 0);
    gtk_widget_set_sensitive(delete_button, TRUE);
    g_signal_connect(delete_button, "clicked",
                     G_CALLBACK(clicked),
                     (gpointer)"Delete");

    GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(expander), vbox);
    // ... put some junk in the vbox

    gtk_widget_show_all(window);
    gtk_main();
    return 0;
}


_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GtkExpander label widgets (using buttons as)

Tristan Van Berkom
David Caldwell wrote:
[...]
>>>Can you reproduce this misbehaviour in a brief code segment and post
>>>it ?
>
> My last snippet was perhaps too snipped. Here is a complete program you should
> just be able to compile up and test.

Indeed its broken,

Strangely, when I do these steps in the builder (experimental glade-3):
     o Create an expander
     o Delete the label widget
     o Add a hbox in its place
     o Add a label and two buttons

The buttons work fine... BUT, if I save & reload the project
then I experience the same problem as in your test case...

So I tried adding this hack to your program:

==========================================
gboolean
hacked_idle (GtkWidget *hbox)
{
     g_object_ref (G_OBJECT (hbox));
     gtk_expander_set_label_widget (GTK_EXPANDER (expander), NULL);

     gtk_expander_set_label_widget (GTK_EXPANDER (expander), hbox);
     g_object_unref (G_OBJECT (hbox));

     return FALSE;
}
==========================================

By removing and re-adding the hbox *after* realization time we can
work around the problem (it works now).

Can you do us all a favor and enter a bug at bugzilla.gnome.org
under GTK+ and put down these details ?

Cheers,
                                   -Tristan
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GtkExpander label widgets (using buttons as)

David Caldwell
Tristan Van Berkom <tvb <at> gnome.org> writes:

> By removing and re-adding the hbox *after* realization time we can
> work around the problem (it works now).

Ah, thank you! I added a call to gtk_widget_show_now() and then add the hbox and
buttons and now they work properly.

> Can you do us all a favor and enter a bug at bugzilla.gnome.org
> under GTK+ and put down these details ?

I will do that right now. Sorry for the 2 week delay, I've been at the Darpa
Grand Challenge!

-David

_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...