[gnome-commander/gcmd-1-2-8] Quick search using shell-style wildcards



commit 7adfc0dee50b325616ef707f3d31d0a6769b7ecb
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 7262cae..3fb84ca 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,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 8ddec10..6da685b 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -6067,6 +6067,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 bd460f7..41d695c 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -132,9 +132,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 07c286f..5aa79cd 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]