Web lists-archives.com

Re: GTK3 - GtkExpander problem, bug ?




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: sebastien.leroux@xxxxxxxxxxxxxxxx
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
===========================================================

/*
   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)));
  }
static void button_clicked3(GtkWidget *button, gpointer user_data)
  {
    g_print("3 %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];
    GtkWidget *buttons3[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);
          }
      }

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

    GtkWidget *grid3=gtk_grid_new();
    for(i=0;i<10;i++)
      {
        for(j=0;j<10;j++)
          {
            gtk_grid_attach(GTK_GRID(grid3), buttons3[i*10+j], j, i, 1, 1);
            g_signal_connect(buttons3[i*10+j], "clicked", G_CALLBACK(button_clicked3), 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 *scroll3=gtk_scrolled_window_new(NULL, NULL);
    gtk_widget_set_vexpand(scroll3, TRUE);
    gtk_widget_set_hexpand(scroll3, TRUE);
    gtk_container_add(GTK_CONTAINER(scroll3), grid3);

    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 *expander3=gtk_expander_new("buttons3");
    gtk_container_add(GTK_CONTAINER(expander3), scroll3);

    GtkWidget *grid4=gtk_grid_new();
    gtk_grid_attach(GTK_GRID(grid4), expander1, 0, 0, 1, 1);
    gtk_grid_attach(GTK_GRID(grid4), expander2, 0, 1, 1, 1);
    gtk_grid_attach(GTK_GRID(grid4), expander3, 0, 2, 1, 1);
    gtk_container_add(GTK_CONTAINER(window), grid4);

    gtk_widget_show_all(window);

    gtk_main();

    return 0;
  }  


_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list