]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
Revert partially (auto) "reformat code! 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 #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( ui::Widget widget, gpointer data ){
31         int *loop, *ret;
32
33         auto parent = widget.window();
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( ui::Widget widget, GdkEvent* event, gpointer data ){
42         widget.hide();
43         int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
44         *loop = 0;
45         return TRUE;
46 }
47
48 void DoAboutDlg(){
49         int loop = 1, ret = IDCANCEL;
50
51         auto dlg = ui::Window(ui::window_type::TOP);
52         gtk_window_set_title(dlg, "About Portal Viewer");
53         dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL);
54         dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL);
55         g_object_set_data(G_OBJECT(dlg), "loop", &loop);
56         g_object_set_data(G_OBJECT(dlg), "ret", &ret);
57
58         auto hbox = ui::HBox(FALSE, 10);
59         hbox.show();
60         dlg.add(hbox);
61         gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
62
63         char const *label_text = "Version 1.000\n\n"
64                         "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
65                         "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
66                         "Built against NetRadiant " RADIANT_VERSION "\n"
67                         __DATE__;
68         auto label = ui::Label(label_text);
69         label.show();
70         hbox.pack_start( label, TRUE, TRUE, 0);
71         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
72
73         auto vbox = ui::VBox(FALSE, 0);
74         vbox.show();
75         hbox.pack_start( vbox, FALSE, FALSE, 0);
76
77         auto button = ui::Button("OK");
78         button.show();
79         vbox.pack_start( button, FALSE, FALSE, 0);
80         button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
81         button.dimensions(60, -1);
82
83         gtk_grab_add(dlg);
84         dlg.show();
85
86         while (loop)
87                 gtk_main_iteration();
88
89         gtk_grab_remove(dlg);
90         dlg.destroy();
91 }
92
93
94 /////////////////////////////////////////////////////////////////////////////
95 // CAboutDialog message handlers