diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2012-05-16 19:07:48 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-05-16 19:07:48 (GMT) |
commit | 0ec6a857aebccf3db13eb7393f2b1316a9497a29 (patch) | |
tree | f65bedac581f17fd3ab0ff22003050d712048f55 | |
parent | 706e63ec346e792b8e0d063c49a252cea0c985f1 (diff) |
Add timeout to auto change the image after 10 seconds
-rw-r--r-- | activity.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activity.py b/activity.py index 358a955..18eb43b 100644 --- a/activity.py +++ b/activity.py @@ -19,6 +19,7 @@ import logging from gettext import gettext as _ import gtk +import gobject from sugar.activity import activity from sugar.graphics.toolbarbox import ToolbarBox @@ -28,6 +29,8 @@ from sugar.graphics import style from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon +DEFAULT_CHANGE_IMAGE_TIME = 10 + class WelcomeActivity(activity.Activity): """WelcomeActivity class as specified in activity.info""" @@ -145,6 +148,9 @@ class ImageCollectionViewer(gtk.VBox): self.show_all() + self.timer_id = gobject.timeout_add_seconds(DEFAULT_CHANGE_IMAGE_TIME, + self.auto_change_image) + # calculate space available for images # (only to tell to the designers) height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2 @@ -154,7 +160,14 @@ class ImageCollectionViewer(gtk.VBox): def __next_clicked_cb(self, button): gtk.main_quit() + def auto_change_image(self): + self.next_image_clicked_cb(None) + return True + def next_image_clicked_cb(self, button): + gobject.source_remove(self.timer_id) + self.timer_id = gobject.timeout_add_seconds(DEFAULT_CHANGE_IMAGE_TIME, + self.auto_change_image) self.image_order += 1 if self.image_order == len(self.image_files_list): self.image_order = 0 |