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

File 0001-Adapt-Sugar-to-new-MessageBox-widget-in-toolkit-with.patch, 7.0 KB (added by svineet, 9 years ago)
  • src/jarabe/desktop/activitieslist.py

    From 3e6b40e0ef726e6b5fa90912ba5c8c2b9cf4e215 Mon Sep 17 00:00:00 2001
    From: Sai Vineet <saivineet89@gmail.com>
    Date: Tue, 2 Dec 2014 12:30:18 +0530
    Subject: [PATCH 1/1] Adapt Sugar to new MessageBox widget in toolkit (with
     manuq)
    
    ---
     src/jarabe/desktop/activitieslist.py | 62 ++++++++++--------------------------
     src/jarabe/journal/listview.py       | 51 ++++++++++-------------------
     2 files changed, 34 insertions(+), 79 deletions(-)
    
    diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py
    index 88bfb0e..e3a69fa 100644
    a b from gi.repository import Gdk 
    3131from sugar3 import profile
    3232from sugar3 import util
    3333from sugar3.graphics import style
     34from sugar3.graphics.messagebox import MessageBox
    3435from sugar3.graphics.icon import Icon, CellRendererIcon
    3536from sugar3.graphics.xocolor import XoColor
    3637from sugar3.graphics.alert import Alert
    class CellRendererActivityIcon(CellRendererIcon): 
    347348        self.emit('erase-activated', bundle_id)
    348349
    349350
    350 class ClearMessageBox(Gtk.EventBox):
    351     def __init__(self, message, button_callback):
    352         Gtk.EventBox.__init__(self)
    353 
    354         self.modify_bg(Gtk.StateType.NORMAL,
    355                        style.COLOR_WHITE.get_gdk_color())
    356 
    357         alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
    358         self.add(alignment)
    359         alignment.show()
    360 
    361         box = Gtk.VBox()
    362         alignment.add(box)
    363         box.show()
    364 
    365         icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
    366                     icon_name='system-search',
    367                     stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
    368                     fill_color=style.COLOR_TRANSPARENT.get_svg())
    369         box.pack_start(icon, expand=True, fill=False, padding=0)
    370         icon.show()
    371 
    372         label = Gtk.Label()
    373         color = style.COLOR_BUTTON_GREY.get_html()
    374         label.set_markup('<span weight="bold" color="%s">%s</span>' % (
    375             color, GLib.markup_escape_text(message)))
    376         box.pack_start(label, expand=True, fill=False, padding=0)
    377         label.show()
    378 
    379         button_box = Gtk.HButtonBox()
    380         button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
    381         box.pack_start(button_box, False, True, 0)
    382         button_box.show()
    383 
    384         button = Gtk.Button(label=_('Clear search'))
    385         button.connect('clicked', button_callback)
    386         button.props.image = Icon(icon_name='dialog-cancel',
    387                                   pixel_size=style.SMALL_ICON_SIZE)
    388         button_box.pack_start(button, expand=True, fill=False, padding=0)
    389         button.show()
    390 
    391 
    392351class ActivitiesList(Gtk.VBox):
    393352    __gtype_name__ = 'SugarActivitiesList'
    394353
    class ActivitiesList(Gtk.VBox): 
    464423        if self._scrolled_window in self.get_children():
    465424            self.remove(self._scrolled_window)
    466425
    467         self._clear_message_box = ClearMessageBox(
    468             message=_('No matching activities'),
    469             button_callback=self.__clear_button_clicked_cb)
     426        # Create MessageBox
     427        self._clear_message_box = MessageBox(
     428            title=_('No matching activities'),
     429            icon=Icon(
     430                pixel_size=style.LARGE_ICON_SIZE,
     431                icon_name='system-search',
     432                stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
     433                fill_color=style.COLOR_TRANSPARENT.get_svg())
     434            )
    470435
    471436        self.pack_end(self._clear_message_box, True, True, 0)
    472437        self._clear_message_box.show()
    473438
     439        clear_button = Gtk.Button(label=_('Clear search'))
     440        clear_button.connect('clicked', self.__clear_button_clicked_cb)
     441        clear_button.props.image = Icon(icon_name='dialog-cancel',
     442                                        icon_size=Gtk.IconSize.BUTTON)
     443        self._clear_message_box.add_button(clear_button)
     444        clear_button.show()
     445
    474446    def __clear_button_clicked_cb(self, button):
    475447        self.emit('clear-clicked')
    476448
  • src/jarabe/journal/listview.py

    diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
    index 46f3259..1faed5e 100644
    a b import logging 
    1818from gettext import gettext as _
    1919import time
    2020
    21 from gi.repository import GLib
    2221from gi.repository import GObject
    2322from gi.repository import Gtk
    2423from gi.repository import Gdk
    2524from gi.repository import Pango
    2625
    2726from sugar3.graphics import style
     27from sugar3.graphics.messagebox import MessageBox
    2828from sugar3.graphics.icon import Icon, CellRendererIcon
    2929from sugar3 import util
    3030from sugar3 import profile
    class BaseListView(Gtk.Bin): 
    446446    def _show_message(self, message, show_clear_query=False):
    447447        self.remove(self.get_child())
    448448
    449         background_box = Gtk.EventBox()
    450         background_box.modify_bg(Gtk.StateType.NORMAL,
    451                                  style.COLOR_WHITE.get_gdk_color())
    452         self.add(background_box)
     449        message_box = MessageBox(
     450            title=message,
     451            icon=Icon(
     452                pixel_size=style.LARGE_ICON_SIZE,
     453                icon_name='activity-journal',
     454                stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
     455                fill_color=style.COLOR_TRANSPARENT.get_svg())
     456            )
    453457
    454         alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
    455         background_box.add(alignment)
    456 
    457         box = Gtk.VBox()
    458         alignment.add(box)
    459 
    460         icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
    461                     icon_name='activity-journal',
    462                     stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
    463                     fill_color=style.COLOR_TRANSPARENT.get_svg())
    464         box.pack_start(icon, expand=True, fill=False, padding=0)
    465 
    466         label = Gtk.Label()
    467         color = style.COLOR_BUTTON_GREY.get_html()
    468         label.set_markup('<span weight="bold" color="%s">%s</span>' % (
    469             color, GLib.markup_escape_text(message)))
    470         box.pack_start(label, expand=True, fill=False, padding=0)
     458        self.add(message_box)
     459        message_box.show()
    471460
    472461        if show_clear_query:
    473             button_box = Gtk.HButtonBox()
    474             button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
    475             box.pack_start(button_box, False, True, 0)
    476             button_box.show()
    477 
    478             button = Gtk.Button(label=_('Clear search'))
    479             button.connect('clicked', self.__clear_button_clicked_cb)
    480             button.props.image = Icon(icon_name='dialog-cancel',
    481                                       pixel_size=style.SMALL_ICON_SIZE)
    482             button_box.pack_start(button, expand=True, fill=False, padding=0)
    483 
    484         background_box.show_all()
     462            clear_button = Gtk.Button(label=_('Clear search'))
     463            clear_button.connect('clicked', self.__clear_button_clicked_cb)
     464            clear_button.props.image = Icon(icon_name='dialog-cancel',
     465                                            icon_size=Gtk.IconSize.BUTTON)
     466            message_box.add_button(clear_button)
     467            clear_button.show()
    485468
    486469    def __clear_button_clicked_cb(self, button):
    487470        self.emit('clear-clicked')