Re: GTK3 - GtkExpander problem, bug ?
- From: cecashon aol com
- To: sebastien leroux ipcms unistra fr, gtk-app-devel-list gnome org, gtk-devel-list gnome org
- Subject: Re: GTK3 - GtkExpander problem, bug ?
- Date: Thu, 14 Dec 2017 14:28:38 -0500
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]