[Goodies-commits] r4877 - xfmpc/trunk/src

Mike Massonnet mmassonnet at xfce.org
Sun Jun 1 21:17:13 CEST 2008


Author: mmassonnet
Date: 2008-06-01 19:17:13 +0000 (Sun, 01 Jun 2008)
New Revision: 4877

Modified:
   xfmpc/trunk/src/dbbrowser.c
Log:
Make search feature work with timeout

* src/dbbrowser.c(cb_search_entry_changed):
  - Initiate a timeout on entry changes to automatically process a search


Modified: xfmpc/trunk/src/dbbrowser.c
===================================================================
--- xfmpc/trunk/src/dbbrowser.c	2008-06-01 19:17:09 UTC (rev 4876)
+++ xfmpc/trunk/src/dbbrowser.c	2008-06-01 19:17:13 UTC (rev 4877)
@@ -51,8 +51,12 @@
                                                                 GdkEventKey *event);
 static void             cb_search_entry_changed                (XfmpcDbbrowser *dbbrowser);
 
+static gboolean         timeout_search                         (XfmpcDbbrowser *dbbrowser);
 
+static void             timeout_search_destroy                 (XfmpcDbbrowser *dbbrowser);
 
+
+
 /* List store identifiers */
 enum
 {
@@ -85,6 +89,7 @@
   GtkListStore             *store;
   GtkWidget                *search_entry;
 
+  guint                     search_timeout;
   gboolean                  is_searching;
 
   gchar                    *wdir;
@@ -384,7 +389,8 @@
 
   if (i == 0)
     {
-      /* TODO display a message that the query returned "no result" */
+      /* TODO display a message that the query returned "no result"?
+       * set the entry background in red? */
       g_message ("change query bad query");
     }
 }
@@ -523,9 +529,7 @@
 
   if (event->keyval == GDK_Escape)
     {
-      priv->is_searching = FALSE;
       gtk_entry_set_text (GTK_ENTRY (priv->search_entry), "");
-      xfmpc_dbbrowser_reload (dbbrowser);
     }
 
   return TRUE;
@@ -534,6 +538,27 @@
 static void
 cb_search_entry_changed (XfmpcDbbrowser *dbbrowser)
 {
-  /* TODO do nothing? execute a timeout to postpone the search? */
+  XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER_GET_PRIVATE (dbbrowser);
+
+  if (priv->search_timeout > 0)
+    g_source_remove (priv->search_timeout);
+
+  priv->search_timeout = g_timeout_add_full (G_PRIORITY_DEFAULT, 642,
+                                             (GSourceFunc)timeout_search, dbbrowser,
+                                             (GDestroyNotify)timeout_search_destroy);
 }
 
+static gboolean
+timeout_search (XfmpcDbbrowser *dbbrowser)
+{
+  cb_search_entry_activated (dbbrowser);
+  return FALSE;
+}
+
+static void
+timeout_search_destroy (XfmpcDbbrowser *dbbrowser)
+{
+  XfmpcDbbrowserPrivate *priv = XFMPC_DBBROWSER_GET_PRIVATE (dbbrowser);
+  priv->search_timeout = 0;
+}
+




More information about the Goodies-commits mailing list