> Thomas Funk <t.funk...@googlemail.com> wrote:
>> Dan, I will send you a small bugfix patch for the actual CVS version. The
>> fixes are in the last patch included but as this is a proof of concept
>> would be better to seperate them.
> Okay.  As you've seen I'm a bit slow to look at these things.
> I haven't looked at your latest work yet.
> I will get to it though.
Attached the patch for
- fixing bug, that empty menus were generated
- fix your fixme for Regenerate Applications Menu
- add forgotten --version
- add forgotten -t for title option
- update help

Thomas
--- /media/daten/shared/sourcen/cvs/fvwm/bin/fvwm-menu-desktop.in	2012-07-13 13:14:31.428392223 +0200
+++ fvwm-menu-desktop.in.p4.1.py	2012-07-18 00:20:03.011125095 +0200
@@ -97,7 +97,7 @@
 
     try:
         opts, args = getopt.getopt(sys.argv[1:], "hs:t:vw",
-                                   ["help", "verbose", "enable-mini-icons", "with-titles", "verbose",
+                                   ["help", "verbose", "enable-mini-icons", "with-titles", "verbose", "version",
                                     "desktop=", "size=", "theme=", "install-prefix=", "menu-type=", "title="]+obs_args+equaled_obs_parms)
     except getopt.GetoptError, err:
         # print help information and exit:
@@ -105,6 +105,7 @@
         print usage
         sys.exit(2)
     global verbose, force, size, theme, icon_dir, top, install_prefix, menu_type, with_titles, menu_entry_count
+    version = "2.0"
     verbose = False
     force = False
     desktop=''
@@ -123,11 +124,14 @@
         elif o in ("-h", "--help") :
             print usage
             sys.exit()
+        elif o in ("--version") :
+            print "fvwm-menu-desktop version " + version
+            sys.exit()
         elif o in ("--enable-mini-icons") :
             force=True
         elif o in ("--desktop") :
             desktop=a
-        elif o in ("--title") :
+        elif o in ("-t", "--title") :
             top=a
         elif o in ("--install-prefix") :
             if a and not os.path.isabs(a):
@@ -364,6 +368,7 @@
     printtext('+ "%s%s" %s' % (name, iconfile, command))
 
 def parsemenus(menulist, desktop):
+    global menu_entry_count
     if len(menulist) == 1:
         # user defines only one special menu
         parsemenu(xdg.Menu.parse(menulist[0]), top)
@@ -385,6 +390,7 @@
             if not menu_entry_count == 0:
                 new_toptitles.append(title)
                 new_menulist.append(menu)
+                menu_entry_count = 0
             else:
                 vprint(" Menu is empty - won't be used!")
         
@@ -402,8 +408,10 @@
 def parsemenu(menu, name="", title=""):
     global menu_entry_count
     m = re.compile('%[A-Z]?', re.I) # Pattern for %A-Z (meant for %U)
+    gen_name = ''
     if not name :
         name = menu.getPath()
+        gen_name = menu.getPath(True)
     if not title:
         title = name
     printtext('DestroyMenu "%s"' % name)
@@ -422,15 +430,16 @@
             menu_entry_count += 1
     	else:
     	    printtext('# not supported: ' + str(entry))
+
+    if gen_name == 'System':
+        printmenu("Regenerate XDG Menu(s)", "system-software-update", "FvwmForm FvwmForm-Desktop" )
+
     printtext('')
 
     for entry in menu.getEntries():
     	if isinstance(entry, xdg.Menu.Menu):
     	    parsemenu(entry)
 
-    if (re.search('.*System Tools$',name)) : # fixme, find a better way to do this?
-        printmenu("Regenerate Applications Menu", "", "FvwmForm " "FvwmForm-Desktop" )
-
 usage="""
 A script which parses xdg menu definitions to build
 the corresponding fvwm menus.
@@ -443,13 +452,13 @@
                               For the system wide menus use /etc/xdg/menus/
     --desktop NAME            desktop name to build menus for:
                               gnome, kde, xfce, lxde, debian, etc.
-    --menu-type NAME          applications (default), settings, preferences, etc.
+    --menu-type NAME          applications, settings, preferences, etc.
     --theme NAME              gnome (default), oxygen, etc. Don't use hicolor. 
                               It's the default fallback theme if no icon will be found.
     -w, --with-titles         generate menus with titles.
     --enable-mini-icons       enable mini-icons in menu
-    -s, --size                set size of mini-icons in menu. Default is 24.
-    --title NAME              menu title of the top menu used by Popup command.
+    -s, --size NUM            set size of mini-icons in menu. Default is 24.
+    -t, --title NAME          menu title of the top menu used by Popup command.
                               Default is FvwmMenu
     -v, --verbose             run and display debug info on STDERR"""
 

Reply via email to