Codebase list sugar-imageviewer-activity / b845688
Show no image message with an add button Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org> Agustin Zubiaga 11 years ago
2 changed file(s) with 76 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
3434 from sugar3 import mime
3535 from sugar3.graphics.toolbutton import ToolButton
3636 from sugar3.graphics.toolbarbox import ToolbarBox
37 from sugar3.graphics.icon import Icon
3738 from sugar3.activity.widgets import ActivityToolbarButton
3839 from sugar3.activity.widgets import StopButton
40 from sugar3.graphics import style
3941
4042 from sugar3 import network
4143 from sugar3.datastore import datastore
118120 self.sw = Gtk.ScrolledWindow(hadj, vadj)
119121 self.view.parent = self.sw
120122
123 notebook = Gtk.Notebook()
124 notebook.set_show_tabs(False)
125
126 if not handle.object_id:
127 empty_widgets = Gtk.EventBox()
128 empty_widgets.modify_bg(Gtk.StateType.NORMAL,
129 style.COLOR_WHITE.get_gdk_color())
130
131 vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
132 mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
133 vbox.pack_start(mvbox, True, False, 0)
134
135 image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
136 icon_name='imageviewer',
137 stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
138 fill_color=style.COLOR_TRANSPARENT.get_svg())
139 mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING)
140
141 label = Gtk.Label('<span foreground="%s"><b>%s</b></span>' %
142 (style.COLOR_BUTTON_GREY.get_html(),
143 _('No image')))
144 label.set_use_markup(True)
145 mvbox.pack_start(label, False, False, style.DEFAULT_PADDING)
146
147 hbox = Gtk.Box()
148 open_image_btn = Gtk.Button()
149 open_image_btn.connect('clicked', self._show_picker_cb, notebook)
150 add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
151 Gtk.IconSize.BUTTON)
152 buttonbox = Gtk.Box()
153 buttonbox.pack_start(add_image, False, True, 0)
154 buttonbox.pack_end(Gtk.Label(_('Choose an image')), True, True, 5)
155 open_image_btn.add(buttonbox)
156 hbox.pack_start(open_image_btn, True, False, 0)
157 mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING)
158
159 empty_widgets.add(vbox)
160 vbox.show_all()
161
162 notebook.append_page(empty_widgets, None)
163 empty_widgets.show_all()
164
121165 self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
122166 self.sw.add_with_viewport(self.view)
123167 # Avoid needless spacing
124168 self.view.parent.props.shadow_type = Gtk.ShadowType.NONE
125169
126 self.set_canvas(self.sw)
127 self.sw.show_all()
170 notebook.append_page(self.sw, None)
171
172 self.set_canvas(notebook)
173 notebook.show_all()
128174
129175 self.unused_download_tubes = set()
130176 self._want_document = True
149195 self.connect("joined", self._joined_cb)
150196 elif self._object_id is None:
151197 self._show_object_picker = GObject.timeout_add(1000, \
152 self._show_picker_cb)
198 self._show_picker_cb, notebook)
153199
154200 def handle_view_source(self):
155201 raise NotImplementedError
255301 def __fullscreen_cb(self, button):
256302 self.fullscreen()
257303
258 def _show_picker_cb(self):
304 def _show_picker_cb(self, *args):
259305 if not self._want_document:
260306 return
261307
268314 jobject = chooser.get_selected_object()
269315 if jobject and jobject.file_path:
270316 self.read_file(jobject.file_path)
317 args[-1].set_current_page(-1)
271318 finally:
272319 chooser.destroy()
273320 del chooser
0 <?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [
1 <!ENTITY stroke_color "#010101">
2 <!ENTITY fill_color "#ffffff">
3 ]><svg height="50" id="svg2" inkscape:version="0.48.2 r9819" sodipodi:docname="image.svg" version="1.1" width="50" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg">
4 <metadata id="metadata26">
5 <rdf:RDF>
6 <cc:Work rdf:about="">
7 <dc:format>image/svg+xml</dc:format>
8 <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
9 <dc:title/>
10 </cc:Work>
11 </rdf:RDF>
12 </metadata>
13 <defs id="defs24"/>
14 <sodipodi:namedview bordercolor="#666666" borderopacity="1" gridtolerance="10" guidetolerance="10" id="namedview22" inkscape:current-layer="svg2" inkscape:cx="25" inkscape:cy="25" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-height="541" inkscape:window-maximized="1" inkscape:window-width="1024" inkscape:window-x="0" inkscape:window-y="27" inkscape:zoom="4.72" objecttolerance="10" pagecolor="#ffffff" showgrid="false"/>
15 <rect height="36" id="rect4" style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:3" width="44" x="3" y="7"/>
16 <polyline id="polyline6" points="15,7 25,1 35,7" style="fill:none;;stroke:&stroke_color;;stroke-width:1.25"/>
17 <circle cx="14" cy="19" id="circle8" r="4.5" style="fill:&stroke_color;;stroke:&stroke_color;;stroke-width:1.5"/>
18 <polyline id="polyline10" points="3,36 16,32 26,35" style="fill:none;;stroke:&stroke_color;;stroke-width:2.5"/>
19 <polyline id="polyline12" points="15,43 37,28 47,34 47,43" style="fill:&stroke_color;;stroke:&stroke_color;;stroke-width:3"/>
20 <polyline id="polyline14" points="22,41.5 35,30 27,41.5" style="fill:&fill_color;;stroke:none;;stroke-width:0"/>
21 <polyline id="polyline16" points="26,23 28,25 30,23" style="fill:none;;stroke:&stroke_color;;stroke-width:.9"/>
22 <polyline id="polyline18" points="31.2,20 33.5,17.7 35.8,20" style="fill:none;;stroke:&stroke_color;;stroke-width:1"/>
23 <polyline id="polyline20" points="36,13 38.5,15.5 41,13" style="fill:none;;stroke:&stroke_color;;stroke-width:1"/>
24 </svg>