34 | 34 |
from sugar3 import mime
|
35 | 35 |
from sugar3.graphics.toolbutton import ToolButton
|
36 | 36 |
from sugar3.graphics.toolbarbox import ToolbarBox
|
|
37 |
from sugar3.graphics.icon import Icon
|
37 | 38 |
from sugar3.activity.widgets import ActivityToolbarButton
|
38 | 39 |
from sugar3.activity.widgets import StopButton
|
|
40 |
from sugar3.graphics import style
|
39 | 41 |
|
40 | 42 |
from sugar3 import network
|
41 | 43 |
from sugar3.datastore import datastore
|
|
118 | 120 |
self.sw = Gtk.ScrolledWindow(hadj, vadj)
|
119 | 121 |
self.view.parent = self.sw
|
120 | 122 |
|
|
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 |
|
121 | 165 |
self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
|
122 | 166 |
self.sw.add_with_viewport(self.view)
|
123 | 167 |
# Avoid needless spacing
|
124 | 168 |
self.view.parent.props.shadow_type = Gtk.ShadowType.NONE
|
125 | 169 |
|
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()
|
128 | 174 |
|
129 | 175 |
self.unused_download_tubes = set()
|
130 | 176 |
self._want_document = True
|
|
149 | 195 |
self.connect("joined", self._joined_cb)
|
150 | 196 |
elif self._object_id is None:
|
151 | 197 |
self._show_object_picker = GObject.timeout_add(1000, \
|
152 | |
self._show_picker_cb)
|
|
198 |
self._show_picker_cb, notebook)
|
153 | 199 |
|
154 | 200 |
def handle_view_source(self):
|
155 | 201 |
raise NotImplementedError
|
|
255 | 301 |
def __fullscreen_cb(self, button):
|
256 | 302 |
self.fullscreen()
|
257 | 303 |
|
258 | |
def _show_picker_cb(self):
|
|
304 |
def _show_picker_cb(self, *args):
|
259 | 305 |
if not self._want_document:
|
260 | 306 |
return
|
261 | 307 |
|
|
268 | 314 |
jobject = chooser.get_selected_object()
|
269 | 315 |
if jobject and jobject.file_path:
|
270 | 316 |
self.read_file(jobject.file_path)
|
|
317 |
args[-1].set_current_page(-1)
|
271 | 318 |
finally:
|
272 | 319 |
chooser.destroy()
|
273 | 320 |
del chooser
|