4
* Copyright (C) 2002 Sun Microsystems, Inc.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the
18
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
21
* Authors: Glynn Foster <glynn.foster@sun.com>
24
#include <glade/glade.h>
28
static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
31
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
33
GladeXML *glade_dialog;
37
switch (msg_data->mode) {
38
case ZENITY_MSG_WARNING:
39
glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog");
40
dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog");
41
text = glade_xml_get_widget (glade_dialog, "zenity_warning_text");
44
case ZENITY_MSG_QUESTION:
45
glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog");
46
dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog");
47
text = glade_xml_get_widget (glade_dialog, "zenity_question_text");
50
case ZENITY_MSG_ERROR:
51
glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog");
52
dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog");
53
text = glade_xml_get_widget (glade_dialog, "zenity_error_text");
57
glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog");
58
dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog");
59
text = glade_xml_get_widget (glade_dialog, "zenity_info_text");
66
g_assert_not_reached ();
70
g_signal_connect (G_OBJECT (dialog), "response",
71
G_CALLBACK (zenity_msg_dialog_response), data);
73
if (glade_dialog == NULL) {
74
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
78
glade_xml_signal_autoconnect (glade_dialog);
81
g_object_unref (glade_dialog);
83
if (data->dialog_title)
84
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
86
switch (msg_data->mode) {
87
case ZENITY_MSG_WARNING:
88
zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING);
91
case ZENITY_MSG_QUESTION:
92
zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION);
95
case ZENITY_MSG_ERROR:
96
zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR);
100
zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_INFO);
107
if (data->width > -1 || data->height > -1)
108
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
110
if (msg_data->dialog_text)
111
gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text);
113
zenity_util_show_dialog (dialog);
118
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
120
ZenityData *zen_data = data;
123
case GTK_RESPONSE_OK:
124
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
127
case GTK_RESPONSE_CANCEL:
128
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
132
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);