Ticket #4398: 0001-New-widget-MessageBox-SL-4398.patch

File 0001-New-widget-MessageBox-SL-4398.patch, 4.0 KB (added by manuq, 10 years ago)

Toolkit patch: new widget MessageBox

  • src/sugar3/graphics/Makefile.am

    From 5fc8fa4ee9d3e2a8d8de1a0a9911c71a24779deb Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Fri, 25 Jan 2013 17:40:15 -0300
    Subject: [PATCH toolkit] New widget: MessageBox - SL #4398
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    A widget that can display informative messages.  This class hides the
    implementation details of the messages in Shell and activities, and
    removes duplicated code.
    
    Also: reorder list in Makefile alphabetically.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/Makefile.am   |  3 +-
     src/sugar3/graphics/messagebox.py | 64 +++++++++++++++++++++++++++++++++++++++
     2 files changed, 66 insertions(+), 1 deletion(-)
     create mode 100644 src/sugar3/graphics/messagebox.py
    
    diff --git a/src/sugar3/graphics/Makefile.am b/src/sugar3/graphics/Makefile.am
    index 344cc82..7932eed 100644
    a b sugar_PYTHON = \ 
    66        combobox.py             \
    77        iconentry.py            \
    88        icon.py                 \
    9         progressicon.py         \
    109        __init__.py             \
    1110        menuitem.py             \
     11        messagebox.py           \
    1212        notebook.py             \
    1313        objectchooser.py        \
    1414        palettegroup.py         \
    sugar_PYTHON = \ 
    1616        palettemenu.py          \
    1717        palettewindow.py        \
    1818        panel.py                \
     19        progressicon.py         \
    1920        radiopalette.py         \
    2021        radiotoolbutton.py      \
    2122        style.py                \
  • new file src/sugar3/graphics/messagebox.py

    diff --git a/src/sugar3/graphics/messagebox.py b/src/sugar3/graphics/messagebox.py
    new file mode 100644
    index 0000000..a98cc6a
    - +  
     1# Copyright (C) 2013, One Laptop Per Child
     2#
     3# This library is free software; you can redistribute it and/or
     4# modify it under the terms of the GNU Lesser General Public
     5# License as published by the Free Software Foundation; either
     6# version 2 of the License, or (at your option) any later version.
     7#
     8# This library is distributed in the hope that it will be useful,
     9# but WITHOUT ANY WARRANTY; without even the implied warranty of
     10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     11# Lesser General Public License for more details.
     12#
     13# You should have received a copy of the GNU Lesser General Public
     14# License along with this library; if not, write to the
     15# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     16# Boston, MA 02111-1307, USA.
     17
     18from gi.repository import Gtk
     19from gi.repository import GLib
     20
     21from sugar3.graphics import style
     22
     23
     24class MessageBox(Gtk.EventBox):
     25    """Widget to display informative messages.
     26
     27    A title is required.  And it can have an icon, and
     28    buttons.
     29
     30    """
     31    def __init__(self, title, icon=None, description=None):
     32        Gtk.EventBox.__init__(self)
     33
     34        self.icon = icon
     35
     36        self.modify_bg(Gtk.StateType.NORMAL,
     37                       style.COLOR_WHITE.get_gdk_color())
     38
     39        alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
     40        self.add(alignment)
     41        alignment.show()
     42
     43        box = Gtk.VBox()
     44        alignment.add(box)
     45        box.show()
     46
     47        if icon is not None:
     48            box.pack_start(icon, expand=True, fill=False, padding=0)
     49            icon.show()
     50
     51        title_label = Gtk.Label()
     52        title_color = style.COLOR_BUTTON_GREY.get_html()
     53        title_label.set_markup('<span weight="bold" color="%s">%s</span>' % (
     54            title_color, GLib.markup_escape_text(title)))
     55        box.pack_start(title_label, expand=True, fill=False, padding=0)
     56        title_label.show()
     57
     58        self.button_box = Gtk.HButtonBox()
     59        self.button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)
     60        box.pack_start(self.button_box, False, True, 0)
     61        self.button_box.show()
     62
     63    def add_button(self, button):
     64        self.button_box.pack_start(button, expand=True, fill=False, padding=0)