def __init__(self, direction): GObject.GObject.__init__(self) self.direction = direction icon = 'pan-end-symbolic' if direction == DIR_FORWARD else 'pan-start-symbolic' self.add(Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)) widget_set_css(self, 'zim-pathbar-scroll-button', 'padding: 2px 2px 2px 2px;')
def add_header(self, widget): '''Add an header widget on top of the object''' widget.get_style_context().add_class(Gtk.STYLE_CLASS_BACKGROUND) widget_set_css(widget, 'zim-insertedobject-head', 'border-bottom: 1px solid @fg_color') self._vbox.pack_start(widget, True, True, 0) self._vbox.reorder_child(widget, 0)
def __init__(self): GObject.GObject.__init__(self) self.set_border_width(3) self._has_cursor = False self._vbox = Gtk.VBox() Gtk.EventBox.add(self, self._vbox) widget_set_css(self._vbox, 'zim-inserted-object', 'border: 1px solid #ccc')
def __init__(self): GObject.GObject.__init__(self) self.set_border_width(3) self._has_cursor = False self._vbox = Gtk.VBox() Gtk.EventBox.add(self, self._vbox) widget_set_css(self._vbox, 'zim-pageview-object', 'border: 1px solid @text_color')
def add(self, child): self._state = None widget_set_css(child, 'zim-pathbar-path-button', 'padding: 2px 6px 2px 6px;') # Make buttons a bit smaller (but keep some horizontal padding) req = child.get_preferred_size()[1] child.set_size_request(min(req.width, MAX_BUTTON_WIDTH), req.height) # Try to force the size to remain stable over state changes Gtk.HBox.add(self, child) self.reorder_child(self._forw_button, -1) # Shuffle to the end
def __init__(self, pageview): GObject.GObject.__init__(self) self.head = Gtk.Label(label=_('ToC')) self.head.set_padding(5, 1) self.tocwidget = ToCWidget(pageview, ellipsis=False) self.tocwidget.set_shadow_type(Gtk.ShadowType.NONE) self._head_event_box = MyEventBox() self._head_event_box.add(self.head) self._head_event_box.connect('button-release-event', self.on_toggle) self._head_event_box.get_style_context().add_class( Gtk.STYLE_CLASS_BACKGROUND) self.pack_start(self._head_event_box, False, True, 0) self.pack_start(self.tocwidget, True, True, 0) widget_set_css(self, 'zim-toc-widget', 'border: 1px solid @fg_color') widget_set_css(self.head, 'zim-toc-head', 'border-bottom: 1px solid @fg_color') ## Add self to textview # Need to wrap in event box to make widget visible # probably because Containers normally don't have their own # gdk window. So would paint directly on background window. self.textview = pageview.textview self._event_box = MyEventBox() self._event_box.add(self) self.textview.add_child_in_window(self._event_box, Gtk.TextWindowType.WIDGET, 0, 0) self.connectto( self.textview, 'size-allocate', handler=DelayedCallback(10, self.update_size_and_position), # Callback wrapper to prevent glitches for fast resizing of the window ) self.connectto(self.tocwidget, 'changed', handler=self.update_size_and_position) self._event_box.show_all()
def __init__(self, pageview): GObject.GObject.__init__(self) self.head = Gtk.Label(label=_('ToC')) self.head.set_padding(5, 1) self.tocwidget = ToCWidget(pageview, ellipsis=False) self.tocwidget.set_shadow_type(Gtk.ShadowType.NONE) self._head_event_box = MyEventBox() self._head_event_box.add(self.head) self._head_event_box.connect('button-release-event', self.on_toggle) self._head_event_box.get_style_context().add_class( Gtk.STYLE_CLASS_BACKGROUND) self.pack_start(self._head_event_box, False, True, 0) self.pack_start(self.tocwidget, True, True, 0) widget_set_css(self, 'zim-toc-widget', 'border: 1px solid @fg_color') widget_set_css(self.head, 'zim-toc-head', 'border-bottom: 1px solid @fg_color') self.set_halign(Gtk.Align.END) self.set_margin_end(self.MARGIN_END) self.set_valign(Gtk.Align.START) self.set_margin_top(self.MARGIN_TOP) pageview.overlay.add_overlay(self) self._textview = pageview.textview self.connectto( self._textview, 'size-allocate', handler=DelayedCallback(10, self.update_size_and_position), # Callback wrapper to prevent glitches for fast resizing of the window ) self.connectto(self.tocwidget, 'changed', handler=self.update_size_and_position_after_change) self.show_all()