From 08ff186126c7614118ec31d77e71657f4b26a4b6 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 17 Feb 2016 18:26:47 +1100 Subject: [PATCH] Wrap GtkWindow --- contrib/bobtoolz/dialogs/dialogs-gtk.cpp | 20 ++++++++++---------- contrib/brushexport/interface.cpp | 2 +- contrib/camera/dialogs.cpp | 10 +++++----- contrib/gtkgensurf/gendlgs.cpp | 2 +- contrib/gtkgensurf/view.cpp | 2 +- contrib/hydratoolz/plugin.cpp | 2 +- contrib/prtview/AboutDialog.cpp | 2 +- contrib/prtview/ConfigDialog.cpp | 2 +- contrib/prtview/LoadPortalFileDialog.cpp | 2 +- contrib/sunplug/sunplug.cpp | 4 ++-- libs/gtkutil/window.cpp | 2 +- libs/uilib/uilib.cpp | 7 +++++++ libs/uilib/uilib.h | 6 ++++++ plugins/textool/TexTool.cpp | 2 +- radiant/dialog.cpp | 2 +- radiant/gtkdlgs.cpp | 2 +- radiant/mainframe.cpp | 4 ++-- 17 files changed, 43 insertions(+), 30 deletions(-) diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 22c00dd9..359148dd 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -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 ); diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index 3c73a6a6..e9688ac2 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -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 ); diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index 5515c400..0100f9b2 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -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 ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index c1cdb8cb..089054c6 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -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); diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index 63980809..84912c3d 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -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 ); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 703b52ad..311eab2e 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -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", diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index 3d3fce12..19838042 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -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 ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 22aa138e..26cc21df 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -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 ); diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index 075bbda8..a2a9fbbf 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -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 ); diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 7455d492..c9d5d73f 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -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 diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index ce400287..2c34e509 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -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 ) { diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index 484cbb07..0e40539d 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -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)); diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index 56696ce5..b6f8fc84 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -65,6 +65,11 @@ namespace ui { NO, }; + enum class window_type { + TOP, + POPUP + }; + template 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); diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 4de2ac5e..39ef3d4e 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -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", diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 38449790..7ccb087c 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -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(); } diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index e6fc9c24..4a333a37 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -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 ); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 6b39e0f7..7c1dea16 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -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 ); -- 2.39.2