]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
Wean off #define
[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 <gtkutil/pointer.h>
23 #include <uilib/uilib.h>
24 #include "version.h"
25 #include "gtkutil/pointer.h"
26
27 #include "prtview.h"
28 #include "ConfigDialog.h"
29
30 static void dialog_button_callback( GtkWidget *widget, gpointer data ){
31         GtkWidget *parent;
32         int *loop, *ret;
33
34         parent = gtk_widget_get_toplevel( widget );
35         loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
36         ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
37
38         *loop = 0;
39         *ret = gpointer_to_int( data );
40 }
41
42 static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
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         int loop = 1, ret = IDCANCEL;
54
55         auto dlg = ui::Window(ui::window_type::TOP);
56         gtk_window_set_title(dlg, "About Portal Viewer");
57         dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL);
58         dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL);
59         g_object_set_data(G_OBJECT(dlg), "loop", &loop);
60         g_object_set_data(G_OBJECT(dlg), "ret", &ret);
61
62         auto hbox = ui::HBox(FALSE, 10);
63         hbox.show();
64         dlg.add(hbox);
65         gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
66
67         char const *label_text = "Version 1.000\n\n"
68                         "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
69                         "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
70                         "Built against NetRadiant " RADIANT_VERSION "\n"
71                         __DATE__;
72         auto label = ui::Label(label_text);
73         label.show();
74         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
75         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
76
77         auto vbox = ui::VBox(FALSE, 0);
78         vbox.show();
79         gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
80
81         auto button = ui::Button("OK");
82         button.show();
83         gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
84         button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
85         button.dimensions(60, -1);
86
87         gtk_grab_add(dlg);
88         dlg.show();
89
90         while (loop)
91                 gtk_main_iteration();
92
93         gtk_grab_remove(dlg);
94         gtk_widget_destroy(dlg);
95 }
96
97
98 /////////////////////////////////////////////////////////////////////////////
99 // CAboutDialog message handlers