]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
cmake: install global.xlink
[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 "gtkutil/pointer.h"
25
26 #include "prtview.h"
27 #include "ConfigDialog.h"
28
29 static void dialog_button_callback( ui::Widget widget, gpointer data ){
30         int *loop, *ret;
31
32         auto parent = widget.window();
33         loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
34         ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
35
36         *loop = 0;
37         *ret = gpointer_to_int( data );
38 }
39
40 static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
41         widget.hide();
42         int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
43         *loop = 0;
44         return TRUE;
45 }
46
47 void DoAboutDlg(){
48         int loop = 1, ret = IDCANCEL;
49
50         auto dlg = ui::Window(ui::window_type::TOP);
51         gtk_window_set_title(dlg, "About " PLUGIN_NAME);
52         dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL);
53         dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL);
54         g_object_set_data(G_OBJECT(dlg), "loop", &loop);
55         g_object_set_data(G_OBJECT(dlg), "ret", &ret);
56
57         auto hbox = ui::HBox(FALSE, 10);
58         hbox.show();
59         dlg.add(hbox);
60         gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
61
62         const char *label_text =
63                         PLUGIN_NAME " " PLUGIN_VERSION " for "
64                         RADIANT_NAME " " RADIANT_VERSION "\n\n"
65                         "Gtk port by Leonardo Zide <leo@lokigames.com>\n"
66                         "Written by Geoffrey DeWan <gdewan@prairienet.org>\n\n"
67                         "Built against "
68                         RADIANT_NAME " " RADIANT_VERSION_STRING "\n"
69                         __DATE__;
70
71         auto label = ui::Label(label_text);
72         label.show();
73         hbox.pack_start( label, TRUE, TRUE, 0);
74         gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
75
76         auto vbox = ui::VBox(FALSE, 0);
77         vbox.show();
78         hbox.pack_start( vbox, FALSE, FALSE, 0);
79
80         auto button = ui::Button("OK");
81         button.show();
82         vbox.pack_start( button, FALSE, FALSE, 0);
83         button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
84         button.dimensions(60, -1);
85
86         gtk_grab_add(dlg);
87         dlg.show();
88
89         while (loop)
90                 gtk_main_iteration();
91
92         gtk_grab_remove(dlg);
93         dlg.destroy();
94 }
95
96
97 /////////////////////////////////////////////////////////////////////////////
98 // CAboutDialog message handlers