shell: Show settings without a panel in Other

Add the X-GNOME-Settings-Panel category. You need a control-center
panel to add this to your desktop file. Desktop entries with this
category but that aren't actually panels will be ignored (no cheating).

If the desktop file for your settings isn't a panel, it will show in the
"Other" section of the control-center shell

https://bugzilla.gnome.org/show_bug.cgi?id=630998
This commit is contained in:
Bastien Nocera 2010-09-30 13:29:23 +01:00
parent e0e25a0264
commit 4ec7801cbb
11 changed files with 80 additions and 15 deletions

View file

@ -23,6 +23,7 @@
#include <string.h>
#define GNOME_SETTINGS_PANEL_ID_KEY "X-GNOME-Settings-Panel"
#define GNOME_SETTINGS_PANEL_CATEGORY GNOME_SETTINGS_PANEL_ID_KEY
G_DEFINE_TYPE (CcShellModel, cc_shell_model, GTK_TYPE_LIST_STORE)
@ -49,6 +50,36 @@ cc_shell_model_new (void)
return g_object_new (CC_TYPE_SHELL_MODEL, NULL);
}
static gboolean
desktop_entry_has_panel_category (GKeyFile *key_file)
{
char **strv;
gsize len;
int i;
strv = g_key_file_get_string_list (key_file,
"Desktop Entry",
"Categories",
&len,
NULL);
if (!strv)
return FALSE;
for (i = 0; strv[i]; i++)
{
if (g_str_equal (strv[i], GNOME_SETTINGS_PANEL_CATEGORY))
{
g_strfreev (strv);
return TRUE;
}
}
g_strfreev (strv);
return FALSE;
}
void
cc_shell_model_add_item (CcShellModel *model,
const gchar *category_name,
@ -73,11 +104,25 @@ cc_shell_model_add_item (CcShellModel *model,
id = g_key_file_get_string (key_file, "Desktop Entry",
GNOME_SETTINGS_PANEL_ID_KEY, NULL);
g_key_file_free (key_file);
key_file = NULL;
if (!id)
id = g_strdup (gmenu_tree_entry_get_desktop_file_id (item));
{
/* Refuse to load desktop files without a panel ID, but
* with the X-GNOME-Control-Center-Panel category */
if (desktop_entry_has_panel_category (key_file))
{
g_warning ("Not loading desktop file '%s' because it uses the "
GNOME_SETTINGS_PANEL_CATEGORY
" category but isn't a panel.",
desktop);
g_key_file_free (key_file);
return;
}
id = g_strdup (gmenu_tree_entry_get_desktop_file_id (item));
}
g_key_file_free (key_file);
key_file = NULL;
/* find the icon */
if (icon != NULL && *icon == '/')