From 571b4cb56ff87cb63ef92a6cbf60e2f6ec349498 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 27 Aug 2012 07:47:15 +0100 Subject: [PATCH] Updated 0desktop for GTK 3 --- zeroinstall/gtkui/addbox.py | 24 ++- zeroinstall/gtkui/desktop.py | 8 +- zeroinstall/gtkui/desktop.ui | 483 +++++++++++++++++++++++-------------------- 3 files changed, 286 insertions(+), 229 deletions(-) diff --git a/zeroinstall/gtkui/addbox.py b/zeroinstall/gtkui/addbox.py index 1e4fa7c..d058b81 100644 --- a/zeroinstall/gtkui/addbox.py +++ b/zeroinstall/gtkui/addbox.py @@ -68,21 +68,31 @@ class AddBox: category.set_active(11) def uri_dropped(eb, drag_context, x, y, selection_data, info, timestamp): - if info == _UTF_16: - import codecs - data = codecs.getdecoder('utf16')(selection_data.data)[0] - data = data.split('\n', 1)[0].strip() + uris = selection_data.get_uris() + if uris: + assert len(uris) == 1, uris + data, = uris else: - data = selection_data.data.split('\n', 1)[0].strip() + if info == _UTF_16: + import codecs + data = codecs.getdecoder('utf16')(selection_data.get_data())[0] + data = data.split('\n', 1)[0].strip() + else: + data = selection_data.get_text().split('\n', 1)[0].strip() if self._sanity_check(data): uri.set_text(data) drag_context.finish(True, False, timestamp) self.window.response(_RESPONSE_NEXT) return True + if sys.version_info[0] < 3: + def TargetEntry(*args): return args + else: + TargetEntry = gtk.TargetEntry.new self.window.drag_dest_set(gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_HIGHLIGHT, - [('text/uri-list', 0, _URI_LIST), - ('text/x-moz-url', 0, _UTF_16)], + [TargetEntry('text/uri-list', 0, _URI_LIST), + TargetEntry('text/x-moz-url', 0, _UTF_16)], gtk.gdk.ACTION_COPY) + self.window.drag_dest_add_uri_targets() # Needed for GTK 3 self.window.connect('drag-data-received', uri_dropped) nb = builder.get_object('notebook1') diff --git a/zeroinstall/gtkui/desktop.py b/zeroinstall/gtkui/desktop.py index 2de8c49..2e75a35 100644 --- a/zeroinstall/gtkui/desktop.py +++ b/zeroinstall/gtkui/desktop.py @@ -49,7 +49,13 @@ def main(command_args): parser.print_help() sys.exit(1) - import pygtk; pygtk.require('2.0') + if sys.version_info[0] < 3: + import pygtk + pygtk.require('2.0') + else: + from zeroinstall.gtkui import pygtkcompat + pygtkcompat.enable() + pygtkcompat.enable_gtk(version = '3.0') import gtk if options.manage: diff --git a/zeroinstall/gtkui/desktop.ui b/zeroinstall/gtkui/desktop.ui index e91dbfa..8173d4e 100644 --- a/zeroinstall/gtkui/desktop.ui +++ b/zeroinstall/gtkui/desktop.ui @@ -1,42 +1,263 @@ - + + + False + Zero Install applications + 500 + 500 + dialog + + + True + False + + + True + False + end + + + gtk-close + False + True + True + True + False + True + + + False + False + 0 + + + + + False + True + True + True + False + Show all Zero Install software currently stored on this computer (i.e. those programs which can be run without a network connection). This can be useful if you're running out of disk space and need to delete something. + + + True + False + 0 + 0 + + + True + False + 2 + + + True + False + gtk-properties + + + False + False + 0 + + + + + True + False + Show Cache + True + + + False + False + 1 + + + + + + + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + 0 + none + + + True + True + never + in + + + True + True + False + True + + + + + + + True + True + 1 + + + + + + closebutton1 + show_cache + + + + + + + + + False Add Zero Install Application center dialog - False True + False + + + True + False + end + + + gtk-cancel + False + True + True + True + False + True + + + False + False + 0 + + + + + gtk-go-back + False + True + False + True + True + False + True + + + False + False + 1 + + + + + gtk-go-forward + False + True + True + True + True + False + True + + + False + False + 2 + + + + + gtk-ok + False + True + True + False + True + + + False + False + 3 + + + + + False + True + end + 0 + + True + False True + False 4 False False True + False 8 0 none True + False 4 12 True + False 8 True + False 0 <i>Enter the URI of the application you want to install, or drag its link from a web-browser into this window.</i> True @@ -50,9 +271,11 @@ True + False True + False URI: @@ -66,14 +289,21 @@ True True True + False + False + True + True + True + True 1 False + True 1 @@ -84,6 +314,7 @@ True + False <b>Application to install</b> True @@ -91,50 +322,53 @@ - - True - label4 - - - False - + True + False 10 True + False 0 none True + False 4 12 True + False True + False 4 4 gtk-missing-image False + True 0 True + False 0 label10 + True + True 1 @@ -145,6 +379,7 @@ True + False <b>About this program</b> True @@ -152,26 +387,31 @@ False + True 0 True + False 0 none True + False 4 12 True + False 4 True + False 0 <i>Choose a category for the program to determine where it appears in the Applications menu.</i> True @@ -185,9 +425,11 @@ True + False True + False Category: @@ -199,6 +441,7 @@ True + False liststore1 @@ -208,11 +451,15 @@ + True + True 1 + False + True 1 @@ -223,6 +470,7 @@ True + False <b>Applications menu</b> True @@ -230,6 +478,7 @@ False + True 1 @@ -239,107 +488,23 @@ - - True - label5 - - - 1 - False - + - - True - label6 - - - 2 - False - + + True + True 1 - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-go-back - True - False - True - True - False - True - - - False - False - 1 - - - - - gtk-go-forward - True - True - True - True - False - True - - - False - False - 2 - - - - - gtk-ok - True - True - False - True - - - False - False - 3 - - - - - False - end - 0 - - @@ -349,128 +514,4 @@ dialog_ok - - - - - - - - Zero Install applications - 500 - 500 - dialog - False - - - True - - - True - 0 - none - - - True - True - never - in - - - True - True - False - True - - - - - - - 1 - - - - - True - end - - - gtk-close - True - True - True - False - True - - - False - False - 0 - - - - - True - True - True - False - Show all Zero Install software currently stored on this computer (i.e. those programs which can be run without a network connection). This can be useful if you're running out of disk space and need to delete something. - - - True - 0 - 0 - - - True - 2 - - - True - gtk-properties - - - False - False - 0 - - - - - True - Show Cache - True - - - False - False - 1 - - - - - - - - - False - False - 1 - - - - - False - end - 0 - - - - - - closebutton1 - show_cache - - -- 2.11.4.GIT