about the GtkStackPage enigma
This commit is contained in:
parent
40cde41b69
commit
bb8fa442a7
4
cold.c
4
cold.c
|
@ -18,10 +18,6 @@ void window_bar(GtkWindow *window, char *title){
|
||||||
gtk_window_set_titlebar (window, titlebar); // header_bar
|
gtk_window_set_titlebar (window, titlebar); // header_bar
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_grid(GtkWindow *window){
|
|
||||||
GtkWidget *grid = gtk_grid_new();
|
|
||||||
gtk_window_set_child (window, grid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
1
cold.h
1
cold.h
|
@ -5,5 +5,4 @@ void print_text(GtkWidget *widget, gpointer data);
|
||||||
void click_print_do (GtkWindow *window, GtkWidget *grid,
|
void click_print_do (GtkWindow *window, GtkWidget *grid,
|
||||||
char *label, char *text, int x, int y, int w, int h);
|
char *label, char *text, int x, int y, int w, int h);
|
||||||
void window_bar(GtkWindow *window, char *title);
|
void window_bar(GtkWindow *window, char *title);
|
||||||
void window_grid(GtkWindow *window);
|
|
||||||
|
|
||||||
|
|
31
hot.h
31
hot.h
|
@ -5,44 +5,41 @@
|
||||||
|
|
||||||
void activate (GtkApplication *app, gpointer user_data) {
|
void activate (GtkApplication *app, gpointer user_data) {
|
||||||
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
||||||
|
window_bar (window, "window");
|
||||||
GtkWidget *grid = gtk_grid_new();
|
GtkWidget *grid = gtk_grid_new();
|
||||||
|
gtk_window_set_child (window, grid);
|
||||||
|
|
||||||
click_print_do (NULL, grid, "(I)", "n°1\n", 0,0,1,1);
|
click_print_do (NULL, grid, "(I)", "n°1\n", 0,0,1,1);
|
||||||
click_print_do (NULL, grid, "(II)", "n°2\n", 1,0,1,1);
|
click_print_do (NULL, grid, "(II)", "n°2\n", 1,0,1,1);
|
||||||
click_print_do (window, grid, "Quit", "bye !...\n", 2,0,1,2);
|
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,2);
|
||||||
|
|
||||||
|
|
||||||
GtkWidget *switcher = gtk_stack_switcher_new();
|
GtkWidget *switcher = gtk_stack_switcher_new();
|
||||||
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 2, 2, 1);
|
||||||
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_VERTICAL);
|
||||||
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
||||||
GtkStack *stack = GTK_STACK (gtk_stack_new());
|
GtkStack *stack = GTK_STACK (gtk_stack_new());
|
||||||
|
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
|
||||||
|
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
|
||||||
|
|
||||||
GtkWidget *page_0 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
GtkWidget *page_0 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
||||||
GtkWidget *page_1 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
GtkWidget *page_1 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
|
||||||
GtkWidget *box_1 = gtk_box_new (0, 6); // 6 = spacing
|
|
||||||
|
|
||||||
window_bar (window, "window");
|
|
||||||
gtk_window_set_child (window, grid);
|
|
||||||
|
|
||||||
gtk_stack_add_titled (stack, page_0, "n°0", "A");
|
gtk_stack_add_titled (stack, page_0, "n°0", "A");
|
||||||
gtk_stack_add_titled (stack, page_1, "n°1", "B");
|
gtk_stack_add_titled (stack, page_1, "n°1", "B");
|
||||||
|
|
||||||
|
GtkWidget *box_1 = gtk_box_new (0, 6); // 6 = spacing
|
||||||
|
|
||||||
GtkStackPage *page_2 = gtk_stack_add_titled (stack, box_1, "any name", "C");
|
GtkStackPage *page_2 = gtk_stack_add_titled (stack, box_1, "any name", "C");
|
||||||
gtk_stack_page_set_name (page_2, "n°2");
|
gtk_stack_page_set_name (page_2, "n°2");
|
||||||
|
|
||||||
// gtk_grid_attach (GTK_GRID (grid_1), button_5, 0, 0, 1, 1);
|
printf("selected page name is [%s] (how do I get its title ?)\n",
|
||||||
|
gtk_stack_get_visible_child_name (stack));
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_VERTICAL);
|
|
||||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
|
||||||
|
|
||||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
|
|
||||||
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
|
|
||||||
|
|
||||||
GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
|
GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
|
||||||
gtk_selection_model_select_item (stack_selection_model, 2, 1);
|
gtk_selection_model_select_item (stack_selection_model, 2, 1);
|
||||||
|
|
||||||
printf("selected page name is [%s] (how do I get its title ?)\n",
|
|
||||||
gtk_stack_get_visible_child_name (stack));
|
|
||||||
// gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
// gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_CROSSFADE);
|
||||||
|
|
||||||
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 2, 2, 1);
|
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
gtk_window_present (GTK_WINDOW (window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue