[gedit-plugins] [multiedit] Cache tooltip widget
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] [multiedit] Cache tooltip widget
- Date: Sat, 6 Sep 2014 10:23:00 +0000 (UTC)
commit 7e24243e8e08f1a64efd7311f58deb4a6d871586
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sat Sep 6 12:20:41 2014 +0200
[multiedit] Cache tooltip widget
plugins/multiedit/multiedit/viewactivatable.py | 72 ++++++++++++-----------
1 files changed, 38 insertions(+), 34 deletions(-)
---
diff --git a/plugins/multiedit/multiedit/viewactivatable.py b/plugins/multiedit/multiedit/viewactivatable.py
index fde5e97..b20fe1b 100644
--- a/plugins/multiedit/multiedit/viewactivatable.py
+++ b/plugins/multiedit/multiedit/viewactivatable.py
@@ -52,6 +52,7 @@ class MultiEditViewActivatable(GObject.Object, Gedit.ViewActivatable, Signals):
self._status = None
self._status_timeout = 0
self._delete_mode_id = 0
+ self._tooltip_widget = None
def do_activate(self):
self.view.multiedit_view_activatable = self
@@ -1248,40 +1249,43 @@ class MultiEditViewActivatable(GObject.Object, Gedit.ViewActivatable, Signals):
if x < geom[0] or x > geom[0] + geom[2] or y < geom[1] or y > geom[1] + geom[3]:
return False
- grid = Gtk.Grid()
- grid.set_row_spacing(3)
- grid.set_column_spacing(12)
-
- grid.attach(self.make_label('<b>Selection</b>', True), 0, 0, 1, 1)
- grid.attach(self.make_label('<Enter>', False), 0, 1, 1, 1)
- grid.attach(self.make_label('<Ctrl><Enter>', False), 0, 2, 1, 1)
- grid.attach(self.make_label('<Ctrl><Shift><Enter>', False), 0, 3, 1, 1)
- grid.attach(self.make_label('<Ctrl><Alt><Shift><Enter>', False), 0, 4, 1, 1)
-
- sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
- sep.show()
-
- grid.attach(sep, 0, 5, 2, 1)
- grid.attach(self.make_label('<b>Edit points</b>', True), 0, 6, 1, 1)
- grid.attach(self.make_label('<Ctrl>+E', False), 0, 7, 1, 1)
- grid.attach(self.make_label('<Ctrl><Home>', False), 0, 8, 1, 1)
- grid.attach(self.make_label('<Ctrl><End>', False), 0, 9, 1, 1)
- grid.attach(self.make_label('<Ctrl><Shift><Enter>', False), 0, 10, 1, 1)
- grid.attach(self.make_label('<Ctrl><Alt><Shift><Enter>', False), 0, 11, 1, 1)
-
- grid.attach(self.make_label(_('Enter column edit mode using selection')), 1, 1, 1, 1)
- grid.attach(self.make_label(_('Enter <b>smart</b> column edit mode using selection')), 1, 2, 1, 1)
- grid.attach(self.make_label(_('<b>Smart</b> column align mode using selection')), 1, 3, 1, 1)
- grid.attach(self.make_label(_('<b>Smart</b> column align mode with additional space using
selection')), 1, 4, 1, 1)
-
- grid.attach(self.make_label(_('Toggle edit point')), 1, 7, 1, 1)
- grid.attach(self.make_label(_('Add edit point at beginning of line/selection')), 1, 8, 1, 1)
- grid.attach(self.make_label(_('Add edit point at end of line/selection')), 1, 9, 1, 1)
- grid.attach(self.make_label(_('Align edit points')), 1, 10, 1, 1)
- grid.attach(self.make_label(_('Align edit points with additional space')), 1, 11, 1, 1)
-
- grid.show_all()
- tooltip.set_custom(grid)
+ if self._tooltip_widget is None:
+ grid = Gtk.Grid()
+ grid.set_row_spacing(3)
+ grid.set_column_spacing(12)
+
+ grid.attach(self.make_label('<b>Selection</b>', True), 0, 0, 1, 1)
+ grid.attach(self.make_label('<Enter>', False), 0, 1, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Enter>', False), 0, 2, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Shift><Enter>', False), 0, 3, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Alt><Shift><Enter>', False), 0, 4, 1, 1)
+
+ sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
+ sep.show()
+
+ grid.attach(sep, 0, 5, 2, 1)
+ grid.attach(self.make_label('<b>Edit points</b>', True), 0, 6, 1, 1)
+ grid.attach(self.make_label('<Ctrl>+E', False), 0, 7, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Home>', False), 0, 8, 1, 1)
+ grid.attach(self.make_label('<Ctrl><End>', False), 0, 9, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Shift><Enter>', False), 0, 10, 1, 1)
+ grid.attach(self.make_label('<Ctrl><Alt><Shift><Enter>', False), 0, 11, 1, 1)
+
+ grid.attach(self.make_label(_('Enter column edit mode using selection')), 1, 1, 1, 1)
+ grid.attach(self.make_label(_('Enter <b>smart</b> column edit mode using selection')), 1, 2, 1,
1)
+ grid.attach(self.make_label(_('<b>Smart</b> column align mode using selection')), 1, 3, 1, 1)
+ grid.attach(self.make_label(_('<b>Smart</b> column align mode with additional space using
selection')), 1, 4, 1, 1)
+
+ grid.attach(self.make_label(_('Toggle edit point')), 1, 7, 1, 1)
+ grid.attach(self.make_label(_('Add edit point at beginning of line/selection')), 1, 8, 1, 1)
+ grid.attach(self.make_label(_('Add edit point at end of line/selection')), 1, 9, 1, 1)
+ grid.attach(self.make_label(_('Align edit points')), 1, 10, 1, 1)
+ grid.attach(self.make_label(_('Align edit points with additional space')), 1, 11, 1, 1)
+
+ grid.show_all()
+ self._tooltip_widget = grid
+
+ tooltip.set_custom(self._tooltip_widget)
return True
def get_border_color(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]