2009-12-01 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / messagebox.cpp
blobe643d34d8aecbb2642fe7bd75a6cb874a5eada71
1 /*
2 * messagebox.cpp: MessageBox dialog
4 * Contact:
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2007, 2009 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
13 #include <config.h>
14 #include "messagebox.h"
16 int
17 message_box_show (const char *caption, const char* text, int buttons)
19 if (!caption || !text)
20 return MESSAGE_BOX_RESULT_NONE;
22 // NOTE: this dialog is displayed even WITHOUT any user action
23 //if (!Deployment::GetCurrent ()->GetSurface ()->IsUserInitiatedEvent ())
24 // return MESSAGE_BOX_RESULT_NONE;
26 GtkButtonsType bt = buttons == MESSAGE_BOX_BUTTON_OK ? GTK_BUTTONS_OK : GTK_BUTTONS_OK_CANCEL;
28 GtkWidget *widget = gtk_message_dialog_new (NULL,
29 GTK_DIALOG_MODAL,
30 GTK_MESSAGE_OTHER,
31 bt,
32 text);
34 gtk_window_set_title (GTK_WINDOW (widget), caption);
36 gint result = gtk_dialog_run (GTK_DIALOG (widget));
37 gtk_widget_destroy (widget);
39 switch (result) {
40 case GTK_RESPONSE_OK:
41 return MESSAGE_BOX_RESULT_OK;
42 case GTK_RESPONSE_CANCEL:
43 return MESSAGE_BOX_RESULT_CANCEL;
44 case GTK_RESPONSE_YES:
45 return MESSAGE_BOX_RESULT_YES;
46 case GTK_RESPONSE_NO:
47 return MESSAGE_BOX_RESULT_NO;
48 case GTK_RESPONSE_NONE:
49 default:
50 return MESSAGE_BOX_RESULT_NONE;