~ubuntu-branches/ubuntu/maverick/gwhere/maverick

« back to all changes in this revision

Viewing changes to src/gui/gwmsgbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Sébastien LECACHEUR
  • Date: 2004-09-27 00:41:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040927004100-q23139ty7b94kryi
Tags: upstream-0.1.6
Import upstream version 0.1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  GWhere.
 
2
 *  Copyright (C) 2000  S�bastien LECACHEUR
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
 
 
20
#include "../gwsupport.h"
 
21
#include "gwmsgbox.h"
 
22
 
 
23
 
 
24
GtkWindow * gw_msg_box_create ( GtkWindow *window, gchar *title, gchar *subject)
 
25
{
 
26
        /*static */GtkWidget *w = NULL;
 
27
        GtkWidget *vbox,*label,*button,*hbox;
 
28
        GtkAccelGroup *accel;
 
29
        guint button_key;
 
30
        gchar *text_utf8 = NULL;
 
31
 
 
32
 
 
33
#ifdef GW_DEBUG_GUI_COMPONENT
 
34
        g_print ( "*** GW - %s (%d) :: %s() : title=%s subject=%s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, title, subject);
 
35
#endif
 
36
 
 
37
        if ( !w )
 
38
        {
 
39
#ifdef GW_DEBUG_GUI_COMPONENT
 
40
                g_print ( "*** GW - %s (%d) :: %s() new dialog window\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
 
41
#endif
 
42
 
 
43
                accel = gtk_accel_group_new ( );
 
44
 
 
45
                w = gtk_window_new ( GTK_WINDOW_DIALOG);
 
46
 
 
47
                gtk_window_set_policy ( GTK_WINDOW ( w), FALSE, FALSE, TRUE);
 
48
                g_strdup_to_gtk_text ( title, text_utf8);
 
49
                gtk_window_set_title ( GTK_WINDOW ( w), text_utf8);
 
50
                g_free ( text_utf8);
 
51
                gtk_container_border_width ( GTK_CONTAINER ( w), 10);
 
52
 
 
53
                gtk_window_set_modal ( GTK_WINDOW ( w),TRUE);
 
54
                gtk_window_set_transient_for ( GTK_WINDOW ( w), window);
 
55
                gtk_window_set_position ( GTK_WINDOW ( w), GTK_WIN_POS_CENTER);
 
56
 
 
57
                gtk_signal_connect ( GTK_OBJECT ( w), "destroy", GTK_SIGNAL_FUNC (gtk_widget_destroyed), &w);
 
58
 
 
59
                vbox = gtk_vbox_new ( TRUE, 10);
 
60
                gtk_container_add ( GTK_CONTAINER ( w), vbox);
 
61
                gtk_container_set_border_width ( GTK_CONTAINER ( vbox), 10);
 
62
 
 
63
                g_strdup_to_gtk_text ( subject, text_utf8);
 
64
                label = gtk_label_new ( text_utf8);
 
65
                gtk_label_set_text ( GTK_LABEL ( label), text_utf8);
 
66
                g_free ( text_utf8);
 
67
                gtk_box_pack_start ( GTK_BOX ( vbox), label, FALSE, FALSE, 0);
 
68
 
 
69
                /* The Ok button area */
 
70
                hbox = gtk_hbutton_box_new ( );
 
71
                gtk_button_box_set_layout ( GTK_BUTTON_BOX ( hbox), GTK_BUTTONBOX_EDGE);
 
72
                gtk_button_box_set_spacing ( GTK_BUTTON_BOX ( hbox), 5);
 
73
                gtk_box_pack_end ( GTK_BOX ( vbox), hbox, FALSE, FALSE, 0);
 
74
 
 
75
                button = gtk_button_new_with_label ( "");
 
76
                g_strdup_to_gtk_text ( _( "_OK"), text_utf8);
 
77
                button_key = gtk_label_parse_uline ( GTK_LABEL ( GTK_BIN ( button)->child), text_utf8);
 
78
                g_free ( text_utf8);
 
79
                gtk_widget_add_accelerator ( button, "clicked", accel, button_key, GDK_MOD1_MASK, 0);
 
80
                gtk_object_set_user_data ( GTK_OBJECT ( button), w);
 
81
                gtk_box_pack_start ( GTK_BOX ( hbox), button, TRUE, FALSE, 0);
 
82
                gtk_signal_connect_object ( GTK_OBJECT ( button), "clicked", GTK_SIGNAL_FUNC ( gtk_widget_destroy), GTK_OBJECT ( w));
 
83
                GTK_WIDGET_SET_FLAGS ( button, GTK_CAN_FOCUS);
 
84
                gtk_widget_grab_focus ( button);
 
85
 
 
86
                gtk_window_add_accel_group ( GTK_WINDOW ( w), accel);
 
87
        }
 
88
 
 
89
        if ( !GTK_WIDGET_VISIBLE ( w))
 
90
        {
 
91
                gtk_widget_show_all ( w);
 
92
        }
 
93
        else
 
94
        {
 
95
                gtk_widget_destroy ( w);
 
96
        }
 
97
 
 
98
        return GTK_WINDOW ( w);
 
99
}