diff options
Diffstat (limited to 'src/gtkext')
| -rw-r--r-- | src/gtkext/area.c | 2 | ||||
| -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/hexview.c | 287 | ||||
| -rw-r--r-- | src/gtkext/hexview.h | 6 | ||||
| -rw-r--r-- | src/gtkext/hexview.ui | 52 | ||||
| -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/gtkext/statusstack-int.h | 6 | ||||
| -rw-r--r-- | src/gtkext/statusstack.c | 138 | ||||
| -rw-r--r-- | src/gtkext/statusstack.h | 10 | ||||
| -rw-r--r-- | src/gtkext/statusstack.ui | 9 |
15 files changed, 517 insertions, 112 deletions
diff --git a/src/gtkext/area.c b/src/gtkext/area.c index 3c59a59..3c573b2 100644 --- a/src/gtkext/area.c +++ b/src/gtkext/area.c @@ -85,6 +85,8 @@ static void gtk_composing_area_class_init(GtkComposingAreaClass *class) widget = GTK_WIDGET_CLASS(class); + gtk_widget_class_set_css_name(widget, "comparea"); + widget->snapshot = gtk_composing_area_snapshot; } 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/hexview.c b/src/gtkext/hexview.c index 5a8dd04..95b592e 100644 --- a/src/gtkext/hexview.c +++ b/src/gtkext/hexview.c @@ -37,6 +37,22 @@ /* ------------------------- BASES D'UN COMPOSANT GRAPHIQUE ------------------------- */ +/* Liste des propriétés */ + +typedef enum _HexViewProperty { + + PROP_0, /* Réservé */ + + PROP_SHOW_OFFSETS, /* Affichage des positions */ + PROP_CONTENT, /* Contenu binaire affiché */ + + N_PROPERTIES + +} HexViewProperty; + +static GParamSpec *_hex_view_properties[N_PROPERTIES] = { NULL, }; + + /* Initialise la classe des afficheurs de tampons bruts. */ static void gtk_hex_view_class_init(GtkHexViewClass *); @@ -44,10 +60,10 @@ static void gtk_hex_view_class_init(GtkHexViewClass *); static void gtk_hex_view_init(GtkHexView *); /* Supprime toutes les références externes. */ -static void gtk_hex_view_dispose(GtkHexView *); +static void gtk_hex_view_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void gtk_hex_view_finalize(GtkHexView *); +static void gtk_hex_view_finalize(GObject *); /* Procède à l'actualisation de l'affichage d'un sous-composant. */ static void gtk_hex_view_dispatch_sub_snapshot(GtkWidget *, GtkSnapshot *, GtkWidget *); @@ -57,14 +73,14 @@ static void gtk_hex_view_populate_cache(GtkHexView *); -void demo_snapshot (GtkWidget *widget, GtkSnapshot *snapshot, GtkWidget *parent); - - - +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ -/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ +/* Met à jour une propriété d'instance GObject. */ +static void gtk_hex_view_set_property(GObject *, guint, const GValue *, GParamSpec *); +/* Fournit la valeur d'une propriété d'instance GObject. */ +static void gtk_hex_view_get_property(GObject *, guint, GValue *, GParamSpec *); /* Prend acte de la taille allouée au composant d'affichage. */ static void gtk_hex_view_size_allocate(GtkWidget *, int, int, int); @@ -105,12 +121,26 @@ static void gtk_hex_view_class_init(GtkHexViewClass *class) object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)gtk_hex_view_dispose; - object->finalize = (GObjectFinalizeFunc)gtk_hex_view_finalize; + object->dispose = gtk_hex_view_dispose; + object->finalize = gtk_hex_view_finalize; + object->set_property = gtk_hex_view_set_property; + object->get_property = gtk_hex_view_get_property; + + _hex_view_properties[PROP_SHOW_OFFSETS] = + g_param_spec_boolean("show-offsets", NULL, NULL, + TRUE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + _hex_view_properties[PROP_CONTENT] = + g_param_spec_object("content", NULL, NULL, + G_TYPE_BIN_CONTENT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + + g_object_class_install_properties(object, N_PROPERTIES, _hex_view_properties); widget = GTK_WIDGET_CLASS(class); - // REMME gtk_widget_class_set_css_name(widget, "GtkHexView"); + gtk_widget_class_set_css_name(widget, "hexview"); g_type_ensure(GTK_TYPE_COMPOSING_AREA); @@ -167,12 +197,14 @@ static void gtk_hex_view_init(GtkHexView *view) view->generator = NULL; + gtk_hex_view_create(view, NULL); + } /****************************************************************************** * * -* Paramètres : view = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * @@ -182,20 +214,24 @@ static void gtk_hex_view_init(GtkHexView *view) * * ******************************************************************************/ -static void gtk_hex_view_dispose(GtkHexView *view) +static void gtk_hex_view_dispose(GObject *object) { - gtk_widget_dispose_template(GTK_WIDGET(view), GTK_TYPE_HEX_VIEW); + GtkHexView *view; /* Version spécialisée */ + + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_HEX_VIEW); + + view = GTK_HEX_VIEW(object); g_clear_object(&view->generator); - G_OBJECT_CLASS(gtk_hex_view_parent_class)->dispose(G_OBJECT(view)); + G_OBJECT_CLASS(gtk_hex_view_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : view = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * @@ -205,9 +241,9 @@ static void gtk_hex_view_dispose(GtkHexView *view) * * ******************************************************************************/ -static void gtk_hex_view_finalize(GtkHexView *view) +static void gtk_hex_view_finalize(GObject *object) { - G_OBJECT_CLASS(gtk_hex_view_parent_class)->finalize(G_OBJECT(view)); + G_OBJECT_CLASS(gtk_hex_view_parent_class)->finalize(object); } @@ -263,13 +299,43 @@ bool gtk_hex_view_create(GtkHexView *view, GBinContent *content) parent = GTK_BUFFER_VIEW(view); - cache = g_buffer_cache_new(1, 2); + cache = g_buffer_cache_new(1 /* opt_count */, 2 /* reg_count */); parent->view = g_buffer_view_new(cache, parent->style); unref_object(cache); - view->generator = g_hex_generator_new(content); + + + gtk_hex_view_set_content(view, content); + + + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : view = composant d'affichage à consulter. * +* * +* Description : Fournit le contenu associé au composant d'affichage. * +* * +* Retour : Contenu dans lequel puise le générateur pour les lignes. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GBinContent *gtk_hex_view_get_content(const GtkHexView *view) +{ + GBinContent *result; /* Référence à retourner */ + + if (view->generator != NULL) + result = g_hex_generator_get_content(view->generator); + else + result = NULL; return result; @@ -278,6 +344,61 @@ bool gtk_hex_view_create(GtkHexView *view, GBinContent *content) /****************************************************************************** * * +* Paramètres : view = composant d'affichage à modifier. * +* content = nouveau contenu pour source de génération. * +* * +* Description : Définit le contenu associé au composant d'affichage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_hex_view_set_content(GtkHexView *view, GBinContent *content) +{ + GBinContent *old; /* Ancienne valeur */ + GBufferCache *cache; /* Tampon à représenter */ + + old = gtk_hex_view_get_content(view); + + assert((old == NULL && view->generator == NULL) || (old != NULL && view->generator != NULL)); + + if (old != content) + { + if (view->generator != NULL) + { + cache = g_buffer_view_get_cache(GTK_BUFFER_VIEW(view)->view); + + g_buffer_cache_wlock(cache); + + g_buffer_cache_truncate(cache, 0); + + g_buffer_cache_wunlock(cache); + + unref_object(cache); + + g_clear_object(&view->generator); + + } + + if (content != NULL) + view->generator = g_hex_generator_new(content); + + g_object_notify_by_pspec(G_OBJECT(view), _hex_view_properties[PROP_CONTENT]); + + assert(content != NULL); + gtk_widget_queue_resize(GTK_WIDGET(view)); + + } + + g_clear_object(&old); + +} + + +/****************************************************************************** +* * * Paramètres : widget = composant GTK à redessiner. * * snapshot = gestionnaire de noeuds de rendu à solliciter. * * parent = composant GTK parent et cadre de l'appel. * @@ -380,60 +501,101 @@ static void gtk_hex_view_populate_cache(GtkHexView *view) /* Mise à jour de l'affichage ? */ + /* if (needed != count) gtk_widget_queue_resize(GTK_WIDGET(view)); + */ } +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à mamnipuler. * +* prop_id = identifiant de la propriété visée. * +* value = valeur à prendre en compte. * +* pspec = définition de la propriété. * +* * +* Description : Met à jour une propriété d'instance GObject. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - -void demo_snapshot (GtkWidget *widget, GtkSnapshot *snapshot, GtkWidget *parent) +static void gtk_hex_view_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - GdkRGBA red, green, yellow, blue; - float w, h; - - gdk_rgba_parse (&red, "red"); - gdk_rgba_parse (&green, "green"); - gdk_rgba_parse (&yellow, "yellow"); - gdk_rgba_parse (&blue, "blue"); + GtkHexView *view; /* Version spécialisée */ + GObject *content; /* Contenu sous forme simple */ - w = gtk_widget_get_width (widget) / 2.0; - h = gtk_widget_get_height (widget) / 2.0; + view = GTK_HEX_VIEW(object); - h /= 2.0; + switch (prop_id) + { + case PROP_SHOW_OFFSETS: + g_display_options_set(GTK_CONTENT_VIEW(view)->options, HCO_OFFSET, g_value_get_boolean(value)); + gtk_widget_set_visible(view->offsets, g_value_get_boolean(value)); + break; - gtk_snapshot_append_color (snapshot, &red, - &GRAPHENE_RECT_INIT(0, 0, w, h)); - gtk_snapshot_append_color (snapshot, &green, - &GRAPHENE_RECT_INIT(w, 0, w, h)); - gtk_snapshot_append_color (snapshot, &yellow, - &GRAPHENE_RECT_INIT(0, h, w, h)); - gtk_snapshot_append_color (snapshot, &blue, - &GRAPHENE_RECT_INIT(w, h, w, h)); + case PROP_CONTENT: + content = g_value_get_object(value); + gtk_hex_view_set_content(view, G_BIN_CONTENT(content)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } } +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à mamnipuler. * +* prop_id = identifiant de la propriété visée. * +* value = valeur à transmettre. [OUT] * +* pspec = définition de la propriété. * +* * +* Description : Fournit la valeur d'une propriété d'instance GObject. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ +static void gtk_hex_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GtkHexView *view; /* Version spécialisée */ + view = GTK_HEX_VIEW(object); + switch (prop_id) + { + case PROP_SHOW_OFFSETS: + g_value_set_boolean(value, gtk_widget_get_visible(view->offsets)); + break; + case PROP_CONTENT: + g_value_take_object(value, gtk_hex_view_get_content(view)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } - - - - -/* ---------------------------------------------------------------------------------- */ -/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ -/* ---------------------------------------------------------------------------------- */ +} /****************************************************************************** @@ -467,7 +629,13 @@ static void gtk_hex_view_size_allocate(GtkWidget *widget, int width, int height, final_widths = alloca(_CHILDREN_COUNT * sizeof(int)); for (i = 0; i < _CHILDREN_COUNT; i++) - gtk_widget_measure(view->children[i], GTK_ORIENTATION_HORIZONTAL, -1, &min_widths[i], NULL, NULL, NULL); + { + if (!gtk_widget_get_visible(view->children[i])) + min_widths[i] = 0; + else + gtk_widget_measure(view->children[i], GTK_ORIENTATION_HORIZONTAL, -1, &min_widths[i], NULL, NULL, NULL); + + } /* Passe 1 : tentative sans défilement vertical */ @@ -491,7 +659,10 @@ static void gtk_hex_view_size_allocate(GtkWidget *widget, int width, int height, for (i = 0; i < _CHILDREN_COUNT; i++) { - final_widths[i] += min_widths[i]; + if (!gtk_widget_get_visible(view->children[i])) + final_widths[i] = 0; + else + final_widths[i] += min_widths[i]; g_width_tracker_set_column_min_width(tracker, i, final_widths[i]); @@ -531,17 +702,6 @@ static GtkSizeRequestMode gtk_hex_view_get_request_mode(GtkWidget *widget) } - - - - - - - - - - - /****************************************************************************** * * * Paramètres : widget = composant GTK à examiner. * @@ -580,8 +740,12 @@ static void gtk_hex_view_measure(GtkWidget *widget, GtkOrientation orientation, for (i = 0; i < _CHILDREN_COUNT; i++) { + if (!gtk_widget_get_visible(view->children[i])) + continue; + gtk_widget_measure(view->children[i], GTK_ORIENTATION_HORIZONTAL, -1, &min, NULL, NULL, NULL); requested += min; + } for_size -= requested; @@ -593,11 +757,14 @@ static void gtk_hex_view_measure(GtkWidget *widget, GtkOrientation orientation, GTK_BUFFER_VIEW(view)->style, for_size); - if (minimum != NULL) *minimum = 0; + if (minimum != NULL) *minimum = requested; if (natural != NULL) *natural = requested; for (i = 0; i < _CHILDREN_COUNT; i++) { + if (!gtk_widget_get_visible(view->children[i])) + continue; + gtk_widget_measure(view->children[i], GTK_ORIENTATION_VERTICAL, -1, &min, &nat, NULL, NULL); if (minimum != NULL && min > *minimum) diff --git a/src/gtkext/hexview.h b/src/gtkext/hexview.h index 2199786..0d2cd5a 100644 --- a/src/gtkext/hexview.h +++ b/src/gtkext/hexview.h @@ -41,6 +41,12 @@ DECLARE_GTYPE(GtkHexView, gtk_hex_view, GTK, HEX_VIEW); /* Crée un composant d'affichage d'octets bruts et imprimables. */ GtkHexView *gtk_hex_view_new(GBinContent *); +/* Fournit le contenu associé au composant d'affichage. */ +GBinContent *gtk_hex_view_get_content(const GtkHexView *); + +/* Définit le contenu associé au composant d'affichage. */ +void gtk_hex_view_set_content(GtkHexView *, GBinContent *); + #endif /* _GTKEXT_HEXVIEW_H */ diff --git a/src/gtkext/hexview.ui b/src/gtkext/hexview.ui index ae4586c..9b42936 100644 --- a/src/gtkext/hexview.ui +++ b/src/gtkext/hexview.ui @@ -1,27 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> <interface> - <template class="GtkHexView" parent="GtkBufferView"> - <property name="css-name">GtkHexView</property> - <child> - <object class="GtkComposingArea" id="offsets"> - <style> - <class name="gutter"/> - </style> - </object> - </child> - <child> - <object class="GtkComposingArea" id="hex"> - <property name="hexpand">true</property> - <style> - <class name="custom-view"/> - </style> - </object> - </child> - <child> - <object class="GtkComposingArea" id="ascii"> - <style> - <class name="custom-view"/> - </style> - </object> - </child> - </template> + + <template class="GtkHexView" parent="GtkBufferView"> + <child> + <object class="GtkComposingArea" id="offsets"> + <style> + <class name="gutter"/> + </style> + </object> + </child> + <child> + <object class="GtkComposingArea" id="hex"> + <property name="hexpand">true</property> + <style> + <class name="custom-view"/> + </style> + </object> + </child> + <child> + <object class="GtkComposingArea" id="ascii"> + <style> + <class name="custom-view"/> + </style> + </object> + </child> + </template> + </interface> 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/gtkext/statusstack-int.h b/src/gtkext/statusstack-int.h index df9db35..721b982 100644 --- a/src/gtkext/statusstack-int.h +++ b/src/gtkext/statusstack-int.h @@ -50,6 +50,12 @@ struct _GtkStatusStack GSourceFunc def_source; /* Appel en fin d'activité */ + /* Message simple par défaut */ + + GtkLabel *def_label; /* Afficheur de message */ + + char *msg; /* Contenu associé */ + /* Navigation */ GtkLabel *nav_segment; /* Désignation du segment */ diff --git a/src/gtkext/statusstack.c b/src/gtkext/statusstack.c index 492d888..92c296a 100644 --- a/src/gtkext/statusstack.c +++ b/src/gtkext/statusstack.c @@ -56,6 +56,10 @@ typedef enum _StatusStackProperty { static GParamSpec *_status_stack_properties[N_PROPERTIES] = { NULL, }; +/* Source d'affichage par défaut */ +#define gtk_status_stack_default_source gtk_status_stack_show_simple_message + + /* Initialise la classe des barres de statut améliorées. */ static void gtk_status_stack_class_init(GtkStatusStackClass *); @@ -87,6 +91,14 @@ static void gtk_status_stack_get_property(GObject *, guint, GValue *, GParamSpec +/* ----------------------- MISE EN AVANT DES MESSAGES SIMPLES ----------------------- */ + + +/* S'assure de l'affichage à jour de la partie "default". */ +static gboolean gtk_status_stack_show_simple_message(gpointer); + + + /* -------------------- STATUT DES INFORMATIONS DE DESASSEMBLAGE -------------------- */ @@ -115,7 +127,7 @@ static void init_navigation_info(navigation_info_t *); static void fini_navigation_info(navigation_info_t *); /* S'assure de l'affichage à jour de la partie "navigation". */ -static gboolean gtk_status_stack_show_current_location(GtkStatusStack *); +static gboolean gtk_status_stack_show_current_location(gpointer); /* Réagit à un clic sur l'icône de zoom. */ static void gtk_status_stack_on_zoom_icon_press(GtkEntry *, GtkEntryIconPosition, GtkStatusStack *); @@ -165,7 +177,7 @@ static void fini_activity_info(activity_info_t *); static activity_status_t *find_activity_status_by_id(activity_info_t *, activity_id_t); /* S'assure de l'affichage à jour de la partie "activité". */ -static gboolean gtk_status_stack_show_current_activity(GtkStatusStack *); +static gboolean gtk_status_stack_show_current_activity(gpointer); @@ -217,6 +229,8 @@ static void gtk_status_stack_class_init(GtkStatusStackClass *class) gtk_widget_class_bind_template_child(widget, GtkStatusStack, main); + gtk_widget_class_bind_template_child(widget, GtkStatusStack, def_label); + gtk_widget_class_bind_template_child(widget, GtkStatusStack, nav_segment); gtk_widget_class_bind_template_child(widget, GtkStatusStack, nav_phys); gtk_widget_class_bind_template_child(widget, GtkStatusStack, nav_virt); @@ -254,7 +268,9 @@ static void gtk_status_stack_init(GtkStatusStack *stack) { gtk_widget_init_template(GTK_WIDGET(stack)); - stack->def_source = NULL; + stack->def_source = gtk_status_stack_default_source; + + stack->msg = NULL; stack->nav_info = calloc(1, sizeof(navigation_info_t)); init_navigation_info(stack->nav_info); @@ -278,6 +294,10 @@ static void gtk_status_stack_init(GtkStatusStack *stack) stack->network_update_tag = g_timeout_add(NETWORK_UPDATE_INTERVAL, G_SOURCE_FUNC(gtk_status_stack_update_network_stats), stack); + /* Premier affichage... */ + + gtk_status_stack_reset_to_default(stack); + } @@ -324,6 +344,9 @@ static void gtk_status_stack_dispose(GtkStatusStack *stack) static void gtk_status_stack_finalize(GtkStatusStack *stack) { + if (stack->msg != NULL) + free(stack->msg); + fini_navigation_info(stack->nav_info); free(stack->nav_info); @@ -370,11 +393,15 @@ GtkStatusStack *gtk_status_stack_new(void) * * ******************************************************************************/ -void gtk_status_stack_reset(GtkStatusStack *stack) +void gtk_status_stack_reset_to_default(GtkStatusStack *stack) { - gtk_stack_set_visible_child_name(stack->main, "default"); + /** + * Une amélioration possible serait de passer à g_idle_add_once(), + * et de s'affranchir des retours G_SOURCE_REMOVE systématiques, + * mais la fonction n'est disponible qu'à partir de la GLib 2.74. + */ - stack->def_source = NULL; + g_idle_add(stack->def_source, stack); } @@ -614,6 +641,69 @@ static void gtk_status_stack_get_property(GObject *object, guint prop_id, GValue /* ---------------------------------------------------------------------------------- */ +/* MISE EN AVANT DES MESSAGES SIMPLES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : stack = barre de statut à actualiser. * +* msg = simple message à faire paraître. * +* * +* Description : Inscrit un message simple dans la barre de statut. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_status_stack_display_message(GtkStatusStack *stack, const char *msg) +{ + if (stack->msg != NULL) + free(stack->msg); + + if (msg != NULL) + stack->msg = strdup(msg); + else + stack->msg = NULL; + + gtk_status_stack_show_simple_message(stack); + +} + + +/****************************************************************************** +* * +* Paramètres : data = pile de statuts à manipuler. * +* * +* Description : S'assure de l'affichage à jour de la partie "default". * +* * +* Retour : G_SOURCE_REMOVE pour une exécution unique. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_status_stack_show_simple_message(gpointer data) +{ + GtkStatusStack *stack; /* Version spécialisée */ + + stack = GTK_STATUS_STACK(data); + + stack->def_source = gtk_status_stack_show_simple_message; + + gtk_label_set_text(stack->def_label, stack->msg != NULL ? stack->msg : ""); + + gtk_stack_set_visible_child_name(stack->main, "default"); + + return G_SOURCE_REMOVE; + +} + + + +/* ---------------------------------------------------------------------------------- */ /* STATUT DES INFORMATIONS DE DESASSEMBLAGE */ /* ---------------------------------------------------------------------------------- */ @@ -744,7 +834,7 @@ void gtk_status_stack_update_current_location(GtkStatusStack *stack, const mrang /****************************************************************************** * * -* Paramètres : stack = pile de statuts à manipuler. * +* Paramètres : data = pile de statuts à manipuler. * * * * Description : S'assure de l'affichage à jour de la partie "navigation". * * * @@ -754,14 +844,15 @@ void gtk_status_stack_update_current_location(GtkStatusStack *stack, const mrang * * ******************************************************************************/ -static gboolean gtk_status_stack_show_current_location(GtkStatusStack *stack) +static gboolean gtk_status_stack_show_current_location(gpointer data) { + GtkStatusStack *stack; /* Version spécialisée */ navigation_info_t *info; /* Informations à constituer */ char raw_pos[6 + VMPA_MAX_LEN + 1]; /* Formatage final en direct */ - stack->def_source = (GSourceFunc)gtk_status_stack_show_current_location; + stack = GTK_STATUS_STACK(data); - gtk_stack_set_visible_child_name(stack->main, "navigation"); + stack->def_source = gtk_status_stack_show_current_location; info = stack->nav_info; @@ -785,6 +876,10 @@ static gboolean gtk_status_stack_show_current_location(GtkStatusStack *stack) gtk_label_set_text(stack->nav_details, info->details != NULL ? info->details : ""); + /* Conclusion */ + + gtk_stack_set_visible_child_name(stack->main, "navigation"); + return G_SOURCE_REMOVE; } @@ -985,7 +1080,7 @@ activity_id_t gtk_status_stack_add_activity(GtkStatusStack *stack, const char *m if (info->tag != 0) g_source_remove(info->tag); - info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack); + info->tag = g_idle_add(gtk_status_stack_show_current_activity, stack); g_mutex_unlock(&info->access); @@ -1052,7 +1147,7 @@ void gtk_status_stack_update_activity_message(GtkStatusStack *stack, activity_id if (info->tag != 0) g_source_remove(info->tag); - info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack); + info->tag = g_idle_add(gtk_status_stack_show_current_activity, stack); } @@ -1109,7 +1204,7 @@ void gtk_status_stack_update_activity_value(GtkStatusStack *stack, activity_id_t if (info->tag != 0) g_source_remove(info->tag); - info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack); + info->tag = g_idle_add(gtk_status_stack_show_current_activity, stack); } @@ -1161,7 +1256,7 @@ void gtk_status_stack_extend_activity_max(GtkStatusStack *stack, activity_id_t i if (info->tag != 0) g_source_remove(info->tag); - info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack); + info->tag = g_idle_add(gtk_status_stack_show_current_activity, stack); } @@ -1227,10 +1322,10 @@ void gtk_status_stack_remove_activity(GtkStatusStack *stack, activity_id_t id) if (info->count == 0) { info->tag = 0; - g_idle_add(stack->def_source, stack); + gtk_status_stack_reset_to_default(stack); } else if (is_last) - info->tag = g_idle_add((GSourceFunc)gtk_status_stack_show_current_activity, stack); + info->tag = g_idle_add(gtk_status_stack_show_current_activity, stack); exit: @@ -1241,7 +1336,7 @@ void gtk_status_stack_remove_activity(GtkStatusStack *stack, activity_id_t id) /****************************************************************************** * * -* Paramètres : stack = pile de statuts à manipuler. * +* Paramètres : data = pile de statuts à manipuler. * * * * Description : S'assure de l'affichage à jour de la partie "activité". * * * @@ -1251,11 +1346,14 @@ void gtk_status_stack_remove_activity(GtkStatusStack *stack, activity_id_t id) * * ******************************************************************************/ -static gboolean gtk_status_stack_show_current_activity(GtkStatusStack *stack) +static gboolean gtk_status_stack_show_current_activity(gpointer data) { + GtkStatusStack *stack; /* Version spécialisée */ activity_info_t *info; /* Informations à consulter */ activity_status_t *last; /* Dernier statut à traiter */ + stack = GTK_STATUS_STACK(data); + info = stack->activity_info; g_mutex_lock(&info->access); @@ -1264,14 +1362,14 @@ static gboolean gtk_status_stack_show_current_activity(GtkStatusStack *stack) { if (info->count > 0) { - gtk_stack_set_visible_child_name(stack->main, "activity"); - last = &info->statuses[info->count - 1]; gtk_label_set_text(stack->activity_message, last->message); gtk_progress_bar_set_fraction(stack->activity_progress, (last->current * 1.0) / last->max); + gtk_stack_set_visible_child_name(stack->main, "activity"); + } info->tag = 0; diff --git a/src/gtkext/statusstack.h b/src/gtkext/statusstack.h index 66ad6db..96d008c 100644 --- a/src/gtkext/statusstack.h +++ b/src/gtkext/statusstack.h @@ -45,7 +45,15 @@ DECLARE_GTYPE(GtkStatusStack, gtk_status_stack, GTK, STATUS_STACK); GtkStatusStack *gtk_status_stack_new(void); /* Réinitialise la barre de statut à son stade par défaut. */ -void gtk_status_stack_reset(GtkStatusStack *); +void gtk_status_stack_reset_to_default(GtkStatusStack *); + + + +/* ----------------------- MISE EN AVANT DES MESSAGES SIMPLES ----------------------- */ + + +/* Inscrit un message simple dans la barre de statut. */ +void gtk_status_stack_display_message(GtkStatusStack *, const char *); diff --git a/src/gtkext/statusstack.ui b/src/gtkext/statusstack.ui index 2a6e256..0b7cd6d 100644 --- a/src/gtkext/statusstack.ui +++ b/src/gtkext/statusstack.ui @@ -12,16 +12,19 @@ <!-- Vide par défaut --> <child> - <object class="GtkStackPage" id="stack"> + <object class="GtkStackPage"> <property name="name">default</property> <property name="child"> - <object class="GtkLabel"> + <object class="GtkLabel" id="def_label"> <property name="hexpand">true</property> <property name="halign">fill</property> - <property name="valign">center</property> + <property name="valign">baseline</property> <property name="xalign">0</property> <property name="label"></property> + <style> + <class name="dim-label"/> + </style> </object> </property> |
