2024-04-27 16:16:21 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
2024-04-29 23:43:04 +02:00
|
|
|
#include "cold.h"
|
2024-04-27 16:16:21 +02:00
|
|
|
|
|
|
|
void print_text(GtkWidget *widget, gpointer data) {g_print (data);}
|
2024-04-28 06:21:57 +02:00
|
|
|
|
2024-05-06 12:45:24 +02:00
|
|
|
GtkWidget *get_objects_and_situations_horizontal_pane(){
|
|
|
|
GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
GtkWidget *frame_objects = gtk_frame_new ("Objects"); // define each class of object transparence
|
|
|
|
GtkWidget *frame_situations = gtk_frame_new ("Situations"); // facilitate each situation identification
|
|
|
|
gtk_widget_set_size_request (objects_and_situations_horizontal_pane, W_GL_AREA, H_STYLES_PANE);
|
|
|
|
gtk_widget_set_size_request (frame_objects, 100, H_STYLES_PANE); // < utile seulement pour la largeur min/max
|
|
|
|
gtk_widget_set_size_request (frame_situations, 100, H_STYLES_PANE); // < utile seulement pour la largeur min/max
|
|
|
|
gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (frame_objects));
|
|
|
|
gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (frame_situations));
|
|
|
|
return objects_and_situations_horizontal_pane;
|
|
|
|
}
|
|
|
|
|
2024-05-06 17:14:52 +02:00
|
|
|
GtkWidget *get_a_space_test_image(){
|
|
|
|
GtkWidget *image;
|
|
|
|
image = GTK_WIDGET(get_scrolled_gl_area());
|
|
|
|
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/aXoris.png");
|
|
|
|
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/gg sketch.png");
|
|
|
|
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli.png");
|
|
|
|
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/images/E coli resized.png");
|
|
|
|
image = gtk_picture_new_for_filename ("/home/jean/01/Gtk4/Getting_Started_with_GTK/E coli by David S. Goodsell (2009).png");
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *get_scroll_speed(){
|
|
|
|
GtkAdjustment *speed_adjust = gtk_adjustment_new (0, 0, 100, 1, 0, 0);
|
|
|
|
GtkWidget *scroll_speed = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, speed_adjust);
|
|
|
|
return scroll_speed;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkBox *get_XYZ_gtk_box(){
|
|
|
|
GtkBox *XYZ_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2
|
|
|
|
// GtkWidget *scale_X = gtk_scale_button_new (0, 360, 10, NULL); < à étudier
|
|
|
|
// (double min, double max, double step, const char** icons)
|
|
|
|
GtkAdjustment *X_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkAdjustment *Y_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkAdjustment *Z_adjust = gtk_adjustment_new (0, 0, 380, 1, 0, 0);
|
|
|
|
GtkWidget *scroll_X = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, X_adjust);
|
|
|
|
GtkWidget *scroll_Y = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Y_adjust);
|
|
|
|
GtkWidget *scroll_Z = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, Z_adjust);
|
|
|
|
|
|
|
|
gtk_box_append (XYZ_box, scroll_X);
|
|
|
|
gtk_box_append (XYZ_box, scroll_Y);
|
|
|
|
gtk_box_append (XYZ_box, scroll_Z);
|
|
|
|
|
|
|
|
return XYZ_box;
|
|
|
|
}
|
|
|
|
|
2024-05-06 12:45:24 +02:00
|
|
|
GtkProgressBar *get_simulation_time_extent_buffer(){
|
|
|
|
GtkProgressBar *buffer = GTK_PROGRESS_BAR (gtk_progress_bar_new ());
|
|
|
|
gtk_progress_bar_set_text (buffer, "<--- [buffer] (simulation extent time) --->");
|
|
|
|
gtk_progress_bar_set_show_text (buffer, TRUE);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2024-05-06 17:14:52 +02:00
|
|
|
|
2024-05-06 12:45:24 +02:00
|
|
|
GtkScrolledWindow *get_scrolled_gl_area(){
|
|
|
|
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
|
|
|
|
gtk_scrolled_window_set_min_content_width (scrolled, W_GL_AREA);
|
|
|
|
gtk_scrolled_window_set_min_content_height (scrolled, H_GL_AREA);
|
|
|
|
// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
|
|
|
// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
2024-05-06 17:14:52 +02:00
|
|
|
// (value, lower, upper, step_increment, page_increment, page_size)
|
|
|
|
// GtkWidget *GLarea = gtk_gl_area_new();
|
|
|
|
// gtk_scrolled_window_set_child (scrolled, GLarea);
|
2024-05-06 12:45:24 +02:00
|
|
|
// https://docs.gtk.org/gtk4/class.GLArea.html
|
|
|
|
return scrolled;
|
2024-04-28 06:21:57 +02:00
|
|
|
}
|
2024-05-06 12:45:24 +02:00
|
|
|
|
2024-05-06 17:14:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-01 11:01:50 +02:00
|
|
|
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));
|
2024-05-01 19:40:36 +02:00
|
|
|
gtk_widget_set_size_request (hpaned, W, H);
|
2024-05-05 20:53:52 +02:00
|
|
|
gtk_widget_set_size_request (frame1, 100, H); // < utile seulement pour la largeur min/max
|
2024-05-01 11:01:50 +02:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-28 06:21:57 +02:00
|
|
|
|
|
|
|
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
|
2024-05-06 17:14:52 +02:00
|
|
|
// GtkWidget my_window_controls = *gtk_window_controls_new (GTK_PACK_END); // _START
|
|
|
|
// gtk_window_controls_set_decoration_layout (GTK_WINDOW_CONTROLS(my_window_controls), NULL); // const char* layout);
|
2024-04-28 06:21:57 +02:00
|
|
|
}
|
|
|
|
|
2024-04-29 23:43:04 +02:00
|
|
|
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());
|
2024-05-06 12:45:24 +02:00
|
|
|
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(notebook), GTK_POS_TOP); // GTK_POS_LEFT
|
2024-04-29 23:43:04 +02:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
2024-04-28 06:21:57 +02:00
|
|
|
|
2024-05-06 12:45:24 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-04-28 08:38:55 +02:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
|
2024-04-28 11:53:35 +02:00
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-04-28 08:38:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* 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 ?
|
|
|
|
|
2024-04-29 06:03:00 +02:00
|
|
|
// https://stackoverflow.com/questions/20122232/gtklistc-code-how-to-get-the-selection-of-a-gtklist < TO CHECK
|
|
|
|
|