[gnome-control-center] shell: Show settings without a panel in Other



commit 4ec7801cbb264ab7a56449291704d8946fc1ed84
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Sep 30 13:29:23 2010 +0100

    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

 .../gnome-background-panel.desktop.in.in           |    2 +-
 panels/datetime/gnome-datetime-panel.desktop.in.in |    2 +-
 .../gnome-default-applications-panel.desktop.in.in |    2 +-
 panels/display/gnome-display-panel.desktop.in.in   |    2 +-
 .../gnome-keybindings-panel.desktop.in.in          |    2 +-
 panels/keyboard/gnome-keyboard-panel.desktop.in.in |    2 +-
 panels/mouse/gnome-mouse-panel.desktop.in.in       |    2 +-
 panels/network/gnome-network-panel.desktop.in.in   |    2 +-
 .../gnome-universal-access-panel.desktop.in.in     |    2 +-
 shell/cc-shell-model.c                             |   51 ++++++++++++++++++-
 shell/gnomecc.menu                                 |   26 +++++++++-
 11 files changed, 80 insertions(+), 15 deletions(-)
---
diff --git a/panels/background/gnome-background-panel.desktop.in.in b/panels/background/gnome-background-panel.desktop.in.in
index 67b540d..2aef884 100644
--- a/panels/background/gnome-background-panel.desktop.in.in
+++ b/panels/background/gnome-background-panel.desktop.in.in
@@ -6,6 +6,6 @@ Icon=preferences-desktop-wallpaper
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;DesktopSettings;
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Settings-Panel=background
diff --git a/panels/datetime/gnome-datetime-panel.desktop.in.in b/panels/datetime/gnome-datetime-panel.desktop.in.in
index 26b43d7..17ca53e 100644
--- a/panels/datetime/gnome-datetime-panel.desktop.in.in
+++ b/panels/datetime/gnome-datetime-panel.desktop.in.in
@@ -6,6 +6,6 @@ Icon=preferences-system-time
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;DesktopSettings;
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Settings-Panel=datetime
diff --git a/panels/default-applications/gnome-default-applications-panel.desktop.in.in b/panels/default-applications/gnome-default-applications-panel.desktop.in.in
index bcdaf9c..75e4870 100644
--- a/panels/default-applications/gnome-default-applications-panel.desktop.in.in
+++ b/panels/default-applications/gnome-default-applications-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=gnome-settings-default-applications
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;
+Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/display/gnome-display-panel.desktop.in.in b/panels/display/gnome-display-panel.desktop.in.in
index 5073f88..bc1e133 100644
--- a/panels/display/gnome-display-panel.desktop.in.in
+++ b/panels/display/gnome-display-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=preferences-desktop-display
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;HardwareSettings;
+Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/keybindings/gnome-keybindings-panel.desktop.in.in b/panels/keybindings/gnome-keybindings-panel.desktop.in.in
index 679c4ee..4191507 100644
--- a/panels/keybindings/gnome-keybindings-panel.desktop.in.in
+++ b/panels/keybindings/gnome-keybindings-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=preferences-desktop-keyboard-shortcuts
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;
+Categories=GNOME;GTK;Settings;X-GNOME-PersonalSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/keyboard/gnome-keyboard-panel.desktop.in.in b/panels/keyboard/gnome-keyboard-panel.desktop.in.in
index ce26ecb..8494e6a 100644
--- a/panels/keyboard/gnome-keyboard-panel.desktop.in.in
+++ b/panels/keyboard/gnome-keyboard-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=preferences-desktop-keyboard
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;HardwareSettings;
+Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/mouse/gnome-mouse-panel.desktop.in.in b/panels/mouse/gnome-mouse-panel.desktop.in.in
index dde4deb..4455484 100644
--- a/panels/mouse/gnome-mouse-panel.desktop.in.in
+++ b/panels/mouse/gnome-mouse-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=input-mouse
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;HardwareSettings;
+Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/network/gnome-network-panel.desktop.in.in b/panels/network/gnome-network-panel.desktop.in.in
index a565498..b52a1b4 100644
--- a/panels/network/gnome-network-panel.desktop.in.in
+++ b/panels/network/gnome-network-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=gnome-network-properties
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;X-GNOME-NetworkSettings;
+Categories=GNOME;GTK;Settings;X-GNOME-NetworkSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/panels/universal-access/gnome-universal-access-panel.desktop.in.in b/panels/universal-access/gnome-universal-access-panel.desktop.in.in
index e969d19..068b04c 100644
--- a/panels/universal-access/gnome-universal-access-panel.desktop.in.in
+++ b/panels/universal-access/gnome-universal-access-panel.desktop.in.in
@@ -6,7 +6,7 @@ Icon=preferences-desktop-accessibility
 Terminal=false
 Type=Application
 StartupNotify=true
-Categories=GNOME;GTK;Settings;DesktopSettings;
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;
 OnlyShowIn=GNOME;
 X-GNOME-Bugzilla-Bugzilla=GNOME
 X-GNOME-Bugzilla-Product=gnome-control-center
diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c
index 741007e..4ed559b 100644
--- a/shell/cc-shell-model.c
+++ b/shell/cc-shell-model.c
@@ -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 == '/')
diff --git a/shell/gnomecc.menu b/shell/gnomecc.menu
index 206429d..1496ff3 100644
--- a/shell/gnomecc.menu
+++ b/shell/gnomecc.menu
@@ -18,6 +18,7 @@
      <Menuname>Internet and Network</Menuname>
      <Menuname>Hardware</Menuname>
      <Menuname>System</Menuname>
+     <Menuname>Other</Menuname>
      <Merge type="all" />
    </Layout>
 
@@ -51,10 +52,12 @@
       <And>
         <Category>Settings</Category>
         <Category>X-GNOME-PersonalSettings</Category>
+        <Category>X-GNOME-Settings-Panel</Category>
       </And>
       <And>
         <Category>Settings</Category>
-        <Category>DesktopSettings</Category>
+	<Category>DesktopSettings</Category>
+        <Category>X-GNOME-Settings-Panel</Category>
       </And>
     </Include>
   </Menu> <!-- End Personal -->
@@ -67,10 +70,11 @@
       <And>
         <Category>Settings</Category>
         <Category>X-GNOME-NetworkSettings</Category>
+        <Category>X-GNOME-Settings-Panel</Category>
       </And>
     </Include>
   </Menu> <!-- End Internet and Network -->
-  
+
   <!-- Hardware category -->
   <Menu>
     <Name>Hardware</Name>
@@ -79,6 +83,7 @@
       <And>
         <Category>Settings</Category>
         <Category>HardwareSettings</Category>
+        <Category>X-GNOME-Settings-Panel</Category>
       </And>
     </Include>
   </Menu> <!-- End Hardware -->
@@ -90,6 +95,7 @@
     <Include>
       <And>
         <Category>Settings</Category>
+        <Category>X-GNOME-Settings-Panel</Category>
         <Or>
           <Category>X-GNOME-SystemSettings</Category>
           <And>
@@ -99,7 +105,7 @@
                 <Category>X-GNOME-PersonalSettings</Category>
                 <Category>DesktopSettings</Category>
                 <Category>HardwareSettings</Category>
-                <Category>X-GNOME-NetworkSettings</Category> 
+                <Category>X-GNOME-NetworkSettings</Category>
               </Or>
             </Not>
           </And>
@@ -108,4 +114,18 @@
     </Include>
   </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 -->



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