From fb012d1a03ec0e3412500740281981278ab375b8 Mon Sep 17 00:00:00 2001 From: Theo Linkspfeifer Date: Tue, 12 Nov 2019 15:24:42 +0100 Subject: [PATCH 1/4] Add "Wrap around" check box to Find and Replace dialog (Bug #11290) --- mousepad/mousepad-replace-dialog.c | 18 ++++++++++++------ mousepad/mousepad-settings.h | 1 + mousepad/org.xfce.mousepad.gschema.xml | 9 ++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/mousepad/mousepad-replace-dialog.c b/mousepad/mousepad-replace-dialog.c index ac1d08f..267165e 100644 --- a/mousepad/mousepad-replace-dialog.c +++ b/mousepad/mousepad-replace-dialog.c @@ -66,8 +66,7 @@ enum enum { DIRECTION_UP = 0, - DIRECTION_DOWN, - DIRECTION_BOTH + DIRECTION_DOWN }; enum @@ -208,10 +207,9 @@ mousepad_replace_dialog_init (MousepadReplaceDialog *dialog) combo = gtk_combo_box_text_new (); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); - gtk_label_set_mnemonic_widget (GTK_LABEL(label), combo); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Up")); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Down")); - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Both")); gtk_widget_show (combo); mousepad_replace_dialog_bind_setting (dialog, MOUSEPAD_SETTING_SEARCH_DIRECTION, combo, "active"); @@ -219,6 +217,13 @@ mousepad_replace_dialog_init (MousepadReplaceDialog *dialog) /* release size group */ g_object_unref (G_OBJECT (size_group)); + /* wrap around */ + check = gtk_check_button_new_with_mnemonic (_("_Wrap around")); + gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0); + gtk_widget_show (check); + + mousepad_replace_dialog_bind_setting (dialog, MOUSEPAD_SETTING_SEARCH_WRAP_AROUND, check, "active"); + /* case sensitive */ check = gtk_check_button_new_with_mnemonic (_("Case sensi_tive")); gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0); @@ -304,11 +309,12 @@ mousepad_replace_dialog_response (GtkWidget *widget, const gchar *search_str, *replace_str; gchar *message; gint search_direction, replace_all_location; - gboolean match_case, match_whole_word, replace_all; + gboolean wrap_around, match_case, match_whole_word, replace_all; /* read the search settings */ search_direction = MOUSEPAD_SETTING_GET_INT (SEARCH_DIRECTION); replace_all_location = MOUSEPAD_SETTING_GET_INT (SEARCH_REPLACE_ALL_LOCATION); + wrap_around = MOUSEPAD_SETTING_GET_BOOLEAN (SEARCH_WRAP_AROUND); match_case = MOUSEPAD_SETTING_GET_BOOLEAN (SEARCH_MATCH_CASE); match_whole_word = MOUSEPAD_SETTING_GET_BOOLEAN (SEARCH_MATCH_WHOLE_WORD); replace_all = MOUSEPAD_SETTING_GET_BOOLEAN (SEARCH_REPLACE_ALL); @@ -332,7 +338,7 @@ mousepad_replace_dialog_response (GtkWidget *widget, flags |= MOUSEPAD_SEARCH_FLAGS_WHOLE_WORD; /* wrap around */ - if (search_direction == DIRECTION_BOTH && ! replace_all) + if (wrap_around) flags |= MOUSEPAD_SEARCH_FLAGS_WRAP_AROUND; /* search area */ diff --git a/mousepad/mousepad-settings.h b/mousepad/mousepad-settings.h index 4993045..511c8ab 100644 --- a/mousepad/mousepad-settings.h +++ b/mousepad/mousepad-settings.h @@ -59,6 +59,7 @@ G_BEGIN_DECLS /* State setting names */ #define MOUSEPAD_SETTING_SEARCH_DIRECTION "/state/search/direction" +#define MOUSEPAD_SETTING_SEARCH_WRAP_AROUND "/state/search/wrap-around" #define MOUSEPAD_SETTING_SEARCH_MATCH_CASE "/state/search/match-case" #define MOUSEPAD_SETTING_SEARCH_MATCH_WHOLE_WORD "/state/search/match-whole-word" #define MOUSEPAD_SETTING_SEARCH_REPLACE_ALL "/state/search/replace-all" diff --git a/mousepad/org.xfce.mousepad.gschema.xml b/mousepad/org.xfce.mousepad.gschema.xml index 105a14a..a622800 100644 --- a/mousepad/org.xfce.mousepad.gschema.xml +++ b/mousepad/org.xfce.mousepad.gschema.xml @@ -327,7 +327,7 @@ - + 1 search direction @@ -335,6 +335,13 @@ direction is forwards/downwards, when 2 the search will wrap around. + + false + Wrap around + + When true searches will wrap around, when false they will not. + + false Match case -- 2.20.1