Frank Richter | 17 Sep 20:31
Gravatar

Patches: various

- gpg.load_keys() used to return the last UID as the name for a key. I 
think it's more sensible to return the first.
- Some feeds (*cough*mine*cough*) use pretty high resolution icons; to 
prevent the feed list getting ridiculously large cap the size of the 
icons to the "normal" icon size.
- Add "--addmenu" option to 0launch to generate menu icons. Probably 
useful for 0export.
- As suggested earlier, make 0publish-gui use gpg.load_keys() instead of 
running gpg once for each secret key found.

hth,
- f.r.
>From d971f9eb37d1fa37ee7ea27cbf2ca5ab3ec0c031 Mon Sep 17 00:00:00 2001
From: frank.richter <at> gmail.com <frank.richter <at> gmail.com>
Date: Wed, 17 Sep 2008 20:15:10 +0200
Subject: [PATCH] zeroinstall.injector.gpg.load_keys(): Use the primary UID for the name of a key

---
 zeroinstall/injector/gpg.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/zeroinstall/injector/gpg.py b/zeroinstall/injector/gpg.py
index 0342a75..7bead09 100644
--- a/zeroinstall/injector/gpg.py
+++ b/zeroinstall/injector/gpg.py
@@ -146,6 +146,8 @@ def load_keys(fingerprints):
 					keys[current_fpr].name = current_uid
 			if line.startswith('uid:'):
 				assert current_fpr is not None
+				# Only take primary UID
+				if current_uid: continue
 				parts = line.split(':')
 				current_uid = parts[9]
 				if current_fpr in keys:
-- 
1.5.6.4

>From 3341d1d630cd1571d3a087979ce57207d3e6e935 Mon Sep 17 00:00:00 2001
From: frank.richter <at> gmail.com <frank.richter <at> gmail.com>
Date: Wed, 17 Sep 2008 20:22:04 +0200
Subject: [PATCH] "Manage feeds" dialog: limit size of icons displayed in list

---
 zeroinstall/gtkui/applistbox.py |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/zeroinstall/gtkui/applistbox.py b/zeroinstall/gtkui/applistbox.py
index 27dd074..98ad214 100644
--- a/zeroinstall/gtkui/applistbox.py
+++ b/zeroinstall/gtkui/applistbox.py
@@ -121,6 +121,8 @@ class AppListBox:
 		model = self.model
 		model.clear()

+		default_icon = self.window.render_icon(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_DIALOG)
+
 		for uri in self.app_list.get_apps():
 			itr = model.append()
 			model[itr][AppListBox.URI] = uri
@@ -133,10 +135,26 @@ class AppListBox:
 			model[itr][AppListBox.NAME] = name
 			pixbuf = icon.load_icon(self.iface_cache.get_icon_path(iface))
 			if not pixbuf:
-				pixbuf = self.window.render_icon(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_DIALOG)
+				pixbuf = default_icon
+			else:
+				# Cap icon size, some icons are really high resolution
+				pixbuf = self.cap_pixbuf_dimensions(pixbuf, default_icon.get_width())
 			model[itr][AppListBox.ICON] = pixbuf

 			model[itr][AppListBox.MARKUP] = '<b>%s</b>\n<i>%s</i>' % (_pango_escape(name), _pango_escape(summary))
+			
+	def cap_pixbuf_dimensions(self, pixbuf, iconsize):
+			pixbuf_w = pixbuf.get_width()
+			pixbuf_h = pixbuf.get_height()
+			if (pixbuf_w > iconsize) or (pixbuf_h > iconsize):
+				if (pixbuf_w > pixbuf_h):
+					newheight = (pixbuf_w/pixbuf_h) * iconsize
+					newwidth = iconsize
+				else:
+					newwidth = (pixbuf_h/pixbuf_w) * iconsize
+					newheight = iconsize
+				return pixbuf.scale_simple(newwidth, newheight, gtk.gdk.INTERP_BILINEAR)
+			return pixbuf

 	def action_run(self, uri):
 		subprocess.Popen(['0launch', '--', uri])
-- 
1.5.6.4

>From 35a8481c5fbd31460bb434b933598e4e055f921b Mon Sep 17 00:00:00 2001
From: frank.richter <at> gmail.com <frank.richter <at> gmail.com>
Date: Wed, 17 Sep 2008 20:23:29 +0200
Subject: [PATCH] 0launch: Add "--addmenu" command line option to create menu icons for given feeds

---
 zeroinstall/gtkui/xdgutils.py |   11 +++++++++++
 zeroinstall/injector/cli.py   |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/zeroinstall/gtkui/xdgutils.py b/zeroinstall/gtkui/xdgutils.py
index 564316e..da860f5 100644
--- a/zeroinstall/gtkui/xdgutils.py
+++ b/zeroinstall/gtkui/xdgutils.py
@@ -90,3 +90,14 @@ def discover_existing_apps():
 				except Exception, ex:
 					warn("Failed to load .desktop file %s: %s", full, ex)
 	return already_installed
+
+def get_known_category(feed_category):
+	if feed_category:
+		categories = ['AudioVideo','Audio','Video','Development','Education','Game',
+			'Graphics','Network','Office','Settings','System','Utility']
+		feed_low = feed_category.lower()
+		for cat in categories:
+			if cat.lower() == feed_low:
+				return cat
+	return None
+
diff --git a/zeroinstall/injector/cli.py b/zeroinstall/injector/cli.py
index 57fecd1..c17988d 100644
--- a/zeroinstall/injector/cli.py
+++ b/zeroinstall/injector/cli.py
@@ -280,6 +280,43 @@ def _get_selections(policy):
 	doc.writexml(sys.stdout)
 	sys.stdout.write('\n')

+def _add_to_menu(options, sels):
+	if len(sels) < 1:
+		raise UsageError()
+	
+	from zeroinstall.injector.namespaces import XMLNS_IFACE
+	from zeroinstall.gtkui import xdgutils
+	
+	for uri in sels:
+		iface_uri = model.canonical_iface_uri(uri)
+		policy = autopolicy.AutoPolicy(iface_uri)
+		if options.offline:
+			policy.network_use = model.network_offline
+		iface = iface_cache.get_interface(iface_uri)
+		
+		refreshed = policy.solve_with_downloads(options.refresh)
+		if refreshed:
+			policy.handler.wait_for_blocker(refreshed)
+		
+		impl = policy.get_implementation(iface)
+		if impl.main is None:
+			# Only add menu items for implementations with a main
+			logging.info("Skipping %s, it has no main" % iface_uri)
+			continue
+		
+		iconfetch = policy.download_icon(iface)
+		if iconfetch:
+			policy.handler.wait_for_blocker(iconfetch)
+		
+		icon_path = iface_cache.get_icon_path(iface)
+		feed_category = None
+		for meta in iface.get_metadata(XMLNS_IFACE, 'category'):
+			feed_category = meta.content
+			break
+		feed_category = xdgutils.get_known_category(feed_category)
+		
+		xdgutils.add_to_menu(iface, icon_path, feed_category)
+
 class UsageError(Exception): pass

 def main(command_args):
@@ -301,6 +338,7 @@ def main(command_args):
 				    "       %prog --list [search-term]\n"
 				    "       %prog --import [signed-interface-files]\n"
 				    "       %prog --feed [interface]")
+	parser.add_option("", "--addmenu", help="add menu items for given interfaces", action='store_true')
 	parser.add_option("", "--before", help="choose a version before this", metavar='VERSION')
 	parser.add_option("-c", "--console", help="never use GUI", action='store_false', dest='gui')
 	parser.add_option("", "--cpu", help="target CPU type", metavar='CPU')
@@ -355,6 +393,8 @@ def main(command_args):
 			_import_feed(args)
 		elif options.feed:
 			_manage_feeds(options, args)
+		elif options.addmenu:
+			_add_to_menu(options, args)
 		else:
 			_normal_mode(options, args)
 	except UsageError:
-- 
1.5.6.4

>From 2f15ab9047c5edf93b49fe1f120907330f934b15 Mon Sep 17 00:00:00 2001
From: Frank Richter frank.richter <at> gmail.com <frank.richter <at> gmail.com>
Date: Wed, 17 Sep 2008 20:30:21 +0200
Subject: [PATCH] Use gpg.load_keys() to get identities for secret keys

---
 signing.py |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/signing.py b/signing.py
index 74cd62e..a15f706 100644
--- a/signing.py
+++ b/signing.py
@@ -62,19 +62,9 @@ def get_secret_keys():
 	# When listing secret keys, the identity show may not be the primary identity as selected by
 	# the user or shown when verifying a signature. However, the primary identity can be obtained
 	# by listing the accompanying public key.
+	loaded_keys = gpg.load_keys([k[0] for k in keys])
 	for key in keys:
-		child = subprocess.Popen(('gpg', '--list-keys', '--with-colons', 
-					'--fingerprint', key[0]),
-					 stdout = subprocess.PIPE)
-		stdout, _ = child.communicate()
-		status = child.wait()
-		if status:
-			raise Exception("GPG failed with exit code %d" % status)
-		for line in stdout.split('\n'):
-			line = line.split(':')
-			if line[0] == 'pub':
-				key[1] = line[9]
-				break
+		key[1] = loaded_keys[key[0]].name
 	return keys

 def check_signature(path):
--

-- 
1.5.6.4

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Zero-install-devel mailing list
Zero-install-devel <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/zero-install-devel

Gmane