From: TimePath Date: Fri, 29 Dec 2017 12:55:31 +0000 (+1100) Subject: Wrap more GTK X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f0350b355f68497312c517c1bfd1fc216c722992;p=xonotic%2Fnetradiant.git Wrap more GTK --- diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index f6b0fb7f..01a1b985 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -34,7 +34,7 @@ // spaces to make label nice and big #define NO_FILE_MSG " (no file loaded) " -static GtkWidget *pDialogWnd; +static ui::Window pDialogWnd{ui::null}; static GtkWidget *pNotebook; static GtkTooltips *pTooltips; @@ -307,7 +307,7 @@ void InitBackgroundDialog(){ CBackgroundDialogPage *pPage; pDialogWnd = gtk_dialog_new_with_buttons( "Background Images", - GTK_WINDOW( g_pMainWidget ), + g_pMainWidget, (GtkDialogFlags)( GTK_DIALOG_DESTROY_WITH_PARENT ), // TODO dialog with no buttons // GTK_STOCK_CLOSE, @@ -335,7 +335,7 @@ void InitBackgroundDialog(){ } void ShowBackgroundDialog(){ - gtk_window_present( GTK_WINDOW( pDialogWnd ) ); + gtk_window_present( pDialogWnd ); } void ShowBackgroundDialogPG( int page ){ diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index 0632f2b1..bbc3979c 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -63,7 +63,7 @@ const char* PLUGIN_NAME = "bobToolz"; static const char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge"; // globals -ui::Widget g_pRadiantWnd{ui::null}; +ui::Window g_pRadiantWnd{ui::null}; static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n" "by digibob (digibob@splashdamage.com)\n" @@ -72,7 +72,7 @@ static const char *PLUGIN_ABOUT = "bobToolz for SDRadiant\n" "MarsMattel, RR2DO2\n"; extern "C" const char* QERPlug_Init( void* hApp, void* pMainWidget ) { - g_pRadiantWnd = ui::Widget::from(pMainWidget); + g_pRadiantWnd = ui::Window::from(pMainWidget); return "bobToolz for GTKradiant"; } diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 15ccf8e1..e6016ddf 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -78,12 +78,11 @@ void Update_TextureReseter(){ gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check ); } -static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +static void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop; EMessageBoxReturn *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" ); @@ -213,7 +212,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess auto window = ui::Window( ui::window_type::TOP ); window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); + gtk_window_set_title( window, lpCaption ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -294,7 +293,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess ret = eIDNO; } - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -316,7 +315,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Intersect" ); + gtk_window_set_title( window, "Intersect" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -377,7 +376,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ // ---- /vbox ---- - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -409,7 +408,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" ); + gtk_window_set_title( window, "Polygon Builder" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -526,7 +525,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // ---- /vbox ---- - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -577,7 +576,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" ); + gtk_window_set_title( window, "Stair Builder" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); @@ -759,7 +758,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ ret = eIDCANCEL; // +djbob: need our "little" modal loop mars :P - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -827,7 +826,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" ); + gtk_window_set_title( window, "Door Builder" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); @@ -997,7 +996,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ // ----------------- // //+djbob - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1037,7 +1036,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); + gtk_window_set_title( window, "Texture Reset" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1161,7 +1160,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ // ----------------- // - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1208,7 +1207,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" ); + gtk_window_set_title( window, "CTF Colour Changer" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1253,7 +1252,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){ // ---- /vbox ---- - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1279,7 +1278,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" ); + gtk_window_set_title( window, "Texture Reset" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1532,7 +1531,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /vbox ---- - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1615,7 +1614,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" ); + gtk_window_set_title( window, "Train Thing" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); @@ -1814,7 +1813,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -1878,7 +1877,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" ); + gtk_window_set_title( window, "Make Chain" ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); @@ -1949,7 +1948,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ ret = eIDCANCEL; - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); diff --git a/contrib/brushexport/callbacks.cpp b/contrib/brushexport/callbacks.cpp index c09ae137..1e639dc5 100644 --- a/contrib/brushexport/callbacks.cpp +++ b/contrib/brushexport/callbacks.cpp @@ -18,7 +18,7 @@ void OnDestroy( ui::Widget w, gpointer data ){ } void OnExportClicked( ui::Button button, gpointer user_data ){ - ui::Widget window = lookup_widget( button , "w_plugplug2" ); + auto window = ui::Window::from(lookup_widget( button , "w_plugplug2" )); ASSERT_TRUE( window ); const char* cpath = GlobalRadiant().m_pfnFileDialog( window, false, "Save as Obj", 0, 0, false, false, true ); if ( !cpath ) { @@ -31,7 +31,7 @@ void OnExportClicked( ui::Button button, gpointer user_data ){ std::set ignore; GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ); - ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); + ui::ListStore list = ui::ListStore::from(gtk_tree_view_get_model( view )); GtkTreeIter iter; gboolean valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL( list ), &iter ); @@ -113,7 +113,7 @@ void OnAddMaterial( ui::Button button, gpointer user_data ){ const gchar* name = gtk_entry_get_text( edit ); if ( g_utf8_strlen( name, -1 ) > 0 ) { - ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ) ) )); + ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ) ) ); list.append(0, name); gtk_entry_set_text( edit, "" ); } @@ -121,7 +121,7 @@ void OnAddMaterial( ui::Button button, gpointer user_data ){ void OnRemoveMaterial( ui::Button button, gpointer user_data ){ GtkTreeView* view = GTK_TREE_VIEW( lookup_widget( button , "t_materialist" ) ); - ui::ListStore list = ui::ListStore(GTK_LIST_STORE( gtk_tree_view_get_model( view ) )); + ui::ListStore list = ui::ListStore::from( gtk_tree_view_get_model( view ) ); GtkTreeSelection* sel = gtk_tree_view_get_selection( view ); GtkTreeIter iter; diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index d9ea6292..4bc8a6f1 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -19,9 +19,9 @@ create_w_plugplug2( void ){ auto 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 ); - gtk_window_set_destroy_with_parent( GTK_WINDOW( w_plugplug2 ), TRUE ); + gtk_window_set_title( w_plugplug2, "BrushExport-Plugin 3.0 by namespace" ); + gtk_window_set_position( w_plugplug2, GTK_WIN_POS_CENTER ); + gtk_window_set_destroy_with_parent( w_plugplug2, TRUE ); auto vbox1 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox1, "vbox1" ); diff --git a/contrib/brushexport/plugin.cpp b/contrib/brushexport/plugin.cpp index a2d0d621..2a221c71 100644 --- a/contrib/brushexport/plugin.cpp +++ b/contrib/brushexport/plugin.cpp @@ -52,7 +52,7 @@ namespace BrushExport ui::Window g_mainwnd{ui::null}; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = ui::Window(GTK_WINDOW(pMainWidget)); + g_mainwnd = ui::Window::from(pMainWidget); ASSERT_TRUE( g_mainwnd ); return ""; } diff --git a/contrib/camera/camera.cpp b/contrib/camera/camera.cpp index 4e74460b..635b3679 100644 --- a/contrib/camera/camera.cpp +++ b/contrib/camera/camera.cpp @@ -39,8 +39,8 @@ static const char *PLUGIN_NAME = "Camera"; static const char *PLUGIN_COMMANDS = "About...,-,Load Camera...,-,Preview Camera,-,Camera Inspector...,-,New Spline Camera,New Interpolated Camera,New Fixed Camera"; // globals -GtkWidget *g_pRadiantWnd = NULL; -GtkWidget *g_pCameraInspectorWnd = NULL; +ui::Window g_pRadiantWnd{ui::null}; +ui::Window g_pCameraInspectorWnd{ui::null}; CCamera *firstCam = NULL; // double linked list CCamera *firstFreeCam = NULL; // single linked list CCamera *currentCam = NULL; // single item diff --git a/contrib/camera/camera.h b/contrib/camera/camera.h index 8f2091c5..ba008a2c 100644 --- a/contrib/camera/camera.h +++ b/contrib/camera/camera.h @@ -156,8 +156,8 @@ void SetCurrentCam( CCamera *cam ); CCamera *GetCurrentCam(); // globals -extern GtkWidget *g_pRadiantWnd; -extern GtkWidget *g_pCameraInspectorWnd; +extern ui::Window g_pRadiantWnd; +extern ui::Window g_pCameraInspectorWnd; extern CCamera *firstCam; extern bool g_bEditOn; extern int g_iEditMode; diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index e2366239..7ca99e91 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -70,10 +70,10 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // create the window auto window = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( window ), "New Camera" ); + gtk_window_set_title( window, "New Camera" ); window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); + gtk_window_set_transient_for( window, g_pCameraInspectorWnd ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -145,7 +145,7 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // -------------------------- // - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -363,10 +363,10 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ // create the window auto window = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" ); + gtk_window_set_title( window, "Rename Path" ); window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); + gtk_window_set_transient_for( window, g_pCameraInspectorWnd ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -427,7 +427,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ // -------------------------- // - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -482,10 +482,10 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // create the window auto window = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( window ), "Add Target" ); + gtk_window_set_title( window, "Add Target" ); window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); + gtk_window_set_transient_for( window, g_pCameraInspectorWnd ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -574,7 +574,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ // -------------------------- // - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -830,10 +830,10 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // create the window auto window = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( window ), "Add Event" ); + gtk_window_set_title( window, "Add Event" ); window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) ); + gtk_window_set_transient_for( window, g_pCameraInspectorWnd ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); @@ -914,7 +914,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ // -------------------------- // - gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER ); + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); window.show(); gtk_grab_add( window ); @@ -996,11 +996,11 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // create the window auto window = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" ); + gtk_window_set_title( window, "Camera Inspector" ); window.connect( "delete_event", G_CALLBACK( ci_close ), NULL ); window.connect( "expose_event", G_CALLBACK( ci_expose ), NULL ); // window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_transient_for( window, g_pRadiantWnd ); // don't use show, as you don't want to have it displayed on startup ;-) gtk_widget_realize( window ); diff --git a/contrib/camera/dialogs_common.cpp b/contrib/camera/dialogs_common.cpp index f53da8d0..805071ca 100644 --- a/contrib/camera/dialogs_common.cpp +++ b/contrib/camera/dialogs_common.cpp @@ -26,11 +26,10 @@ #include "camera.h" -void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index a6545f34..75d9740e 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -934,7 +934,7 @@ static gint fix_value_entryfocusout( GtkWidget* widget, GdkEventFocus *event, gp "GenSurf", eMB_OK, eMB_ICONWARNING ); sprintf( Text, "%d", (int)xyz[Vertex[0].i][Vertex[0].j].fixed_value ); gtk_entry_set_text( GTK_ENTRY( widget ), Text ); - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), widget ); + gtk_window_set_focus( widget.window(), widget ); } else if ( i != xyz[Vertex[0].i][Vertex[0].j].fixed_value ) { for ( k = 0; k < NumVerticesSelected; k++ ) @@ -1356,10 +1356,10 @@ GtkWidget* create_main_dialog(){ "Wall facing 180","Wall facing 270" }; auto dlg = g_pWnd = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption ); + gtk_window_set_title( dlg, gszCaption ); dlg.connect( "delete_event", G_CALLBACK( main_close ), NULL ); // dlg.connect( "destroy", G_CALLBACK (gtk_widget_destroy), NULL); - gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); + gtk_window_set_transient_for( dlg, g_pRadiantWnd ); auto hbox = ui::HBox( FALSE, 5 ); hbox.show(); diff --git a/contrib/gtkgensurf/gensurf.h b/contrib/gtkgensurf/gensurf.h index 7a90cb64..84a78cd6 100644 --- a/contrib/gtkgensurf/gensurf.h +++ b/contrib/gtkgensurf/gensurf.h @@ -412,7 +412,7 @@ extern int SP; // ^Fishman - Snap to grid. extern HCURSOR ghCursorDefault; extern HCURSOR ghCursorVertex; extern HINSTANCE ghInst;*/ -extern GtkWidget *g_pRadiantWnd; +extern ui::Window g_pRadiantWnd; extern ui::Window g_pWnd; /*extern HWND ghwndAngles; extern HWND ghwndFix; diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index 6969ca5c..975c5cae 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -371,11 +371,11 @@ void CreateViewWindow(){ #endif auto dlg = g_pWndPreview = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" ); + gtk_window_set_title( dlg, "GtkGenSurf Preview" ); dlg.connect( "delete_event", G_CALLBACK( preview_close ), NULL ); dlg.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pWnd ) ); - gtk_window_set_default_size( GTK_WINDOW( dlg ), 300, 400 ); + gtk_window_set_transient_for( dlg, g_pWnd ); + gtk_window_set_default_size( dlg, 300, 400 ); auto vbox = ui::VBox( FALSE, 5 ); vbox.show(); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index 1f1f6cd0..14f2c4b8 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -58,11 +58,10 @@ void *g_pMainWnd; // ============================================================================= // Ripped from TexTool.cpp -static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +static void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "loop" ); ret = (int*)gtk_object_get_data( GTK_OBJECT( parent ), "ret" ); @@ -89,7 +88,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); + gtk_window_set_title( window, lpCaption ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); gtk_object_set_data( GTK_OBJECT( window ), "loop", &loop ); gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index c517e6c1..f320de22 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -27,11 +27,10 @@ #include "prtview.h" #include "ConfigDialog.h" -static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +static void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index 6e248977..f4c22b98 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -28,11 +28,10 @@ #include "prtview.h" #include "portals.h" -static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +static void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); @@ -238,7 +237,7 @@ void DoConfigDialog(){ int loop = 1, ret = IDCANCEL; auto dlg = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" ); + gtk_window_set_title( dlg, "Portal Viewer Configuration" ); dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); dlg.connect( "destroy", diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index 3252bc40..0d095a74 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -33,11 +33,10 @@ #include "prtview.h" #include "portals.h" -static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; +static void dialog_button_callback( ui::Widget widget, gpointer data ){ int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); @@ -80,7 +79,7 @@ int DoLoadPortalFileDialog(){ int loop = 1, ret = IDCANCEL; auto dlg = ui::Window( ui::window_type::TOP ); - gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" ); + gtk_window_set_title( dlg, "Load .prt" ); dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); dlg.connect( "destroy", diff --git a/contrib/shaderplug/shaderplug.cpp b/contrib/shaderplug/shaderplug.cpp index 75171bd8..6f272509 100644 --- a/contrib/shaderplug/shaderplug.cpp +++ b/contrib/shaderplug/shaderplug.cpp @@ -67,7 +67,7 @@ XmlTagBuilder TagBuilder; void CreateTagFile(); const char* init( void* hApp, void* pMainWidget ){ - g_window = ui::Window(GTK_WINDOW( pMainWidget )); + g_window = ui::Window::from(pMainWidget); return ""; } const char* getName(){ diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 91408c2b..589299b2 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -130,8 +130,8 @@ static void destroy( ui::Widget widget, gpointer data ){ } // function for close button to destroy the toplevel widget -static void close_window( GtkWidget *widget, gpointer data ){ - ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy(); +static void close_window( ui::Widget widget, gpointer data ){ + widget.window().destroy(); } // callback function to assign the optimal mapcoords to the spinboxes @@ -148,7 +148,7 @@ gint grab_int_value( GtkSpinButton *a_spinner, gpointer user_data ) { } // write the values of the Spinner-Boxes to the worldspawn -static void set_coordinates( GtkWidget *widget, gpointer data ){ +static void set_coordinates( ui::Widget widget, gpointer data ){ //Str str_min, str_max; char buffer[10], str_min[20], str_max[20]; @@ -189,7 +189,7 @@ ui::Window main_window{ui::null}; char MenuList[100] = ""; const char* init( void* hApp, void* pMainWidget ){ - main_window = ui::Window(GTK_WINDOW( pMainWidget )); + main_window = ui::Window::from(pMainWidget); return "Initializing SunPlug for GTKRadiant"; } const char* getName(){ @@ -255,12 +255,12 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server // About dialog void about_plugin_window(){ auto 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 + gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window - gtk_window_set_title( GTK_WINDOW( window ), "About SunPlug" ); // set the title of the window for the window - gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window - gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows + gtk_window_set_title( window, "About SunPlug" ); // set the title of the window for the window + gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window + gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically @@ -274,7 +274,7 @@ void about_plugin_window(){ g_signal_connect_swapped( G_OBJECT( button ), "clicked", G_CALLBACK( gtk_widget_destroy ), (void *) window ); // connect the click event to close the window vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box - gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window on screen + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window on screen gtk_widget_show_all( window ); // show the window and all subelements } @@ -320,12 +320,12 @@ void MapCoordinator(){ // in any case we need a window to show the user what to do auto 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 + gtk_window_set_transient_for( window, SunPlug::main_window ); // make the window to stay in front of the main window window.connect( "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window window.connect( "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window - gtk_window_set_title( GTK_WINDOW( window ), "ET-MapCoordinator" ); // set the title of the window for the window - gtk_window_set_resizable( GTK_WINDOW( window ), FALSE ); // don't let the user resize the window - gtk_window_set_modal( GTK_WINDOW( window ), TRUE ); // force the user not to do something with the other windows + gtk_window_set_title( window, "ET-MapCoordinator" ); // set the title of the window for the window + gtk_window_set_resizable( window, FALSE ); // don't let the user resize the window + gtk_window_set_modal( window, TRUE ); // force the user not to do something with the other windows gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); // set the border of the window auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically @@ -435,6 +435,6 @@ void MapCoordinator(){ vbox.pack_start( button, FALSE, FALSE, 2 ); // insert the button in the box } - gtk_window_set_position( GTK_WINDOW( window ), GTK_WIN_POS_CENTER ); // center the window + gtk_window_set_position( window, GTK_WIN_POS_CENTER ); // center the window gtk_widget_show_all( window ); // show the window and all subelements } diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index 2b0d1ba8..99815ab0 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -62,7 +62,7 @@ namespace UFOAI ui::Window g_mainwnd{ui::null}; const char* init( void* hApp, void* pMainWidget ){ - g_mainwnd = ui::Window(GTK_WINDOW( pMainWidget )); + g_mainwnd = ui::Window::from(pMainWidget); return "Initializing GTKRadiant UFOAI plugin"; } const char* getName(){ diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index 5b287c89..ea233fe7 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -46,8 +46,8 @@ static void destroy( ui::Widget widget, gpointer data ){ /** * @brief function for close button to destroy the toplevel widget */ -static void close_window( GtkWidget *widget, gpointer data ){ - ui::Widget(gtk_widget_get_toplevel( widget ) ).destroy(); +static void close_window( ui::Widget widget, gpointer data ){ + widget.window().destroy(); } /* =============================== */ diff --git a/include/qerplugin.h b/include/qerplugin.h index 8e56da9c..b6a8865f 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -65,22 +65,22 @@ enum EMessageBoxReturn // simple Message Box, see above for the 'type' flags -typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Widget parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); +typedef EMessageBoxReturn ( *PFN_QERAPP_MESSAGEBOX )( ui::Window parent, const char* text, const char* caption /* = "NetRadiant"*/, EMessageBoxType type /* = eMB_OK*/, EMessageBoxIcon icon /* = eMB_ICONDEFAULT*/ ); // file and directory selection functions return null if the user hits cancel // - 'title' is the dialog title (can be null) // - 'path' is used to set the initial directory (can be null) // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples -typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Widget parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); +typedef const char* ( *PFN_QERAPP_FILEDIALOG )( ui::Window parent, bool open, const char* title, const char* path /* = 0*/, const char* pattern /* = 0*/, bool want_load /* = false*/, bool want_import /* = false*/, bool want_save /* = false*/ ); // returns a gchar* string that must be g_free'd by the user -typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Widget parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); +typedef char* ( *PFN_QERAPP_DIRDIALOG )( ui::Window parent, const char* title /* = "Choose Directory"*/, const char* path /* = 0*/ ); // return true if the user closed the dialog with 'Ok' // 'color' is used to set the initial value and store the selected value template class BasicVector3; typedef BasicVector3 Vector3; -typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Widget parent, Vector3& color, +typedef bool ( *PFN_QERAPP_COLORDIALOG )( ui::Window parent, Vector3& color, const char* title /* = "Choose Color"*/ ); // load a .bmp file and create a GtkImage widget from it diff --git a/libs/gtkutil/cursor.cpp b/libs/gtkutil/cursor.cpp index bb56fe61..999621f1 100644 --- a/libs/gtkutil/cursor.cpp +++ b/libs/gtkutil/cursor.cpp @@ -59,10 +59,10 @@ gboolean DeferredMotion::gtk_motion(ui::Widget widget, GdkEventMotion *event, De return FALSE; } -gboolean FreezePointer::motion_delta(ui::Widget widget, GdkEventMotion *event, FreezePointer *self) +gboolean FreezePointer::motion_delta(ui::Window widget, GdkEventMotion *event, FreezePointer *self) { int current_x, current_y; - Sys_GetCursorPos( ui::Window(GTK_WINDOW( widget )), ¤t_x, ¤t_y ); + Sys_GetCursorPos( widget, ¤t_x, ¤t_y ); int dx = current_x - self->last_x; int dy = current_y - self->last_y; int ddx = current_x - self->recorded_x; @@ -72,7 +72,7 @@ gboolean FreezePointer::motion_delta(ui::Widget widget, GdkEventMotion *event, F if ( dx != 0 || dy != 0 ) { //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n"; if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) { - Sys_SetCursorPos( ui::Window(GTK_WINDOW( widget )), self->recorded_x, self->recorded_y ); + Sys_SetCursorPos( widget, self->recorded_x, self->recorded_y ); self->last_x = self->recorded_x; self->last_y = self->recorded_y; } diff --git a/libs/gtkutil/cursor.h b/libs/gtkutil/cursor.h index 6f2c6cc7..2d16142e 100644 --- a/libs/gtkutil/cursor.h +++ b/libs/gtkutil/cursor.h @@ -114,7 +114,7 @@ void* m_data; public: FreezePointer() : handle_motion( 0 ), m_function( 0 ), m_data( 0 ){ } -static gboolean motion_delta( ui::Widget widget, GdkEventMotion *event, FreezePointer* self ); +static gboolean motion_delta( ui::Window widget, GdkEventMotion *event, FreezePointer* self ); void freeze_pointer( ui::Window window, MotionDeltaFunction function, void* data ); diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index c8267310..73e241ab 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -262,6 +262,6 @@ ui::Table DialogRow_new( const char* name, ui::Widget widget ){ return table; } -void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ){ +void DialogVBox_packRow( ui::Box vbox, ui::Widget row ){ vbox.pack_start( row, FALSE, FALSE, 0 ); } diff --git a/libs/gtkutil/dialog.h b/libs/gtkutil/dialog.h index 7907e76b..b4367e5c 100644 --- a/libs/gtkutil/dialog.h +++ b/libs/gtkutil/dialog.h @@ -118,7 +118,7 @@ BrowsedPathEntry( const BrowseCallback& browse ); ui::Label DialogLabel_new( const char* name ); ui::Table DialogRow_new( const char* name, ui::Widget widget ); -void DialogVBox_packRow( ui::VBox vbox, ui::Widget row ); +void DialogVBox_packRow( ui::Box vbox, ui::Widget row ); #endif diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index c2c74c2f..38b6636e 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -124,7 +124,7 @@ filetype_pair_t GetTypeForGTKMask( const char *mask ) const { static char g_file_dialog_file[1024]; -const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ +const char* file_dialog_show( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ filetype_t type; if ( pattern == 0 ) { @@ -140,28 +140,28 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c title = open ? "Open File" : "Save File"; } - GtkWidget* dialog; + ui::Dialog dialog{ui::null}; if ( open ) { - dialog = gtk_file_chooser_dialog_new( title, - GTK_WINDOW( parent ), + dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title, + parent, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL ); + NULL )); } else { - dialog = gtk_file_chooser_dialog_new( title, - GTK_WINDOW( parent ), + dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title, + parent, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL ); + NULL )); gtk_file_chooser_set_current_name( GTK_FILE_CHOOSER( dialog ), "unnamed" ); } - gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE ); - gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( dialog, TRUE ); + gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT ); // we expect an actual path below, if the path is 0 we might crash if ( path != 0 && !string_empty( path ) ) { @@ -240,16 +240,16 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c return g_file_dialog_file; } -char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ - GtkWidget* dialog = gtk_file_chooser_dialog_new( title, - GTK_WINDOW( parent ), +char* dir_dialog( ui::Window parent, const char* title, const char* path ){ + auto dialog = ui::Dialog::from(gtk_file_chooser_dialog_new( title, + parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL ); + NULL )); - gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE ); - gtk_window_set_position( GTK_WINDOW( dialog ), GTK_WIN_POS_CENTER_ON_PARENT ); + gtk_window_set_modal( dialog, TRUE ); + gtk_window_set_position( dialog, GTK_WIN_POS_CENTER_ON_PARENT ); if ( !string_empty( path ) ) { gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), path ); @@ -260,12 +260,12 @@ char* dir_dialog( ui::Widget parent, const char* title, const char* path ){ filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dialog ) ); } - ui::Widget(dialog).destroy(); + dialog.destroy(); return filename; } -const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ +const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){ for (;; ) { const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save ); diff --git a/libs/gtkutil/filechooser.h b/libs/gtkutil/filechooser.h index ae7c0b34..cdad28b7 100644 --- a/libs/gtkutil/filechooser.h +++ b/libs/gtkutil/filechooser.h @@ -27,13 +27,13 @@ /// \file /// GTK+ file-chooser dialogs. -const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); +const char* file_dialog( ui::Window parent, bool open, const char* title, const char* path = 0, const char* pattern = 0, bool want_load = false, bool want_import = false, bool want_save = false ); /// \brief Prompts the user to browse for a directory. /// The prompt window will be transient to \p parent. /// The directory will initially default to \p path, which must be an absolute path. /// The returned string is allocated with \c g_malloc and must be freed with \c g_free. -char* dir_dialog( ui::Widget parent, const char* title = "Choose Directory", const char* path = "" ); +char* dir_dialog( ui::Window parent, const char* title = "Choose Directory", const char* path = "" ); #endif diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 28e29a14..d71dfadb 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -51,15 +51,13 @@ const char* messagebox_stock_icon( EMessageBoxIcon type ){ } } -EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ +EMessageBoxReturn gtk_MessageBox( ui::Window parentWindow, const char* text, const char* title, EMessageBoxType type, EMessageBoxIcon icon ){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); ModalDialogButton yes_button( dialog, eIDYES ); ModalDialogButton no_button( dialog, eIDNO ); - ui::Window parentWindow = ui::Window(parent ? GTK_WINDOW( parent ) : 0); - ui::Window window = create_fixedsize_modal_dialog_window( parentWindow, title, dialog, 400, 100 ); if ( parentWindow ) { diff --git a/libs/gtkutil/messagebox.h b/libs/gtkutil/messagebox.h index 69939939..4ae8a3f8 100644 --- a/libs/gtkutil/messagebox.h +++ b/libs/gtkutil/messagebox.h @@ -25,6 +25,6 @@ #include "qerplugin.h" /// \brief Shows a modal message-box. -EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); +EMessageBoxReturn gtk_MessageBox( ui::Window parent, const char* text, const char* title = "NetRadiant", EMessageBoxType type = eMB_OK, EMessageBoxIcon icon = eMB_ICONDEFAULT ); #endif diff --git a/libs/gtkutil/nonmodal.cpp b/libs/gtkutil/nonmodal.cpp index f150ec2a..049c62c0 100644 --- a/libs/gtkutil/nonmodal.cpp +++ b/libs/gtkutil/nonmodal.cpp @@ -6,7 +6,7 @@ gboolean escape_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data) { if (event->keyval == GDK_KEY_Escape) { - gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(widget)), NULL); + gtk_window_set_focus(widget.window(), NULL); return TRUE; } return FALSE; @@ -43,7 +43,7 @@ gboolean NonModalEntry::enter(ui::Entry entry, GdkEventKey *event, NonModalEntry if (event->keyval == GDK_KEY_Return) { self->m_apply(); self->m_editing = false; - gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(entry)), NULL); + gtk_window_set_focus(entry.window(), NULL); return TRUE; } return FALSE; @@ -54,7 +54,7 @@ gboolean NonModalEntry::escape(ui::Entry entry, GdkEventKey *event, NonModalEntr if (event->keyval == GDK_KEY_Escape) { self->m_cancel(); self->m_editing = false; - gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(entry)), NULL); + gtk_window_set_focus(entry.window(), NULL); return TRUE; } return FALSE; @@ -78,7 +78,7 @@ gboolean NonModalSpinner::changed(ui::SpinButton spin, NonModalSpinner *self) gboolean NonModalSpinner::enter(ui::SpinButton spin, GdkEventKey *event, NonModalSpinner *self) { if (event->keyval == GDK_KEY_Return) { - gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(spin)), NULL); + gtk_window_set_focus(spin.window(), NULL); return TRUE; } return FALSE; @@ -88,7 +88,7 @@ gboolean NonModalSpinner::escape(ui::SpinButton spin, GdkEventKey *event, NonMod { if (event->keyval == GDK_KEY_Escape) { self->m_cancel(); - gtk_window_set_focus(GTK_WINDOW(gtk_widget_get_toplevel(spin)), NULL); + gtk_window_set_focus(spin.window(), NULL); return TRUE; } return FALSE; diff --git a/libs/gtkutil/window.cpp b/libs/gtkutil/window.cpp index 411e2b5a..9276ad2d 100644 --- a/libs/gtkutil/window.cpp +++ b/libs/gtkutil/window.cpp @@ -110,7 +110,7 @@ gboolean persistent_floating_window_delete( ui::Window floating, GdkEvent *event } ui::Window create_persistent_floating_window( const char* title, ui::Window main_window ){ - ui::Window window = ui::Window(GTK_WINDOW( create_floating_window( title, main_window ) )); + auto window = create_floating_window( title, main_window ); gtk_widget_set_events( window , GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK ); @@ -145,9 +145,9 @@ ui::ScrolledWindow create_scrolled_window( ui::Policy hscrollbar_policy, ui::Pol return scr; } -gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data) +gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data) { - gtk_window_set_focus( GTK_WINDOW( widget ), NULL ); + gtk_window_set_focus( widget, NULL ); return FALSE; } diff --git a/libs/gtkutil/window.h b/libs/gtkutil/window.h index 2adc3caf..5a24a729 100644 --- a/libs/gtkutil/window.h +++ b/libs/gtkutil/window.h @@ -28,7 +28,7 @@ #include "generic/callback.h" #include "widget.h" -gboolean window_focus_in_clear_focus_widget(ui::Widget widget, GdkEventKey *event, gpointer data); +gboolean window_focus_in_clear_focus_widget(ui::Window widget, GdkEventKey *event, gpointer data); guint window_connect_focus_in_clear_focus_widget(ui::Window window); diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index c2c24c50..cb44edb2 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -60,36 +60,16 @@ namespace ui { Widget::Widget(ui::New_t) : Widget(nullptr) {} - alert_response IWidget::alert(std::string text, std::string title, alert_type type, alert_icon icon) + Window IWidget::window() { - auto ret = gtk_MessageBox(this, text.c_str(), - title.c_str(), - type == alert_type::OK ? eMB_OK : - type == alert_type::OKCANCEL ? eMB_OKCANCEL : - type == alert_type::YESNO ? eMB_YESNO : - type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL : - type == alert_type::NOYES ? eMB_NOYES : - eMB_OK, - icon == alert_icon::Default ? eMB_ICONDEFAULT : - icon == alert_icon::Error ? eMB_ICONERROR : - icon == alert_icon::Warning ? eMB_ICONWARNING : - icon == alert_icon::Question ? eMB_ICONQUESTION : - icon == alert_icon::Asterisk ? eMB_ICONASTERISK : - eMB_ICONDEFAULT - ); - return - ret == eIDOK ? alert_response::OK : - ret == eIDCANCEL ? alert_response::CANCEL : - ret == eIDYES ? alert_response::YES : - ret == eIDNO ? alert_response::NO : - alert_response::OK; + return Window::from(gtk_widget_get_toplevel(this)); } const char * IWidget::file_dialog(bool open, const char *title, const char *path, const char *pattern, bool want_load, bool want_import, bool want_save) { - return ::file_dialog(this, open, title, path, pattern, want_load, want_import, want_save); + return ::file_dialog(this.window(), open, title, path, pattern, want_load, want_import, want_save); } bool IWidget::visible() @@ -156,6 +136,31 @@ namespace ui { ))) {} + alert_response IWindow::alert(std::string text, std::string title, alert_type type, alert_icon icon) + { + auto ret = gtk_MessageBox(this, text.c_str(), + title.c_str(), + type == alert_type::OK ? eMB_OK : + type == alert_type::OKCANCEL ? eMB_OKCANCEL : + type == alert_type::YESNO ? eMB_YESNO : + type == alert_type::YESNOCANCEL ? eMB_YESNOCANCEL : + type == alert_type::NOYES ? eMB_NOYES : + eMB_OK, + icon == alert_icon::Default ? eMB_ICONDEFAULT : + icon == alert_icon::Error ? eMB_ICONERROR : + icon == alert_icon::Warning ? eMB_ICONWARNING : + icon == alert_icon::Question ? eMB_ICONQUESTION : + icon == alert_icon::Asterisk ? eMB_ICONASTERISK : + eMB_ICONDEFAULT + ); + return + ret == eIDOK ? alert_response::OK : + ret == eIDCANCEL ? alert_response::CANCEL : + ret == eIDYES ? alert_response::YES : + ret == eIDNO ? alert_response::NO : + alert_response::OK; + } + Window IWindow::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 e15bdbe4..f02a5172 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -244,14 +244,10 @@ namespace ui { int height; }; + class Window; WRAP(Widget, Object, _GtkWidget, (), , - alert_response alert( - std::string text, - std::string title = "NetRadiant", - alert_type type = alert_type::OK, - alert_icon icon = alert_icon::Default - ); + Window window(); const char *file_dialog( bool open, const char *title, @@ -288,6 +284,13 @@ namespace ui { WRAP(Window, Bin, _GtkWindow, (), explicit Window(window_type type); , + alert_response alert( + std::string text, + std::string title = "NetRadiant", + alert_type type = alert_type::OK, + alert_icon icon = alert_icon::Default + ); + Window create_dialog_window( const char *title, void func(), diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 818d8d2f..7d5eba90 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -29,10 +29,9 @@ #include "StdAfx.h" static void dialog_button_callback( GtkWidget *widget, gpointer data ){ - GtkWidget *parent; int *loop, *ret; - parent = gtk_widget_get_toplevel( widget ); + auto parent = widget.window(); loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); @@ -59,7 +58,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ G_CALLBACK( dialog_delete_callback ), NULL ); window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); - gtk_window_set_title( GTK_WINDOW( window ), lpCaption ); + gtk_window_set_title( window, lpCaption ); gtk_container_set_border_width( GTK_CONTAINER( window ), 10 ); g_object_set_data( G_OBJECT( window ), "loop", &loop ); g_object_set_data( G_OBJECT( window ), "ret", &ret ); diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index d4dcd43b..8d42b715 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -1255,7 +1255,7 @@ if ( ( m_bFreeMove && ( buttons == ( RAD_CONTROL | RAD_SHIFT ) ) ) void CamWnd::Cam_PositionDrag(){ int x, y; - Sys_GetCursorPos( GTK_WINDOW( m_gl_widget ), &x, &y ); + Sys_GetCursorPos( m_gl_widget, &x, &y ); if ( x != m_PositionDragCursorX || y != m_PositionDragCursorY ) { x -= m_PositionDragCursorX; vector3_add( m_Camera.origin, vector3_scaled( m_Camera.vright, x ) ); @@ -1265,7 +1265,7 @@ void CamWnd::Cam_PositionDrag(){ CamWnd_Update( camwnd ); CameraMovedNotify(); - Sys_SetCursorPos( GTK_WINDOW( m_parent ), m_PositionDragCursorX, m_PositionDragCursorY ); + Sys_SetCursorPos( m_parent, m_PositionDragCursorX, m_PositionDragCursorY ); } } #endif diff --git a/radiant/commands.cpp b/radiant/commands.cpp index 02ad4447..c92bd23b 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -177,7 +177,7 @@ void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){ if ( dialog.m_waiting_for_key ) { // just unhighlight, user wanted to cancel dialog.m_waiting_for_key = false; - gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); + gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); gtk_widget_set_sensitive( dialog.m_list , true ); dialog.m_model = NULL; return; @@ -204,7 +204,7 @@ void accelerator_clear_button_clicked( GtkButton *btn, gpointer dialogptr ){ } thisShortcutIterator->second.first = accelerator_null(); - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 1, "", -1 ); + gtk_list_store_set( ui::ListStore::from( model ), &iter, 1, "", -1 ); g_value_unset( &val ); } @@ -226,13 +226,13 @@ void accelerator_edit_button_clicked( GtkButton *btn, gpointer dialogptr ){ //gtk_widget_set_sensitive(dialog.m_list, false); // 3. highlight the row - gtk_list_store_set( GTK_LIST_STORE( model ), &iter, 2, true, -1 ); + gtk_list_store_set( ui::ListStore::from( model ), &iter, 2, true, -1 ); // 4. grab keyboard focus dialog.m_waiting_for_key = true; } -bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpointer dialogptr ){ +bool accelerator_window_key_press( ui::Window widget, GdkEventKey *event, gpointer dialogptr ){ command_list_dialog_t &dialog = *(command_list_dialog_t *) dialogptr; if ( !dialog.m_waiting_for_key ) { @@ -273,7 +273,7 @@ bool accelerator_window_key_press( ui::Widget widget, GdkEventKey *event, gpoint const char *commandName = g_value_get_string( &val );; Shortcuts::iterator thisShortcutIterator = g_shortcuts.find( commandName ); if ( thisShortcutIterator == g_shortcuts.end() ) { - gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); + gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); gtk_widget_set_sensitive( dialog.m_list , true ); return true; } @@ -306,7 +306,7 @@ public: StringOutputStream msg; msg << "The command " << name << " is already assigned to the key " << accelerator << ".\n\n" << "Do you want to unassign " << name << " first?"; - auto r = widget.alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL ); + auto r = widget.window().alert( msg.c_str(), "Key already used", ui::alert_type::YESNOCANCEL ); if ( r == ui::alert_response::YES ) { // clear the ACTUAL accelerator too! disconnect_accelerator( name ); @@ -322,7 +322,7 @@ public: gtk_tree_model_get_value( GTK_TREE_MODEL( model ), &i, 0, &val ); const char *thisName = g_value_get_string( &val );; if ( !strcmp( thisName, name ) ) { - gtk_list_store_set( GTK_LIST_STORE( model ), &i, 1, "", -1 ); + gtk_list_store_set( ui::ListStore::from( model ), &i, 1, "", -1 ); } g_value_unset( &val ); if ( !gtk_tree_model_iter_next( GTK_TREE_MODEL( model ), &i ) ) { @@ -340,7 +340,7 @@ public: } verify_visitor( commandName, newAccel, widget, dialog.m_model ); GlobalShortcuts_foreach( verify_visitor ); - gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); + gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 2, false, -1 ); gtk_widget_set_sensitive( dialog.m_list , true ); if ( verify_visitor.allow ) { @@ -352,7 +352,7 @@ public: // write into the cell StringOutputStream modifiers; modifiers << newAccel; - gtk_list_store_set( GTK_LIST_STORE( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 ); + gtk_list_store_set( ui::ListStore::from( dialog.m_model ), &dialog.m_command_iter, 1, modifiers.c_str(), -1 ); // set the ACTUAL accelerator too! connect_accelerator( commandName ); @@ -379,7 +379,7 @@ public: accelerator_parse(i->second.first, new_text); StringOutputStream modifiers; modifiers << i->second.first; - gtk_list_store_set(GTK_LIST_STORE(model), &row, 1, modifiers.c_str(), -1); + gtk_list_store_set(ui::ListStore::from(model), &row, 1, modifiers.c_str(), -1); } }; */ @@ -389,7 +389,7 @@ void DoCommandListDlg(){ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Mapped Commands", dialog, -1, 400); window.on_key_press([](ui::Widget widget, GdkEventKey *event, gpointer dialogptr) { - return accelerator_window_key_press(widget, event, dialogptr); + return accelerator_window_key_press(ui::Window::from(widget), event, dialogptr); }, &dialog); auto accel = ui::AccelGroup(ui::New); diff --git a/radiant/console.cpp b/radiant/console.cpp index 11295779..8c72bcd7 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -67,7 +67,7 @@ void Sys_LogFile( bool enable ){ << "This is NetRadiant '" RADIANT_VERSION "' compiled " __DATE__ "\n" RADIANT_ABOUTMSG "\n"; } else{ - ui::root.alert( "Failed to create log file, check write permissions in Radiant directory.\n", + ui::root.window().alert( "Failed to create log file, check write permissions in Radiant directory.\n", "Console logging", ui::alert_type::OK, ui::alert_icon::Error ); } } @@ -112,8 +112,8 @@ ui::Widget Console_constructWindow( ui::Window toplevel ){ { auto text = ui::TextView(ui::New); gtk_widget_set_size_request( text, 0, -1 ); // allow shrinking - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text ), GTK_WRAP_WORD ); - gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), FALSE ); + gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD ); + gtk_text_view_set_editable( text, FALSE ); scr.add(text); text.show(); g_console = text; @@ -163,7 +163,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ if ( level != SYS_NOCON ) { if ( g_console ) { - GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( g_console ) ); + GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_console ); GtkTextIter iter; gtk_text_buffer_get_end_iter( buffer, &iter ); @@ -207,7 +207,7 @@ std::size_t Sys_Print( int level, const char* buf, std::size_t length ){ // update console widget immediatly if we're doing something time-consuming if ( contains_newline ) { - gtk_text_view_scroll_mark_onscreen( GTK_TEXT_VIEW( g_console ), end ); + gtk_text_view_scroll_mark_onscreen( g_console, end ); if ( !ScreenUpdates_Enabled() && gtk_widget_get_realized( g_console ) ) { ScreenUpdates_process(); diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index e588f93f..2a6e4138 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -453,20 +453,20 @@ EMessageBoxReturn Dialog::DoModal(){ } -ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ +ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){ auto check = ui::CheckButton( flag ); check.show(); AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(DialogRow_new( name, check ) )); + DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, check ) )); return check; } -ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ){ +ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){ return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) ); } -void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show(); { @@ -484,14 +484,14 @@ void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange value } auto row = DialogRow_new( name, alignment ); - DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row ); + DialogVBox_packRow( vbox, row ); } -void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){ +void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){ addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ +void Dialog::addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){ #if 0 if ( draw_value == FALSE ) { auto hbox2 = ui::HBox( FALSE, 0 ); @@ -527,10 +527,10 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); auto row = DialogRow_new( name, alignment ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); + DialogVBox_packRow( vbox, row ); } -void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show();; { @@ -540,14 +540,14 @@ void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names } auto row = DialogRow_new( name, alignment ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); + DialogVBox_packRow( vbox, row ); } -void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){ +void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){ addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) ); } -void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE ); table.show();; @@ -576,64 +576,64 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) ); + DialogVBox_packRow( vbox, DialogRow_new( name, table ) ); } -void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){ +void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){ addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) ); } -ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddIntEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + DialogVBox_packRow( vbox, row.m_row ); return row.m_row; } -ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ +ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddSizeEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + DialogVBox_packRow( vbox, row.m_row ); return row.m_row; } -ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogEntryRow row( DialogEntryRow_new( name ) ); AddFloatEntryData( *GTK_ENTRY(row.m_entry), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + DialogVBox_packRow( vbox, row.m_row ); return row.m_row; } -ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ +ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){ PathEntry pathEntry = PathEntry_new(); pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry ); AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer ); auto row = DialogRow_new( name, ui::Widget(pathEntry.m_frame ) ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row ); + DialogVBox_packRow( vbox, row ); return ui::Widget(row ); } -ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool browse_directory ){ +ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){ return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) ); } -ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) ); AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + DialogVBox_packRow( vbox, row.m_row ); return ui::SpinButton(row.m_spin); } -ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ){ +ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){ return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) ); } -ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ +ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){ DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) ); AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), importViewer, exportViewer ); - DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row ); + DialogVBox_packRow( vbox, row.m_row ); return ui::SpinButton(row.m_spin); } diff --git a/radiant/dialog.h b/radiant/dialog.h index cf1c4858..b862daa0 100644 --- a/radiant/dialog.h +++ b/radiant/dialog.h @@ -133,32 +133,32 @@ const ui::Window GetWidget() const { return m_window; } -ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); -ui::CheckButton addCheckBox( ui::Widget vbox, const char* name, const char* flag, bool& data ); -void addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ); -void addSlider( ui::Widget vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); -void addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ); -void addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -void addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ); -ui::Widget addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -ui::Widget addEntry( ui::Widget vbox, const char* name, int& data ){ +ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback ); +ui::CheckButton addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ); +void addCombo( ui::VBox vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ); +void addSlider( ui::VBox vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ); +void addRadio( ui::VBox vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ); +void addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +void addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ); +ui::Widget addIntEntry( ui::VBox vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::Widget addEntry( ui::VBox vbox, const char* name, int& data ){ return addIntEntry( vbox, name, IntImportCaller( data ), IntExportCaller( data ) ); } -ui::Widget addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); -ui::Widget addEntry( ui::Widget vbox, const char* name, std::size_t& data ){ +ui::Widget addSizeEntry( ui::VBox vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback ); +ui::Widget addEntry( ui::VBox vbox, const char* name, std::size_t& data ){ return addSizeEntry( vbox, name, SizeImportCaller( data ), SizeExportCaller( data ) ); } -ui::Widget addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); -ui::Widget addEntry( ui::Widget vbox, const char* name, float& data ){ +ui::Widget addFloatEntry( ui::VBox vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addEntry( ui::VBox vbox, const char* name, float& data ){ return addFloatEntry( vbox, name, FloatImportCaller( data ), FloatExportCaller( data ) ); } -ui::Widget addPathEntry( ui::Widget vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); -ui::Widget addPathEntry( ui::Widget vbox, const char* name, CopiedString& data, bool directory ); -ui::SpinButton addSpinner( ui::Widget vbox, const char* name, int& data, double value, double lower, double upper ); -ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); -ui::SpinButton addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback ); +ui::Widget addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool directory ); +ui::SpinButton addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ); +ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback ); +ui::SpinButton addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback ); protected: diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index a82d7797..4aa63242 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -240,7 +240,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = misc_model_dialog( ui::Widget(gtk_widget_get_toplevel( m_entry.m_entry.m_frame ) )); + const char *filename = misc_model_dialog( m_entry.m_entry.m_frame.window() ); if ( filename != 0 ) { setPath( filename ); @@ -303,7 +303,7 @@ void update(){ } typedef MemberCaller UpdateCaller; void browse( const BrowsedPathEntry::SetPathCallback& setPath ){ - const char *filename = browse_sound( ui::Widget(gtk_widget_get_toplevel( m_entry.m_entry.m_frame )) ); + const char *filename = browse_sound( m_entry.m_entry.m_frame.window() ); if ( filename != 0 ) { setPath( filename ); @@ -1085,13 +1085,13 @@ void EntityInspector_selectionChanged( const Selectable& ){ // Creates a new entity based on the currently selected brush and entity type. // void EntityClassList_createEntity(){ - GtkTreeView* view = g_entityClassList; + auto view = ui::Widget::from(g_entityClassList); // find out what type of entity we are trying to create GtkTreeModel* model; GtkTreeIter iter; - if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( view ), &model, &iter ) == FALSE ) { - ui::Widget(gtk_widget_get_toplevel( ui::TreeView(g_entityClassList) )).alert( "You must have a selected class to create an entity", "info" ); + if ( gtk_tree_selection_get_selected( gtk_tree_view_get_selection( g_entityClassList ), &model, &iter ) == FALSE ) { + view.window().alert( "You must have a selected class to create an entity", "info" ); return; } @@ -1119,14 +1119,14 @@ void EntityInspector_applyKeyValue(){ // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity if ( !strcmp( key.c_str(), "classname" ) && !strcmp( value.c_str(), "worldspawn" ) ) { - ui::Widget(gtk_widget_get_toplevel( g_entityKeyEntry ) ).alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK ); + g_entityKeyEntry.window().alert( "Cannot change \"classname\" key back to worldspawn.", 0, ui::alert_type::OK ); return; } // RR2DO2: we don't want spaces in entity keys if ( strstr( key.c_str(), " " ) ) { - ui::Widget(gtk_widget_get_toplevel( g_entityKeyEntry ) ).alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK ); + g_entityKeyEntry.window().alert( "No spaces are allowed in entity keys.", 0, ui::alert_type::OK ); return; } @@ -1262,7 +1262,7 @@ static gint EntityEntry_keypress( ui::Entry widget, GdkEventKey* event, gpointer if ( event->keyval == GDK_KEY_Return ) { if ( widget._handle == g_entityKeyEntry._handle ) { g_entityValueEntry.text( "" ); - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), g_entityValueEntry ); + gtk_window_set_focus( widget.window(), g_entityValueEntry ); } else { @@ -1271,7 +1271,7 @@ static gint EntityEntry_keypress( ui::Entry widget, GdkEventKey* event, gpointer return TRUE; } if ( event->keyval == GDK_KEY_Escape ) { - gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( widget ) ), NULL ); + gtk_window_set_focus( widget.window(), NULL ); return TRUE; } diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index 261d625b..78033931 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -81,7 +81,7 @@ void GroupDialog_updatePageTitle( ui::Window window, std::size_t pageIndex ){ } static gboolean switch_page( GtkNotebook *notebook, gpointer page, guint page_num, gpointer data ){ - GroupDialog_updatePageTitle( ui::Window(GTK_WINDOW( data )), page_num ); + GroupDialog_updatePageTitle( ui::Window::from(data), page_num ); g_current_page = page_num; return FALSE; diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index e35159fa..9f07e893 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -568,10 +568,10 @@ void DoAbout(){ frame.add(sc_extensions); { auto text_extensions = ui::TextView(ui::New); - gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE ); + gtk_text_view_set_editable( text_extensions, FALSE ); sc_extensions.add(text_extensions); text_extensions.text(reinterpret_cast(glGetString(GL_EXTENSIONS))); - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD ); + gtk_text_view_set_wrap_mode( text_extensions, GTK_WRAP_WORD ); text_extensions.show(); } } @@ -706,11 +706,11 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ // Text Editor dialog // master window widget -static ui::Widget text_editor{ui::null}; +static ui::Window text_editor{ui::null}; static ui::Widget text_widget{ui::null}; // slave, text widget from the gtk editor static gint editor_delete( ui::Widget widget, gpointer data ){ - if ( widget.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { + if ( widget.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return TRUE; } @@ -724,7 +724,7 @@ static void editor_save( ui::Widget widget, gpointer data ){ gpointer text = g_object_get_data( G_OBJECT( data ), "text" ); if ( f == 0 ) { - ui::Widget::from(data).alert( "Error saving file !" ); + ui::Widget::from(data).window().alert( "Error saving file !" ); return; } @@ -734,7 +734,7 @@ static void editor_save( ui::Widget widget, gpointer data ){ } static void editor_close( ui::Widget widget, gpointer data ){ - if ( text_editor.alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { + if ( text_editor.window().alert( "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) { return; } @@ -746,7 +746,7 @@ static void CreateGtkTextEditor(){ dlg.connect( "delete_event", G_CALLBACK( editor_delete ), 0 ); - gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 ); + gtk_window_set_default_size( dlg, 600, 300 ); auto vbox = ui::VBox( FALSE, 5 ); vbox.show(); @@ -763,7 +763,7 @@ static void CreateGtkTextEditor(){ scr.add(text); text.show(); g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text ); - gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE ); + gtk_text_view_set_editable( text, TRUE ); auto hbox = ui::HBox( FALSE, 5 ); hbox.show(); @@ -809,9 +809,9 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){ rewind( f ); fread( buf, 1, len, f ); - gtk_window_set_title( GTK_WINDOW( text_editor ), filename ); + gtk_window_set_title( text_editor, filename ); - GtkTextBuffer* text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_widget ) ); + GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(ui::TextView::from(text_widget)); gtk_text_buffer_set_text( text_buffer, (char*)buf, len ); old_filename = g_object_get_data( G_OBJECT( text_editor ), "filename" ); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 0f210221..aa334a1c 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -97,23 +97,23 @@ ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const ch // ============================================================================= // File dialog -bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ +bool color_dialog( ui::Window parent, Vector3& color, const char* title ){ GdkColor clr = { 0, guint16(color[0] * 65535), guint16(color[1] * 65535), guint16(color[2] * 65535) }; ModalDialog dialog; - auto dlg = ui::Widget(gtk_color_selection_dialog_new( title )); + auto dlg = ui::Window::from(gtk_color_selection_dialog_new( title )); gtk_color_selection_set_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); dlg.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), &dialog ); GtkWidget *ok_button, *cancel_button; - g_object_get(dlg, "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); + g_object_get(G_OBJECT(dlg), "ok-button", &ok_button, "cancel-button", &cancel_button, nullptr); ui::Widget(ok_button).connect( "clicked", G_CALLBACK( dialog_button_ok ), &dialog ); ui::Widget(cancel_button).connect( "clicked", G_CALLBACK( dialog_button_cancel ), &dialog ); if ( parent ) { - gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( parent ) ); + gtk_window_set_transient_for( dlg, parent ); } - bool ok = modal_dialog_show( ui::Window(GTK_WINDOW( dlg )), dialog ) == eIDOK; + bool ok = modal_dialog_show( dlg, dialog ) == eIDOK; if ( ok ) { gtk_color_selection_get_current_color( GTK_COLOR_SELECTION( gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG( dlg )) ), &clr ); color[0] = clr.red / 65535.0f; @@ -127,7 +127,7 @@ bool color_dialog( ui::Widget parent, Vector3& color, const char* title ){ } void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){ - const char *filename = ui::Widget(gtk_widget_get_toplevel( widget )).file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); + const char *filename = widget.file_dialog( TRUE, "Choose File", gtk_entry_get_text( entry ) ); if ( filename != 0 ) { entry.text(filename); @@ -136,7 +136,7 @@ void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ){ void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ){ const char* text = gtk_entry_get_text( entry ); - char *dir = dir_dialog( ui::Widget(gtk_widget_get_toplevel( widget )), "Choose Directory", path_is_absolute( text ) ? text : "" ); + char *dir = dir_dialog( widget.window(), "Choose Directory", path_is_absolute( text ) ? text : "" ); if ( dir != 0 ) { gchar* converted = g_filename_to_utf8( dir, -1, 0, 0, 0 ); diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index ed6114ce..e867d6a2 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -52,7 +52,7 @@ ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const ch template class BasicVector3; typedef BasicVector3 Vector3; -bool color_dialog( ui::Widget parent, Vector3& color, const char* title = "Choose Color" ); +bool color_dialog( ui::Window parent, Vector3& color, const char* title = "Choose Color" ); void button_clicked_entry_browse_file( ui::Widget widget, ui::Entry entry ); void button_clicked_entry_browse_directory( ui::Widget widget, ui::Entry entry ); diff --git a/radiant/main.cpp b/radiant/main.cpp index 4fa42d27..fd451524 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -304,12 +304,12 @@ bool handleMessage(){ ScopedLock lock( m_lock ); #if GDEF_DEBUG m_buffer << "Break into the debugger?\n"; - bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO; + bool handled = ui::root.window().alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO; m_buffer.clear(); return handled; #else m_buffer << "Please report this error to the developers\n"; - ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error ); + ui::root.window().alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error ); m_buffer.clear(); #endif } @@ -390,7 +390,7 @@ bool check_version(){ msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n" "Make sure you run the right/latest editor binary you installed\n" << AppPath_get(); - ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default); + ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default); } return bVerIsGood; #else @@ -418,7 +418,7 @@ void create_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); + ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -428,14 +428,14 @@ void create_global_pid(){ "The failure may be related to current global preferences.\n" "Do you want to reset global preferences to defaults?"; - if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { + if ( ui::root.window().alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { g_GamesDialog.Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); + ui::root.window().alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // set without saving, the class is not in a coherent state yet @@ -459,7 +459,7 @@ void remove_global_pid(){ if ( remove( g_pidFile.c_str() ) == -1 ) { StringOutputStream msg( 256 ); msg << "WARNING: Could not delete " << g_pidFile.c_str(); - ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); + ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } } @@ -477,7 +477,7 @@ void create_local_pid(){ if ( remove( g_pidGameFile.c_str() ) == -1 ) { StringOutputStream msg; msg << "WARNING: Could not delete " << g_pidGameFile.c_str(); - ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); + ui::root.window().alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error ); } // in debug, never prompt to clean registry, turn console logging auto after a failed start @@ -487,14 +487,14 @@ void create_local_pid(){ "The failure may be caused by current preferences.\n" "Do you want to reset all preferences to defaults?"; - if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { + if ( ui::root.window().alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) { Preferences_Reset(); } msg.clear(); msg << "Logging console output to " << SettingsPath_get() << "radiant.log\nRefer to the log if Radiant fails to start again."; - ui::root.alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); + ui::root.window().alert( msg.c_str(), "Radiant - Console Log", ui::alert_type::OK ); #endif // force console logging on! (will go in prefs too) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index c06c2904..a40a923c 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1659,7 +1659,7 @@ bool MainFrame_isActiveApp(){ for ( GList* i = list; i != 0; i = g_list_next( i ) ) { //globalOutputStream() << "toplevel.. "; - if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) { + if ( gtk_window_is_active( ui::Window::from( i->data ) ) ) { //globalOutputStream() << "is active\n"; return true; } diff --git a/radiant/pluginapi.cpp b/radiant/pluginapi.cpp index fff61864..c006913d 100644 --- a/radiant/pluginapi.cpp +++ b/radiant/pluginapi.cpp @@ -51,7 +51,7 @@ void QERApp_GetCamWindowExtents( int *x, int *y, int *width, int *height ){ #if 0 CamWnd* camwnd = g_pParentWnd->GetCamWnd(); - gtk_window_get_position( GTK_WINDOW( camwnd->m_window ), x, y ); + gtk_window_get_position( camwnd->m_window, x, y ); *width = camwnd->Camera()->width; *height = camwnd->Camera()->height; diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index ed4daf52..7d21c16c 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -326,7 +326,7 @@ ui::Window CGameDialog::BuildDialog(){ frame.add(vbox2); { - PreferencesPage preferencesPage( *this, ui::Widget(vbox2 ) ); + PreferencesPage preferencesPage( *this, vbox2 ); Global_constructPreferences( preferencesPage ); CreateGlobalFrame( preferencesPage ); } @@ -482,7 +482,7 @@ CGameDialog g_GamesDialog; static void OnButtonClean( ui::Widget widget, gpointer data ){ // make sure this is what the user wants - if ( ui::Widget(g_Preferences.GetWidget( )).alert( "This will close Radiant and clean the corresponding registry entries.\n" + if ( g_Preferences.GetWidget().alert( "This will close Radiant and clean the corresponding registry entries.\n" "Next time you start Radiant it will be good as new. Do you wish to continue?", "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) { PrefsDlg *dlg = (PrefsDlg*)data; @@ -629,8 +629,8 @@ void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){ } -inline ui::Widget getVBox( ui::Widget page ){ - return ui::Widget(gtk_bin_get_child( GTK_BIN( page ) )); +inline ui::VBox getVBox( ui::Bin page ){ + return ui::VBox::from(gtk_bin_get_child(page)); } GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, ui::Widget page ){ @@ -640,7 +640,7 @@ GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, return group; } -ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){ +ui::Bin PreferencePages_addPage( ui::Widget notebook, const char* name ){ ui::Widget preflabel = ui::Label( name ); preflabel.show(); @@ -673,7 +673,7 @@ PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, GtkTreeStore* store, G m_group( group ){ } PreferencesPage createPage( const char* treeName, const char* frameName ){ - ui::Widget page = PreferencePages_addPage( m_notebook, frameName ); + auto page = PreferencePages_addPage( m_notebook, frameName ); PreferenceTree_appendPage( m_store, &m_group, treeName, page ); return PreferencesPage( m_dialog, getVBox( page ) ); } @@ -760,14 +760,14 @@ ui::Window PrefsDlg::BuildDialog(){ PreferencePages_addPage( m_notebook, "Front Page" ); { - ui::Widget global = PreferencePages_addPage( m_notebook, "Global Preferences" ); + auto global = PreferencePages_addPage( m_notebook, "Global Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( global ) ); Global_constructPreferences( preferencesPage ); } GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global ); { - ui::Widget game = PreferencePages_addPage( m_notebook, "Game" ); + auto game = PreferencePages_addPage( m_notebook, "Game" ); PreferencesPage preferencesPage( *this, getVBox( game ) ); g_GamesDialog.CreateGlobalFrame( preferencesPage ); @@ -776,7 +776,7 @@ ui::Window PrefsDlg::BuildDialog(){ } { - ui::Widget interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); + auto interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( interfacePage ) ); PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage ); @@ -789,7 +789,7 @@ ui::Window PrefsDlg::BuildDialog(){ } { - ui::Widget display = PreferencePages_addPage( m_notebook, "Display Preferences" ); + auto display = PreferencePages_addPage( m_notebook, "Display Preferences" ); { PreferencesPage preferencesPage( *this, getVBox( display ) ); PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage ); @@ -801,7 +801,7 @@ ui::Window PrefsDlg::BuildDialog(){ } { - ui::Widget settings = PreferencePages_addPage( m_notebook, "General Settings" ); + auto settings = PreferencePages_addPage( m_notebook, "General Settings" ); { PreferencesPage preferencesPage( *this, getVBox( settings ) ); PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage ); diff --git a/radiant/preferences.h b/radiant/preferences.h index 0f6804f7..c959ad3e 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -39,9 +39,9 @@ void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ); class PreferencesPage { Dialog& m_dialog; -ui::Widget m_vbox; +ui::VBox m_vbox; public: -PreferencesPage( Dialog& dialog, ui::Widget vbox ) : m_dialog( dialog ), m_vbox( vbox ){ +PreferencesPage( Dialog& dialog, ui::VBox vbox ) : m_dialog( dialog ), m_vbox( vbox ){ } ui::CheckButton appendCheckBox( const char* name, const char* flag, bool& data ){ return m_dialog.addCheckBox( m_vbox, name, flag, data ); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 5197d5e2..cf623b69 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -2320,7 +2320,7 @@ void TextureBrowser_renameTag(){ } else { - ui::Widget(g_TextureBrowser.m_parent ).alert( "Select a single tag for renaming." ); + g_TextureBrowser.m_parent.alert( "Select a single tag for renaming." ); } } @@ -2331,7 +2331,7 @@ void TextureBrowser_deleteTag(){ gtk_tree_selection_selected_foreach( selection, GtkTreeSelectionForeachFunc( TextureBrowser_selectionHelper ), &selected ); if ( g_slist_length( selected ) == 1 ) { // we only delete a single tag - auto result = ui::Widget(g_TextureBrowser.m_parent ).alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question ); + auto result = g_TextureBrowser.m_parent.alert( "Are you sure you want to delete the selected tag?", "Delete Tag", ui::alert_type::YESNO, ui::alert_icon::Question ); if ( result == ui::alert_response::YES ) { GtkTreeIter iterSelected; @@ -2360,7 +2360,7 @@ void TextureBrowser_deleteTag(){ } } else { - ui::Widget(g_TextureBrowser.m_parent ).alert( "Select a single tag for deletion." ); + g_TextureBrowser.m_parent.alert( "Select a single tag for deletion." ); } } @@ -2452,7 +2452,7 @@ void TextureBrowser_showAll(){ } void TextureBrowser_showUntagged(){ - auto result = ui::Widget(g_TextureBrowser.m_parent ).alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning ); + auto result = g_TextureBrowser.m_parent.alert( "WARNING! This function might need a lot of memory and time. Are you sure you want to use it?", "Show Untagged", ui::alert_type::YESNO, ui::alert_icon::Warning ); if ( result == ui::alert_response::YES ) { g_TextureBrowser.m_found_shaders.clear(); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 9203f964..2365df8c 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1488,7 +1488,7 @@ void XYWnd::XY_DisableBackground( void ){ void WXY_BackgroundSelect( void ){ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0; if ( !brushesSelected ) { - ui::root.alert( "You have to select some brushes to get the bounding box for.\n", + ui::root.window().alert( "You have to select some brushes to get the bounding box for.\n", "No selection", ui::alert_type::OK, ui::alert_icon::Error ); return; }