Fix focus problem when using the Find dialog.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1663 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
f90fc4f005
commit
6069531e78
@ -1,7 +1,12 @@
|
||||
2007-07-04 Enrico Tröger <enrico.troeger@uvena.de>
|
||||
|
||||
* geany.glade, src/interface.c, src/keybindings.c, src/keybindings.h:
|
||||
* geany.glade, doc/geany.docbook, src/interface.c, src/keybindings.c,
|
||||
src/keybindings.h:
|
||||
Change Help shortcut to F1, use Ctrl-H for Replace.
|
||||
* src/callbacks.c, src/dialogs.c, src/dialogs.h, src/document.c,
|
||||
src/document.h, src/editor.c, src/project.c, src/search.c,
|
||||
src/utils.c, src/win32.c, src/win32.h:
|
||||
Fix focus problem when using the Find dialog.
|
||||
|
||||
|
||||
2007-07-04 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||
|
@ -1670,6 +1670,10 @@ widget "GeanyPrefsDialog" style "geanyStyle"
|
||||
<entry>Preferences</entry>
|
||||
<entry>Opens preferences dialog.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>Help</entry>
|
||||
<entry>Opens the manual.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>Find Next</entry>
|
||||
<entry>Finds next result.</entry>
|
||||
|
@ -170,7 +170,7 @@ on_exit_clicked (GtkWidget *widget, gpointer gdata)
|
||||
}
|
||||
else
|
||||
if (! app->pref_main_confirm_exit ||
|
||||
dialogs_show_question_full(GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL,
|
||||
dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL,
|
||||
_("Do you really want to quit?")))
|
||||
{
|
||||
quit_app();
|
||||
@ -487,7 +487,7 @@ on_reload_as_activate (GtkMenuItem *menuitem,
|
||||
}
|
||||
|
||||
basename = g_path_get_basename(doc_list[idx].file_name);
|
||||
if (dialogs_show_question_full(_("_Reload"), GTK_STOCK_CANCEL,
|
||||
if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
|
||||
_("Any unsaved changes will be lost."),
|
||||
_("Are you sure you want to reload '%s'?"), basename))
|
||||
{
|
||||
@ -1322,7 +1322,7 @@ on_find_next1_activate (GtkMenuItem *menuitem,
|
||||
if (search_data.text)
|
||||
{
|
||||
document_find_text(idx, search_data.text, search_data.flags,
|
||||
search_data.backwards, TRUE);
|
||||
search_data.backwards, TRUE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1340,7 +1340,7 @@ on_find_previous1_activate (GtkMenuItem *menuitem,
|
||||
else
|
||||
{
|
||||
document_find_text(idx, search_data.text, search_data.flags,
|
||||
!search_data.backwards, TRUE);
|
||||
!search_data.backwards, TRUE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ void dialogs_show_msgbox(gint type, const gchar *text, ...)
|
||||
va_end(args);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
win32_message_dialog(type, string);
|
||||
win32_message_dialog(NULL, type, string);
|
||||
#else
|
||||
dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
type, GTK_BUTTONS_OK, "%s", string);
|
||||
@ -1057,21 +1057,23 @@ void dialogs_show_file_properties(gint idx)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
show_question(const gchar *yes_btn, const gchar *no_btn, const gchar *question_text,
|
||||
const gchar *extra_text)
|
||||
static gboolean show_question(GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn,
|
||||
const gchar *question_text, const gchar *extra_text)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
#ifdef G_OS_WIN32
|
||||
gchar *string = (extra_text == NULL) ? g_strdup(question_text) :
|
||||
g_strconcat(question_text, "\n\n", extra_text, NULL);
|
||||
|
||||
ret = win32_message_dialog(GTK_MESSAGE_QUESTION, string);
|
||||
ret = win32_message_dialog(parent, GTK_MESSAGE_QUESTION, string);
|
||||
g_free(string);
|
||||
#else
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = gtk_message_dialog_new(GTK_WINDOW(app->window),
|
||||
if (parent == NULL)
|
||||
parent = app->window;
|
||||
|
||||
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");
|
||||
@ -1102,14 +1104,15 @@ gboolean dialogs_show_question(const gchar *text, ...)
|
||||
va_start(args, text);
|
||||
g_vsnprintf(string, 511, text, args);
|
||||
va_end(args);
|
||||
ret = show_question(GTK_STOCK_YES, GTK_STOCK_NO, string, NULL);
|
||||
ret = show_question(app->window, GTK_STOCK_YES, GTK_STOCK_NO, string, NULL);
|
||||
g_free(string);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* extra_text can be NULL; otherwise it is displayed below main_text. */
|
||||
gboolean dialogs_show_question_full(const gchar *yes_btn, const gchar *no_btn,
|
||||
/* extra_text can be NULL; otherwise it is displayed below main_text.
|
||||
* if parent is NULL, app->window will be used */
|
||||
gboolean dialogs_show_question_full(GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn,
|
||||
const gchar *extra_text, const gchar *main_text, ...)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
@ -1119,7 +1122,7 @@ gboolean dialogs_show_question_full(const gchar *yes_btn, const gchar *no_btn,
|
||||
va_start(args, main_text);
|
||||
g_vsnprintf(string, 511, main_text, args);
|
||||
va_end(args);
|
||||
ret = show_question(yes_btn, no_btn, string, extra_text);
|
||||
ret = show_question(parent, yes_btn, no_btn, string, extra_text);
|
||||
g_free(string);
|
||||
return ret;
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ void dialogs_show_file_properties(gint idx);
|
||||
gboolean dialogs_show_question(const gchar *text, ...) G_GNUC_PRINTF (1, 2);
|
||||
|
||||
/* extra_text can be NULL; otherwise it is displayed below main_text. */
|
||||
gboolean dialogs_show_question_full(const gchar *yes_btn, const gchar *no_btn,
|
||||
const gchar *extra_text, const gchar *main_text, ...) G_GNUC_PRINTF (4, 5);
|
||||
gboolean dialogs_show_question_full(GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn,
|
||||
const gchar *extra_text, const gchar *main_text, ...) G_GNUC_PRINTF (5, 6);
|
||||
|
||||
void dialogs_show_msgbox(gint type, const gchar *text, ...) G_GNUC_PRINTF (2, 3);
|
||||
|
||||
|
@ -924,7 +924,7 @@ gint document_reload_file(gint idx, const gchar *forced_enc)
|
||||
{
|
||||
gint pos = 0;
|
||||
|
||||
if (idx < 0 || ! doc_list[idx].is_valid)
|
||||
if (! DOC_IDX_VALID(idx))
|
||||
return -1;
|
||||
|
||||
// try to set the cursor to the position before reloading
|
||||
@ -1151,7 +1151,7 @@ void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean
|
||||
* Returns -1 on failure or the start position of the matching text.
|
||||
* Will skip past any selection, ignoring it. */
|
||||
gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards,
|
||||
gboolean scroll)
|
||||
gboolean scroll, GtkWidget *parent)
|
||||
{
|
||||
gint selection_end, selection_start, search_pos, first_visible_line;
|
||||
|
||||
@ -1198,13 +1198,13 @@ gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search
|
||||
|
||||
// we searched only part of the document, so ask whether to wraparound.
|
||||
if (app->pref_main_suppress_search_dialogs ||
|
||||
dialogs_show_question_full(GTK_STOCK_FIND, GTK_STOCK_CANCEL,
|
||||
dialogs_show_question_full(parent, GTK_STOCK_FIND, GTK_STOCK_CANCEL,
|
||||
_("Wrap search and find again?"), _("\"%s\" was not found."), text))
|
||||
{
|
||||
gint ret;
|
||||
|
||||
sci_set_current_position(doc_list[idx].sci, (search_backwards) ? sci_len : 0, FALSE);
|
||||
ret = document_find_text(idx, text, flags, search_backwards, scroll);
|
||||
ret = document_find_text(idx, text, flags, search_backwards, scroll, parent);
|
||||
if (ret == -1)
|
||||
{ // return to original cursor position if not found
|
||||
sci_set_current_position(doc_list[idx].sci, selection_start, FALSE);
|
||||
@ -1234,7 +1234,7 @@ gint document_replace_text(gint idx, const gchar *find_text, const gchar *replac
|
||||
if (selection_end == selection_start)
|
||||
{
|
||||
// no selection so just find the next match
|
||||
document_find_text(idx, find_text, flags, search_backwards, TRUE);
|
||||
document_find_text(idx, find_text, flags, search_backwards, TRUE, NULL);
|
||||
return -1;
|
||||
}
|
||||
// there's a selection so go to the start before finding to search through it
|
||||
@ -1244,7 +1244,7 @@ gint document_replace_text(gint idx, const gchar *find_text, const gchar *replac
|
||||
else
|
||||
sci_goto_pos(doc_list[idx].sci, selection_start, TRUE);
|
||||
|
||||
search_pos = document_find_text(idx, find_text, flags, search_backwards, TRUE);
|
||||
search_pos = document_find_text(idx, find_text, flags, search_backwards, TRUE, NULL);
|
||||
// return if the original selected text did not match (at the start of the selection)
|
||||
if (search_pos != selection_start) return -1;
|
||||
|
||||
@ -1782,8 +1782,9 @@ void document_print(gint idx)
|
||||
cmdline = g_strdup(app->tools_print_cmd);
|
||||
cmdline = utils_str_replace(cmdline, "%f", doc_list[idx].file_name);
|
||||
|
||||
if (dialogs_show_question(_("The file \"%s\" will be printed with the following command:\n\n%s"),
|
||||
doc_list[idx].file_name, cmdline))
|
||||
if (dialogs_show_question(
|
||||
_("The file \"%s\" will be printed with the following command:\n\n%s"),
|
||||
doc_list[idx].file_name, cmdline))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
|
@ -166,7 +166,7 @@ void document_search_bar_find(gint idx, const gchar *text, gint flags, gboolean
|
||||
/* General search function, used from the find dialog.
|
||||
* Returns -1 on failure or the start position of the matching text. */
|
||||
gint document_find_text(gint idx, const gchar *text, gint flags, gboolean search_backwards,
|
||||
gboolean scroll);
|
||||
gboolean scroll, GtkWidget *parent);
|
||||
|
||||
gint document_replace_text(gint idx, const gchar *find_text, const gchar *replace_text,
|
||||
gint flags, gboolean search_backwards);
|
||||
|
@ -1428,7 +1428,7 @@ static void real_uncomment_multiline(gint idx)
|
||||
if (idx == -1 || ! doc_list[idx].is_valid || doc_list[idx].file_type == NULL) return;
|
||||
|
||||
// remove comment open chars
|
||||
pos = document_find_text(idx, doc_list[idx].file_type->comment_open, 0, TRUE, FALSE);
|
||||
pos = document_find_text(idx, doc_list[idx].file_type->comment_open, 0, TRUE, FALSE, NULL);
|
||||
SSM(doc_list[idx].sci, SCI_DELETEBACK, 0, 0);
|
||||
|
||||
// check whether the line is empty and can be deleted
|
||||
@ -1441,7 +1441,7 @@ static void real_uncomment_multiline(gint idx)
|
||||
g_free(linebuf);
|
||||
|
||||
// remove comment close chars
|
||||
pos = document_find_text(idx, doc_list[idx].file_type->comment_close, 0, FALSE, FALSE);
|
||||
pos = document_find_text(idx, doc_list[idx].file_type->comment_close, 0, FALSE, FALSE, NULL);
|
||||
SSM(doc_list[idx].sci, SCI_DELETEBACK, 0, 0);
|
||||
|
||||
// check whether the line is empty and can be deleted
|
||||
|
@ -497,7 +497,7 @@ static gboolean close_open_project()
|
||||
{
|
||||
if (app->project != NULL)
|
||||
{
|
||||
if (dialogs_show_question_full(GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
||||
if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
||||
_("Do you want to close it before proceeding?"),
|
||||
_("The '%s' project is already open. "), app->project->name))
|
||||
{
|
||||
@ -552,7 +552,7 @@ static gboolean update_config(const PropertyDialogElements *e)
|
||||
gchar *locale_path = utils_get_locale_from_utf8(base_path);
|
||||
if (! g_file_test(locale_path, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
if (dialogs_show_question_full(GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
||||
if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
||||
_("Create the project's base path directory?"),
|
||||
_("The path \"%s\" does not exist."),
|
||||
base_path))
|
||||
|
@ -269,7 +269,7 @@ void search_find_selection(gint idx, gboolean search_backwards)
|
||||
if (s)
|
||||
{
|
||||
setup_find_next(s); // allow find next/prev
|
||||
document_find_text(idx, s, 0, search_backwards, TRUE);
|
||||
document_find_text(idx, s, 0, search_backwards, TRUE, NULL);
|
||||
g_free(s);
|
||||
}
|
||||
}
|
||||
@ -848,7 +848,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
case GEANY_RESPONSE_FIND:
|
||||
case GEANY_RESPONSE_FIND_PREVIOUS:
|
||||
document_find_text(idx, search_data.text, search_data.flags,
|
||||
(response == GEANY_RESPONSE_FIND_PREVIOUS), TRUE);
|
||||
(response == GEANY_RESPONSE_FIND_PREVIOUS), TRUE, GTK_WIDGET(dialog));
|
||||
check_close = FALSE;
|
||||
if (app->pref_main_suppress_search_dialogs)
|
||||
check_close = TRUE;
|
||||
@ -954,7 +954,7 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
search_backwards_re);
|
||||
if (rep != -1)
|
||||
document_find_text(idx, find, search_flags_re, search_backwards_re,
|
||||
TRUE);
|
||||
TRUE, NULL);
|
||||
break;
|
||||
}
|
||||
case GEANY_RESPONSE_REPLACE:
|
||||
@ -965,7 +965,8 @@ on_replace_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
}
|
||||
case GEANY_RESPONSE_FIND:
|
||||
{
|
||||
document_find_text(idx, find, search_flags_re, search_backwards_re, TRUE);
|
||||
document_find_text(idx, find, search_flags_re, search_backwards_re, TRUE,
|
||||
GTK_WIDGET(dialog));
|
||||
break;
|
||||
}
|
||||
case GEANY_RESPONSE_REPLACE_IN_FILE:
|
||||
|
@ -350,7 +350,7 @@ gboolean utils_check_disk_status(gint idx, gboolean force)
|
||||
{
|
||||
gchar *basename = g_path_get_basename(doc_list[idx].file_name);
|
||||
|
||||
if (dialogs_show_question_full(_("_Reload"), GTK_STOCK_CANCEL,
|
||||
if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
|
||||
_("Do you want to reload it?"),
|
||||
_("The file '%s' on the disk is more recent than\n"
|
||||
"the current buffer."), basename))
|
||||
|
13
src/win32.c
13
src/win32.c
@ -234,7 +234,7 @@ gchar *win32_show_project_open_dialog(const gchar *title, const gchar *initial_d
|
||||
{
|
||||
gchar *error;
|
||||
error = g_strdup_printf("File dialog box error (%x)", (int)CommDlgExtendedError());
|
||||
win32_message_dialog(GTK_MESSAGE_ERROR, error);
|
||||
win32_message_dialog(NULL, GTK_MESSAGE_ERROR, error);
|
||||
g_free(error);
|
||||
}
|
||||
g_free(fname);
|
||||
@ -294,7 +294,7 @@ gboolean win32_show_file_dialog(gboolean file_open)
|
||||
{
|
||||
gchar error[100];
|
||||
snprintf(error, sizeof error, "File dialog box error (%x)", (int)CommDlgExtendedError());
|
||||
win32_message_dialog(GTK_MESSAGE_ERROR, error);
|
||||
win32_message_dialog(NULL, GTK_MESSAGE_ERROR, error);
|
||||
}
|
||||
g_free(fname);
|
||||
return FALSE;
|
||||
@ -453,7 +453,7 @@ void win32_show_pref_file_dialog(GtkEntry *item)
|
||||
{
|
||||
gchar error[100];
|
||||
snprintf(error, sizeof error, "File dialog box error (%x)", (int)CommDlgExtendedError());
|
||||
win32_message_dialog(GTK_MESSAGE_ERROR, error);
|
||||
win32_message_dialog(NULL, GTK_MESSAGE_ERROR, error);
|
||||
}
|
||||
g_strfreev(field);
|
||||
g_free(fname);
|
||||
@ -483,7 +483,7 @@ void win32_show_pref_file_dialog(GtkEntry *item)
|
||||
/* Creates a native Windows message box of the given type and returns always TRUE
|
||||
* or FALSE representing th pressed Yes or No button.
|
||||
* If type is not GTK_MESSAGE_QUESTION, it returns always TRUE. */
|
||||
gboolean win32_message_dialog(GtkMessageType type, const gchar *msg)
|
||||
gboolean win32_message_dialog(GtkWidget *parent, GtkMessageType type, const gchar *msg)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
gint rc;
|
||||
@ -526,7 +526,10 @@ gboolean win32_message_dialog(GtkMessageType type, const gchar *msg)
|
||||
MultiByteToWideChar(CP_UTF8, 0, title, -1, w_title, sizeof(w_title)/sizeof(w_title[0]));
|
||||
|
||||
// display the message box
|
||||
rc = MessageBoxW(GDK_WINDOW_HWND(app->window->window), w_msg, w_title, t);
|
||||
if (parent == NULL)
|
||||
parent = app->window;
|
||||
|
||||
rc = MessageBoxW(GDK_WINDOW_HWND(parent->window), w_msg, w_title, t);
|
||||
|
||||
if (type == GTK_MESSAGE_QUESTION && rc != IDYES)
|
||||
ret = FALSE;
|
||||
|
@ -36,7 +36,7 @@ void win32_show_color_dialog(const gchar *colour);
|
||||
/* Creates a native Windows message box of the given type and returns always TRUE
|
||||
* or FALSE representing th pressed Yes or No button.
|
||||
* If type is not GTK_MESSAGE_QUESTION, it returns always TRUE. */
|
||||
gboolean win32_message_dialog(GtkMessageType type, const gchar *msg);
|
||||
gboolean win32_message_dialog(GtkWidget *parent, GtkMessageType type, const gchar *msg);
|
||||
|
||||
/* Special dialog to ask for an action when closing an unsaved file */
|
||||
gint win32_message_dialog_unsaved(const gchar *msg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user