diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2012-05-16 17:28:51 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-05-16 17:28:51 (GMT) |
commit | cf67d2f1f1bb881ad0b2f5255c4e0e9132431695 (patch) | |
tree | 9d10f0b6d963aa1a1847cbfa56def2c53a4024fc | |
parent | e50b371cd85b846db000e8915ce65d8dd42671e2 (diff) |
Implement Gary design proposal
More information:
http://wiki.sugarlabs.org/go/Design_Team/Proposals/Welcome_First_Boot_Intro
-rw-r--r-- | activity.py | 217 | ||||
-rw-r--r-- | icons/go-next-paired-grey.svg | 35 | ||||
-rw-r--r-- | icons/go-previous-paired-grey.svg | 35 |
3 files changed, 151 insertions, 136 deletions
diff --git a/activity.py b/activity.py index bda2311..ccaac70 100644 --- a/activity.py +++ b/activity.py @@ -19,14 +19,11 @@ import logging from gettext import gettext as _ import gtk -import gobject from sugar.activity import activity from sugar.graphics.toolbarbox import ToolbarBox -from sugar.activity.widgets import ActivityButton -from sugar.activity.widgets import TitleEntry +from sugar.activity.widgets import ActivityToolbarButton from sugar.activity.widgets import StopButton -from sugar.activity.widgets import ShareButton from sugar.graphics import style from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon @@ -45,140 +42,58 @@ class WelcomeActivity(activity.Activity): # toolbar with the new toolbar redesign toolbar_box = ToolbarBox() - activity_button = ActivityButton(self) + activity_button = ActivityToolbarButton(self) toolbar_box.toolbar.insert(activity_button, 0) - activity_button.show() - title_entry = TitleEntry(self) - toolbar_box.toolbar.insert(title_entry, -1) - title_entry.show() + toolbar_box.toolbar.insert(gtk.SeparatorToolItem(), -1) - share_button = ShareButton(self) - toolbar_box.toolbar.insert(share_button, -1) - share_button.show() + self.image_viewer = ImageCollectionViewer(False) + + prev_bt = ToolButton("go-previous-paired") + prev_bt.connect("clicked", self.image_viewer.prev_image_clicked_cb) + toolbar_box.toolbar.insert(prev_bt, -1) + + next_bt = ToolButton("go-next-paired") + next_bt.connect("clicked", self.image_viewer.next_image_clicked_cb) + toolbar_box.toolbar.insert(next_bt, -1) separator = gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) - separator.show() stop_button = StopButton(self) toolbar_box.toolbar.insert(stop_button, -1) - stop_button.show() self.set_toolbar_box(toolbar_box) - toolbar_box.show() - - label = gtk.Label("") - label.show() - self.set_canvas(label) - gobject.idle_add(self.show_dialog) - - def show_dialog(self): - welcome_dialog = WelcomeDialog() - welcome_dialog.set_transient_for(self.get_toplevel()) - + toolbar_box.show_all() -class _DialogWindow(gtk.Window): + self.set_canvas(self.image_viewer) - # A base class for a modal dialog window. - def __init__(self, icon_name, title): - super(_DialogWindow, self).__init__() +class CustomButton(gtk.Button): - self.set_border_width(style.LINE_WIDTH) - offset = style.GRID_CELL_SIZE - width = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2 - height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2 - self.set_size_request(width, height) - self.set_position(gtk.WIN_POS_CENTER_ALWAYS) - self.set_decorated(False) - self.set_border_width(style.LINE_WIDTH) - self.set_resizable(False) - self.set_modal(True) + def __init__(self, icon): + super(gtk.Button, self).__init__() + icon = Icon(file='./icons/%s.svg' % icon) + self.set_image(icon) self.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) + self.modify_bg(gtk.STATE_PRELIGHT, style.COLOR_WHITE.get_gdk_color()) - vbox = gtk.VBox() - self.add(vbox) - - toolbar = _DialogToolbar(icon_name, title) - toolbar.connect('stop-clicked', self._stop_clicked_cb) - vbox.pack_start(toolbar, False) - - self.content_vbox = gtk.VBox() - self.content_vbox.set_border_width(1) - vbox.add(self.content_vbox) - - self.connect('realize', self._realize_cb) - - def _stop_clicked_cb(self, source): - self.destroy() - - def _realize_cb(self, source): - self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG) - self.window.set_accept_focus(True) - -class _DialogToolbar(gtk.Toolbar): - - # Displays a dialog window's toolbar, with title, icon, and close box. - - __gsignals__ = { - 'stop-clicked': (gobject.SIGNAL_RUN_LAST, None, ()), - } - - def __init__(self, icon_name, title): - super(_DialogToolbar, self).__init__() - - if icon_name is not None: - icon = Icon() - icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR) - self._add_widget(icon) - - self._add_separator() - - label = gtk.Label(title) - self._add_widget(label) - - self._add_separator(expand=True) - - stop = ToolButton(icon_name='dialog-cancel') - stop.set_tooltip(_('Done')) - stop.connect('clicked', self._stop_clicked_cb) - self.add(stop) - - def _add_separator(self, expand=False): - separator = gtk.SeparatorToolItem() - separator.set_expand(expand) - separator.set_draw(False) - self.add(separator) - - def _add_widget(self, widget): - tool_item = gtk.ToolItem() - tool_item.add(widget) - self.add(tool_item) - - def _stop_clicked_cb(self, button): - self.emit('stop-clicked') - - -class WelcomeDialog(_DialogWindow): +class ImageCollectionViewer(gtk.VBox): __gtype_name__ = 'WelcomeDialog' - def __init__(self): - - # TODO: May be remove the title - super(WelcomeDialog, self).__init__(None, _('Welcome')) + def __init__(self, start_window=True): + super(gtk.VBox, self).__init__() self.image = gtk.Image() - self.content_vbox.pack_start(self.image, True, True, padding=0) - - bottom_toolbar = gtk.Toolbar() - self.content_vbox.pack_start(bottom_toolbar, False, padding=0) + self.pack_start(self.image, True, True, padding=0) - images_path = os.path.expanduser('~/Activities/Welcome.activity/images/') + # images management + images_path = \ + os.path.expanduser('~/Activities/Welcome.activity/images/') self.image_order = 0 self.image_files_list = [] @@ -189,38 +104,61 @@ class WelcomeDialog(_DialogWindow): if self.image_files_list: self.image.set_from_file(self.image_files_list[self.image_order]) - separator = gtk.SeparatorToolItem() - separator.props.draw = False - separator.set_expand(True) - bottom_toolbar.insert(separator, -1) + if start_window: + # Create bottom controls - prev_bt = ToolButton(icon_name='go-previous') - bottom_toolbar.insert(prev_bt, -1) - prev_bt.connect('clicked', self.__prev_clicked_cb) + bottom_toolbar = gtk.HBox() + self.pack_start(bottom_toolbar, False, padding=5) - next_bt = ToolButton(icon_name='go-next') - bottom_toolbar.insert(next_bt, -1) - next_bt.connect('clicked', self.__next_clicked_cb) - self.show_all() + left_box = gtk.HBox() + bottom_toolbar.pack_start(left_box, False, padding=0) + + center_align = gtk.Alignment(0.5, 0, 0, 0) + center_box = gtk.HBox() + center_align.add(center_box) + bottom_toolbar.pack_start(center_align, True, True, padding=0) + + right_box = gtk.HBox() + bottom_toolbar.pack_start(right_box, False, padding=0) + + prev_bt = CustomButton('go-previous-paired-grey') + center_box.pack_start(prev_bt, False, False) + prev_bt.connect('clicked', self.prev_image_clicked_cb) + + next_bt = CustomButton('go-next-paired-grey') + center_box.pack_start(next_bt, False, False) + next_bt.connect('clicked', self.next_image_clicked_cb) - width, height = self.image.size_request() + _next_button = gtk.Button() + image = Icon(icon_name='go-right') + _next_button.set_image(image) + _next_button.set_label(_('Next')) + _next_button.connect('clicked', self.__next_clicked_cb) + right_box.pack_end(_next_button, False, False, padding=5) - height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 4 - width_av = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2 - size_label = gtk.Label(' Size available for image: %d x %d' % - (width_av, height_av)) - item = gtk.ToolItem() - item.add(size_label) - bottom_toolbar.insert(item, 0) - item.show_all() + # do the right_box and left_box have the same size + width = int(gtk.gdk.screen_width() / 4) + right_box.set_size_request(width, -1) + left_box.set_size_request(width, -1) + + self.show_all() + + # calculate space available for images + # (only to tell to the designers) + height_av = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2 + width_av = gtk.gdk.screen_width() + print 'Size available for image: %d x %d' % (width_av, height_av) def __next_clicked_cb(self, button): + gtk.main_quit() + + def next_image_clicked_cb(self, button): self.image_order += 1 if self.image_order == len(self.image_files_list): self.image_order = 0 self.image.set_from_file(self.image_files_list[self.image_order]) - def __prev_clicked_cb(self, button): + def prev_image_clicked_cb(self, button): self.image_order -= 1 if self.image_order < 0: self.image_order = len(self.image_files_list) - 1 @@ -228,9 +166,16 @@ class WelcomeDialog(_DialogWindow): def main(): - welcome_dialog = WelcomeDialog() - #welcome_dialog.set_transient_for(self.get_toplevel()) - welcome_dialog.connect("destroy", gtk.main_quit) + win = gtk.Window() + image_viewer = ImageCollectionViewer() + win.add(image_viewer) + win.set_size_request(gtk.gdk.screen_width(), gtk.gdk.screen_height()) + win.set_position(gtk.WIN_POS_CENTER_ALWAYS) + win.set_decorated(False) + win.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color()) + + win.show_all() + win.connect("destroy", gtk.main_quit) gtk.main() if __name__ == "__main__": diff --git a/icons/go-next-paired-grey.svg b/icons/go-next-paired-grey.svg new file mode 100644 index 0000000..4047302 --- /dev/null +++ b/icons/go-next-paired-grey.svg @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="55.125" + height="55" + viewBox="0 0 55.125 55" + id="svg3906" + xml:space="preserve"><metadata + id="metadata3921"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs3919"> + + + + + </defs><g + id="g4438"><path + d="M 22.561,50 C 34.954,50 45,39.924 45,27.498 45,15.076 34.954,5 22.561,5 H 0 v 45 h 22.561 z" + id="path3911" + style="fill:#4c4d4f;fill-opacity:1" /><g + id="g3913" + style="fill:#ffffff;fill-opacity:1"> + <polygon + points="15.707,37.555 15.707,16.706 30.772,27.133 " + id="polygon3915" + style="fill:#ffffff;fill-opacity:1" /> + </g></g></svg>
\ No newline at end of file diff --git a/icons/go-previous-paired-grey.svg b/icons/go-previous-paired-grey.svg new file mode 100644 index 0000000..0484b87 --- /dev/null +++ b/icons/go-previous-paired-grey.svg @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="55.125" + height="55" + viewBox="0 0 55.125 55" + id="svg3050" + xml:space="preserve"><metadata + id="metadata3065"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs3063"> + + + + + </defs><g + id="g3846"><path + d="M 32.439,5 C 20.046,5 10,15.076 10,27.502 10,39.924 20.046,50 32.439,50 H 55 V 5 H 32.439 z" + id="path3055" + style="fill:#4c4d4f;fill-opacity:0.94117647;fill-rule:nonzero" /><g + id="g3057" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero"> + <polygon + points="39.294,17.445 39.294,38.294 24.227,27.867 " + id="polygon3059" + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero" /> + </g></g></svg>
\ No newline at end of file |