2
* Copyright (C) 2000 S�bastien LECACHEUR
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "../gwsupport.h"
21
#include "gwdialogbox.h"
24
/*! @define GW_REF_DIALOG_BOX_PARENT_WINDOW The parent window */
25
#define GW_REF_DIALOG_BOX_PARENT_WINDOW "gw_ref_dialog_box_parent_window"
26
/*! @define GW_REF_DIALOG_BOX_USER_DATA The attached user data */
27
#define GW_REF_DIALOG_BOX_USER_DATA "gw_ref_dialog_box_user_data"
30
GtkWidget * gw_dialog_box_create ( GtkWindow *window, gchar *title, gchar *text, GtkSignalFunc ok, GtkSignalFunc no, GtkSignalFunc cancel, gpointer data)
32
/*static */GtkWidget *w = NULL;
37
gchar *text_utf8 = NULL;
40
#ifdef GW_DEBUG_GUI_COMPONENT
41
g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
46
accel = gtk_accel_group_new ( );
48
w = gtk_dialog_new ( );
52
gtk_window_set_modal ( GTK_WINDOW ( w), TRUE);
53
gtk_window_set_transient_for ( GTK_WINDOW ( w), GTK_WINDOW ( window));
54
gtk_object_set_data ( GTK_OBJECT ( w), GW_REF_DIALOG_BOX_PARENT_WINDOW, window);
59
gtk_object_set_data ( GTK_OBJECT ( w), GW_REF_DIALOG_BOX_USER_DATA, data);
62
gtk_window_set_position ( GTK_WINDOW ( w), GTK_WIN_POS_CENTER);
63
gtk_container_set_border_width ( GTK_CONTAINER ( w), 10);
64
gtk_window_set_policy ( GTK_WINDOW ( w), FALSE, FALSE, TRUE);
67
gtk_signal_connect ( GTK_OBJECT ( w), "destroy", GTK_SIGNAL_FUNC ( gtk_widget_destroyed), &w);
69
g_strdup_to_gtk_text ( title, text_utf8);
70
gtk_window_set_title ( GTK_WINDOW ( w), text_utf8);
73
g_strdup_to_gtk_text ( text, text_utf8);
74
label = gtk_label_new ( text_utf8);
76
gtk_misc_set_padding ( GTK_MISC ( label), 10, 10);
77
gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG ( w)->vbox), label, TRUE, TRUE, 0);
79
button = gtk_button_new_with_label ( "");
80
g_strdup_to_gtk_text ( _( "_OK"), text_utf8);
81
button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
83
gtk_widget_add_accelerator ( button, "clicked", accel, button_key, GDK_MOD1_MASK, 0);
87
gtk_signal_connect ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( ok), w);
91
gtk_signal_connect_object ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));
94
gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG ( w)->action_area), button, TRUE, TRUE, 0);
95
gtk_widget_grab_focus ( button);
97
button = gtk_button_new_with_label ( "");
98
g_strdup_to_gtk_text ( _("_No"), text_utf8);
99
button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
101
gtk_widget_add_accelerator ( button, "clicked", accel, button_key, GDK_MOD1_MASK, 0);
105
gtk_signal_connect ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( no), w);
109
gtk_signal_connect_object ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));
112
gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG ( w)->action_area), button, TRUE, TRUE, 0);
114
button = gtk_button_new_with_label ( "");
115
g_strdup_to_gtk_text ( _("_Cancel"), text_utf8);
116
button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
118
gtk_widget_add_accelerator ( button, "clicked", accel, button_key, GDK_MOD1_MASK, 0);
120
if ( cancel != NULL )
122
gtk_signal_connect ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( cancel), w);
126
gtk_signal_connect_object ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));
129
gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG ( w)->action_area), button, TRUE, TRUE, 0);
131
gtk_window_add_accel_group ( GTK_WINDOW ( w), accel);
134
if ( !GTK_WIDGET_VISIBLE ( w) )
136
gtk_widget_show_all ( w);
140
gtk_widget_destroy ( w);
147
gpointer gw_dialog_box_get_user_data ( GtkWindow *w)
149
gpointer data = NULL;
152
#ifdef GW_DEBUG_GUI_COMPONENT
153
g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
158
data = gtk_object_get_data ( GTK_OBJECT ( w), GW_REF_DIALOG_BOX_USER_DATA);
165
GtkWindow * gw_dialog_box_get_parent_window ( GtkWindow *w)
167
GtkWindow *window = NULL;
170
#ifdef GW_DEBUG_GUI_COMPONENT
171
g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
176
window = gtk_object_get_data ( GTK_OBJECT ( w), GW_REF_DIALOG_BOX_PARENT_WINDOW);