From c056f6b74993c1ab19ea3eb5da73db3ae0a4f1c5 Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Fri, 14 Dec 2012 19:43:01 -0300 Subject: [PATCH] Select files by coincidences (*%s*) by default instead of use one pattern. Add a check button, to use own patterns. --- thunar/thunar-standard-view-ui.xml | 2 +- thunar/thunar-standard-view.c | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/thunar/thunar-standard-view-ui.xml b/thunar/thunar-standard-view-ui.xml index b91d60e..277fd32 100644 --- a/thunar/thunar-standard-view-ui.xml +++ b/thunar/thunar-standard-view-ui.xml @@ -32,7 +32,7 @@ - + diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index e807296..80be11f 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -190,7 +190,7 @@ static void thunar_standard_view_action_paste_into_folder (Gtk ThunarStandardView *standard_view); static void thunar_standard_view_action_select_all_files (GtkAction *action, ThunarStandardView *standard_view); -static void thunar_standard_view_action_select_by_pattern (GtkAction *action, +static void thunar_standard_view_action_select_files (GtkAction *action, ThunarStandardView *standard_view); static void thunar_standard_view_action_selection_invert (GtkAction *action, ThunarStandardView *standard_view); @@ -393,7 +393,7 @@ static const GtkActionEntry action_entries[] = { "delete", GTK_STOCK_DELETE, N_ ("_Delete"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_delete), }, { "paste-into-folder", GTK_STOCK_PASTE, N_ ("Paste Into Folder"), NULL, N_ ("Move or copy files previously selected by a Cut or Copy command into the selected folder"), G_CALLBACK (thunar_standard_view_action_paste_into_folder), }, { "select-all-files", NULL, N_ ("Select _all Files"), NULL, N_ ("Select all files in this window"), G_CALLBACK (thunar_standard_view_action_select_all_files), }, - { "select-by-pattern", NULL, N_ ("Select _by Pattern..."), "S", N_ ("Select all files that match a certain pattern"), G_CALLBACK (thunar_standard_view_action_select_by_pattern), }, + { "select-files", NULL, N_ ("Select files..."), "S", N_ ("Select all files that match a certain word or pattern"), G_CALLBACK (thunar_standard_view_action_select_files), }, { "invert-selection", NULL, N_ ("_Invert Selection"), NULL, N_ ("Select all and only the items that are not currently selected"), G_CALLBACK (thunar_standard_view_action_selection_invert), }, { "duplicate", NULL, N_ ("Du_plicate"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_duplicate), }, { "make-link", NULL, N_ ("Ma_ke Link"), NULL, NULL, G_CALLBACK (thunar_standard_view_action_make_link), }, @@ -2538,23 +2538,25 @@ thunar_standard_view_action_select_all_files (GtkAction *action, static void -thunar_standard_view_action_select_by_pattern (GtkAction *action, - ThunarStandardView *standard_view) +thunar_standard_view_action_select_files (GtkAction *action, + ThunarStandardView *standard_view) { GtkWidget *window; GtkWidget *dialog; GtkWidget *hbox; GtkWidget *label; GtkWidget *entry; + GtkWidget *check; GList *paths; GList *lp; + gchar *pattern; gint response; _thunar_return_if_fail (GTK_IS_ACTION (action)); _thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view)); window = gtk_widget_get_toplevel (GTK_WIDGET (standard_view)); - dialog = gtk_dialog_new_with_buttons (_("Select by Pattern"), + dialog = gtk_dialog_new_with_buttons (_("Select files"), GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR @@ -2569,7 +2571,7 @@ thunar_standard_view_action_select_by_pattern (GtkAction *action, gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0); gtk_widget_show (hbox); - label = gtk_label_new_with_mnemonic (_("_Pattern:")); + label = gtk_label_new_with_mnemonic (_("_Filter:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); @@ -2578,11 +2580,24 @@ thunar_standard_view_action_select_by_pattern (GtkAction *action, gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry); gtk_widget_show (entry); + check = gtk_check_button_new_with_mnemonic (_("Select _by Pattern")); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), check, TRUE, TRUE, 0); + gtk_widget_show (check); + response = gtk_dialog_run (GTK_DIALOG (dialog)); if (response == GTK_RESPONSE_OK) { /* select all files that match the entered pattern */ - paths = thunar_list_model_get_paths_for_pattern (standard_view->model, gtk_entry_get_text (GTK_ENTRY (entry))); + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) + { + pattern = g_strdup(gtk_entry_get_text (GTK_ENTRY (entry))); + } + else + { + pattern = g_strdup_printf("*%s*", gtk_entry_get_text (GTK_ENTRY (entry))); + } + + paths = thunar_list_model_get_paths_for_pattern (standard_view->model, pattern); THUNAR_STANDARD_VIEW_GET_CLASS (standard_view)->unselect_all (standard_view); /* set the cursor and scroll to the first selected item */ @@ -2595,6 +2610,7 @@ thunar_standard_view_action_select_by_pattern (GtkAction *action, gtk_tree_path_free (lp->data); } g_list_free (paths); + g_free(pattern); } gtk_widget_destroy (dialog); -- 1.8.0.2