]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/prtview/AboutDialog.cpp
GTK: wrap gtk_box_pack_start
[xonotic/netradiant.git] / contrib / prtview / AboutDialog.cpp
index b82a7a49a91fdc69fb18046297cf62c9607f1251..c517e6c1427b55cd2f4d0b9314415544b6124792 100644 (file)
-/*\r
-PrtView plugin for GtkRadiant\r
-Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com\r
-\r
-This library is free software; you can redistribute it and/or\r
-modify it under the terms of the GNU Lesser General Public\r
-License as published by the Free Software Foundation; either\r
-version 2.1 of the License, or (at your option) any later version.\r
-\r
-This library is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
-Lesser General Public License for more details.\r
-\r
-You should have received a copy of the GNU Lesser General Public\r
-License along with this library; if not, write to the Free Software\r
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-*/\r
-\r
-// AboutDialog.cpp : implementation file\r
-//\r
-\r
-#include "stdafx.h"\r
-\r
-#ifdef _DEBUG\r
-#define new DEBUG_NEW\r
-#undef THIS_FILE\r
-//static char THIS_FILE[] = __FILE__;\r
-#endif\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CAboutDialog dialog\r
-\r
-#ifdef GTK_PLUGIN\r
-\r
-static void dialog_button_callback (GtkWidget *widget, gpointer data)\r
-{\r
-  GtkWidget *parent;\r
-  int *loop, *ret;\r
-\r
-  parent = gtk_widget_get_toplevel (widget);\r
-  loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");\r
-  ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");\r
-\r
-  *loop = 0;\r
-  *ret = (int)data;\r
-}\r
-\r
-static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)\r
-{\r
-  int *loop;\r
-\r
-  gtk_widget_hide (widget);\r
-  loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");\r
-  *loop = 0;\r
-\r
-  return TRUE;\r
-}\r
-\r
-void DoAboutDlg ()\r
-{\r
-  GtkWidget *dlg, *hbox, *vbox, *button, *label;\r
-  int loop = 1, ret = IDCANCEL;\r
-\r
-  dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);\r
-  gtk_window_set_title (GTK_WINDOW (dlg), "About Portal Viewer");\r
-  gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",\r
-                      GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);\r
-  gtk_signal_connect (GTK_OBJECT (dlg), "destroy",\r
-                      GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);\r
-  g_object_set_data (G_OBJECT (dlg), "loop", &loop);\r
-  g_object_set_data (G_OBJECT (dlg), "ret", &ret);\r
-\r
-  hbox = gtk_hbox_new (FALSE, 10);\r
-  gtk_widget_show (hbox);\r
-  gtk_container_add (GTK_CONTAINER (dlg), hbox);\r
-  gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);\r
-\r
-  label = gtk_label_new ("Version 1.000\n\n"\r
-                        "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"\r
-                        "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"\r
-       "Built against GtkRadiant " RADIANT_VERSION "\n"\r
-       __DATE__\r
-       );\r
-  gtk_widget_show (label);\r
-  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);\r
-  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);\r
-\r
-  vbox = gtk_vbox_new (FALSE, 0);\r
-  gtk_widget_show (vbox);\r
-  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);\r
-\r
-  button = gtk_button_new_with_label ("OK");\r
-  gtk_widget_show (button);\r
-  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);\r
-  gtk_signal_connect (GTK_OBJECT (button), "clicked",\r
-                     GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));\r
-  gtk_widget_set_usize (button, 60, -2);\r
-\r
-  gtk_grab_add (dlg);\r
-  gtk_widget_show (dlg);\r
-\r
-  while (loop)\r
-    gtk_main_iteration ();\r
-\r
-  gtk_grab_remove (dlg);\r
-  gtk_widget_destroy (dlg);\r
-}\r
-\r
-#else // GTK_PLUGIN\r
-\r
-CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/)\r
-       : CDialog(CAboutDialog::IDD, pParent)\r
-{\r
-       //{{AFX_DATA_INIT(CAboutDialog)\r
-               // NOTE: the ClassWizard will add member initialization here\r
-       //}}AFX_DATA_INIT\r
-}\r
-\r
-\r
-void CAboutDialog::DoDataExchange(CDataExchange* pDX)\r
-{\r
-       CDialog::DoDataExchange(pDX);\r
-       //{{AFX_DATA_MAP(CAboutDialog)\r
-               // NOTE: the ClassWizard will add DDX and DDV calls here\r
-       //}}AFX_DATA_MAP\r
-}\r
-\r
-\r
-BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)\r
-       //{{AFX_MSG_MAP(CAboutDialog)\r
-               // NOTE: the ClassWizard will add message map macros here\r
-       //}}AFX_MSG_MAP\r
-END_MESSAGE_MAP()\r
-\r
-#endif // GTK_PLUGIN\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-// CAboutDialog message handlers\r
+/*
+   PrtView plugin for GtkRadiant
+   Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "AboutDialog.h"
+#include <gtk/gtk.h>
+#include <gtkutil/pointer.h>
+#include <uilib/uilib.h>
+#include "version.h"
+#include "gtkutil/pointer.h"
+
+#include "prtview.h"
+#include "ConfigDialog.h"
+
+static void dialog_button_callback( GtkWidget *widget, gpointer data ){
+       GtkWidget *parent;
+       int *loop, *ret;
+
+       parent = gtk_widget_get_toplevel( widget );
+       loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
+       ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" );
+
+       *loop = 0;
+       *ret = gpointer_to_int( data );
+}
+
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+       widget.hide();
+       int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
+       *loop = 0;
+       return TRUE;
+}
+
+void DoAboutDlg(){
+       int loop = 1, ret = IDCANCEL;
+
+       auto dlg = ui::Window(ui::window_type::TOP);
+       gtk_window_set_title(dlg, "About Portal Viewer");
+       dlg.connect("delete_event", G_CALLBACK(dialog_delete_callback), NULL);
+       dlg.connect("destroy", G_CALLBACK(gtk_widget_destroy), NULL);
+       g_object_set_data(G_OBJECT(dlg), "loop", &loop);
+       g_object_set_data(G_OBJECT(dlg), "ret", &ret);
+
+       auto hbox = ui::HBox(FALSE, 10);
+       hbox.show();
+       dlg.add(hbox);
+       gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
+
+       char const *label_text = "Version 1.000\n\n"
+                       "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"
+                       "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"
+                       "Built against NetRadiant " RADIANT_VERSION "\n"
+                       __DATE__;
+       auto label = ui::Label(label_text);
+       label.show();
+       hbox.pack_start( label, TRUE, TRUE, 0);
+       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+
+       auto vbox = ui::VBox(FALSE, 0);
+       vbox.show();
+       hbox.pack_start( vbox, FALSE, FALSE, 0);
+
+       auto button = ui::Button("OK");
+       button.show();
+       vbox.pack_start( button, FALSE, FALSE, 0);
+       button.connect("clicked", G_CALLBACK(dialog_button_callback), GINT_TO_POINTER(IDOK));
+       button.dimensions(60, -1);
+
+       gtk_grab_add(dlg);
+       dlg.show();
+
+       while (loop)
+               gtk_main_iteration();
+
+       gtk_grab_remove(dlg);
+       dlg.destroy();
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDialog message handlers