Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/groupthink
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-06-15 20:08:28 (GMT)
committer flavio <fdanesse@gmail.com>2012-06-15 20:08:28 (GMT)
commitebae32267a9369ed9cdf389571581f43c871b38c (patch)
tree3f8febac7ae9e1994372929a3ee3a0f15283a237 /groupthink
parent7058c4b3d7d92442a46de28befec64f141664eb3 (diff)
Port Gtk3 Base
Diffstat (limited to 'groupthink')
-rw-r--r--groupthink/gtk_tools.py42
-rw-r--r--groupthink/sugar_tools.py112
2 files changed, 74 insertions, 80 deletions
diff --git a/groupthink/gtk_tools.py b/groupthink/gtk_tools.py
index 0cd4029..2b74276 100644
--- a/groupthink/gtk_tools.py
+++ b/groupthink/gtk_tools.py
@@ -1,15 +1,19 @@
-import gtk
+import gi
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
+
import groupthink_base as groupthink
import logging
import stringtree
-class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry):
- """RecentEntry is an extension of gtk.Entry that, when attached to a group,
+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)
+ GObject.GObject.__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)
@@ -27,12 +31,13 @@ class RecentEntry(groupthink.UnorderedHandlerAcceptor, gtk.Entry):
if self.get_text() != text:
#The following code will break if running in any thread other than
#the main thread. I do not know how to make code that works with
- #both multithreaded gtk _and_ single-threaded gtk.
+ #both multithreaded gtk _and_ single-threaded Gtk.
self.handler_block(self._text_changed_handler)
self.set_text(text)
self.handler_unblock(self._text_changed_handler)
-
-class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel):
+
+'''
+class SharedTreeStore(groupthink.CausalHandlerAcceptor, Gtk.GenericTreeModel):
def __init__(self, columntypes=(), translators=()):
self._columntypes = columntypes
self._causaltree = groupthink.CausalTree()
@@ -60,10 +65,10 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel):
h = handler.copy(str(i))
self._columndicts[i].set_handler(h)
- ### Methods necessary to implement 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 +191,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
@@ -219,7 +224,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel):
self.row_has_child_toggled(path, it)
self.emit('changed')
- ### Methods for resembling gtk.TreeStore ###
+ ### Methods for resembling Gtk.TreeStore ###
def set_value(self, it, column, value):
node = self.get_user_data(it)
@@ -283,7 +288,7 @@ class SharedTreeStore(groupthink.CausalHandlerAcceptor, gtk.GenericTreeModel):
def move(self, it, newparent):
node = self.get_user_data(row)
p = self.get_user_data(newparent)
- self._causaltree.change_parent(node,p)
+ self._causaltree.change_parent(node,p)'''
class TextBufferUnorderedStringLinker:
def __init__(self,tb,us):
@@ -320,18 +325,17 @@ class TextBufferUnorderedStringLinker:
self._tb.handler_unblock(self._insert_handler)
self._tb.handler_unblock(self._delete_handler)
-
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)
+ GObject.GObject.__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 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()