diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-05-22 02:37:08 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-05-22 02:37:08 (GMT) |
commit | c3fb323e06bafe2fa04a00c29cf07a7bf4e44b37 (patch) | |
tree | 7a756b9edce8262c7dfb072ecb8e003754dc0a07 | |
parent | 8ef19378427c1b2d88f72817ff2870445bf674d3 (diff) |
Notify panel [de]activations.
-rw-r--r-- | src/gtkext/dockstation.c | 51 | ||||
-rw-r--r-- | src/gtkext/dockstation.h | 4 | ||||
-rw-r--r-- | src/gtkext/grid.c | 29 | ||||
-rw-r--r-- | src/gtkext/grid.h | 3 | ||||
-rw-r--r-- | src/gtkext/panel-int.h | 4 | ||||
-rw-r--r-- | src/gtkext/panel.c | 26 | ||||
-rw-r--r-- | src/gtkext/panel.h | 2 | ||||
-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 |
12 files changed, 247 insertions, 5 deletions
diff --git a/src/gtkext/dockstation.c b/src/gtkext/dockstation.c index 359e3a1..80bae75 100644 --- a/src/gtkext/dockstation.c +++ b/src/gtkext/dockstation.c @@ -259,7 +259,7 @@ GtkWidget *gtk_dock_station_new(void) /****************************************************************************** * * -* Paramètres : station = station d'accueil pour panneau à compléter. * +* Paramètres : station = station d'accueil pour panneaux à compléter. * * panel = nouveau panneau à afficher. * * * * Description : Ajoute un panneau à un groupe de tuiles. * @@ -293,7 +293,7 @@ void gtk_dock_station_add_panel(GtkDockStation *station, GtkTiledPanel *panel) /****************************************************************************** * * -* Paramètres : station = station d'accueil pour panneau à compléter. * +* Paramètres : station = station d'accueil pour panneaux à compléter. * * panel = nouveau panneau à afficher. * * * * Description : Ajoute un panneau à conserver à un groupe de tuiles. * @@ -332,7 +332,7 @@ void gtk_dock_station_keep_panel(GtkDockStation *station, GtkTiledPanel *panel) /****************************************************************************** * * -* Paramètres : station = station d'accueil pour panneau à consulter. * +* Paramètres : station = station d'accueil pour panneaux à consulter. * * * * Description : Indique si la station d'accueil contient au moins un panneau.* * * @@ -361,6 +361,51 @@ bool gtk_dock_station_is_empty(const GtkDockStation *station) } +/****************************************************************************** +* * +* Paramètres : station = station d'accueil pour panneaux à 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_dock_station_notify_new_main_panel_state(const GtkDockStation *station, GtkTiledPanel *main, bool activated) +{ + GListModel *list; /* Liste de pages à parcourir */ + guint count; /* Nombre de pages */ + guint i; /* Boucle de parcours */ + GtkStackPage *page; /* Page à consulter */ + GtkWidget *panel; /* Panneau intégré */ + + list = G_LIST_MODEL(gtk_stack_get_pages(station->stack)); + + count = g_list_model_get_n_items(list); + + for (i = 0; i < count; i++) + { + page = GTK_STACK_PAGE(g_list_model_get_object(list, i)); + if (page == NULL) continue; + + panel = gtk_stack_page_get_child(page); + + gtk_tiled_panel_notify_new_main_panel_state(GTK_TILED_PANEL(panel), main, activated); + + unref_object(page); + + } + + unref_object(list); + +} + + + /* ---------------------------------------------------------------------------------- */ /* IMPLEMENTATION DES FONCTIONS DE CLASSE */ /* ---------------------------------------------------------------------------------- */ diff --git a/src/gtkext/dockstation.h b/src/gtkext/dockstation.h index 3106dae..e4c849f 100644 --- a/src/gtkext/dockstation.h +++ b/src/gtkext/dockstation.h @@ -50,6 +50,10 @@ void gtk_dock_station_keep_panel(GtkDockStation *, GtkTiledPanel *); /* Indique si la station d'accueil contient au moins un panneau. */ bool gtk_dock_station_is_empty(const GtkDockStation *); +/* Note un ajout ou un retrait de panneau principal. */ +void gtk_dock_station_notify_new_main_panel_state(const GtkDockStation *, GtkTiledPanel *, bool); + + #if 0 diff --git a/src/gtkext/grid.c b/src/gtkext/grid.c index afc74b7..eb3cdf9 100644 --- a/src/gtkext/grid.c +++ b/src/gtkext/grid.c @@ -544,6 +544,35 @@ void gtk_tiling_grid_add_panel(GtkTilingGrid *grid, GtkTiledPanel *panel, bool k /****************************************************************************** * * +* Paramètres : grid = zone d'affichage en tuiles à 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_tiling_grid_notify_new_main_panel_state(const GtkTilingGrid *grid, GtkTiledPanel *main, bool activated) +{ + gtk_dock_station_notify_new_main_panel_state(grid->top_station, main, activated); + + gtk_dock_station_notify_new_main_panel_state(grid->left_station, main, activated); + + gtk_dock_station_notify_new_main_panel_state(grid->main_station, main, activated); + + gtk_dock_station_notify_new_main_panel_state(grid->right_station, main, activated); + + gtk_dock_station_notify_new_main_panel_state(grid->bottom_station, main, activated); + +} + + +/****************************************************************************** +* * * Paramètres : station = plateforme GTK ayant connu un changement. * * widget = nouvel élément à intégrer. * * grid = gestionnaire de placement en tuile concerné. * diff --git a/src/gtkext/grid.h b/src/gtkext/grid.h index f02cf38..fd98035 100644 --- a/src/gtkext/grid.h +++ b/src/gtkext/grid.h @@ -66,6 +66,9 @@ bool gtk_tiling_grid_get_visible(GtkTilingGrid *, TilingGridBorder); /* Ajoute un panneau à un conteneur en tuiles. */ void gtk_tiling_grid_add_panel(GtkTilingGrid *, GtkTiledPanel *, bool); +/* Note un ajout ou un retrait de panneau principal. */ +void gtk_tiling_grid_notify_new_main_panel_state(const GtkTilingGrid *, GtkTiledPanel *, bool); + /* --------------------- FORME GENERIQUE DE MISE EN DISPOSITION --------------------- */ diff --git a/src/gtkext/panel-int.h b/src/gtkext/panel-int.h index cb210d9..5398e51 100644 --- a/src/gtkext/panel-int.h +++ b/src/gtkext/panel-int.h @@ -36,6 +36,8 @@ typedef char * (* get_tiled_panel_path) (const GtkTiledPanel *); /* Fournit les composants adaptés pour la barre de titre. */ typedef GListStore * (* get_tiled_panel_widgets_cb) (const GtkTiledPanel *, bool); +/* Note un ajout ou un retrait de panneau principal. */ +typedef void (* notify_tiled_panel_state_cb) (GtkTiledPanel *, GtkTiledPanel *, bool); /* Elément réactif pour panneaux de l'éditeur (instance) */ @@ -53,6 +55,8 @@ struct _GtkTiledPanelClass get_tiled_panel_path get_default_path; /* Localisation de l'affichage */ get_tiled_panel_widgets_cb get_widgets; /* Récupération de composants */ + notify_tiled_panel_state_cb notify; /* Note d'un ajout ou retrait */ + }; diff --git a/src/gtkext/panel.c b/src/gtkext/panel.c index 48019dc..f63cfa1 100644 --- a/src/gtkext/panel.c +++ b/src/gtkext/panel.c @@ -193,6 +193,32 @@ GListStore *gtk_tiled_panel_get_title_widgets(const GtkTiledPanel *panel, bool l } +/****************************************************************************** +* * +* Paramètres : panel = panneau graphique à 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_tiled_panel_notify_new_main_panel_state(GtkTiledPanel *panel, GtkTiledPanel *main, bool activated) +{ + GtkTiledPanelClass *class; /* Classe à actionner */ + + class = GTK_TILED_PANEL_GET_CLASS(panel); + + if (class->notify != NULL) + class->notify(panel, main, activated); + +} + + diff --git a/src/gtkext/panel.h b/src/gtkext/panel.h index 3b0361e..9b00657 100644 --- a/src/gtkext/panel.h +++ b/src/gtkext/panel.h @@ -44,6 +44,8 @@ char *gtk_tiled_panel_get_path(const GtkTiledPanel *); /* Fournit les composants adaptés pour la barre de titre. */ GListStore *gtk_tiled_panel_get_title_widgets(const GtkTiledPanel *, bool); +/* Note un ajout ou un retrait de panneau principal. */ +void gtk_tiled_panel_notify_new_main_panel_state(GtkTiledPanel *, GtkTiledPanel *, bool); 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 */ |