summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-03-03 07:05:31 -0500
committerMatthias Clasen <mclasen@redhat.com>2014-03-03 07:18:39 -0500
commit441d8f6858f8872309d7a469167722409c8ed463 (patch)
tree96e4ab6bb12f85bd47f37fe33e68857424e107ec /tests
parent77fced56fc1d6c1b4184854f95b413f9d8a6e580 (diff)
downloadgtk+-441d8f6858f8872309d7a469167722409c8ed463.tar.gz
testdialogs: Add message dialog examples
Related to https://bugzilla.gnome.org/show_bug.cgi?id=723668
Diffstat (limited to 'tests')
-rw-r--r--tests/testdialog.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/testdialog.c b/tests/testdialog.c
index 5683d181be..e1c2f7c69d 100644
--- a/tests/testdialog.c
+++ b/tests/testdialog.c
@@ -1,6 +1,48 @@
#include <gtk/gtk.h>
static void
+show_message_dialog1 (GtkWindow *parent)
+{
+ GtkWidget *dialog;
+
+ dialog = GTK_WIDGET (gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_DESTROY_WITH_PARENT|
+ GTK_DIALOG_USE_HEADER_BAR,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "Oops! Something went wrong."));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "Unhandled error message: SSH program unexpectedly exited");
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
+
+static void
+show_message_dialog2 (GtkWindow *parent)
+{
+ GtkWidget *dialog;
+
+ dialog = GTK_WIDGET (gtk_message_dialog_new (parent,
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_DESTROY_WITH_PARENT|
+ GTK_DIALOG_USE_HEADER_BAR,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_NONE,
+ "Empty all items from Wastebasket?"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "All items in the Wastebasket will be permanently deleted");
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ "Cancel", GTK_RESPONSE_CANCEL,
+ "Empty Wastebasket", GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+}
+
+static void
show_color_chooser (GtkWindow *parent)
{
GtkWidget *dialog;
@@ -253,6 +295,17 @@ main (int argc, char *argv[])
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (vbox), box);
+ button = gtk_button_new_with_label ("Message dialog");
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (show_message_dialog1), window);
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ button = gtk_button_new_with_label ("Confirmation dialog");
+ g_signal_connect_swapped (button, "clicked", G_CALLBACK (show_message_dialog2), window);
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ button = gtk_button_new_with_label ("Builtin");
button = gtk_button_new_with_label ("Builtin");
g_signal_connect_swapped (button, "clicked", G_CALLBACK (show_color_chooser), window);
gtk_widget_show (button);