[gnome-tweak-tool] AppChooser: Desensitize ‘Add ’ button when no app is selected
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] AppChooser: Desensitize ‘Add ’ button when no app is selected
- Date: Wed, 29 Apr 2015 09:53:00 +0000 (UTC)
commit 6874ba8e675f40e756b06060f95479c843e34cc4
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Wed Apr 1 18:37:49 2015 +0100
AppChooser: Desensitize ‘Add’ button when no app is selected
The ‘Add Application’ button shouldn't be sensitive if there is no
application currently selected. This is complicated be the fact that
when Gtk.Listbox filters the list it does not clear the selection so if
there is a selected row we need to check if it is mapped before changing
the state of the ‘Add Application’ button.
https://bugzilla.gnome.org/show_bug.cgi?id=747983
configure.ac | 2 +-
gtweak/tweaks/tweak_group_startup.py | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fb70864..130ca05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,7 +8,7 @@ AM_PATH_PYTHON([2.6])
GLIB_GSETTINGS
DESKTOP_SCHEMAS_REQUIRED_VERSION=3.4.0
-GTK_REQUIRED_VERSION=3.12.0
+GTK_REQUIRED_VERSION=3.14.0
PYGOBJECT_REQUIRED_VERSION=3.2.1
PKG_CHECK_MODULES([GSETTINGS_DESKTOP_SCHEMAS], [gsettings-desktop-schemas >=
$DESKTOP_SCHEMAS_REQUIRED_VERSION])
diff --git a/gtweak/tweaks/tweak_group_startup.py b/gtweak/tweaks/tweak_group_startup.py
index ef74892..e897374 100644
--- a/gtweak/tweaks/tweak_group_startup.py
+++ b/gtweak/tweaks/tweak_group_startup.py
@@ -50,7 +50,8 @@ class _AppChooser(Gtk.Dialog):
lb.set_sort_func(self._sort_apps, None)
lb.set_header_func(_list_header_func, None)
lb.set_filter_func(self._list_filter_func, None)
- self.entry.connect("search-changed", lambda e: lb.invalidate_filter())
+ self.entry.connect("search-changed", self._on_search_entry_changed)
+ lb.connect("row-selected", self._on_row_selected)
apps = Gio.app_info_get_all()
for a in apps:
@@ -136,6 +137,20 @@ class _AppChooser(Gtk.Dialog):
return True
return False
+ def _on_search_entry_changed(self, editable):
+ self.listbox.invalidate_filter()
+ selected = self.listbox.get_selected_row()
+ if selected and selected.get_mapped():
+ self.set_response_sensitive(Gtk.ResponseType.OK, True)
+ else:
+ self.set_response_sensitive(Gtk.ResponseType.OK, False)
+
+ def _on_row_selected(self, box, row):
+ if row and row.get_mapped():
+ self.set_response_sensitive(Gtk.ResponseType.OK, True)
+ else:
+ self.set_response_sensitive(Gtk.ResponseType.OK, False)
+
def _on_key_press(self, widget, event):
keyname = Gdk.keyval_name(event.keyval)
if keyname == 'Escape':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]