diff options
Diffstat (limited to 'groupthink/sugar_tools.py')
-rw-r--r-- | groupthink/sugar_tools.py | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/groupthink/sugar_tools.py b/groupthink/sugar_tools.py index d68b616..14a8cee 100644 --- a/groupthink/sugar_tools.py +++ b/groupthink/sugar_tools.py @@ -17,22 +17,22 @@ import logging import telepathy -from sugar.activity.activity import Activity -from sugar.graphics.toolbarbox import ToolbarBox +from sugar3.activity.activity import Activity +from sugar3.graphics.toolbarbox import ToolbarBox -from sugar.presence import presenceservice +from sugar3.presence import presenceservice -from sugar.presence.tubeconn import TubeConnection -from sugar.graphics.window import Window +from sugar3.presence.tubeconn import TubeConnection +from sugar3.graphics.window import Window -import gtk -import gobject +from gi.repository import Gtk +from gi.repository import GObject import groupthink_base as groupthink def exhaust_event_loop(): - while gtk.events_pending(): - gtk.main_iteration() + while Gtk.events_pending(): + Gtk.main_iteration() class GroupActivity(Activity): @@ -44,7 +44,7 @@ class GroupActivity(Activity): def __init__(self, handle): # self.initiating indicates whether this instance has initiated sharing # it always starts false, but will be set to true if this activity - # initiates sharing. In particular, if Activity.__init__ calls + # initiates sharing. In particular, if Activity.__init__ calls # self.share(), self.initiating will be set to True. self.initiating = False # self._processed_share indicates whether when_shared() has been called @@ -61,9 +61,9 @@ class GroupActivity(Activity): self._handle = handle ##gobject.threads_init() - self._sharing_completed = not self._shared_activity + self._sharing_completed = not self.shared_activity self._readfile_completed = not handle.object_id - if self._shared_activity: + if self.shared_activity: self.message = self.message_joining elif handle.object_id: self.message = self.message_loading @@ -75,9 +75,9 @@ class GroupActivity(Activity): self.set_toolbox(toolbox) toolbox.show() - v = gtk.VBox() - self.startup_label = gtk.Label(self.message) - v.pack_start(self.startup_label) + v = Gtk.VBox() + self.startup_label = Gtk.Label(self.message) + v.pack_start(self.startup_label, False, False, 0) Window.set_canvas(self,v) self.show_all() @@ -114,15 +114,15 @@ class GroupActivity(Activity): else: self._joined_cb(self) - self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) + self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK) self.connect("visibility-notify-event", self._visible_cb) self.connect("notify::active", self._active_cb) if not self._readfile_completed: self._initialize_display() self.read_file(self._jobject.file_path) - elif not self._shared_activity: - gobject.idle_add(self._initialize_cleanstart) + elif not self.shared_activity: + GObject.idle_add(self._initialize_cleanstart) def _initialize_cleanstart(self): self.initialize_cleanstart() @@ -144,7 +144,7 @@ class GroupActivity(Activity): main_widget = self.initialize_display() Window.set_canvas(self, main_widget) self.initialized = True - if self._shared_activity and not self._processed_share: + if self.shared_activity and not self._processed_share: # We are joining a shared activity, but when_shared has not yet # been called self.when_shared() @@ -182,13 +182,13 @@ class GroupActivity(Activity): self.dbus_name, {}) def _sharing_setup(self): - if self._shared_activity is None: + if self.shared_activity is None: self.logger.error('Failed to share or join activity') return - self.conn = self._shared_activity.telepathy_conn - self.tubes_chan = self._shared_activity.telepathy_tubes_chan - self.text_chan = self._shared_activity.telepathy_text_chan + self.conn = self.shared_activity.telepathy_conn + self.tubes_chan = self.shared_activity.telepathy_tubes_chan + self.text_chan = self.shared_activity.telepathy_text_chan self.tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal('NewTube', self._new_tube_cb) @@ -202,7 +202,7 @@ class GroupActivity(Activity): self.logger.error('ListTubes() failed: %s', e) def _joined_cb(self, activity): - if not self._shared_activity: + if not self.shared_activity: return self.logger.debug('Joined an existing shared activity') @@ -241,7 +241,7 @@ class GroupActivity(Activity): """This implementation of load_from_journal simply returns the contents of the file. Any inheritor overriding this method must return the string provided to save_to_journal as cloudstring.""" - if file_path: + if file_path: f = file(file_path,'rb') s = f.read() f.close() @@ -255,12 +255,12 @@ class GroupActivity(Activity): # read) before writing. if not self._readfile_completed: self.read_file(self._jobject.file_path) - self.save_to_journal(file_path, self.cloud.dumps()) + self.save_to_journal(file_path, self.cloud.dumps()) def save_to_journal(self, file_path, cloudstring): - """This implementation of save_to_journal simply dumps the output of + """This implementation of save_to_journal simply dumps the output of self.cloud.dumps() to disk. Any inheritor who wishes to control file - output should override this method, and must + output should override this method, and must be sure to include cloudstring in its write_file.""" f = file(file_path, 'wb') f.write(cloudstring) @@ -275,7 +275,7 @@ class GroupActivity(Activity): def _visible_cb(self, widget, event): self.logger.debug("_visible_cb") - if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED: + if event.get_state() == Gdk.VisibilityState.FULLY_OBSCURED: self.pause() else: self.resume() |