[gnome-menus] libmenu: always call menu_layout_load() with non_prefixed_name parameter
- From: Alexandre Rostovtsev <arostovtsev src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-menus] libmenu: always call menu_layout_load() with non_prefixed_name parameter
- Date: Thu, 6 Dec 2012 01:40:06 +0000 (UTC)
commit 9d45c5369f4a486d2ba5c3a8c3262c84172b095a
Author: Alexandre Rostovtsev <tetromino gentoo org>
Date: Sat Nov 24 15:24:50 2012 -0500
libmenu: always call menu_layout_load() with non_prefixed_name parameter
We must ensure that when loading "${XDG_MENU_PREFIX}applications.menu"
or "applications.menu", the root layout node's name is set to "applications",
not "${XDG_MENU_PREFIX}applications", because the menu spec states that the
default merge directory for "${XDG_MENU_PREFIX}applications.menu" is
"applications-merged", not "${XDG_MENU_PREFIX}applications-merged".
https://bugzilla.gnome.org/show_bug.cgi?id=688972
libmenu/gmenu-tree.c | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/libmenu/gmenu-tree.c b/libmenu/gmenu-tree.c
index 3e59c2c..8e01af4 100644
--- a/libmenu/gmenu-tree.c
+++ b/libmenu/gmenu-tree.c
@@ -60,6 +60,7 @@ struct _GMenuTree
GObject parent_instance;
char *basename;
+ char *non_prefixed_basename;
char *path;
char *canonical_path;
@@ -410,16 +411,34 @@ gmenu_tree_canonicalize_path (GMenuTree *tree,
}
else
{
+ const gchar *xdg_menu_prefix;
+
menu_file = tree->basename;
+ xdg_menu_prefix = g_getenv ("XDG_MENU_PREFIX");
- if (strcmp (tree->basename, "applications.menu") == 0 &&
- g_getenv ("XDG_MENU_PREFIX"))
+ if (xdg_menu_prefix != NULL)
{
- char *prefixed_basename;
- prefixed_basename = g_strdup_printf ("%s%s",
- g_getenv ("XDG_MENU_PREFIX"),
- tree->basename);
- canonicalize_basename (tree, prefixed_basename);
+ gchar *prefixed_basename;
+
+ prefixed_basename = g_strdup_printf ("%sapplications.menu",
+ xdg_menu_prefix);
+
+ /* Some gnome-menus using applications just use "applications.menu"
+ * as the basename and expect gnome-menus to prefix it. Others (e.g.
+ * Alacarte) explicitly use "${XDG_MENU_PREFIX}applications.menu" as
+ * the basename, because they want to save changes to the right files
+ * in ~. In both cases, we want to use "applications-merged" as the
+ * merge directory (as required by the fd.o menu spec), so we save
+ * the non-prefixed basename and use it later when calling
+ * menu_layout_load().
+ */
+ if (!g_strcmp0 (tree->basename, "applications.menu") ||
+ !g_strcmp0 (tree->basename, prefixed_basename))
+ {
+ canonicalize_basename (tree, prefixed_basename);
+ g_free (tree->non_prefixed_basename);
+ tree->non_prefixed_basename = g_strdup ("applications.menu");
+ }
g_free (prefixed_basename);
}
@@ -587,6 +606,9 @@ gmenu_tree_finalize (GObject *object)
g_free (tree->basename);
tree->basename = NULL;
+ g_free (tree->non_prefixed_basename);
+ tree->non_prefixed_basename = NULL;
+
if (tree->path != NULL)
g_free (tree->path);
tree->path = NULL;
@@ -1896,7 +1918,7 @@ load_merge_file (GMenuTree *tree,
menu_verbose ("Merging file \"%s\"\n", canonical);
- to_merge = menu_layout_load (canonical, NULL, NULL);
+ to_merge = menu_layout_load (canonical, tree->non_prefixed_basename, NULL);
if (to_merge == NULL)
{
menu_verbose ("No menu for file \"%s\" found when merging\n",
@@ -3054,7 +3076,7 @@ gmenu_tree_load_layout (GMenuTree *tree,
error = NULL;
tree->layout = menu_layout_load (tree->canonical_path,
- tree->path ? NULL : tree->basename,
+ tree->non_prefixed_basename,
error);
if (!tree->layout)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]