Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: GitHub noreply@github.com Date: Sat, 23 Nov 2024 17:46:36 UTC Commit: 4a07dd715e600a801ada4015f321642173edaec9 https://github.com/geany/geany/commit/4a07dd715e600a801ada4015f321642173edae...
Log Message: ----------- Merge pull request #4042 from techee/find_wrap
Make "Find" the default button in the wrap search dialog
Modified Paths: -------------- src/document.c
Modified: src/document.c 39 lines changed, 37 insertions(+), 2 deletions(-) =================================================================== @@ -2307,6 +2307,42 @@ gboolean document_search_bar_find(GeanyDocument *doc, const gchar *text, gboolea }
+/* like dialogs_show_question_full() but makes the non-cancel button default */ +static gboolean show_wrap_search_dialog(GtkWidget *parent, const gchar *search_text) +{ + gboolean ret; + GtkWidget *dialog; + GtkWidget *btn; + gchar *question_text; + + if (parent == NULL && main_status.main_window_realized) + parent = main_widgets.window; + + question_text = g_strdup_printf(_(""%s" was not found."), search_text); + + dialog = gtk_message_dialog_new(GTK_WINDOW(parent), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, + GTK_BUTTONS_NONE, "%s", question_text); + gtk_widget_set_name(dialog, "GeanyDialog"); + gtk_window_set_title(GTK_WINDOW(dialog), _("Question")); + gtk_window_set_icon_name(GTK_WINDOW(dialog), "geany"); + + gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), + "%s", _("Wrap search and find again?")); + + gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_NO); + btn = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_FIND, GTK_RESPONSE_YES); + gtk_widget_grab_default(btn); + + ret = gtk_dialog_run(GTK_DIALOG(dialog)); + + gtk_widget_destroy(dialog); + g_free(question_text); + + return ret == GTK_RESPONSE_YES; +} + + /* General search function, used from the find dialog. * Returns -1 on failure or the start position of the matching text. * Will skip past any selection, ignoring it. @@ -2370,8 +2406,7 @@ gint document_find_text(GeanyDocument *doc, const gchar *text, const gchar *orig
/* we searched only part of the document, so ask whether to wraparound. */ if (search_prefs.always_wrap || - dialogs_show_question_full(parent, GTK_STOCK_FIND, GTK_STOCK_CANCEL, - _("Wrap search and find again?"), _(""%s" was not found."), original_text)) + show_wrap_search_dialog(parent, original_text)) { gint ret;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).