problem solved using gtk_notebook
This commit is contained in:
parent
3e1c51dff5
commit
92cc46c9ac
2
cold.c
2
cold.c
|
@ -68,3 +68,5 @@ void window_bar(GtkWindow *window, char *title){
|
||||||
|
|
||||||
// how do I attach a widget to a page ?
|
// how do I attach a widget to a page ?
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/20122232/gtklistc-code-how-to-get-the-selection-of-a-gtklist < TO CHECK
|
||||||
|
|
||||||
|
|
51
hot.h
51
hot.h
|
@ -3,53 +3,4 @@
|
||||||
#include "warm.h"
|
#include "warm.h"
|
||||||
#include "cold.h"
|
#include "cold.h"
|
||||||
|
|
||||||
void activate (GtkApplication *app, gpointer user_data) {
|
void activate (GtkApplication *app, gpointer user_data);
|
||||||
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
|
||||||
window_bar (window, "window");
|
|
||||||
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, "(II)", "n°2\n", 1,0,1,1);
|
|
||||||
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,1);
|
|
||||||
|
|
||||||
GtkWidget *switcher = gtk_stack_switcher_new();
|
|
||||||
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
|
||||||
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 1, 3, 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());
|
|
||||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
|
|
||||||
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
|
|
||||||
|
|
||||||
GtkWidget *box_0 = gtk_box_new (0, 0);
|
|
||||||
GtkWidget *box_1 = gtk_box_new (0, 0);
|
|
||||||
GtkWidget *box_2 = gtk_box_new (0, 0);
|
|
||||||
gtk_stack_add_titled (stack, box_0, "n°0", "A");
|
|
||||||
gtk_stack_add_titled (stack, box_1, "n°1", "B");
|
|
||||||
gtk_stack_add_titled (stack, box_2, "n°2", "C");
|
|
||||||
GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
|
|
||||||
gtk_selection_model_select_item (stack_selection_model, 1, 1);
|
|
||||||
printf("selected page name is [%s] \n", gtk_stack_get_visible_child_name (stack));
|
|
||||||
|
|
||||||
GtkWidget *box_3 = gtk_box_new (0, 0);
|
|
||||||
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("30"));
|
|
||||||
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("31"));
|
|
||||||
gtk_grid_attach (GTK_GRID (grid), box_3, 0, 2, 1, 1);
|
|
||||||
|
|
||||||
GtkWidget *grid_2 = gtk_grid_new();
|
|
||||||
GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
||||||
GtkWidget *frame1 = gtk_frame_new ("hello ?");
|
|
||||||
GtkWidget *frame2 = gtk_frame_new ("it's me !");
|
|
||||||
gtk_frame_set_child ( GTK_FRAME(frame2), grid_2);
|
|
||||||
gtk_paned_set_start_child (GTK_PANED(hpaned), GTK_WIDGET (frame1));
|
|
||||||
gtk_paned_set_end_child (GTK_PANED(hpaned), GTK_WIDGET (frame2));
|
|
||||||
gtk_widget_set_size_request (hpaned, 400, 200);
|
|
||||||
// gtk_widget_set_size_request (frame1, 50, 100); < utile seulement pour la largeur min/max
|
|
||||||
// gtk_widget_set_size_request (frame2, 50, 100);
|
|
||||||
gtk_grid_attach (GTK_GRID (grid), hpaned, 0, 3, 3, 1);
|
|
||||||
gtk_grid_attach (GTK_GRID (grid_2), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1);
|
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (window));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
106
warm.c
106
warm.c
|
@ -1,3 +1,109 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <gtk-4.0/gtk/gtk.h>
|
#include <gtk-4.0/gtk/gtk.h>
|
||||||
|
#include "cold.h"
|
||||||
|
|
||||||
|
void activate (GtkApplication *app, gpointer user_data) {
|
||||||
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
||||||
|
window_bar (window, "window");
|
||||||
|
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, "(II)", "n°2\n", 1,0,1,1);
|
||||||
|
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,1);
|
||||||
|
|
||||||
|
GtkWidget *grid_2 = gtk_grid_new();
|
||||||
|
GtkWidget* notebook = gtk_notebook_new ();
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), notebook, 0, 3, 1, 1);
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), grid_2, gtk_label_new ("hello !"));
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK(notebook), gtk_button_new_with_label ("me too !"), NULL);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid_2), gtk_button_new_with_label ("here am I !"), 0, 0, 1, 1);
|
||||||
|
|
||||||
|
GtkWidget *box_3 = gtk_box_new (0, 0);
|
||||||
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("30"));
|
||||||
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("31"));
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), box_3, 0, 2, 1, 1);
|
||||||
|
|
||||||
|
GtkWidget *grid_3 = gtk_grid_new();
|
||||||
|
GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
GtkWidget *frame1 = gtk_frame_new ("hello ?");
|
||||||
|
GtkWidget *frame2 = gtk_frame_new ("it's me !");
|
||||||
|
gtk_frame_set_child ( GTK_FRAME(frame2), grid_3);
|
||||||
|
gtk_paned_set_start_child (GTK_PANED(hpaned), GTK_WIDGET (frame1));
|
||||||
|
gtk_paned_set_end_child (GTK_PANED(hpaned), GTK_WIDGET (frame2));
|
||||||
|
gtk_widget_set_size_request (hpaned, 400, 200);
|
||||||
|
// gtk_widget_set_size_request (frame1, 50, 100); < utile seulement pour la largeur min/max
|
||||||
|
// gtk_widget_set_size_request (frame2, 50, 100);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), hpaned, 0, 4, 3, 1);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid_3), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1);
|
||||||
|
|
||||||
|
gtk_window_present (GTK_WINDOW (window));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
static void activate_old (GtkApplication *app, gpointer user_data) {
|
||||||
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
||||||
|
window_bar (window, "window");
|
||||||
|
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, "(II)", "n°2\n", 1,0,1,1);
|
||||||
|
click_print_do (window, grid, "Quit", "bye !\n", 2,0,1,1);
|
||||||
|
|
||||||
|
GtkWidget *switcher = gtk_stack_switcher_new();
|
||||||
|
// GtkWidget *sidebar = gtk_stack_sidebar_new();
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), switcher, 0, 1, 3, 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());
|
||||||
|
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
|
||||||
|
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
|
||||||
|
|
||||||
|
GtkWidget *box_0 = gtk_box_new (0, 0);
|
||||||
|
GtkWidget *box_1 = gtk_box_new (0, 0);
|
||||||
|
GtkWidget *box_2 = gtk_box_new (0, 0);
|
||||||
|
gtk_stack_add_titled (stack, box_0, "n°0", "A");
|
||||||
|
gtk_stack_add_titled (stack, box_1, "n°1", "B");
|
||||||
|
gtk_stack_add_titled (stack, box_2, "n°2", "C");
|
||||||
|
GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
|
||||||
|
gtk_selection_model_select_item (stack_selection_model, 1, 1);
|
||||||
|
printf("selected page name is [%s] \n", gtk_stack_get_visible_child_name (stack));
|
||||||
|
GtkWidget *grid_3 = gtk_grid_new();
|
||||||
|
gtk_grid_attach (GTK_GRID (grid_3), gtk_button_new_with_label ("0,0 1,1"), 0, 0, 1, 1);
|
||||||
|
gtk_stack_add_child (stack, grid_3);
|
||||||
|
// gtk_stack_page_set_visible (GTK_STACK_PAGE(stack_selection_model_get_item()), TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
GtkWidget *box_3 = gtk_box_new (0, 0);
|
||||||
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("30"));
|
||||||
|
gtk_box_append (GTK_BOX (box_3), gtk_button_new_with_label ("31"));
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), box_3, 0, 2, 1, 1);
|
||||||
|
|
||||||
|
GtkWidget *grid_2 = gtk_grid_new();
|
||||||
|
GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
||||||
|
GtkWidget *frame1 = gtk_frame_new ("hello ?");
|
||||||
|
GtkWidget *frame2 = gtk_frame_new ("it's me !");
|
||||||
|
gtk_frame_set_child ( GTK_FRAME(frame2), grid_2);
|
||||||
|
gtk_paned_set_start_child (GTK_PANED(hpaned), GTK_WIDGET (frame1));
|
||||||
|
gtk_paned_set_end_child (GTK_PANED(hpaned), GTK_WIDGET (frame2));
|
||||||
|
gtk_widget_set_size_request (hpaned, 400, 200);
|
||||||
|
// gtk_widget_set_size_request (frame1, 50, 100); < utile seulement pour la largeur min/max
|
||||||
|
// gtk_widget_set_size_request (frame2, 50, 100);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), hpaned, 0, 3, 3, 1);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid_2), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1);
|
||||||
|
|
||||||
|
gtk_window_present (GTK_WINDOW (window));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue