]> git.0d.be Git - empathy.git/commitdiff
hide notifications options when in Shell
authorJuan R. Garcia Blanco <jgblanco.mail@gmail.com>
Thu, 22 Sep 2011 07:03:09 +0000 (09:03 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 26 Sep 2011 10:07:24 +0000 (12:07 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=659207

src/empathy-main-window.c
src/empathy-main-window.h
src/empathy-preferences.c
src/empathy-preferences.h
src/empathy.c

index f3722524bb83abbe2f2994f5f8e0ce41c6c7f9ff..3f87c4f7afb7f7123049b593efeabc33d9645e47 100644 (file)
@@ -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,
@@ -2082,14 +2103,65 @@ empathy_main_window_constructor (GType type,
        return window;
 }
 
+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));
 }
 
index cb0ae3cf07ef4e6703e7343b39b23ad57a38e7b7..af4c1924eb53fedf27a9f31b0604665f7b693d4a 100644 (file)
@@ -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
 
index 9dc7f58bf39f4ae48e3baecd5e89053719e60a17..e141aa201c7c9b72c4a2de38e9af34d789da0d45 100644 (file)
@@ -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;
 }
 
index fef0646d78b36d814c66f5035edc51d71b6acad7..b8b126bd8988dee7d69b3d0c41af016ffc3d1fee 100644 (file)
@@ -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);
index e95ad1d205046fcee9bbf9a9c78224c9353bba55..e1dab1f1812f50b26c9c04f42bad1bb64b92e4dd 100644 (file)
@@ -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
     {