SF.net SVN: geany: [1663] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Wed Jul 4 17:08:54 UTC 2007
Revision: 1663
http://svn.sourceforge.net/geany/?rev=1663&view=rev
Author: eht16
Date: 2007-07-04 10:08:53 -0700 (Wed, 04 Jul 2007)
Log Message:
-----------
Fix focus problem when using the Find dialog.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/geany.docbook
trunk/src/callbacks.c
trunk/src/dialogs.c
trunk/src/dialogs.h
trunk/src/document.c
trunk/src/document.h
trunk/src/editor.c
trunk/src/project.c
trunk/src/search.c
trunk/src/utils.c
trunk/src/win32.c
trunk/src/win32.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/ChangeLog 2007-07-04 17:08:53 UTC (rev 1663)
@@ -1,7 +1,12 @@
2007-07-04 Enrico Tröger <enrico.troeger at 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 at btinternet.com>
Modified: trunk/doc/geany.docbook
===================================================================
--- trunk/doc/geany.docbook 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/doc/geany.docbook 2007-07-04 17:08:53 UTC (rev 1663)
@@ -1671,6 +1671,10 @@
<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>
</row>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/callbacks.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -170,7 +170,7 @@
}
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 @@
}
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 @@
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 @@
else
{
document_find_text(idx, search_data.text, search_data.flags,
- !search_data.backwards, TRUE);
+ !search_data.backwards, TRUE, NULL);
}
}
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/dialogs.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -370,7 +370,7 @@
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 @@
}
-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 @@
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 @@
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;
}
Modified: trunk/src/dialogs.h
===================================================================
--- trunk/src/dialogs.h 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/dialogs.h 2007-07-04 17:08:53 UTC (rev 1663)
@@ -50,8 +50,8 @@
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);
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/document.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -924,7 +924,7 @@
{
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 @@
* 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 @@
// 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 @@
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 @@
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 @@
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;
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/document.h 2007-07-04 17:08:53 UTC (rev 1663)
@@ -166,7 +166,7 @@
/* 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);
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/editor.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -1428,7 +1428,7 @@
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 @@
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
Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/project.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -497,7 +497,7 @@
{
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 @@
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))
Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/search.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -269,7 +269,7 @@
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 @@
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 @@
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 @@
}
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:
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/utils.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -350,7 +350,7 @@
{
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))
Modified: trunk/src/win32.c
===================================================================
--- trunk/src/win32.c 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/win32.c 2007-07-04 17:08:53 UTC (rev 1663)
@@ -234,7 +234,7 @@
{
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 @@
{
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 @@
{
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 @@
/* 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,8 +526,11 @@
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;
Modified: trunk/src/win32.h
===================================================================
--- trunk/src/win32.h 2007-07-04 14:41:58 UTC (rev 1662)
+++ trunk/src/win32.h 2007-07-04 17:08:53 UTC (rev 1663)
@@ -36,7 +36,7 @@
/* 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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list