From 3f124cc3e77ce77097594be01b1cd867ceb97f85 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 3 Jun 2007 15:38:21 +0000 Subject: [PATCH] The interface URI box is now a combo, listing all interfaces that are already installed. This allows you to edit the policy for them. git-svn-id: https://zero-install.svn.sourceforge.net/svnroot/zero-install/trunk/Zero2Desktop/trunk/Zero2Desktop@1853 9f8c893c-44ee-0310-b757-c8ca8341c71e --- Zero2Desktop.xml | 2 +- zero2desktop | 30 ++++++++++++++++++++++++++---- zero2desktop.glade | 14 +++++--------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Zero2Desktop.xml b/Zero2Desktop.xml index b4a37b8..4932188 100644 --- a/Zero2Desktop.xml +++ b/Zero2Desktop.xml @@ -12,7 +12,7 @@ This program creates a freedesktop.org ".desktop" file, which causes t to appear in the GNOME or KDE Applications menus. - + diff --git a/zero2desktop b/zero2desktop index a9fc31b..927b33c 100755 --- a/zero2desktop +++ b/zero2desktop @@ -3,11 +3,14 @@ import os, sys, popen2, tempfile, shutil, optparse import pygtk; pygtk.require('2.0') import gtk, gobject import gtk.glade +from logging import warn from zeroinstall.injector.namespaces import XMLNS_IFACE from zeroinstall.injector.policy import Policy from zeroinstall.injector.iface_cache import iface_cache +import basedir + version = '0.2' parser = optparse.OptionParser(usage="usage: %prog [options] [interface]") parser.add_option("-V", "--version", help="display version information", action='store_true') @@ -50,6 +53,22 @@ UTF_16 = 1 RESPONSE_PREV = 0 RESPONSE_NEXT = 1 +already_installed = {} +for d in basedir.load_data_paths('applications'): + for desktop_file in os.listdir(d): + if desktop_file.startswith('zeroinstall-') and desktop_file.endswith('.desktop'): + full = os.path.join(d, desktop_file) + try: + for line in file(full): + if line.startswith('Exec='): + uri = line.split(' -- ', 1)[1].split(' ', 1)[0].strip() + already_installed[uri] = desktop_file + break + else: + warn("Failed to find Exec line in %s", full) + except Exception, ex: + warn("Failed to load .desktop file %s: %s", full, ex) + class MainWindow: def __init__(self): tree = gtk.glade.XML(gladefile, 'main') @@ -58,7 +77,7 @@ class MainWindow: self.set_keep_above(True) def set_uri_ok(uri): - text = uri.get_text() + text = uri.get_active_text() self.window.set_response_sensitive(RESPONSE_NEXT, bool(text)) drop_uri = tree.get_widget('drop_uri') @@ -77,6 +96,9 @@ class MainWindow: category.set_active(11) + for item in sorted(already_installed): + uri.append_text(item) + def uri_dropped(eb, drag_context, x, y, selection_data, info, timestamp): if info == UTF_16: import codecs @@ -97,7 +119,7 @@ class MainWindow: nb = tree.get_widget('notebook1') def update_details_page(): - iface = iface_cache.get_interface(uri.get_text()) + iface = iface_cache.get_interface(uri.get_active_text()) about.set_text('%s - %s' % (iface.get_name(), iface.summary)) icon_path = iface_cache.get_icon_path(iface) if icon_path: @@ -128,7 +150,7 @@ class MainWindow: self.window.set_response_sensitive(RESPONSE_PREV, True) def finish(): - iface = iface_cache.get_interface(uri.get_text()) + iface = iface_cache.get_interface(uri.get_active_text()) tmpdir = tempfile.mkdtemp(prefix = 'zero2desktop-') try: desktop_name = os.path.join(tmpdir, 'zeroinstall-%s.desktop' % iface.get_name().lower()) @@ -153,7 +175,7 @@ class MainWindow: def response(box, resp): if resp == RESPONSE_NEXT: - iface = uri.get_text() + iface = uri.get_active_text() self.window.set_sensitive(False) self.set_keep_above(False) child = popen2.Popen4(['0launch', diff --git a/zero2desktop.glade b/zero2desktop.glade index b6b8998..f797420 100644 --- a/zero2desktop.glade +++ b/zero2desktop.glade @@ -138,7 +138,7 @@ True <i>Enter the URI of the application you want to install, or drag its link from a web-browser -into this window.</i> +into this window OR select an existing application to edit or remove it.</i> False True GTK_JUSTIFY_LEFT @@ -192,16 +192,12 @@ into this window.</i> - + True - True - True - True - 0 - + + False True - * - True + True 0 -- 2.11.4.GIT