2024-05-31 22:34:15 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk-4.0/gtk/gtk.h>
|
|
|
|
|
2024-06-02 22:49:16 +02:00
|
|
|
#include "tree.h"
|
2024-05-31 22:34:15 +02:00
|
|
|
#include "display.h"
|
|
|
|
#include "contain.h"
|
|
|
|
#include "texts.h"
|
2024-06-02 22:49:16 +02:00
|
|
|
#include "in_depth.h"
|
2024-05-31 22:34:15 +02:00
|
|
|
|
2024-06-02 22:14:24 +02:00
|
|
|
/******************************************************************************/
|
2024-06-02 22:49:16 +02:00
|
|
|
/* M A I N W I N D O W A C T I V A T I O N */
|
2024-06-02 22:14:24 +02:00
|
|
|
/******************************************************************************/
|
2024-06-02 22:49:16 +02:00
|
|
|
void ui_main_window (GtkApplication *self, gpointer user_data)
|
2024-06-02 22:14:24 +02:00
|
|
|
{
|
2024-06-02 22:49:16 +02:00
|
|
|
GtkWindow *main_window = GTK_WINDOW (gtk_application_window_new (self));
|
|
|
|
window_header_bar (main_window,
|
|
|
|
"E coli (with permission from David S. Goodsell, 2009)");
|
|
|
|
two_notebooks_in_two_panes (main_window);
|
|
|
|
gtk_window_present (GTK_WINDOW (main_window));
|
2024-06-02 22:14:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/* T R E E */
|
|
|
|
/******************************************************************************/
|
2024-06-03 05:46:01 +02:00
|
|
|
void on_user_tree_expander_toggled (GtkExpander *expander, gpointer user_data)
|
2024-06-02 22:14:24 +02:00
|
|
|
{
|
|
|
|
GtkTreeListRow *row = GTK_TREE_LIST_ROW (user_data);
|
|
|
|
gboolean is_expanded = gtk_tree_list_row_get_expanded(row);
|
|
|
|
gtk_tree_list_row_set_expanded (row, !is_expanded);
|
|
|
|
}
|
|
|
|
|
|
|
|
void on_bind_user_tree_factory (GtkSignalListItemFactory *factory, GObject* object, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkListItem *list_item = GTK_LIST_ITEM (object); assert (list_item);
|
2024-06-03 05:46:01 +02:00
|
|
|
GtkTreeListRow *row = gtk_list_item_get_item (list_item); assert (row); // if (row != NULL) {...} ?
|
2024-06-02 22:14:24 +02:00
|
|
|
const gchar *text = gtk_string_object_get_string (GTK_STRING_OBJECT (gtk_tree_list_row_get_item (row)));
|
|
|
|
GtkWidget *expander = gtk_list_item_get_child (list_item);
|
|
|
|
gtk_expander_set_label (GTK_EXPANDER (expander), text);
|
|
|
|
g_signal_handlers_disconnect_by_func(expander, G_CALLBACK (on_user_tree_expander_toggled), row);
|
|
|
|
g_signal_connect(expander, "activate", G_CALLBACK (on_user_tree_expander_toggled), row);
|
2024-06-03 05:46:01 +02:00
|
|
|
gtk_widget_set_margin_start(expander, gtk_tree_list_row_get_depth(row) * 20);
|
2024-05-31 22:34:15 +02:00
|
|
|
}
|
|
|
|
|
2024-06-02 22:49:16 +02:00
|
|
|
/******************************************************************************/
|
|
|
|
/* B U T T O N S */
|
|
|
|
/******************************************************************************/
|
2024-06-03 23:11:03 +02:00
|
|
|
void ui_toggle_exec_edit (GtkWidget *btt_exec_xor_edit, GtkWidget *btt_run_stop_model_exec)
|
2024-06-03 05:46:01 +02:00
|
|
|
{
|
|
|
|
if (get_exec_edit_mode()) {
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "system-run-symbolic");
|
|
|
|
set_exec_edit_mode (0);
|
|
|
|
} else {
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "document-edit-symbolic");
|
2024-06-03 06:13:03 +02:00
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_exec_xor_edit), "text-editor-symbolic"); // I hesitate
|
2024-06-03 05:46:01 +02:00
|
|
|
set_exec_edit_mode (1);
|
2024-06-03 23:11:03 +02:00
|
|
|
|
|
|
|
if (! get_run_xor_stop_exec()) { // il faudra une pop-up window, ici, TODO
|
|
|
|
// pour prévenir l'utilisateur du risque de perte des données de la simulation en cours
|
|
|
|
set_run_xor_stop_exec (0);
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-pause-symbolic");
|
|
|
|
}
|
2024-06-03 05:46:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ui_toggle_model_exec (GtkWidget *btt_run_stop_model_exec, gpointer data)
|
2024-06-02 22:49:16 +02:00
|
|
|
{
|
2024-06-03 23:11:03 +02:00
|
|
|
if (get_run_xor_stop_exec() && ! get_exec_edit_mode()) {
|
2024-06-03 05:46:01 +02:00
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-start-symbolic");
|
|
|
|
set_run_xor_stop_exec (0);
|
2024-06-02 22:49:16 +02:00
|
|
|
} else {
|
2024-06-03 05:46:01 +02:00
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (btt_run_stop_model_exec), "media-playback-pause-symbolic");
|
|
|
|
set_run_xor_stop_exec (1);
|
2024-06-02 22:49:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-03 06:13:03 +02:00
|
|
|
|