Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-01-29 18:01:47 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-01-29 18:01:47 (GMT)
commit48a3c653d91aad048f7b0ba34ec5767d9ae35e1d (patch)
tree950d7285ee0bfe65a5f9bc4421f2b253f1d60f08
parentaaf957ba0cec1a70463250b6a85b02514b10bade (diff)
Update-pair-button's sensitivity reflects to selected pair OLPC#6618
-rw-r--r--activity.py2
-rw-r--r--cardlist.py8
-rw-r--r--createcardpanel.py27
3 files changed, 22 insertions, 15 deletions
diff --git a/activity.py b/activity.py
index 9b15453..3b1d816 100644
--- a/activity.py
+++ b/activity.py
@@ -168,7 +168,7 @@ class MemorizeActivity(Activity):
self.createcardpanel = createcardpanel.CreateCardPanel()
self.createcardpanel.connect('add-pair', self.cardlist.add_pair)
self.createcardpanel.connect('update-pair', self.cardlist.update_selected)
- self.cardlist.connect('pair-selected', self.createcardpanel.load_pair)
+ self.cardlist.connect('pair-selected', self.createcardpanel.pair_selected)
self.cardlist.connect('update-create-toolbar', self._createToolbar.update_create_toolbar)
self.cardlist.connect('update-create-buttons', self._createToolbar.update_buttons_status)
self._createToolbar.connect('create_new_game', self.cardlist.clean_list)
diff --git a/cardlist.py b/cardlist.py
index 735af5c..f324ad0 100644
--- a/cardlist.py
+++ b/cardlist.py
@@ -39,7 +39,7 @@ _logger = logging.getLogger('memorize-activity')
class CardList(gtk.EventBox):
__gsignals__ = {
- 'pair-selected': (SIGNAL_RUN_FIRST, None, 6 * [TYPE_PYOBJECT]),
+ 'pair-selected': (SIGNAL_RUN_FIRST, None, 7 * [TYPE_PYOBJECT]),
'update-create-toolbar': (SIGNAL_RUN_FIRST, None, 3 * [TYPE_PYOBJECT]),
'update-create-buttons': (SIGNAL_RUN_FIRST, None, 2 * [TYPE_PYOBJECT]),
}
@@ -210,6 +210,7 @@ class CardList(gtk.EventBox):
self.pairs.remove(widget)
del widget
self.emit('update-create-buttons', True, True)
+ self.emit('pair-selected', False, None, None, None, None, None, None)
def set_selected(self, widget, event):
if self.current_pair <> None:
@@ -217,7 +218,10 @@ class CardList(gtk.EventBox):
self.old.set_selected(False)
self.current_pair = widget
widget.set_selected(True)
- self.emit('pair-selected', self.current_pair.get_text(1), self.current_pair.get_text(2), self.current_pair.get_pixbuf(1), self.current_pair.get_pixbuf(2), self.current_pair.get_sound(1), self.current_pair.get_sound(2))
+ self.emit('pair-selected', True,
+ self.current_pair.get_text(1), self.current_pair.get_text(2),
+ self.current_pair.get_pixbuf(1), self.current_pair.get_pixbuf(2),
+ self.current_pair.get_sound(1), self.current_pair.get_sound(2))
def update_selected(self, widget, newtext1, newtext2, aimg, bimg, asnd, bsnd):
self.current_pair.change_text(newtext1, newtext2)
diff --git a/createcardpanel.py b/createcardpanel.py
index 88929d5..9b157a0 100644
--- a/createcardpanel.py
+++ b/createcardpanel.py
@@ -43,6 +43,7 @@ class CreateCardPanel(gtk.EventBox):
gtk.EventBox.__init__(self)
self.equal_pairs = False
+ self._updatebutton_sensitive = False
# Set the add new pair buttom
add_icon = join(dirname(__file__), 'images', 'pair-add.svg')
@@ -103,15 +104,18 @@ class CreateCardPanel(gtk.EventBox):
self.emit('update-pair', self.cardeditor1.get_text(), self.cardeditor2.get_text(), self.cardeditor1.get_pixbuf(), self.cardeditor2.get_pixbuf(), self.cardeditor1.get_snd(), self.cardeditor2.get_snd())
self.clean(None)
- def load_pair(self, widget, newtext1, newtext2, aimg, bimg, asnd, bsnd):
- self.cardeditor1.set_text(newtext1)
- self.cardeditor2.set_text(newtext2)
- self.cardeditor1.set_pixbuf(aimg)
- self.cardeditor2.set_pixbuf(bimg)
- self.cardeditor1.set_snd(asnd)
- self.cardeditor2.set_snd(bsnd)
- self._addbutton.set_sensitive(True)
- self._updatebutton.set_sensitive(True)
+ def pair_selected(self, widget, selected, newtext1, newtext2, aimg, bimg,
+ asnd, bsnd):
+ if selected:
+ self.cardeditor1.set_text(newtext1)
+ self.cardeditor2.set_text(newtext2)
+ self.cardeditor1.set_pixbuf(aimg)
+ self.cardeditor2.set_pixbuf(bimg)
+ self.cardeditor1.set_snd(asnd)
+ self.cardeditor2.set_snd(bsnd)
+ self._addbutton.set_sensitive(True)
+ self._updatebutton.set_sensitive(selected)
+ self._updatebutton_sensitive = selected
def change_equal_pairs(self, widget, state):
self.equal_pairs = state
@@ -130,7 +134,6 @@ class CreateCardPanel(gtk.EventBox):
self.cardeditor1.clean()
self.cardeditor2.clean()
self._addbutton.set_sensitive(False)
- self._updatebutton.set_sensitive(False)
self._card1_has_text = False
self._card2_has_text = False
self._card1_has_picture = False
@@ -154,14 +157,14 @@ class CreateCardPanel(gtk.EventBox):
if not self.equal_pairs:
if (self._card1_has_text or self._card1_has_picture) and (self._card2_has_text or self._card2_has_picture):
self._addbutton.set_sensitive(True)
- self._updatebutton.set_sensitive(True)
+ self._updatebutton.set_sensitive(self._updatebutton_sensitive)
else:
self._addbutton.set_sensitive(False)
self._updatebutton.set_sensitive(False)
else:
if self._card1_has_text or self._card1_has_picture:
self._addbutton.set_sensitive(True)
- self._updatebutton.set_sensitive(True)
+ self._updatebutton.set_sensitive(self._updatebutton_sensitive)
else:
self._addbutton.set_sensitive(False)
self._updatebutton.set_sensitive(False)