Ticket #4318: style_palettemenu-4318.patch

File style_palettemenu-4318.patch, 1.6 KB (added by manuq, 11 years ago)

Trying to do the same as the Gtk.Window implementation

  • src/sugar3/graphics/palettewindow.py

    diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py
    index ff5e340..d87ea7e 100644
    a b class _PaletteMenuWidget(Gtk.Menu): 
    260260                self._entered = True
    261261                self.emit('enter-notify')
    262262
     263    def get_rect(self):
     264        win_x, win_y = self.get_origin()
     265        rectangle = self.get_allocation()
     266
     267        x = win_x + rectangle.x
     268        y = win_y + rectangle.y
     269        minimum, natural = self.get_preferred_size()
     270        rect = Gdk.Rectangle()
     271        rect.x = x
     272        rect.y = y
     273        rect.width = minimum.width
     274        rect.height = natural.height
     275
     276        return rect
     277
     278    def do_draw(self, cr):
     279        # FIXME: Gtk.Menu.do_draw already calls a render_frame:
     280        # http://git.gnome.org/browse/gtk+/tree/gtk/gtkmenu.c#n3046
     281        Gtk.Menu.do_draw(self, cr)
     282
     283        if self._invoker is not None and self._invoker.has_rectangle_gap():
     284            invoker = self._invoker.get_rect()
     285            palette = self.get_rect()
     286            gap = _calculate_gap(palette, invoker)
     287        else:
     288            gap = False
     289
     290        allocation = self.get_allocation()
     291        context = self.get_style_context()
     292        context.add_class('toolitem')
     293        if gap:
     294            Gtk.render_frame_gap(context, cr, 0, 0, allocation.width, allocation.height,
     295                                 gap[0], gap[1], gap[1] + gap[2])
     296        else:
     297            Gtk.render_frame(context, cr, 0, 0, allocation.width, allocation.height)
     298        return False
     299
    263300
    264301class _PaletteWindowWidget(Gtk.Window):
    265302