]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Wrap GtkWindow
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 07:26:47 +0000 (18:26 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 17 Feb 2016 07:26:47 +0000 (18:26 +1100)
17 files changed:
contrib/bobtoolz/dialogs/dialogs-gtk.cpp
contrib/brushexport/interface.cpp
contrib/camera/dialogs.cpp
contrib/gtkgensurf/gendlgs.cpp
contrib/gtkgensurf/view.cpp
contrib/hydratoolz/plugin.cpp
contrib/prtview/AboutDialog.cpp
contrib/prtview/ConfigDialog.cpp
contrib/prtview/LoadPortalFileDialog.cpp
contrib/sunplug/sunplug.cpp
libs/gtkutil/window.cpp
libs/uilib/uilib.cpp
libs/uilib/uilib.h
plugins/textool/TexTool.cpp
radiant/dialog.cpp
radiant/gtkdlgs.cpp
radiant/mainframe.cpp

index 22c00dd9ff8626dde787e7a51498a91966905748..359148dd0612dad3ec41a91eb415655b810fb35a 100644 (file)
@@ -214,7 +214,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = ui::Widget(gtk_window_new( GTK_WINDOW_TOPLEVEL ));
+       window = ui::Window( ui::window_type::TOP );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy",
@@ -328,7 +328,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -426,7 +426,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -600,7 +600,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
 
        const gchar    *text = "Please set a value in the boxes below and press 'OK' to build the stairs";
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -856,7 +856,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -1071,7 +1071,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -1242,7 +1242,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -1313,7 +1313,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -1649,7 +1649,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        EMessageBoxReturn ret;
        int loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -1912,7 +1912,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
 
        const gchar    *text = "Please set a value in the boxes below and press 'OK' to make a chain";
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
 
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
index 3c73a6a6de2e6730c73e8d8e118cb9ff64743873..e9688ac2a17fcd211e398e7f9ea3a1146e056345 100644 (file)
@@ -41,7 +41,7 @@ create_w_plugplug2( void ){
 
        tooltips = gtk_tooltips_new();
 
-       w_plugplug2 = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       w_plugplug2 = ui::Window( ui::window_type::TOP );
        gtk_widget_set_name( w_plugplug2, "w_plugplug2" );
        gtk_window_set_title( GTK_WINDOW( w_plugplug2 ), "BrushExport-Plugin 3.0 by namespace" );
        gtk_window_set_position( GTK_WINDOW( w_plugplug2 ), GTK_WIN_POS_CENTER );
index 5515c400cc39fadcf18e7a84bb3c8d96783c1eae..0100f9b23d748731e86d53b3717eeccbe35a4ed6 100644 (file)
@@ -69,7 +69,7 @@ static gint ci_new( GtkWidget *widget, gpointer data ){
 //     char buf[128];
 
        // create the window
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( window ), "New Camera" );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -362,7 +362,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){
        }
 
        // create the window
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -481,7 +481,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){
        }
 
        // create the window
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( window ), "Add Target" );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -829,7 +829,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){
        }
 
        // create the window
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( window ), "Add Event" );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
@@ -995,7 +995,7 @@ GtkWidget *CreateCameraInspectorDialog( void ){
        GtkWidget *window, *w, *vbox, *hbox, *table, *frame;
 
        // create the window
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event", GTK_SIGNAL_FUNC( ci_close ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
index c1cdb8cbb650ad74589c5eb1c27b2d26553b1f59..089054c68bfac94ebfa87df0f05ad18578f15953 100644 (file)
@@ -1355,7 +1355,7 @@ GtkWidget* create_main_dialog(){
        const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
                                                                   "Wall facing 180","Wall facing 270" };
 
-       g_pWnd = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       g_pWnd = dlg = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption );
        g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( main_close ), NULL );
        //  g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (gtk_widget_destroy), NULL);
index 639808094427dc65e1d84e04a428481ea9b6b8bc..84912c3df8bad65c866f3eb995e91d6b68ec8ec2 100644 (file)
@@ -371,7 +371,7 @@ void CreateViewWindow(){
        azimuth   = PI / 6.;
 #endif
 
-       g_pWndPreview = dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       g_pWndPreview = dlg = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" );
        gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event", GTK_SIGNAL_FUNC( preview_close ), NULL );
        gtk_signal_connect( GTK_OBJECT( dlg ), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
index 703b52adb3d0a85c06e415d353acff71494f8188..311eab2e96b61b48af8ac29ab9e5f5d557749cc8 100644 (file)
@@ -84,7 +84,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){
        GtkWidget *window, *w, *vbox, *hbox;
        int mode = ( uType & MB_TYPEMASK ), ret, loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy",
index 3d3fce12716e28f339b89f5a59a48dadc83462ad..198380427ed4c0c737d6711cff31626a902f81c0 100644 (file)
@@ -53,7 +53,7 @@ void DoAboutDlg(){
        GtkWidget *dlg, *hbox, *vbox, *button, *label;
        int loop = 1, ret = IDCANCEL;
 
-       dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       dlg = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" );
        gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
index 22aa138eef0d62cae220045bc20fbda11d209f52..26cc21df194f077b19734063877fcc8715908791 100644 (file)
@@ -246,7 +246,7 @@ void DoConfigDialog(){
        GtkWidget *show2check, *show3check, *portalcheck;
        int loop = 1, ret = IDCANCEL;
 
-       dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       dlg = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" );
        gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
index 075bbda8deb74d6c0b88abbe1d0cde2fcffb5463..a2a9fbbf896404c581d495d82d9c8631800f4d1e 100644 (file)
@@ -108,7 +108,7 @@ int DoLoadPortalFileDialog(){
        GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d;
        int loop = 1, ret = IDCANCEL;
 
-       dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       dlg = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" );
        gtk_signal_connect( GTK_OBJECT( dlg ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
index 7455d492906978d25a280d4d819738074b27fbfb..c9d5d73f4a6a78891becc57dc5d3dd7c24956c75 100644 (file)
@@ -256,7 +256,7 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server
 void about_plugin_window(){
        GtkWidget *window, *vbox, *label, *button;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create a window
+       window = ui::Window( ui::window_type::TOP ); // create a window
        gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
        g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event
        g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
@@ -321,7 +321,7 @@ void MapCoordinator(){
        char line[20];
 
        // in any case we need a window to show the user what to do
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); // create the window
+       window = ui::Window( ui::window_type::TOP ); // create the window
        gtk_window_set_transient_for( GTK_WINDOW( window ), SunPlug::main_window ); // make the window to stay in front of the main window
        g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window
        g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window
index ce40028746c542e529b929dccee914182b1bb16f..2c34e509fccaf45dce1a77f2623343eb3acc246b 100644 (file)
@@ -83,7 +83,7 @@ guint connect_floating_window_destroy_present( GtkWindow* floating, GtkWindow* m
 }
 
 GtkWindow* create_floating_window( const char* title, GtkWindow* parent ){
-       GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
+       GtkWindow* window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( window, title );
 
        if ( parent != 0 ) {
index 484cbb073e588352752833dc588cc46abf87d5c0..0e40539d5f25af7a395d61fcb9fe63dd7d99aac5 100644 (file)
@@ -56,6 +56,13 @@ namespace ui {
         return ::file_dialog(*this, open, title, path, pattern, want_load, want_import, want_save);
     }
 
+    Window::Window(window_type type)
+            : Window(GTK_WINDOW(gtk_window_new(
+            type == window_type::TOP ? GTK_WINDOW_TOPLEVEL :
+            type == window_type::POPUP ? GTK_WINDOW_POPUP :
+            GTK_WINDOW_TOPLEVEL)))
+    { };
+
     Window Window::create_dialog_window(const char *title, void func(), void *data, int default_w, int default_h)
     {
         return Window(::create_dialog_window(*this, title, func, data, default_w, default_h));
index 56696ce55f8c73a6abe3d6ff70b4eaf0d50d94df..b6f8fc84637f68dbf059e6c693a823b0847c1cc5 100644 (file)
@@ -65,6 +65,11 @@ namespace ui {
         NO,
     };
 
+    enum class window_type {
+        TOP,
+        POPUP
+    };
+
     template<class Self, class T, bool implicit = true>
     struct Convertible;
 
@@ -236,6 +241,7 @@ namespace ui {
 
     WRAP(Window, Widget, ui_window,
          Window() : Window(nullptr) {};
+         Window(window_type type);
 
          Window create_dialog_window(const char *title, void func(), void *data, int default_w = -1,
                                      int default_h = -1);
index 4de2ac5e25e700f0fabd9df857c159763aadbca5..39ef3d4e15c7fe0c84237d988f7a9f67a7649f0d 100644 (file)
@@ -54,7 +54,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){
        GtkWidget *window, *w, *vbox, *hbox;
        int mode = ( uType & MB_TYPEMASK ), ret, loop = 1;
 
-       window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+       window = ui::Window( ui::window_type::TOP );
        gtk_signal_connect( GTK_OBJECT( window ), "delete_event",
                                                GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
        gtk_signal_connect( GTK_OBJECT( window ), "destroy",
index 38449790eaec5a6ac10afd93c54f552c9b2c7216..7ccb087cc0957020fb5a0afaa201b91fb6f05100 100644 (file)
@@ -350,7 +350,7 @@ void Dialog::Destroy(){
        ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" );
 
        gtk_widget_destroy( GTK_WIDGET( m_window ) );
-       m_window = ui::Window(nullptr);
+       m_window = ui::Window();
 }
 
 
index e6fc9c2408c3d5fbdf478c7700fd84b702efd302..4a333a37995da98762b6b5516a384519f7d4fa46 100644 (file)
@@ -749,7 +749,7 @@ static void CreateGtkTextEditor(){
        ui::Widget dlg;
        ui::Widget vbox, hbox, button, scr, text;
 
-       dlg = ui::Widget(gtk_window_new( GTK_WINDOW_TOPLEVEL ));
+       dlg = ui::Window( ui::window_type::TOP );
 
        g_signal_connect( G_OBJECT( dlg ), "delete_event",
                                          G_CALLBACK( editor_delete ), 0 );
index 6b39e0f79af3f8821dfefbbb6ac74bafcabfdb2f..7c1dea162ed8906a06037432b4fffea5acaa8601 100644 (file)
@@ -2659,7 +2659,7 @@ void MainFrame::OnSleep(){
 
 
 ui::Window create_splash(){
-       ui::Window window = ui::Window(GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ));
+       ui::Window window = ui::Window( ui::window_type::TOP );
        gtk_window_set_decorated( window, FALSE );
        gtk_window_set_resizable( window, FALSE );
        gtk_window_set_modal( window, TRUE );
@@ -2703,7 +2703,7 @@ static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data
 }
 
 void MainFrame::Create(){
-       ui::Window window = ui::Window(GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ));
+       ui::Window window = ui::Window( ui::window_type::TOP );
 
        GlobalWindowObservers_connectTopLevel( window );