[gnome-commander] qsearch: enhancement for file name matching



commit 7f868f68812b8c9d88f63f73462c26907ffc60fa
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Thu Oct 7 21:57:43 2010 +0200

    qsearch: enhancement for file name matching

 NEWS                               |    1 +
 doc/C/gnome-commander.xml          |    3 +++
 src/gnome-cmd-data.cc              |    6 ++++++
 src/gnome-cmd-data.h               |    2 ++
 src/gnome-cmd-options-dialog.cc    |   14 +++++++++++++-
 src/gnome-cmd-quicksearch-popup.cc |    7 ++++++-
 6 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index acdbe00..68c0127 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ New features:
  * Revamped file properties dialog
  * One instance mode
  * User defined LS_COLORS colours
+ * Enhanced file name matching in quick search
  * New or updated docs: de, en, es, fr, sl
  * New or updated translations: da, es, eu, fr, hu, pl, ro, ru, sl, uk, zh_CN
  * New key bindings:
diff --git a/doc/C/gnome-commander.xml b/doc/C/gnome-commander.xml
index 31609ba..990f957 100644
--- a/doc/C/gnome-commander.xml
+++ b/doc/C/gnome-commander.xml
@@ -7431,6 +7431,9 @@
                             <para>User defined LS_COLORS colours</para>
                         </listitem>
                         <listitem>
+                            <para>Enhanced file name matching in quick search</para>
+                        </listitem>
+                        <listitem>
                             <para>New or updated docs: de, en, es, fr, sl</para>
                         </listitem>
                         <listitem>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index e650c42..14925cc 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -908,6 +908,8 @@ GnomeCmdData::GnomeCmdData()
     size_disp_mode = GNOME_CMD_SIZE_DISP_MODE_POWERED;
     perm_disp_mode = GNOME_CMD_PERM_DISP_MODE_TEXT;
     alt_quick_search = FALSE;
+    quick_search_exact_match_begin = TRUE;
+    quick_search_exact_match_end = FALSE;
 
     filter_type = Filter::TYPE_FNMATCH;
     memset(&filter_settings, 0, sizeof(filter_settings));
@@ -1183,6 +1185,8 @@ void GnomeCmdData::load()
     allow_multiple_instances = gnome_cmd_data_get_bool ("/programs/allow_multiple_instances", FALSE);
     use_internal_viewer = gnome_cmd_data_get_bool ("/programs/use_internal_viewer", TRUE);
     alt_quick_search = gnome_cmd_data_get_bool ("/programs/alt_quick_search", FALSE);
+    quick_search_exact_match_begin = gnome_cmd_data_get_bool ("/programs/quick_search_exact_match_begin", TRUE);
+    quick_search_exact_match_end = gnome_cmd_data_get_bool ("/programs/quick_search_exact_match_end", FALSE);
     skip_mounting = gnome_cmd_data_get_bool ("/programs/skip_mounting", FALSE);
 
     priv->symlink_prefix = gnome_cmd_data_get_string ("/options/symlink_prefix", _("link to %s"));
@@ -1586,6 +1590,8 @@ void GnomeCmdData::save()
     gnome_cmd_data_set_bool   ("/programs/allow_multiple_instances", allow_multiple_instances);
     gnome_cmd_data_set_bool   ("/programs/use_internal_viewer", use_internal_viewer);
     gnome_cmd_data_set_bool   ("/programs/alt_quick_search", alt_quick_search);
+    gnome_cmd_data_set_bool   ("/programs/quick_search_exact_match_begin", quick_search_exact_match_begin);
+    gnome_cmd_data_set_bool   ("/programs/quick_search_exact_match_end", quick_search_exact_match_end);
     gnome_cmd_data_set_bool   ("/programs/skip_mounting", skip_mounting);
 
     gnome_cmd_data_set_bool   ("/programs/toolbar_visibility", toolbar_visibility);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 2432e3b..9cafbd1 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -194,6 +194,8 @@ struct GnomeCmdData
     GnomeCmdSizeDispMode         size_disp_mode;
     GnomeCmdPermDispMode         perm_disp_mode;
     gboolean                     alt_quick_search;
+    gboolean                     quick_search_exact_match_begin;
+    gboolean                     quick_search_exact_match_end;
 
     Filter::Type                 filter_type;
     FilterSettings               filter_settings;
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 75beb93..351fbee 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -141,7 +141,7 @@ static GtkWidget *create_general_tab (GtkWidget *parent)
 
     // Quick search options
     cat_box = create_vbox (parent, FALSE, 0);
-    cat = create_category (parent, cat_box, _("Quick search using"));
+    cat = create_category (parent, cat_box, _("Quick search"));
     gtk_box_pack_start (GTK_BOX (vbox), cat, FALSE, TRUE, 0);
 
     radio = create_radio (parent, NULL, _("CTRL+ALT+letters"), "ctrl_alt_quick_search");
@@ -151,6 +151,14 @@ static GtkWidget *create_general_tab (GtkWidget *parent)
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), gnome_cmd_data.alt_quick_search);
 
+    check = create_check (parent, _("Match beginning of the file name"), "qsearch_exact_match_begin");
+    gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.quick_search_exact_match_begin);
+
+    check = create_check (parent, _("Match end of the file name"), "qsearch_exact_match_end");
+    gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), gnome_cmd_data.quick_search_exact_match_end);
+
 
     // Multiple instances
     cat_box = create_vbox (parent, FALSE, 0);
@@ -190,6 +198,8 @@ inline void store_general_options (GnomeCmdOptionsDialog *dialog)
     GtkWidget *case_sens_check = lookup_widget (GTK_WIDGET (dialog), "case_sens_check");
     GtkWidget *alt_quick_search = lookup_widget (GTK_WIDGET (dialog), "alt_quick_search");
     GtkWidget *multiple_instance_check = lookup_widget (GTK_WIDGET (dialog), "multiple_instance_check");
+    GtkWidget *qsearch_exact_match_begin = lookup_widget (GTK_WIDGET (dialog), "qsearch_exact_match_begin");
+    GtkWidget *qsearch_exact_match_end = lookup_widget (GTK_WIDGET (dialog), "qsearch_exact_match_end");
     GtkWidget *save_dirs = lookup_widget (GTK_WIDGET (dialog), "save_dirs");
     GtkWidget *save_tabs = lookup_widget (GTK_WIDGET (dialog), "save_tabs");
 
@@ -208,6 +218,8 @@ inline void store_general_options (GnomeCmdOptionsDialog *dialog)
     gnome_cmd_data.case_sens_sort = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (case_sens_check));
     gnome_cmd_data.alt_quick_search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (alt_quick_search));
     gnome_cmd_data.allow_multiple_instances = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (multiple_instance_check));
+    gnome_cmd_data.quick_search_exact_match_begin = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (qsearch_exact_match_begin));
+    gnome_cmd_data.quick_search_exact_match_end = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (qsearch_exact_match_end));
     gnome_cmd_data.save_dirs_on_exit = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_dirs));
     gnome_cmd_data.save_tabs_on_exit = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_tabs));
 }
diff --git a/src/gnome-cmd-quicksearch-popup.cc b/src/gnome-cmd-quicksearch-popup.cc
index 2cada7d..5a8a991 100644
--- a/src/gnome-cmd-quicksearch-popup.cc
+++ b/src/gnome-cmd-quicksearch-popup.cc
@@ -73,7 +73,12 @@ static void set_filter (GnomeCmdQuicksearchPopup *popup, const gchar *text)
         popup->priv->matches = NULL;
     }
 
-    gchar *pattern = g_strconcat (text, "*", NULL);
+    gchar *pattern;
+
+    if (gnome_cmd_data.quick_search_exact_match_begin)
+        pattern = gnome_cmd_data.quick_search_exact_match_end ? g_strdup (text) : g_strconcat (text, "*", NULL);
+    else
+        pattern = gnome_cmd_data.quick_search_exact_match_end ? g_strconcat ("*", text, NULL) : g_strconcat ("*", text, "*", NULL);
 
     for (GList *files = popup->priv->fl->get_visible_files(); files; files = files->next)
     {



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