Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-06-29 23:47:52 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-06-29 23:47:52 (GMT)
commit9d3f08f0ac65a98ac13f744bfcfb4687e4ad58c8 (patch)
treee9eb131b8edcdfd9962c75636a23238f37933f07
parentbfaa863fed3f99c737b67c7f8cd81f2a8e7aeda3 (diff)
Load picture button
-rw-r--r--icons/insert-picture.svg40
-rw-r--r--images.py4
-rwxr-xr-xpresent.py16
-rw-r--r--toolbars.py12
4 files changed, 67 insertions, 5 deletions
diff --git a/icons/insert-picture.svg b/icons/insert-picture.svg
new file mode 100644
index 0000000..b8d4cf4
--- /dev/null
+++ b/icons/insert-picture.svg
@@ -0,0 +1,40 @@
+<?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">
+]>
+<svg xmlns="http://www.w3.org/2000/svg" width="55" height="55" id="insert-image.svg">
+ <defs>
+ <mask id="Mask" maskUnits="userSpaceOnUse" x="0" y="0" width="55" height="55">
+ <rect x="0" y="0" width="55" height="55" fill="white" />
+ <line x1="35" y1="4" x2="35" y2="26" stroke-width="10.0" stroke="black" />
+ <line x1="24" y1="15" x2="46" y2="15" stroke-width="10.0" stroke="black" />
+ <polyline points="17.7,38.7 26.3,31 21,38.7" style="fill:black;;stroke:none;;stroke-width:0" />
+ </mask>
+ </defs>
+ <g transform="translate(2,2)">
+ <rect
+ style="opacity:1;fill:#000000;fill-opacity:0;stroke:#ffffff;stroke-width:2.89933752999999994;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect3161"
+ width="37.150295"
+ height="28.059385"
+ x="7.0200901"
+ y="12.647797" />
+ <polyline
+ points="13,39.7 27.6,29.6 34.3,33.6 34.3,39.7"
+ mask="url(#Mask)"
+ style="fill:#ffffff;stroke:#ffffff;stroke-width:3;stroke-opacity:1"
+ id="polyline23"
+ transform="matrix(0.9827085,0,0,0.9742491,10.040979,0.9463818)" />
+ <polyline
+ points="5,35 13.7,32.3 20.3,34.1"
+ mask="url(#Mask)"
+ style="fill:none;stroke:#ffffff;stroke-width:2.50000000000000000;stroke-opacity:1"
+ id="polyline21"
+ transform="translate(3.3549781,4.1125541)" />
+ </g>
+ <line fill="none" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="7" x1="28.376" x2="28.376" y1="30.664" y2="5.712"/>
+ <polyline fill="none" points="36.098,21.51 28.376,30.664 20.653,21.51" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-width="7"/>
+ <line fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5" x1="28.376" x2="28.376" y1="30.664" y2="5.712"/>
+ <polyline fill="none" points="36.098,21.51 28.376,30.664 20.653,21.51" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.5"/>
+</svg>
diff --git a/images.py b/images.py
index 6a22d2d..383d317 100644
--- a/images.py
+++ b/images.py
@@ -92,10 +92,10 @@ class ImagesGalery(VTray):
image_widget = gtk.image_new_from_pixbuf(pixbuf)
image_widget.show()
item.set_icon_widget(image_widget)
- self.galery.add_item(item)
+ self.add_item(item)
item.show()
self.images.append((item, image))
- adjustment = self.galery._viewport.get_vadjustment()
+ adjustment = self._viewport.get_vadjustment()
adjustment.set_value(adjustment.get_upper())
def __init__(self):
diff --git a/present.py b/present.py
index 32787c9..e13414d 100755
--- a/present.py
+++ b/present.py
@@ -21,11 +21,14 @@
#
import gtk
+from sugar import mime
from sugar.activity import activity
from sugar.activity.widgets import ActivityToolbarButton
from sugar.activity.widgets import StopButton
+from sugar.graphics.objectchooser import ObjectChooser
from slides import SlidesNotebook
from toolbars import PresentToolbarBox
+from images import Image
from images import ImagesGalery
@@ -35,6 +38,7 @@ class PresentActivity(activity.Activity):
activity_button = ActivityToolbarButton(self)
stop_button = StopButton(self)
toolbarbox = PresentToolbarBox(activity_button, stop_button)
+ toolbarbox.connect('insert-picture', self.load_picture)
self.set_toolbar_box(toolbarbox)
self.images_galery = ImagesGalery()
self.images_galery.show()
@@ -43,6 +47,12 @@ class PresentActivity(activity.Activity):
self.set_canvas(canvas)
self.show_all()
-if __name__ == "__main__":
- Present().show()
- gtk.main()
+ def load_picture(self, widget):
+ chooser = ObjectChooser(parent=self,
+ what_filter=mime.GENERIC_TYPE_IMAGE)
+ result = chooser.run()
+ if result == gtk.RESPONSE_ACCEPT:
+ jobject = chooser.get_selected_object()
+ image = Image()
+ image.set_from_file(jobject.get_file_path())
+ self.images_galery.append_image(image)
diff --git a/toolbars.py b/toolbars.py
index 8936cc4..af91de6 100644
--- a/toolbars.py
+++ b/toolbars.py
@@ -20,15 +20,27 @@
# MA 02110-1301, USA.
#
+import gobject
import gtk
+from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.toolbarbox import ToolbarBox
class PresentToolbarBox(ToolbarBox):
+ __gsignals__ = {'insert-picture': (gobject.SIGNAL_RUN_LAST,
+ gobject.TYPE_NONE,
+ tuple())}
+
def __init__(self, activitybutton, stopbutton):
ToolbarBox.__init__(self)
self.toolbar.insert(activitybutton, -1)
activitybutton.show_all()
+ insert_image_button = ToolButton('insert-picture')
+ insert_image_button.props.tooltip = 'Load a picture'
+ insert_image_button.connect('clicked',
+ lambda w: self.emit('insert-picture'))
+ insert_image_button.show()
+ self.toolbar.insert(insert_image_button, -1)
separator = gtk.SeparatorToolItem()
separator.set_expand(True)
separator.set_draw(False)