Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-11-02 02:31:36 (GMT)
committer flavio <fdanesse@gmail.com>2012-11-02 02:31:36 (GMT)
commit2e578e86d69f2ec90352497af5e51c49b6b44239 (patch)
tree647f7ef048d62c3cc14133b7d6099e96b6530f68
parent95a6594ee5eb844ff5c87025a5e7c8ec0f0c8af7 (diff)
corrections
-rwxr-xr-xactivity.py10
-rw-r--r--montage.py52
-rw-r--r--toolkit/activity.py15
-rw-r--r--toolkit/pixbuf.py4
-rw-r--r--toolkit/temposlider.py34
-rw-r--r--utils.py8
6 files changed, 71 insertions, 52 deletions
diff --git a/activity.py b/activity.py
index 9b35c2a..9d2c8af 100755
--- a/activity.py
+++ b/activity.py
@@ -22,12 +22,14 @@ logger = logging.getLogger('cartoon-builder')
from sugar3.graphics.toolbutton import ToolButton
from sugar3.graphics.toggletoolbutton import ToggleToolButton
+from sugar3.activity.widgets import ActivityToolbarButton
+from sugar3.activity.widgets import StopButton
#from sugar3.activity.activity import ActivityToolbox
from toolkit.temposlider import TempoSlider
from toolkit.activity import SharedActivity
from toolkit.toolbarbox import ToolbarBox
-from toolkit.activity_widgets import *
+#from toolkit.activity_widgets import * # ActivityToolbarButton
import montage
import lessons
@@ -37,7 +39,7 @@ import ground
import sound
import theme
from messenger import Messenger, SERVICE
-from utils import *
+#from utils import ComboBox
class CartoonBuilderActivity(SharedActivity):
@@ -92,7 +94,7 @@ class CartoonBuilderActivity(SharedActivity):
toolbox.show_all()
self.toolbar_box = toolbox
-
+
def new_instance(self):
logger.debug('new_instance')
self.montage.restore()
@@ -157,7 +159,7 @@ class CartoonBuilderActivity(SharedActivity):
self.montage.props.frame = (i, None)
def __tempo_cb(self, widget):
- self.montage.set_tempo(widget.value)
+ self.montage.set_tempo(widget.get_value())
def __play_cb(self, widget, playButtonImg, pauseButtonImg):
diff --git a/montage.py b/montage.py
index b8e248f..426929e 100644
--- a/montage.py
+++ b/montage.py
@@ -33,7 +33,7 @@ import ground
import sound
from document import Document, clean
from screenbuil import Screen
-from utils import *
+from utils import ComboBox
logger = logging.getLogger('cartoon-builder')
@@ -179,12 +179,12 @@ class View(Gtk.EventBox):
#table_scroll = VScrolledBox()
table_scroll = Gtk.ScrolledWindow()
table_scroll.add_with_viewport(self.table)
- table_scroll.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BUTTON_BACKGROUND))
+ table_scroll.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BUTTON_BACKGROUND'))
yellow_frames = Gtk.EventBox()
- yellow_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(YELLOW))
+ yellow_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('YELLOW'))
table_frames = Gtk.EventBox()
- table_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND))
+ table_frames.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BACKGROUND'))
table_frames.set_border_width(5)
table_frames.add(table_scroll)
yellow_frames.add(table_frames)
@@ -200,7 +200,7 @@ class View(Gtk.EventBox):
# screen
screen_pink = Gtk.EventBox()
- screen_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(PINK))
+ screen_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('PINK'))
screen_box = Gtk.EventBox()
screen_box.set_border_width(5)
screen_box.add(self._screen)
@@ -211,11 +211,11 @@ class View(Gtk.EventBox):
tape = Gtk.HBox()
- for i in range(TAPE_COUNT):
+ for i in range(theme.TAPE_COUNT):
frame_box = Gtk.VBox()
filmstrip_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
- theme.path('icons', 'filmstrip.png'), THUMB_SIZE, -1, False)
+ theme.path('icons', 'filmstrip.png'), theme.THUMB_SIZE, -1, False)
filmstrip = Gtk.Image()
filmstrip.set_from_pixbuf(filmstrip_pixbuf);
@@ -224,8 +224,8 @@ class View(Gtk.EventBox):
frame = Gtk.EventBox()
frame.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
frame.connect('button_press_event', self._tape_cb, i)
- frame.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BLACK))
- frame.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse(BLACK))
+ frame.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BLACK'))
+ frame.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse('BLACK'))
frame.props.border_width = 2
frame.set_size_request(theme.THUMB_SIZE, theme.THUMB_SIZE)
frame_box.pack_start(frame, True, True, 0)
@@ -261,7 +261,7 @@ class View(Gtk.EventBox):
screen_alignment.add(screen_pink)
box = Gtk.EventBox()
- box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND))
+ box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BACKGROUND'))
box.connect('size-allocate', self._screen_size_cb, screen_pink)
box.add(screen_alignment)
@@ -278,9 +278,9 @@ class View(Gtk.EventBox):
arrow = Gtk.Image()
arrow.set_from_file(theme.path('icons', 'pink_arrow.png'))
tape_pink = Gtk.EventBox()
- tape_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(PINK))
+ tape_pink.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('PINK'))
tape_bg = Gtk.EventBox()
- tape_bg.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND))
+ tape_bg.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BACKGROUND'))
tape_bg.set_border_width(5)
tape_bg.add(tape)
tape_pink.add(tape_bg)
@@ -298,11 +298,11 @@ class View(Gtk.EventBox):
desktop.pack_start(tape_box, False, False, 0)
greenbox = Gtk.EventBox()
- greenbox.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BACKGROUND))
+ greenbox.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BACKGROUND'))
greenbox.set_border_width(5)
greenbox.add(desktop)
- self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(YELLOW))
+ self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('YELLOW'))
self.add(greenbox)
self.show_all()
@@ -331,8 +331,9 @@ class View(Gtk.EventBox):
for i in range(theme.TAPE_COUNT):
self._play_tape_num += 1
- if self._play_tape_num == TAPE_COUNT:
+ if self._play_tape_num == theme.TAPE_COUNT:
self._play_tape_num = 0
+
if Document.tape[self._play_tape_num].empty():
continue
return True
@@ -352,8 +353,8 @@ class View(Gtk.EventBox):
image_box = Gtk.EventBox()
image_box.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
image_box.connect('button_press_event', self._frame_cb, index)
- image_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(BLACK))
- image_box.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse(BLACK))
+ image_box.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BLACK'))
+ image_box.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse('BLACK'))
image_box.props.border_width = 2
image_box.set_size_request(theme.THUMB_SIZE, theme.THUMB_SIZE)
image_box.add(image)
@@ -371,25 +372,27 @@ class View(Gtk.EventBox):
return
tape = self._tape[index]
- tape.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(YELLOW))
- tape.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse(YELLOW))
+ tape.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('YELLOW'))
+ tape.modify_bg(Gtk.StateType.PRELIGHT, Gdk.color_parse('YELLOW'))
if self._tape_selected != index:
if self._tape_selected != -1:
old_tape = self._tape[self._tape_selected]
old_tape.modify_bg(Gtk.StateType.NORMAL,
- Gdk.color_parse(BLACK))
+ Gdk.color_parse('BLACK'))
old_tape.modify_bg(Gtk.StateType.PRELIGHT,
- Gdk.color_parse(BLACK))
+ Gdk.color_parse('BLACK'))
self._tape_selected = index
self._screen.fgpixbuf = Document.tape[index].orig()
self._screen.draw()
def _frame_cb(self, widget, event, i):
+
if event.button == 3:
self._char.clean(i)
self._frames[i].set_from_pixbuf(self._char.frames[i].thumb())
+
else:
if i < len(self._char.frames):
frame = self._char.frames[i]
@@ -400,11 +403,14 @@ class View(Gtk.EventBox):
self.set_frame((self._tape_selected, None))
def _char_cb(self, widget, closure):
+
self._char = widget.props.value
+
for i in range(len(self._frames)):
if i < len(self._char.frames):
self._frames[i].set_from_pixbuf(self._char.frames[i].thumb())
self._frames[i].parent.show()
+
else:
self._frames[i].parent.hide()
@@ -417,8 +423,8 @@ class View(Gtk.EventBox):
if id(choice) != id(widget.props.value):
widget.append_item(choice, text=choice.name,
- size=(theme.THUMB_SIZE, theme.THUMB_SIZE),
- pixbuf=choice.thumb())
+ size=(theme.THUMB_SIZE, theme.THUMB_SIZE),
+ pixbuf=choice.thumb())
widget.set_active(len(widget.get_model()) - 1)
self._prev_combo_selected[widget] = widget.get_active()
diff --git a/toolkit/activity.py b/toolkit/activity.py
index 49e0884..fef5cd8 100644
--- a/toolkit/activity.py
+++ b/toolkit/activity.py
@@ -79,7 +79,7 @@ class Activity(activity.Activity):
Subclass should implement this method to save activity data.
"""
raise NotImplementedError
-
+
def on_save_instance(self, cb, *args):
""" Register callback which will be invoked before save_instance """
self.__on_save_instance.append((cb, args))
@@ -191,9 +191,9 @@ class Activity(activity.Activity):
# XXX do it after(possible) read_file() invoking
# have to rely on calling read_file() from map_cb in sugar-toolkit
- canvas.connect_after('map', self.__map_canvasactivity_cb)
+ #canvas.connect_after('map', self.__map_canvasactivity_cb)
self.set_canvas(canvas)
-
+
def __instance(self):
logging.debug('Activity.__instance')
@@ -224,11 +224,12 @@ class Activity(activity.Activity):
def write_file(self, filepath):
"""Subclass should not override this method"""
-
- for cb, args in self.__on_save_instance:
- cb(*args)
+ # FIXME: ERROR root: Error saving activity object to datastore
+ #for cb, args in self.__on_save_instance:
+ # cb(*args)
- self.save_instance(filepath)
+ #self.save_instance(filepath)
+ pass
def __map_canvasactivity_cb(self, widget):
diff --git a/toolkit/pixbuf.py b/toolkit/pixbuf.py
index bb01b9a..c9b9a78 100644
--- a/toolkit/pixbuf.py
+++ b/toolkit/pixbuf.py
@@ -18,13 +18,13 @@
import re
import cStringIO
-import rsvg
import cairo
import logging
import gi
from gi.repository import Gtk
from gi.repository import GdkPixbuf
+from gi.repository import Rsvg
from sugar3.graphics import style
from sugar3.graphics.xocolor import XoColor, is_valid
@@ -89,7 +89,7 @@ def from_svg_at_size(filename=None, width=None, height=None, handle=None,
"""Scale and load SVG into pixbuf"""
if not handle:
- handle = rsvg.Handle(filename)
+ handle = Rsvg.Handle(filename)
dimensions = handle.get_dimension_data()
icon_width = dimensions[0]
diff --git a/toolkit/temposlider.py b/toolkit/temposlider.py
index d8e633d..d2bf3ad 100644
--- a/toolkit/temposlider.py
+++ b/toolkit/temposlider.py
@@ -17,8 +17,8 @@
import gi
from gi.repository import Gtk
from gi.repository import GdkPixbuf
+from gi.repository import Rsvg
-import rsvg
import cairo
from sugar3.graphics import style
@@ -48,8 +48,8 @@ class TempoSlider(Gtk.HBox):
slider.connect("button-press-event", self._press_cb)
slider.connect("button-release-event", self._release_cb)
- self.pack_start(slider, True, True)
- self.pack_end(self._image, False, False)
+ self.pack_start(slider, True, True, 0)
+ self.pack_end(self._image, False, False, 0)
def set_value(self, tempo, quiet = False):
@@ -75,16 +75,17 @@ class TempoSlider(Gtk.HBox):
return oupper
return olower + int((oupper-olower+1) * (value-ilower) /
- float(iupper-ilower))
+ float(iupper-ilower))
- img = map_range(tempo, self.adjustment.lower,
- self.adjustment.upper, 0, 7)
+ img = map_range(tempo, self.adjustment.get_lower(),
+ self.adjustment.get_upper(), 0, 7)
if not self._pixbuf[img]:
- svg = rsvg.Handle(data=IMAGE[img])
+ svg = Rsvg.Handle()
+ svg.new_from_data(IMAGE[img])
self._pixbuf[img] = _from_svg_at_size(handle=svg,
- width=style.STANDARD_ICON_SIZE,
- height=style.STANDARD_ICON_SIZE)
+ width=style.STANDARD_ICON_SIZE,
+ height=style.STANDARD_ICON_SIZE)
self._image.set_from_pixbuf(self._pixbuf[img])
@@ -103,13 +104,16 @@ def _from_svg_at_size(filename=None, width=None, height=None, handle=None,
""" import from pixbuf.py """
if not handle:
- handle = rsvg.Handle(filename)
+ svg = Rsvg.Handle()
+ svg.new_from_file(IMAGE[img])
- dimensions = handle.get_dimension_data()
- icon_width = dimensions[0]
- icon_height = dimensions[1]
-
- if icon_width != width or icon_height != height:
+ dimensions = handle.get_dimensions()
+ icon_width = dimensions.height
+ icon_height = dimensions.width
+
+ if (icon_width != width or icon_height != height) and \
+ icon_width != 0 and icon_height != 0:
+
ratio_width = float(width) / icon_width
ratio_height = float(height) / icon_height
diff --git a/utils.py b/utils.py
index 5fa965e..0eb2b95 100644
--- a/utils.py
+++ b/utils.py
@@ -26,7 +26,9 @@ from theme import *
class ComboBox(_ComboBox):
+
def __init__(self):
+
_ComboBox.__init__(self)
self.set_name('we-really-need-it-to-use-custom-combobox-colors')
@@ -48,8 +50,9 @@ class ComboBox(_ComboBox):
self.add_attribute(self._icon_renderer, 'pixbuf', 2)
if not self._text_renderer and text:
+
self._text_renderer = Gtk.CellRendererText()
- # FIXME: Re escribir
+ # FIXME: Re write
#self._text_renderer.props.ellipsize = Pango.ELLIPSIZE_END
self.pack_end(self._text_renderer, True)
self.add_attribute(self._text_renderer, 'text', 1)
@@ -59,14 +62,17 @@ class ComboBox(_ComboBox):
if not size:
size = Gtk.IconSize.LARGE_TOOLBAR
width, height = Gtk.icon_size_lookup(size)
+
else:
width, height = size
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_name,
width, height)
+
else:
pixbuf = None
if position:
self._model.insert(position, [action_id, text, pixbuf, False])
+
else:
self._model.append([action_id, text, pixbuf, False])