diff options
author | Daniel Drake <dsd@laptop.org> | 2012-10-13 21:48:15 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2012-10-13 21:52:45 (GMT) |
commit | 2644bfdeed730a81261a61e201f18da1200aea35 (patch) | |
tree | d9d7f95c414a4c9f17ed60b0c8e147c747be6672 | |
parent | ca5f5e3c68b9a64e4a34e95697e59ed56b45817a (diff) |
GTK3 port fixups
-rwxr-xr-x | src/model.py | 12 | ||||
-rwxr-xr-x | src/view.py | 55 |
2 files changed, 36 insertions, 31 deletions
diff --git a/src/model.py b/src/model.py index 0c29112..35896e2 100755 --- a/src/model.py +++ b/src/model.py @@ -23,7 +23,9 @@ _DEBUG_CHECK_VERSIONS = False # default timeout for HTTP connections, in seconds HTTP_TIMEOUT=30 +from gi.repository import Rsvg from gi.repository import Gtk +from gi.repository import GdkPixbuf from gi.repository import GObject import locale @@ -44,7 +46,7 @@ import bitfrost.update.actutils as actutils import bitfrost.update.microformat as microformat import bitfrost.util.urlrange as urlrange -from sugar.bundle.bundleversion import NormalizedVersion +from sugar3.bundle.bundleversion import NormalizedVersion # weak dependency on inhibit_suspend from olpc-update package try: @@ -74,7 +76,7 @@ def _humanize_size(bytes): def _svg2pixbuf(icon_data): """Convert the given `icon_data` SVG string to a `GdkPixbuf.Pixbuf` with maximum size 55x55.""" - import re, rsvg + import re # substitute black/white for icon color entities. for entity, value in [('stroke_color','#808080'), ('fill_color','#eee')]: @@ -195,7 +197,7 @@ class UpdateList(Gtk.ListStore): } def __init__(self, skip_icons=False): - GObject.GObject.__init__(self, + Gtk.ListStore.__init__(self, # column types str, object, GdkPixbuf.Pixbuf, str, str, long, @@ -214,7 +216,7 @@ class UpdateList(Gtk.ListStore): global _column_name_map # defaults for each column row = [None, None, None, - None, 0, 0, + None, "0", 0, True, True, None, None, False, 0] # set entries in the row based on kwargs for k,v in kwargs.items(): @@ -315,7 +317,7 @@ class UpdateList(Gtk.ListStore): GROUP_NUM=group_num, UPDATE_EXISTS=True, UPDATE_URL=url, - UPDATE_VERSION=version, + UPDATE_VERSION=str(version), DESCRIPTION_BIG=tmp_desc) steps_total[0] += 1 # new activity? else: diff --git a/src/view.py b/src/view.py index b2dceb8..acb3862 100755 --- a/src/view.py +++ b/src/view.py @@ -7,10 +7,11 @@ Checks for updates to activities and installs them.""" from __future__ import with_statement from __future__ import division -import gi -gi.require_version('Gtk', '3.0') -import gtk, gobject -Gdk.threads_init() +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import GObject +GLib.threads_init() import gettext import os @@ -21,7 +22,7 @@ import gettext _ = lambda msg: gettext.dgettext('sugar-update-control', msg) import bitfrost.update.actutils as actutils -from sugar.graphics import style +from sugar3.graphics import style from jarabe.controlpanel.sectionview import SectionView from jarabe.controlpanel.inlinealert import InlineAlert @@ -31,8 +32,8 @@ from model import _humanize_size, _svg2pixbuf, inhibit_suspend # COMPATIBILITY HACK: work around trac #8532 by forcibly removing the # SIGCHLD handler (and the necessity for one) -import sugar.activity.activityfactory -if hasattr(sugar.activity.activityfactory, '_sigchild_handler'): +import sugar3.activity.activityfactory +if hasattr(sugar3.activity.activityfactory, '_sigchild_handler'): from ctypes import CDLL, Structure, c_voidp, c_int, c_ulong, pointer import signal libc = CDLL("libc.so.6") @@ -121,7 +122,7 @@ class ActivityListView(Gtk.ScrolledWindow): # create the TreeViewColumn to display the data def view_func_maker(propname): - def view_func(cell_layout, renderer, m, it): + def view_func(cell_layout, renderer, m, it, user_data=None): renderer.set_property(propname, not m.get_value(it, model.IS_HEADER)) return view_func @@ -131,12 +132,12 @@ class ActivityListView(Gtk.ScrolledWindow): self.column_install.add_attribute(crbool, 'active', model.UPDATE_SELECTED) self.column_install.set_cell_data_func(crbool, hide_func) self.column = Gtk.TreeViewColumn('Name') - self.column.pack_start(cricon, False, True, 0) - self.column.pack_start(crtext, True, True, 0) + self.column.pack_start(cricon, False) + self.column.pack_start(crtext, True) self.column.add_attribute(cricon, 'pixbuf', model.ACTIVITY_ICON) self.column.set_resizable(True) self.column.set_cell_data_func(cricon, hide_func) - def markup_func(cell_layout, renderer, m, it): + def markup_func(cell_layout, renderer, m, it, user_data): s = '<b>%s</b>' % _e(m.get_value(it, model.DESCRIPTION_BIG)) if m.get_value(it, model.IS_HEADER): s = '<big>%s</big>' % s @@ -216,17 +217,19 @@ class GroupListView(Gtk.VBox): self.groupview.set_rules_hint(True) self.groupview.set_enable_search(False) self.groupview.set_reorderable(False) # we'll write own DnD funcs below - TARGETS = Gtk.target_list_add_text_targets(info=0) - TARGETS = Gtk.target_list_add_uri_targets(list=TARGETS, info=1) - self.groupview.enable_model_drag_source( Gdk.ModifierType.BUTTON1_MASK, - TARGETS, - Gdk.DragAction.DEFAULT - |Gdk.DragAction.COPY - |Gdk.DragAction.MOVE) - self.groupview.enable_model_drag_dest(TARGETS, - Gdk.DragAction.DEFAULT - |Gdk.DragAction.COPY - |Gdk.DragAction.MOVE) + # FIXME: port to GTK3 + #TARGETS = Gtk.TargetList() + #TARGETS.add_text_targets(0) + #TARGETS.add_uri_targets(1) + #self.groupview.enable_model_drag_source( Gdk.ModifierType.BUTTON1_MASK, + # TARGETS, + # Gdk.DragAction.DEFAULT + # |Gdk.DragAction.COPY + # |Gdk.DragAction.MOVE) + #self.groupview.enable_model_drag_dest(TARGETS, + # Gdk.DragAction.DEFAULT + # |Gdk.DragAction.COPY + # |Gdk.DragAction.MOVE) def drag_data_get_data(groupview, context, drag_selection, target_id, etime): selection = groupview.get_selection() m, it = selection.get_selected() @@ -437,7 +440,7 @@ class ProgressPane(Gtk.VBox): (self.refresh_button, activity_updater.refresh_cb), (self.try_again_button, activity_updater.refresh_cb)]: widget.connect('clicked', cb, activity_updater) - hbox.pack_start(widget, expand=True, fill=False) + hbox.pack_start(widget, True, False, 0) self.pack_start(self.icon, True, True, 0) self.pack_start(self.bar, True, True, 0) @@ -515,7 +518,7 @@ class ActivityUpdater(SectionView): bottom_label.set_markup(_('Software updates correct errors, eliminate security vulnerabilities, and provide new features.')) vbox2 = Gtk.VBox() vbox2.pack_start(self.top_label, False, True, 0) - vbox2.pack_start(Gtk.HSeparator(, True, True, 0), expand=False) + vbox2.pack_start(Gtk.HSeparator(), False, False, 0) vbox2.pack_start(bottom_label, True, True, 0) self.pack_start(vbox2, False, True, 0) @@ -526,7 +529,7 @@ class ActivityUpdater(SectionView): # progress pane ########### self.progress_pane = ProgressPane(self) - self.pack_start(self.progress_pane, expand=True, fill=False) + self.pack_start(self.progress_pane, True, False, 0) # special little extension to progress pane. self.expander = Gtk.Expander(label=_('Modify activity groups')) @@ -545,7 +548,7 @@ class ActivityUpdater(SectionView): def download_cb(self, widget, event, data=None): """Invoked when the 'ok' button is clicked.""" - from sugar.bundle.activitybundle import ActivityBundle + from sugar3.bundle.activitybundle import ActivityBundle self.top_label.set_markup('<big>%s</big>' % _('Downloading updates...')) self.progress_pane.switch_to_download_progress() |