GTK3 - GtkExpander problem, bug ?

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

GTK3 - GtkExpander problem, bug ?

Sébastien Le Roux
Dear all thanks in advance for reading this,

I wrote a piece of code in GTK3, and I might have found an issue with
the GtkExpander widget,
shorter than a long text explanation, I attach to this email a screen
capture from a window from my program.
This window contains a bunch of GtkExpander, inside each a
GtkScrolledWindow that contains a GtkFixed,
each GtkFixed contains a series of GtkToggleButtons. (I can have a lot
of buttons piled up in there).
I tried several container widget other than the ScrolledWindow, but it
is the only one that offers to browse
the entire button list that my program will create.

The first time, I open/close one of the GtkExpander (1) everything works
fine, the button are working fine,
then if I open/close another GtkExpander (2) and re-open the first one I
lose information regarding the buttons,
some stop to function, for other the pointers for the callback are
damaged and the function will not work properly afterwards.
I noticed that I could even recall buttons located in the other expander
(2), basically at the location they were
appearing on the window before having expander (2) closed, like if the
two sets of buttons from the 2 expanders
  were overlapping/sharing positions somehow.

So there is no GTK signal used in all this window excepted for the
buttons, and a simple 'play' with the expanders
is messing everything up ... GDB and VALGRIND are not giving me any
error so ...
I figured that this was out of my skill range, hence this email.


I also attach to this message a piece of code to illustrate how I
generate the window from my picture, the part
the generate the button is missing but that it too big to included in
this message.

Finally I want to add that the almost the exact same code works just
fine with GTK2 ... if that helps.

Thanks in advance for you help.

Best regards.

--
===========================================================
Dr. Sébastien Le Roux
Ingénieur de Recherche CNRS
Institut de Physique et Chimie des Matériaux de Strasbourg
Département des Matériaux Organiques
23, rue du Loess
BP 43
F-67034 Strasbourg Cedex 2, France
E-mail: [hidden email]
Webpage: http://www-ipcms.u-strasbg.fr/spip.php?article1771
RINGS project: http://rings-code.sourceforge.net/
ISAACS project: http://isaacs.sourceforge.net/
Fax:   +33 3 88 10 72 46
Phone: +33 3 88 10 71 62
===========================================================

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

Re: GTK3 - GtkExpander problem, bug ?

codemusings
Hello Sébastien,

attaching images isn't allowed on here. Have you created a minimal
working example that reproduces the bug? Otherwise it'll be hard to
help you.

Cheers,

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

Re: GTK3 - GtkExpander problem, bug ?

Gtk+ - Apps Dev mailing list
In reply to this post by Sébastien Le Roux

 
Hi Sébastien,

If I try some test code... it should work. The code uses a grid instead of a fixed container. Is this similar to what you have tried?

Eric

/*
   gcc -Wall buttons1.c -o buttons1 `pkg-config --cflags --libs gtk+-3.0`
   Tested with GTK3.18 on Ubuntu16.04
*/
#include<gtk/gtk.h>

static void button_clicked1(GtkWidget *button, gpointer user_data)
  {
    g_print("1 %s\n", gtk_button_get_label(GTK_BUTTON(button)));
  }
static void button_clicked2(GtkWidget *button, gpointer user_data)
  {
    g_print("2 %s\n", gtk_button_get_label(GTK_BUTTON(button)));
  }
int main(int argc, char *argv[])
  {
    gtk_init (&argc, &argv);

    GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "Buttons");
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 400);
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    gint i=0;
    gint j=0;
    GtkWidget *buttons1[100];
    GtkWidget *buttons2[100];

    //First set of buttons.
    for(i=0;i<100;i++)
      {
        gchar *string=g_strdup_printf("button%i", i);
        buttons1[i]=gtk_button_new_with_label(string);
        g_free(string);
      }

    GtkWidget *grid1=gtk_grid_new();
    for(i=0;i<10;i++)
      {
        for(j=0;j<10;j++)
          {
            gtk_grid_attach(GTK_GRID(grid1), buttons1[i*10+j], j, i, 1, 1);
            g_signal_connect(buttons1[i*10+j], "clicked", G_CALLBACK(button_clicked1), NULL);
          }
      }

    //Second set of buttons.
    for(i=0;i<100;i++)
      {
        gchar *string=g_strdup_printf("button%i", i);
        buttons2[i]=gtk_button_new_with_label(string);
        g_free(string);
      }

    GtkWidget *grid2=gtk_grid_new();
    for(i=0;i<10;i++)
      {
        for(j=0;j<10;j++)
          {
            gtk_grid_attach(GTK_GRID(grid2), buttons2[i*10+j], j, i, 1, 1);
            g_signal_connect(buttons2[i*10+j], "clicked", G_CALLBACK(button_clicked2), NULL);
          }
      }  

    GtkWidget *scroll1=gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_vexpand(scroll1, TRUE);
    gtk_widget_set_hexpand(scroll1, TRUE);
    gtk_container_add(GTK_CONTAINER(scroll1), grid1);

    GtkWidget *scroll2=gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_vexpand(scroll2, TRUE);
    gtk_widget_set_hexpand(scroll2, TRUE);
    gtk_container_add(GTK_CONTAINER(scroll2), grid2);

    GtkWidget *expander1=gtk_expander_new("buttons1");
    gtk_container_add(GTK_CONTAINER(expander1), scroll1);

    GtkWidget *expander2=gtk_expander_new("buttons2");
    gtk_container_add(GTK_CONTAINER(expander2), scroll2);

    GtkWidget *grid3=gtk_grid_new();
    gtk_grid_attach(GTK_GRID(grid3), expander1, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(grid3), expander2, 0, 1, 1, 1);

    gtk_container_add(GTK_CONTAINER(window), grid3);

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
  }  

 


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

Re: GTK3 - GtkExpander problem, bug ?

Sébastien Le Roux
Dear Eric,
thanks for your answer, and yes it is pretty much the same, the
differences in my case,
are: I use toggle buttons and I do not use  a grid.

Thanks you for providing me with this nice working example, I played
with it to illustrate the
bug because it happens with your code too, check the new 'test.c' file
attached !

I simply added a third expander and a third set of buttons, I invite you
to compile the code attached,
and play with it you will see, that at same point even it stops to
function properly.

To start to have errors you can follow the following sequence:
1) open the first expander
2) open the second
3) open the third
4) close the second
5) starting clicking on the second expander location (without buttons
visible) and it starts.

I can only guess that the more expander you use the more messy it will
get ... hence the problems
with my program that uses 10.

Just so you know I overcame the issue using a TreeView in a
ScrolledWindow instead of a bunch of Expander + ScrolledWindow,
I do not think that it is as nice visually but it works smoothly.

Best regards

Sébastien Le Roux
--

===========================================================
Dr. Sébastien Le Roux
Ingénieur de Recherche CNRS
Institut de Physique et Chimie des Matériaux de Strasbourg
Département des Matériaux Organiques
23, rue du Loess
BP 43
F-67034 Strasbourg Cedex 2, France
E-mail: [hidden email]
Webpage: http://www-ipcms.u-strasbg.fr/spip.php?article1771
RINGS project: http://rings-code.sourceforge.net/
ISAACS project: http://isaacs.sourceforge.net/
Fax:   +33 3 88 10 72 46
Phone: +33 3 88 10 71 62
===========================================================

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

Re: GTK3 - GtkExpander problem, bug ?

Gtk+ - Apps Dev mailing list
In reply to this post by Sébastien Le Roux


 
Hi Sébastien,

An out of sync reply. I must have accidently deleted your last response after I read it. Also I didn't notice there were two mailing lists referenced. Probably just need the app dev list.

It looks like it is a bug that has been recently introduced. If I test, test.c with three expanders, on GTK3.18 it works fine. No problems. If I test on GTK3.22, after I close any expander the buttons can still be clicked even though they aren't showing. This is also the case with only 2 expanders in the original test code.



It sounds like the treeview work around is the way to go in this case.


Eric



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

Re: GTK3 - GtkExpander problem, bug ?

Gtk+ - Apps Dev mailing list
In reply to this post by Sébastien Le Roux

 
Thanks Matthias. I probably should have checked bugzilla first. Just rebuilt GTK to version 3.22.26 and it works fine. There is no click through after closing the expander.

Eric

 


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