# # # patch "AdvancedFind.pm" # from [c1b16b8bee1ad2c756404a2f542b860a9d4587f7] # to [9403bfc2e2ec4155da6ca1b6460d450efe5dcebf] # # patch "Common.pm" # from [d3591a613d333dcab84a11ff965b836cd882088a] # to [2071b3e516e2db9781963a6fed62fc169d571291] # # patch "FindFiles.pm" # from [9a53448f388865ef0aae2b9efaaa731296737f07] # to [a0a330c0bf3a006487a06c645ce78eb705de0f7d] # # patch "FindText.pm" # from [8e704f3b0b00cd3234c13a446365d83146432f5e] # to [bd4864c583ac0258554cbf366d52c028a587896f] # # patch "Preferences.pm" # from [4f874eb8f76d7a3896e7d787611f740b06dd4ed1] # to [ce39e679c617347077fda4a113fe215bd3522a2a] # ============================================================ --- AdvancedFind.pm c1b16b8bee1ad2c756404a2f542b860a9d4587f7 +++ AdvancedFind.pm 9403bfc2e2ec4155da6ca1b6460d450efe5dcebf @@ -618,8 +618,9 @@ sub get_advanced_find_window($) $instance->{search_term_comboboxentry}-> set_model(Gtk2::ListStore->new("Glib::String")); $instance->{search_term_comboboxentry}->set_text_column(0); - $instance->{query_history} = []; $instance->{term_combobox}->set_active(0); + handle_comboxentry_history($instance->{search_term_comboboxentry}, + "advanced_find"); # Setup the revisions list browser. @@ -963,7 +964,6 @@ sub update_advanced_find_state($$) if ($err eq "") { - my $found; if (scalar(@revision_ids) == 0) { my $dialog; @@ -976,30 +976,10 @@ sub update_advanced_find_state($$) $wm->allow_input(sub { $dialog->run(); }); $dialog->destroy(); } - $found = 0; - foreach my $entry (@{$advanced_find->{query_history}}) - { - if ($entry eq $query) - { - $found = 1; - last; - } - } - if (! $found) - { - if (unshift(@{$advanced_find->{query_history}}, $query) - > 20) - { - pop(@{$advanced_find->{query_history}}); - } - $advanced_find->{search_term_comboboxentry}->get_model()-> - clear(); - foreach my $entry (@{$advanced_find->{query_history}}) - { - $advanced_find->{search_term_comboboxentry}-> - append_text($entry); - } - } + handle_comboxentry_history + ($advanced_find->{search_term_comboboxentry}, + "advanced_find", + $query); } } ============================================================ --- Common.pm d3591a613d333dcab84a11ff965b836cd882088a +++ Common.pm 2071b3e516e2db9781963a6fed62fc169d571291 @@ -66,6 +66,7 @@ sub glade_signal_autoconnect($$); sub get_file_details($$$$$$); sub get_revision_ids($$;$); sub glade_signal_autoconnect($$); +sub handle_comboxentry_history($$;$); sub hex_dump($); sub open_database($$$); sub run_command($@); @@ -897,6 +898,89 @@ sub file_glob_to_regexp($) # ############################################################################## # +# Routine - handle_comboxentry_history +# +# Description - Handle comboboxentry histories. Histories are limited to a +# small fixed value and are stored to disk in the user's +# preferences file. +# +# Data - $widget : The comboboxentry that is to be updated. +# $history_name : The name of the history list that is to be +# updated or loaded. +# $value : The new value that is to be added to the +# specified history list and comboboxentry or +# undef if the comboboxentry is just to +# updated with the current history list. This +# is optional. +# +############################################################################## + + + +sub handle_comboxentry_history($$;$) +{ + + my($widget, $history_name, $value) = @_; + + my $update_history = 1; + my $history_ref = $user_preferences->{histories}->{$history_name}; + + # Update the comboxentry history list and save it to disk. + + if (defined($value)) + { + if ($value ne "") + { + foreach my $entry (@$history_ref) + { + if ($entry eq $value) + { + $update_history = 0; + last; + } + } + } + else + { + $update_history = 0; + } + if ($update_history) + { + pop(@$history_ref) if (unshift(@$history_ref, $value) > 20); + eval + { + save_preferences($user_preferences); + }; + if ($@ ne "") + { + chomp($@); + my $dialog = Gtk2::MessageDialog->new + (undef, + ["modal"], + "warning", + "close", + __("Your preferences could not be saved:\n") . $@); + $dialog->run(); + $dialog->destroy(); + } + } + } + + # Update the comboboxentry itself if necessary. + + if ($update_history) + { + $widget->get_model()->clear(); + foreach my $entry (@$history_ref) + { + $widget->append_text($entry); + } + } + +} +# +############################################################################## +# # Routine - create_format_tags # # Description - Creates the Gtk2::TextBuffer tags that are used to pretty ============================================================ --- FindFiles.pm 9a53448f388865ef0aae2b9efaaa731296737f07 +++ FindFiles.pm a0a330c0bf3a006487a06c645ce78eb705de0f7d @@ -85,7 +85,6 @@ sub size_comparitor_combobox_changed_cb( sub save_query_from_gui($); sub search_files_button_clicked_cb($$); sub size_comparitor_combobox_changed_cb($$); -sub update_comboxentries_history($$); sub validate_query($$); # ############################################################################## @@ -325,7 +324,15 @@ sub search_files_button_clicked_cb($$) # Update the comboxentries histories. - update_comboxentries_history($instance, $query); + handle_comboxentry_history($instance->{files_named_comboboxentry}, + "find_files_named", + $query->{file_glob}); + handle_comboxentry_history($instance->{files_containing_comboboxentry}, + "find_files_containing", + $query->{contents_pattern}); + handle_comboxentry_history($instance->{modified_by_comboboxentry}, + "find_files_modified_by", + $query->{modified_by}); # Build up a sub-manifest representing the items that we are going to # search. @@ -952,15 +959,12 @@ sub get_find_files_window() $instance->{files_named_comboboxentry}-> set_model(Gtk2::ListStore->new("Glib::String")); $instance->{files_named_comboboxentry}->set_text_column(0); - $instance->{files_named_history} = []; $instance->{files_containing_comboboxentry}-> set_model(Gtk2::ListStore->new("Glib::String")); $instance->{files_containing_comboboxentry}->set_text_column(0); - $instance->{files_containing_history} = []; $instance->{modified_by_comboboxentry}-> set_model(Gtk2::ListStore->new("Glib::String")); $instance->{modified_by_comboboxentry}->set_text_column(0); - $instance->{modified_by_history} = []; $instance->{size_comparitor_combobox}->set_active(CMP_ANY_SIZE); $instance->{size_units_combobox}->set_active(SIZE_KB); $instance->{time_units_combobox}->set_active(DURATION_DAYS); @@ -1018,6 +1022,15 @@ sub get_find_files_window() set_label_value($instance->{last_update_value_label}, ""); set_label_value($instance->{file_revision_id_value_label}, ""); + # Load in the comboboxentries histories. + + handle_comboxentry_history($instance->{files_named_comboboxentry}, + "find_files_named"); + handle_comboxentry_history($instance->{files_containing_comboboxentry}, + "find_files_containing"); + handle_comboxentry_history($instance->{modified_by_comboboxentry}, + "find_files_modified_by"); + return $instance; } @@ -1146,65 +1159,6 @@ sub validate_query($$) # ############################################################################## # -# Routine - update_comboxentries_history -# -# Description - Update all the histories for every comboboxentry widget in -# a in a find files window. -# -# Data - $instance : The associated window instance. -# $query : The query record containing what was saved from -# the GUI. -# -############################################################################## - - - -sub update_comboxentries_history($$) -{ - - my($instance, $query) = @_; - - my $found; - - # Update the comboxentries histories. - - for my $record ({widget => $instance->{files_named_comboboxentry}, - history => $instance->{files_named_history}, - value => $query->{file_glob}}, - {widget => $instance->{files_containing_comboboxentry}, - history => $instance->{files_containing_history}, - value => $query->{contents_pattern}}, - {widget => $instance->{modified_by_comboboxentry}, - history => $instance->{modified_by_history}, - value => $query->{modified_by}}) - { - $found = 0; - foreach my $entry (@{$record->{history}}) - { - if ($entry eq $record->{value}) - { - $found = 1; - last; - } - } - if (! $found) - { - if (unshift(@{$record->{history}}, $record->{value}) > 20) - { - pop(@{$record->{history}}); - } - $record->{widget}->get_model()->clear(); - foreach my $entry (@{$record->{history}}) - { - $record->{widget}->append_text($entry); - } - } - } - -} -# -############################################################################## -# # Routine - save_query_from_gui # # Description - Saves the query information from the find files window into ============================================================ --- FindText.pm 8e704f3b0b00cd3234c13a446365d83146432f5e +++ FindText.pm bd4864c583ac0258554cbf366d52c028a587896f @@ -399,27 +399,9 @@ sub find_button_clicked_cb($$) # Store the search term in the history. - $found = 0; - foreach my $entry (@{$instance->{search_history}}) - { - if ($entry eq $search_term) - { - $found = 1; - last; - } - } - if (! $found) - { - if (unshift(@{$instance->{search_history}}, $search_term) > 20) - { - pop(@{$instance->{search_history}}); - } - $instance->{find_comboboxentry}->get_model()->clear(); - foreach my $entry (@{$instance->{search_history}}) - { - $instance->{find_comboboxentry}->append_text($entry); - } - } + handle_comboxentry_history($instance->{find_comboboxentry}, + "find_text", + $search_term); # Work out where to start searching from. @@ -728,7 +710,6 @@ sub get_find_text_window($$) $instance->{find_comboboxentry}-> set_model(Gtk2::ListStore->new("Glib::String")); $instance->{find_comboboxentry}->set_text_column(0); - $instance->{search_history} = []; } else { @@ -743,6 +724,10 @@ sub get_find_text_window($$) $instance->{old_y} = 0; $instance->{old_search_term} = ""; + # Load in the comboboxentry history. + + handle_comboxentry_history($instance->{find_comboboxentry}, "find_text"); + # Make sure the find button is only enabled when there is something entered # into the comboboxentry widget. ============================================================ --- Preferences.pm 4f874eb8f76d7a3896e7d787611f740b06dd4ed1 +++ Preferences.pm ce39e679c617347077fda4a113fe215bd3522a2a @@ -60,7 +60,7 @@ use constant PREFERENCES_FILE_NAME => ". # Constant for the preferences file's format version. -use constant PREFERENCES_FORMAT_VERSION => 2; +use constant PREFERENCES_FORMAT_VERSION => 3; # Text viewable application mime types. @@ -1044,7 +1044,7 @@ sub get_preferences_window($$) $instance->{glade}->get_widget("file_name_pattern_entry"), $instance->{glade}->get_widget("file_actions_frame")]; - # Setup the advanced find window deletion handlers. + # Setup the preferences window deletion handlers. $instance->{window}->signal_connect ("delete_event", @@ -1118,7 +1118,7 @@ sub get_preferences_window($$) $instance->{file_name_patterns_treeview}->set_search_column(0); - # Update the advanced find dialog's state. + # Reparent the preferences window to the specified parent. $instance->{window}->set_transient_for($parent); @@ -1506,7 +1506,18 @@ sub upgrade_preferences($) { $preferences->{coloured_diffs} = 1; $preferences->{diffs_application} = "kompare '{file1}' '{file2}'"; + $preferences->{version} = 2; } + if ($preferences->{version} == 2) + { + $preferences->{histories} = {advanced_find => [], + find_files_named => [], + find_files_containing => [], + find_files_modified_by => [], + find_text => []}; + $preferences->{version} = 3; + } + $preferences->{version} = PREFERENCES_FORMAT_VERSION; } @@ -1559,7 +1570,12 @@ sub initialise_preferences() cmp_revision_2 => {fg => "DarkGreen", bg => "DarkSeaGreen1", hl => "SpringGreen1"}}, - mime_table => $mime_table); + mime_table => $mime_table, + histories => {advanced_find => [], + find_files_named => [], + find_files_containing => [], + find_files_modified_by => [], + find_text => []}); return \%preferences;