[gnome-control-center] shell: set the window name and icon when opening an embedded settings panel



commit 27bf283683914d63296f9e95776e52093511aead
Author: Thomas Wood <thomas wood intel com>
Date:   Tue May 25 14:38:36 2010 +0100

    shell: set the window name and icon when opening an embedded settings panel
    
    This involves storing the default window title and icon name and resetting
    the title and icon name when an embedded settings panel is closed.
    
    The icon name and title for each panel is retrieved from the desktop file
    information and stored in the CcShellModel.

 shell/cc-shell-model.c       |    3 +-
 shell/cc-shell-model.h       |    1 +
 shell/gnome-control-center.c |   43 +++++++++++++++++++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 4 deletions(-)
---
diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c
index 3bd4d31..6c5ac34 100644
--- a/shell/cc-shell-model.c
+++ b/shell/cc-shell-model.c
@@ -34,7 +34,7 @@ static void
 cc_shell_model_init (CcShellModel *self)
 {
   GType types[] = {G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
-      GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING};
+      GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING};
 
   gtk_list_store_set_column_types (GTK_LIST_STORE (self),
                                    N_COLS, types);
@@ -94,6 +94,7 @@ cc_shell_model_add_item (CcShellModel   *model,
                                      COL_PIXBUF, pixbuf,
                                      COL_CATEGORY, category_name,
                                      COL_SEARCH_TARGET, search_target,
+                                     COL_ICON_NAME, icon,
                                      -1);
 
   g_free (search_target);
diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h
index 851b7d2..4ba9a36 100644
--- a/shell/cc-shell-model.h
+++ b/shell/cc-shell-model.h
@@ -61,6 +61,7 @@ enum
   COL_PIXBUF,
   COL_CATEGORY,
   COL_SEARCH_TARGET,
+  COL_ICON_NAME,
 
   N_COLS
 };
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 0542179..e859fa9 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -69,13 +69,18 @@ struct _GnomeControlCenterPrivate
   guint32 last_time;
 
   GIOExtensionPoint *extension_point;
+
+  gchar *default_window_title;
+  gchar *default_window_icon;
 };
 
 
 static void
 activate_panel (GnomeControlCenter *shell,
                 const gchar        *id,
-                const gchar        *desktop_file)
+                const gchar        *desktop_file,
+                const gchar        *name,
+                const gchar        *icon_name)
 {
   GnomeControlCenterPrivate *priv = shell->priv;
   GAppInfo *appinfo;
@@ -123,6 +128,10 @@ activate_panel (GnomeControlCenter *shell,
       gtk_widget_show_all (box);
       gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
 
+      /* set the title of the window */
+      gtk_window_set_title (GTK_WINDOW (priv->window), name);
+      gtk_window_set_icon_name (GTK_WINDOW (priv->window), icon_name);
+
       return;
     }
 
@@ -177,6 +186,13 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
   g_free (priv->filter_string);
   priv->filter_string = g_strdup ("");
   gtk_entry_set_text (GTK_ENTRY (priv->search_entry), "");
+
+  /* reset window title and icon */
+  gtk_window_set_title (GTK_WINDOW (priv->window), priv->default_window_title);
+  gtk_window_set_icon_name (GTK_WINDOW (priv->window),
+                            priv->default_window_icon);
+
+  g_debug ("%s %s", priv->default_window_title, priv->default_window_icon);
 }
 
 
@@ -503,7 +519,7 @@ _shell_set_active_panel_from_id (CcShell      *shell,
   GtkTreeIter iter;
   gboolean iter_valid;
   gchar *name = NULL;
-  gchar *desktop;
+  gchar *desktop, *icon_name;
   GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (shell)->priv;
 
 
@@ -519,6 +535,7 @@ _shell_set_active_panel_from_id (CcShell      *shell,
                           COL_NAME, &name,
                           COL_ID, &id,
                           COL_DESKTOP_FILE, &desktop,
+                          COL_ICON_NAME, &icon_name,
                           -1);
       if (id && !strcmp (id, start_id))
         {
@@ -530,6 +547,7 @@ _shell_set_active_panel_from_id (CcShell      *shell,
           g_free (id);
           g_free (name);
           g_free (desktop);
+          g_free (icon_name);
 
           name = NULL;
           id = NULL;
@@ -546,10 +564,12 @@ _shell_set_active_panel_from_id (CcShell      *shell,
     }
   else
     {
-      activate_panel (GNOME_CONTROL_CENTER (shell), start_id, desktop);
+      activate_panel (GNOME_CONTROL_CENTER (shell), start_id, desktop, name,
+                      icon_name);
 
       g_free (name);
       g_free (desktop);
+      g_free (icon_name);
 
       return TRUE;
     }
@@ -636,6 +656,18 @@ gnome_control_center_finalize (GObject *object)
       priv->filter_string = NULL;
     }
 
+  if (priv->default_window_title)
+    {
+      g_free (priv->default_window_title);
+      priv->default_window_title = NULL;
+    }
+
+  if (priv->default_window_icon)
+    {
+      g_free (priv->default_window_icon);
+      priv->default_window_icon = NULL;
+    }
+
   G_OBJECT_CLASS (gnome_control_center_parent_class)->finalize (object);
 }
 
@@ -707,7 +739,12 @@ gnome_control_center_init (GnomeControlCenter *self)
   /* setup search functionality */
   setup_search (self);
 
+
   gtk_widget_show_all (priv->window);
+
+  /* store default window title and name */
+  priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
+  priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
 }
 
 GnomeControlCenter *



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