Ticket #4398: 0001-Adapt-Jukebox-to-new-MessageBox-widget-VERSION2.patch

File 0001-Adapt-Jukebox-to-new-MessageBox-widget-VERSION2.patch, 4.3 KB (added by svineet, 8 years ago)
  • activity.py

    From 2e179d603e270f5ffbedc28e20722bd8050f2289 Mon Sep 17 00:00:00 2001
    From: Sai Vineet <saivineet89@gmail.com>
    Date: Tue, 2 Dec 2014 11:59:12 +0530
    Subject: [PATCH 1/1] Adapt Jukebox to new MessageBox widget in toolkit
    
    ---
     activity.py   | 32 ++++++++++++++++++++++++++++----
     emptypanel.py | 46 ----------------------------------------------
     2 files changed, 28 insertions(+), 50 deletions(-)
     delete mode 100644 emptypanel.py
    
    diff --git a/activity.py b/activity.py
    index b4e54b8..e200610 100644
    a b  
    2121
    2222import sys
    2323import logging
    24 import emptypanel
    2524from gettext import gettext as _
    2625
    2726from sugar3.activity import activity
    from sugar3.graphics.alert import ErrorAlert 
    3635from sugar3.graphics.alert import Alert
    3736from sugar3.graphics.icon import Icon
    3837from sugar3.graphics.toolbutton import ToolButton
     38from sugar3.graphics.messagebox import MessageBox
     39from sugar3.graphics import style
     40
    3941
    4042import gi
    4143gi.require_version('Gtk', '3.0')
    class JukeboxActivity(activity.Activity): 
    178180            # The activity was launched from scratch. We need to show
    179181            # the Empty Widget
    180182            self.playlist_widget.hide()
    181             emptypanel.show(self, 'activity-jukebox',
    182                             _('No media'), _('Choose media files'),
    183                             self.control.show_picker_cb)
     183
     184            image_icon = Icon(
     185                pixel_size=style.LARGE_ICON_SIZE,
     186                icon_name='activity-jukebox',
     187                stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
     188                fill_color=style.COLOR_TRANSPARENT.get_svg())
     189
     190            emptypanel = MessageBox(
     191                title=_('No media'),
     192                icon=image_icon)
     193
     194            open_image_btn = Gtk.Button()
     195            open_image_btn.connect('clicked', self.control.show_picker_cb)
     196            add_image = Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
     197                                                 Gtk.IconSize.BUTTON)
     198            buttonbox = Gtk.Box()
     199            buttonbox.pack_start(add_image, False, True, 0)
     200            buttonbox.pack_end(Gtk.Label(_('Choose media files')),
     201                               True, True, 5)
     202            open_image_btn.add(buttonbox)
     203
     204            emptypanel.add_button(open_image_btn)
     205            emptypanel.show_all()
     206
     207            self.set_canvas(emptypanel)
    184208
    185209        self.control.check_if_next_prev()
    186210
  • deleted file emptypanel.py

    diff --git a/emptypanel.py b/emptypanel.py
    deleted file mode 100644
    index bf4c414..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.view_area.append_page(empty_widgets, None)
    46     activity.view_area.set_current_page(2)