changeset 2570:aaca094d2f32

Bug fix: GPS map expander When the expander for the GPS map was closed, the map continued to be displayed. The reason is unknown. This commit uses the expander signal to explicitly show or hide the child of the expander.
author Colin Clark <colin.clark@cclark.uk>
date Sat, 05 Aug 2017 17:36:05 +0100
parents ab3ff63854d4
children 6b6f18504950
files src/bar.c src/bar_gps.c
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar.c	Sat Aug 05 10:57:44 2017 +0100
+++ b/src/bar.c	Sat Aug 05 17:36:05 2017 +0100
@@ -364,6 +364,24 @@
 	return FALSE;
 }
 
+static void bar_expander_cb(GObject *object, GParamSpec *param_spec, gpointer data)
+{
+	GtkExpander *expander;
+	GtkWidget *child;
+
+	expander = GTK_EXPANDER(object);
+	child = gtk_bin_get_child(GTK_BIN(expander));
+
+	if (gtk_expander_get_expanded(expander))
+		{
+		gtk_widget_show_all(child);
+		}
+	else
+		{
+		gtk_widget_hide(child);
+		}
+}
+
 static gboolean bar_menu_add_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
 	bar_menu_add_popup(widget);
@@ -563,6 +581,7 @@
 	gtk_box_pack_start(GTK_BOX(bd->vbox), expander, FALSE, TRUE, 0);
 
 	g_signal_connect(expander, "button_release_event", G_CALLBACK(bar_menu_cb), bd);
+	g_signal_connect(expander, "notify::expanded", G_CALLBACK(bar_expander_cb), pd);
 
 	gtk_container_add(GTK_CONTAINER(expander), pane);
 
--- a/src/bar_gps.c	Sat Aug 05 10:57:44 2017 +0100
+++ b/src/bar_gps.c	Sat Aug 05 17:36:05 2017 +0100
@@ -519,13 +519,6 @@
 {
 	GList *list;
 
-	/* The widget does not have a parent during bar_pane_gps_new, so calling gtk_widget_show_all there gives a
-	 * "Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed"
-	 * error. gtk_widget_show_all can be given after it has been added to the bar.
-	 */
-	if (gtk_widget_get_parent(pgd->widget) != NULL)
-		gtk_widget_show_all(pgd->widget);
-
 	/* If a create-marker background process is running, kill it
 	 * and start again
 	 */