367 lines
16 KiB
C
367 lines
16 KiB
C
#include <stdio.h>
|
|
#include <gtk-4.0/gtk/gtk.h>
|
|
#include "cold.h"
|
|
|
|
void print_text(GtkWidget *widget, gpointer data) {g_print (data);}
|
|
|
|
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;
|
|
}
|
|
|
|
// TODO cliquer sur "RUN" --> affiche "STOP" (et inversement)
|
|
GtkBox *get_RUN_STOP_box(){
|
|
GtkBox *RUN_STOP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2)); // spacing = 2
|
|
|
|
GtkWidget *RUN_Label = GTK_WIDGET (gtk_label_new (NULL)); // "RUN"));
|
|
const char *str = " RUN-STOP";
|
|
const char *format = "<span style=\"oblique\">\%s</span>"; // ^c^v no more...
|
|
char *markup;
|
|
|
|
markup = g_markup_printf_escaped (format, str);
|
|
gtk_label_set_markup (GTK_LABEL (RUN_Label), markup); // Sets the labels text and attributes from markup.
|
|
g_free (markup);
|
|
|
|
gtk_label_set_max_width_chars (GTK_LABEL(RUN_Label), 12);
|
|
gtk_label_set_wrap (GTK_LABEL(RUN_Label), TRUE);
|
|
gtk_label_set_xalign (GTK_LABEL(RUN_Label), 0.5); // xalign value, between 0 and 1
|
|
gtk_label_set_yalign (GTK_LABEL(RUN_Label), 0.5);
|
|
gtk_label_set_selectable (GTK_LABEL(RUN_Label), FALSE); // default = FALSE
|
|
gtk_label_set_single_line_mode (GTK_LABEL(RUN_Label), TRUE); // default = TRUE
|
|
//
|
|
gtk_box_append (RUN_STOP_box, RUN_Label);
|
|
return RUN_STOP_box;
|
|
}
|
|
|
|
GtkBox *get_STEP_by_STEP_box(){
|
|
GtkBox *STEP_by_STEP_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
|
GtkWidget *STEP_by_STEP_Label = GTK_WIDGET (gtk_label_new ("ONE\nSTEP"));
|
|
gtk_box_append (STEP_by_STEP_box, STEP_by_STEP_Label);
|
|
return STEP_by_STEP_box;
|
|
}
|
|
|
|
GtkBox *get_ZOOM_box(){
|
|
GtkBox *ZOOM_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
|
GtkWidget *ZOOM_Label = GTK_WIDGET (gtk_label_new ("ZOOM\n ---\n(space\nstruct.)"));
|
|
gtk_box_append (ZOOM_box, ZOOM_Label);
|
|
return ZOOM_box;
|
|
}
|
|
|
|
GtkBox *get_XYZ_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);
|
|
|
|
// gtk_box_set_baseline_position (XYZ_box, GTK_BASELINE_POSITION_BOTTOM);
|
|
|
|
return XYZ_box;
|
|
}
|
|
|
|
GtkBox *get_ELAPSED_TIME_box(){
|
|
GtkBox *ELAPSED_TIME_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2));
|
|
|
|
// 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);
|
|
|
|
gtk_box_append (ELAPSED_TIME_box, GTK_WIDGET(buffer));
|
|
return ELAPSED_TIME_box;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
GtkBox *get_objects_box(){
|
|
GtkBox *objects_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" membrane ")));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" co-enzyme A ")));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" ribosome ")));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" cytochrome C ")));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" ATP synthase ")));
|
|
gtk_box_append (objects_box, GTK_WIDGET (gtk_label_new (" chromosome ")));
|
|
return objects_box;
|
|
}
|
|
|
|
GtkBox *get_situations_box(){
|
|
GtkBox *situations_box = GTK_BOX(gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" transcription ")));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" épissage ")));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" translation ")));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" transport Na/K ")));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" ubiquitination ")));
|
|
gtk_box_append (situations_box, GTK_WIDGET (gtk_label_new (" rotation du moteur flagellaire ")));
|
|
return situations_box;
|
|
}
|
|
|
|
static GtkWidget *get_frame_objects(){
|
|
GtkWidget *frame_objects = gtk_frame_new (" Objects"); // defines each class of object transparence
|
|
gtk_widget_set_size_request (frame_objects, 0, H_STYLES_PANE); // < utile seulement pour la largeur min/max
|
|
gtk_frame_set_child (GTK_FRAME (frame_objects), GTK_WIDGET (get_objects_box()));
|
|
return frame_objects;
|
|
}
|
|
|
|
static GtkWidget *get_frame_situations(){
|
|
GtkWidget *frame_situations = gtk_frame_new (" Situations"); // facilitates each situation identification
|
|
gtk_widget_set_size_request (GTK_WIDGET (frame_situations), 0, H_STYLES_PANE); // < utile seulement pour la largeur min/max
|
|
gtk_frame_set_child (GTK_FRAME (frame_situations), GTK_WIDGET (get_situations_box()));
|
|
return frame_situations;
|
|
}
|
|
|
|
GtkWidget *get_objects_and_situations_horizontal_pane(){
|
|
GtkWidget *objects_and_situations_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
gtk_paned_set_start_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (get_frame_objects()));
|
|
gtk_paned_set_end_child (GTK_PANED(objects_and_situations_horizontal_pane), GTK_WIDGET (get_frame_situations()));
|
|
return objects_and_situations_horizontal_pane;
|
|
}GtkScrolledWindow *get_scrolled_gl_area(){
|
|
GtkScrolledWindow *scrolled = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new());
|
|
gtk_scrolled_window_set_min_content_width (scrolled, W_IMAGE);
|
|
gtk_scrolled_window_set_min_content_height (scrolled, H_IMAGE);
|
|
// GtkAdjustment *width = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
|
// GtkAdjustment *height = gtk_adjustment_new (600, 300, 1000, 1, 1, 1000);
|
|
// (value, lower, upper, step_increment, page_increment, page_size)
|
|
// GtkWidget *GLarea = gtk_gl_area_new();
|
|
// gtk_scrolled_window_set_child (scrolled, GLarea);
|
|
// https://docs.gtk.org/gtk4/class.GLArea.html
|
|
return scrolled;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
GtkWidget *get_edit_rules_page_new(){
|
|
GtkWidget *xxx_grid = gtk_grid_new();
|
|
return xxx_grid;
|
|
}
|
|
|
|
GtkWidget *get_edit_measures_page_new(){
|
|
GtkWidget *measures_grid = gtk_grid_new();
|
|
return measures_grid;
|
|
}
|
|
|
|
GtkWidget *get_edit_results_page_new(){
|
|
GtkWidget *xxx_grid = gtk_grid_new();
|
|
return xxx_grid;
|
|
}
|
|
|
|
GtkWidget *get_edit_discuss_page_new(){
|
|
GtkWidget *xxx_grid = gtk_grid_new();
|
|
return xxx_grid;
|
|
}
|
|
|
|
GtkWidget *get_edit_help_page_new(){
|
|
GtkWidget *xxx_grid = gtk_grid_new();
|
|
return xxx_grid;
|
|
}
|
|
|
|
GtkWidget *get_run_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_run_results_page_new(){
|
|
GtkWidget *results_grid = gtk_grid_new();
|
|
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Repartitions"), 0, 0, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Correlations"), 0, 1, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(results_grid), gtk_button_new_with_label ("Evolutions"), 0, 2, 1, 1);
|
|
return results_grid;
|
|
}
|
|
|
|
GtkWidget *get_run_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_run_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_run_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, W, H);
|
|
// gtk_widget_set_size_request (frame1, 0, H); // < 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;
|
|
}
|
|
|
|
|
|
GtkWidget *get_run_space_page_new(){
|
|
|
|
GtkWidget *space_grid = gtk_grid_new();
|
|
// attach either : get_ELAPSED_TIME_box() or get_simulation_time_extent_buffer()
|
|
// gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_ELAPSED_TIME_box()), 0, 0, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_simulation_time_extent_buffer()), 0, 0, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), get_a_space_test_image(), 0, 1, 1, 3);
|
|
gtk_grid_attach (GTK_GRID(space_grid), get_objects_and_situations_horizontal_pane(), 0, 4, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_RUN_STOP_box()), 1, 0, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), get_scroll_speed(), 1, 1, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_STEP_by_STEP_box()), 1, 2, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_XYZ_box()), 1, 3, 1, 1);
|
|
gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(get_ZOOM_box()), 1, 4, 1, 1);
|
|
// How to use gtk_separators ?
|
|
// gtk_grid_attach (GTK_GRID(space_grid), GTK_WIDGET(gtk_separator_new (GTK_ORIENTATION_HORIZONTAL)), 1, 1, 1, 1);
|
|
|
|
return space_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
|
|
// 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);
|
|
}
|
|
|
|
void activate (GtkApplication *app, gpointer user_data) {
|
|
GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app));
|
|
window_bar (window, "E coli (with permission from David S. Goodsell, 2009)");
|
|
|
|
GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
|
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(run_notebook), GTK_POS_TOP); // GTK_POS_LEFT
|
|
|
|
gtk_notebook_append_page (run_notebook, get_run_space_page_new(), gtk_label_new ("space"));
|
|
gtk_notebook_append_page (run_notebook, get_run_rules_page_new(), gtk_label_new ("rules"));
|
|
gtk_notebook_append_page (run_notebook, get_run_measures_page_new(),gtk_label_new ("measures"));
|
|
gtk_notebook_append_page (run_notebook, get_run_results_page_new(), gtk_label_new ("results"));
|
|
gtk_notebook_append_page (run_notebook, get_run_discuss_page_new(), gtk_label_new ("interpret"));
|
|
gtk_notebook_append_page (run_notebook, get_run_help_page_new(), gtk_label_new ("help"));
|
|
|
|
GtkNotebook *edit_notebook = GTK_NOTEBOOK(gtk_notebook_new());
|
|
gtk_notebook_set_tab_pos (GTK_NOTEBOOK(edit_notebook), GTK_POS_TOP); // GTK_POS_LEFT
|
|
|
|
gtk_notebook_append_page (edit_notebook, get_edit_space_page_new(), gtk_label_new ("space"));
|
|
gtk_notebook_append_page (edit_notebook, get_edit_rules_page_new(), gtk_label_new ("rules"));
|
|
gtk_notebook_append_page (edit_notebook, get_edit_measures_page_new(),gtk_label_new ("measures"));
|
|
gtk_notebook_append_page (edit_notebook, get_edit_results_page_new(), gtk_label_new ("results"));
|
|
gtk_notebook_append_page (edit_notebook, get_edit_discuss_page_new(), gtk_label_new ("interpret"));
|
|
gtk_notebook_append_page (edit_notebook, get_edit_help_page_new(), gtk_label_new ("help"));
|
|
|
|
GtkWidget *run_xor_edit_horizontal_pane = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
|
|
GtkWidget *frame_edits = gtk_frame_new ("Situations"); // facilitate each situation identification
|
|
gtk_widget_set_size_request (run_xor_edit_horizontal_pane, W_IMAGE, H_STYLES_PANE);
|
|
gtk_widget_set_size_request (GTK_WIDGET (frame_edits), 0, H_STYLES_PANE); // < utile pour la largeur min/max
|
|
gtk_paned_set_start_child (GTK_PANED(run_xor_edit_horizontal_pane), GTK_WIDGET (run_notebook));
|
|
gtk_paned_set_end_child (GTK_PANED(run_xor_edit_horizontal_pane), GTK_WIDGET (edit_notebook));
|
|
gtk_paned_set_position (GTK_PANED (run_xor_edit_horizontal_pane), W_IMAGE + 90); // ! WARNING ! '90' is AD HOC
|
|
gtk_window_set_child (window, GTK_WIDGET(run_xor_edit_horizontal_pane));
|
|
gtk_window_present (GTK_WINDOW (window));
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
/* 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
|
|
|