From e69af6b007c74e0f69e69aee83b647032def6f4e Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 1 Jun 2024 11:32:57 +0200 Subject: [PATCH] cleaning only; application = self << ? (contain.c line 346) --- callback.c | 13 ++++ callback.h | 50 ++++++++++++- contain.c | 212 +++++++++++++++++++++++++++++++---------------------- contain.h | 13 ++++ display.h | 2 +- 5 files changed, 202 insertions(+), 88 deletions(-) diff --git a/callback.c b/callback.c index 7a33cbe..bfd3043 100644 --- a/callback.c +++ b/callback.c @@ -27,4 +27,17 @@ void on_togglerunedit_action (GSimpleAction *action, GVariant *parameter, gpoint ui_toggle_run_edit (); } +void on_quit_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_about_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_preferences_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_togglerunstop_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_togglesidebar_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_editmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_runmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_presentmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_openfile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_closefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_savefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} +void on_toast_close_action (GSimpleAction *action, GVariant *parameter, gpointer user_data) {} + diff --git a/callback.h b/callback.h index bede566..7fc2582 100644 --- a/callback.h +++ b/callback.h @@ -1,2 +1,50 @@ -void on_togglerunedit_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void ui_enable_action (const char *name); +void ui_disable_action (const char *name); + +void set_run_edit_mode(int prescribed_mode); +int get_run_edit_mode(); + +// je vais déjà voir si j'arrive à manoeuvrer ces deux là... (2024-05-30) +// GtkWidget *btt_run_xor_edit = gtk_toggle_button_new (); +// GtkWidget *btt_run_stop_exec = gtk_toggle_button_new (); + +// https://docs.gtk.org/gio/method.ActionMap.add_action_entries.html +// A function for creating multiple GSimpleAction instances and adding them to a GActionMap. +// @see application . gem_graph_client_application_init (GemGraphClientApplication *self) { +// g_action_map_add_action_entries (G_ACTION_MAP(self), app_actions, G_N_ELEMENTS(app_actions), self); ... + void ui_toggle_run_edit(); + +void on_quit_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_about_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_preferences_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); + + // my "action of interest" : (2024-06-01) +void on_togglerunedit_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); + // +void on_togglerunstop_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_togglesidebar_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_editmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_runmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_presentmode_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_openfile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_closefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_savefile_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); +void on_toast_close_action (GSimpleAction *action, GVariant *parameter, gpointer user_data); + +static const GActionEntry app_actions[] = { + { "quit", on_quit_action, NULL, NULL, NULL }, + { "about", on_about_action, NULL, NULL, NULL }, + { "preferences", on_preferences_action, NULL, NULL, NULL }, + { "togglerunedit", on_togglerunedit_action, NULL, NULL, NULL }, + { "togglerunstop", on_togglerunstop_action, NULL, NULL, NULL }, + { "togglesidebar", on_togglesidebar_action, NULL, NULL, NULL }, + { "editmode", on_editmode_action, NULL, NULL, NULL }, + { "runmode", on_runmode_action, NULL, NULL, NULL }, + { "presentmode", on_presentmode_action, NULL, NULL, NULL }, + { "openfile", on_openfile_action, NULL, NULL, NULL }, + { "closefile", on_closefile_action, NULL, NULL, NULL }, + { "savefile", on_savefile_action, NULL, NULL, NULL }, + { "toastclose", on_toast_close_action, NULL, NULL, NULL }, +}; + diff --git a/contain.c b/contain.c index 2929e6e..f215486 100644 --- a/contain.c +++ b/contain.c @@ -168,110 +168,113 @@ GtkWidget *get_run_space_page_new(){ return GTK_WIDGET (page_box); } -GtkWidget *get_btt_run_xor_edit() { - GtkWidget *run_xor_edit = gtk_toggle_button_new (); - return GTK_WIDGET (run_xor_edit); +GtkButton *get_btt_run_xor_edit() { + GtkButton *run_xor_edit = GTK_BUTTON (gtk_toggle_button_new ()); + return run_xor_edit; +} + +static void icons_for_fun (GtkHeaderBar *header_bar) +{ + GtkButton *go_home = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (go_home, "go-home-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (go_home)); + + GtkButton *user_trash = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (user_trash, "user-trash-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (user_trash)); + + GtkButton *help_biblio = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (help_biblio, "accessories-dictionary-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_biblio)); + + GtkButton *help_doc = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (help_doc, "emblem-documents-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_doc)); + + GtkButton *help_about = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (help_about, "help-about-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_about)); + + GtkButton *help_faq = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (help_faq, "help-faq-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (help_faq)); + + GtkButton *terminal = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (terminal, "utilities-terminal-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (terminal)); + + GtkButton *search = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (search, "folder-saved-search-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (search)); + + GtkButton *preferences_desktop_appearance = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (preferences_desktop_appearance, "preferences-desktop-appearance-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_desktop_appearance)); + + GtkButton *preferences_system = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (preferences_system, "preferences-system-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (preferences_system)); + + GtkButton *document_properties = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (document_properties, "document-properties-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (document_properties)); + + GtkButton *text_edit = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (text_edit, "text-editor-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (text_edit)); + + GtkButton *applications_utilities = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (applications_utilities, "applications-utilities-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (applications_utilities)); + + GtkButton *open_menu = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (open_menu, "open-menu-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (open_menu)); + + GtkButton *power_max = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (power_max, "power-profile-performance-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_max)); + + GtkButton *power_middle = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (power_middle, "power-profile-balanced-rtl-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_middle)); + + GtkButton *power_low = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (power_low, "power-profile-power-saver-symbolic"); + gtk_header_bar_pack_end (header_bar, GTK_WIDGET (power_low)); } void window_bar(GtkWindow *window, char *title){ - GtkWidget *header_bar = gtk_header_bar_new(); + GtkWidget *header_bar = GTK_WIDGET (gtk_header_bar_new()); gtk_window_set_titlebar (window, 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); - gtk_button_set_icon_name (GTK_BUTTON (get_btt_run_xor_edit()), "document-edit-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (get_btt_run_xor_edit()), "text-editor-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (get_btt_run_xor_edit()), "system-run-symbolic"); + gtk_button_set_icon_name (get_btt_run_xor_edit(), "document-edit-symbolic"); + gtk_button_set_icon_name (get_btt_run_xor_edit(), "text-editor-symbolic"); + gtk_button_set_icon_name (get_btt_run_xor_edit(), "system-run-symbolic"); - g_signal_connect (GTK_BUTTON (get_btt_run_xor_edit()), + g_signal_connect (get_btt_run_xor_edit(), "clicked", G_CALLBACK (on_togglerunedit_action), NULL); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), get_btt_run_xor_edit()); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (get_btt_run_xor_edit())); gtk_window_set_titlebar (window, header_bar); - GtkWidget *run_stop_model_exec = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (run_stop_model_exec), "system-shutdown-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (run_stop_model_exec), "media-playback-start-symbolic"); - gtk_button_set_icon_name (GTK_BUTTON (run_stop_model_exec), "media-playback-pause-symbolic"); - gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), run_stop_model_exec); - - // https://iconduck.com/sets/adwaita-icon-theme - - GtkWidget *go_home = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (go_home), "go-home-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), go_home); - - GtkWidget *user_trash = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (user_trash), "user-trash-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), user_trash); - - GtkWidget *help_biblio = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (help_biblio), "accessories-dictionary-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), help_biblio); - - GtkWidget *help_doc = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (help_doc), "emblem-documents-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), help_doc); - - GtkWidget *help_about = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (help_about), "help-about-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), help_about); - - GtkWidget *help_faq = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (help_faq), "help-faq-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), help_faq); - - GtkWidget *terminal = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (terminal), "utilities-terminal-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), terminal); - - GtkWidget *search = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (search), "folder-saved-search-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), search); - - GtkWidget *preferences_desktop_appearance = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (preferences_desktop_appearance), "preferences-desktop-appearance-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), preferences_desktop_appearance); - - GtkWidget *preferences_system = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (preferences_system), "preferences-system-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), preferences_system); - - GtkWidget *document_properties = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (document_properties), "document-properties-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), document_properties); - - GtkWidget *text_edit = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (text_edit), "text-editor-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), text_edit); - - GtkWidget *applications_utilities = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (applications_utilities), "applications-utilities-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), applications_utilities); - - GtkWidget *open_menu = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (open_menu), "open-menu-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), open_menu); - - GtkWidget *power_max = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (power_max), "power-profile-performance-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), power_max); - - GtkWidget *power_middle = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (power_middle), "power-profile-balanced-rtl-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), power_middle); - - GtkWidget *power_low = gtk_button_new (); - gtk_button_set_icon_name (GTK_BUTTON (power_low), "power-profile-power-saver-symbolic"); - gtk_header_bar_pack_end (GTK_HEADER_BAR (header_bar), power_low); + GtkButton *run_stop_model_exec = GTK_BUTTON (gtk_button_new ()); + gtk_button_set_icon_name (run_stop_model_exec, "system-shutdown-symbolic"); + gtk_button_set_icon_name (run_stop_model_exec, "media-playback-start-symbolic"); + gtk_button_set_icon_name (run_stop_model_exec, "media-playback-pause-symbolic"); + gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), GTK_WIDGET (run_stop_model_exec)); + icons_for_fun (GTK_HEADER_BAR (header_bar)); // https://iconduck.com/sets/adwaita-icon-theme } -void activate (GtkApplication *app, gpointer user_data) { - GtkWindow *window = GTK_WINDOW (gtk_application_window_new (app)); +void activate (GtkApplication *self, gpointer user_data) { + + GtkWindow *window = GTK_WINDOW (gtk_application_window_new (self)); window_bar (window, "E coli (with permission from David S. Goodsell, 2009)"); GtkNotebook *run_notebook = GTK_NOTEBOOK(gtk_notebook_new()); @@ -306,3 +309,40 @@ void activate (GtkApplication *app, gpointer user_data) { gtk_notebook_set_current_page (edit_notebook, 1); // @see hot.c 2024-05-11 (line 68) } +/*------------------------------------------------------------------------------ + +struct _MyApplication {GtkApplication parent_instance;}; + +G_DEFINE_TYPE (MyApplication, + my_application, + GTK_TYPE_APPLICATION) + +static MyApplication *application; + +void ui_enable_action (const char *name) { + g_simple_action_set_enabled ( + (GSimpleAction *)g_action_map_lookup_action( + G_ACTION_MAP(application), + name), + true); +} + +void ui_disable_action (const char *name) { + g_simple_action_set_enabled ( + (GSimpleAction *)g_action_map_lookup_action( + G_ACTION_MAP(application), + name), + false); +} + +// Action records are registered here + +static void my_application_init (MyApplication *self) +{ + g_action_map_add_action_entries(G_ACTION_MAP(self), + app_actions, + G_N_ELEMENTS(app_actions), + self); + application = self; +} +*/ diff --git a/contain.h b/contain.h index 2909d99..daa8d2f 100644 --- a/contain.h +++ b/contain.h @@ -15,6 +15,19 @@ #define W_IMAGE_LOCAL W / 16 #define H_IMAGE_LOCAL H / 16 +/* +G_BEGIN_DECLS +#define MY_TYPE_WINDOW (my_window_get_type()) +G_DECLARE_FINAL_TYPE (MyWindow, my_window, MY, WINDOW, GtkApplicationWindow) +G_END_DECLS + +G_BEGIN_DECLS +#define MY_TYPE_APPLICATION (my_application_get_type()) +G_DECLARE_FINAL_TYPE (MyApplication, my_application, MY, APPLICATION, GtkApplication) +MyApplication *my_application_new (const char *application_id, GApplicationFlags flags); +G_END_DECLS +*/ + GtkWidget *get_selected_rules_vpaned_new(); void activate (GtkApplication *app, gpointer user_data); diff --git a/display.h b/display.h index ce8f85e..0a31695 100644 --- a/display.h +++ b/display.h @@ -30,7 +30,7 @@ GtkBox *get_XYZ_box(); GtkWidget *get_OBJECTS_and_SITUATIONS(); GtkBox *get_ELAPSED_TIME_box(); -GtkWidget *get_btt_run_xor_edit(); +GtkButton *get_btt_run_xor_edit(); void window_bar(GtkWindow *window, char *title);