Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvaDobreva <iva95dobreva@gmail.com>2013-01-13 18:24:10 (GMT)
committer IvaDobreva <iva95dobreva@gmail.com>2013-01-13 18:24:10 (GMT)
commitca21feee3193e89105a17ec2307aa5eaab26a9a2 (patch)
tree9e907a40d3f0bdd9d6a3ead7ffce13cd2eb2e37b
parent02877f563ed180f17496a6a83b5f4295a757f601 (diff)
GObject
-rw-r--r--activity.py8
-rw-r--r--chat.py1
-rw-r--r--chat.py~1
-rw-r--r--chatbox.py1
-rw-r--r--chatbox.py~1
-rw-r--r--eye.py1
-rw-r--r--eye.py~2
-rw-r--r--face.py1
-rw-r--r--mouth.py1
-rw-r--r--mouth.py~102
-rw-r--r--toolkit/scrolledbox.py1
-rw-r--r--toolkit/scrolledbox.py~1
-rw-r--r--toolkit/temposlider.py1
-rw-r--r--toolkit/temposlider.py~1
14 files changed, 118 insertions, 5 deletions
diff --git a/activity.py b/activity.py
index d50f303..8f4654d 100644
--- a/activity.py
+++ b/activity.py
@@ -74,13 +74,13 @@ class SpeakActivity(SharedActivity):
self.connect("notify::active", self._activeCb)
# make a box to type into
- self.entrycombo = Gtk.combo_box_entry_new()
+ 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)
+ # self.entry.set_editable(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()
diff --git a/chat.py b/chat.py
index b769690..d498fcd 100644
--- a/chat.py
+++ b/chat.py
@@ -16,6 +16,7 @@
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import GObject
from gi.repository import Pango
import logging
diff --git a/chat.py~ b/chat.py~
index 173448e..b769690 100644
--- a/chat.py~
+++ b/chat.py~
@@ -15,6 +15,7 @@
# 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 Pango
import logging
diff --git a/chatbox.py b/chatbox.py
index 2592d15..d9a7ad6 100644
--- a/chatbox.py
+++ b/chatbox.py
@@ -18,6 +18,7 @@
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import GObject
import logging
from gi.repository import Pango
import re
diff --git a/chatbox.py~ b/chatbox.py~
index d2048cd..2592d15 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
diff --git a/eye.py b/eye.py
index 7e61ce9..ad0a69a 100644
--- a/eye.py
+++ b/eye.py
@@ -23,6 +23,7 @@
import gi
from gi.repository import Gtk
+from gi.repository import GObject
from gi.repository import Gdk
import math
diff --git a/eye.py~ b/eye.py~
index de91565..7e61ce9 100644
--- a/eye.py~
+++ b/eye.py~
@@ -23,7 +23,7 @@
import gi
from gi.repository import Gtk
-import Gdk
+from gi.repository import Gdk
import math
diff --git a/face.py b/face.py
index 9eec72f..17cc53b 100644
--- a/face.py
+++ b/face.py
@@ -25,6 +25,7 @@
import logging
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import GObject
import json
import sugar3.graphics.style as style
diff --git a/mouth.py b/mouth.py
index f101249..93b14c5 100644
--- a/mouth.py
+++ b/mouth.py
@@ -24,6 +24,7 @@
# This code is a super-stripped down version of the waveform view from Measure
from gi.repository import Gtk
+from gi.repository import GObject
import cairo
from struct import unpack
import numpy.core
diff --git a/mouth.py~ b/mouth.py~
new file mode 100644
index 0000000..f101249
--- /dev/null
+++ b/mouth.py~
@@ -0,0 +1,102 @@
+# Speak.activity
+# A simple front end to the espeak text-to-speech engine on the XO laptop
+# http://wiki.laptop.org/go/Speak
+#
+# Copyright (C) 2008 Joshua Minor
+# This file is part of Speak.activity
+#
+# Parts of Speak.activity are based on code from Measure.activity
+# Copyright (C) 2007 Arjun Sarwal - arjun@laptop.org
+#
+# Speak.activity is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Speak.activity is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Speak.activity. If not, see <http://www.gnu.org/licenses/>.
+
+# This code is a super-stripped down version of the waveform view from Measure
+
+from gi.repository import Gtk
+import cairo
+from struct import unpack
+import numpy.core
+
+
+class Mouth(Gtk.DrawingArea):
+ def __init__(self, audioSource, fill_color):
+
+ GObject.GObject.__init__(self)
+ self.connect("expose_event", self.expose)
+ self.buffers = []
+ self.buffer_size = 256
+ self.main_buffers = []
+ self.newest_buffer = []
+ self.fill_color = fill_color
+
+ audioSource.connect("new-buffer", self._new_buffer)
+
+ def _new_buffer(self, obj, buf):
+ if len(buf) < 28:
+ self.newest_buffer = []
+ else:
+ self.newest_buffer = list(unpack(str(int(len(buf)) / 2) + 'h', buf))
+ self.main_buffers += self.newest_buffer
+ if(len(self.main_buffers) > self.buffer_size):
+ del self.main_buffers[0:(len(self.main_buffers) - \
+ self.buffer_size)]
+
+ self.queue_draw()
+ return True
+
+ def processBuffer(self, bounds):
+ if len(self.main_buffers) == 0 or len(self.newest_buffer) == 0:
+ self.volume = 0
+ else:
+ self.volume = numpy.core.max(self.main_buffers) # - numpy.core.min(self.main_buffers)
+
+ def expose(self, widget, event):
+ """This function is the "expose" event handler and does all the drawing."""
+ bounds = self.get_allocation()
+
+ self.processBuffer(bounds)
+
+ #Create context, disable antialiasing
+ self.context = widget.window.cairo_create()
+ 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.clip()
+
+ # background
+ self.context.set_source_rgba(*self.fill_color.get_rgba())
+ self.context.rectangle(0, 0, bounds.width, bounds.height)
+ self.context.fill()
+
+ # Draw the mouth
+ volume = self.volume / 30000.
+ mouthH = volume * bounds.height
+ mouthW = volume**2 * (bounds.width / 2.) + bounds.width / 2.
+ # T
+ # L R
+ # B
+ Lx, Ly = bounds.width / 2 - mouthW / 2, bounds.height / 2
+ Tx, Ty = bounds.width / 2, bounds.height / 2 - mouthH / 2
+ Rx, Ry = bounds.width / 2 + mouthW / 2, bounds.height / 2
+ Bx, By = bounds.width / 2, bounds.height / 2 + mouthH / 2
+ self.context.set_line_width(min(bounds.height / 10.0, 10))
+ self.context.move_to(Lx, Ly)
+ self.context.curve_to(Tx, Ty, Tx, Ty, Rx, Ry)
+ self.context.curve_to(Bx, By, Bx, By, Lx, Ly)
+ self.context.set_source_rgb(0, 0, 0)
+ self.context.close_path()
+ self.context.stroke()
+
+ return True
diff --git a/toolkit/scrolledbox.py b/toolkit/scrolledbox.py
index 5cf5873..54cb3ea 100644
--- a/toolkit/scrolledbox.py
+++ b/toolkit/scrolledbox.py
@@ -15,6 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gi.repository import Gtk
+from gi.repository import GObject
from gi.repository import Gdk
from sugar3.graphics.icon import Icon
diff --git a/toolkit/scrolledbox.py~ b/toolkit/scrolledbox.py~
index bc8ecdf..5cf5873 100644
--- a/toolkit/scrolledbox.py~
+++ b/toolkit/scrolledbox.py~
@@ -15,6 +15,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gi.repository import Gtk
+from gi.repository import Gdk
from sugar3.graphics.icon import Icon
diff --git a/toolkit/temposlider.py b/toolkit/temposlider.py
index 726b540..4bd6d88 100644
--- a/toolkit/temposlider.py
+++ b/toolkit/temposlider.py
@@ -17,6 +17,7 @@
# Widget was copy&pasted from TamTam activities
from gi.repository import Gtk
+from gi.repository import GObject
from gi.repository import Gdk
import rsvg
import cairo
diff --git a/toolkit/temposlider.py~ b/toolkit/temposlider.py~
index 863307d..726b540 100644
--- a/toolkit/temposlider.py~
+++ b/toolkit/temposlider.py~
@@ -17,6 +17,7 @@
# Widget was copy&pasted from TamTam activities
from gi.repository import Gtk
+from gi.repository import Gdk
import rsvg
import cairo