]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
contrib/prtview: unify about dialog construction
authorThomas Debesse <dev@illwieckz.net>
Sat, 4 Apr 2020 01:10:12 +0000 (03:10 +0200)
committerThomas Debesse <dev@illwieckz.net>
Sat, 4 Apr 2020 05:46:51 +0000 (07:46 +0200)
contrib/prtview/AboutDialog.cpp [deleted file]
contrib/prtview/AboutDialog.h [deleted file]
contrib/prtview/CMakeLists.txt
contrib/prtview/prtview.cpp

diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp
deleted file mode 100644 (file)
index 32b6f92..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-   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 "gtkutil/pointer.h"
-
-#include "prtview.h"
-#include "ConfigDialog.h"
-
-static void dialog_button_callback( ui::Widget widget, gpointer data ){
-       int *loop, *ret;
-
-       auto parent = widget.window();
-       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 " PLUGIN_NAME);
-       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);
-
-       const char *label_text =
-                       PLUGIN_NAME " " PLUGIN_VERSION " for "
-                       RADIANT_NAME " " RADIANT_VERSION "\n\n"
-                       "Gtk port by Leonardo Zide <leo@lokigames.com>\n"
-                       "Written by Geoffrey DeWan <gdewan@prairienet.org>\n\n"
-                       "Built against "
-                       RADIANT_NAME " " RADIANT_VERSION_STRING "\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
diff --git a/contrib/prtview/AboutDialog.h b/contrib/prtview/AboutDialog.h
deleted file mode 100644 (file)
index b46fa93..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-   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
- */
-
-#if !defined( INCLUDED_ABOUTDIALOG_H )
-#define INCLUDED_ABOUTDIALOG_H
-
-void DoAboutDlg();
-
-#endif
index f08707f1368a46c9beebaf14cbaacc01dc0e5b60..c54e49a65c5a2dabccc5dfd19dd842c2e46472b2 100644 (file)
@@ -1,5 +1,4 @@
 radiant_plugin(prtview
-        AboutDialog.cpp AboutDialog.h
         ConfigDialog.cpp ConfigDialog.h
         LoadPortalFileDialog.cpp LoadPortalFileDialog.h
         portals.cpp portals.h
index 26783004aa03bba0c6bc1b04e343d8046f66e352..62aa2a9f4456f9b3456caae758fd205d4ae17225 100644 (file)
@@ -31,7 +31,6 @@
 #include "stream/stringstream.h"
 
 #include "portals.h"
-#include "AboutDialog.h"
 #include "ConfigDialog.h"
 #include "LoadPortalFileDialog.h"
 
@@ -66,6 +65,7 @@ const char *TRANS_3D = "Transparency";
 const char *CLIP_RANGE = "ClipRange";
 const char *CLIP = "Clip";
 
+ui::Window main_window{ui::null};
 
 void PrtView_construct(){
        StringOutputStream tmp( 64 );
@@ -200,6 +200,9 @@ static const char *PLUGIN_COMMANDS =
 
 
 const char* QERPlug_Init( void *hApp, void* pMainWidget ){
+       main_window = ui::Window::from(pMainWidget);
+       ASSERT_TRUE( main_window );
+
        return PLUGIN_NAME " for " RADIANT_NAME;
 }
 
@@ -221,7 +224,19 @@ void QERPlug_Dispatch( const char* p, float* vMin, float* vMax, bool bSingleBrus
        globalOutputStream() << MSG_PREFIX "Command \"" << p << "\"\n";
 
        if ( !strcmp( p,Q3R_CMD_ABOUT ) ) {
-               DoAboutDlg();
+               const char *label_text =
+                               PLUGIN_NAME " " PLUGIN_VERSION " for "
+                               RADIANT_NAME " " RADIANT_VERSION "\n\n"
+                               "Gtk port by Leonardo Zide <leo@lokigames.com>\n"
+                               "Written by Geoffrey DeWan <gdewan@prairienet.org>\n\n"
+                               "Built against "
+                               RADIANT_NAME " " RADIANT_VERSION_STRING "\n"
+                               __DATE__;
+
+               GlobalRadiant().m_pfnMessageBox( main_window, label_text,
+                                                                               "About " PLUGIN_NAME,
+                                                                               eMB_OK,
+                                                                               eMB_ICONDEFAULT );
        }
        else if ( !strcmp( p,Q3R_CMD_LOAD ) ) {
                if ( DoLoadPortalFileDialog() == IDOK ) {