diff options
author | Walter Bender <walter@sugarlabs.org> | 2013-07-20 11:59:03 (GMT) |
---|---|---|
committer | Walter Bender <walter@sugarlabs.org> | 2013-07-20 11:59:03 (GMT) |
commit | cfda2ed353a8145e53d8f81ec7f03bc4419440df (patch) | |
tree | dd6ae23aa1220b963d8b16383f170eaad932a8c0 | |
parent | 7a46ab73335e4dd02ef6def73ea2724a91e27aae (diff) |
general clean up
-rw-r--r-- | activity.py | 86 | ||||
-rw-r--r-- | activity/activity.svg | 211 |
2 files changed, 196 insertions, 101 deletions
diff --git a/activity.py b/activity.py index 98e89dc..b272d76 100644 --- a/activity.py +++ b/activity.py @@ -14,10 +14,11 @@ import os import glob from sugar3.activity import activity +from sugar3.activity.widgets import ActivityToolbarButton from sugar3.graphics.toolbarbox import ToolbarBox from sugar3.activity.widgets import StopButton from sugar3.graphics.toolbutton import ToolButton -from sugar3.activity.widgets import _create_activity_icon as ActivityIcon +# from sugar3.activity.widgets import _create_activity_icon as ActivityIcon from sugar3.graphics.alert import NotifyAlert from sugar3.graphics import style from sugar3.datastore import datastore @@ -37,37 +38,33 @@ MIME_TYPES = {'svg': 'image/svg+xml', 'png': 'image/png', 'gif': 'image/gif', class ClipArtActivity(activity.Activity): def __init__(self, handle): - activity.Activity.__init__(self, handle, False) - + activity.Activity.__init__(self, handle) self._selected_image = None - self.max_participants = 1 - self.toolbar_box = ToolbarBox() - self.toolbar = self.toolbar_box.toolbar + self.max_participants = 1 - activity_button = ToolButton() - icon = ActivityIcon(None) - activity_button.set_icon_widget(icon) - activity_button.set_tooltip(self.get_title()) - stop_button = StopButton(self) + toolbarbox = ToolbarBox() + self.set_toolbar_box(toolbarbox) - separator = Gtk.SeparatorToolItem() - separator.props.draw = False - separator.set_expand(True) + activity_button = ActivityToolbarButton(self) + toolbarbox.toolbar.insert(activity_button, 0) + activity_button.show() self.save_button = ToolButton('image-save') self.save_button.set_tooltip(_('Save to Journal')) self.save_button.connect('clicked', self._save_to_journal) self.save_button.set_sensitive(False) + self.save_button.show() + toolbarbox.toolbar.insert(self.save_button, -1) - self.toolbar.insert(activity_button, 0) - self.toolbar.insert(Gtk.SeparatorToolItem(), -1) - self.toolbar.insert(self.save_button, -1) - - self.toolbar.insert(separator, -1) - self.toolbar.insert(stop_button, -1) + separator = Gtk.SeparatorToolItem() + separator.props.draw = False + separator.set_expand(True) + toolbarbox.toolbar.insert(separator, -1) - artwork_paths = self._scan() + stop_button = StopButton(self) + toolbarbox.toolbar.insert(stop_button, -1) + stop_button.show() scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN) @@ -80,19 +77,18 @@ class ClipArtActivity(activity.Activity): icon_view = Gtk.IconView.new_with_model(store) icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE) - icon_view.connect('selection-changed', self._clipart_selected, - store) + icon_view.connect('selection-changed', self._clipart_selected, store) icon_view.set_pixbuf_column(0) icon_view.grab_focus() scrolled_window.add(icon_view) icon_view.show() - self.set_toolbar_box(self.toolbar_box) - self.set_canvas(self.canvas) + toolbarbox.show_all() self.show_all() self._notify() - GObject.idle_add(fill_clipart_list, store, artwork_paths) + + GObject.idle_add(_fill_clipart_list, store) def _save_to_journal(self, widget): if self._selected_image is None: @@ -133,23 +129,6 @@ class ClipArtActivity(activity.Activity): self._selected_image = image_path self.save_button.set_sensitive(True) - def _scan(self): - # We need a list of all the .png, .jpg, .gif, and .svg files - # in ~/Activities. We don't need to search Documents since - # that is already available through the Journal. - root_path = os.path.join(os.path.expanduser('~'), 'Activities') - artwork_paths = [] - for suffix in ['.png', '.jpg', '.gif', '.svg']: - # Look in ~/Activities/* and ~/Activities/*/* - file_list = glob.glob(os.path.join(root_path, '*', '*' + suffix)) - for f in file_list: - artwork_paths.append(f) - file_list = glob.glob(os.path.join(root_path, '*', '*', - '*' + suffix)) - for f in file_list: - artwork_paths.append(f) - return artwork_paths - def _notify(self): alert = NotifyAlert() alert.props.title = _('Scanning for clipart') @@ -163,11 +142,11 @@ class ClipArtActivity(activity.Activity): self.add_alert(alert) -def fill_clipart_list(store, artwork_paths): +def _fill_clipart_list(store): ''' Append images from the artwork_paths to the store. ''' - for filepath in artwork_paths: + for filepath in _scan_for_artwork(): pixbuf = None try: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( @@ -177,3 +156,20 @@ def fill_clipart_list(store, artwork_paths): pass else: store.append([pixbuf, filepath]) + + +def _scan_for_artwork(): + # We need a list of all the .png, .jpg, .gif, and .svg files + # in ~/Activities. We don't need to search Documents since + # that is already available through the Journal. + root_path = os.path.join(os.path.expanduser('~'), 'Activities') + artwork_paths = [] + for suffix in ['.png', '.jpg', '.gif', '.svg']: + # Look in ~/Activities/* and ~/Activities/*/* + file_list = glob.glob(os.path.join(root_path, '*', '*' + suffix)) + for f in file_list: + artwork_paths.append(f) + file_list = glob.glob(os.path.join(root_path, '*', '*', '*' + suffix)) + for f in file_list: + artwork_paths.append(f) + return artwork_paths diff --git a/activity/activity.svg b/activity/activity.svg index e6a4c60..be2ce78 100644 --- a/activity/activity.svg +++ b/activity/activity.svg @@ -1,86 +1,185 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ - <!ENTITY fill_color "#FFFFFF"> - <!ENTITY stroke_color "#010101"> +<?xml version="1.0" ?> +<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#000"> + <!ENTITY fill_color "#aaa"> ]> -<svg - xmlns="http://www.w3.org/2000/svg" - version="1.1" - width="55" - height="55" - viewBox="0 0 55 55" - id="svg3059" - style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"> -<g +<svg height="55px" viewBox="0 0 55 55" width="55px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" stroke="&stroke_color;" fill="&fill_color;"> + <g transform="matrix(0.55205508,0,0,0.55205508,77.118464,18.235971)" - id="g4382"><g + id="g4382"> + <g transform="translate(-80.093659,12.220029)" id="g4308" - style="fill:none;stroke:&stroke_color;;stroke-opacity:1"> - <g - id="g4310" - style="fill:none;stroke:&stroke_color;;stroke-opacity:1"> - <path - d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389" - id="path4312" - style="fill:none;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> - </g> - </g><g + style="fill:none"> + <g + id="g4310" + style="fill:none"> + <path + d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389" + id="path4312" + style="fill:none" /> + </g> + </g> + <g transform="translate(-80.093659,12.220029)" id="g4314" - style="fill:none;stroke:&stroke_color;;stroke-opacity:1"> - <g - id="g4316" - style="fill:none;stroke:&stroke_color;;stroke-opacity:1"> - <path - d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z" - id="path4318" - style="fill:none;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> - </g> - </g><path + style="fill:none"> + <g + id="g4316" + style="fill:none"> + <path + d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z" + id="path4318" + style="fill:none" /> + </g> + </g> + <path d="m -70.669659,54.827029 c 0,0 -1.351,-0.543 -2.702,-0.543 -1.351,0 -2.703,0.543 -2.703,0.543" id="path4320" - style="fill:none;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path + style="fill:none" /> + <path d="m -70.669659,44.226029 c 0,0 -1.239,-0.543 -2.815,-0.543 -1.577,0 -2.59,0.543 -2.59,0.543" id="path4322" - style="fill:none;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path + style="fill:none" /> + <path d="m -70.669659,33.898029 c 0,0 -1.125,-0.544 -2.927,-0.544 -1.802,0 -2.478,0.544 -2.478,0.544" id="path4324" - style="fill:none;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><line - style="fill:none;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + style="fill:none" /> + <line + style="fill:none" x1="-66.884659" x2="-66.884659" y1="58.753029" y2="23.725029" - id="line4326" /></g><g + id="line4326" /> + </g> + <g transform="matrix(1.1623273,0,0,1.1623273,-14.422024,-12.63995)" id="g3882" - style="fill:none;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"><g + style="fill:none"> + <g id="g3884" - style="fill:none;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"><polygon - points="43.041,21.577 35.281,13.812 15.204,13.812 15.204,35.189 43.041,35.189 " + style="fill:none"> + <polygon + points="35.281,13.812 15.204,13.812 15.204,35.189 43.041,35.189 43.041,21.577 " id="polygon3886" - style="fill:none;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><polyline + style="fill:none" /> + <polyline id="polyline3888" points="35.281,13.812 35.281,21.577 43.041,21.577 " - style="fill:none;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><path - d="m 19.426691,12.275117 c -4.727185,0 -8.666312,4.714399 -8.666312,4.714399 0,0 3.939127,4.737646 8.666312,4.735322 4.729509,-0.0046 8.668637,-4.739971 8.668637,-4.739971 0,0 -3.939128,-4.713237 -8.668637,-4.70975 z m 0,8.039818 c -1.830666,0 -3.314958,-1.484292 -3.314958,-3.31612 0,-1.827179 1.484292,-3.314958 3.314958,-3.314958 1.828341,0 3.312632,1.487779 3.312632,3.314958 0,1.831828 -1.484291,3.31612 -3.312632,3.31612 z" - id="path3890" - style="fill:&stroke_color;;fill-opacity:1;stroke:none;display:inline" /><circle + style="fill:none" /> + </g> + </g> + <g + transform="matrix(1,0,0,-1,-24.850339,47.707501)" + id="g4770"> + <g + transform="translate(34.0803,-1006.42)" + id="g4772"> + <polyline + transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" + style="fill:none" + points="51.562,15.306 41.17,16.188 42.053,5.794" + id="polyline4774" /> + <path + d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" + id="path4776" + style="fill:none" /> + </g> + </g> + <g + transform="matrix(0.55205508,0,0,0.55205508,76.503414,18.153914)" + id="g4382-4" + style="fill:&fill_color;;fill-opacity:1"> + <g + transform="translate(-80.093659,12.220029)" + id="g4308-4" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1"> + <g + id="g4310-4" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1"> + <path + d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389" + id="path4312-1" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + </g> + </g> + <g + transform="translate(-80.093659,12.220029)" + id="g4314-9" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1"> + <g + id="g4316-1" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1"> + <path + d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z" + id="path4318-6" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + </g> + </g> + <path + d="m -70.669659,54.827029 c 0,0 -1.351,-0.543 -2.702,-0.543 -1.351,0 -2.703,0.543 -2.703,0.543" + id="path4320-9" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <path + d="m -70.669659,44.226029 c 0,0 -1.239,-0.543 -2.815,-0.543 -1.577,0 -2.59,0.543 -2.59,0.543" + id="path4322-3" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <path + d="m -70.669659,33.898029 c 0,0 -1.125,-0.544 -2.927,-0.544 -1.802,0 -2.478,0.544 -2.478,0.544" + id="path4324-6" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /> + <line + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" + x1="-66.884659" + x2="-66.884659" + y1="58.753029" + y2="23.725029" + id="line4326-6" /> + </g> + <g + transform="matrix(1.1623273,0,0,1.1623273,-15.037074,-12.722007)" + id="g3882-5" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"> + <g + id="g3884-1" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"> + <polygon + points="43.041,21.577 35.281,13.812 15.204,13.812 15.204,35.189 43.041,35.189 " + id="polygon3886-0" + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <polyline + id="polyline3888-4" + points="35.281,13.812 35.281,21.577 43.041,21.577 " + style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-width:2.15085721;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> + <path + d="m 18.811641,12.19306 c -4.727185,0 -8.666312,4.714399 -8.666312,4.714399 0,0 3.939127,4.737646 8.666312,4.735322 4.729509,-0.0046 8.668637,-4.739971 8.668637,-4.739971 0,0 -3.939128,-4.713237 -8.668637,-4.70975 z m 0,8.039818 c -1.830666,0 -3.314958,-1.484292 -3.314958,-3.31612 0,-1.827179 1.484292,-3.314958 3.314958,-3.314958 1.828341,0 3.312632,1.487779 3.312632,3.314958 0,1.831828 -1.484291,3.31612 -3.312632,3.31612 z" + id="path3890-6" + style="fill:&stroke_color;;fill-opacity:1;stroke:none;display:inline" /> + <circle cx="29.207001" cy="25.863001" r="1.294" - transform="matrix(1.1623273,0,0,1.1623273,-14.520241,-13.061294)" - id="circle3892" - style="fill:&fill_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1;display:inline" /><g - transform="matrix(1,0,0,-1,-24.850339,47.707501)" - id="g4770"><g + transform="matrix(1.1623273,0,0,1.1623273,-15.135291,-13.143351)" + id="circle3892-5" + style="fill:&stroke_color;;fill-opacity:1;stroke:&stroke_color;;stroke-opacity:1;display:inline" /> + <g + transform="matrix(1,0,0,-1,-25.465389,47.625444)" + id="g4770-3"> + <g transform="translate(34.0803,-1006.42)" - id="g4772"><polyline + id="g4772-5"> + <polyline transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" style="fill:none;stroke:&stroke_color;;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round" points="51.562,15.306 41.17,16.188 42.053,5.794" - id="polyline4774" /><path + id="polyline4774-9" /> + <path d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067" - id="path4776" - style="fill:none;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g></svg> + id="path4776-2" + style="fill:none;stroke:&stroke_color;;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + </g> +</svg> |