diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/core/panels.c | 37 | ||||
-rw-r--r-- | src/gui/core/panels.h | 3 | ||||
-rw-r--r-- | src/gui/window-int.h | 3 | ||||
-rw-r--r-- | src/gui/window.c | 82 | ||||
-rw-r--r-- | src/gui/window.h | 8 |
5 files changed, 131 insertions, 2 deletions
diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c index 3232e0c..9fca411 100644 --- a/src/gui/core/panels.c +++ b/src/gui/core/panels.c @@ -299,6 +299,43 @@ bool register_framework_panel_definition(const panel_info_t *info) * * * Paramètres : target = type de définition de panneau recherchée. * * * +* Description : Récupère les particularités d'un panneau graphique. * +* * +* Retour : Détails du comportement associé au panneau visé. * +* * +* Remarques : - * +* * +******************************************************************************/ + +FrameworkPanelPersonality get_framework_panel_personality(GType target) +{ + FrameworkPanelPersonality result; /* Propriétées à retourner */ + size_t i; /* Boucle de parcours */ + ext_panel_info_t *info; /* Informations conservées */ + + result = FPP_NONE; + + for (i = 0; i < _panels_count; i++) + { + info = _panels_list[i]; + + if (info->panel_type == target) + { + result = info->personality; + break; + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : target = type de définition de panneau recherchée. * +* * * Description : Met en place (au besoin) un panneau graphique unique. * * * * Retour : Instance de définition identifiée ou NULL en cas d'échec. * diff --git a/src/gui/core/panels.h b/src/gui/core/panels.h index 4d0ce41..e17ef8a 100644 --- a/src/gui/core/panels.h +++ b/src/gui/core/panels.h @@ -71,6 +71,9 @@ void unload_all_framework_panel_definitions(void); /* Enregistre la définition d'un panneau graphique. */ bool register_framework_panel_definition(const panel_info_t *); +/* Récupère les particularités d'un panneau graphique. */ +FrameworkPanelPersonality get_framework_panel_personality(GType); + /* Met en place (au besoin) un panneau graphique unique. */ GtkTiledPanel *get_framework_panel_singleton(GType); diff --git a/src/gui/window-int.h b/src/gui/window-int.h index b72a499..4f3dd57 100644 --- a/src/gui/window-int.h +++ b/src/gui/window-int.h @@ -38,6 +38,9 @@ struct _GtkFrameworkWindow GSettings *settings; /* Paramètres globaux */ GtkTilingGrid *grid; /* Réceptacle de panneaux */ + GtkStatusStack *status; /* Barre de statut */ + + GtkTiledPanel *main; /* Panneau principal courant */ }; diff --git a/src/gui/window.c b/src/gui/window.c index dbe7e87..e14ecf7 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -33,7 +33,6 @@ #include "panels/welcome.h" #include "../gtkext/grid.h" #include "../gtkext/helpers.h" -#include "../gtkext/statusstack.h" @@ -106,6 +105,7 @@ static void gtk_framework_window_class_init(GtkFrameworkWindowClass *class) gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/window.ui"); gtk_widget_class_bind_template_child(widget, GtkFrameworkWindow, grid); + gtk_widget_class_bind_template_child(widget, GtkFrameworkWindow, status); /* Active une action native (cf. https://docs.gtk.org/gtk4/class.Window.html#actions) */ gtk_widget_class_add_binding_action(widget, GDK_KEY_Q, GDK_CONTROL_MASK, "window.close", NULL); @@ -148,6 +148,8 @@ static void gtk_framework_window_init(GtkFrameworkWindow *window) g_settings_bind(window->settings, "window-height", G_OBJECT(window), "default-height", G_SETTINGS_BIND_DEFAULT); g_settings_bind(window->settings, "window-maximized", G_OBJECT(window), "maximized", G_SETTINGS_BIND_DEFAULT); + window->main = NULL; + g_action_map_add_action_entries(G_ACTION_MAP(window), app_entries, G_N_ELEMENTS(app_entries), window); @@ -206,6 +208,8 @@ static void gtk_framework_window_dispose(GObject *object) g_clear_object(&window->settings); + g_clear_object(&window->main); + G_OBJECT_CLASS(gtk_framework_window_parent_class)->dispose(object); } @@ -488,6 +492,31 @@ static void gtk_framework_window_activate_about(GSimpleAction *action, GVariant /****************************************************************************** * * +* Paramètres : window = instance de fenêtre principale à consulter. * +* * +* Description : Fournit une référence à la barre de statut intégrée. * +* * +* Retour : Composant GTK en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkStatusStack *gtk_framework_window_get_status_stack(const GtkFrameworkWindow *window) +{ + GtkStatusStack *result; /* Instance à retourner */ + + result = window->status; + ref_object(result); + + return result; + +} + + + +/****************************************************************************** +* * * Paramètres : window = instance de fenêtre principale à remplir. * * panel = nouveau panneau à afficher. * * * @@ -506,6 +535,7 @@ void gtk_framework_window_add(GtkFrameworkWindow *window, /* __steal */GtkTiledP guint count; /* Nombre d'élements présents */ guint i; /* Boucle de parcours */ GtkWidget *widget; /* Composant à intégrer */ + FrameworkPanelPersonality personality; /* Propriétés du panneau */ @@ -538,4 +568,54 @@ void gtk_framework_window_add(GtkFrameworkWindow *window, /* __steal */GtkTiledP } + /* Mise à jour des liens vers un panneau principal */ + + personality = get_framework_panel_personality(G_OBJECT_TYPE(panel)); + + if (personality & FPP_MAIN_PANEL) + gtk_framework_window_notify_new_main_panel_state(window, panel, true); + + else + { + if (window->main != NULL) + gtk_tiled_panel_notify_new_main_panel_state(panel, window->main, true); + } + +} + + +/****************************************************************************** +* * +* Paramètres : window = instance de fenêtre principale à manipuler. * +* main = panneau principal visé par l'opération. * +* activated = nature du changement de statut : ajout, retrait ?* +* * +* Description : Note un ajout ou un retrait de panneau principal. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_framework_window_notify_new_main_panel_state(GtkFrameworkWindow *window, GtkTiledPanel *main, bool activated) +{ + if (activated) + { + g_clear_object(&window->main); + + window->main = main; + ref_object(main); + + } + + else + { + if (main == window->main) + g_clear_object(&window->main); + + } + + gtk_tiling_grid_notify_new_main_panel_state(window->grid, main, activated); + } diff --git a/src/gui/window.h b/src/gui/window.h index 56c56ec..077d51a 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -30,6 +30,7 @@ #include "../glibext/helpers.h" #include "../gtkext/panel.h" +#include "../gtkext/statusstack.h" @@ -43,13 +44,18 @@ DECLARE_GTYPE(GtkFrameworkWindow, gtk_framework_window, GTK, FRAMEWORK_WINDOW); - /* Crée une nouvelle application principale pour Chrysalide. */ GtkApplicationWindow *gtk_framework_window_new(GtkApplication *); +/* Fournit une référence à la barre de statut intégrée. */ +GtkStatusStack *gtk_framework_window_get_status_stack(const GtkFrameworkWindow *); + /* Ajoute un panneau à la fenêtre principale de Chrysalide. */ void gtk_framework_window_add(GtkFrameworkWindow *, GtkTiledPanel *); +/* Note un ajout ou un retrait de panneau principal. */ +void gtk_framework_window_notify_new_main_panel_state(GtkFrameworkWindow *, GtkTiledPanel *, bool); + #endif /* _GUI_WINDOW_H */ |