diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-08-20 21:49:12 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-08-20 21:49:12 (GMT) |
commit | 384cba185a99ea30d3c1f13a151679a123f74acc (patch) | |
tree | 3750d75a81ea1dbc79b24f39bbe8c2a667566a24 /src | |
parent | 8e56898ab1054f3fbeff85c393364dc943fa942a (diff) |
Hidden the main toolbar when it gets useless.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/editor.c | 45 | ||||
-rw-r--r-- | src/gui/tb/portions.c | 13 |
2 files changed, 56 insertions, 2 deletions
diff --git a/src/gui/editor.c b/src/gui/editor.c index b4e13b0..e5a16d1 100644 --- a/src/gui/editor.c +++ b/src/gui/editor.c @@ -92,6 +92,9 @@ static gboolean on_key_event(GtkWidget *, GdkEventKey *, GObject *); /* ------------------------ INTEGRATION DE LA BARRE D'OUTILS ------------------------ */ +/* Suit les évolutions d'affichage dans la barre d'outils. */ +static void on_toolbar_item_visibility_change(GtkWidget *, GtkToolbar *); + /* Construit la barre d'outils de l'éditeur. */ static GtkWidget *build_editor_toolbar(GObject *); @@ -565,6 +568,40 @@ static gboolean on_key_event(GtkWidget *widget, GdkEventKey *event, GObject *ref /****************************************************************************** * * +* Paramètres : widget = composant graphique dont l'affichage a basculé. * +* toolbar = barre d'outils à mettre à jour. * +* * +* Description : Suit les évolutions d'affichage dans la barre d'outils. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void on_toolbar_item_visibility_change(GtkWidget *widget, GtkToolbar *toolbar) +{ + bool show; /* Impose un affichage */ + + show = false; + + void visit_all_tb_items(GtkWidget *w, gpointer unused) + { + show |= gtk_widget_get_visible(w); + } + + gtk_container_foreach(GTK_CONTAINER(toolbar), visit_all_tb_items, NULL); + + if (show) + gtk_widget_show(GTK_WIDGET(toolbar)); + else + gtk_widget_hide(GTK_WIDGET(toolbar)); + +} + + +/****************************************************************************** +* * * Paramètres : ref = espace de référencement global. * * * * Description : Construit la barre d'outils de l'éditeur. * @@ -587,6 +624,14 @@ static GtkWidget *build_editor_toolbar(GObject *ref) item = create_portions_tb_item(ref); register_editor_item(item); + void track_tb_items_visibility(GtkWidget *widget, gpointer unused) + { + g_signal_connect(widget, "hide", G_CALLBACK(on_toolbar_item_visibility_change), result); + g_signal_connect(widget, "show", G_CALLBACK(on_toolbar_item_visibility_change), result); + } + + gtk_container_foreach(GTK_CONTAINER(result), track_tb_items_visibility, NULL); + return result; } diff --git a/src/gui/tb/portions.c b/src/gui/tb/portions.c index 202cd43..a8eb606 100644 --- a/src/gui/tb/portions.c +++ b/src/gui/tb/portions.c @@ -221,6 +221,7 @@ GEditorItem *create_portions_tb_item(GObject *ref) static void change_portions_tbitem_current_content(GEditorItem *item, GLoadedContent *old, GLoadedContent *new) { GLoadedBinary *binary; /* Autre version de l'instance */ + GtkWidget *widget; /* Elément graphique principal */ GtkBinaryStrip *strip; /* Bande pour binaire */ if (G_IS_LOADED_BINARY(new)) @@ -228,9 +229,17 @@ static void change_portions_tbitem_current_content(GEditorItem *item, GLoadedCon else binary = NULL; - strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(item->widget), "strip")); + widget = g_editor_item_get_widget(item); - gtk_binary_strip_attach(strip, binary); + strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(widget), "strip")); + + if (binary != NULL) + { + gtk_binary_strip_attach(strip, binary); + gtk_widget_show(GTK_WIDGET(widget)); + } + else + gtk_widget_hide(GTK_WIDGET(widget)); } |