[gnome-commander] Quick search using shell-style wildcards



commit 1115c09db6119e14880f2d719ecfd556ef4a7cd7
Author: ��� <yangyingchao gmail com>
Date:   Thu Sep 30 22:10:10 2010 +0200

    Quick search using shell-style wildcards

 NEWS                               |    3 +++
 doc/C/gnome-commander.xml          |    8 ++++++++
 src/gnome-cmd-main-win.cc          |    6 +++---
 src/gnome-cmd-quicksearch-popup.cc |   12 +++++-------
 4 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index f6f961f..06c138c 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,9 @@ gnome-commander 1.2.8.9
 Bug fixes:
  * ...
 
+New features:
+ * Support for shell-style wildcards in quick search
+
 
 ===================================
 gnome-commander 1.2.8.8
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 08a4b93..ff461f4 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -7440,6 +7440,14 @@
                         </listitem>
                     </itemizedlist>
                 </para>
+                <para>New features:</para>
+                <para>
+                    <itemizedlist>
+                        <listitem>
+                            <para>Support for shell-style wildcards in quick search</para>
+                        </listitem>
+                    </itemizedlist>
+                </para>
             </entry>
         </row>
         <row valign="top">
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 89e8d59..90e8859 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -138,9 +138,9 @@ gint gnome_cmd_key_snooper(GtkWidget *grab_widget, GdkEventKey *event, GnomeCmdM
     if (event->type!=GDK_KEY_PRESS)
         return FALSE;
 
-    if (!((event->keyval >= GDK_A && event->keyval <= GDK_Z) ||
-            (event->keyval >= GDK_a && event->keyval <= GDK_z) ||
-            (event->keyval == GDK_period)))
+    if (!(event->keyval >= GDK_A && event->keyval <= GDK_Z || event->keyval >= GDK_a && event->keyval <= GDK_z ||
+          event->keyval >= GDK_0 && event->keyval <= GDK_9 ||
+          event->keyval == GDK_period || event->keyval == GDK_asterisk || event->keyval == GDK_bracketleft))
         return FALSE;
 
     if (!gnome_cmd_data.alt_quick_search)
diff --git a/src/gnome-cmd-quicksearch-popup.cc b/src/gnome-cmd-quicksearch-popup.cc
index 8254b70..2cada7d 100644
--- a/src/gnome-cmd-quicksearch-popup.cc
+++ b/src/gnome-cmd-quicksearch-popup.cc
@@ -73,17 +73,13 @@ static void set_filter (GnomeCmdQuicksearchPopup *popup, const gchar *text)
         popup->priv->matches = NULL;
     }
 
+    gchar *pattern = g_strconcat (text, "*", NULL);
+
     for (GList *files = popup->priv->fl->get_visible_files(); files; files = files->next)
     {
         GnomeCmdFile *f = (GnomeCmdFile *) files->data;
-        gint res;
-
-        if (gnome_cmd_data.case_sens_sort)
-            res = strncmp (f->info->name, text, strlen(text));
-        else
-            res = strncasecmp (f->info->name, text, strlen(text));
 
-        if (res == 0)
+        if (gnome_cmd_filter_fnmatch (pattern, f->info->name, gnome_cmd_data.case_sens_sort))
         {
             if (first)
             {
@@ -95,6 +91,8 @@ static void set_filter (GnomeCmdQuicksearchPopup *popup, const gchar *text)
         }
     }
 
+    g_free (pattern);
+
     // If no file matches the new filter, focus on the last file that matched a previous filter
     if (popup->priv->matches==NULL && popup->priv->last_focused_file!=NULL)
         popup->priv->matches = g_list_append (popup->priv->matches, popup->priv->last_focused_file);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]