Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-07-18 01:12:14 (GMT)
committer flavio <fdanesse@gmail.com>2012-07-18 01:12:14 (GMT)
commit973dc1a85c8b770c8e365457546c6fe816f58aa8 (patch)
tree33f47b669f9c0ee1ddec176edac53718e66bac9f
parent0edb2b73645352222a518ca98d7c8b6e7fc4c063 (diff)
The activity starts
-rw-r--r--activity.py43
-rw-r--r--chat.py12
-rw-r--r--chatbox.py13
-rw-r--r--combobox.py5
-rw-r--r--espeak.py12
-rw-r--r--eye.py20
-rw-r--r--face.py31
-rw-r--r--mouth.py16
-rw-r--r--roundbox.py23
-rw-r--r--shared_activity.py2
-rw-r--r--toolitem.py4
11 files changed, 98 insertions, 83 deletions
diff --git a/activity.py b/activity.py
index 6861420..4045f75 100644
--- a/activity.py
+++ b/activity.py
@@ -26,6 +26,7 @@ from sugar3.activity import activity
from sugar3.presence import presenceservice
import logging
from gi.repository import Gtk
+from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import Pango
import cjson
@@ -100,20 +101,22 @@ class SpeakActivity(SharedActivity):
self.connect("notify::active", self._activeCb)
# make a box to type into
- self.entrycombo = Gtk.combo_box_entry_new_text()
+ self.entrycombo = Gtk.ComboBoxText()
self.entrycombo.connect("changed", self._combo_changed_cb)
self.entry = self.entrycombo.get_child()
- self.entry.set_editable(True)
- self.entry.connect('activate', self._entry_activate_cb)
+ # FIXME: unknown signal name: activate
+ #self.entry.can_activate_accel(True)
+ #self.entry.connect('activate', self._entry_activate_cb)
self.entry.connect("key-press-event", self._entry_key_press_cb)
- self.input_font = Pango.FontDescription(str='sans bold 24')
+ self.input_font = Pango.FontDescription('sans bold 24')
self.entry.modify_font(self.input_font)
self.face = face.View()
self.face.show()
# layout the screen
- box = Gtk.VBox(homogeneous=False)
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ box.set_homogeneous(False)
box.pack_start(self.face, True, True, 0)
box.pack_start(self.entrycombo, False, True, 0)
@@ -130,17 +133,18 @@ class SpeakActivity(SharedActivity):
self.notebook.props.show_tabs = False
box.show_all()
- self.notebook.append_page(box)
+ self.notebook.append_page(box, Gtk.Label(""))
self.chat = chat.View()
self.chat.show_all()
- self.notebook.append_page(self.chat)
+ self.notebook.append_page(self.chat, Gtk.Label(""))
# make the text box active right away
self.entry.grab_focus()
-
- self.entry.connect("move-cursor", self._cursor_moved_cb)
- self.entry.connect("changed", self._cursor_moved_cb)
+ # FIXME: unknown signal name: move-cursor
+ #self.entry.connect("move-cursor", self._cursor_moved_cb)
+ # FIXME: unknown signal name: changed
+ #self.entry.connect("changed", self._cursor_moved_cb)
# toolbar
toolbox = ToolbarBox()
@@ -221,7 +225,7 @@ class SpeakActivity(SharedActivity):
if self._cursor != cursor:
self._cursor = cursor
- self.window.set_cursor(self._cursor)
+ self.get_property('window').set_cursor(self._cursor)
def __map_canvasactivity_cb(self, widget):
logging.debug('Activity.__map_canvasactivity_cb state=%s' % \
@@ -293,7 +297,7 @@ class SpeakActivity(SharedActivity):
self.eye_shape_combo.select(status.eyes[0])
self.numeyesadj.value = len(status.eyes)
- self.entry.props.text = cfg['text'].encode('utf-8', 'ignore')
+ #self.entry.props.text = cfg['text'].encode('utf-8', 'ignore')
for i in cfg['history']:
self.entrycombo.append_text(i.encode('utf-8', 'ignore'))
@@ -337,10 +341,11 @@ class SpeakActivity(SharedActivity):
self.pitchadj = Gtk.Adjustment(self.face.status.pitch, 0,
espeak.PITCH_MAX, 1, espeak.PITCH_MAX / 10, 0)
- pitchbar = Gtk.HScale(self.pitchadj)
+ pitchbar = Gtk.Scale(orientation = Gtk.Orientation.HORIZONTAL)
+ pitchbar.set_adjustment(self.pitchadj)
pitchbar.set_draw_value(False)
# pitchbar.set_inverted(True)
- pitchbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
+ #pitchbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
pitchbar.set_size_request(240, 15)
pitchbar_toolitem = ToolWidget(
@@ -350,10 +355,11 @@ class SpeakActivity(SharedActivity):
self.rateadj = Gtk.Adjustment(self.face.status.rate, 0,
espeak.RATE_MAX, 1, espeak.RATE_MAX / 10, 0)
- ratebar = Gtk.HScale(self.rateadj)
+ ratebar = Gtk.Scale(orientation = Gtk.Orientation.HORIZONTAL)
+ ratebar.set_adjustment(self.rateadj)
ratebar.set_draw_value(False)
# ratebar.set_inverted(True)
- ratebar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
+ #ratebar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
ratebar.set_size_request(240, 15)
ratebar_toolitem = ToolWidget(
@@ -398,9 +404,10 @@ class SpeakActivity(SharedActivity):
facebar.insert(eye_shape_toolitem, -1)
self.numeyesadj = Gtk.Adjustment(2, 1, 5, 1, 1, 0)
- numeyesbar = Gtk.HScale(self.numeyesadj)
+ numeyesbar = Gtk.Scale(orientation = Gtk.Orientation.HORIZONTAL)
+ numeyesbar.set_adjustment(self.numeyesadj)
numeyesbar.set_draw_value(False)
- numeyesbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
+ #numeyesbar.set_update_policy(Gtk.UPDATE_DISCONTINUOUS)
numeyesbar.set_size_request(240, 15)
numeyesbar_toolitem = ToolWidget(
diff --git a/chat.py b/chat.py
index 4d1fcc7..38875aa 100644
--- a/chat.py
+++ b/chat.py
@@ -15,6 +15,8 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
from gi.repository import Pango
import logging
from gettext import gettext as _
@@ -46,7 +48,7 @@ ENTRY_YPAD = 7
class View(Gtk.EventBox):
def __init__(self):
- GObject.GObject.__init__(self)
+ Gtk.EventBox.__init__(self)
self.messenger = None
self.me = None
@@ -97,20 +99,20 @@ class View(Gtk.EventBox):
separator.modify_bg(Gtk.StateType.NORMAL, ENTRY_COLOR.get_gdk_color())
separator.set_size_request(ENTRY_YPAD, -1)
separator.show()
- chat_entry.pack_start(separator, False, False)
+ chat_entry.pack_start(separator, False, False, 0)
chat_entry.pack_start(chat_post_box, True, True, ENTRY_XPAD)
evbox = Gtk.EventBox()
evbox.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
chat_box = Gtk.VBox()
- chat_box.pack_start(self._chat, True, True)
- chat_box.pack_start(chat_entry, False, True)
+ chat_box.pack_start(self._chat, True, True, 0)
+ chat_box.pack_start(chat_entry, False, True, 0)
evbox.add(chat_box)
# desk
self._desk = Gtk.HBox()
- self._desk.pack_start(evbox, True, True)
+ self._desk.pack_start(evbox, True, True, 0)
self._desk.show_all()
self.add(self._desk)
diff --git a/chatbox.py b/chatbox.py
index eeb8f86..d876622 100644
--- a/chatbox.py
+++ b/chatbox.py
@@ -17,6 +17,7 @@
# This code is a stripped down version of the Chat
from gi.repository import Gtk
+from gi.repository import Gdk
import logging
from gi.repository import Pango
import re
@@ -25,7 +26,7 @@ from gettext import gettext as _
from sugar3.graphics import style
from sugar3.graphics.palette import Palette
-from sugar3.graphics.palette import CanvasInvoker
+#from sugar3.graphics.palette import CanvasInvoker
from sugar3.graphics.palette import MouseSpeedDetector
from sugar3.presence import presenceservice
from sugar3.graphics.menuitem import MenuItem
@@ -41,11 +42,11 @@ URL_REGEXP = re.compile('((http|ftp)s?://)?'
class TextBox(Gtk.TextView):
- hand_cursor = Gdk.Cursor.new(Gdk.HAND2)
+ hand_cursor = Gdk.Cursor.new(Gdk.CursorType.HAND2)
def __init__(self, color, bg_color, lang_rtl):
self._lang_rtl = lang_rtl
- GObject.GObject.__init__(self)
+ Gtk.TextView.__init__(self)
self.set_editable(False)
self.set_cursor_visible(False)
self.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
@@ -196,7 +197,7 @@ class ColorLabel(Gtk.Label):
if self._color is not None:
text = '<span foreground="%s">' % self._color.get_html() +\
text + '</span>'
- GObject.GObject.__init__(self)
+ Gtk.Label.__init__(self)
self.set_use_markup(True)
self.set_markup(text)
self.props.selectable = True
@@ -205,7 +206,7 @@ class ColorLabel(Gtk.Label):
class ChatBox(Gtk.ScrolledWindow):
def __init__(self):
- GObject.GObject.__init__(self)
+ Gtk.ScrolledWindow.__init__(self)
self.owner = presenceservice.get_instance().get_owner()
@@ -340,7 +341,7 @@ class ChatBox(Gtk.ScrolledWindow):
def _scroll_changed_cb(self, adj, scroll=None):
"""Scroll the chat window to the bottom"""
if self._scroll_auto:
- adj.set_value(adj.upper - adj.page_size)
+ adj.set_value(adj.get_upper() - adj.get_page_size())
self._scroll_value = adj.get_value()
def _link_activated_cb(self, link):
diff --git a/combobox.py b/combobox.py
index 3fa1690..a065d2b 100644
--- a/combobox.py
+++ b/combobox.py
@@ -22,12 +22,13 @@ STABLE.
from gi.repository import GObject
from gi.repository import Gtk
+from gi.repository import GdkPixbuf
class ComboBox(Gtk.ComboBox):
def __init__(self):
- GObject.GObject.__init__(self)
+ Gtk.ComboBox.__init__(self)
self._text_renderer = None
self._icon_renderer = None
@@ -38,7 +39,7 @@ class ComboBox(Gtk.ComboBox):
GObject.TYPE_BOOLEAN)
self.set_model(model)
- self.set_row_separator_func(self._is_separator)
+ #self.set_row_separator_func(self._is_separator)
def get_value(self):
"""
diff --git a/espeak.py b/espeak.py
index 1a88af3..7a2b888 100644
--- a/espeak.py
+++ b/espeak.py
@@ -15,7 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import gst
-import gobject
+from gi.repository import GObject
import subprocess
import logging
@@ -24,13 +24,13 @@ logger = logging.getLogger('speak')
supported = True
-class BaseAudioGrab(gobject.GObject):
+class BaseAudioGrab(GObject.GObject):
__gsignals__ = {
- 'new-buffer': (gobject.SIGNAL_RUN_FIRST, None, [gobject.TYPE_PYOBJECT])
+ 'new-buffer': (GObject.SIGNAL_RUN_FIRST, None, [GObject.TYPE_PYOBJECT])
}
def __init__(self):
- gobject.GObject.__init__(self)
+ GObject.GObject.__init__(self)
self.pipeline = None
self.quiet = True
@@ -69,7 +69,7 @@ class BaseAudioGrab(gobject.GObject):
def on_buffer(element, buffer, pad):
# we got a new buffer of data, ask for another
- gobject.timeout_add(100, self._new_buffer, str(buffer))
+ GObject.timeout_add(100, self._new_buffer, str(buffer))
return True
sink = self.pipeline.get_by_name('sink')
@@ -87,7 +87,7 @@ class BaseAudioGrab(gobject.GObject):
logger.debug(message.type)
self._was_message = False
- gobject.timeout_add(500, self._new_buffer, str(buffer))
+ GObject.timeout_add(500, self._new_buffer, str(buffer))
elif message.type in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
logger.debug(message.type)
diff --git a/eye.py b/eye.py
index 3d95dff..fdb4a4f 100644
--- a/eye.py
+++ b/eye.py
@@ -23,14 +23,14 @@
import gi
from gi.repository import Gtk
-import Gtk.gdk
+from gi.repository import Gdk
+from gi.repository import GObject
import math
class Eye(Gtk.DrawingArea):
def __init__(self, fill_color):
- GObject.GObject.__init__(self)
- self.connect("expose_event", self.expose)
+ Gtk.DrawingArea.__init__(self)
self.frame = 0
self.blink = False
self.x, self.y = 0, 0
@@ -66,7 +66,7 @@ class Eye(Gtk.DrawingArea):
if self.x is None or self.y is None:
# look ahead, but not *directly* in the middle
- if a.x + a.width / 2 < self.parent.get_allocation().width / 2:
+ if a.x + a.width / 2 < self.get_allocation().width / 2:
cx = a.width * 0.6
else:
cx = a.width * 0.4
@@ -96,7 +96,7 @@ class Eye(Gtk.DrawingArea):
return a.width / 2 + dx, a.height / 2 + dy
- def expose(self, widget, event):
+ def do_draw(self, context):
self.frame += 1
bounds = self.get_allocation()
@@ -112,15 +112,15 @@ class Eye(Gtk.DrawingArea):
pupilX = bounds.width / 2 + dX * limit / distance
pupilY = bounds.height / 2 + dY * limit / distance
- self.context = widget.window.cairo_create()
+ self.context = context
#self.context.set_antialias(cairo.ANTIALIAS_NONE)
#set a clip region for the expose event.
#This reduces redrawing work (and time)
- self.context.rectangle(event.area.x,
- event.area.y,
- event.area.width,
- event.area.height)
+ self.context.rectangle(bounds.x,
+ bounds.y,
+ bounds.width,
+ bounds.height)
self.context.clip()
# background
diff --git a/face.py b/face.py
index 7609923..8393788 100644
--- a/face.py
+++ b/face.py
@@ -23,7 +23,8 @@
import logging
-import gtk
+from gi.repository import Gtk
+from gi.repository import Gdk
import cjson
import sugar3.graphics.style as style
@@ -92,9 +93,9 @@ class Status:
return new
-class View(gtk.EventBox):
+class View(Gtk.EventBox):
def __init__(self, fill_color=style.COLOR_BUTTON_GREY):
- gtk.EventBox.__init__(self)
+ Gtk.EventBox.__init__(self)
self.status = Status()
self.fill_color = fill_color
@@ -105,20 +106,21 @@ class View(gtk.EventBox):
# make an empty box for some eyes
self._eyes = None
- self._eyebox = gtk.HBox()
+ self._eyebox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self._eyebox.show()
# make an empty box to put the mouth in
self._mouth = None
- self._mouthbox = gtk.HBox()
+ self._mouthbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
self._mouthbox.show()
# layout the screen
- box = gtk.VBox(homogeneous=False)
- box.pack_start(self._eyebox)
- box.pack_start(self._mouthbox, False)
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
+ box.set_homogeneous(False)
+ box.pack_start(self._eyebox, True, True, 0)
+ box.pack_start(self._mouthbox, False, False, 0)
box.set_border_width(FACE_PAD)
- self.modify_bg(gtk.STATE_NORMAL, self.fill_color.get_gdk_color())
+ self.modify_bg(0, self.fill_color.get_gdk_color())
self.add(box)
self._peding = None
@@ -138,7 +140,7 @@ class View(gtk.EventBox):
def look_at(self, pos=None):
if self._eyes:
if pos is None:
- display = gtk.gdk.display_get_default()
+ display = Gdk.Display()
screen_, x, y, modifiers_ = display.get_pointer()
else:
x, y = pos
@@ -148,9 +150,10 @@ class View(gtk.EventBox):
if not status:
status = self.status
else:
- if not self.flags() & gtk.MAPPED:
- self._peding = status
- return
+ # FIXME: view object has no attribute flags
+ #if not self.flags() & Gtk.MAPPED:
+ # self._peding = status
+ # return
self.status = status
if self._eyes:
@@ -164,7 +167,7 @@ class View(gtk.EventBox):
for i in status.eyes:
eye = i(self.fill_color)
self._eyes.append(eye)
- self._eyebox.pack_start(eye, padding=FACE_PAD)
+ self._eyebox.pack_start(eye, FACE_PAD, False, 0)
eye.show()
self._mouth = status.mouth(self._audio, self.fill_color)
diff --git a/mouth.py b/mouth.py
index 631189f..2b517bd 100644
--- a/mouth.py
+++ b/mouth.py
@@ -32,8 +32,8 @@ import numpy.core
class Mouth(Gtk.DrawingArea):
def __init__(self, audioSource, fill_color):
- GObject.GObject.__init__(self)
- self.connect("expose_event", self.expose)
+ Gtk.DrawingArea.__init__(self)
+
self.buffers = []
self.buffer_size = 256
self.main_buffers = []
@@ -63,7 +63,7 @@ class Mouth(Gtk.DrawingArea):
self.volume = numpy.core.max(self.main_buffers) # -\
# numpy.core.min(self.main_buffers)
- def expose(self, widget, event):
+ def do_draw(self, context):
"""This function is the "expose" event
handler and does all the drawing."""
bounds = self.get_allocation()
@@ -71,15 +71,15 @@ class Mouth(Gtk.DrawingArea):
self.processBuffer(bounds)
#Create context, disable antialiasing
- self.context = widget.window.cairo_create()
+ self.context = context
self.context.set_antialias(cairo.ANTIALIAS_NONE)
# set a clip region for the expose event.
# This reduces redrawing work (and time)
- self.context.rectangle(event.area.x,
- event.area.y,
- event.area.width,
- event.area.height)
+ self.context.rectangle(bounds.x,
+ bounds.y,
+ bounds.width,
+ bounds.height)
self.context.clip()
# background
diff --git a/roundbox.py b/roundbox.py
index 0fb7307..c34a7db 100644
--- a/roundbox.py
+++ b/roundbox.py
@@ -1,15 +1,16 @@
import math
from gi.repository import Gtk
+from gi.repository import GObject
from sugar3.graphics import style
-class RoundBox(Gtk.HBox):
+class RoundBox(Gtk.Box):
__gtype_name__ = 'RoundBox'
_BORDER_DEFAULT = style.LINE_WIDTH
- def __init__(self, **kwargs):
- GObject.GObject.__init__(self, **kwargs)
+ def __init__(self):
+ Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
self._x = None
self._y = None
@@ -20,8 +21,7 @@ class RoundBox(Gtk.HBox):
self.border_color = style.COLOR_BLACK
self.background_color = None
self.set_reallocate_redraws(True)
- self.set_resize_mode(Gtk.RESIZE_PARENT)
- self.connect("expose_event", self.__expose_cb)
+ self.set_resize_mode(Gtk.ResizeMode.PARENT)
self.connect("add", self.__add_cb)
def __add_cb(self, child, params):
@@ -33,12 +33,11 @@ class RoundBox(Gtk.HBox):
self._width = allocation.width
self._height = allocation.height
- def __expose_cb(self, widget, event):
- context = widget.window.cairo_create()
-
+ def do_draw(self, context):
+ rect = self.get_allocation()
# set a clip region for the expose event
- context.rectangle(event.area.x, event.area.y,
- event.area.width, event.area.height)
+ context.rectangle(rect.x, rect.y,
+ rect.width, rect.height)
context.clip()
self.draw(context)
return False
@@ -81,13 +80,13 @@ if __name__ == '__main__':
box1 = RoundBox()
vbox.add(box1)
- label1 = Gtk.Label(label="Test 1")
+ label1 = Gtk.Label("Test 1")
box1.add(label1)
rbox = RoundBox()
rbox.background_color = style.Color('#FF0000')
vbox.add(rbox)
- label2 = Gtk.Label(label="Test 2")
+ label2 = Gtk.Label("Test 2")
rbox.add(label2)
bbox = RoundBox()
diff --git a/shared_activity.py b/shared_activity.py
index c372d7b..ed3a502 100644
--- a/shared_activity.py
+++ b/shared_activity.py
@@ -48,6 +48,8 @@ class SharedActivity(activity.Activity):
self.connect('shared', self._shared_cb)
+ # FIXME: object has no attribute '_shared_activity
+ self._shared_activity = False
# Owner.props.key
if self._shared_activity:
# We are joining the activity
diff --git a/toolitem.py b/toolitem.py
index 5a6cf38..accc86c 100644
--- a/toolitem.py
+++ b/toolitem.py
@@ -31,7 +31,7 @@ class ToolWidget(Gtk.ToolItem):
self._label_text = None
self._box = Gtk.HBox(False, style.DEFAULT_SPACING)
- GObject.GObject.__init__(self, **kwargs)
+ Gtk.ToolItem.__init__(self)
self.props.border_width = style.DEFAULT_PADDING
self._box.show()
@@ -57,7 +57,7 @@ class ToolWidget(Gtk.ToolItem):
if self._label is not None:
self._box.remove(self._label)
self._label = label
- self._box.pack_start(label, False)
+ self._box.pack_start(label, False, False, 0)
self._box.reorder_child(label, 0)
label.show()
self.set_label_text(self._label_text)