Be able to click in a tooltip - Fixes #991
This issue was reported many times, when new users see a tooltip try to click, and are confused when there are no action. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
This commit is contained in:
parent
f52b4e1a96
commit
dee29c0e75
@ -22,8 +22,8 @@
|
||||
"""
|
||||
STABLE.
|
||||
"""
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gdk
|
||||
from gi.repository import GObject
|
||||
from gi.repository import Pango
|
||||
|
||||
@ -111,7 +111,10 @@ class Palette(PaletteWindow):
|
||||
self._icon_visible = True
|
||||
self._palette_state = self.PRIMARY
|
||||
|
||||
self._primary_event_box = Gtk.EventBox()
|
||||
self._primary_event_box.show()
|
||||
self._primary_box = Gtk.HBox()
|
||||
self._primary_event_box.add(self._primary_box)
|
||||
self._primary_box.show()
|
||||
|
||||
self._icon_box = Gtk.HBox()
|
||||
@ -135,6 +138,9 @@ class Palette(PaletteWindow):
|
||||
self._label.set_max_width_chars(text_maxlen)
|
||||
self._label.set_ellipsize(Pango.EllipsizeMode.MIDDLE)
|
||||
labels_box.pack_start(self._label, True, True, 0)
|
||||
self._primary_event_box.connect('button-release-event',
|
||||
self.__button_release_event_cb)
|
||||
self._primary_event_box.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK)
|
||||
|
||||
self._secondary_label = Gtk.Label()
|
||||
self._secondary_label.set_alignment(0, 0.5)
|
||||
@ -255,6 +261,10 @@ class Palette(PaletteWindow):
|
||||
getter=get_primary_text,
|
||||
setter=set_primary_text)
|
||||
|
||||
def __button_release_event_cb(self, widget, event):
|
||||
if self.props.invoker is not None:
|
||||
self.props.invoker.primary_text_clicked()
|
||||
|
||||
def set_secondary_text(self, label):
|
||||
if label is not None:
|
||||
label = label.split('\n', 1)[0]
|
||||
@ -334,13 +344,14 @@ class Palette(PaletteWindow):
|
||||
self._setup_widget()
|
||||
|
||||
self._palette_box = Gtk.VBox()
|
||||
self._palette_box.pack_start(self._primary_box, False, True, 0)
|
||||
self._palette_box.pack_start(self._primary_event_box, False, True,
|
||||
0)
|
||||
self._palette_box.pack_start(self._secondary_box, True, True, 0)
|
||||
|
||||
self._widget.add(self._palette_box)
|
||||
self._palette_box.show()
|
||||
height = style.GRID_CELL_SIZE - 2 * self._widget.get_border_width()
|
||||
self._primary_box.set_size_request(-1, height)
|
||||
self._primary_event_box.set_size_request(-1, height)
|
||||
|
||||
if self._content.get_children():
|
||||
self._content.remove(self._content.get_children()[0])
|
||||
@ -405,14 +416,14 @@ class Palette(PaletteWindow):
|
||||
if self._widget is None \
|
||||
or not isinstance(self._widget, _PaletteMenuWidget):
|
||||
if self._widget is not None:
|
||||
self._palette_box.remove(self._primary_box)
|
||||
self._palette_box.remove(self._primary_event_box)
|
||||
self._palette_box.remove(self._secondary_box)
|
||||
self._teardown_widget()
|
||||
self._widget.destroy()
|
||||
|
||||
self._widget = _PaletteMenuWidget()
|
||||
|
||||
self._label_menuitem = _HeaderItem(self._primary_box)
|
||||
self._label_menuitem = _HeaderItem(self._primary_event_box)
|
||||
self._label_menuitem.show()
|
||||
self._widget.append(self._label_menuitem)
|
||||
|
||||
|
@ -1052,6 +1052,10 @@ class Invoker(GObject.GObject):
|
||||
if not self.props.cache_palette:
|
||||
self.set_palette(None)
|
||||
|
||||
def primary_text_clicked(self):
|
||||
"""Implemented by invokers that can be clicked"""
|
||||
pass
|
||||
|
||||
|
||||
class WidgetInvoker(Invoker):
|
||||
|
||||
@ -1345,6 +1349,9 @@ class ToolInvoker(WidgetInvoker):
|
||||
else:
|
||||
return self.LEFT + self.RIGHT
|
||||
|
||||
def primary_text_clicked(self):
|
||||
self._widget.emit('clicked')
|
||||
|
||||
|
||||
class CellRendererInvoker(Invoker):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user