#include #include #include "cold.h" void print_text(GtkWidget *widget, gpointer data) {g_print (data);} void click_print_do (GtkWindow *window, GtkWidget *grid, char *label, char *text, int x, int y, int w, int h){ GtkWidget *button = gtk_button_new_with_label (label); gtk_grid_attach (GTK_GRID (grid), button, x, y, w, h); g_signal_connect (button, "clicked", G_CALLBACK (print_text), text); if (window) g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); } GtkWidget *get_measures_page_new(){ GtkWidget *measures_grid = gtk_grid_new(); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("movements"), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transports"), 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("transformations"), 2, 0, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("objects"), 0, 1, 1, 1); gtk_grid_attach (GTK_GRID (measures_grid), gtk_button_new_with_label ("situations"), 1, 1, 1, 1); return measures_grid; } GtkWidget *get_results_page_new(){ GtkWidget *results_grid = gtk_grid_new(); gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Here are some results :"), 0, 0, 1, 1); return results_grid; } GtkWidget *get_discuss_page_new(){ GtkWidget *discuss_grid = gtk_grid_new(); gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Interpretations"), 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (discuss_grid), gtk_button_new_with_label ("Discussions"), 0, 1, 1, 1); return discuss_grid; } GtkWidget *get_help_page_new(){ GtkWidget *help_grid = gtk_grid_new(); gtk_grid_attach (GTK_GRID (help_grid), gtk_button_new_with_label ("Can I help you ?"), 0, 0, 1, 1); return help_grid; } GtkWidget *get_rules_page_new(){ GtkWidget *rules_grid = gtk_grid_new(); GtkWidget *hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_grid_attach (GTK_GRID (rules_grid), hpaned, 0, 0, 1, 1); GtkWidget *frame1 = gtk_frame_new ("hello ?"); GtkWidget *frame2 = gtk_frame_new ("it's me !"); GtkWidget *grid_3 = gtk_grid_new(); 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, 600, 600); gtk_widget_set_size_request (frame1, 100, 0); // < utile seulement pour la largeur min/max // gtk_widget_set_size_request (frame2, 50, 100); // gtk_grid_attach (GTK_GRID (rules_grid), hpaned, 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid_3), gtk_button_new_with_label ("in the right pane"), 0, 0, 1, 1); return rules_grid; } void window_bar(GtkWindow *window, char *title){ GtkWidget *titlebar = gtk_header_bar_new(); gtk_window_set_title (window, title); gtk_window_set_titlebar (window, titlebar); // header_bar } void activate (GtkApplication *app, gpointer user_data) { GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app)); window_bar (window, "window"); GtkNotebook *notebook = GTK_NOTEBOOK(gtk_notebook_new()); gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook), GTK_POS_LEFT); gtk_notebook_append_page (notebook, get_space_page_new(), gtk_label_new ("space")); gtk_notebook_append_page (notebook, get_rules_page_new(), gtk_label_new ("rules")); gtk_notebook_append_page (notebook, get_measures_page_new(),gtk_label_new ("measures")); gtk_notebook_append_page (notebook, get_results_page_new(), gtk_label_new ("results")); gtk_notebook_append_page (notebook, get_discuss_page_new(), gtk_label_new ("interpret")); gtk_notebook_append_page (notebook, get_help_page_new(), gtk_label_new ("help")); gtk_window_set_child (window, GTK_WIDGET(notebook)); gtk_window_present (GTK_WINDOW (window)); } /*----------------------------------------------------------------------------*/ /* GtkBox GtkGrid GtkRevealer GtkStack * GtkOverlay GtkPaned GtkExpander GtkFixed */ /* GtkBox * int spacing = 8; * box = gtk_box_new (0, spacing); * 0 = GTK_ORIENTATION_HORIZONTAL, 1 = GTK_ORIENTATION_VERTICAL * gtk_widget_set_halign (box, GTK_ALIGN_FILL); * gtk_widget_set_valign (box, GTK_ALIGN_CENTER); * START CENTER END FILL * * gtk_window_set_child (GTK_WINDOW (window), box); * gtk_box_append (GTK_BOX (box), button); */ /* grid = gtk_grid_new (); gtk_window_set_child (GTK_WINDOW (window), grid); button = gtk_button_new_with_label (" I "); n fois gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1); n fois */ /* * gtk_paned_new (GTK_ORIENTATION_VERTICAL or GTK_ORIENTATION_VERTICAL) * GtkPaned has two panes, arranged either horizontally or vertically. * The division between the two panes is adjustable by the user by dragging a handle. * Child widgets are added to the panes of the widget * with gtk_paned_pack1() and gtk_paned_pack2(). */ /* * GtkWidget* gtk_box_new (GtkOrientation orientation, gint spacing) */ /* TODO or NOT TODO * * GtkRevealer *revealer = gtk_revealer_new(); * gtk_revealer_set_child (GTK_ ? (revealer), box); * gtk_revealer_set_transition_type (revealer, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN); * */ // GtkWidget *overlay = gtk_overlay_new(); // gtk_overlay_set_buildable_id (GTK_BUILDABLE(overlay), "overlay id"); // printf("overlay %s\n", gtk_buildable_get_buildable_id (GTK_BUILDABLE(overlay))); // 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