Ticket #4144: 0002-Set-correct-padding-and-size-for-the-palette-window-.patch

File 0002-Set-correct-padding-and-size-for-the-palette-window-.patch, 4.6 KB (added by manuq, 11 years ago)

Toolkit patch, correct size and paddings for palette window implementation

  • src/sugar3/graphics/palette.py

    From c0a95e45a515927d14ee10547045e52c1c62df85 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Thu, 1 Nov 2012 17:45:37 -0300
    Subject: [PATCH toolkit-gtk3 2/2] Set correct padding and size for the
     palette, window implementation - SL #4144
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    Palette width: make it a minimun size of 4 Sugar grid cells.
    
    Padding of content, secondary box: we need top and bottom padding,
    which can be set when packing the items container inside the secondary
    box.
    
    Padding of menu items: needs to be just for left and right, so move
    the padding to a new horizontal box.
    
    Padding of separators: unlike GtkSeparatorMenuItem, GtkSeparator
    doesn't support padding.  But we can wrap it in a GtkEventBox and
    force the height of the widget there.
    
    Add PaletteMenuItemCustom class for usage in Palette implementations.
    Instead of adding widgets to the content directly, pack them inside
    this and get the correct padding.
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     src/sugar3/graphics/palette.py         |  4 ++--
     src/sugar3/graphics/palettemenuitem.py | 27 ++++++++++++++++++++++-----
     src/sugar3/graphics/palettewindow.py   |  2 +-
     3 files changed, 25 insertions(+), 8 deletions(-)
    
    diff --git a/src/sugar3/graphics/palette.py b/src/sugar3/graphics/palette.py
    index efdc9fd..0e49e35 100644
    a b class Palette(PaletteWindow): 
    230230    def _add_content(self):
    231231        # The content is not shown until a widget is added
    232232        self._content = Gtk.VBox()
    233         self._content.set_border_width(style.DEFAULT_SPACING)
    234         self._secondary_box.pack_start(self._content, True, True, 0)
     233        self._secondary_box.pack_start(self._content, True, True,
     234                                       style.DEFAULT_SPACING)
    235235
    236236    def _update_accel_widget(self):
    237237        assert self.props.invoker is not None
  • src/sugar3/graphics/palettemenuitem.py

    diff --git a/src/sugar3/graphics/palettemenuitem.py b/src/sugar3/graphics/palettemenuitem.py
    index 7861a0b..e6e3d5b 100644
    a b from sugar3.graphics.icon import Icon 
    2323from sugar3.graphics import style
    2424
    2525
    26 class PaletteMenuItemSeparator(Gtk.HSeparator):
    27     """A HSeparator that can be styled in the theme"""
     26class PaletteMenuItemSeparator(Gtk.EventBox):
     27    """Contains a HSeparator and has the proper height for the menu."""
    2828
    2929    __gtype_name__ = 'SugarPaletteMenuItemSeparator'
    3030
    3131    def __init__(self):
    32         Gtk.HSeparator.__init__(self)
     32        Gtk.EventBox.__init__(self)
     33        separator = Gtk.HSeparator()
     34        self.add(separator)
     35        separator.show()
     36        self.set_size_request(-1, style.DEFAULT_SPACING * 2)
     37
     38
     39class PaletteMenuItemCustom(Gtk.HBox):
     40    def __init__(self):
     41        Gtk.HBox.__init__(self)
     42
     43    def add(self, widget):
     44        self.pack_start(widget, True, True, style.DEFAULT_SPACING)
    3345
    3446
    3547class PaletteMenuItem(Gtk.EventBox):
    class PaletteMenuItem(Gtk.EventBox): 
    4759        self.icon = None
    4860
    4961        vbox = Gtk.VBox()
    50         vbox.set_border_width(style.DEFAULT_PADDING)
    5162        self._hbox = Gtk.HBox()
    5263        if icon_name is not None:
    5364            self.icon = Icon(icon_name=icon_name,
    class PaletteMenuItem(Gtk.EventBox): 
    6980        align.add(self.label)
    7081        self._hbox.pack_start(align, expand=True, fill=True,
    7182                        padding=style.DEFAULT_PADDING)
    72         vbox.pack_start(self._hbox, expand=False, fill=False,
     83
     84        # This box is just for setting left and right padding.
     85        inner_hbox = Gtk.HBox()
     86        inner_hbox.pack_start(self._hbox, False, False,
     87                              padding=style.DEFAULT_PADDING)
     88
     89        vbox.pack_start(inner_hbox, expand=False, fill=False,
    7390                        padding=style.DEFAULT_PADDING)
    7491        self.add(vbox)
    7592
  • src/sugar3/graphics/palettewindow.py

    diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
    index 6e33efe..d9bb517 100644
    a b class _PaletteWindowWidget(Gtk.Window): 
    282282        if self._palette is not None:
    283283            label_width = self._palette.get_label_width()
    284284        size = max(natural, label_width + 2 * self.get_border_width(),
    285                    style.GRID_CELL_SIZE * 2)
     285                   style.GRID_CELL_SIZE * 4)
    286286        return size, size
    287287
    288288    def do_size_allocate(self, allocation):