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.
This commit is contained in:
Thomas Wood 2010-05-25 14:38:36 +01:00
parent 4fcc633a36
commit 27bf283683
3 changed files with 43 additions and 4 deletions

View file

@ -34,7 +34,7 @@ static void
cc_shell_model_init (CcShellModel *self) cc_shell_model_init (CcShellModel *self)
{ {
GType types[] = {G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, 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), gtk_list_store_set_column_types (GTK_LIST_STORE (self),
N_COLS, types); N_COLS, types);
@ -94,6 +94,7 @@ cc_shell_model_add_item (CcShellModel *model,
COL_PIXBUF, pixbuf, COL_PIXBUF, pixbuf,
COL_CATEGORY, category_name, COL_CATEGORY, category_name,
COL_SEARCH_TARGET, search_target, COL_SEARCH_TARGET, search_target,
COL_ICON_NAME, icon,
-1); -1);
g_free (search_target); g_free (search_target);

View file

@ -61,6 +61,7 @@ enum
COL_PIXBUF, COL_PIXBUF,
COL_CATEGORY, COL_CATEGORY,
COL_SEARCH_TARGET, COL_SEARCH_TARGET,
COL_ICON_NAME,
N_COLS N_COLS
}; };

View file

@ -69,13 +69,18 @@ struct _GnomeControlCenterPrivate
guint32 last_time; guint32 last_time;
GIOExtensionPoint *extension_point; GIOExtensionPoint *extension_point;
gchar *default_window_title;
gchar *default_window_icon;
}; };
static void static void
activate_panel (GnomeControlCenter *shell, activate_panel (GnomeControlCenter *shell,
const gchar *id, const gchar *id,
const gchar *desktop_file) const gchar *desktop_file,
const gchar *name,
const gchar *icon_name)
{ {
GnomeControlCenterPrivate *priv = shell->priv; GnomeControlCenterPrivate *priv = shell->priv;
GAppInfo *appinfo; GAppInfo *appinfo;
@ -123,6 +128,10 @@ activate_panel (GnomeControlCenter *shell,
gtk_widget_show_all (box); gtk_widget_show_all (box);
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i); 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; return;
} }
@ -177,6 +186,13 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
g_free (priv->filter_string); g_free (priv->filter_string);
priv->filter_string = g_strdup (""); priv->filter_string = g_strdup ("");
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), ""); 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; GtkTreeIter iter;
gboolean iter_valid; gboolean iter_valid;
gchar *name = NULL; gchar *name = NULL;
gchar *desktop; gchar *desktop, *icon_name;
GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (shell)->priv; GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (shell)->priv;
@ -519,6 +535,7 @@ _shell_set_active_panel_from_id (CcShell *shell,
COL_NAME, &name, COL_NAME, &name,
COL_ID, &id, COL_ID, &id,
COL_DESKTOP_FILE, &desktop, COL_DESKTOP_FILE, &desktop,
COL_ICON_NAME, &icon_name,
-1); -1);
if (id && !strcmp (id, start_id)) if (id && !strcmp (id, start_id))
{ {
@ -530,6 +547,7 @@ _shell_set_active_panel_from_id (CcShell *shell,
g_free (id); g_free (id);
g_free (name); g_free (name);
g_free (desktop); g_free (desktop);
g_free (icon_name);
name = NULL; name = NULL;
id = NULL; id = NULL;
@ -546,10 +564,12 @@ _shell_set_active_panel_from_id (CcShell *shell,
} }
else 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 (name);
g_free (desktop); g_free (desktop);
g_free (icon_name);
return TRUE; return TRUE;
} }
@ -636,6 +656,18 @@ gnome_control_center_finalize (GObject *object)
priv->filter_string = NULL; 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); 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 functionality */
setup_search (self); setup_search (self);
gtk_widget_show_all (priv->window); 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 * GnomeControlCenter *