[gnome-menus] [editor] Better fix for XDG_MENU_PREFIX support in editor



commit 2054996af842e6df1726e58d81a569f03e30d75f
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Jun 30 12:36:26 2010 +0200

    [editor] Better fix for XDG_MENU_PREFIX support in editor
    
    The previous fix was partly wrong, because the menu file referenced in
    the created user menu file was not using the prefix.
    
    So instead of letting the library handle XDG_MENU_PREFIX, we handle it
    ourselves everywhere.

 simple-editor/GMenuSimpleEditor/menufilewriter.py |   10 ++--------
 simple-editor/GMenuSimpleEditor/menutreemodel.py  |    3 +++
 2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/simple-editor/GMenuSimpleEditor/menufilewriter.py b/simple-editor/GMenuSimpleEditor/menufilewriter.py
index 9f17ab5..16bb46a 100644
--- a/simple-editor/GMenuSimpleEditor/menufilewriter.py
+++ b/simple-editor/GMenuSimpleEditor/menufilewriter.py
@@ -145,12 +145,6 @@ class MenuFileWriter:
 
     def sync (self, iter):
         menu_file = self.model[iter][self.model.COLUMN_MENU_FILE]
-
-        if os.environ.has_key ("XDG_MENU_PREFIX") and menu_file == "applications.menu":
-            prefixed_menu_file = os.environ["XDG_MENU_PREFIX"] + menu_file
-        else:
-            prefixed_menu_file = menu_file
-
         system_menu_file = menutreemodel.lookup_system_menu_file (menu_file)
         
         (contents, has_changes) = self.__append_menu (DTD_DECLARATION,
@@ -160,12 +154,12 @@ class MenuFileWriter:
 
         if not has_changes:
             try:
-                os.remove (get_user_menu_file_path (prefixed_menu_file))
+                os.remove (get_user_menu_file_path (menu_file))
             except:
                 pass
             return
             
-        write_file (get_user_menu_file_path (prefixed_menu_file), contents)
+        write_file (get_user_menu_file_path (menu_file), contents)
 
     def __sync_idle_handler_func (self, iter):
         self.sync (iter)
diff --git a/simple-editor/GMenuSimpleEditor/menutreemodel.py b/simple-editor/GMenuSimpleEditor/menutreemodel.py
index 5856d56..214319e 100644
--- a/simple-editor/GMenuSimpleEditor/menutreemodel.py
+++ b/simple-editor/GMenuSimpleEditor/menutreemodel.py
@@ -107,6 +107,9 @@ class MenuTreeModel (gtk.TreeStore):
             menu_files = ["applications.menu", "settings.menu"]
 
         for menu_file in menu_files:
+            if menu_file == "applications.menu" and os.environ.has_key ("XDG_MENU_PREFIX"):
+                menu_file = os.environ["XDG_MENU_PREFIX"] + menu_file
+
             tree = gmenu.lookup_tree (menu_file, gmenu.FLAGS_INCLUDE_EXCLUDED)
             tree.sort_key = gmenu.SORT_DISPLAY_NAME
             self.__append_directory (tree.root, None, False, menu_file)



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