Commit d91e466f authored by Thomas Wood's avatar Thomas Wood
Browse files

shell: Use the X-GNOME-Settings-Panel value to identify panels

Use the custom .desktop file field to identify panels and make sure the
panel implementations use the name to identify themselves.
parent 8aa419da
......@@ -106,6 +106,6 @@ cc_example_panel_register (GIOModule *module)
cc_example_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_EXAMPLE_PANEL,
"gnome-example-panel.desktop", 0);
"example-panel", 0);
}
......@@ -127,6 +127,6 @@ cc_default_applications_panel_register (GIOModule *module)
cc_default_applications_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_DEFAULT_APPLICATIONS_PANEL,
"default-applications.desktop", 0);
"default-applications", 0);
}
......@@ -125,6 +125,6 @@ cc_keybindings_panel_register (GIOModule *module)
cc_keybindings_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_KEYBINDINGS_PANEL,
"keybinding.desktop", 0);
"keybinding", 0);
}
......@@ -135,5 +135,5 @@ cc_keyboard_panel_register (GIOModule * module)
cc_keyboard_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_KEYBOARD_PANEL,
"keyboard.desktop", 0);
"keyboard", 0);
}
......@@ -142,6 +142,6 @@ cc_mouse_panel_register (GIOModule *module)
cc_mouse_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_MOUSE_PANEL,
"gnome-settings-mouse.desktop", 0);
"mouse", 0);
}
......@@ -132,6 +132,6 @@ cc_network_panel_register (GIOModule *module)
cc_network_panel_register_type (G_TYPE_MODULE (module));
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
CC_TYPE_NETWORK_PANEL,
"gnome-network-properties.desktop", 0);
"network", 0);
}
......@@ -77,7 +77,7 @@ struct _GnomeControlCenterPrivate
static void
activate_panel (GnomeControlCenter *shell,
const gchar *id,
const gchar *nid,
const gchar *desktop_file,
const gchar *name,
const gchar *icon_name)
......@@ -89,72 +89,89 @@ activate_panel (GnomeControlCenter *shell,
GKeyFile *key_file;
GType panel_type = G_TYPE_INVALID;
GList *panels, *l;
gchar *panel_id;
/* check if there is an plugin that implements this panel */
panels = g_io_extension_point_get_extensions (priv->extension_point);
for (l = panels; l != NULL; l = l->next)
{
GIOExtension *extension;
const gchar *name;
if (!desktop_file)
return;
extension = l->data;
key_file = g_key_file_new ();
g_key_file_load_from_file (key_file, desktop_file, 0, &err);
panel_id = g_key_file_get_string (key_file, "Desktop Entry",
"X-GNOME-Settings-Panel", NULL);
name = g_io_extension_get_name (extension);
if (panel_id)
{
if (!g_strcmp0 (name, id))
for (l = panels; l != NULL; l = l->next)
{
panel_type = g_io_extension_get_type (extension);
break;
GIOExtension *extension;
const gchar *name;
extension = l->data;
name = g_io_extension_get_name (extension);
if (!g_strcmp0 (name, panel_id))
{
panel_type = g_io_extension_get_type (extension);
break;
}
}
}
if (panel_type != G_TYPE_INVALID)
{
GtkWidget *panel;
GtkWidget *box;
gint i;
if (panel_type != G_TYPE_INVALID)
{
GtkWidget *panel;
GtkWidget *box;
gint i;
/* create the panel plugin */
panel = g_object_new (panel_type, "shell", shell, NULL);
/* create the panel plugin */
panel = g_object_new (panel_type, "shell", shell, NULL);
box = gtk_alignment_new (0, 0, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);
box = gtk_alignment_new (0, 0, 1, 1);
gtk_alignment_set_padding (GTK_ALIGNMENT (box), 6, 6, 6, 6);
gtk_container_add (GTK_CONTAINER (box), panel);
gtk_container_add (GTK_CONTAINER (box), panel);
/* switch to the new panel */
i = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), box, NULL);
gtk_widget_show_all (box);
gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), i);
/* switch to the new panel */
i = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), box, NULL);
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);
/* 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;
g_key_file_free (key_file);
key_file = NULL;
return;
}
}
/* if a plugin was not found, then start app directly */
if (!desktop_file)
return;
key_file = g_key_file_new ();
g_key_file_load_from_file (key_file, desktop_file, 0, &err);
if (err)
{
g_warning ("Error starting \"%s\": %s", id, err->message);
g_warning ("Error starting \"%s\": %s", desktop_file, err->message);
g_error_free (err);
err = NULL;
g_key_file_free (key_file);
key_file = NULL;
return;
}
appinfo = (GAppInfo*) g_desktop_app_info_new_from_keyfile (key_file);
g_key_file_free (key_file);
key_file = NULL;
ctx = gdk_app_launch_context_new ();
......@@ -168,7 +185,7 @@ activate_panel (GnomeControlCenter *shell,
if (err)
{
g_warning ("Error starting \"%s\": %s", id, err->message);
g_warning ("Error starting \"%s\": %s", desktop_file, err->message);
g_error_free (err);
err = NULL;
}
......@@ -191,8 +208,6 @@ shell_show_overview_page (GnomeControlCenterPrivate *priv)
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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment