From 3f537e41990fea901e640867ced6a8f5a77d06bb Mon Sep 17 00:00:00 2001 From: Ignacio Rodríguez Date: Mon, 31 Dec 2012 01:52:21 +0000 Subject: Plugin - Port Finish --- diff --git a/plugin/__init__.py b/plugin/__init__.py index baaa057..223bc15 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -20,11 +20,11 @@ import subprocess from os.path import abspath, dirname from gettext import gettext as _ -import gtk import dbus -import gobject +from gi.repository import Gtk +from gi.repository import GObject -from sugar.graphics.alert import NotifyAlert, ErrorAlert +from sugar3.graphics.alert import NotifyAlert, ErrorAlert from sugar_network import api_url, server_mode, IPCClient from active_toolkit.options import Option @@ -102,27 +102,27 @@ def start(): def control_panel_section(): - section = gtk.VBox() + section = Gtk.VBox() - server_box = gtk.VBox() - section.pack_start(server_box) - master_button = gtk.RadioButton() + server_box = Gtk.VBox() + section.pack_start(server_box, False, False, 0) + master_button = Gtk.RadioButton() master_button.props.label = _('Connect to master server') - server_box.pack_start(master_button, expand=False) - discover_button = gtk.RadioButton(master_button) + server_box.pack_start(master_button, False, False, 0) + discover_button = Gtk.RadioButton(master_button) discover_button.props.label = _('Auto discover server in local network') - server_box.pack_start(discover_button, expand=False) + server_box.pack_start(discover_button, False, False, 0) if api_url.value: master_button.props.active = True else: discover_button.props.active = True - server_mode_button = gtk.CheckButton() + server_mode_button = Gtk.CheckButton() server_mode_button.props.label = _('Behave as a Sugar Network server ' 'providing data from mounted device') server_mode_button.props.active = server_mode.value - section.pack_start(server_mode_button, expand=False) + section.pack_start(server_mode_button, False, False, 0) def master_toggled_cb(button, url): api_url.value = url @@ -205,20 +205,20 @@ def _get_bundle_path(self): return env.split('=', 1)[-1] -class _Client(gobject.GObject): +class _Client(GObject.GObject): __gsignals__ = { 'event': ( - gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - [str, gobject.TYPE_PYOBJECT]), + GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, + [str, GObject.TYPE_PYOBJECT]), } def __init__(self): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self._client = IPCClient() self._subscription = self._client.subscribe() - gobject.io_add_watch(self._subscription.fileno(), - gobject.IO_IN | gobject.IO_HUP, self.__subscription_cb) + GObject.io_add_watch(self._subscription.fileno(), + GObject.IO_IN | GObject.IO_HUP, self.__subscription_cb) def __getattr__(self, name): return getattr(self._client, name) diff --git a/plugin/browser.py b/plugin/browser.py index f9b377d..ca48ca2 100644 --- a/plugin/browser.py +++ b/plugin/browser.py @@ -17,16 +17,17 @@ import urllib import logging from gettext import gettext as _ -import gtk -import glib -import webkit -import gobject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import WebKit +from gi.repository import GObject from sugar_network import webui_port -from sugar import wm -from sugar.graphics.window import Window -from sugar.activity.activityfactory import create_activity_id +from sugar3 import wm +from sugar3.graphics.window import Window +from sugar3.activity.activityfactory import create_activity_id from jarabe.view.palettes import BasePalette from jarabe.plugins.sn import SN_BROWSER_NAME, get_client @@ -53,13 +54,13 @@ class Browser(Window): self.connect('realize', self.__realize_cb) self.iconify() - scrolled = gtk.ScrolledWindow() - scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled.set_shadow_type(gtk.SHADOW_NONE) + scrolled = Gtk.ScrolledWindow() + scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + scrolled.set_shadow_type(Gtk.ShadowType.NONE) self.set_canvas(scrolled) # pylint: disable-msg=E1101 - self._webkit = webkit.WebView() + self._webkit = WebKit.WebView() scrolled.add(self._webkit) self.show_all() @@ -67,7 +68,7 @@ class Browser(Window): self._webkit.connect('notify::load-status', self.__load_status_cb) get_client().connect('event', self.__Event_cb) - gobject.timeout_add_seconds(_RETRY_TIMEOUT, self._open) + GObject.timeout_add_seconds(_RETRY_TIMEOUT, self._open) def open_report(self, **kwargs): self._open('_report', **kwargs) @@ -98,7 +99,7 @@ class Browser(Window): else: self.get_window().set_cursor(None) elif self._webkit.props.load_status == _WEBKIT_LOAD_PROVISIONAL: - self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) + self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) def __realize_cb(self, window): wm.set_bundle_id(window.window, SN_BROWSER_NAME) @@ -118,4 +119,4 @@ class Palette(BasePalette): def setup_palette(self): title = self._activity.get_title() - self.set_primary_text(glib.markup_escape_text(title)) + self.set_primary_text(GLib.markup_escape_text(title)) diff --git a/plugin/bundleregistry.py b/plugin/bundleregistry.py index 20860da..07cbc7b 100644 --- a/plugin/bundleregistry.py +++ b/plugin/bundleregistry.py @@ -17,17 +17,18 @@ import shutil import logging from gettext import gettext as _ -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject + from pylru import lrucache -from sugar import util +from sugar3 import util from sugar_network import clones -from sugar.bundle.activitybundle import ActivityBundle -from sugar.bundle.contentbundle import ContentBundle -from sugar.bundle.bundleversion import NormalizedVersion -from sugar.bundle.bundle import AlreadyInstalledException +from sugar3.bundle.activitybundle import ActivityBundle +from sugar3.bundle.contentbundle import ContentBundle +from sugar3.bundle.bundleversion import NormalizedVersion +from sugar3.bundle.bundle import AlreadyInstalledException from jarabe.model import mimeregistry from jarabe.plugins.sn import SN_BROWSER_NAME, get_client from jarabe.journal.journalentrybundle import JournalEntryBundle @@ -41,25 +42,25 @@ _online_cache = lrucache(32) def stub_icon(): global _stub_icon_path if not _stub_icon_path: - theme = gtk.icon_theme_get_default() + theme = Gtk.IconTheme.get_default() _stub_icon_path = theme.lookup_icon('empty', 0, 0).get_filename() return _stub_icon_path -class BundleRegistry(gobject.GObject): +class BundleRegistry(GObject.GObject): """Tracks the available activity bundles""" __gsignals__ = { - 'bundle-added': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])), - 'bundle-removed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])), - 'bundle-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([gobject.TYPE_PYOBJECT])), + 'bundle-added': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, + ([GObject.TYPE_PYOBJECT])), + 'bundle-removed': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, + ([GObject.TYPE_PYOBJECT])), + 'bundle-changed': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, + ([GObject.TYPE_PYOBJECT])), } def __init__(self): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self._bundles = {} get_client().connect('event', self.__Event_cb) @@ -347,7 +348,7 @@ class _BundleInfo(object): class _BrowserInfo(object): def __init__(self): - icon = gtk.icon_theme_get_default().lookup_icon('sugar-network', 0, 0) + icon = Gtk.IconTheme.get_default().lookup_icon('sugar-network', 0, 0) self._icon_path = icon.get_filename() def get_name(self): diff --git a/plugin/launcher.py b/plugin/launcher.py index ec403ed..24894ec 100644 --- a/plugin/launcher.py +++ b/plugin/launcher.py @@ -15,13 +15,14 @@ import logging -import gtk -import wnck -import gconf +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import Wnck +from gi.repository import GConf -from sugar import wm -from sugar.graphics.xocolor import XoColor -from sugar.activity.activityfactory import create_activity_id +from sugar3 import wm +from sugar3.graphics.xocolor import XoColor +from sugar3.activity.activityfactory import create_activity_id from jarabe.view.launcher import LaunchWindow from jarabe.journal import model @@ -37,7 +38,7 @@ class Launcher(object): def __init__(self): self._launches = {} - self._screen = wnck.screen_get_default() + self._screen = Wnck.Screen.get_default() self._screen.connect('window-opened', self.__window_opened_cb) get_client().connect('event', self.__Event_cb) @@ -47,7 +48,7 @@ class Launcher(object): activity = shell.get_model().get_activity_by_id(activity_id) if activity is not None: _logger.debug('Resume %r activity', activity_id) - activity.get_window().activate(gtk.get_current_event_time()) + activity.get_window().activate(Gtk.get_current_event_time()) return def found_jobjects(jobjects, total): @@ -92,7 +93,7 @@ class Launcher(object): def _start_launcher(self, bundle_id, icon, activity_id, color): if color is None: - gc = gconf.client_get_default() + gc = GConf.Client.get_default() color = XoColor(gc.get_string('/desktop/sugar/user/color')) window = LaunchWindow(activity_id, icon, color) window.connect('realize', self.__window_realize_cb, @@ -116,7 +117,7 @@ class Launcher(object): get_browser().open_report(**kwargs) def __window_opened_cb(self, screen, window): - if window.get_window_type() != wnck.WINDOW_NORMAL or \ + if window.get_window_type() != Wnck.WindowType.NORMAL or \ wm.get_sugar_window_type(window) == 'launcher': return activity_id = wm.get_activity_id(window) @@ -126,7 +127,7 @@ class Launcher(object): def __window_realize_cb(self, widget, bundle_id, activity_id): wm.set_activity_id(widget.window, str(activity_id)) widget.window.property_change('_SUGAR_WINDOW_TYPE', 'STRING', 8, - gtk.gdk.PROP_MODE_REPLACE, 'launcher') + Gdk.PropMode.REPLACE, 'launcher') wm.set_bundle_id(widget.window, str(bundle_id)) def __Event_cb(self, event, data): -- cgit v0.9.1