[vinagre] Added vinagre_utils_ask_question()
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vinagre] Added vinagre_utils_ask_question()
- Date: Tue, 3 Nov 2009 19:58:08 +0000 (UTC)
commit 17e8c6787b609577f5481ab8980a8f35a2f7c9c9
Author: Jonh Wendell <jwendell gnome org>
Date: Tue Nov 3 16:46:56 2009 -0300
Added vinagre_utils_ask_question()
vinagre/vinagre-utils.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++
vinagre/vinagre-utils.h | 7 +++++-
2 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/vinagre/vinagre-utils.c b/vinagre/vinagre-utils.c
index ed96055..b0c2944 100644
--- a/vinagre/vinagre-utils.c
+++ b/vinagre/vinagre-utils.c
@@ -547,4 +547,58 @@ vinagre_gtk_button_new_with_stock_icon (const gchar *label,
return button;
}
+/**
+ * vinagre_utils_ask_question:
+ * @parent: transient parent, or NULL for none
+ * @message: The message to be displayed, if it contains multiple lines,
+ * the first one is considered as the title.
+ * @choices: NULL-terminated array of button's labels of the dialog
+ * @choice: Place to store the selected button. Zero is the first.
+ *
+ * Displays a dialog with a message and some options to the user.
+ *
+ * Returns TRUE if the user has selected any option, FALSE if the dialog
+ * was canceled.
+ */
+gboolean
+vinagre_utils_ask_question (GtkWindow *parent,
+ const char *message,
+ char **choices,
+ int *choice)
+{
+ gchar **messages;
+ GtkWidget *d;
+ int i, n_choices, result;
+
+ g_return_val_if_fail (message && choices && choice, FALSE);
+
+ messages = g_strsplit (message, "\n", 2);
+
+ d = gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ "%s",
+ messages[0]);
+
+ if (g_strv_length (messages) > 1)
+ gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (d),
+ "%s",
+ messages[1]);
+ g_strfreev (messages);
+
+ n_choices = g_strv_length (choices);
+ for (i = 0; i < n_choices; i++)
+ gtk_dialog_add_button (GTK_DIALOG (d), choices[i], i);
+
+ result = gtk_dialog_run (GTK_DIALOG (d));
+ gtk_widget_destroy (d);
+
+ if (result == GTK_RESPONSE_NONE || result == GTK_RESPONSE_DELETE_EVENT)
+ return FALSE;
+
+ *choice = result;
+ return TRUE;
+}
+
/* vim: set ts=8: */
diff --git a/vinagre/vinagre-utils.h b/vinagre/vinagre-utils.h
index 785e856..69b119e 100644
--- a/vinagre/vinagre-utils.h
+++ b/vinagre/vinagre-utils.h
@@ -2,7 +2,7 @@
* vinagre-utils.h
* This file is part of vinagre
*
- * Copyright (C) 2007,2008 - Jonh Wendell <wendell bani com br>
+ * Copyright (C) 2007,2008,2009 - Jonh Wendell <wendell bani com br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,5 +66,10 @@ gboolean vinagre_utils_parse_boolean (const gchar* value);
GtkWidget *vinagre_gtk_button_new_with_stock_icon (const gchar *label,
const gchar *stock_id);
+
+gboolean vinagre_utils_ask_question (GtkWindow *parent,
+ const char *message,
+ char **choices,
+ int *choice);
#endif /* __VINAGRE_UTILS_H__ */
/* vim: set ts=8: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]