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: sebastien.ler...@ipcms.unistra.fr
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
===========================================================

#define NGRAPHS 10

GtkWidget * gfixed[NGRAPHS];
GtkWidget * expand[NGRAPHS];
gchar * graph_img[NGRAPHS];

char * graph_name[NGRAPHS] = {"g(r)/G(r)",
                              "S(q) from FFT[g(r)]",
                              "S(q) from Debye equation",
                              "g(r)/G(r) from FFT[S(q)]",
                              "Bonds properties",
                              "Angle distributions",
                              "Ring statistics",
                              "Chain statistics",
                              "Spherical harmonics",
                              "Mean Squared Displacement"};

GtkWidget * markup_label (gchar * text,
                          int dimx, int dimy,
                          float ax, float ay)
{
  GtkWidget * lab = gtk_label_new (text);
  gtk_label_align (lab, ax, ay);
  gtk_widget_set_size_request (lab, dimx, dimy);
  gtk_label_set_use_markup (GTK_LABEL(lab), TRUE);
  return lab;
}

GtkWidget * create_scroll (GtkWidget * box, int dimx, int dimy, int shadow)
{
  GtkWidget * scroll = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scroll), shadow);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request (scroll, dimx, dimy);
  if (box != NULL) gtk_container_add (GTK_CONTAINER(box), scroll);
  return scroll;
}

GtkWidget * create_expander (gchar * name, gchar * img_file, int i, gboolean ctb)
{
  GtkWidget * expand = gtk_expander_new (name);
  GtkWidget * hbox = create_hbox (0);
  if (img_file != NULL)
  {
    GtkWidget * img = gtk_image_new_from_file (img_file);
    gtk_widget_set_size_request (img, 20, 20);
    gtk_box_pack_start (GTK_BOX (hbox), img, TRUE, TRUE, 10);
  }
  gtk_box_pack_start (GTK_BOX (hbox), markup_label(name, 200, 20, 0.0, 0.5), FALSE, TRUE, 0);
  gtk_expander_set_label_widget (GTK_EXPANDER(expand), hbox);
  if (ctb)
  {
    GtkWidget * scrol = create_scroll (expand, -1, -1, GTK_SHADOW_NONE);
    gfixed[i] = gtk_fixed_new ();
    gtk_container_add (GTK_CONTAINER(scrol), gfixed[i]);
    gtk_widget_set_hexpand (gfixed[i], TRUE);
    gtk_widget_set_vexpand (gfixed[i], TRUE);
  }
  return expand;
}

GtkWidget * create_win (gchar * str)
{
  GtkWidget * win;
  GtkAccelGroup * accel_group;

  accel_group = gtk_accel_group_new ();
  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(win), str);
  gtk_window_add_accel_group (GTK_WINDOW (win), accel_group);

  return win;
}

GtkWidget * curvetbox (void)
{
  int i;
  GtkWidget * ctbox;
  GtkWidget * vbox;

  ctbox = create_win("Tool boxes");
  gtk_widget_set_size_request (ctbox, 300, 250);
  gtk_window_set_resizable (GTK_WINDOW (ctbox), FALSE);
  gtk_window_set_transient_for (GTK_WINDOW(ctbox), GTK_WINDOW(MainWindow));
  graph_img[0] = g_strdup_printf ("%s", PACKAGE_GR);
  graph_img[1] = g_strdup_printf ("%s", PACKAGE_SQ);
  graph_img[2] = g_strdup_printf ("%s", PACKAGE_SQ);
  graph_img[3] = g_strdup_printf ("%s", PACKAGE_GR);
  graph_img[4] = g_strdup_printf ("%s", PACKAGE_BD);
  graph_img[5] = g_strdup_printf ("%s", PACKAGE_AN);
  graph_img[6] = g_strdup_printf ("%s", PACKAGE_RI);
  graph_img[7] = g_strdup_printf ("%s", PACKAGE_CH);
  graph_img[8] = g_strdup_printf ("%s", PACKAGE_SP);
  graph_img[9] = g_strdup_printf ("%s", PACKAGE_MS);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  for (i=0; i< NGRAPHS; i++)
  {
    expand[i] = create_expander (graph_name[i], graph_img[i], i, TRUE);
    gtk_widget_set_size_request (expand[i], 300, 20);
    gtk_container_add (GTK_CONTAINER(vbox), expand[i]);
  }
  gtk_container_add (GTK_CONTAINER(ctbox), vbox);
  gtk_widget_show_all (vbox);
  g_signal_connect(G_OBJECT(ctbox), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
  return (ctbox);
}
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list

Reply via email to