[empathy] hide notifications options when in Shell



commit 23ecdf691227368b7d914908aeaa6666fd46c890
Author: Juan R. Garcia Blanco <jgblanco mail gmail com>
Date:   Thu Sep 22 09:03:09 2011 +0200

    hide notifications options when in Shell
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659207

 src/empathy-main-window.c |   74 ++++++++++++++++++++++++++++++++++++++++++++-
 src/empathy-main-window.h |    2 +
 src/empathy-preferences.c |   20 +++++++++++-
 src/empathy-preferences.h |    3 +-
 src/empathy.c             |    3 ++
 5 files changed, 98 insertions(+), 4 deletions(-)
---
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index f372252..3f87c4f 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -98,6 +98,11 @@ enum {
 	PAGE_NO_MATCH
 };
 
+enum {
+	PROP_0,
+	PROP_SHELL_RUNNING
+};
+
 G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);
 
 #define GET_PRIV(self) ((EmpathyMainWindowPriv *)((EmpathyMainWindow *) self)->priv)
@@ -166,6 +171,8 @@ struct _EmpathyMainWindowPriv {
 
 	/* The idle event source to migrate butterfly's logs */
 	guint butterfly_log_migration_members_changed_id;
+
+	gboolean               shell_running;
 };
 
 static void
@@ -1854,7 +1861,8 @@ empathy_main_window_show_preferences (EmpathyMainWindow *window,
 	EmpathyMainWindowPriv *priv = GET_PRIV (window);
 
 	if (priv->preferences == NULL) {
-		priv->preferences = empathy_preferences_new (GTK_WINDOW (window));
+		priv->preferences = empathy_preferences_new (GTK_WINDOW (window),
+		                                             priv->shell_running);
 		g_object_add_weak_pointer (G_OBJECT (priv->preferences),
 					   (gpointer) &priv->preferences);
 
@@ -2064,6 +2072,19 @@ main_window_members_changed_cb (EmpathyContactList *list,
 	}
 }
 
+void
+empathy_main_window_set_shell_running (EmpathyMainWindow *window,
+                                       gboolean          shell_running)
+{
+	EmpathyMainWindowPriv *priv = GET_PRIV (window);
+
+	if (priv->shell_running == shell_running)
+		return;
+
+	priv->shell_running = shell_running;
+	g_object_notify (G_OBJECT (window), "shell-running");
+}
+
 static GObject *
 empathy_main_window_constructor (GType type,
                                  guint n_construct_params,
@@ -2083,13 +2104,64 @@ empathy_main_window_constructor (GType type,
 }
 
 static void
+empathy_main_window_set_property (GObject       *object,
+                                  guint         property_id,
+                                  const GValue *value,
+                                  GParamSpec    *pspec)
+{
+	EmpathyMainWindow *self = EMPATHY_MAIN_WINDOW (object);
+	EmpathyMainWindowPriv *priv = GET_PRIV (self);
+
+	switch (property_id)
+	{
+		case PROP_SHELL_RUNNING:
+			priv->shell_running = g_value_get_boolean (value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+			break;
+	}
+}
+
+static void
+empathy_main_window_get_property (GObject    *object,
+                                  guint      property_id,
+                                  GValue     *value,
+                                  GParamSpec *pspec)
+{
+	EmpathyMainWindow *self = EMPATHY_MAIN_WINDOW (object);
+	EmpathyMainWindowPriv *priv = GET_PRIV (self);
+
+	switch (property_id)
+	{
+		case PROP_SHELL_RUNNING:
+			g_value_set_boolean (value, priv->shell_running);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+			break;
+	}
+}
+
+static void
 empathy_main_window_class_init (EmpathyMainWindowClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GParamSpec *pspec;
 
 	object_class->finalize = empathy_main_window_finalize;
 	object_class->constructor = empathy_main_window_constructor;
 
+	object_class->set_property = empathy_main_window_set_property;
+	object_class->get_property = empathy_main_window_get_property;
+
+	pspec = g_param_spec_boolean ("shell-running",
+	                              "Shell running",
+	                              "Whether the Shell is running or not",
+	                              FALSE,
+	                              G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (object_class, PROP_SHELL_RUNNING, pspec);
+
 	g_type_class_add_private (object_class, sizeof (EmpathyMainWindowPriv));
 }
 
diff --git a/src/empathy-main-window.h b/src/empathy-main-window.h
index cb0ae3c..af4c192 100644
--- a/src/empathy-main-window.h
+++ b/src/empathy-main-window.h
@@ -55,6 +55,8 @@ GtkWidget *empathy_main_window_dup (void);
 
 void empathy_main_window_show_preferences (EmpathyMainWindow *window,
     const gchar *tab);
+void empathy_main_window_set_shell_running (EmpathyMainWindow *window,
+                                            gboolean           shell_running);
 
 G_END_DECLS
 
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index 9dc7f58..e141aa2 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -1283,9 +1283,12 @@ empathy_preferences_tab_to_string (EmpathyPreferencesTab tab)
 }
 
 GtkWidget *
-empathy_preferences_new (GtkWindow *parent)
+empathy_preferences_new (GtkWindow *parent,
+                         gboolean  shell_running)
 {
-	GtkWidget *self;
+	GtkWidget              *self;
+	EmpathyPreferencesPriv *priv;
+	GtkWidget              *notif_page;
 
 	g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
 
@@ -1296,6 +1299,19 @@ empathy_preferences_new (GtkWindow *parent)
 					      parent);
 	}
 
+	/* when running in Gnome Shell we must hide these options since they
+	 * are meaningless in that context:
+	 * - 'Display incoming events in the notification area' (General->Behavior)
+	 * - 'Notifications' tab
+	 */
+	priv = GET_PRIV (self);
+	if (shell_running) {
+		gtk_widget_hide (priv->checkbutton_events_notif_area);
+		notif_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook),
+		                                        EMPATHY_PREFERENCES_TAB_NOTIFICATIONS);
+		gtk_widget_hide (notif_page);
+	}
+
 	return self;
 }
 
diff --git a/src/empathy-preferences.h b/src/empathy-preferences.h
index fef0646..b8b126b 100644
--- a/src/empathy-preferences.h
+++ b/src/empathy-preferences.h
@@ -64,7 +64,8 @@ typedef enum
 
 GType empathy_preferences_get_type (void);
 
-GtkWidget *empathy_preferences_new (GtkWindow *parent);
+GtkWidget *empathy_preferences_new (GtkWindow *parent,
+                                    gboolean  shell_running);
 
 void empathy_preferences_show_tab (EmpathyPreferences *self,
     const gchar *tab);
diff --git a/src/empathy.c b/src/empathy.c
index e95ad1d..e1dab1f 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -287,6 +287,9 @@ out:
 
       /* Rely on GNOME Shell to watch session state */
       empathy_presence_manager_set_auto_away (self->presence_mgr, FALSE);
+
+      empathy_main_window_set_shell_running (EMPATHY_MAIN_WINDOW (self->window),
+                                             TRUE);
     }
   else
     {



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