[gnome-bluetooth] Reset to the Devices view when the panel is hidden



commit 3536d1463b9e9e69c855d71bfee5f8a4f68dc3b9
Author: Joshua Lock <josh linux intel com>
Date:   Tue Oct 20 17:48:55 2009 +0100

    Reset to the Devices view when the panel is hidden
    
    When the panel is hidden reset to the default devices view. This follows
    the moblin ethos of panels being in their default state when shown and has
    a nice side bonus of preventing the panel being left in discovery mode and
    (presumably) hammering the battery.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=599074

 moblin/main.c         |   13 +++++++++++++
 moblin/moblin-panel.c |   12 ++++++++++++
 moblin/moblin-panel.h |    2 ++
 3 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/moblin/main.c b/moblin/main.c
index 9ec1cb2..9890a20 100644
--- a/moblin/main.c
+++ b/moblin/main.c
@@ -54,6 +54,18 @@ bluetooth_status_changed (MoblinPanel *panel, gboolean connecting, gpointer user
 	g_free (style);
 }
 
+/*
+ * When the panel is hidden we should re-set the MoblinPanel to its default state.
+ * i.e. stop any discovery and show the defaults devices view
+ */
+static void
+_reset_view_cb (MplPanelClient *client, gpointer user_data)
+{
+	MoblinPanel *panel = MOBLIN_PANEL (user_data);
+
+	moblin_panel_reset_view (panel);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -107,6 +119,7 @@ main (int argc, char *argv[])
 		window  = mpl_panel_gtk_get_window (MPL_PANEL_GTK (panel));
 
 		content = moblin_panel_new ();
+		g_signal_connect (panel, "hide-end", (GCallback) _reset_view_cb, content);
 		g_signal_connect (content, "state-changed",
 				G_CALLBACK (bluetooth_status_changed), panel);
 		gtk_widget_show (content);
diff --git a/moblin/moblin-panel.c b/moblin/moblin-panel.c
index 8879beb..fd9f3f2 100644
--- a/moblin/moblin-panel.c
+++ b/moblin/moblin-panel.c
@@ -1560,3 +1560,15 @@ moblin_panel_new (void)
 {
 	return g_object_new (MOBLIN_TYPE_PANEL, NULL);
 }
+
+/**
+ *
+ * moblin_panel_reset_view:
+ *
+ * @self: A #MoblinPanel widget
+ **/
+void
+moblin_panel_reset_view (MoblinPanel *self)
+{
+	set_current_page (self, PAGE_DEVICES);
+}
diff --git a/moblin/moblin-panel.h b/moblin/moblin-panel.h
index 0cae24d..d273e79 100644
--- a/moblin/moblin-panel.h
+++ b/moblin/moblin-panel.h
@@ -71,6 +71,8 @@ GType moblin_panel_get_type (void);
 
 GtkWidget *moblin_panel_new (void);
 
+void moblin_panel_reset_view (MoblinPanel *self);
+
 G_END_DECLS
 
 #endif /* _MOBLIN_PANEL_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]