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

@ -6,6 +6,6 @@ Icon=preferences-desktop-wallpaper
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings; Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Settings-Panel=background X-GNOME-Settings-Panel=background

View file

@ -6,6 +6,6 @@ Icon=preferences-system-time
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings; Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Settings-Panel=datetime X-GNOME-Settings-Panel=datetime

View file

@ -6,7 +6,7 @@ Icon=gnome-settings-default-applications
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings; Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=preferences-desktop-display
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings; Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=preferences-desktop-keyboard-shortcuts
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings; Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=preferences-desktop-keyboard
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings; Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=input-mouse
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings; Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=gnome-network-properties
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;X-GNOME-NetworkSettings; Categories=GNOME;GTK;Settings;X-GNOME-NetworkSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -6,7 +6,7 @@ Icon=preferences-desktop-accessibility
Terminal=false Terminal=false
Type=Application Type=Application
StartupNotify=true StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings; Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME; OnlyShowIn=GNOME;
X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#define GNOME_SETTINGS_PANEL_ID_KEY "X-GNOME-Settings-Panel" #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) 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); 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 void
cc_shell_model_add_item (CcShellModel *model, cc_shell_model_add_item (CcShellModel *model,
const gchar *category_name, 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", id = g_key_file_get_string (key_file, "Desktop Entry",
GNOME_SETTINGS_PANEL_ID_KEY, NULL); GNOME_SETTINGS_PANEL_ID_KEY, NULL);
g_key_file_free (key_file);
key_file = NULL;
if (!id) if (!id)
{
/* 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)); id = g_strdup (gmenu_tree_entry_get_desktop_file_id (item));
}
g_key_file_free (key_file);
key_file = NULL;
/* find the icon */ /* find the icon */
if (icon != NULL && *icon == '/') if (icon != NULL && *icon == '/')

View file

@ -18,6 +18,7 @@
<Menuname>Internet and Network</Menuname> <Menuname>Internet and Network</Menuname>
<Menuname>Hardware</Menuname> <Menuname>Hardware</Menuname>
<Menuname>System</Menuname> <Menuname>System</Menuname>
<Menuname>Other</Menuname>
<Merge type="all" /> <Merge type="all" />
</Layout> </Layout>
@ -51,10 +52,12 @@
<And> <And>
<Category>Settings</Category> <Category>Settings</Category>
<Category>X-GNOME-PersonalSettings</Category> <Category>X-GNOME-PersonalSettings</Category>
<Category>X-GNOME-Settings-Panel</Category>
</And> </And>
<And> <And>
<Category>Settings</Category> <Category>Settings</Category>
<Category>DesktopSettings</Category> <Category>DesktopSettings</Category>
<Category>X-GNOME-Settings-Panel</Category>
</And> </And>
</Include> </Include>
</Menu> <!-- End Personal --> </Menu> <!-- End Personal -->
@ -67,6 +70,7 @@
<And> <And>
<Category>Settings</Category> <Category>Settings</Category>
<Category>X-GNOME-NetworkSettings</Category> <Category>X-GNOME-NetworkSettings</Category>
<Category>X-GNOME-Settings-Panel</Category>
</And> </And>
</Include> </Include>
</Menu> <!-- End Internet and Network --> </Menu> <!-- End Internet and Network -->
@ -79,6 +83,7 @@
<And> <And>
<Category>Settings</Category> <Category>Settings</Category>
<Category>HardwareSettings</Category> <Category>HardwareSettings</Category>
<Category>X-GNOME-Settings-Panel</Category>
</And> </And>
</Include> </Include>
</Menu> <!-- End Hardware --> </Menu> <!-- End Hardware -->
@ -90,6 +95,7 @@
<Include> <Include>
<And> <And>
<Category>Settings</Category> <Category>Settings</Category>
<Category>X-GNOME-Settings-Panel</Category>
<Or> <Or>
<Category>X-GNOME-SystemSettings</Category> <Category>X-GNOME-SystemSettings</Category>
<And> <And>
@ -108,4 +114,18 @@
</Include> </Include>
</Menu> <!-- End System --> </Menu> <!-- End System -->
<!-- Other category -->
<Menu>
<Name>Other</Name>
<Directory>X-GNOME-Other.directory</Directory>
<Include>
<And>
<Category>Settings</Category>
<Not>
<Category>X-GNOME-Settings-Panel</Category>
</Not>
</And>
</Include>
</Menu> <!-- End Other -->
</Menu> <!-- End CC --> </Menu> <!-- End CC -->