307 | | class PDFProgressMessageBox(Gtk.EventBox): |
308 | | def __init__(self, message, button_callback): |
309 | | Gtk.EventBox.__init__(self) |
310 | | |
311 | | self.modify_bg(Gtk.StateType.NORMAL, |
312 | | style.COLOR_WHITE.get_gdk_color()) |
313 | | |
314 | | alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1) |
315 | | self.add(alignment) |
316 | | alignment.show() |
317 | | |
318 | | box = Gtk.VBox() |
319 | | alignment.add(box) |
320 | | box.show() |
321 | | |
322 | | icon = ProgressIcon(icon_name='book', |
323 | | pixel_size=style.LARGE_ICON_SIZE, |
324 | | stroke_color=style.COLOR_BUTTON_GREY.get_svg(), |
325 | | fill_color=style.COLOR_SELECTION_GREY.get_svg()) |
326 | | self.progress_icon = icon |
327 | | |
328 | | box.pack_start(icon, expand=True, fill=False, padding=0) |
329 | | icon.show() |
330 | | |
331 | | label = Gtk.Label() |
332 | | color = style.COLOR_BUTTON_GREY.get_html() |
333 | | label.set_markup('<span weight="bold" color="%s">%s</span>' % ( |
334 | | color, GLib.markup_escape_text(message))) |
335 | | box.pack_start(label, expand=True, fill=False, padding=0) |
336 | | label.show() |
337 | | |
338 | | button_box = Gtk.HButtonBox() |
339 | | button_box.set_layout(Gtk.ButtonBoxStyle.CENTER) |
340 | | box.pack_start(button_box, False, True, 0) |
341 | | button_box.show() |
342 | | |
343 | | button = Gtk.Button(label=_('Cancel')) |
344 | | button.connect('clicked', button_callback) |
345 | | button.props.image = Icon(icon_name='dialog-cancel', |
346 | | pixel_size=style.SMALL_ICON_SIZE) |
347 | | button_box.pack_start(button, expand=True, fill=False, padding=0) |
348 | | button.show() |
349 | | |
350 | | |
351 | | class PDFErrorMessageBox(Gtk.EventBox): |
352 | | def __init__(self, title, message, button_callback): |
353 | | Gtk.EventBox.__init__(self) |
354 | | |
355 | | self.modify_bg(Gtk.StateType.NORMAL, |
356 | | style.COLOR_WHITE.get_gdk_color()) |
357 | | |
358 | | alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1) |
359 | | self.add(alignment) |
360 | | alignment.show() |
361 | | |
362 | | box = Gtk.VBox() |
363 | | alignment.add(box) |
364 | | box.show() |
365 | | |
366 | | # Get the icon of this activity through the bundle path. |
367 | | bundle_path = activity.get_bundle_path() |
368 | | activity_bundle = ActivityBundle(bundle_path) |
369 | | icon = Icon(pixel_size=style.LARGE_ICON_SIZE, |
370 | | file=activity_bundle.get_icon(), |
371 | | stroke_color=style.COLOR_BUTTON_GREY.get_svg(), |
372 | | fill_color=style.COLOR_TRANSPARENT.get_svg()) |
373 | | |
374 | | box.pack_start(icon, expand=True, fill=False, padding=0) |
375 | | icon.show() |
376 | | |
377 | | color = style.COLOR_BUTTON_GREY.get_html() |
378 | | |
379 | | label = Gtk.Label() |
380 | | label.set_markup('<span weight="bold" color="%s">%s</span>' % ( |
381 | | color, GLib.markup_escape_text(title))) |
382 | | box.pack_start(label, expand=True, fill=False, padding=0) |
383 | | label.show() |
384 | | |
385 | | label = Gtk.Label() |
386 | | label.set_markup('<span color="%s">%s</span>' % ( |
387 | | color, GLib.markup_escape_text(message))) |
388 | | box.pack_start(label, expand=True, fill=False, padding=0) |
389 | | label.show() |
390 | | |
391 | | button_box = Gtk.HButtonBox() |
392 | | button_box.set_layout(Gtk.ButtonBoxStyle.CENTER) |
393 | | box.pack_start(button_box, False, True, 0) |
394 | | button_box.show() |
395 | | |
396 | | button = Gtk.Button(label=_('Try again')) |
397 | | button.connect('clicked', button_callback) |
398 | | button.props.image = Icon(icon_name='entry-refresh', |
399 | | pixel_size=style.SMALL_ICON_SIZE, |
400 | | stroke_color=style.COLOR_WHITE.get_svg(), |
401 | | fill_color=style.COLOR_TRANSPARENT.get_svg()) |
402 | | button_box.pack_start(button, expand=True, fill=False, padding=0) |
403 | | button.show() |
404 | | |
405 | | |
491 | | self._message_box = PDFProgressMessageBox( |
492 | | message=_("Downloading document..."), |
493 | | button_callback=self.close_tab) |
| 392 | icon = ProgressIcon(icon_name='book', |
| 393 | pixel_size=style.LARGE_ICON_SIZE, |
| 394 | stroke_color=style.COLOR_BUTTON_GREY.get_svg(), |
| 395 | fill_color=style.COLOR_SELECTION_GREY.get_svg()) |
| 396 | self.progress_icon = icon |
| 397 | |
| 398 | self._message_box = MessageBox(title=_("Downloading document..."), |
| 399 | icon=self.progress_icon) |
| 400 | |
| 401 | cancel_btn = Gtk.Button(label=_('Cancel')) |
| 402 | cancel_btn.connect('clicked', self.close_tab) |
| 403 | cancel_btn.props.image = Icon(icon_name='dialog-cancel', |
| 404 | pixel_size=style.SMALL_ICON_SIZE) |
| 405 | |
| 406 | self._message_box.add_button(cancel_btn) |
| 407 | self._message_box.show_all() |