[Deskbar] [PATCH] don't start queries until a minimum number of chars have been entered
- From: Maxime Henrion <mux FreeBSD org>
- To: deskbar-applet-list gnome org
- Subject: [Deskbar] [PATCH] don't start queries until a minimum number of chars have been entered
- Date: Wed, 31 May 2006 04:40:13 +0200
Hello all,
I've been writing a small patch to the deskbar applet so that it's
possible to configure a minimum number of characters that need to
be typed before the applet starts suggesting matches. I personally
like to set this to 2, to avoid a lot of meaningless matches when
only one character has been typed.
This is implemented using a GConf key which defaults to 1, so as
to preserve the existing behaviour. There are no UI hooks to allow
changing this setting through the preferences dialog. I suppose
it could be nice to have, unless it is deemed a too advanced setting
to show there. Also, this setting is global (like keybinding), and
not per-applet; I thought it made little sense to want this different
across several applet instances.
This patch is generated against deskbar-applet 2.15.2.1. I think
the potential for conflicts is low, but if it happens to be a
problem, I can merge the patch against CVS and send it back.
Cheers,
Maxime
diff -ru deskbar-applet-2.15.2.1/data/deskbar-applet.schemas.in /home/mux/ports/deskbar-applet-2.15.2.1/data/deskbar-applet.schemas.in
--- deskbar-applet-2.15.2.1/data/deskbar-applet.schemas.in Wed Apr 5 18:12:59 2006
+++ /home/mux/ports/deskbar-applet-2.15.2.1/data/deskbar-applet.schemas.in Wed May 31 03:40:46 2006
@@ -23,6 +23,17 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/deskbar/minchars</key>
+ <applyto>/apps/deskbar/minchars</applyto>
+ <owner>deskbar</owner>
+ <type>int</type>
+ <default>1</default>
+ <locale name="C">
+ <short>The minimum number of characters that need to be typed before the applet starts showing matches</short>
+ <!-- <long></long> -->
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/deskbar/keybinding</key>
<applyto>/apps/deskbar/keybinding</applyto>
<owner>deskbar</owner>
diff -ru deskbar-applet-2.15.2.1/deskbar/DeskbarApplet.py /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/DeskbarApplet.py
--- deskbar-applet-2.15.2.1/deskbar/DeskbarApplet.py Wed May 31 04:08:25 2006
+++ /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/DeskbarApplet.py Wed May 31 04:07:28 2006
@@ -40,7 +40,13 @@
self.loader.connect ("module-initialized", self._connect_if_async)
gtk.window_set_default_icon_name("deskbar-applet")
-
+
+ self.minchars = deskbar.GCONF_CLIENT.get_int(self.prefs.GCONF_MINCHARS)
+ if self.minchars == None:
+ self.minchars = 1
+
+ deskbar.GCONF_CLIENT.notify_add(self.prefs.GCONF_MINCHARS, lambda x, y, z, a: self.on_minchars_changed (z.value))
+
# Set and retrieve the UI to be used
ui_name = deskbar.GCONF_CLIENT.get_string(self.prefs.GCONF_UI_NAME)
if ui_name == None:
@@ -93,6 +99,8 @@
get_deskbar_history().add(text, match)
def on_start_query (self, sender, qstring):
+ if len(qstring) < self.minchars:
+ return
if self.start_query_id != 0:
gobject.source_remove(self.start_query_id)
@@ -281,6 +289,12 @@
self.ui.connect ("keyboard-shortcut", self.on_keyboard_shortcut)
self.applet.connect('change-orient', lambda applet, orient: self.ui.on_change_orient(applet))
self.applet.connect('change-size', lambda applet, orient: self.ui.on_change_size(applet))
+
+ def on_minchars_changed (self, value):
+ if value is None or value.type != gconf.VALUE_INT:
+ return
+
+ self.minchars = value.get_int()
def on_ui_changed (self, value):
if value is None or value.type != gconf.VALUE_STRING:
diff -ru deskbar-applet-2.15.2.1/deskbar/DeskbarAppletPreferences.py /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/DeskbarAppletPreferences.py
--- deskbar-applet-2.15.2.1/deskbar/DeskbarAppletPreferences.py Wed May 31 04:08:25 2006
+++ /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/DeskbarAppletPreferences.py Wed May 31 04:07:00 2006
@@ -12,9 +12,10 @@
self.GCONF_EXPAND = deskbar.GCONF_EXPAND
self.GCONF_UI_NAME = deskbar.GCONF_UI_NAME
- # This preference is shared across all applet instances, unlike
- # width, which is per-instance.
+ # These preferences are shared across all applet instances
+ # unlike width, which is per-instance.
self.GCONF_KEYBINDING = deskbar.GCONF_KEYBINDING
+ self.GCONF_MINCHARS = deskbar.GCONF_MINCHARS
# Retreive this applet's pref folder
path = applet.get_preferences_key()
diff -ru deskbar-applet-2.15.2.1/deskbar/__init__.py /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/__init__.py
--- deskbar-applet-2.15.2.1/deskbar/__init__.py Wed May 31 04:08:25 2006
+++ /home/mux/ports/deskbar-applet-2.15.2.1/deskbar/__init__.py Wed May 31 04:04:21 2006
@@ -82,6 +82,8 @@
# GConf key to the per applet entry expand setting
GCONF_EXPAND = GCONF_DIR + "/expand"
+# GConf key to the setting for the minimum number of chars of a query
+GCONF_MINCHARS = GCONF_DIR + "/minchars"
# GConf key for global keybinding
GCONF_KEYBINDING = GCONF_DIR + "/keybinding"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]