diff options
Diffstat (limited to 'groupthink')
-rw-r--r-- | groupthink/gtk_tools.py | 24 | ||||
-rw-r--r-- | groupthink/sugar_tools.py | 58 |
2 files changed, 41 insertions, 41 deletions
diff --git a/groupthink/gtk_tools.py b/groupthink/gtk_tools.py index 0cd4029..c88d27e 100644 --- a/groupthink/gtk_tools.py +++ b/groupthink/gtk_tools.py @@ -1,15 +1,15 @@ -import gtk +from gi.repository import Gtk import groupthink_base as groupthink import logging import stringtree -class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry): +class RecentEntry(groupthink.UnorderedHandlerAcceptor, Gtk.Entry): """RecentEntry is an extension of gtk.Entry that, when attached to a group, creates a unified Entry field for all participants""" def __init__(self, *args, **kargs): - gtk.Entry.__init__(self, *args, **kargs) + Gtk.Entry.__init__(self, *args, **kargs) self.logger = logging.getLogger('RecentEntry') - self.add_events(gtk.gdk.PROPERTY_CHANGE_MASK) + self.add_events(Gdk.EventMask.PROPERTY_CHANGE_MASK) self._text_changed_handler = self.connect('changed', self._local_change_cb) self._recent = groupthink.Recentest(self.get_text(), groupthink.string_translator) self._recent.register_listener(self._remote_change_cb) @@ -32,7 +32,7 @@ class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry): self.set_text(text) self.handler_unblock(self._text_changed_handler) -class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): +class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.TreeModel): def __init__(self, columntypes=(), translators=()): self._columntypes = columntypes self._causaltree = groupthink.CausalTree() @@ -63,7 +63,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): ### Methods necessary to implement gtk.GenericTreeModel ### def on_get_flags(self): - return gtk.TREE_MODEL_ITERS_PERSIST + return Gtk.TREE_MODEL_ITERS_PERSIST def on_get_n_columns(self): return len(self._columntypes) @@ -186,9 +186,9 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel): for cmd in reverse: clean = True if cmd[0] == self._causaltree.SET_PARENT: - if (clean and - cmd[2] in self._causaltree and - (cmd[1] not in self._causaltree or + if (clean and + cmd[2] in self._causaltree and + (cmd[1] not in self._causaltree or cmd[2] != self._causaltree.get_parent(cmd[1]))): clean = False @@ -324,14 +324,14 @@ class TextBufferUnorderedStringLinker: class TextBufferSharePoint(groupthink.UnorderedHandlerAcceptor): def __init__(self, buff): self._us = groupthink.UnorderedString(buff.get_text(buff.get_start_iter(), buff.get_end_iter())) - self._linker = TextBufferUnorderedStringLinker(buff, self._us) + self._linker = TextBufferUnorderedStringLinker(buff, self._us) def set_handler(self, handler): self._us.set_handler(handler) -class SharedTextView(groupthink.UnorderedHandlerAcceptor, gtk.TextView): +class SharedTextView(groupthink.UnorderedHandlerAcceptor, Gtk.TextView): def __init__(self, *args, **kargs): - gtk.TextView.__init__(self, *args, **kargs) + Gtk.TextView.__init__(self, *args, **kargs) self._link = TextBufferSharePoint(self.get_buffer()) def set_handler(self, handler): 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() |