[gnome-control-center] shell: Only load desktop files from our dirs
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: Only load desktop files from our dirs
- Date: Fri, 26 Aug 2011 10:35:49 +0000 (UTC)
commit dde732b9a9f565969c2a3a1d51f17f072d19f0a1
Author: Bastien Nocera <hadess hadess net>
Date: Fri Aug 26 10:28:58 2011 +0100
shell: Only load desktop files from our dirs
As we don't know how to load the extension points in the
other directories anyway. Stops system-wide desktop files
appearing in a prefixed build.
shell/Makefile.am | 1 +
shell/gnome-control-center.c | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/shell/Makefile.am b/shell/Makefile.am
index d6a4f71..3a9600a 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -40,6 +40,7 @@ AM_CPPFLAGS = \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DUIDIR="\"$(uidir)\"" \
-DMENUDIR="\"$(menudir)\"" \
+ -DDESKTOP_FILES_DIR="\"$(datadir)/applications/\"" \
-DPANELS_DIR="\"$(PANELS_DIR)\""
menudir = $(sysconfdir)/xdg/menus
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 3725a63..a42aa79 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -63,6 +63,7 @@ struct _GnomeControlCenterPrivate
GtkWidget *lock_button;
GMenuTree *menu_tree;
+ char *desktop_files_dir;
GtkListStore *store;
GHashTable *category_views;
@@ -648,6 +649,19 @@ maybe_add_category_view (GnomeControlCenter *shell,
g_hash_table_insert (shell->priv->category_views, g_strdup (name), categoryview);
}
+static gboolean
+item_is_in_dir (GnomeControlCenter *shell,
+ GMenuTreeEntry *item)
+{
+ const char *path;
+
+ path = gmenu_tree_entry_get_desktop_file_path (item);
+
+ if (g_str_has_prefix (path, shell->priv->desktop_files_dir))
+ return TRUE;
+ return FALSE;
+}
+
static void
reload_menu (GnomeControlCenter *shell)
{
@@ -689,9 +703,12 @@ reload_menu (GnomeControlCenter *shell)
if (sub_next_type == GMENU_TREE_ITEM_ENTRY)
{
GMenuTreeEntry *item = gmenu_tree_iter_get_entry (sub_iter);
- cc_shell_model_add_item (CC_SHELL_MODEL (shell->priv->store),
- dir_name,
- item);
+ if (item_is_in_dir (shell, item))
+ {
+ cc_shell_model_add_item (CC_SHELL_MODEL (shell->priv->store),
+ dir_name,
+ item);
+ }
gmenu_tree_item_unref (item);
}
}
@@ -716,6 +733,7 @@ static void
setup_model (GnomeControlCenter *shell)
{
GnomeControlCenterPrivate *priv = shell->priv;
+ GFile *file;
gtk_container_set_border_width (GTK_CONTAINER (shell->priv->main_vbox), 10);
gtk_container_set_focus_vadjustment (GTK_CONTAINER (shell->priv->main_vbox),
@@ -725,6 +743,11 @@ setup_model (GnomeControlCenter *shell)
priv->category_views = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
priv->menu_tree = gmenu_tree_new_for_path (MENUDIR "/gnomecc.menu", 0);
+ /* Normalise the file path, to avoid repeat slashes */
+ file = g_file_new_for_path (DESKTOP_FILES_DIR);
+ priv->desktop_files_dir = g_file_get_path (file);
+ g_object_unref (file);
+
reload_menu (shell);
g_signal_connect (priv->menu_tree, "changed", G_CALLBACK (on_menu_changed), shell);
@@ -955,6 +978,12 @@ gnome_control_center_finalize (GObject *object)
g_object_unref (priv->menu_tree);
}
+ if (priv->desktop_files_dir)
+ {
+ g_free (priv->desktop_files_dir);
+ priv->desktop_files_dir = NULL;
+ }
+
if (priv->category_views)
{
g_hash_table_destroy (priv->category_views);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]