diff options
author | florent <florent.pigout@gmail.com> | 2011-04-15 23:40:17 (GMT) |
---|---|---|
committer | florent <florent.pigout@gmail.com> | 2011-04-15 23:40:17 (GMT) |
commit | f18a18153ec1b4806e69d7879f3a387f7ea5f4de (patch) | |
tree | 4386fa18527299c99d36351d2ef9f33082226eca | |
parent | e3fac95899171b7c79104db5bb82a08d4100eba3 (diff) |
prepare import/export buttons and cb
-rw-r--r-- | activity.py | 5 | ||||
-rw-r--r-- | atoidejouer/tools/storage.py | 15 | ||||
-rw-r--r-- | atoidejouer/ui/screens.py | 61 | ||||
-rw-r--r-- | atoidejouer/ui/timeline.py | 2 | ||||
-rw-r--r-- | atoidejouer/ui/toolbar.py | 13 | ||||
-rw-r--r-- | docs/img/src/export.py | 2 | ||||
-rw-r--r-- | docs/img/src/export.svg | 57 | ||||
-rw-r--r-- | docs/img/src/export/24/export.png | bin | 0 -> 1490 bytes | |||
-rw-r--r-- | docs/img/src/export/24/import.png | bin | 0 -> 1515 bytes | |||
-rw-r--r-- | docs/img/src/import.svg | 57 | ||||
-rw-r--r-- | static/data/icons/export.png | bin | 0 -> 1490 bytes | |||
-rw-r--r-- | static/data/icons/import.png | bin | 0 -> 1515 bytes |
12 files changed, 205 insertions, 7 deletions
diff --git a/activity.py b/activity.py index a6add05..ac325dd 100644 --- a/activity.py +++ b/activity.py @@ -122,6 +122,11 @@ def _toolbar_changed(toolbox, page, activity_): if page == 0: # show the activity screen activity_._change_screen(toolbar=None, name='activity') + # .. + _screen = activity_.get_current_screen() + # .. + _screen.msg_label_import.hide() + _screen.msg_label_export.hide() else: pass # propagate it diff --git a/atoidejouer/tools/storage.py b/atoidejouer/tools/storage.py index f0fca4d..584559f 100644 --- a/atoidejouer/tools/storage.py +++ b/atoidejouer/tools/storage.py @@ -1,6 +1,8 @@ # python import import logging, os, shutil, time +# .. +from gettext import gettext as _ # gtk import import gtk @@ -224,3 +226,16 @@ def init_activity_folder(): __check_dir_files(os.path.join('sequences', 'sounds')) # stories __check_dir_files('stories') + + +def import_project(file_path, msg_label): + # .. + msg_label.set_markup(_('<span size="large" style="italic">IMPORT</span>')) + msg_label.show() + + + +def export_project(msg_label): + # .. + msg_label.set_markup(_('<span size="large" style="italic">EXPORT</span>')) + msg_label.show() diff --git a/atoidejouer/ui/screens.py b/atoidejouer/ui/screens.py index e5e0678..8fcde91 100644 --- a/atoidejouer/ui/screens.py +++ b/atoidejouer/ui/screens.py @@ -3,6 +3,7 @@ import logging, os, threading, time # .. from functools import partial +# .. from gettext import gettext as _ # gtk import @@ -10,6 +11,7 @@ import cairo, gobject, gtk, glib # sugar import from sugar.activity import activity +from sugar.graphics.objectchooser import ObjectChooser # atoidejouer import from atoidejouer.tools import config, image, key, sound, storage, ui @@ -575,6 +577,33 @@ def _on_toggle_click(radio, screen, option, value): pass +def _on_button_click(button, screen, name, msg_label): + if name == 'import': + try: + # int file chooser + _chooser = ObjectChooser(button.get_label(), screen, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) + # get chooser result + _r = _chooser.run() + # check result + if _r == gtk.RESPONSE_ACCEPT: + # get selected object + _object = _chooser.get_selected_object() + # do import + storage.import_project(_object.file_path, msg_label) + else: + pass + except Exception, e: + # DEBUG + logger.error('[screens] _on_button_click - e: %s' % e) + # DEBUG + elif name == 'export': + # do export + storage.export_project(msg_label) + else: + pass + + [ ADVANCED, MEDIUM, @@ -589,6 +618,9 @@ class ScreenActivity(gtk.HBox): gtk.HBox.__init__(self, homogeneous=True, spacing=2) # keep toolbar self._activity = activity_ + # keep result label + self.msg_label_import = None + self.msg_label_export = None # add left menu self._group_mode = None self._add_left_part() @@ -623,7 +655,6 @@ class ScreenActivity(gtk.HBox): else: self._group_mode[EASY].set_active(True) - def _get_title(self, text): # init _label = gtk.Label() @@ -647,6 +678,26 @@ class ScreenActivity(gtk.HBox): # return it return _toggle + def _get_button(self, name, text, stock_id, msg_label=None): + # init button + _button = ui.get_button(label=text, stock_id=stock_id) + _button.show() + # set cb + _button.connect('clicked', _on_button_click, self, name, msg_label) + # return it + return _button + + def _get_hidden_text(self): + # init + _label = gtk.Label() + # set markup + _label.set_use_markup(True) + # align + _label.set_padding(5, 5) + _label.set_alignment(0, 0.5) + # return it + return _label + def _get_mode_part(self): # .. _vbox = gtk.VBox(homogeneous=False, spacing=5) @@ -695,9 +746,17 @@ class ScreenActivity(gtk.HBox): # add first part title _vbox.pack_start(self._get_title(_('IMPORT')), expand=False, fill=True) + self.msg_label_import = self._get_hidden_text() + _vbox.pack_start(self._get_button('import', _('Choose a File'), + 'import', msg_label=self.msg_label_import), expand=False, fill=True) + _vbox.pack_start(self.msg_label_import, expand=False, fill=True) # add first part title _vbox.pack_start(self._get_title(_('EXPORT')), expand=False, fill=True) + self.msg_label_export = self._get_hidden_text() + _vbox.pack_start(self._get_button('export', _('Choose a Destination'), + 'export', msg_label=self.msg_label_export), expand=False, fill=True) + _vbox.pack_start(self.msg_label_export, expand=False, fill=True) # .. return _vbox diff --git a/atoidejouer/ui/timeline.py b/atoidejouer/ui/timeline.py index 04d9e8c..6a77515 100644 --- a/atoidejouer/ui/timeline.py +++ b/atoidejouer/ui/timeline.py @@ -6,7 +6,7 @@ from functools import partial from gettext import gettext as _ # gtk import -import gobject, gtk, glib +import gtk, glib # atoidejouer import from atoidejouer.tools import ui diff --git a/atoidejouer/ui/toolbar.py b/atoidejouer/ui/toolbar.py index 34d0aef..5cb1834 100644 --- a/atoidejouer/ui/toolbar.py +++ b/atoidejouer/ui/toolbar.py @@ -598,11 +598,14 @@ class Toolbar(gtk.Toolbar): else: # update current screen self.activity._change_screen(self) - # enable or disble add - _mode = config.Config().get('activity>mode') - _conf = config.Config().get('mode>%s' % _mode, type_=list) - # .. - self._button_dict['add'].set_sensitive('remove' in _conf) + if 'add' in self._button_dict: + # enable or disble add + _mode = config.Config().get('activity>mode') + _conf = config.Config().get('mode>%s' % _mode, type_=list) + # .. + self._button_dict['add'].set_sensitive('remove' in _conf) + else: + pass def _has_button(self, button_id): return button_id in self._button_dict diff --git a/docs/img/src/export.py b/docs/img/src/export.py index 1954f2d..17c4d75 100644 --- a/docs/img/src/export.py +++ b/docs/img/src/export.py @@ -39,6 +39,8 @@ def main(argv=None): 'repeat', 'repeat_grey', 'stop', + 'import', + 'export', ] cwd = os.getcwd() diff --git a/docs/img/src/export.svg b/docs/img/src/export.svg new file mode 100644 index 0000000..957cc94 --- /dev/null +++ b/docs/img/src/export.svg @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg height="60.0000000" id="svg1" inkscape:version="0.38.1" sodipodi:docbase="/home/danny/flat/scalable/apps" sodipodi:docname="ark.svg" sodipodi:version="0.32" version="1.0" width="60.0000000" x="0" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" y="0"> + <metadata> + <rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <cc:Work rdf:about=""> + <dc:title>Part of the Flat Icon Collection (Wed Aug 25 23:23:49 2004)</dc:title> + <dc:description/> + <dc:subject> + <rdf:Bag> + <rdf:li>hash</rdf:li> + <rdf:li/> + <rdf:li>application</rdf:li> + <rdf:li>computer</rdf:li> + <rdf:li>icons</rdf:li> + <rdf:li>theme</rdf:li> + </rdf:Bag> + </dc:subject> + <dc:publisher> + <cc:Agent rdf:about="http://www.openclipart.org"> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:publisher> + <dc:creator> + <cc:Agent> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:creator> + <dc:rights> + <cc:Agent> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:rights> + <dc:date/> + <dc:format>image/svg+xml</dc:format> + <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> + <cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/> + <dc:language>en</dc:language> + </cc:Work> + <cc:License rdf:about="http://web.resource.org/cc/PublicDomain"> + <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/> + <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/> + <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/> + </cc:License> + </rdf:RDF> + </metadata> + <sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:cx="38.251093" inkscape:cy="21.394416" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="693" inkscape:window-width="1016" inkscape:window-x="0" inkscape:window-y="0" inkscape:zoom="6.9465337" pagecolor="#ffffff"/> + <defs id="defs3"/> + <rect height="24.939224" id="rect976" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 2.52755; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.774389, 0, 0, 0.710631, 7.1537, 12.2017)" width="31.301271" x="4.5806737" y="37.860077"/> + <rect height="31.301271" id="rect977" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(127, 127, 127); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 3.30057; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.54748, -0.432413, 0, 0.589462, 15.3705, 35.3505)" width="30.792307" x="35.881947" y="31.498030"/> + <rect height="12.724094" id="rect975" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(127, 127, 127); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 2.47862; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.805265, 0, -0.469268, 0.710631, 12.7273, 16.0944)" width="31.046789" x="25.702669" y="1.4691677"/> + <path d="M 4.9623967,35.060776 L -6.1075652,27.299079 L 14.250985,10.884997 L 25.575429,18.010490 L 4.9623967,35.060776 z " id="path980" sodipodi:nodetypes="ccccc" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-opacity: 1; stroke-width: 2.42126; stroke-linejoin: round; stroke-linecap: round; fill-opacity: 1; stroke-dasharray: none;" transform="matrix(0.774389, 0, 0, 0.774389, 7.1537, 12.0992)"/> + <rect height="32.064716" id="rect974" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 3.35126; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.774389, 0, -0.50872, 0.404228, 26.5506, 21.1536)" width="32.064716" x="8.6523838" y="12.411888"/> + <path d="M 27.738525,23.481850 L 27.738525,35.951462" id="path981" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: none; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-opacity: 1; stroke-width: 1.85731; stroke-linejoin: miter; stroke-linecap: butt; fill-opacity: 0.75; stroke-dasharray: none;" transform="matrix(1.00953, 0, 0, 1.00953, -1.07287, 2.72303)"/> + <path d="M 1.8856384,5.0717015 C 24.588783,12.240858 20.876965,25.061318 20.876965,25.188559 L 15.151123,25.188559 L 23.484852,32.708388 L 32.137788,25.124939 L 26.348325,25.124939 C 26.348325,25.124939 29.055003,4.4520315 1.8856384,5.0717015 z " id="path968" sodipodi:nodetypes="ccccccc" sodipodi:stroke-cmyk="(0 0 0 0.8)" style="fill: rgb(127, 127, 127); fill-rule: evenodd; stroke: rgb(51, 51, 51); stroke-width: 3.09551; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: none;" transform="matrix(1.00953, 0, 0, 1.00953, 5.98071, -1.09562)"/> +</svg>
\ No newline at end of file diff --git a/docs/img/src/export/24/export.png b/docs/img/src/export/24/export.png Binary files differnew file mode 100644 index 0000000..a2b92d9 --- /dev/null +++ b/docs/img/src/export/24/export.png diff --git a/docs/img/src/export/24/import.png b/docs/img/src/export/24/import.png Binary files differnew file mode 100644 index 0000000..37d037b --- /dev/null +++ b/docs/img/src/export/24/import.png diff --git a/docs/img/src/import.svg b/docs/img/src/import.svg new file mode 100644 index 0000000..435d148 --- /dev/null +++ b/docs/img/src/import.svg @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg height="60.0000000" id="svg1" inkscape:version="0.38.1" sodipodi:docbase="/home/danny/flat/scalable/actions" sodipodi:docname="ark_extract.svg" sodipodi:version="0.32" version="1.0" width="60.0000000" x="0" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" y="0"> + <metadata> + <rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> + <cc:Work rdf:about=""> + <dc:title>Part of the Flat Icon Collection (Wed Aug 25 23:29:46 2004)</dc:title> + <dc:description/> + <dc:subject> + <rdf:Bag> + <rdf:li>hash</rdf:li> + <rdf:li/> + <rdf:li>action</rdf:li> + <rdf:li>computer</rdf:li> + <rdf:li>icons</rdf:li> + <rdf:li>theme</rdf:li> + </rdf:Bag> + </dc:subject> + <dc:publisher> + <cc:Agent rdf:about="http://www.openclipart.org"> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:publisher> + <dc:creator> + <cc:Agent> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:creator> + <dc:rights> + <cc:Agent> + <dc:title>Danny Allen</dc:title> + </cc:Agent> + </dc:rights> + <dc:date/> + <dc:format>image/svg+xml</dc:format> + <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> + <cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/> + <dc:language>en</dc:language> + </cc:Work> + <cc:License rdf:about="http://web.resource.org/cc/PublicDomain"> + <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/> + <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/> + <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/> + </cc:License> + </rdf:RDF> + </metadata> + <sodipodi:namedview bordercolor="#666666" borderopacity="1.0" id="base" inkscape:cx="38.251093" inkscape:cy="21.394416" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:window-height="693" inkscape:window-width="1016" inkscape:window-x="0" inkscape:window-y="0" inkscape:zoom="6.9465337" pagecolor="#ffffff"/> + <defs id="defs3"/> + <rect height="24.939224" id="rect976" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 2.52755; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.774389, 0, 0, 0.710631, 7.1537, 12.2017)" width="31.301271" x="4.5806737" y="37.860077"/> + <rect height="31.301271" id="rect977" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(127, 127, 127); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 3.30057; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.54748, -0.432413, 0, 0.589462, 15.3705, 35.3505)" width="30.792307" x="35.881947" y="31.498030"/> + <rect height="12.724094" id="rect975" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(127, 127, 127); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 2.47862; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.805265, 0, -0.469268, 0.710631, 12.7273, 16.0944)" width="31.046789" x="25.702669" y="1.4691677"/> + <path d="M 4.9623967,35.060776 L -6.1075652,27.299079 L 14.250985,10.884997 L 25.575429,18.010490 L 4.9623967,35.060776 z " id="path980" sodipodi:nodetypes="ccccc" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-opacity: 1; stroke-width: 2.42126; stroke-linejoin: round; stroke-linecap: round; fill-opacity: 1; stroke-dasharray: none;" transform="matrix(0.774389, 0, 0, 0.774389, 7.1537, 12.0992)"/> + <rect height="32.064716" id="rect974" rx="0" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: rgb(179, 179, 179); fill-opacity: 1; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-width: 3.35126; stroke-dasharray: none; stroke-linejoin: round; stroke-linecap: round; stroke-opacity: 1;" transform="matrix(0.774389, 0, -0.50872, 0.404228, 26.5506, 21.1536)" width="32.064716" x="8.6523838" y="12.411888"/> + <path d="M 27.738525,23.481850 L 27.738525,35.951462" id="path981" sodipodi:stroke-cmyk="(0.0000000 0.0000000 0.0000000 0.69999999)" style="fill: none; fill-rule: evenodd; stroke: rgb(76, 76, 76); stroke-opacity: 1; stroke-width: 1.85731; stroke-linejoin: miter; stroke-linecap: butt; fill-opacity: 0.75; stroke-dasharray: none;" transform="matrix(1.00953, 0, 0, 1.00953, -1.07287, 2.72303)"/> + <path d="M 37.097588,33.237675 C 29.860131,10.318238 16.917531,14.065418 16.789078,14.065418 L 16.789078,19.845810 L 9.1976068,11.432686 L 16.853304,2.6973130 L 16.853304,8.5419332 C 16.853304,8.5419332 37.723162,5.8094682 37.097588,33.237675 z " id="path968" sodipodi:nodetypes="ccccccc" sodipodi:stroke-cmyk="(0 0 0 0.8)" style="fill: rgb(127, 127, 127); fill-rule: evenodd; stroke: rgb(51, 51, 51); stroke-width: 3.125; stroke-linecap: round; stroke-linejoin: round;" transform="translate(-6.658)"/> +</svg>
\ No newline at end of file diff --git a/static/data/icons/export.png b/static/data/icons/export.png Binary files differnew file mode 100644 index 0000000..a2b92d9 --- /dev/null +++ b/static/data/icons/export.png diff --git a/static/data/icons/import.png b/static/data/icons/import.png Binary files differnew file mode 100644 index 0000000..37d037b --- /dev/null +++ b/static/data/icons/import.png |