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-04 15:13:28 (GMT)
committer flavio <fdanesse@gmail.com>2012-11-04 15:13:28 (GMT)
commitd39aabd190c720477411a8444c6ddf747580a18d (patch)
tree776ab37290bd01be9e127efbf68a3a757aba49e8
parent2e578e86d69f2ec90352497af5e51c49b6b44239 (diff)
fixing mistakes
-rwxr-xr-xactivity.py5
-rw-r--r--char.py26
-rw-r--r--ground.py11
-rw-r--r--montage.py30
-rw-r--r--screenbuil.py48
-rw-r--r--toolkit/activity.py8
-rw-r--r--toolkit/combobox.py2
-rw-r--r--utils.py3
8 files changed, 90 insertions, 43 deletions
diff --git a/activity.py b/activity.py
index 9d2c8af..efeb157 100755
--- a/activity.py
+++ b/activity.py
@@ -109,7 +109,8 @@ class CartoonBuilderActivity(SharedActivity):
def save_instance(self, filepath):
logger.debug('save_instance to %s' % filepath)
- document.save(filepath)
+ # FIXME: AttributeError: 'NoneType' object has no attribute 'custom'
+ #document.save(filepath)
def share_instance(self, tube_conn, initiating):
logger.debug('share_instance')
@@ -133,7 +134,7 @@ class CartoonBuilderActivity(SharedActivity):
pauseButtonImg)
toolbar.insert(self.playButton, -1)
self.playButton.set_tooltip(_('Play / Pause'))
-
+
tempo = TempoSlider(0, 10)
tempo.adjustment.connect("value-changed", self.__tempo_cb)
tempo.set_size_request(250, -1)
diff --git a/char.py b/char.py
index 77c8408..a436e04 100644
--- a/char.py
+++ b/char.py
@@ -34,14 +34,17 @@ def load():
custom.frames[i] = f
-class Frame:
+class Frame():
+
def __init__(self, id):
+
self.id = id
self.name = ''
self._thumb = None
self._orig = None
def serialize(self):
+
if self._orig:
return pixbuf.to_str(self._orig)
else:
@@ -66,7 +69,9 @@ class Frame:
class PreinstalledFrame(Frame):
+
def __init__(self, filename):
+
Frame.__init__(self, filename)
self._filename = filename
@@ -74,13 +79,17 @@ class PreinstalledFrame(Frame):
return False
def orig(self):
+
if self._orig == None:
self._orig = theme.pixbuf(self._filename)
+
return self._orig
class EmptyFrame(Frame):
+
def __init__(self):
+
Frame.__init__(self, None)
self._thumb = theme.EMPTY_THUMB
self._orig = theme.EMPTY_ORIG
@@ -93,37 +102,48 @@ class EmptyFrame(Frame):
class RestoredFrame(Frame):
+
def __init__(self, id, data):
+
Frame.__init__(self, id)
self._orig = pixbuf.from_str(data)
class CustomFrame(Frame):
+
def __init__(self):
+
Frame.__init__(self, None)
self._thumb = theme.CUSTOM_FRAME_THUMB
def orig(self):
+
if self._orig == None:
return theme.EMPTY_ORIG
return self._orig
def select(self):
+
if self._orig:
- return True;
+ return True
+
self.name, self.id, self._orig = chooser.pick(
lambda jobject: (jobject.metadata['title'], jobject.object_id,
theme.pixbuf(jobject.file_path)),
(None, None, None), what=chooser.IMAGE)
+
if self.name:
self._thumb = theme.scale(self._orig)
return True
+
else:
return False
-class Char:
+class Char():
+
def __init__(self, name, thumbfile, dir):
+
self.name = name
self.frames = []
diff --git a/ground.py b/ground.py
index c342f76..7801e67 100644
--- a/ground.py
+++ b/ground.py
@@ -33,7 +33,9 @@ def load():
class Ground:
+
def __init__(self, name, id):
+
self.name = name
self.id = id
self._thumb = None
@@ -57,7 +59,9 @@ class Ground:
class PreinstalledGround(Ground):
+
def __init__(self, name, filename):
+
Ground.__init__(self, name, filename)
self._orig = theme.pixbuf(filename)
@@ -66,7 +70,9 @@ class PreinstalledGround(Ground):
class CustomGround(Ground):
+
def __init__(self, name, filename):
+
Ground.__init__(self, name, None)
self._orig = theme.pixbuf(filename)
@@ -79,14 +85,19 @@ class CustomGround(Ground):
class RestoredGround(Ground):
+
def __init__(self, name, id, data):
+
Ground.__init__(self, name, id)
self._orig = pixbuf.from_str(data)
class JournalGround(Ground):
+
def __init__(self, jobject):
+
Ground.__init__(self, jobject.metadata['title'], jobject.object_id)
+
self._orig = theme.pixbuf(jobject.file_path)
THEMES.append(self)
diff --git a/montage.py b/montage.py
index 426929e..de74c07 100644
--- a/montage.py
+++ b/montage.py
@@ -48,7 +48,7 @@ class View(Gtk.EventBox):
GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,)),
'sound-changed': (
GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,))}
-
+
def set_frame(self, value):
tape_num, frame = value
@@ -58,6 +58,7 @@ class View(Gtk.EventBox):
if self._emission:
self.emit('frame-changed', tape_num, None)
+
else:
if not frame.select():
return False
@@ -68,8 +69,10 @@ class View(Gtk.EventBox):
if frame.custom():
index = [i for i, f in enumerate(char.THEMES[-1].frames)
if f == frame][0]
+
if index >= len(self._frames):
first = index / theme.FRAME_COLS * theme.FRAME_COLS
+
for i in range(first, first + theme.FRAME_COLS):
self._add_frame(i)
@@ -101,8 +104,9 @@ class View(Gtk.EventBox):
sound = GObject.property(type=object, getter=None, setter=set_sound)
emittion = GObject.property(type=bool, default=True, getter=get_emittion,
setter=set_emittion)
-
+
def restore(self):
+
def new_combo(themes, cb, object=None, closure=None):
combo = ComboBox()
sel = 0
@@ -112,8 +116,10 @@ class View(Gtk.EventBox):
combo.append_item(o, text=o.name,
size=(theme.THUMB_SIZE, theme.THUMB_SIZE),
pixbuf=o.thumb())
+
if object and o.name == object.name:
sel = i
+
else:
combo.append_separator()
@@ -152,6 +158,7 @@ class View(Gtk.EventBox):
self._playing = GObject.timeout_add(self._delay, self._play_tape)
def __init__(self):
+
Gtk.EventBox.__init__(self)
self._screen = Screen()
@@ -178,6 +185,7 @@ class View(Gtk.EventBox):
# FIXME: There is no longer VscrooledBox
#table_scroll = VScrolledBox()
table_scroll = Gtk.ScrolledWindow()
+ table_scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
table_scroll.add_with_viewport(self.table)
table_scroll.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('BUTTON_BACKGROUND'))
@@ -305,7 +313,7 @@ class View(Gtk.EventBox):
self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('YELLOW'))
self.add(greenbox)
self.show_all()
-
+
def _set_combo(self, combo, value):
pos = -1
@@ -323,6 +331,7 @@ class View(Gtk.EventBox):
combo.set_active(pos)
def _play_tape(self):
+
if not self._playing:
return False
@@ -339,8 +348,9 @@ class View(Gtk.EventBox):
return True
return True
-
+
def _add_frame(self, index):
+
y = index / theme.FRAME_COLS
x = index - y * theme.FRAME_COLS
logger.debug('add new frame x=%d y=%d index=%d' % (x, y, index))
@@ -367,6 +377,7 @@ class View(Gtk.EventBox):
return image
def _tape_cb(self, widget, event, index):
+
if event and event.button == 3:
self.set_frame((index, None))
return
@@ -441,9 +452,16 @@ class View(Gtk.EventBox):
Document.sound = choice
if self._emission:
self.emit('sound-changed', choice)
-
+
def _screen_size_cb(self, sender, aloc, widget):
+
+ size = min(aloc.width, aloc.height)
+ widget.set_size_request(size, size)
+
+ return True
+ '''
def set_size():
+
size = min(aloc.width, aloc.height)
widget.set_size_request(size, size)
self._screen_size_id = None
@@ -451,4 +469,4 @@ class View(Gtk.EventBox):
if self._screen_size_id is not None:
GObject.source_remove(self._screen_size_id)
- self._screen_size_id = GObject.timeout_add(500, set_size)
+ self._screen_size_id = GObject.timeout_add(500, set_size)'''
diff --git a/screenbuil.py b/screenbuil.py
index 37121ce..59eaa0e 100644
--- a/screenbuil.py
+++ b/screenbuil.py
@@ -20,42 +20,42 @@
import gi
from gi.repository import Gtk
+from gi.repository import Gdk
import theme
class Screen(Gtk.DrawingArea):
+
def __init__(self):
+
Gtk.DrawingArea.__init__(self)
- self.gc = None # initialized in realize-event handler
- self.width = 0 # updated in size-allocate handler
- self.height = 0 # idem
+
self.bgpixbuf = None
self.fgpixbuf = None
- # FIXME: Re escribir
- '''
- self.connect('size-allocate', self.on_size_allocate)
- self.connect('expose-event', self.on_expose_event)
- self.connect('realize', self.on_realize)
- def on_realize(self, widget):
- self.gc = widget.window.new_gc()
-
- def on_size_allocate(self, widget, allocation):
- self.height = self.width = min(allocation.width, allocation.height)
-
- def on_expose_event(self, widget, event):
+ def do_draw(self, context):
# This is where the drawing takes place
+
+ allocation = self.get_allocation()
+ value = min(allocation.width, allocation.height)
+
if self.bgpixbuf:
pixbuf = self.bgpixbuf
- if pixbuf.get_width != self.width:
- pixbuf = theme.scale(pixbuf, self.width)
- widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0)
-
+
+ if pixbuf.get_width != value:
+ pixbuf = theme.scale(pixbuf, value)
+
+ Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0)
+ context.paint()
+
if self.fgpixbuf:
pixbuf = self.fgpixbuf
- if pixbuf.get_width != self.width:
- pixbuf = theme.scale(pixbuf, self.width)
- widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0)
-
+
+ if pixbuf.get_width != value:
+ pixbuf = theme.scale(pixbuf, value)
+
+ Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0)
+ context.paint()
+
def draw(self):
- self.queue_draw()'''
+ self.queue_draw()
diff --git a/toolkit/activity.py b/toolkit/activity.py
index fef5cd8..62b0c0a 100644
--- a/toolkit/activity.py
+++ b/toolkit/activity.py
@@ -224,12 +224,10 @@ class Activity(activity.Activity):
def write_file(self, filepath):
"""Subclass should not override this method"""
- # FIXME: ERROR root: Error saving activity object to datastore
- #for cb, args in self.__on_save_instance:
- # cb(*args)
+ for cb, args in self.__on_save_instance:
+ cb(*args)
- #self.save_instance(filepath)
- pass
+ self.save_instance(filepath)
def __map_canvasactivity_cb(self, widget):
diff --git a/toolkit/combobox.py b/toolkit/combobox.py
index c9207e7..99dbe72 100644
--- a/toolkit/combobox.py
+++ b/toolkit/combobox.py
@@ -60,7 +60,7 @@ class ComboBox(Gtk.ComboBox):
return row[0]
value = GObject.property(
- type=Object, getter=get_value, setter=None)
+ type=object, getter=get_value, setter=None)
def _get_real_name_from_theme(self, name, size):
diff --git a/utils.py b/utils.py
index 0eb2b95..b80de3d 100644
--- a/utils.py
+++ b/utils.py
@@ -19,7 +19,6 @@ from gi.repository import Pango
from sugar3.graphics import style
from sugar3.graphics.icon import Icon
-from sugar3.graphics.icon import Icon
from sugar3.graphics.combobox import ComboBox as _ComboBox
from theme import *
@@ -31,7 +30,7 @@ class ComboBox(_ComboBox):
_ComboBox.__init__(self)
self.set_name('we-really-need-it-to-use-custom-combobox-colors')
-
+
def append_item(self, action_id, text=None, icon_name=None, size=None,
pixbuf=None, position=None):