]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
uncrustify! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / contrib / prtview / AboutDialog.cpp
1 /*
2    PrtView plugin for GtkRadiant
3    Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
4
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 // AboutDialog.cpp : implementation file
21 //
22
23 #include "stdafx.h"
24
25 #ifdef _DEBUG
26 #define new DEBUG_NEW
27 #undef THIS_FILE
28 //static char THIS_FILE[] = __FILE__;
29 #endif
30
31 /////////////////////////////////////////////////////////////////////////////
32 // CAboutDialog dialog
33
34 static void dialog_button_callback( GtkWidget *widget, gpointer data ){
35         GtkWidget *parent;
36         int *loop, *ret;
37
38         parent = gtk_widget_get_toplevel( widget );
39         loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
40         ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
41
42         *loop = 0;
43         *ret = (int)data;
44 }
45
46 static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
47         int *loop;
48
49         gtk_widget_hide( widget );
50         loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
51         *loop = 0;
52
53         return TRUE;
54 }
55
56 void DoAboutDlg(){
57         GtkWidget *dlg, *hbox, *vbox, *button, *label;
58         int loop = 1, ret = IDCANCEL;
59
60         dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
61         gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" );
62         gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
63                                                 GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
64         gtk_signal_connect( GTK_OBJECT( dlg ), "destroy",
65                                                 GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
66         g_object_set_data( G_OBJECT( dlg ), "loop", &loop );
67         g_object_set_data( G_OBJECT( dlg ), "ret", &ret );
68
69         hbox = gtk_hbox_new( FALSE, 10 );
70         gtk_widget_show( hbox );
71         gtk_container_add( GTK_CONTAINER( dlg ), hbox );
72         gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 );
73
74         label = gtk_label_new( "Version 1.000\n\n"
75                                                    "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
76                                                    "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
77                                                    "Built against GtkRadiant " RADIANT_VERSION "\n"
78                                                    __DATE__
79                                                    );
80         gtk_widget_show( label );
81         gtk_box_pack_start( GTK_BOX( hbox ), label, TRUE, TRUE, 0 );
82         gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT );
83
84         vbox = gtk_vbox_new( FALSE, 0 );
85         gtk_widget_show( vbox );
86         gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 );
87
88         button = gtk_button_new_with_label( "OK" );
89         gtk_widget_show( button );
90         gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 );
91         gtk_signal_connect( GTK_OBJECT( button ), "clicked",
92                                                 GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( IDOK ) );
93         gtk_widget_set_usize( button, 60, -2 );
94
95         gtk_grab_add( dlg );
96         gtk_widget_show( dlg );
97
98         while ( loop )
99                 gtk_main_iteration();
100
101         gtk_grab_remove( dlg );
102         gtk_widget_destroy( dlg );
103 }
104
105 /////////////////////////////////////////////////////////////////////////////
106 // CAboutDialog message handlers