=== modified file 'softwarecenter/ui/gtk3/widgets/searchentry.py' --- softwarecenter/ui/gtk3/widgets/searchentry.py 2012-11-28 15:54:20 +0000 +++ softwarecenter/ui/gtk3/widgets/searchentry.py 2013-01-14 17:36:22 +0000 @@ -42,7 +42,8 @@ """ Gtk.Entry.__init__(self) self.set_width_chars(25) - self.set_size_request(0, em(1.7)) + self.set_size_request(230, em(1.7)) + self.is_pressed = False if not icon_theme: icon_theme = Gtk.IconTheme.get_default() @@ -51,6 +52,7 @@ self._on_changed) self.connect("icon-press", self._on_icon_pressed) + self.connect("icon-release", self._on_icon_released) self.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY, 'edit-find-symbolic') @@ -66,20 +68,30 @@ self._redo_stack = [] def _on_icon_pressed(self, widget, icon, mouse_button): + self.is_pressed = True + + def _on_icon_released(self, widget, icon, mouse_button): """ Emit the terms-changed signal without any time out when the clear button was clicked - """ - if icon == Gtk.EntryIconPosition.SECONDARY: - # clear with no signal and emit manually to avoid the - # search-timeout - self.clear_with_no_signal() - self.grab_focus() - self.emit("terms-changed", "") + """ + # things for checking if user have clicked (press and release) and + # if the mouse is in the SearchEntry area + (x, y) = self.get_pointer() + rect = self.get_allocation() - elif icon == Gtk.EntryIconPosition.PRIMARY: - self.select_region(0, -1) - self.grab_focus() + if self.is_pressed == True and x > 192 and x < rect.width and y > 17 and y < rect.height: + if icon == Gtk.EntryIconPosition.SECONDARY: + # clear with no signal and emit manually to avoid the + # search-timeout + self.clear_with_no_signal() + self.grab_focus() + self.emit("terms-changed", "") + elif icon == Gtk.EntryIconPosition.PRIMARY: + self.select_region(0, -1) + self.grab_focus() + + self.is_pressed = False def undo(self): if len(self._undo_stack) <= 1: