Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-12-06 02:40:09 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-12-06 02:40:48 (GMT)
commit8fe4890d2417cf343815cdc42b916b9838ba13d3 (patch)
tree9387494aa2d4ff7fa05c0c1a8a8e7db4d5d7f007
parent403147acc6466df43f7e612595a39b05403d4ad7 (diff)
Add slideview mode
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org> Reviewed-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--historietaactivity.py55
-rw-r--r--icons/slideshow.svg93
-rw-r--r--slideview.py111
-rw-r--r--toolbar.py12
4 files changed, 268 insertions, 3 deletions
diff --git a/historietaactivity.py b/historietaactivity.py
index 0ca0f1d..8f69ef3 100644
--- a/historietaactivity.py
+++ b/historietaactivity.py
@@ -15,11 +15,13 @@ from gettext import gettext as _
from sugar3.graphics.toolbarbox import ToolbarBox, ToolbarButton
from sugar3.activity.widgets import StopButton
from sugar3.activity.widgets import ActivityToolbarButton
-
+from sugar3.graphics.toggletoolbutton import ToggleToolButton
from sugar3.graphics.toolbutton import ToolButton
from toolbar import TextToolbar
from toolbar import GlobesManager
+from slideview import SlideView
+
import time
from sugar3.datastore import datastore
from sugar3 import profile
@@ -47,6 +49,29 @@ class HistorietaActivity(activity.Activity):
activity_toolbar = activity_button.page
toolbar_box.toolbar.insert(activity_button, 0)
+ separator = Gtk.SeparatorToolItem()
+ toolbar_box.toolbar.insert(separator, -1)
+
+ view_subtoolbar = ToolbarButton()
+ view_toolbar = Gtk.Toolbar()
+ view_subtoolbar.props.page = view_toolbar
+ view_subtoolbar.props.icon_name = 'toolbar-view'
+ view_subtoolbar.label = _('View')
+ toolbar_box.toolbar.insert(view_subtoolbar, -1)
+
+ slideview_btn = ToggleToolButton('slideshow')
+ slideview_btn.set_tooltip(_('Slideshow'))
+ slideview_btn.set_active(False)
+ view_toolbar.insert(slideview_btn, -1)
+ slideview_btn.show()
+
+ fullscreen_btn = ToolButton('view-fullscreen')
+ fullscreen_btn.set_tooltip(_('Fullscreen'))
+ fullscreen_btn.props.accelerator = '<Alt>Return'
+ fullscreen_btn.connect('clicked', lambda w: self.fullscreen())
+ view_toolbar.insert(fullscreen_btn, -1)
+ fullscreen_btn.show()
+
#self._add_toolbar_buttons(toolbar_box)
self.set_toolbar_box(toolbar_box)
@@ -61,11 +86,13 @@ class HistorietaActivity(activity.Activity):
text_button.props.page = TextToolbar(self.page)
text_button.props.icon_name = 'format-text-size'
text_button.props.label = _('Text')
+ slideview_btn.connect('clicked', self._switch_view_mode, text_button)
toolbar_box.toolbar.insert(text_button, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
+
toolbar_box.toolbar.insert(separator, -1)
stop = StopButton(self)
@@ -93,7 +120,17 @@ class HistorietaActivity(activity.Activity):
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
scrolled.add_with_viewport(self.page)
scrolled.show_all()
- self.set_canvas(scrolled)
+
+ self._slideview = SlideView(self)
+ self._slideview.show_all()
+
+ self._notebook = Gtk.Notebook()
+ self._notebook.set_show_tabs(False)
+ self._notebook.append_page(scrolled, Gtk.Label('Fototoon'))
+ self._notebook.append_page(self._slideview, Gtk.Label('SlideView'))
+ self._notebook.show_all()
+
+ self.set_canvas(self._notebook)
self.show()
self.metadata['mime_type'] = 'application/x-fototoon-activity'
@@ -277,6 +314,17 @@ class HistorietaActivity(activity.Activity):
preview_data = ''.join(preview_data)
return dbus.ByteArray(preview_data)
+ def _switch_view_mode(self, widget, textbutton):
+ if widget.get_active():
+ self._notebook.set_current_page(1)
+ self._slideview.set_boxes(self.page.boxs)
+ self._slideview.set_current_box(0)
+ else:
+ self._notebook.set_current_page(0)
+ self.globes_manager.set_buttons_sensitive(not widget.get_active())
+ textbutton.set_sensitive(not widget.get_active())
+
+
DEF_SPACING = 6
DEF_WIDTH = 4
@@ -505,8 +553,9 @@ class ComicBox(Gtk.DrawingArea):
ct.paint()
if (self.image != None):
- ctx.set_source_surface(self.image, 0, 0)
ctx.rectangle(0, 0, self.width, self.height)
+ ctx.clip()
+ ctx.set_source_surface(self.image, 0, 0)
ctx.paint()
# Dibujamos el recuadro
diff --git a/icons/slideshow.svg b/icons/slideshow.svg
new file mode 100644
index 0000000..0653381
--- /dev/null
+++ b/icons/slideshow.svg
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<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"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="55px"
+ viewBox="0 0 55 55"
+ width="55px"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="3.5"
+ stroke="#000"
+ fill="#eee"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="slideshow.svg"><metadata
+ id="metadata14">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svgxml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+</metadata>
+<defs
+ id="defs12" />
+<sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1024"
+ inkscape:window-height="541"
+ id="namedview10"
+ showgrid="false"
+ inkscape:zoom="4.2909091"
+ inkscape:cx="27.5"
+ inkscape:cy="27.5"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g3041" />
+
+` <g
+ transform="matrix(0.8501594,0,0,0.8501594,4.1206165,2.9055499)"
+ id="g3041"
+ style="stroke:#ffffff">
+ <rect
+ width="40"
+ height="30"
+ x="7.5"
+ y="5.8274999"
+ id="rect2996"
+ style="fill:none;stroke:#ffffff;stroke-width:2.34500003000000001;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <g
+ transform="translate(-1.0846148,0)"
+ id="g3793"
+ style="stroke:#ffffff">
+ <line
+ id="line2460"
+ y2="52.31316"
+ y1="36.358479"
+ x2="23.419287"
+ x1="27.69433"
+ style="fill:none;stroke:#ffffff;stroke-width:1.78056883999999993;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ <line
+ id="line2460-2"
+ y2="52.313156"
+ y1="36.358479"
+ x2="33.749943"
+ x1="29.474899"
+ style="fill:none;stroke:#ffffff;stroke-width:1.78056883999999993;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" />
+ </g>
+ <line
+ style="fill:none;stroke:#ffffff;stroke-width:2.66399025999999983;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
+ x1="9.0131855"
+ x2="45.986813"
+ y1="8.168005"
+ y2="8.168005"
+ id="line2460-0" />
+</g>
+</svg>
diff --git a/slideview.py b/slideview.py
new file mode 100644
index 0000000..fec8254
--- /dev/null
+++ b/slideview.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2012 Agustin Zubiaga <aguz@sugarlabs.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+from gi.repository import Gtk
+from sugar3.graphics import style
+from sugar3.graphics.icon import Icon
+
+
+class SlideView(Gtk.EventBox):
+
+ def __init__(self, activity):
+ Gtk.EventBox.__init__(self)
+
+ activity.connect('key_press_event', self._key_press_cb)
+
+ self._area = Gtk.DrawingArea()
+ self._area.connect('draw', self._area_draw_cb)
+
+ self._boxes = []
+ self._current_box = None
+
+ prev_btn = Gtk.EventBox()
+ prev_btn.connect('button-press-event', self._prev_slide)
+ self._prev_icon = Icon(pixel_size=100)
+ self._prev_icon.props.icon_name = 'go-previous'
+ prev_btn.add(self._prev_icon)
+
+ next_btn = Gtk.EventBox()
+ next_btn.connect('button-press-event', self._next_slide)
+ self._next_icon = Icon(pixel_size=100)
+ self._next_icon.props.icon_name = 'go-next'
+ next_btn.add(self._next_icon)
+
+ hbox = Gtk.Box()
+ hbox.set_border_width(10)
+ hbox.pack_start(prev_btn, True, False, 0)
+ hbox.pack_start(self._area, False, False, 0)
+ hbox.pack_end(next_btn, True, False, 0)
+
+ self.add(hbox)
+
+ self.show_all()
+
+ def _area_draw_cb(self, widget, context):
+ if self._current_box is None:
+ return
+
+ box = self._boxes[self._current_box]
+ self._area.set_size_request(box.width + 1, box.height + 1)
+
+ context.move_to(box.width - style.zoom(40),
+ box.height + style.zoom(25))
+ context.set_font_size(style.zoom(20))
+ context.show_text('%s/%s' % (self._current_box + 1,
+ str(len(self._boxes))))
+
+ if self._current_box == len(self._boxes) - 1:
+ self._next_icon.set_fill_color(style.COLOR_BUTTON_GREY.get_html())
+ else:
+ self._next_icon.set_fill_color(None)
+
+ if self._current_box == 0:
+ self._prev_icon.set_fill_color(style.COLOR_BUTTON_GREY.get_html())
+ else:
+ self._prev_icon.set_fill_color(None)
+
+ box.draw_in_context(context)
+
+ def set_boxes(self, boxes):
+ # Discard the title box
+ self._boxes = boxes[1:]
+
+ def set_current_box(self, box):
+ self._current_box = box
+ self._area.queue_draw()
+
+ def _next_slide(self, widget, event):
+ self._current_box += 1
+ if self._current_box > len(self._boxes) - 1:
+ self._current_box -= 1
+ self._area.queue_draw()
+
+ def _prev_slide(self, widget, event):
+ self._current_box -= 1
+ if self._current_box < 0:
+ self._current_box += 1
+ self._area.queue_draw()
+
+ def _key_press_cb(self, widget, event):
+ if event.keyval == 65361:
+ self._prev_slide(None, None)
+
+ elif event.keyval == 65363:
+ self._next_slide(None, None) \ No newline at end of file
diff --git a/toolbar.py b/toolbar.py
index e2434f7..36c9557 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -156,6 +156,18 @@ class GlobesManager():
self.b_borrar.set_tooltip(_('Delete'))
toolbar.insert(self.b_borrar, -1)
+ def set_buttons_sensitive(self, sensitive):
+ self.add_box.set_sensitive(sensitive)
+ self.add_cloud.set_sensitive(sensitive)
+ self.add_globe.set_sensitive(sensitive)
+ self.add_photo.set_sensitive(sensitive)
+ self.add_scream.set_sensitive(sensitive)
+ self.add_whisp.set_sensitive(sensitive)
+ self.add_photo.set_sensitive(sensitive)
+ self.b_borrar.set_sensitive(sensitive)
+ self.b_girar.set_sensitive(sensitive)
+ self._lines_menu.set_sensitive(sensitive)
+
def __activate_add_line_cb(self, widget, image_name):
active_box = self._page.get_active_box()
active_box.add_imagen("icons/" + image_name + ".svg", 60, 60)