]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
bd85103a9240bcb70231d3cef17692af52a04096
[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 #include "AboutDialog.h"
21 #include <gtk/gtk.h>
22 #include "version.h"
23 #include "gtkutil/pointer.h"
24
25 #include "prtview.h"
26 #include "ConfigDialog.h"
27
28 static void dialog_button_callback (GtkWidget *widget, gpointer data)
29 {
30   GtkWidget *parent;
31   int *loop, *ret;
32
33   parent = gtk_widget_get_toplevel (widget);
34   loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");
35   ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");
36
37   *loop = 0;
38   *ret = gpointer_to_int(data);
39 }
40
41 static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)
42 {
43   int *loop;
44
45   gtk_widget_hide (widget);
46   loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");
47   *loop = 0;
48
49   return TRUE;
50 }
51
52 void DoAboutDlg ()
53 {
54   GtkWidget *dlg, *hbox, *vbox, *button, *label;
55   int loop = 1, ret = IDCANCEL;
56
57   dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
58   gtk_window_set_title (GTK_WINDOW (dlg), "About Portal Viewer");
59   gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",
60                       GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);
61   gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
62                       GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);
63   g_object_set_data (G_OBJECT (dlg), "loop", &loop);
64   g_object_set_data (G_OBJECT (dlg), "ret", &ret);
65
66   hbox = gtk_hbox_new (FALSE, 10);
67   gtk_widget_show (hbox);
68   gtk_container_add (GTK_CONTAINER (dlg), hbox);
69   gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
70
71   label = gtk_label_new ("Version 1.000\n\n"
72                          "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
73                          "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
74        "Built against GtkRadiant " RADIANT_VERSION "\n"
75        __DATE__
76        );
77   gtk_widget_show (label);
78   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
79   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
80
81   vbox = gtk_vbox_new (FALSE, 0);
82   gtk_widget_show (vbox);
83   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
84
85   button = gtk_button_new_with_label ("OK");
86   gtk_widget_show (button);
87   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
88   gtk_signal_connect (GTK_OBJECT (button), "clicked",
89                       GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
90   gtk_widget_set_usize (button, 60, -2);
91
92   gtk_grab_add (dlg);
93   gtk_widget_show (dlg);
94
95   while (loop)
96     gtk_main_iteration ();
97
98   gtk_grab_remove (dlg);
99   gtk_widget_destroy (dlg);
100 }
101
102
103 /////////////////////////////////////////////////////////////////////////////
104 // CAboutDialog message handlers