SF.net SVN: geany: [736] trunk/src
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Aug 18 17:23:02 UTC 2006
Revision: 736
Author: ntrel
Date: 2006-08-18 10:22:57 -0700 (Fri, 18 Aug 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=736&view=rev
Log Message:
-----------
Add dialogs_show_question_full for custom buttons and extra text; Don't show message dialogs in the window manager taskbar
Modified Paths:
--------------
trunk/src/dialogs.c
trunk/src/dialogs.h
Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c 2006-08-18 16:17:38 UTC (rev 735)
+++ trunk/src/dialogs.c 2006-08-18 17:22:57 UTC (rev 736)
@@ -223,7 +223,7 @@
win32_message_dialog(GTK_MESSAGE_INFO, string);
#else
- dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "%s", string);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -247,7 +247,7 @@
#ifdef G_OS_WIN32
win32_message_dialog(GTK_MESSAGE_ERROR, string);
#else
- dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(GTK_WINDOW(app->window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", string);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -1384,30 +1384,69 @@
}
-gboolean dialogs_show_question(const gchar *text, ...)
+static gboolean
+show_question(const gchar *yes_btn, const gchar *no_btn, const gchar *question_text,
+ const gchar *extra_text)
{
-#ifndef G_OS_WIN32
+ 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);
+ g_free(string);
+#else
GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new(GTK_WINDOW(app->window),
+ GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, "%s", question_text);
+ // question_text will be in bold if optional extra_text used
+ if (extra_text != NULL)
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+ "%s", extra_text);
+
+ // For a cancel button, use cancel reponse so user can press escape to cancel
+ gtk_dialog_add_button(GTK_DIALOG(dialog), no_btn,
+ g_str_equal(no_btn, GTK_STOCK_CANCEL) ? GTK_RESPONSE_CANCEL : GTK_RESPONSE_NO);
+ gtk_dialog_add_button(GTK_DIALOG(dialog), yes_btn, GTK_RESPONSE_YES);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
+ ret = TRUE;
+ gtk_widget_destroy(dialog);
#endif
+ return ret;
+}
+
+
+gboolean dialogs_show_question(const gchar *text, ...)
+{
+ gboolean ret = FALSE;
gchar *string = g_malloc(512);
- gboolean ret = FALSE;
va_list args;
va_start(args, text);
g_vsnprintf(string, 511, text, args);
va_end(args);
+ ret = show_question(GTK_STOCK_YES, GTK_STOCK_NO, string, NULL);
+ g_free(string);
+ return ret;
+}
-#ifdef G_OS_WIN32
- ret = win32_message_dialog(GTK_MESSAGE_QUESTION, string);
-#else
- dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s", string);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES)
- ret = TRUE;
- gtk_widget_destroy(dialog);
-#endif
+
+/* 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, ...)
+{
+ gboolean ret = FALSE;
+ gchar *string = g_malloc(512);
+ va_list args;
+
+ 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);
g_free(string);
-
return ret;
}
Modified: trunk/src/dialogs.h
===================================================================
--- trunk/src/dialogs.h 2006-08-18 16:17:38 UTC (rev 735)
+++ trunk/src/dialogs.h 2006-08-18 17:22:57 UTC (rev 736)
@@ -63,6 +63,10 @@
gboolean dialogs_show_question(const gchar *text, ...);
+/* 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, ...);
+
void dialogs_show_keyboard_shortcuts(void);
#endif
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