[gedit] quickopen: add icon to entry following other gtk widgets
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] quickopen: add icon to entry following other gtk widgets
- Date: Fri, 2 Sep 2011 13:28:17 +0000 (UTC)
commit ce08250ddaa426d09738fe18ab43791bb71bc4c8
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Sep 2 15:30:01 2011 +0200
quickopen: add icon to entry following other gtk widgets
plugins/quickopen/quickopen/popup.py | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/plugins/quickopen/quickopen/popup.py b/plugins/quickopen/quickopen/popup.py
index a22728d..bbe16ee 100644
--- a/plugins/quickopen/quickopen/popup.py
+++ b/plugins/quickopen/quickopen/popup.py
@@ -65,9 +65,11 @@ class Popup(Gtk.Dialog):
vbox.set_spacing(3)
self._entry = Gtk.Entry()
+ self.set_entry_icon(self._entry)
self._entry.connect('changed', self.on_changed)
self._entry.connect('key-press-event', self.on_key_press_event)
+ self._entry.connect('icon-press', self.on_icon_press)
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
@@ -358,10 +360,24 @@ class Popup(Gtk.Dialog):
self.do_search()
+ def set_entry_icon(self, entry):
+ if entry.get_text() == "":
+ icon = Gio.ThemedIcon.new_with_default_fallbacks("edit-find-symbolic")
+ entry.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, False)
+ entry.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, False)
+ else:
+ icon = Gio.ThemedIcon.new_with_default_fallbacks("edit-clear-symbolic")
+ entry.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, True)
+ entry.set_icon_sensitive(Gtk.EntryIconPosition.SECONDARY, True)
+
+ entry.set_icon_from_gicon(Gtk.EntryIconPosition.SECONDARY, icon)
+
def on_changed(self, editable):
self.do_search()
self.on_selection_changed(self._treeview.get_selection())
+ self.set_entry_icon(editable)
+
def _shift_extend(self, towhere):
selection = self._treeview.get_selection()
@@ -512,6 +528,9 @@ class Popup(Gtk.Dialog):
return False
+ def on_icon_press(self, entry, icon_pos, event):
+ entry.set_text("")
+
def on_row_activated(self, view, path, column):
self._activate()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]