Ticket #4398: 0001-Adapt-Read-to-new-MessageBox-widget-in-toolkit.patch

File 0001-Adapt-Read-to-new-MessageBox-widget-in-toolkit.patch, 4.5 KB (added by svineet, 8 years ago)
  • deleted file emptypanel.py

    From ce7f1e341b43c5d6a4b5364b3fdc9f04c85d4e2d Mon Sep 17 00:00:00 2001
    From: Sai Vineet <saivineet89@gmail.com>
    Date: Tue, 2 Dec 2014 11:38:24 +0530
    Subject: [PATCH 1/1] Adapt Read to new MessageBox widget in toolkit
    
    ---
     emptypanel.py   | 45 ---------------------------------------------
     readactivity.py | 32 ++++++++++++++++++++++++++++----
     2 files changed, 28 insertions(+), 49 deletions(-)
     delete mode 100644 emptypanel.py
    
    diff --git a/emptypanel.py b/emptypanel.py
    deleted file mode 100644
    index d8fa042..0000000
    + -  
    1 import logging
    2 
    3 from gi.repository import Gtk
    4 
    5 from sugar3.graphics import style
    6 from sugar3.graphics.icon import Icon
    7 
    8 
    9 def show(activity, icon_name, message, btn_label, btn_callback):
    10     empty_widgets = Gtk.EventBox()
    11     empty_widgets.modify_bg(Gtk.StateType.NORMAL,
    12                             style.COLOR_WHITE.get_gdk_color())
    13 
    14     vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    15     mvbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
    16     vbox.pack_start(mvbox, True, False, 0)
    17 
    18     image_icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
    19                       icon_name=icon_name,
    20                       stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
    21                       fill_color=style.COLOR_TRANSPARENT.get_svg())
    22     mvbox.pack_start(image_icon, False, False, style.DEFAULT_PADDING)
    23 
    24     label = Gtk.Label('<span foreground="%s"><b>%s</b></span>' %
    25                       (style.COLOR_BUTTON_GREY.get_html(),
    26                        message))
    27     label.set_use_markup(True)
    28     mvbox.pack_start(label, False, False, style.DEFAULT_PADDING)
    29 
    30     hbox = Gtk.Box()
    31     open_image_btn = Gtk.Button()
    32     open_image_btn.connect('clicked', btn_callback)
    33     add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
    34                                          Gtk.IconSize.BUTTON)
    35     buttonbox = Gtk.Box()
    36     buttonbox.pack_start(add_image, False, True, 0)
    37     buttonbox.pack_end(Gtk.Label(btn_label), True, True, 5)
    38     open_image_btn.add(buttonbox)
    39     hbox.pack_start(open_image_btn, True, False, 0)
    40     mvbox.pack_start(hbox, False, False, style.DEFAULT_PADDING)
    41 
    42     empty_widgets.add(vbox)
    43     empty_widgets.show_all()
    44     logging.error('Showing empty Panel')
    45     activity.set_canvas(empty_widgets)
  • readactivity.py

    diff --git a/readactivity.py b/readactivity.py
    index 0f16fae..482a646 100644
    a b import re 
    2525import md5
    2626import StringIO
    2727import cairo
    28 import emptypanel
    2928
    3029import dbus
    3130from gi.repository import GObject
    from sugar3.graphics.alert import Alert 
    4746from sugar3.activity.widgets import ActivityToolbarButton
    4847from sugar3.activity.widgets import StopButton
    4948from sugar3.graphics.tray import HTray
     49from sugar3.graphics.messagebox import MessageBox
     50from sugar3.graphics.icon import Icon
    5051from sugar3 import network
    5152from sugar3 import mime
    5253from sugar3 import profile
    class ReadActivity(activity.Activity): 
    373374                self._load_document(handle.uri)
    374375            else:
    375376                # Not joining, not resuming or resuming session without file
    376                 emptypanel.show(self, 'activity-read',
    377                                 _('No book'), _('Choose something to read'),
    378                                 self._show_journal_object_picker_cb)
     377                image_icon = Icon(
     378                    pixel_size=style.LARGE_ICON_SIZE,
     379                    icon_name='activity-read',
     380                    stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
     381                    fill_color=style.COLOR_TRANSPARENT.get_svg())
     382
     383                emptypanel = MessageBox(
     384                    title=_('No book'),
     385                    icon=image_icon
     386                    )
     387
     388                open_image_btn = Gtk.Button()
     389                open_image_btn.connect(
     390                    'clicked',
     391                    self._show_journal_object_picker_cb)
     392                add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
     393                                                     Gtk.IconSize.BUTTON)
     394                buttonbox = Gtk.Box()
     395                buttonbox.pack_start(add_image, False, True, 0)
     396                buttonbox.pack_end(
     397                    Gtk.Label(_('Choose something to read')), True, True, 5)
     398                open_image_btn.add(buttonbox)
     399                emptypanel.add_button(open_image_btn)
     400
     401                self.set_canvas(emptypanel)
     402                emptypanel.show_all()
    379403
    380404    def _create_back_button(self):
    381405        back = ToolButton('go-previous-paired')