Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/groupthink/sugar_tools.py
diff options
context:
space:
mode:
Diffstat (limited to 'groupthink/sugar_tools.py')
-rw-r--r--groupthink/sugar_tools.py112
1 files changed, 51 insertions, 61 deletions
diff --git a/groupthink/sugar_tools.py b/groupthink/sugar_tools.py
index 66d4a0e..cb651c6 100644
--- a/groupthink/sugar_tools.py
+++ b/groupthink/sugar_tools.py
@@ -16,28 +16,21 @@
import logging
import telepathy
-
-from sugar.activity.activity import Activity, ActivityToolbox
-from sugar.presence import presenceservice
-
-from sugar.presence.tubeconn import TubeConnection
-from sugar.graphics.window import Window
-
-import gtk
-import gobject
-
+import gi
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
+from sugar3.activity.activity import Activity
+from sugar3.presence import presenceservice
+from sugar3.presence.tubeconn import TubeConnection
+from sugar3.graphics.window import Window
+from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
+from sugar3.activity.widgets import ActivityToolbarButton
import groupthink_base as groupthink
-OLD_TOOLBAR = False
-try:
- from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton
- from sugar.activity.widgets import ActivityToolbarButton
-except ImportError:
- OLD_TOOLBAR = True
-
def exhaust_event_loop():
- while gtk.events_pending():
- gtk.main_iteration()
+ while Gtk.events_pending():
+ Gtk.main_iteration()
class GroupActivity(Activity):
@@ -49,7 +42,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
@@ -65,31 +58,26 @@ class GroupActivity(Activity):
self._handle = handle
- ##gobject.threads_init()
+ ##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:
- self.message = self.message_joining
- elif handle.object_id:
- self.message = self.message_loading
- else:
- self.message = self.message_preparing
+ #if self._shared_activity:
+ # self.message = self.message_joining
+ #elif handle.object_id:
+ # self.message = self.message_loading
+ #else:
+ # self.message = self.message_preparing
+ self.message = "Shared No Funciona"
- if OLD_TOOLBAR:
- self.toolbox = ActivityToolbox(self)
- self.set_toolbox(self.toolbox)
- self.toolbox.show()
- self.set_toolbox(self.toolbox)
- else:
- toolbar_box = ToolbarBox()
- self.activity_button = ActivityToolbarButton(self)
- toolbar_box.toolbar.insert(self.activity_button, 0)
- self.set_toolbar_box(toolbar_box)
+ toolbar_box = ToolbarBox()
+ self.activity_button = ActivityToolbarButton(self)
+ toolbar_box.toolbar.insert(self.activity_button, 0)
+ self.set_toolbar_box(toolbar_box)
- v = gtk.VBox()
- self.startup_label = gtk.Label(self.message)
- v.pack_start(self.startup_label)
+ v = Gtk.VBox()
+ self.startup_label = Gtk.Label(label=self.message)
+ v.pack_start(self.startup_label, True, True, 0)
Window.set_canvas(self,v)
self.show_all()
@@ -117,22 +105,22 @@ class GroupActivity(Activity):
owner = self.pservice.get_owner()
self.owner = owner
- self.connect('shared', self._shared_cb)
- self.connect('joined', self._joined_cb)
- if self.get_shared():
- if self.initiating:
- self._shared_cb(self)
- else:
- self._joined_cb(self)
+ #self.connect('shared', self._shared_cb)
+ #self.connect('joined', self._joined_cb)
+ #if self.get_shared():
+ # if self.initiating:
+ # self._shared_cb(self)
+ # 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.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()
@@ -154,18 +142,19 @@ 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:
# We are joining a shared activity, but when_shared has not yet
# been called
self.when_shared()
- self._processed_share = True
+ self._processed_share = True'''
self.show_all()
def initialize_display(self):
"""All subclasses must override this method, in order to display
their GUI using self.set_canvas()"""
raise NotImplementedError
-
+ '''
def share(self, private=False):
"""The purpose of this function is solely to permit us to determine
whether share() has been called. This is necessary because share() may
@@ -238,20 +227,21 @@ class GroupActivity(Activity):
self.tubebox.insert_tube(tube_conn, self.initiating)
self._sharing_completed = True
if self._readfile_completed and not self.initialized:
- self._initialize_display()
+ self._initialize_display()'''
def read_file(self, file_path):
self.cloud.loads(self.load_from_journal(file_path))
self._readfile_completed = True
- if self._sharing_completed and not self.initialized:
- self._initialize_display()
+ #if self._sharing_completed and not self.initialized:
+ # self._initialize_display()
+ self._initialize_display()
pass
def load_from_journal(self, file_path):
"""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()
@@ -265,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)
@@ -285,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()