[Sugar-devel] [PATCH 1/2] Port from PyGTK to PyGI, renaming
Simon Schampijer
simon at schampijer.de
Wed Nov 23 16:53:59 EST 2011
El 22/11/11 22:42, Manuel Quiñones escribió:
> Was done running the pygi-convert.sh script.
>
> Signed-off-by: Manuel Quiñones<manuq at laptop.org>
Looks good, please push to the master branch.
Acked-by: Simon Schampijer <simon at laptop.org>
> ---
> browser.py | 54 +++++++++++++++++++++++++-------------------------
> downloadmanager.py | 18 ++++++++--------
> edittoolbar.py | 12 +++++-----
> filepicker.py | 4 +-
> linkbutton.py | 20 +++++++++---------
> model.py | 10 ++++----
> palettes.py | 34 ++++++++++++++++----------------
> progresslistener.py | 12 +++++-----
> sessionhistory.py | 12 +++++-----
> viewtoolbar.py | 8 +++---
> webactivity.py | 30 ++++++++++++++--------------
> webtoolbar.py | 50 +++++++++++++++++++++++-----------------------
> widgets.py | 32 +++++++++++++++---------------
> 13 files changed, 148 insertions(+), 148 deletions(-)
>
> diff --git a/browser.py b/browser.py
> index e1d8990..f2c4cc5 100644
> --- a/browser.py
> +++ b/browser.py
> @@ -20,9 +20,9 @@ import os
> import time
> from gettext import gettext as _
>
> -import gobject
> -import gtk
> -import pango
> +from gi.repository import GObject
> +from gi.repository import Gtk
> +from gi.repository import Pango
> import hulahop
> import xpcom
> from xpcom.nsError import *
> @@ -102,8 +102,8 @@ class TabbedView(BrowserNotebook):
> __gtype_name__ = 'TabbedView'
>
> __gsignals__ = {
> - 'focus-url-entry': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'focus-url-entry': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> }
>
> @@ -285,7 +285,7 @@ class TabbedView(BrowserNotebook):
> def _get_current_browser(self):
> return self.get_nth_page(self.get_current_page())
>
> - current_browser = gobject.property(type=object,
> + current_browser = GObject.property(type=object,
> getter=_get_current_browser)
>
> def get_session(self):
> @@ -310,7 +310,7 @@ class TabbedView(BrowserNotebook):
> sessionstore.set_session(browser, tab_session)
>
>
> -gtk.rc_parse_string('''
> +Gtk.rc_parse_string('''
> style "browse-tab-close" {
> xthickness = 0
> ythickness = 0
> @@ -318,37 +318,37 @@ gtk.rc_parse_string('''
> widget "*browse-tab-close" style "browse-tab-close"''')
>
>
> -class TabLabel(gtk.HBox):
> +class TabLabel(Gtk.HBox):
> __gtype_name__ = 'TabLabel'
>
> __gsignals__ = {
> - 'tab-close': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'tab-close': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([object])),
> }
>
> def __init__(self, browser):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
>
> self._browser = browser
> self._browser.connect('is-setup', self.__browser_is_setup_cb)
>
> - self._label = gtk.Label(_('Untitled'))
> - self._label.set_ellipsize(pango.ELLIPSIZE_END)
> + self._label = Gtk.Label(label=_('Untitled'))
> + self._label.set_ellipsize(Pango.EllipsizeMode.END)
> self._label.set_alignment(0, 0.5)
> - self.pack_start(self._label)
> + self.pack_start(self._label, True, True, 0)
> self._label.show()
>
> close_tab_icon = Icon(icon_name='browse-close-tab')
> - button = gtk.Button()
> - button.props.relief = gtk.RELIEF_NONE
> + button = Gtk.Button()
> + button.props.relief = Gtk.ReliefStyle.NONE
> button.props.focus_on_click = False
> - icon_box = gtk.HBox()
> + icon_box = Gtk.HBox()
> icon_box.pack_start(close_tab_icon, True, False, 0)
> button.add(icon_box)
> button.connect('clicked', self.__button_clicked_cb)
> button.set_name('browse-tab-close')
> - self.pack_start(button, expand=False)
> + self.pack_start(button, False, True, 0)
> close_tab_icon.show()
> icon_box.show()
> button.show()
> @@ -389,11 +389,11 @@ class Browser(WebView):
> __gtype_name__ = 'Browser'
>
> __gsignals__ = {
> - 'is-setup': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'is-setup': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> - 'new-tab': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'new-tab': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([str])),
> }
>
> @@ -489,15 +489,15 @@ class Browser(WebView):
> self.emit('new-tab', url)
>
>
> -class PopupDialog(gtk.Window):
> +class PopupDialog(Gtk.Window):
> def __init__(self):
> - gtk.Window.__init__(self)
> + GObject.GObject.__init__(self)
>
> - self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
> + self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
>
> border = style.GRID_CELL_SIZE
> - self.set_default_size(gtk.gdk.screen_width() - border * 2,
> - gtk.gdk.screen_height() - border * 2)
> + self.set_default_size(Gdk.Screen.width() - border * 2,
> + Gdk.Screen.height() - border * 2)
>
> self.view = WebView()
> self.view.connect('notify::visibility', self.__notify_visibility_cb)
> diff --git a/downloadmanager.py b/downloadmanager.py
> index 98d4f1a..0a8d2b2 100644
> --- a/downloadmanager.py
> +++ b/downloadmanager.py
> @@ -21,7 +21,7 @@ from gettext import gettext as _
> import time
> import tempfile
>
> -import gtk
> +from gi.repository import Gtk
> import hulahop
> import xpcom
> from xpcom.nsError import *
> @@ -188,11 +188,11 @@ class Download:
> self._stop_alert.props.title = _('Download completed')
> self._stop_alert.props.msg = self._get_file_name()
> open_icon = Icon(icon_name='zoom-activity')
> - self._stop_alert.add_button(gtk.RESPONSE_APPLY,
> + self._stop_alert.add_button(Gtk.ResponseType.APPLY,
> _('Show in Journal'), open_icon)
> open_icon.show()
> ok_icon = Icon(icon_name='dialog-ok')
> - self._stop_alert.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon)
> + self._stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'), ok_icon)
> ok_icon.show()
> self._activity.add_alert(self._stop_alert)
> self._stop_alert.connect('response', self.__stop_response_cb)
> @@ -219,7 +219,7 @@ class Download:
> timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
>
> def _check_image_mime_type(self):
> - for pixbuf_format in gtk.gdk.pixbuf_get_formats():
> + for pixbuf_format in GdkPixbuf.Pixbuf.get_formats():
> if self._mime_type in pixbuf_format['mime_types']:
> return True
> return False
> @@ -227,7 +227,7 @@ class Download:
> def _get_preview_image(self):
> preview_width, preview_height = style.zoom(300), style.zoom(225)
>
> - pixbuf = gtk.gdk.pixbuf_new_from_file(self._target_file.path)
> + pixbuf = GdkPixbuf.Pixbuf.new_from_file(self._target_file.path)
> width, height = pixbuf.get_width(), pixbuf.get_height()
>
> scale = 1
> @@ -236,7 +236,7 @@ class Download:
> scale_y = preview_height / float(height)
> scale = min(scale_x, scale_y)
>
> - pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, \
> + pixbuf2 = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, \
> pixbuf.get_has_alpha(), \
> pixbuf.get_bits_per_sample(), \
> preview_width, preview_height)
> @@ -249,7 +249,7 @@ class Download:
> preview_width - (margin_x * 2), \
> preview_height - (margin_y * 2), \
> margin_x, margin_y, scale, scale, \
> - gtk.gdk.INTERP_BILINEAR)
> + GdkPixbuf.InterpType.BILINEAR)
>
> preview_data = []
>
> @@ -262,7 +262,7 @@ class Download:
>
> def __start_response_cb(self, alert, response_id):
> global _active_downloads
> - if response_id is gtk.RESPONSE_CANCEL:
> + if response_id is Gtk.ResponseType.CANCEL:
> logging.debug('Download Canceled')
> logging.debug('target_path=%r', self._target_file.path)
> self.cancelable.cancel(NS_ERROR_FAILURE)
> @@ -278,7 +278,7 @@ class Download:
>
> def __stop_response_cb(self, alert, response_id):
> global _active_downloads
> - if response_id is gtk.RESPONSE_APPLY:
> + if response_id is Gtk.ResponseType.APPLY:
> logging.debug('Start application with downloaded object')
> activity.show_object_in_journal(self._object_id)
> self._activity.remove_alert(alert)
> diff --git a/edittoolbar.py b/edittoolbar.py
> index f0cdb1a..d5f0286 100644
> --- a/edittoolbar.py
> +++ b/edittoolbar.py
> @@ -15,7 +15,7 @@
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>
> -import gtk
> +from gi.repository import Gtk
> from gettext import gettext as _
>
> from xpcom.components import interfaces
> @@ -64,13 +64,13 @@ class EditToolbar(activity.EditToolbar):
> logging.debug('observe: %r %r %r' % (subject, topic, data))
> """
>
> - separator = gtk.SeparatorToolItem()
> + separator = Gtk.SeparatorToolItem()
> separator.set_draw(False)
> separator.set_expand(True)
> self.insert(separator, -1)
> separator.show()
>
> - search_item = gtk.ToolItem()
> + search_item = Gtk.ToolItem()
> self.search_entry = iconentry.IconEntry()
> self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
> 'system-search')
> @@ -78,7 +78,7 @@ class EditToolbar(activity.EditToolbar):
> self.search_entry.connect('activate', self.__search_entry_activate_cb)
> self.search_entry.connect('changed', self.__search_entry_changed_cb)
>
> - width = int(gtk.gdk.screen_width() / 3)
> + width = int(Gdk.Screen.width() / 3)
> self.search_entry.set_size_request(width, -1)
>
> search_item.add(self.search_entry)
> @@ -135,12 +135,12 @@ class EditToolbar(activity.EditToolbar):
> if found == interfaces.nsITypeAheadFind.FIND_NOTFOUND:
> self._prev.props.sensitive = False
> self._next.props.sensitive = False
> - entry.modify_text(gtk.STATE_NORMAL,
> + entry.modify_text(Gtk.StateType.NORMAL,
> style.COLOR_BUTTON_GREY.get_gdk_color())
> else:
> self._prev.props.sensitive = True
> self._next.props.sensitive = True
> - entry.modify_text(gtk.STATE_NORMAL,
> + entry.modify_text(Gtk.StateType.NORMAL,
> style.COLOR_BLACK.get_gdk_color())
>
> def __find_previous_cb(self, button):
> diff --git a/filepicker.py b/filepicker.py
> index 27bf383..a06e879 100644
> --- a/filepicker.py
> +++ b/filepicker.py
> @@ -19,7 +19,7 @@ import os
> import tempfile
> import shutil
>
> -import gtk
> +from gi.repository import Gtk
> import hulahop
>
> import xpcom
> @@ -74,7 +74,7 @@ class FilePicker:
> jobject = None
> try:
> result = chooser.run()
> - if result == gtk.RESPONSE_ACCEPT:
> + if result == Gtk.ResponseType.ACCEPT:
> jobject = chooser.get_selected_object()
> logging.debug('FilePicker.show: %r', jobject)
>
> diff --git a/linkbutton.py b/linkbutton.py
> index 4a0a18f..49f6451 100644
> --- a/linkbutton.py
> +++ b/linkbutton.py
> @@ -15,9 +15,9 @@
> # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> # Boston, MA 02111-1307, USA.
>
> -import gtk
> +from gi.repository import Gtk
> import os
> -import gobject
> +from gi.repository import GObject
> from gettext import gettext as _
> import rsvg
> import re
> @@ -28,11 +28,11 @@ from sugar.graphics.tray import TrayButton
> from sugar.graphics import style
>
>
> -class LinkButton(TrayButton, gobject.GObject):
> +class LinkButton(TrayButton, GObject.GObject):
> __gtype_name__ = 'LinkButton'
> __gsignals__ = {
> - 'remove_link': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE, ([str])),
> + 'remove_link': (GObject.SignalFlags.RUN_FIRST,
> + None, ([str])),
> }
>
> def __init__(self, url, buf, color, title, owner, index, hash):
> @@ -44,8 +44,8 @@ class LinkButton(TrayButton, gobject.GObject):
> self.setup_rollover_options(info)
>
> def set_image(self, buf, fill='#0000ff', stroke='#4d4c4f'):
> - img = gtk.Image()
> - loader = gtk.gdk.PixbufLoader()
> + img = Gtk.Image()
> + loader = GdkPixbuf.PixbufLoader()
> loader.write(buf)
> loader.close()
> pixbuf = loader.get_pixbuf()
> @@ -55,7 +55,7 @@ class LinkButton(TrayButton, gobject.GObject):
> pixbuf_bg = self._read_link_background(xo_buddy, fill, stroke)
> pixbuf_bg = pixbuf_bg.scale_simple(style.zoom(120),
> style.zoom(110),
> - gtk.gdk.INTERP_BILINEAR)
> + GdkPixbuf.InterpType.BILINEAR)
> dest_x = style.zoom(10)
> dest_y = style.zoom(20)
> w = pixbuf.get_width()
> @@ -64,7 +64,7 @@ class LinkButton(TrayButton, gobject.GObject):
> scale_y = 1
>
> pixbuf.composite(pixbuf_bg, dest_x, dest_y, w, h, dest_x, dest_y,
> - scale_x, scale_y, gtk.gdk.INTERP_BILINEAR, 255)
> + scale_x, scale_y, GdkPixbuf.InterpType.BILINEAR, 255)
> img.set_from_pixbuf(pixbuf_bg)
> self.set_icon_widget(img)
> img.show()
> @@ -92,7 +92,7 @@ class LinkButton(TrayButton, gobject.GObject):
> palette = Palette(info, text_maxlen=50)
> self.set_palette(palette)
>
> - menu_item = gtk.MenuItem(_('Remove'))
> + menu_item = Gtk.MenuItem(_('Remove'))
> menu_item.connect('activate', self.item_remove_cb)
> palette.menu.append(menu_item)
> menu_item.show()
> diff --git a/model.py b/model.py
> index f6d7eae..d3d26e4 100644
> --- a/model.py
> +++ b/model.py
> @@ -18,21 +18,21 @@
>
> import cjson
> import sha
> -import gobject
> +from gi.repository import GObject
> import base64
>
>
> -class Model(gobject.GObject):
> +class Model(GObject.GObject):
> ''' The model of web-activity which uses json to serialize its data
> to a file and deserealize from it.
> '''
> __gsignals__ = {
> - 'add_link': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE, ([int])),
> + 'add_link': (GObject.SignalFlags.RUN_FIRST,
> + None, ([int])),
> }
>
> def __init__(self):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
> self.data = {}
> self.data['shared_links'] = []
> self.data['deleted'] = []
> diff --git a/palettes.py b/palettes.py
> index 3c8eebb..5c8f242 100644
> --- a/palettes.py
> +++ b/palettes.py
> @@ -20,8 +20,8 @@ import tempfile
> import urlparse
> from gettext import gettext as _
>
> -import gtk
> -import gobject
> +from gi.repository import Gtk
> +from gi.repository import GObject
> import xpcom
> from xpcom import components
> from xpcom.components import interfaces
> @@ -35,17 +35,17 @@ from sugar.activity import activity
> import downloadmanager
>
>
> -class MouseOutListener(gobject.GObject):
> +class MouseOutListener(GObject.GObject):
> _com_interfaces_ = interfaces.nsIDOMEventListener
>
> __gsignals__ = {
> - 'mouse-out': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'mouse-out': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> }
>
> def __init__(self, target):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
> self.target = target
>
> def handleEvent(self, event):
> @@ -66,7 +66,7 @@ class ContentInvoker(Invoker):
> return self.AT_CURSOR
>
> def get_rect(self):
> - return gtk.gdk.Rectangle()
> + return ()
>
> def get_toplevel(self):
> return None
> @@ -153,7 +153,7 @@ class LinkPalette(Palette):
>
> menu_item = MenuItem(_('Keep link'))
> icon = Icon(icon_name='document-save', xo_color=profile.get_color(),
> - icon_size=gtk.ICON_SIZE_MENU)
> + icon_size=Gtk.IconSize.MENU)
> menu_item.set_image(icon)
> menu_item.connect('activate', self.__download_activate_cb)
> self.menu.append(menu_item)
> @@ -161,7 +161,7 @@ class LinkPalette(Palette):
>
> menu_item = MenuItem(_('Copy link'))
> icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(),
> - icon_size=gtk.ICON_SIZE_MENU)
> + icon_size=Gtk.IconSize.MENU)
> menu_item.set_image(icon)
> menu_item.connect('activate', self.__copy_activate_cb)
> self.menu.append(menu_item)
> @@ -175,9 +175,9 @@ class LinkPalette(Palette):
> self._browser.grab_focus()
>
> def __copy_activate_cb(self, menu_item):
> - clipboard = gtk.Clipboard()
> - targets = gtk.target_list_add_uri_targets()
> - targets = gtk.target_list_add_text_targets(targets)
> + clipboard = Gtk.Clipboard()
> + targets = Gtk.target_list_add_uri_targets()
> + targets = Gtk.target_list_add_text_targets(targets)
> targets.append(('text/x-moz-url', 0, 0))
>
> clipboard.set_with_data(targets,
> @@ -186,9 +186,9 @@ class LinkPalette(Palette):
>
> def __clipboard_get_func_cb(self, clipboard, selection_data, info, data):
> uri_targets = \
> - [target[0] for target in gtk.target_list_add_uri_targets()]
> + [target[0] for target in Gtk.target_list_add_uri_targets()]
> text_targets = \
> - [target[0] for target in gtk.target_list_add_text_targets()]
> + [target[0] for target in Gtk.target_list_add_text_targets()]
>
> if selection_data.target in uri_targets:
> selection_data.set_uris([self._url])
> @@ -217,7 +217,7 @@ class ImagePalette(Palette):
>
> menu_item = MenuItem(_('Keep image'))
> icon = Icon(icon_name='document-save', xo_color=profile.get_color(),
> - icon_size=gtk.ICON_SIZE_MENU)
> + icon_size=Gtk.IconSize.MENU)
> menu_item.set_image(icon)
> menu_item.connect('activate', self.__download_activate_cb)
> self.menu.append(menu_item)
> @@ -225,7 +225,7 @@ class ImagePalette(Palette):
>
> menu_item = MenuItem(_('Copy image'))
> icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(),
> - icon_size=gtk.ICON_SIZE_MENU)
> + icon_size=Gtk.IconSize.MENU)
> menu_item.set_image(icon)
> menu_item.connect('activate', self.__copy_activate_cb)
> self.menu.append(menu_item)
> @@ -289,7 +289,7 @@ class _ImageProgressListener(object):
> def onStateChange(self, webProgress, request, stateFlags, status):
> if (stateFlags& interfaces.nsIWebProgressListener.STATE_IS_REQUEST and
> stateFlags& interfaces.nsIWebProgressListener.STATE_STOP):
> - clipboard = gtk.Clipboard()
> + clipboard = Gtk.Clipboard()
> clipboard.set_with_data([('text/uri-list', 0, 0)],
> _clipboard_get_func_cb,
> _clipboard_clear_func_cb,
> diff --git a/progresslistener.py b/progresslistener.py
> index fb08b13..2a78c42 100644
> --- a/progresslistener.py
> +++ b/progresslistener.py
> @@ -16,16 +16,16 @@
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>
> -import gobject
> +from gi.repository import GObject
> import xpcom
> from xpcom.components import interfaces
>
>
> -class ProgressListener(gobject.GObject):
> +class ProgressListener(GObject.GObject):
> _com_interfaces_ = interfaces.nsIWebProgressListener
>
> def __init__(self):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
>
> self._location = None
> self._loading = False
> @@ -90,14 +90,14 @@ class ProgressListener(gobject.GObject):
> def _get_location(self):
> return self._location
>
> - location = gobject.property(type=object, getter=_get_location)
> + location = GObject.property(type=object, getter=_get_location)
>
> def _get_loading(self):
> return self._loading
>
> - loading = gobject.property(type=bool, default=False, getter=_get_loading)
> + loading = GObject.property(type=bool, default=False, getter=_get_loading)
>
> def _get_progress(self):
> return self._progress
>
> - progress = gobject.property(type=float, getter=_get_progress)
> + progress = GObject.property(type=float, getter=_get_progress)
> diff --git a/sessionhistory.py b/sessionhistory.py
> index be4ab93..615a98d 100644
> --- a/sessionhistory.py
> +++ b/sessionhistory.py
> @@ -16,24 +16,24 @@
>
> import logging
>
> -import gobject
> +from gi.repository import GObject
> import xpcom
> from xpcom.components import interfaces
>
>
> -class HistoryListener(gobject.GObject):
> +class HistoryListener(GObject.GObject):
> _com_interfaces_ = interfaces.nsISHistoryListener
>
> __gsignals__ = {
> - 'session-history-changed': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'session-history-changed': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([int])),
> - 'session-link-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
> + 'session-link-changed': (GObject.SignalFlags.RUN_FIRST, None,
> ([str])),
> }
>
> def __init__(self):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
>
> self._wrapped_self = xpcom.server.WrapObject( \
> self, interfaces.nsISHistoryListener)
> diff --git a/viewtoolbar.py b/viewtoolbar.py
> index 61f4943..7f74035 100644
> --- a/viewtoolbar.py
> +++ b/viewtoolbar.py
> @@ -17,14 +17,14 @@
>
> from gettext import gettext as _
>
> -import gtk
> +from gi.repository import Gtk
>
> from sugar.graphics.toolbutton import ToolButton
>
>
> -class ViewToolbar(gtk.Toolbar):
> +class ViewToolbar(Gtk.Toolbar):
> def __init__(self, activity):
> - gtk.Toolbar.__init__(self)
> + GObject.GObject.__init__(self)
>
> self._activity = activity
> self._activity.tray.connect('unmap', self.__unmap_cb)
> @@ -42,7 +42,7 @@ class ViewToolbar(gtk.Toolbar):
> self.insert(self.zoomin, -1)
> self.zoomin.show()
>
> - self.separator = gtk.SeparatorToolItem()
> + self.separator = Gtk.SeparatorToolItem()
> self.separator.set_draw(True)
> self.insert(self.separator, -1)
> self.separator.show()
> diff --git a/webactivity.py b/webactivity.py
> index 707b602..cb7b351 100644
> --- a/webactivity.py
> +++ b/webactivity.py
> @@ -21,16 +21,16 @@ from gettext import gettext as _
> from gettext import ngettext
> import os
>
> -import gobject
> -gobject.threads_init()
> +from gi.repository import GObject
> +GObject.threads_init()
>
> -import gtk
> +from gi.repository import Gtk
> import base64
> import time
> import shutil
> import sqlite3
> import cjson
> -import gconf
> +from gi.repository import GConf
> import locale
> import cairo
> from hashlib import sha1
> @@ -78,7 +78,7 @@ if _profile_version< PROFILE_VERSION:
> def _seed_xs_cookie():
> ''' Create a HTTP Cookie to authenticate with the Schoolserver
> '''
> - client = gconf.client_get_default()
> + client = GConf.Client.get_default()
> backup_url = client.get_string('/desktop/sugar/backup_url')
> if not backup_url:
> _logger.debug('seed_xs_cookie: Not registered with Schoolserver')
> @@ -221,7 +221,7 @@ class WebActivity(activity.Activity):
> ' to a bug in cairo/mozilla')
>
> self._tray = HTray()
> - self.set_tray(self._tray, gtk.POS_BOTTOM)
> + self.set_tray(self._tray, Gtk.PositionType.BOTTOM)
> self._tray.show()
>
> self._primary_toolbar = PrimaryToolbar(self._tabbed_view, self)
> @@ -476,10 +476,10 @@ class WebActivity(activity.Activity):
> self._tabbed_view.load_homepage()
>
> def _key_press_cb(self, widget, event):
> - key_name = gtk.gdk.keyval_name(event.keyval)
> + key_name = Gdk.keyval_name(event.keyval)
> browser = self._tabbed_view.props.current_browser
>
> - if event.state& gtk.gdk.CONTROL_MASK:
> + if event.get_state()& Gdk.EventMask.CONTROL_MASK:
>
> if key_name == 'd':
> self._add_link()
> @@ -503,7 +503,7 @@ class WebActivity(activity.Activity):
> elif key_name == 'r':
> flags = components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE
> browser.web_navigation.reload(flags)
> - elif gtk.gdk.keyval_name(event.keyval) == "t":
> + elif Gdk.keyval_name(event.keyval) == "t":
> if not self._disable_multiple_tabs:
> self._tabbed_view.add_tab()
> else:
> @@ -579,7 +579,7 @@ class WebActivity(activity.Activity):
> window = self._tabbed_view.props.current_browser.window
> width, height = window.get_size()
>
> - screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=False,
> + screenshot = GdkPixbuf.Pixbuf(GdkPixbuf.Colorspace.RGB, has_alpha=False,
> bits_per_sample=8, width=width,
> height=height)
> screenshot.get_from_drawable(window, window.get_colormap(), 0, 0, 0, 0,
> @@ -587,7 +587,7 @@ class WebActivity(activity.Activity):
>
> screenshot = screenshot.scale_simple(style.zoom(100),
> style.zoom(80),
> - gtk.gdk.INTERP_BILINEAR)
> + GdkPixbuf.InterpType.BILINEAR)
>
> buf = self.get_buffer(screenshot)
> return buf
> @@ -609,9 +609,9 @@ class WebActivity(activity.Activity):
> cancel_icon = Icon(icon_name='dialog-cancel')
> cancel_label = ngettext('Continue download', 'Continue downloads',
> downloadmanager.num_downloads())
> - alert.add_button(gtk.RESPONSE_CANCEL, cancel_label, cancel_icon)
> + alert.add_button(Gtk.ResponseType.CANCEL, cancel_label, cancel_icon)
> stop_icon = Icon(icon_name='dialog-ok')
> - alert.add_button(gtk.RESPONSE_OK, _('Stop'), stop_icon)
> + alert.add_button(Gtk.ResponseType.OK, _('Stop'), stop_icon)
> stop_icon.show()
> self.add_alert(alert)
> alert.connect('response', self.__inprogress_response_cb)
> @@ -621,9 +621,9 @@ class WebActivity(activity.Activity):
>
> def __inprogress_response_cb(self, alert, response_id):
> self.remove_alert(alert)
> - if response_id is gtk.RESPONSE_CANCEL:
> + if response_id is Gtk.ResponseType.CANCEL:
> logging.debug('Keep on')
> - elif response_id == gtk.RESPONSE_OK:
> + elif response_id == Gtk.ResponseType.OK:
> logging.debug('Stop downloads and quit')
> self._force_close = True
> downloadmanager.remove_all_downloads()
> diff --git a/webtoolbar.py b/webtoolbar.py
> index 97bdcd6..7d5b284 100644
> --- a/webtoolbar.py
> +++ b/webtoolbar.py
> @@ -18,9 +18,9 @@
>
> from gettext import gettext as _
>
> -import gobject
> -import gtk
> -import pango
> +from gi.repository import GObject
> +from gi.repository import Gtk
> +from gi.repository import Pango
> from xpcom.components import interfaces
>
> from sugar.graphics.toolbutton import ToolButton
> @@ -42,13 +42,13 @@ class WebEntry(iconentry.IconEntry):
> _COL_TITLE = 1
>
> def __init__(self):
> - gobject.GObject.__init__(self)
> + GObject.GObject.__init__(self)
>
> self._address = None
> self._title = None
> self._search_view = self._search_create_view()
>
> - self._search_window = gtk.Window(gtk.WINDOW_POPUP)
> + self._search_window = Gtk.Window(Gtk.WindowType.POPUP)
> self._search_window.add(self._search_view)
> self._search_view.show()
>
> @@ -78,44 +78,44 @@ class WebEntry(iconentry.IconEntry):
> def _set_address(self, address):
> self._address = address
>
> - address = gobject.property(type=str, setter=_set_address)
> + address = GObject.property(type=str, setter=_set_address)
>
> def _set_title(self, title):
> self._title = title
> if title is not None and not self.props.has_focus:
> self._set_text(title)
>
> - title = gobject.property(type=str, setter=_set_title)
> + title = GObject.property(type=str, setter=_set_title)
>
> def _search_create_view(self):
> - view = gtk.TreeView()
> + view = Gtk.TreeView()
> view.props.headers_visible = False
>
> view.connect('button-press-event', self.__view_button_press_event_cb)
>
> - column = gtk.TreeViewColumn()
> + column = Gtk.TreeViewColumn()
> view.append_column(column)
>
> - cell = gtk.CellRendererText()
> - cell.props.ellipsize = pango.ELLIPSIZE_END
> + cell = Gtk.CellRendererText()
> + cell.props.ellipsize = Pango.EllipsizeMode.END
> cell.props.ellipsize_set = True
> cell.props.font = 'Bold'
> column.pack_start(cell, True)
>
> column.set_attributes(cell, text=self._COL_TITLE)
>
> - cell = gtk.CellRendererText()
> - cell.props.ellipsize = pango.ELLIPSIZE_END
> + cell = Gtk.CellRendererText()
> + cell.props.ellipsize = Pango.EllipsizeMode.END
> cell.props.ellipsize_set = True
> - cell.props.alignment = pango.ALIGN_LEFT
> - column.pack_start(cell)
> + cell.props.alignment = Pango.Alignment.LEFT
> + column.pack_start(cell, True)
>
> column.set_attributes(cell, text=self._COL_ADDRESS)
>
> return view
>
> def _search_update(self):
> - list_store = gtk.ListStore(str, str)
> + list_store = Gtk.ListStore(str, str)
>
> for place in places.get_store().search(self.props.text):
> list_store.append([place.uri, place.title])
> @@ -131,7 +131,7 @@ class WebEntry(iconentry.IconEntry):
> x = entry_x + entry_h / 2
> y = entry_y + entry_h
> width = self.allocation.width - entry_h
> - height = gtk.gdk.screen_height() / 3
> + height = Gdk.Screen.height() / 3
>
> self._search_window.move(x, y)
> self._search_window.resize(width, height)
> @@ -165,7 +165,7 @@ class WebEntry(iconentry.IconEntry):
> self.activate(uri)
>
> def __key_press_event_cb(self, entry, event):
> - keyname = gtk.gdk.keyval_name(event.keyval)
> + keyname = Gdk.keyval_name(event.keyval)
>
> selection = self._search_view.get_selection()
> model, selected = selection.get_selected()
> @@ -220,11 +220,11 @@ class PrimaryToolbar(ToolbarBase):
> __gtype_name__ = 'PrimaryToolbar'
>
> __gsignals__ = {
> - 'add-link': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'add-link': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> - 'go-home': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'go-home': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> }
>
> @@ -253,7 +253,7 @@ class PrimaryToolbar(ToolbarBase):
> self.entry.connect('icon-press', self._stop_and_reload_cb)
> self.entry.connect('activate', self._entry_activate_cb)
>
> - entry_item = gtk.ToolItem()
> + entry_item = Gtk.ToolItem()
> entry_item.set_expand(True)
> entry_item.add(self.entry)
> self.entry.show()
> @@ -294,7 +294,7 @@ class PrimaryToolbar(ToolbarBase):
> self._session_history_changed_hid = None
> self._title_changed_hid = None
>
> - gobject.idle_add(lambda:
> + GObject.idle_add(lambda:
> self._connect_to_browser(tabbed_view.props.current_browser))
>
> tabbed_view.connect_after('switch-page', self.__switch_page_cb)
> @@ -343,7 +343,7 @@ class PrimaryToolbar(ToolbarBase):
>
> def _session_history_changed_cb(self, session_history, current_page_index):
> # We have to wait until the history info is updated.
> - gobject.idle_add(self._reload_session_history, current_page_index)
> + GObject.idle_add(self._reload_session_history, current_page_index)
>
> def __location_changed_cb(self, progress_listener, pspec):
> self._set_address(progress_listener.location)
> diff --git a/widgets.py b/widgets.py
> index 1759e38..9fc0b9f 100644
> --- a/widgets.py
> +++ b/widgets.py
> @@ -16,34 +16,34 @@
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>
> -import gobject
> -import gtk
> +from gi.repository import GObject
> +from gi.repository import Gtk
>
> from sugar.graphics.icon import Icon
>
>
> -class TabAdd(gtk.HBox):
> +class TabAdd(Gtk.HBox):
> __gtype_name__ = 'TabAdd'
>
> __gsignals__ = {
> - 'tab-added': (gobject.SIGNAL_RUN_FIRST,
> - gobject.TYPE_NONE,
> + 'tab-added': (GObject.SignalFlags.RUN_FIRST,
> + None,
> ([])),
> }
>
> def __init__(self):
> - gtk.HBox.__init__(self)
> + GObject.GObject.__init__(self)
>
> add_tab_icon = Icon(icon_name='add')
> - button = gtk.Button()
> - button.props.relief = gtk.RELIEF_NONE
> + button = Gtk.Button()
> + button.props.relief = Gtk.ReliefStyle.NONE
> button.props.focus_on_click = False
> - icon_box = gtk.HBox()
> + icon_box = Gtk.HBox()
> icon_box.pack_start(add_tab_icon, True, False, 0)
> button.add(icon_box)
> button.connect('clicked', self.__button_clicked_cb)
> button.set_name('browse-tab-add')
> - self.pack_start(button)
> + self.pack_start(button, True, True, 0)
> add_tab_icon.show()
> icon_box.show()
> button.show()
> @@ -52,19 +52,19 @@ class TabAdd(gtk.HBox):
> self.emit('tab-added')
>
>
> -class BrowserNotebook(gtk.Notebook):
> +class BrowserNotebook(Gtk.Notebook):
> __gtype_name__ = 'BrowserNotebook'
>
> """Handle an extra tab at the end with an Add Tab button."""
>
> def __init__(self):
> - gtk.Notebook.__init__(self)
> + GObject.GObject.__init__(self)
> self._switch_handler = self.connect('switch-page',
> self.__on_switch_page)
>
> tab_add = TabAdd()
> tab_add.connect('tab-added', self.on_add_tab)
> - empty_page = gtk.HBox()
> + empty_page = Gtk.HBox()
> self.append_page(empty_page, tab_add)
> empty_page.show()
>
> @@ -73,7 +73,7 @@ class BrowserNotebook(gtk.Notebook):
>
> def __on_switch_page(self, notebook, page, page_num):
> """Don't switch to the extra tab at the end."""
> - if page_num == gtk.Notebook.get_n_pages(self) - 1:
> + if page_num == Gtk.Notebook.get_n_pages(self) - 1:
> self.handler_block(self._switch_handler)
> self.set_current_page(-1)
> self.handler_unblock(self._switch_handler)
> @@ -82,7 +82,7 @@ class BrowserNotebook(gtk.Notebook):
>
> def get_n_pages(self):
> """Skip the extra tab at the end on the pages count."""
> - return gtk.Notebook.get_n_pages(self) - 1
> + return Gtk.Notebook.get_n_pages(self) - 1
>
> def append_page(self, page, label):
> """Append keeping the extra tab at the end."""
> @@ -92,4 +92,4 @@ class BrowserNotebook(gtk.Notebook):
> """If indexing from the end, skip the extra tab."""
> if number< 0:
> number = self.get_n_pages() - 1
> - gtk.Notebook.set_current_page(self, number)
> + Gtk.Notebook.set_current_page(self, number)
More information about the Sugar-devel
mailing list