Ticket #4398: 0001-Add-MessageBox-widget-with-manuq.patch

File 0001-Add-MessageBox-widget-with-manuq.patch, 3.2 KB (added by svineet, 9 years ago)
  • src/sugar3/graphics/Makefile.am

    From f0bc6973851ebbeb8397975d1dd11e8c36312b30 Mon Sep 17 00:00:00 2001
    From: Sai Vineet <saivineet89@gmail.com>
    Date: Tue, 2 Dec 2014 11:18:15 +0530
    Subject: [PATCH 1/1] Add MessageBox widget (with manuq)
    
    ---
     src/sugar3/graphics/Makefile.am   |  1 +
     src/sugar3/graphics/messagebox.py | 64 +++++++++++++++++++++++++++++++++++++++
     2 files changed, 65 insertions(+)
     create mode 100644 src/sugar3/graphics/messagebox.py
    
    diff --git a/src/sugar3/graphics/Makefile.am b/src/sugar3/graphics/Makefile.am
    index 344cc82..857fc77 100644
    a b sugar_PYTHON = \ 
    99        progressicon.py         \
    1010        __init__.py             \
    1111        menuitem.py             \
     12        messagebox.py           \
    1213        notebook.py             \
    1314        objectchooser.py        \
    1415        palettegroup.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..ca872a9
    - +  
     1# Copyright (C) 2014, 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    Required: title
     28    Optional: An Icon, description text, and multiple 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)