Skip to content

Commit

Permalink
handle XDG_MENU_PREFIX, like it was in GNOME2/GNOME3
Browse files Browse the repository at this point in the history
do not enforce hardcoded mate prefix
  • Loading branch information
glensc committed Jan 16, 2013
1 parent 9ae808b commit ea38655
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mate-menus.spec
@@ -1,12 +1,13 @@
Summary: Displays menus for MATE Desktop
Name: mate-menus
Version: 1.5.0
Release: 1
Release: 2
License: GPL v2+ and LGPL v2+
Group: X11/Applications
Source0: http://pub.mate-desktop.org/releases/1.5/%{name}-%{version}.tar.xz
# Source0-md5: fc36e94245d8508cda14c2cd436aad5a
URL: http://wiki.mate-desktop.org/mate-menus
Patch0: xdg-menu-prefix-compat.patch
BuildRequires: gobject-introspection-devel
BuildRequires: intltool >= 0.40.0
BuildRequires: mate-common >= 1.5
Expand Down Expand Up @@ -35,6 +36,7 @@ Development files for mate-menus

%prep
%setup -q
%patch0 -p1

%build
NOCONFIGURE=1 ./autogen.sh
Expand Down
73 changes: 73 additions & 0 deletions xdg-menu-prefix-compat.patch
@@ -0,0 +1,73 @@
restore XDG_MENU_PREFIX functionality

23:19:05 glen> hmm, xdg menus does not seem to work
23:19:07 glen> i mean $XDG_MENU_PREFIX
23:19:09 glen> is not respected
23:19:51 glen> 23:19:38 root[load: 3.16]@blodnatt xdg/menus# ls -l /etc/xdg/menus/${XDG_MENU_PREFIX}applications.menu
23:19:51 glen> -rw-r--r-- 1 root root 23K 18. mai 2012 /etc/xdg/menus/applnk-applications.menu

seems perberos just renamed the file not to conflict file installed by GNOME

additionally load mate-applications.menu if XDG_MENU_PREFIX is not set, as this
is how we package mate applications.menu.
--- mate-menus-1.5.0/./libmenu/matemenu-tree.c~ 2012-10-11 11:26:03.000000000 +0300
+++ mate-menus-1.5.0/./libmenu/matemenu-tree.c 2013-01-15 23:41:33.733159313 +0200
@@ -539,7 +539,7 @@
{
matemenu_tree_remove_menu_file_monitors (tree);

- if (strcmp(tree->basename, "mate-applications.menu") == 0 && g_getenv("XDG_MENU_PREFIX"))
+ if (strcmp(tree->basename, "applications.menu") == 0 && g_getenv("XDG_MENU_PREFIX"))
{
char* prefixed_basename;
prefixed_basename = g_strdup_printf("%s%s", g_getenv("XDG_MENU_PREFIX"), tree->basename);
@@ -1895,7 +1895,7 @@
found = FALSE;
menu_file = g_strconcat(menu_name, ".menu", NULL);

- if (strcmp(menu_file, "mate-applications.menu") == 0 && g_getenv("XDG_MENU_PREFIX"))
+ if (strcmp(menu_file, "applications.menu") == 0 && g_getenv("XDG_MENU_PREFIX"))
{
char* prefixed_basename;
prefixed_basename = g_strdup_printf("%s%s", g_getenv("XDG_MENU_PREFIX"), menu_file);
--- mate-menus-1.5.0/util/test-menu-spec.c~ 2012-10-11 11:26:03.000000000 +0300
+++ mate-menus-1.5.0/util/test-menu-spec.c 2013-01-15 23:36:26.719020435 +0200
@@ -191,8 +191,7 @@
flags |= MATEMENU_TREE_FLAGS_INCLUDE_NODISPLAY;
}

- // Usamos applications.menu is existe. Para compatibilidad con GNOME
- MateMenuTree* tree = matemenu_tree_lookup(menu_file ? menu_file : "mate-applications.menu", flags);
+ MateMenuTree* tree = matemenu_tree_lookup(menu_file ? menu_file : "applications.menu", flags);

g_assert(tree != NULL);

--- mate-menus-1.5.0/util/mate-menus-ls.py~ 2012-10-11 11:26:03.000000000 +0300
+++ mate-menus-1.5.0/util/mate-menus-ls.py 2013-01-15 23:37:38.595663893 +0200
@@ -72,7 +72,7 @@
if options.file:
menu_file = options.file
else:
- menu_file = 'mate-applications.menu'
+ menu_file = 'applications.menu'

flags = matemenu.FLAGS_NONE
if options.exclude:
--- mate-menus-1.5.0/libmenu/matemenu-tree.c~ 2013-01-16 11:12:55.000000000 +0200
+++ mate-menus-1.5.0/libmenu/matemenu-tree.c 2013-01-16 12:36:08.224428926 +0200
@@ -1903,6 +1903,15 @@
g_free(prefixed_basename);
}

+ // load mate-applications.menu
+ if (!found && !g_getenv("XDG_MENU_PREFIX"))
+ {
+ char* prefixed_basename;
+ prefixed_basename = g_strdup_printf("mate-%s", menu_file);
+ found = load_parent_merge_file_from_basename(tree, loaded_menu_files, layout, prefixed_basename, canonical_basedir);
+ g_free(prefixed_basename);
+ }
+
if (!found)
{
found = load_parent_merge_file_from_basename(tree, loaded_menu_files, layout, menu_file, canonical_basedir);

0 comments on commit ea38655

Please sign in to comment.