diff --git a/emptypanel.py b/emptypanel.py new file mode 100644 index 0000000..d8fa042 --- /dev/null +++ b/emptypanel.py @@ -0,0 +1,45 @@ +import logging + +from gi.repository import Gtk + +from sugar3.graphics import style +from sugar3.graphics.icon import Icon + + +def show(activity, icon_name, message, btn_label, btn_callback): + empty_widgets = Gtk.EventBox() + empty_widgets.modify_bg(Gtk.StateType.NORMAL, + style.COLOR_WHITE.get_gdk_color()) + + vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) + vbox.pack_start(mvbox, True, False, 0) + + image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE, + icon_name=icon_name, + stroke_color=style.COLOR_BUTTON_GREY.get_svg(), + fill_color=style.COLOR_TRANSPARENT.get_svg()) + mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING) + + label = Gtk.Label('%s' % + (style.COLOR_BUTTON_GREY.get_html(), + message)) + label.set_use_markup(True) + mvbox.pack_start(label, False, False, style.DEFAULT_PADDING) + + hbox = Gtk.Box() + open_image_btn = Gtk.Button() + open_image_btn.connect('clicked', btn_callback) + add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD, + Gtk.IconSize.BUTTON) + buttonbox = Gtk.Box() + buttonbox.pack_start(add_image, False, True, 0) + buttonbox.pack_end(Gtk.Label(btn_label), True, True, 5) + open_image_btn.add(buttonbox) + hbox.pack_start(open_image_btn, True, False, 0) + mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING) + + empty_widgets.add(vbox) + empty_widgets.show_all() + logging.error('Showing empty Panel') + activity.set_canvas(empty_widgets) diff --git a/icons/activity-read.svg b/icons/activity-read.svg new file mode 100644 index 0000000..66910d5 --- /dev/null +++ b/icons/activity-read.svg @@ -0,0 +1,10 @@ + + +]> + + + + + + diff --git a/readactivity.py b/readactivity.py index c7a81aa..701d3aa 100644 --- a/readactivity.py +++ b/readactivity.py @@ -25,6 +25,7 @@ import md5 import StringIO import cairo +import emptypanel import dbus from gi.repository import GObject @@ -336,7 +337,9 @@ self.connect("joined", self._joined_cb) elif self._object_id is None: # Not joining, not resuming - self._show_journal_object_picker() + emptypanel.show(self, 'activity-read', + _('No book'), _('Choose something to read'), + self._show_journal_object_picker_cb) def _create_back_button(self): back = ToolButton('go-previous-paired') @@ -627,7 +630,7 @@ else: logging.debug('link "%s" not found in the toc model', current_link) - def _show_journal_object_picker(self): + def _show_journal_object_picker_cb(self, button): """Show the journal object picker to load a document. This is for if Read is launched without a document. @@ -643,6 +646,7 @@ jobject = chooser.get_selected_object() if jobject and jobject.file_path: self.read_file(jobject.file_path) + self.set_canvas(self._vbox) finally: chooser.destroy() del chooser