rpms/fluxbox/FC-4 fluxbox-xdg-menu.py, 1.2, 1.3 fluxbox.spec, 1.17, 1.18 fluxbox-menu.patch, 1.1, NONE

Andreas Bierfert (awjb) fedora-extras-commits at redhat.com
Sat Oct 21 09:38:43 UTC 2006


Author: awjb

Update of /cvs/extras/rpms/fluxbox/FC-4
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1585/FC-4

Modified Files:
	fluxbox-xdg-menu.py fluxbox.spec 
Removed Files:
	fluxbox-menu.patch 
Log Message:
- fix #209347 and #187740
- fc{5,6} fix #196106 



Index: fluxbox-xdg-menu.py
===================================================================
RCS file: /cvs/extras/rpms/fluxbox/FC-4/fluxbox-xdg-menu.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fluxbox-xdg-menu.py	5 Apr 2006 21:19:29 -0000	1.2
+++ fluxbox-xdg-menu.py	21 Oct 2006 09:38:12 -0000	1.3
@@ -1,20 +1,34 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
+# vim: noexpandtab:ts=4:sts=4
+
 """Menu Generator for Fluxbox
 
 Generates a menu for Fluxbox using the freedesktop.org standards
 
-Usage: fluxbox-fdo-menugen.py [options]
+Usage: fluxbox-xdg-menu.py [options]
 
 Options:
   -l ..., --lang=...      create the menu using a language. Default = $LANG
   -h, --help              show this help
   -f ..., --file=...      output the menu into a file. Default = ~/.fluxbox/menu
-  --with-icons         do not put icons for applications in the menu
+  -t ..., --theme=...     what icon theme you want to use
+  --with-icons            put icons for applications in the menu
   --stdout                output the menu to standard output
+  --submenu               output to be used as an include/submenu with fluxbox
+  --with-backgrounds      creates a background menu. Default background_paths = 
+                          ~/.fluxbox/backgrounds, /usr/share/wallpapers,
+                          /usr/share/backgrounds
+  --backgrounds-only      do not regenerate menu, only do the bg menu.
+  --bg-path=              path to location to look for images 
+                          example: --bg-path=~/pics  
+			  may be used with --backgrounds-only but --bg-path= 
+			  must be first: --bg-path=~/some/path --backgrounds-only
 
+A nice example string to use: fluxbox-fdo-menugen.py --with-icons --with-backgrounds --bg-path=~/some/path
+To update only the backgrounds: fluxbox-fdo-menugen.py --bg-path=~/some/path --backgrounds-only
 """
 
-__author__ = "Rudolf Kastl , Antonio Gomes"
+__author__ = "Rudolf Kastl , Antonio Gomes, Michael Rice"
 __version__ = "$Revision$"
 __date__ = "$Date$"
 __license__ = "GPL"
@@ -22,6 +36,7 @@
 
 import os,re,sys,glob,getopt
 import xdg.Menu,xdg.DesktopEntry,xdg.IconTheme
+from os.path import isfile
 
 def usage():
 	print __doc__
@@ -31,7 +46,7 @@
 [begin] (Fluxbox)
 	[exec] (Web Browser) {htmlview}
 	[exec] (Email) {evolution}
-	[exec] (Terminal) {gnome-terminal}
+	[exec] (Terminal) {$TERM}
 	[exec] (Irc) {xchat}
 	[separator]\n"""
 
@@ -78,66 +93,31 @@
 			else:
 				entry.Show = True 
 	
-#def findIcon(icon):
-#	"""Finds the path and filename for the given icon name
-#		e.g. gaim --> /usr/share/pixmaps/gaim.png
-#		e.g. fart.png --> /usr/share/pixmaps/fart.png
-#	"""
-#	if os.path.isfile(icon): return icon
-#	paths = ["~/.icons","/usr/share/pixmaps","/usr/share/icons"]
-#	for path in paths:
-#		for dirpath , dirnames, filenames in os.walk(os.path.expanduser(path)):
-#			for filename in filenames:
-#				pattern = '^%s\.(png|jpg|gif|xpm)' % icon # matches <filename>.<something>
-#				if icon == filename or re.search(pattern, filename):
-#					return os.path.join(dirpath,filename)
-
-
-def findIcon(icon):
+def findIcon(icon, theme):
 	"""Finds the path and filename for the given icon name
 		e.g. gaim --> /usr/share/pixmaps/gaim.png
 		e.g. fart.png --> /usr/share/pixmaps/fart.png
 	"""
-	global paths
-	global locs
-
-	# Case Icon=/path/to/file.extension
-	if os.path.isfile(icon): return icon
-
-
-	# Case Icon=file.extension	
-
-	if re.search("^\w+.*\.\w{3}$",icon):
-		names=[icon]
-	# Case Icon=file
-	elif re.search("^\w+.*$",icon):
-		names=[icon+".png",icon+".xpm",icon+".jpg"]
-	else:
-		names=[]
+	retval=str(xdg.IconTheme.getIconPath(icon, 48, theme))
+	if retval == "None":
+		retval=""
 
-	for path in paths:	
-		for name in names:
-			if (os.path.isfile(path+name)):
-				locs.append(path)
-				return (path+name).encode('utf8')
+	return (retval + "").encode('utf8')
 
-
-def parseMenu(menu,depth=1):
-	global wm
-	global use_icons
+def parseMenu(menu,wm,use_icons,theme,depth=1):
 	if use_icons:
-		print "%s[submenu] (%s) <%s> " % ( (depth*"\t"), menu.getName().encode('utf8'), findIcon(menu.getIcon()) )
+		print "%s[submenu] (%s) <%s> " % ( (depth*"\t"), menu.getName().encode('utf8'),  findIcon(menu.getIcon(), theme) )
 	else:
 		print "%s[submenu] (%s) " % ( (depth*"\t"), menu.getName().encode('utf8'), )
 	depth += 1
 	for entry in menu.getEntries():
 		if isinstance(entry, xdg.Menu.Menu):
-			parseMenu(entry,depth)
+			parseMenu(entry,wm,use_icons,theme,depth)
 		elif isinstance(entry, xdg.Menu.MenuEntry):
 			checkWm(entry,wm)
 			if entry.Show == False: continue
 			if use_icons:
-				print "%s[exec] (%s) {%s} <%s> " % ( (depth*"\t"), entry.DesktopEntry.getName().encode("utf8"), entry.DesktopEntry.getExec().split()[0], findIcon(entry.DesktopEntry.getIcon()) )
+				print "%s[exec] (%s) {%s} <%s> " % ( (depth*"\t"), entry.DesktopEntry.getName().encode("utf8"), entry.DesktopEntry.getExec().split()[0], findIcon(entry.DesktopEntry.getIcon(), theme) )
 			else:
 				print "%s[exec] (%s) {%s} " % ( (depth*"\t"), entry.DesktopEntry.getName().encode("utf8"), entry.DesktopEntry.getExec().split()[0] )
 		elif isinstance(entry,xdg.Menu.Separator):
@@ -147,22 +127,77 @@
 	depth -= 1
 	print "%s[end]" % (depth*"\t")
 
+def get_bgimgs_and_parse(xPath):
+    try:
+        if isfile(os.path.expanduser("~/.fluxbox/bgmenu")) == True:
+            os.unlink(os.path.expanduser("~/.fluxbox/bgmenu"))
+    except OSError:
+        pass
+    h = {}
+    bg_paths =["~/.fluxbox/backgrounds","/usr/share/wallpapers",
+		"/usr/share/backgrounds","/usr/share/backgrounds/images"]
+    try:
+        if xPath == None:
+           pass
+        else:
+            bg_paths.append(xPath)
+    except(TypeError):
+        pass
+    for dir in bg_paths:
+        for imgpth in bg_paths:
+            try:
+                imgs = os.listdir(os.path.expanduser(imgpth))
+                for i in imgs:
+                    h[i] = imgpth
+            except (OSError):
+                pass
+    bgMenu = open(os.path.expanduser("~/.fluxbox/bgmenu"),'w+')
+    num = len(h)
+    countNum = 1
+    bgPagCk = 1
+    bgPgNum = 1
+    bgMenu.write( "[submenu] (Backgrounds)\n" )
+    bgMenu.write( "[submenu] (Backgrounds) {Set Your Background}\n" )
+    bgMenu.write("\t[exec]  (Random Image)  {fbsetbg -r ~/.fluxbox/backgrounds}\n")
+	types = ["png","jpg","jpeg","gif"]
+    for i in h.keys():
+	    try:
+		    t = i.split(".")[-1].lower()
+			if t in types:
+			    print "Hello"
+			    bgMenu.write( "\t[exec]\t("+ i +") {fbsetbg -f "+ h[i] + "/" + i +"}\n" )
+				countNum = countNum + 1
+				num = num - 1
+				bgPagCk = bgPagCk + 1
+				if bgPagCk == 26:
+				    bgPgNum = bgPgNum + 1
+					bgMenu.write("[end]\n[submenu] (Backgrounds " + str(bgPgNum) +") \
+						{Set Your Background}\n")
+					bgPagCk = 1
+				if num == 0:
+				    bgMenu.write( "[end]\n[end]\n" )
+					bgMenu.close()
+		except(KeyError):
+		    print h[i]
+		    pass
 
 def main(argv):
 # Setting the default values
-	global locs
-	locs=[]
-	global wm
 	wm = "fluxbox"
-	global file
 	file = "~/.fluxbox/menu"
-	global use_icons
 	use_icons = False
+    use_bg = False
+    bg_Xpath = False
+	theme = "gnome"
 	lang = os.getenv("LANG","C")
 	file = os.path.expanduser("~/.fluxbox/menu")
+	do_submenu = False
+	use_stdout = False
 	
 	try:
-		opts, args = getopt.getopt(argv, "hf:dl:d", ["help","lang=","file=","with-icons","stdout"])
+		opts, args = getopt.getopt(argv, "hf:dl:d", ["help","lang=","file=","with-icons","stdout",\
+			"theme=","submenu","with-backgrounds","backgrounds-only","bg-path="])
+
 	except getopt.GetoptError:
 		usage()
 		sys.exit(2)
@@ -175,50 +210,51 @@
 		elif opt in ("-f", "--file"):
 			file = os.path.expanduser(arg)
 		elif opt == '--with-icons':
-			use_icons = True		
-			global paths
-			locations = \
-			['/usr/share/pixmaps/', \
-			'/usr/share/icons/hicolor/24x24/apps/', \
-			'/usr/share/icons/hicolor/32x32/apps/', \
-			'/usr/share/icons/hicolor/48x48/apps/', \
-			'/usr/share/icons/hicolor/24x24/stock/generic/', \
-			'/usr/share/icons/HighContrastLargePrintInverse/48x48/apps/', \
-			'/usr/share/icons/crystalsvg/16x16/apps/', \
-			'/usr/share/icons/crystalsvg/32x32/apps/', \
-			'/usr/share/icons/crystalsvg/48x48/apps/', \
-			'/usr/share/icons/crystalsvg/48x48/devices/', \
-			'/usr/share/icons/', \
-			'/usr/share/icons/hicolor/32x32/apps/', \
-			'/usr/share/icons/Bluecurve/24x24/stock/', \
-			'/usr/share/icons/Bluecurve/48x48/filesystems/']
-			paths=locations
-#			for path in locations:
-#				paths+=glob.glob(path+"/*/")+glob.glob(path+"/*/*/")
-#			print paths
+			use_icons = True
+		elif opt in ("-t", "--theme"):
+			theme = arg
+		elif opt == '--stdout':
+			use_stdout = True
 		elif opt == '--stdout':
 			file = sys.stdout
-
-
-	fsock = open(file,'w')
-	saveout = sys.stdout
-	sys.stdout = fsock
+		elif opt == '--bg-path':
+		    bg_Xpath = True
+			xPath = os.path.expanduser(arg)
+		elif opt == '--with-backgrounds':
+		    use_bg = True
+		elif opt == '--backgrounds-only':
+		    if bg_Xpath:
+			    get_bgimgs_and_parse(xPath)
+			else:
+			    get_bgimgs_and_parse(None)
+				raise SystemExit
+			  
+		elif opt == '--submenu':
+			do_submenu = True
+
+	if not use_stdout:
+		fsock = open(file,'w')
+		saveout = sys.stdout
+		sys.stdout = fsock
 
 	menu=xdg.Menu.parse()
 # is done automatically now
 #	menu.setLocale(lang)
 
-	print header()
-	parseMenu(menu)
-	print footer()
+	if not do_submenu:
+        print header()
+	parseMenu(menu,wm,use_icons,theme)
+	if not do_submenu and use_bg and bg_Xpath:
+	    get_bgimgs_and_parse(xPath) 
+	    print "[include] (~/.fluxbox/bgmenu)"
+	if not do_submenu and use_bg and not bg_Xpath:
+	    print "[include] (~/.fluxbox/bgmenu)"
+		get_bgimgs_and_parse(None)
+    if not do_submenu:
+        print footer()
+	if not use_stdout:
+		sys.stdout = saveout
 
-	sys.stdout = saveout
 #	print menu
 if __name__ == "__main__":
 	main(sys.argv[1:])
-
-#WindowMaker Reminder
-#>>> p=re.compile("(\).*),(\s*\))")
-#>>> p.search("((ola),(ola),)").groups()
-#('),(ola)', ')')
-


Index: fluxbox.spec
===================================================================
RCS file: /cvs/extras/rpms/fluxbox/FC-4/fluxbox.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- fluxbox.spec	5 Apr 2006 21:19:29 -0000	1.17
+++ fluxbox.spec	21 Oct 2006 09:38:12 -0000	1.18
@@ -1,6 +1,6 @@
 Name:           fluxbox
 Version:        0.9.15.1
-Release:        1%{?dist}
+Release:        2%{?dist}
 
 Summary:	Window Manager based on Blackbox
 
@@ -13,7 +13,6 @@
 Source2:        FluxBox
 Source3:        fluxbox.desktop
 Source4:        fluxbox-xdg-menu.py
-Patch1:         fluxbox-menu.patch
 
 BuildRoot:	%{_tmppath}/%{name}-%{version}-buildroot
 BuildRequires:  imlib2-devel
@@ -35,7 +34,6 @@
 
 %prep
 %setup -q
-%patch1
 
 %build
 %configure      --enable-xft \
@@ -80,6 +78,10 @@
 %{_sysconfdir}/X11/dm/Sessions/fluxbox.desktop
 
 %changelog
+* Sat Oct 21 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
+0.9.15.1-2
+- fix #187740 and #209347
+
 * Wed Apr 05 2006 Andreas Bierfert <andreas.bierfert[AT]lowlatency.de>
 0.9.15.1-1
 - version upgrade


--- fluxbox-menu.patch DELETED ---




More information about the scm-commits mailing list