From 3a259b1e1e3fe870f9d1837ea2ecf6ce5c1d0162 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sat, 22 Oct 2016 12:00:41 +0200
Subject: Fixed GUI bugs in the case where no binary is loaded.

---
 ChangeLog                   |  8 ++++++++
 src/gtkext/gtkbinarystrip.c | 12 ++++++++++--
 src/gui/editor.c            |  3 +++
 src/gui/panels/symbols.c    | 12 +++++++++++-
 src/gui/tb/source.c         |  3 ++-
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 336a34b..44b667f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+16-10-22  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/gtkext/gtkbinarystrip.c:
+	* src/gui/editor.c:
+	* src/gui/panels/symbols.c:
+	* src/gui/tb/source.c:
+	Fix GUI bugs in the case where no binary is loaded.
+
 16-10-21  Cyrille Bagard <nocbos@gmail.com>
 
 	* src/glibext/gwidthtracker.c:
diff --git a/src/gtkext/gtkbinarystrip.c b/src/gtkext/gtkbinarystrip.c
index 0ad0763..9a1b827 100644
--- a/src/gtkext/gtkbinarystrip.c
+++ b/src/gtkext/gtkbinarystrip.c
@@ -436,13 +436,21 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y
 
 void gtk_binary_strip_attach(GtkBinaryStrip *strip, GLoadedBinary *binary)
 {
+    GtkWidget *widget;                      /* Autre version du composant  */
+
     if (strip->binary != NULL)
         g_object_unref(G_OBJECT(strip->binary));
 
     strip->binary = binary;
-    g_object_ref(G_OBJECT(strip->binary));
 
-    gtk_widget_queue_draw(GTK_WIDGET(strip));
+    if (strip->binary != NULL)
+        g_object_ref(G_OBJECT(strip->binary));
+
+    widget = GTK_WIDGET(strip);
+
+    gtk_widget_set_sensitive(widget, strip->binary != NULL);
+
+    gtk_widget_queue_draw(widget);
 
 }
 
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 3723bd8..bff001d 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -349,6 +349,9 @@ GtkWidget *create_editor(void)
 
 
 
+    /* Actualisation des contenus */
+
+    change_editor_items_current_binary(ref, NULL);
 
 
 
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index 0cbb9eb..4c8a78a 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -590,14 +590,24 @@ static void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBin
     GtkToggleToolButton *button;            /* Mode de représentation      */
     GtkRequisition req;                     /* Nouvelle taille idéale      */
 
+    /* Basculement du binaire utilisé */
+
     if (panel->binary != NULL)
         g_object_unref(G_OBJECT(panel->binary));
 
     panel->binary = binary;
-    g_object_ref(G_OBJECT(binary));
+
+    if (panel->binary != NULL)
+        g_object_ref(G_OBJECT(panel->binary));
 
     gtk_tree_store_clear(panel->store);
 
+    /* Si le panneau actif ne représente pas un binaire... */
+
+    if (binary == NULL) return;
+
+    /* Actualisation de l'affichage */
+
     button = g_object_get_data(G_OBJECT(G_EDITOR_ITEM(panel)->widget), "list");
 
     if (gtk_toggle_tool_button_get_active(button))
diff --git a/src/gui/tb/source.c b/src/gui/tb/source.c
index 466bade..f35ca7c 100644
--- a/src/gui/tb/source.c
+++ b/src/gui/tb/source.c
@@ -223,6 +223,7 @@ GEditorItem *create_source_tb_item(GObject *ref)
 
 static void update_source_item_binary(GEditorItem *item, GLoadedBinary *binary)
 {
+#if 0
     GtkComboBoxText *combo;                 /* Liste de sélection          */
     GtkTreeModel *model;                    /* Gestionnaire d'éléments     */
     GtkTreeIter iter;                       /* Boucle de parcours #2       */
@@ -259,7 +260,7 @@ static void update_source_item_binary(GEditorItem *item, GLoadedBinary *binary)
     g_signal_handlers_unblock_by_func(combo, G_CALLBACK(change_selected_source), item);
 
     //gtk_combo_box_set_active(combo, defsrc);
-
+#endif
 }
 
 
-- 
cgit v0.11.2-87-g4458