From: TimePath Date: Sat, 22 Jul 2017 04:34:22 +0000 (+1000) Subject: Purge gtk_container_add X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=225950494a606af9aac2bc2f06ece70cb2146481 Purge gtk_container_add --- diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index a787c8fa..7ec945b4 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -172,8 +172,6 @@ void CBackgroundDialogPage::SetPosLabel(){ } CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ - GtkWidget *frame; - GtkWidget *hbox; GtkWidget *w; m_vt = vt; @@ -198,13 +196,13 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ // A vbox to hold everything m_pWidget = ui::VBox( FALSE,0 ); // Frame for file row - frame = ui::Frame( "File" ); + auto frame = ui::Frame( "File" ); gtk_box_pack_start( GTK_BOX( m_pWidget ),frame, FALSE, FALSE, 2 ); // hbox for first row - hbox = ui::HBox( FALSE,5 ); + auto hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + frame.add(hbox); // label to display filename m_pFileLabel = ui::Label( NO_FILE_MSG ); @@ -239,7 +237,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ hbox = ui::HBox( FALSE,5 ); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + frame.add(hbox); w = ui::Label( "Vertex alpha:" ); gtk_box_pack_start( GTK_BOX( hbox ),w, FALSE, FALSE, 5 ); @@ -262,7 +260,7 @@ CBackgroundDialogPage::CBackgroundDialogPage( VIEWTYPE vt ){ gtk_box_pack_start( GTK_BOX( m_pWidget ), frame, FALSE, FALSE, 2 ); hbox = ui::HBox( FALSE,5 ); - gtk_container_add( GTK_CONTAINER( frame ), hbox ); + frame.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ),4 ); w = ui::Button( "from selection" ); diff --git a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp index 19b773fa..954747bc 100644 --- a/contrib/bobtoolz/dialogs/dialogs-gtk.cpp +++ b/contrib/bobtoolz/dialogs/dialogs-gtk.cpp @@ -209,11 +209,11 @@ bool ValidateTextInt( const char* pData, char* error_title, int* value ){ */ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){ - ui::Widget window, w, vbox, hbox; + ui::Widget w, vbox, hbox; EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", @@ -225,7 +225,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess gtk_widget_realize( window ); vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + window.add(vbox); gtk_widget_show( vbox ); w = ui::Label( lpText ); @@ -321,12 +321,12 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess } EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *hbox; GtkWidget *check1, *check2; EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -341,8 +341,8 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- @@ -416,7 +416,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){ } EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox, *vbox2, *hbox2; + GtkWidget *w, *hbox, *vbox2, *hbox2; GtkWidget *check1, *check2, *check3; GtkWidget *text1, *text2; @@ -424,7 +424,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -439,9 +439,9 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- @@ -586,8 +586,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){ // for stair builder stuck as close as i could to the MFC version // obviously feel free to change it at will :) EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ - // i made widgets for just about everything ... i think that's what i need to do dunno tho - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w; GtkWidget *textStairHeight, *textRiserTex, *textMainTex; GtkWidget *radioNorth, *radioSouth, *radioEast, *radioWest; // i'm guessing we can't just abuse 'w' for these if we're getting a value GtkWidget *radioOldStyle, *radioBobStyle, *radioCornerStyle; @@ -598,7 +597,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ char *text = "Please set a value in the boxes below and press 'OK' to build the stairs"; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -613,12 +612,12 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); - hbox = ui::HBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( vbox ), hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + vbox.add(hbox); gtk_widget_show( hbox ); // dunno if you want this text or not ... @@ -843,7 +842,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){ } EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ - GtkWidget *window, *hbox, *vbox, *w; + GtkWidget *hbox, *w; GtkWidget *textFrontBackTex, *textTrimTex; GtkWidget *checkScaleMainH, *checkScaleMainV, *checkScaleTrimH, *checkScaleTrimV; GtkWidget *comboMain, *comboTrim; @@ -854,7 +853,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -874,8 +873,8 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures ); LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures ); - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // -------------------------- // @@ -1059,7 +1058,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){ } EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *hbox; GtkWidget *text1, *text2, *text3; GtkWidget *check1, *check2; @@ -1067,7 +1066,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -1082,8 +1081,8 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- @@ -1234,11 +1233,11 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){ } EMessageBoxReturn DoCTFColourChangeBox(){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *hbox; EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -1253,8 +1252,8 @@ EMessageBoxReturn DoCTFColourChangeBox(){ - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); gtk_widget_show( vbox ); // ---- vbox ---- @@ -1304,12 +1303,12 @@ EMessageBoxReturn DoCTFColourChangeBox(){ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ Str texSelected; - GtkWidget *window, *w, *vbox, *hbox, *frame, *table; + GtkWidget *w, *hbox; EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -1322,9 +1321,9 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_widget_realize( window ); - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- @@ -1344,13 +1343,13 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ // ---- /hbox ---- - frame = ui::Frame( "Reset Texture Names" ); + auto frame = ui::Frame( "Reset Texture Names" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + auto table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1397,8 +1396,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1453,8 +1452,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1509,8 +1508,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 1, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1635,7 +1634,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ Str texSelected; - GtkWidget *window, *w, *vbox, *hbox, *frame, *table; + GtkWidget *w, *hbox; GtkWidget *radiusX, *radiusY; GtkWidget *angleStart, *angleEnd; @@ -1645,7 +1644,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ EMessageBoxReturn ret; int loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -1658,9 +1657,9 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_widget_realize( window ); - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); // ---- vbox ---- @@ -1670,13 +1669,13 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ---- /hbox ---- - frame = ui::Frame( "Radii" ); + auto frame = ui::Frame( "Radii" ); gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); - table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + auto table = ui::Table( 2, 3, TRUE ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1718,8 +1717,8 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1760,8 +1759,8 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1803,8 +1802,8 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 2, 3, TRUE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + table.show(); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -1901,14 +1900,14 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){ // ailmanki // add a simple input for the MakeChain thing.. EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w; GtkWidget *textlinkNum, *textlinkName; EMessageBoxReturn ret; int loop = 1; - char *text = "Please set a value in the boxes below and press 'OK' to make a chain"; + char const *text = "Please set a value in the boxes below and press 'OK' to make a chain"; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -1923,13 +1922,13 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){ gtk_widget_realize( window ); // new vbox - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); - hbox = ui::HBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( vbox ), hbox ); - gtk_widget_show( hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + vbox.add(hbox); + hbox.show(); // dunno if you want this text or not ... w = ui::Label( text ); diff --git a/contrib/brushexport/interface.cpp b/contrib/brushexport/interface.cpp index dc37bc8c..131883ed 100644 --- a/contrib/brushexport/interface.cpp +++ b/contrib/brushexport/interface.cpp @@ -15,8 +15,6 @@ // created by glade GtkWidget* create_w_plugplug2( void ){ - GtkWidget *w_plugplug2; - GtkWidget *vbox1; GtkWidget *hbox2; GtkWidget *vbox4; GtkWidget *r_collapse; @@ -28,8 +26,6 @@ create_w_plugplug2( void ){ GtkWidget *b_close; GtkWidget *vbox2; GtkWidget *label1; - GtkWidget *scrolledwindow1; - GtkWidget *t_materialist; GtkWidget *ed_materialname; GtkWidget *hbox1; GtkWidget *b_addmaterial; @@ -38,16 +34,16 @@ create_w_plugplug2( void ){ GtkWidget *t_limitmatnames; GtkWidget *t_objects; - w_plugplug2 = ui::Window( ui::window_type::TOP ); + 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 ); - vbox1 = ui::VBox( FALSE, 0 ); + auto vbox1 = ui::VBox( FALSE, 0 ); gtk_widget_set_name( vbox1, "vbox1" ); gtk_widget_show( vbox1 ); - gtk_container_add( GTK_CONTAINER( w_plugplug2 ), vbox1 ); + w_plugplug2.add(vbox1); gtk_container_set_border_width( GTK_CONTAINER( vbox1 ), 5 ); hbox2 = ui::HBox( TRUE, 5 ); @@ -113,17 +109,17 @@ create_w_plugplug2( void ){ gtk_widget_show( label1 ); gtk_box_pack_start( GTK_BOX( vbox2 ), label1, FALSE, FALSE, 0 ); - scrolledwindow1 = ui::ScrolledWindow(); + auto scrolledwindow1 = ui::ScrolledWindow(); gtk_widget_set_name( scrolledwindow1, "scrolledwindow1" ); - gtk_widget_show( scrolledwindow1 ); + scrolledwindow1.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), scrolledwindow1, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scrolledwindow1 ), GTK_SHADOW_IN ); - t_materialist = ui::TreeView(); + auto t_materialist = ui::TreeView(); gtk_widget_set_name( t_materialist, "t_materialist" ); - gtk_widget_show( t_materialist ); - gtk_container_add( GTK_CONTAINER( scrolledwindow1 ), t_materialist ); + t_materialist.show(); + scrolledwindow1.add(t_materialist); gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( t_materialist ), FALSE ); gtk_tree_view_set_enable_search( GTK_TREE_VIEW( t_materialist ), FALSE ); diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index 460f8abf..a3b8423d 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -61,7 +61,7 @@ static gint ci_editmode_add( GtkWidget *widget, gpointer data ){ }*/ static gint ci_new( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame; //, *name; + GtkWidget *w, *hbox; //, *name; GtkWidget *fixed, *interpolated, *spline; EMessageBoxReturn ret; int loop = 1; @@ -69,7 +69,7 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ // char buf[128]; // create the window - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "New Camera" ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -81,9 +81,9 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // @@ -91,12 +91,12 @@ static gint ci_new( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = ui::Frame( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -353,7 +353,7 @@ static void RefreshEventList( void ){ } static gint ci_rename( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *hbox, *name; + GtkWidget *w, *hbox, *name; EMessageBoxReturn ret; int loop = 1; @@ -362,7 +362,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } // create the window - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Rename Path" ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -374,9 +374,9 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // @@ -469,7 +469,7 @@ static gint ci_rename( GtkWidget *widget, gpointer data ){ } static gint ci_add_target( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *name; + GtkWidget *w, *hbox, *name; GtkWidget *fixed, *interpolated, *spline; EMessageBoxReturn ret; int loop = 1; @@ -481,7 +481,7 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ } // create the window - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Target" ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -493,9 +493,9 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // @@ -520,12 +520,12 @@ static gint ci_add_target( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = ui::Frame( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -817,7 +817,7 @@ const char *camEventStr[] = { }; static gint ci_add( GtkWidget *widget, gpointer data ){ - GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *parameters; + GtkWidget *w, *hbox, *parameters; GtkWidget *eventWidget[EVENT_COUNT]; EMessageBoxReturn ret; int i, loop = 1; @@ -829,7 +829,7 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ } // create the window - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Add Event" ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", G_CALLBACK( gtk_widget_destroy ), NULL ); @@ -841,9 +841,9 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ gtk_widget_realize( window ); // fill the window - vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + window.add(vbox); + vbox.show(); // -------------------------- // @@ -851,12 +851,12 @@ static gint ci_add( GtkWidget *widget, gpointer data ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - frame = ui::Frame( "Type" ); + auto frame = ui::Frame( "Type" ); gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 ); gtk_widget_show( frame ); - vbox2 = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); gtk_widget_show( vbox2 ); @@ -992,10 +992,10 @@ static gint ci_timeline_changed( GtkAdjustment *adjustment ){ } GtkWidget *CreateCameraInspectorDialog( void ){ - GtkWidget *window, *w, *vbox, *hbox, *table, *frame; + GtkWidget *w, *hbox; // create the window - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( window ), "Camera Inspector" ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( ci_close ), NULL ); g_signal_connect( GTK_OBJECT( window ), "expose_event", G_CALLBACK( ci_expose ), NULL ); @@ -1010,9 +1010,9 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // the table // -------------------------- // - table = ui::Table( 3, 2, FALSE ); - gtk_widget_show( table ); - gtk_container_add( GTK_CONTAINER( window ), table ); + auto table = ui::Table( 3, 2, FALSE ); + table.show(); + window.add(table); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); @@ -1070,16 +1070,16 @@ GtkWidget *CreateCameraInspectorDialog( void ){ // -------------------------- // - frame = ui::Frame( "Path and Target editing" ); - gtk_widget_show( frame ); + auto frame = ui::Frame( "Path and Target editing" ); + frame.show(); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); - vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - gtk_widget_show( vbox ); + vbox.show(); // -------------------------- // @@ -1171,9 +1171,9 @@ GtkWidget *CreateCameraInspectorDialog( void ){ (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); vbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - gtk_widget_show( vbox ); + vbox.show(); // -------------------------- // @@ -1252,14 +1252,14 @@ GtkWidget *CreateCameraInspectorDialog( void ){ gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 ); gtk_widget_show( hbox ); - w = ui::ScrolledWindow(); + auto scr = w = ui::ScrolledWindow(); gtk_widget_set_size_request( w, 0, 150 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 ); gtk_widget_show( w ); g_pEventsList = gtk_clist_new( 3 ); - gtk_container_add( GTK_CONTAINER( w ), g_pEventsList ); + scr.add(g_pEventsList); //g_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", G_CALLBACK (proplist_select_row), NULL); gtk_clist_set_selection_mode( GTK_CLIST( g_pEventsList ), GTK_SELECTION_BROWSE ); gtk_clist_column_titles_hide( GTK_CLIST( g_pEventsList ) ); diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index d0639f0a..fe41d935 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -1344,7 +1344,7 @@ void create_tooltips(){ // create main dialog GtkWidget* create_main_dialog(){ - GtkWidget *dlg, *vbox, *hbox, *hbox2, *button, *notebook, *frame, *table, *table2; + GtkWidget *hbox2, *button, *notebook, *table2; GtkWidget *check, *spin, *radio, *label, *entry, *scale; ui::Adjustment adj; GSList *group; @@ -1355,15 +1355,15 @@ GtkWidget* create_main_dialog(){ const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90", "Wall facing 180","Wall facing 270" }; - g_pWnd = dlg = ui::Window( ui::window_type::TOP ); + auto dlg = g_pWnd = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), gszCaption ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( main_close ), NULL ); // g_signal_connect (G_OBJECT (dlg), "destroy", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_transient_for( GTK_WINDOW( dlg ), GTK_WINDOW( g_pRadiantWnd ) ); - hbox = ui::HBox( FALSE, 5 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), hbox ); + auto hbox = ui::HBox( FALSE, 5 ); + hbox.show(); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); notebook = gtk_notebook_new(); @@ -1384,15 +1384,15 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( label ); gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), table, label ); - frame = ui::Frame( "Game" ); + auto frame = ui::Frame( "Game" ); gtk_widget_show( frame ); gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); - vbox = ui::VBox( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + auto vbox = ui::VBox( TRUE, 5 ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < NUMGAMES; i++ ) @@ -1412,8 +1412,8 @@ GtkWidget* create_main_dialog(){ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); vbox = ui::VBox( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < 5; i++ ) @@ -1433,8 +1433,8 @@ GtkWidget* create_main_dialog(){ (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); vbox = ui::VBox( TRUE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( frame ), vbox ); + vbox.show(); + frame.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); for ( i = 0, group = NULL; i < 6; i++ ) @@ -1540,10 +1540,10 @@ GtkWidget* create_main_dialog(){ gtk_widget_show( frame ); gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); - table = ui::Table( 3, 4, FALSE ); - gtk_widget_show( table ); + auto table = ui::Table( 3, 4, FALSE ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); @@ -1628,9 +1628,9 @@ GtkWidget* create_main_dialog(){ gtk_box_pack_start( GTK_BOX( hbox2 ), frame, TRUE, TRUE, 0 ); table = ui::Table( 2, 2, FALSE ); - gtk_widget_show( table ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); @@ -1712,9 +1712,9 @@ GtkWidget* create_main_dialog(){ gtk_box_pack_start( GTK_BOX( vbox ), frame, FALSE, TRUE, 0 ); table = ui::Table( 3, 4, FALSE ); - gtk_widget_show( table ); + table.show(); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); diff --git a/contrib/gtkgensurf/gensurf.cpp b/contrib/gtkgensurf/gensurf.cpp index cecc8ab2..1be8b135 100644 --- a/contrib/gtkgensurf/gensurf.cpp +++ b/contrib/gtkgensurf/gensurf.cpp @@ -71,7 +71,7 @@ int Antialiasing; // ^Fishman - Antializing for the preview window. int AddTerrainKey; // ^Fishman - Add terrain key to func_group. int SP; // ^Fishman - Snap to grid. -GtkWidget *g_pWnd; // ghwnd; +ui::Window g_pWnd{ui::null}; // ghwnd; GtkWidget *g_pRadiantWnd; // ghwnd_main; /*HWND ghwndAngles; */GtkWidget *g_pWndPreview; diff --git a/contrib/gtkgensurf/gensurf.h b/contrib/gtkgensurf/gensurf.h index 99e4a46b..521e4ab4 100644 --- a/contrib/gtkgensurf/gensurf.h +++ b/contrib/gtkgensurf/gensurf.h @@ -414,7 +414,7 @@ extern int SP; // ^Fishman - Snap to grid. extern HCURSOR ghCursorVertex; extern HINSTANCE ghInst;*/ extern GtkWidget *g_pRadiantWnd; -extern GtkWidget *g_pWnd; +extern ui::Window g_pWnd; /*extern HWND ghwndAngles; extern HWND ghwndFix; */extern GtkWidget *g_pWndPreview; diff --git a/contrib/gtkgensurf/view.cpp b/contrib/gtkgensurf/view.cpp index 00c74aaa..da39689e 100644 --- a/contrib/gtkgensurf/view.cpp +++ b/contrib/gtkgensurf/view.cpp @@ -363,7 +363,7 @@ static void preview_spin( GtkAdjustment *adj, double *data ){ } void CreateViewWindow(){ - GtkWidget *dlg, *vbox, *hbox, *label, *spin, *frame; + GtkWidget *hbox, *label, *spin; GtkObject *adj; #ifndef ISOMETRIC @@ -371,16 +371,16 @@ void CreateViewWindow(){ azimuth = PI / 6.; #endif - g_pWndPreview = dlg = ui::Window( ui::window_type::TOP ); + auto dlg = g_pWndPreview = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "GtkGenSurf Preview" ); g_signal_connect( GTK_OBJECT( dlg ), "delete_event", G_CALLBACK( preview_close ), NULL ); g_signal_connect( GTK_OBJECT( dlg ), "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 ); - vbox = ui::VBox( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); #ifndef ISOMETRIC hbox = ui::HBox( TRUE, 5 ); @@ -414,8 +414,8 @@ void CreateViewWindow(){ g_signal_connect( G_OBJECT( spin ), "focus_out_event", G_CALLBACK( doublevariable_spinfocusout ), &azimuth ); #endif - frame = ui::Frame( nullptr ); - gtk_widget_show( frame ); + auto frame = ui::Frame( nullptr ); + frame.show(); gtk_frame_set_shadow_type( GTK_FRAME( frame ), GTK_SHADOW_IN ); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); @@ -428,7 +428,7 @@ void CreateViewWindow(){ G_CALLBACK( button_press ), NULL ); gtk_widget_show( g_pPreviewWidget ); - gtk_container_add( GTK_CONTAINER( frame ), g_pPreviewWidget ); + frame.add(ui::Widget(g_pPreviewWidget)); if ( Preview ) { gtk_widget_show( g_pWndPreview ); diff --git a/contrib/hydratoolz/plugin.cpp b/contrib/hydratoolz/plugin.cpp index f2e3d89b..71e7ab68 100644 --- a/contrib/hydratoolz/plugin.cpp +++ b/contrib/hydratoolz/plugin.cpp @@ -81,10 +81,10 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", @@ -95,9 +95,9 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_object_set_data( GTK_OBJECT( window ), "ret", &ret ); gtk_widget_realize( window ); - vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); - gtk_widget_show( vbox ); + auto vbox = ui::VBox( FALSE, 10 ); + window.add(vbox); + vbox.show(); w = ui::Label( lpText ); gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 ); diff --git a/contrib/prtview/AboutDialog.cpp b/contrib/prtview/AboutDialog.cpp index c90c319f..a0dd6834 100644 --- a/contrib/prtview/AboutDialog.cpp +++ b/contrib/prtview/AboutDialog.cpp @@ -50,10 +50,10 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } void DoAboutDlg(){ - GtkWidget *dlg, *hbox, *vbox, *button, *label; + GtkWidget *vbox, *button, *label; int loop = 1, ret = IDCANCEL; - dlg = ui::Window( ui::window_type::TOP ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "About Portal Viewer" ); g_signal_connect( GTK_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); @@ -62,9 +62,9 @@ void DoAboutDlg(){ g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - hbox = ui::HBox( FALSE, 10 ); - gtk_widget_show( hbox ); - gtk_container_add( GTK_CONTAINER( dlg ), hbox ); + auto hbox = ui::HBox( FALSE, 10 ); + hbox.show(); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 10 ); char const *label_text = "Version 1.000\n\n" diff --git a/contrib/prtview/ConfigDialog.cpp b/contrib/prtview/ConfigDialog.cpp index acb9f5b5..dc89bf49 100644 --- a/contrib/prtview/ConfigDialog.cpp +++ b/contrib/prtview/ConfigDialog.cpp @@ -243,14 +243,14 @@ static void OnClip( GtkWidget *widget, gpointer data ){ } void DoConfigDialog(){ - GtkWidget *dlg, *hbox, *vbox, *vbox2, *button, *table, *frame; + GtkWidget *hbox, *button, *table; GtkWidget *lw3slider, *lw3label, *lw2slider, *lw2label, *item; GtkWidget *aa2check, *aa3check, *depthcheck, *linescheck, *polyscheck; GtkWidget *transslider, *translabel, *clipslider, *cliplabel; GtkWidget *show2check, *show3check, *portalcheck; int loop = 1, ret = IDCANCEL; - dlg = ui::Window( ui::window_type::TOP ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Portal Viewer Configuration" ); g_signal_connect( GTK_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); @@ -259,18 +259,18 @@ void DoConfigDialog(){ g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = ui::VBox( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - frame = ui::Frame( "3D View" ); - gtk_widget_show( frame ); + auto frame = ui::Frame( "3D View" ); + frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); - vbox2 = ui::VBox( FALSE, 5 ); - gtk_widget_show( vbox2 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + auto vbox2 = ui::VBox( FALSE, 5 ); + vbox2.show(); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); hbox = ui::HBox( FALSE, 5 ); @@ -405,8 +405,8 @@ void DoConfigDialog(){ gtk_box_pack_start( GTK_BOX( vbox ), frame, TRUE, TRUE, 0 ); vbox2 = ui::VBox( FALSE, 5 ); - gtk_widget_show( vbox2 ); - gtk_container_add( GTK_CONTAINER( frame ), vbox2 ); + vbox2.show(); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); hbox = ui::HBox( FALSE, 5 ); diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index eaee56c4..4e64faf8 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -80,10 +80,10 @@ static void change_clicked( GtkWidget *widget, gpointer data ){ } int DoLoadPortalFileDialog(){ - GtkWidget *dlg, *vbox, *hbox, *button, *entry, *check2d, *check3d; + GtkWidget *hbox, *button, *entry, *check2d, *check3d; int loop = 1, ret = IDCANCEL; - dlg = ui::Window( ui::window_type::TOP ); + auto dlg = ui::Window( ui::window_type::TOP ); gtk_window_set_title( GTK_WINDOW( dlg ), "Load .prt" ); g_signal_connect( GTK_OBJECT( dlg ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); @@ -92,9 +92,9 @@ int DoLoadPortalFileDialog(){ g_object_set_data( G_OBJECT( dlg ), "loop", &loop ); g_object_set_data( G_OBJECT( dlg ), "ret", &ret ); - vbox = ui::VBox( FALSE, 5 ); - gtk_widget_show( vbox ); - gtk_container_add( GTK_CONTAINER( dlg ), vbox ); + auto vbox = ui::VBox( FALSE, 5 ); + vbox.show(); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); entry = ui::Entry(); diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index 9caa98fb..3ace8f02 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -253,9 +253,9 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server // About dialog void about_plugin_window(){ - GtkWidget *window, *vbox, *label, *button; + GtkWidget *label, *button; - window = ui::Window( ui::window_type::TOP ); // create a 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 g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window @@ -264,8 +264,8 @@ void about_plugin_window(){ gtk_window_set_modal( GTK_WINDOW( 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 - vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically - gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window + auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically + window.add(vbox); label = ui::Label( "SunPlug v1.0 for NetRadiant 1.5\nby Topsun" ); // create a label gtk_label_set_justify( GTK_LABEL( label ), GTK_JUSTIFY_LEFT ); // text align left @@ -314,13 +314,13 @@ void GetOptimalCoordinates( AABB *levelBoundingBox ){ // MapCoordinator dialog window void MapCoordinator(){ - GtkWidget *window, *vbox, *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button; + GtkWidget *table, *label, *spinnerMinX, *spinnerMinY, *spinnerMaxX, *spinnerMaxY, *button; Entity *theWorldspawn = NULL; const char *buffer; char line[20]; // in any case we need a window to show the user what to do - window = ui::Window( ui::window_type::TOP ); // create the window + 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 g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( delete_event ), NULL ); // connect the delete event for the window g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( destroy ), NULL ); // connect the destroy event for the window @@ -329,8 +329,8 @@ void MapCoordinator(){ gtk_window_set_modal( GTK_WINDOW( 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 - vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically - gtk_container_add( GTK_CONTAINER( window ), vbox ); // add the box to the window + auto vbox = ui::VBox( FALSE, 10 ); // create a box to arrange new objects vertically + window.add(vbox); scene::Path path = makeReference( GlobalSceneGraph().root() ); // get the path to the root element of the graph scene::Instance* instance = GlobalSceneGraph().find( path ); // find the instance to the given path diff --git a/libs/gtkutil/button.cpp b/libs/gtkutil/button.cpp index 778a74a8..af19ef35 100644 --- a/libs/gtkutil/button.cpp +++ b/libs/gtkutil/button.cpp @@ -73,7 +73,7 @@ guint toggle_button_connect_callback( ui::ToggleToolButton button, const Callbac void button_set_icon( ui::Button button, const char* icon ){ ui::Image image = ui::Image(new_local_image( icon )); image.show(); - gtk_container_add( GTK_CONTAINER( button ), GTK_WIDGET( image ) ); + button.add(image); } void toggle_button_set_active_no_signal( ui::ToggleButton button, gboolean active ){ diff --git a/libs/gtkutil/container.h b/libs/gtkutil/container.h index d931f0f0..8e70e35a 100644 --- a/libs/gtkutil/container.h +++ b/libs/gtkutil/container.h @@ -25,13 +25,13 @@ #include inline ui::Widget container_add_widget( ui::Container container, ui::Widget widget ){ - gtk_container_add( container, widget ); + container.add(widget); return widget; } inline void container_remove( ui::Widget item, gpointer data ){ auto container = ui::Container(GTK_CONTAINER( data )); - gtk_container_remove( container, item ); + container.add(item); } inline void container_remove_all( ui::Container container ){ diff --git a/libs/gtkutil/dialog.cpp b/libs/gtkutil/dialog.cpp index 8a144871..85ee46df 100644 --- a/libs/gtkutil/dialog.cpp +++ b/libs/gtkutil/dialog.cpp @@ -160,17 +160,17 @@ gboolean dialog_delete_callback( ui::Widget widget, GdkEventAny* event, ModalDia ui::Window create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, ui::Widget contents ){ ui::Window window = create_fixedsize_modal_dialog_window(ui::Window(), title, dialog ); - GtkVBox* vbox1 = create_dialog_vbox( 8, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) ); + auto vbox1 = create_dialog_vbox( 8, 4 ); + window.add(vbox1); - gtk_container_add( GTK_CONTAINER( vbox1 ), contents ); + vbox1.add(contents); ui::Alignment alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vbox1 ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) ); + auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); + alignment.add(button); return window; } @@ -200,7 +200,7 @@ PathEntry PathEntry_new(){ gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); // path entry - GtkHBox* hbox = ui::HBox( FALSE, 0 ); + auto hbox = ui::HBox( FALSE, 0 ); gtk_widget_show( GTK_WIDGET( hbox ) ); auto entry = ui::Entry(); @@ -214,7 +214,7 @@ PathEntry PathEntry_new(){ gtk_widget_show( GTK_WIDGET( button ) ); gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( hbox ) ); + frame.add(hbox); return PathEntry( frame, entry, button ); } diff --git a/libs/gtkutil/frame.cpp b/libs/gtkutil/frame.cpp index a11ae16b..6baab763 100644 --- a/libs/gtkutil/frame.cpp +++ b/libs/gtkutil/frame.cpp @@ -28,7 +28,7 @@ ui::Frame create_framed_widget( ui::Widget widget ){ auto frame = ui::Frame(); frame.show(); gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN ); - gtk_container_add( GTK_CONTAINER( frame ), widget ); - gtk_widget_show( GTK_WIDGET( widget ) ); + frame.add(widget); + widget.show(); return frame; } diff --git a/libs/gtkutil/menu.cpp b/libs/gtkutil/menu.cpp index 3e227a2c..007d7a4e 100644 --- a/libs/gtkutil/menu.cpp +++ b/libs/gtkutil/menu.cpp @@ -34,7 +34,7 @@ #include "pointer.h" void menu_add_item( ui::Menu menu, ui::MenuItem item ){ - gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( item ) ); + menu.add(item); } ui::MenuItem menu_separator( ui::Menu menu ){ diff --git a/libs/gtkutil/messagebox.cpp b/libs/gtkutil/messagebox.cpp index 86ed48c3..3913d11b 100644 --- a/libs/gtkutil/messagebox.cpp +++ b/libs/gtkutil/messagebox.cpp @@ -70,8 +70,8 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha auto accel = ui::AccelGroup(); window.add_accel_group( accel ); - GtkVBox* vbox = create_dialog_vbox( 8, 8 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 8, 8 ); + window.add(vbox); GtkHBox* hboxDummy = create_dialog_hbox( 0, 0 ); @@ -97,12 +97,12 @@ EMessageBoxReturn gtk_MessageBox( ui::Widget parent, const char* text, const cha GtkVBox* vboxDummy = create_dialog_vbox( 0, 0 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( vboxDummy ), FALSE, FALSE, 0 ); - GtkAlignment* alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); + auto alignment = ui::Alignment( 0.5, 0.0, 0.0, 0.0 ); gtk_widget_show( GTK_WIDGET( alignment ) ); gtk_box_pack_start( GTK_BOX( vboxDummy ), GTK_WIDGET( alignment ), FALSE, FALSE, 0 ); - GtkHBox* hbox = create_dialog_hbox( 8, 0 ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 8, 0 ); + alignment.add(hbox); gtk_box_pack_start( GTK_BOX( vboxDummy ), create_padding( 400, 0 ), FALSE, FALSE, 0 ); // HACK to force minimum width diff --git a/libs/gtkutil/toolbar.cpp b/libs/gtkutil/toolbar.cpp index 85e371ad..1bd3be42 100644 --- a/libs/gtkutil/toolbar.cpp +++ b/libs/gtkutil/toolbar.cpp @@ -30,16 +30,16 @@ #include "image.h" -void toolbar_append( ui::Toolbar toolbar, GtkToolItem* button, const char* description ){ +void toolbar_append( ui::Toolbar toolbar, ui::ToolItem button, const char* description ){ gtk_widget_show_all(GTK_WIDGET(button)); gtk_widget_set_tooltip_text(GTK_WIDGET(button), description); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); + toolbar.add(button); } ui::ToolButton toolbar_append_button( ui::Toolbar toolbar, const char* description, const char* icon, const Callback& callback ){ auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_local_image(icon)), nullptr))); button_connect_callback(button, callback); - toolbar_append(toolbar, GTK_TOOL_ITEM(button), description); + toolbar_append(toolbar, button, description); return button; } @@ -48,7 +48,7 @@ ui::ToggleToolButton toolbar_append_toggle_button( ui::Toolbar toolbar, const ch toggle_button_connect_callback(button, callback); gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_local_image(icon))); gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), description); - toolbar_append(toolbar, GTK_TOOL_ITEM(button), description); + toolbar_append(toolbar, button, description); return button; } diff --git a/libs/uilib/uilib.cpp b/libs/uilib/uilib.cpp index e91f03fe..a27d2d84 100644 --- a/libs/uilib/uilib.cpp +++ b/libs/uilib/uilib.cpp @@ -90,6 +90,15 @@ namespace ui { gtk_widget_show(this); } + IMPL(Container, GTK_CONTAINER); + + void IContainer::add(Widget widget) + { + gtk_container_add(this, widget); + } + + IMPL(Bin, GTK_BIN); + IMPL(Window, GTK_WINDOW); Window::Window() : Window(nullptr) diff --git a/libs/uilib/uilib.h b/libs/uilib/uilib.h index f5b6e180..4dbdd791 100644 --- a/libs/uilib/uilib.h +++ b/libs/uilib/uilib.h @@ -21,6 +21,7 @@ struct _GtkContainer; struct _GtkDialog; struct _GtkEditable; struct _GtkEntry; +struct _GtkEntryCompletion; struct _GtkFrame; struct _GtkHBox; struct _GtkHPaned; @@ -140,6 +141,8 @@ namespace ui { }; } + extern struct Null {} null; + class Object : public details::Convertible, public details::Convertible { @@ -160,16 +163,17 @@ namespace ui { #define WRAP(name, super, T, interfaces, ctors, methods) \ class name; \ - class I##name { \ + class I##name : public details::Convertible { \ public: \ using self = name *; \ methods \ }; \ - class name : public super, public details::Convertible, public I##name, public details::Mixin::type { \ + class name : public super, public I##name, public details::Mixin::type { \ public: \ using self = name *; \ using native = T *; \ explicit name(native h) : super(reinterpret_cast(h)) {} \ + explicit name(Null n) : name((native) nullptr) {} \ ctors \ }; \ inline bool operator<(name self, name other) { return self._handle < other._handle; } \ @@ -177,6 +181,8 @@ namespace ui { // https://developer.gnome.org/gtk2/stable/ch01.html + // GInterface + WRAP(CellEditable, Object, _GtkCellEditable, (), , ); @@ -187,6 +193,12 @@ namespace ui { void editable(bool value); ); + WRAP(TreeModel, Object, _GtkTreeModel, (), + , + ); + + // GObject + WRAP(Widget, Object, _GtkWidget, (), Widget(); , @@ -210,6 +222,7 @@ namespace ui { WRAP(Container, Widget, _GtkContainer, (), , + void add(Widget widget); ); WRAP(Bin, Container, _GtkBin, (), @@ -466,15 +479,17 @@ namespace ui { , ); - WRAP(ListStore, Object, _GtkListStore, (), + WRAP(EntryCompletion, Object, _GtkEntryCompletion, (), , - void clear(); ); - WRAP(TreeModel, Widget, _GtkTreeModel, (), + WRAP(ListStore, Object, _GtkListStore, (ITreeModel), , + void clear(); ); + // GBoxed + WRAP(TreePath, Object, _GtkTreePath, (), TreePath(); TreePath(const char *path); diff --git a/plugins/textool/TexTool.cpp b/plugins/textool/TexTool.cpp index 63f77b7f..22f5a6e3 100644 --- a/plugins/textool/TexTool.cpp +++ b/plugins/textool/TexTool.cpp @@ -51,10 +51,10 @@ static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer } int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ - GtkWidget *window, *w, *vbox, *hbox; + GtkWidget *w, *vbox, *hbox; int mode = ( uType & MB_TYPEMASK ), ret, loop = 1; - window = ui::Window( ui::window_type::TOP ); + auto window = ui::Window( ui::window_type::TOP ); g_signal_connect( GTK_OBJECT( window ), "delete_event", G_CALLBACK( dialog_delete_callback ), NULL ); g_signal_connect( GTK_OBJECT( window ), "destroy", @@ -66,7 +66,7 @@ int DoMessageBox( const char* lpText, const char* lpCaption, guint32 uType ){ gtk_widget_realize( window ); vbox = ui::VBox( FALSE, 10 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + window.add(vbox); gtk_widget_show( vbox ); w = ui::Label( lpText ); diff --git a/radiant/build.cpp b/radiant/build.cpp index 24dc28e9..830bf2f0 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -842,8 +842,8 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi ui::Widget buildView; { - GtkTable* table1 = create_dialog_table( 2, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) ); + auto table1 = create_dialog_table( 2, 2, 4, 4, 4 ); + window.add(table1); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1, @@ -859,13 +859,13 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi } } { - GtkFrame* frame = create_dialog_frame( "Build menu" ); + auto frame = create_dialog_frame( "Build menu" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); + frame.add(scr); { auto store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); @@ -887,7 +887,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi buildView = view; projectList.m_store = store; - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); g_signal_connect( G_OBJECT( view ), "key_press_event", G_CALLBACK( project_key_press ), &projectList ); @@ -896,13 +896,13 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi } } { - GtkFrame* frame = create_dialog_frame( "Commandline" ); + auto frame = create_dialog_frame( "Commandline" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), 0, 0 ); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); + frame.add(scr); { ui::ListStore store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); @@ -922,7 +922,7 @@ ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectLi view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); g_object_unref( G_OBJECT( store ) ); diff --git a/radiant/commands.cpp b/radiant/commands.cpp index cce8b9db..5d2cadaf 100644 --- a/radiant/commands.cpp +++ b/radiant/commands.cpp @@ -394,11 +394,11 @@ void DoCommandListDlg(){ auto accel = ui::AccelGroup(); window.add_accel_group( accel ); - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); + auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { @@ -422,7 +422,7 @@ void DoCommandListDlg(){ } view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); { // Initialize dialog diff --git a/radiant/console.cpp b/radiant/console.cpp index 044648f9..b6855523 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -104,7 +104,7 @@ gboolean destroy_set_null( ui::Window widget, ui::Widget* p ){ WidgetFocusPrinter g_consoleWidgetFocusPrinter( "console" ); ui::Widget Console_constructWindow( ui::Window toplevel ){ - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); scr.show(); @@ -114,7 +114,7 @@ ui::Widget Console_constructWindow( ui::Window toplevel ){ 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_container_add( GTK_CONTAINER( scr ), text ); + scr.add(text); text.show(); g_console = text; diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index b3ba1f1a..a77ddedd 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -45,7 +45,7 @@ #include "gtkmisc.h" -GtkEntry* DialogEntry_new(){ +ui::Entry DialogEntry_new(){ auto entry = ui::Entry(); entry.show(); gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 ); @@ -62,17 +62,17 @@ GtkEntry* m_entry; }; DialogEntryRow DialogEntryRow_new( const char* name ){ - ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show(); - GtkEntry* entry = DialogEntry_new(); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) ); + auto entry = DialogEntry_new(); + alignment.add(entry); return DialogEntryRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), entry ); } -GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int fraction ){ +ui::SpinButton DialogSpinner_new( double value, double lower, double upper, int fraction ){ double step = 1.0 / double(fraction); unsigned int digits = 0; for (; fraction > 1; fraction /= 10 ) @@ -95,11 +95,11 @@ GtkSpinButton* m_spin; }; DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){ - ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show(); - GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) ); + auto spin = DialogSpinner_new( value, lower, upper, fraction ); + alignment.add(spin); return DialogSpinnerRow( ui::Widget(GTK_WIDGET( DialogRow_new( name, alignment ) )), spin ); } @@ -465,7 +465,7 @@ ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const ch } void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show(); { ui::Widget combo = ui::ComboBoxText(); @@ -478,7 +478,7 @@ void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange value AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer ); combo.show(); - gtk_container_add( GTK_CONTAINER( alignment ), combo ); + alignment.add(combo); } auto row = DialogRow_new( name, alignment ); @@ -513,13 +513,13 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d AddIntAdjustmentData( *GTK_ADJUSTMENT(adj), IntImportCaller( data ), IntExportCaller( data ) ); // scale - ui::Widget alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 ); + auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 ); alignment.show(); ui::Widget scale = ui::HScale( adj ); gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT ); scale.show(); - gtk_container_add( GTK_CONTAINER( alignment ), scale ); + alignment.add(scale); gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value ); gtk_scale_set_digits( GTK_SCALE( scale ), 0 ); @@ -529,11 +529,11 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d } void Dialog::addRadio( ui::Widget vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){ - ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); + auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 ); alignment.show();; { RadioHBox radioBox = RadioHBox_new( names ); - gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) ); + alignment.add(radioBox.m_hbox); AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer ); } diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index 8e3e3e1d..cc0c2008 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -176,7 +176,7 @@ StringAttribute( const char* key ) : ui::Widget getWidget() const { return ui::Widget(GTK_WIDGET( m_entry )); } -GtkEntry* getEntry() const { +ui::Entry getEntry() const { return m_entry; } @@ -1310,7 +1310,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ { // class list - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); gtk_paned_add1( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -1338,7 +1338,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ view.show(); - gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( view ) ); + scr.add(view); g_object_unref( G_OBJECT( store ) ); g_entityClassList = view; @@ -1347,7 +1347,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ } { - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); gtk_paned_add2( GTK_PANED( split2 ), scr ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS ); @@ -1359,7 +1359,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD ); gtk_text_view_set_editable( text, FALSE ); text.show(); - gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( text ) ); + scr.add(text); g_entityClassComment = text; } } @@ -1394,7 +1394,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ { // key/value list - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); gtk_box_pack_start( GTK_BOX( vbox2 ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); @@ -1426,7 +1426,7 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); g_object_unref( G_OBJECT( store ) ); @@ -1504,19 +1504,19 @@ ui::Widget EntityInspector_constructWindow( ui::Window toplevel ){ } { - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); - ui::Widget viewport = ui::Widget(gtk_viewport_new( 0, 0 )); + auto viewport = ui::Container(GTK_CONTAINER(gtk_viewport_new( 0, 0 ))); viewport.show(); gtk_viewport_set_shadow_type( GTK_VIEWPORT( viewport ), GTK_SHADOW_NONE ); g_attributeBox = ui::VBox( FALSE, 2 ); g_attributeBox.show(); - gtk_container_add( GTK_CONTAINER( viewport ), GTK_WIDGET( g_attributeBox ) ); - gtk_container_add( GTK_CONTAINER( scr ), viewport ); + viewport.add(g_attributeBox); + scr.add(viewport); gtk_paned_pack2( GTK_PANED( split2 ), scr, FALSE, FALSE ); } } diff --git a/radiant/entitylist.cpp b/radiant/entitylist.cpp index efdc9ca0..f8847255 100644 --- a/radiant/entitylist.cpp +++ b/radiant/entitylist.cpp @@ -281,7 +281,7 @@ void DetachEntityTreeModel(){ void EntityList_constructWindow( ui::Window main_window ){ ASSERT_TRUE( !getEntityList().m_window ); - ui::Window window = ui::Window(create_persistent_floating_window( "Entity List", main_window )); + auto window = ui::Window(create_persistent_floating_window( "Entity List", main_window )); window.add_accel_group(global_accel); @@ -291,8 +291,8 @@ void EntityList_constructWindow( ui::Window main_window ){ getEntityList().m_window = window; { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); + auto scr = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); + window.add(scr); { ui::Widget view = ui::TreeView(); @@ -312,7 +312,7 @@ void EntityList_constructWindow( ui::Window main_window ){ gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column ); view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); getEntityList().m_tree_view = GTK_TREE_VIEW( view ); } } diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index 3c6aaa5d..00512547 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -263,7 +263,7 @@ void CDbgDlg::Init(){ g_ptr_array_remove_index( m_pFeedbackElements, 0 ); } - if ( m_clist != NULL ) { + if ( m_clist ) { gtk_list_store_clear( m_clist ); } } @@ -289,11 +289,11 @@ void CDbgDlg::Push( ISAXHandler *pHandler ){ } ui::Window CDbgDlg::BuildDialog(){ - ui::Window window = MainFrame_getWindow().create_floating_window("Q3Map debug window" ); + auto window = MainFrame_getWindow().create_floating_window("Q3Map debug window" ); - ui::Widget scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( scr ) ); + window.add(scr); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); @@ -317,7 +317,7 @@ ui::Window CDbgDlg::BuildDialog(){ view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); g_object_unref( G_OBJECT( store ) ); diff --git a/radiant/findtexturedialog.cpp b/radiant/findtexturedialog.cpp index 57cce140..201f2c67 100644 --- a/radiant/findtexturedialog.cpp +++ b/radiant/findtexturedialog.cpp @@ -127,13 +127,14 @@ FindTextureDialog::~FindTextureDialog(){ ui::Window FindTextureDialog::BuildDialog(){ ui::Widget vbox, hbox, table, label; - ui::Widget button, check, entry; + ui::Widget button, check; + ui::Entry entry{nullptr}; - ui::Window dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent )); + auto dlg = ui::Window(create_floating_window( "Find / Replace Texture(s)", m_parent )); hbox = ui::HBox( FALSE, 5 ); hbox.show(); - gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( hbox ) ); + dlg.add(hbox); gtk_container_set_border_width( GTK_CONTAINER( hbox ), 5 ); vbox = ui::VBox( FALSE, 5 ); @@ -168,7 +169,7 @@ ui::Window FindTextureDialog::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( find_focus_in ), 0 ); AddDialogData( *GTK_ENTRY( entry ), m_strFind ); - GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); + GlobalTextureEntryCompletion::instance().connect( entry ); entry = ui::Entry(); entry.show(); @@ -178,7 +179,7 @@ ui::Window FindTextureDialog::BuildDialog(){ g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( replace_focus_in ), 0 ); AddDialogData( *GTK_ENTRY( entry ), m_strReplace ); - GlobalTextureEntryCompletion::instance().connect( GTK_ENTRY( entry ) ); + GlobalTextureEntryCompletion::instance().connect( entry ); check = ui::CheckButton( "Within selected brushes only" ); check.show(); diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index ce9e467d..6559da19 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -92,7 +92,7 @@ GroupDlg::GroupDlg() : m_window( 0 ){ void GroupDlg::Create( ui::Window parent ){ ASSERT_MESSAGE( !m_window, "dialog already created" ); - ui::Window window = ui::Window(create_persistent_floating_window( "Entities", parent )); + auto window = ui::Window(create_persistent_floating_window( "Entities", parent )); global_accel_connect_window( window ); @@ -112,7 +112,7 @@ void GroupDlg::Create( ui::Window parent ){ { ui::Widget notebook = ui::Widget(gtk_notebook_new()); notebook.show(); - gtk_container_add( GTK_CONTAINER( window ), notebook ); + window.add(notebook); gtk_notebook_set_tab_pos( GTK_NOTEBOOK( notebook ), GTK_POS_BOTTOM ); m_pNotebook = notebook; diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 0888570d..3b446f93 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -200,11 +200,11 @@ GtkComboBox* gamemode_combo; }; ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){ - ui::Window window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal ); + auto window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal ); { - GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) ); + auto table1 = create_dialog_table( 1, 2, 4, 4, 4 ); + window.add(table1); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1, @@ -220,13 +220,13 @@ ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, Modal } } { - GtkFrame* frame = create_dialog_frame( "Project settings" ); + auto frame = create_dialog_frame( "Project settings" ); gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions) ( GTK_FILL ), 0, 0 ); { - GtkTable* table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) ); + auto table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 ); + frame.add(table2); { auto label = ui::Label( "Select mod" ); @@ -368,14 +368,14 @@ void DoSides( int type, int axis ){ ModalDialog dialog; GtkEntry* sides_entry; - ui::Window window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); + auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog ); auto accel = ui::AccelGroup(); window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { auto label = ui::Label( "Sides:" ); label.show(); @@ -439,11 +439,11 @@ void DoAbout(){ ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - ui::Window window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); + auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkHBox* hbox = create_dialog_hbox( 4 ); @@ -453,12 +453,12 @@ void DoAbout(){ GtkVBox* vbox2 = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, FALSE, 0 ); { - GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN ); + auto frame = create_dialog_frame( 0, GTK_SHADOW_IN ); gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { auto image = new_local_image( "logo.png" ); image.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) ); + frame.add(image); } } } @@ -503,11 +503,11 @@ void DoAbout(){ } } { - GtkFrame* frame = create_dialog_frame( "OpenGL Properties" ); + auto frame = create_dialog_frame( "OpenGL Properties" ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { - GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) ); + auto table = create_dialog_table( 3, 2, 4, 4, 4 ); + frame.add(table); { auto label = ui::Label( "Vendor:" ); label.show(); @@ -558,15 +558,15 @@ void DoAbout(){ } } { - GtkFrame* frame = create_dialog_frame( "OpenGL Extensions" ); + auto frame = create_dialog_frame( "OpenGL Extensions" ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 ); { - GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) ); + auto sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 ); + frame.add(sc_extensions); { - ui::Widget text_extensions = ui::TextView(); + auto text_extensions = ui::TextView(); gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE ); - gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions ); + sc_extensions.add(text_extensions); GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) ); gtk_text_buffer_set_text( buffer, reinterpret_cast( glGetString( GL_EXTENSIONS ) ), -1 ); gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD ); @@ -596,14 +596,14 @@ EMessageBoxReturn DoTextureLayout( float *fx, float *fy ){ GtkEntry* x; GtkEntry* y; - ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); + auto window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog ); auto accel = ui::AccelGroup(); window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); @@ -740,10 +740,9 @@ static void editor_close( ui::Widget widget, gpointer data ){ } static void CreateGtkTextEditor(){ - ui::Widget dlg; - ui::Widget vbox, hbox, button, scr, text; + ui::Widget vbox, hbox, button, text; - dlg = ui::Window( ui::window_type::TOP ); + auto dlg = ui::Window( ui::window_type::TOP ); g_signal_connect( G_OBJECT( dlg ), "delete_event", G_CALLBACK( editor_delete ), 0 ); @@ -751,17 +750,17 @@ static void CreateGtkTextEditor(){ vbox = ui::VBox( FALSE, 5 ); vbox.show(); - gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) ); + dlg.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); - scr = ui::ScrolledWindow(); + auto scr = ui::ScrolledWindow(); scr.show(); gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 ); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN ); text = ui::TextView(); - gtk_container_add( GTK_CONTAINER( scr ), text ); + 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 ); @@ -863,8 +862,8 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ){ window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); @@ -924,14 +923,14 @@ EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){ ModalDialogButton ok_button( dialog, eIDOK ); ModalDialogButton cancel_button( dialog, eIDCANCEL ); - ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); + auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); auto accel_group = ui::AccelGroup(); window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); @@ -983,14 +982,14 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* ModalDialog dialog; ModalDialogButton ok_button( dialog, eIDOK ); - ui::Window window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); + auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 ); auto accel_group = ui::AccelGroup(); window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkVBox* vbox = create_dialog_vbox( 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 ); diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index adf4797c..7b1b80ef 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -27,13 +27,8 @@ #include "mainframe.h" -#include "debugging/debugging.h" -#include "version.h" - #include "ifilesystem.h" #include "iundo.h" -#include "ifilter.h" -#include "itoolbar.h" #include "editable.h" #include "ientity.h" #include "ishaders.h" @@ -46,7 +41,6 @@ #include "cmdlib.h" -#include "scenelib.h" #include "stream/stringstream.h" #include "signal/isignal.h" #include "os/path.h" @@ -55,14 +49,11 @@ #include "moduleobservers.h" #include "gtkutil/clipboard.h" -#include "gtkutil/container.h" #include "gtkutil/frame.h" -#include "gtkutil/glfont.h" #include "gtkutil/glwidget.h" #include "gtkutil/image.h" #include "gtkutil/menu.h" #include "gtkutil/paned.h" -#include "gtkutil/widget.h" #include "autosave.h" #include "build.h" @@ -91,7 +82,6 @@ #include "pluginmanager.h" #include "pluginmenu.h" #include "plugintoolbar.h" -#include "points.h" #include "preferences.h" #include "qe3.h" #include "qgl.h" @@ -446,7 +436,7 @@ ui::Window BuildDialog(){ auto frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN ); auto vbox2 = create_dialog_vbox( 0, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + frame.add(vbox2); { PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); @@ -899,8 +889,8 @@ ColoursMenu() : ColoursMenu g_ColoursMenu; -GtkMenuItem* create_colours_menu(){ - GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); +ui::MenuItem create_colours_menu(){ + auto colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" ); auto menu_in_menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); @@ -1638,7 +1628,7 @@ WaitDialog create_wait_dialog( const char* title, const char* text ){ dialog.m_label.show(); gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 ); - gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) ); + dialog.m_window.add(dialog.m_label); } return dialog; } @@ -1791,9 +1781,9 @@ LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" ); -GtkMenuItem* create_file_menu(){ +ui::MenuItem create_file_menu(){ // File menu - GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); + auto file_menu_item = new_sub_menu_item_with_mnemonic( "_File" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1831,9 +1821,9 @@ GtkMenuItem* create_file_menu(){ return file_menu_item; } -GtkMenuItem* create_edit_menu(){ +ui::MenuItem create_edit_menu(){ // Edit menu - GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); + auto edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -1888,9 +1878,9 @@ ui::Widget g_toggle_console_item; ui::Widget g_toggle_entity_item; ui::Widget g_toggle_entitylist_item; -GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ +ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){ // View menu - GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); + auto view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2002,9 +1992,9 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ return view_menu_item; } -GtkMenuItem* create_selection_menu(){ +ui::MenuItem create_selection_menu(){ // Selection menu - GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); + auto selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2057,9 +2047,9 @@ GtkMenuItem* create_selection_menu(){ return selection_menu_item; } -GtkMenuItem* create_bsp_menu(){ +ui::MenuItem create_bsp_menu(){ // BSP menu - GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); + auto bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { @@ -2077,9 +2067,9 @@ GtkMenuItem* create_bsp_menu(){ return bsp_menu_item; } -GtkMenuItem* create_grid_menu(){ +ui::MenuItem create_grid_menu(){ // Grid menu - GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); + auto grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2090,9 +2080,9 @@ GtkMenuItem* create_grid_menu(){ return grid_menu_item; } -GtkMenuItem* create_misc_menu(){ +ui::MenuItem create_misc_menu(){ // Misc menu - GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); + auto misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2101,7 +2091,7 @@ GtkMenuItem* create_misc_menu(){ #if 0 create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller() ); #endif - gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) ); + menu.add(create_colours_menu()); create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" ); create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" ); @@ -2111,9 +2101,9 @@ GtkMenuItem* create_misc_menu(){ return misc_menu_item; } -GtkMenuItem* create_entity_menu(){ +ui::MenuItem create_entity_menu(){ // Brush menu - GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); + auto entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2124,9 +2114,9 @@ GtkMenuItem* create_entity_menu(){ return entity_menu_item; } -GtkMenuItem* create_brush_menu(){ +ui::MenuItem create_brush_menu(){ // Brush menu - GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); + auto brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2137,9 +2127,9 @@ GtkMenuItem* create_brush_menu(){ return brush_menu_item; } -GtkMenuItem* create_patch_menu(){ +ui::MenuItem create_patch_menu(){ // Curve menu - GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); + auto patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2150,9 +2140,9 @@ GtkMenuItem* create_patch_menu(){ return patch_menu_item; } -GtkMenuItem* create_help_menu(){ +ui::MenuItem create_help_menu(){ // Help menu - GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); + auto help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" ); auto menu = ui::Menu(GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) )); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu ); @@ -2175,18 +2165,18 @@ GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){ auto menu_bar = ui::MenuBar(GTK_MENU_BAR( gtk_menu_bar_new() )); menu_bar.show(); - gtk_container_add( menu_bar, GTK_WIDGET( create_file_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_edit_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_view_menu( style ) ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_selection_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_bsp_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_grid_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_misc_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_entity_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_brush_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_patch_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_plugins_menu() ) ); - gtk_container_add( menu_bar, GTK_WIDGET( create_help_menu() ) ); + menu_bar.add(create_file_menu()); + menu_bar.add(create_edit_menu()); + menu_bar.add(create_view_menu(style)); + menu_bar.add(create_selection_menu()); + menu_bar.add(create_bsp_menu()); + menu_bar.add(create_grid_menu()); + menu_bar.add(create_misc_menu()); + menu_bar.add(create_entity_menu()); + menu_bar.add(create_brush_menu()); + menu_bar.add(create_patch_menu()); + menu_bar.add(create_plugins_menu()); + menu_bar.add(create_help_menu()); return menu_bar; } @@ -2328,7 +2318,7 @@ ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){ auto space = [&]() { auto btn = ui::Widget(GTK_WIDGET(gtk_separator_tool_item_new())); btn.show(); - gtk_container_add(toolbar, btn); + toolbar.add(btn); }; File_constructToolbar( toolbar ); @@ -2423,7 +2413,7 @@ ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); gtk_misc_set_padding( GTK_MISC( label ), 4, 2 ); label.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) ); + frame.add(label); pStatusLabel[i] = ui::Widget(GTK_WIDGET( label )); } @@ -2678,7 +2668,7 @@ ui::Window create_splash(){ auto image = new_local_image( "splash.png" ); image.show(); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) ); + window.add(image); gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 ); window.show(); @@ -2743,7 +2733,7 @@ void MainFrame::Create(){ GetPlugInMgr().Init( window ); ui::Widget vbox = ui::VBox( FALSE, 0 ); - gtk_container_add( GTK_CONTAINER( window ), vbox ); + window.add(vbox); vbox.show(); global_accel_connect_window( window ); @@ -2873,8 +2863,8 @@ void MainFrame::Create(){ GlobalCamera_setCamWnd( *m_pCamWnd ); { - GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) ); + window.add(frame); } CamWnd_setParent( *m_pCamWnd, window ); @@ -2892,8 +2882,8 @@ void MainFrame::Create(){ { - GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pXYWnd->GetWidget() ); + window.add(frame); } XY_Top_Shown_Construct( window ); @@ -2910,8 +2900,8 @@ void MainFrame::Create(){ m_pXZWnd->SetViewType( XZ ); { - GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pXZWnd->GetWidget() ); + window.add(frame); } XZ_Front_Shown_Construct( window ); @@ -2929,8 +2919,8 @@ void MainFrame::Create(){ m_pYZWnd->SetViewType( YZ ); { - GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) ); + auto frame = create_framed_widget( m_pYZWnd->GetWidget() ); + window.add(frame); } YZ_Side_Shown_Construct( window ); diff --git a/radiant/map.cpp b/radiant/map.cpp index 244001ea..fa54737a 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -770,8 +770,8 @@ void DoMapInfo(){ window_set_position( window, g_posMapInfoWnd ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkHBox* hbox = create_dialog_hbox( 4 ); @@ -835,7 +835,7 @@ void DoMapInfo(){ gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); } { - GtkScrolledWindow* scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); + auto scr = create_scrolled_window( GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( scr ), TRUE, TRUE, 0 ); { @@ -860,7 +860,7 @@ void DoMapInfo(){ view.show(); - gtk_container_add( GTK_CONTAINER( scr ), view ); + scr.add(view); EntityBreakdownWalker = store; } @@ -2043,8 +2043,8 @@ void DoFind(){ window.add_accel_group( accel ); { - GtkVBox* vbox = create_dialog_vbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + auto vbox = create_dialog_vbox( 4, 4 ); + window.add(vbox); { GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); diff --git a/radiant/patchdialog.cpp b/radiant/patchdialog.cpp index b3785496..2121b928 100644 --- a/radiant/patchdialog.cpp +++ b/radiant/patchdialog.cpp @@ -565,7 +565,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); vbox.show(); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + window.add(vbox); { auto hbox = ui::HBox( FALSE, 5 ); hbox.show(); @@ -583,7 +583,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 2, 2, FALSE ); table.show(); @@ -730,7 +730,7 @@ ui::Window PatchInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 5 ); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 3, 2, FALSE ); table.show(); @@ -797,7 +797,7 @@ ui::Window PatchInspector::BuildDialog(){ { auto vbox2 = ui::VBox( FALSE, 5 ); vbox2.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + frame.add(vbox2); gtk_container_set_border_width( GTK_CONTAINER( vbox2 ), 5 ); { auto label = ui::Label( "Name:" ); diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index 572e8e9b..16d5d5e2 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -852,8 +852,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows, window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); @@ -979,13 +979,13 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ window.add_accel_group( accel_group ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + window.add(hbox); { // Gef: Added a vbox to contain the toggle buttons - GtkVBox* radio_vbox = create_dialog_vbox( 4 ); - gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) ); + auto radio_vbox = create_dialog_vbox( 4 ); + hbox.add(radio_vbox); { auto table = ui::Table( 5, 2, FALSE ); diff --git a/radiant/pluginmenu.cpp b/radiant/pluginmenu.cpp index b9dd5dc7..e3b278c5 100644 --- a/radiant/pluginmenu.cpp +++ b/radiant/pluginmenu.cpp @@ -40,7 +40,7 @@ void plugin_activated( ui::Widget widget, gpointer data ){ #include -void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ +void PlugInMenu_Add( ui::Menu plugin_menu, IPlugIn* pPlugIn ){ ui::Widget item, parent; ui::Menu menu{nullptr}, subMenu{nullptr}; const char *menuText, *menuCommand; @@ -48,7 +48,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ parent = ui::MenuItem( pPlugIn->getMenuName() ); parent.show(); - gtk_container_add( GTK_CONTAINER( plugin_menu ), parent ); + plugin_menu.add(parent); std::size_t nCount = pPlugIn->getCommandCount(); if ( nCount > 0 ) { @@ -76,7 +76,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ item = ui::MenuItem( menuText ); item.show(); - gtk_container_add( GTK_CONTAINER( menu ), item ); + menu.add(item); subMenu = ui::Menu(); gtk_menu_item_set_submenu( GTK_MENU_ITEM( item ), subMenu ); @@ -102,7 +102,7 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( plugin_activated ), gint_to_pointer( m_nNextPlugInID ) ); } item.show(); - gtk_container_add( GTK_CONTAINER( menu ), item ); + menu.add(item); pPlugIn->addMenuID( m_nNextPlugInID++ ); } } @@ -122,15 +122,15 @@ void PlugInMenu_Add( GtkMenu* plugin_menu, IPlugIn* pPlugIn ){ } } -GtkMenu* g_plugins_menu = 0; +ui::Menu g_plugins_menu{ui::null}; GtkMenuItem* g_plugins_menu_separator = 0; void PluginsMenu_populate(){ class PluginsMenuConstructor : public PluginsVisitor { - GtkMenu* m_menu; + ui::Menu m_menu; public: - PluginsMenuConstructor( GtkMenu* menu ) : m_menu( menu ){ + PluginsMenuConstructor( ui::Menu menu ) : m_menu( menu ){ } void visit( IPlugIn& plugin ){ PlugInMenu_Add( m_menu, &plugin ); diff --git a/radiant/plugintoolbar.cpp b/radiant/plugintoolbar.cpp index 6486e1bd..ac79b101 100644 --- a/radiant/plugintoolbar.cpp +++ b/radiant/plugintoolbar.cpp @@ -54,29 +54,29 @@ ui::Image new_plugin_image( const char* filename ){ return image_new_missing(); } -void toolbar_insert( GtkToolbar *toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){ +void toolbar_insert( ui::Toolbar toolbar, const char* icon, const char* text, const char* tooltip, IToolbarButton::EType type, GCallback handler, gpointer data ){ if (type == IToolbarButton::eSpace) { auto it = ui::Widget(GTK_WIDGET(gtk_separator_tool_item_new())); it.show(); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(it)); + toolbar.add(it); return; } if (type == IToolbarButton::eButton) { - auto button = gtk_tool_button_new(GTK_WIDGET(new_plugin_image(icon)), text); - gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip); - gtk_widget_show_all(GTK_WIDGET(button)); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(handler), data); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); + auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_tool_button_new(GTK_WIDGET(new_plugin_image(icon)), text))); + gtk_widget_set_tooltip_text(button, tooltip); + gtk_widget_show_all(button); + g_signal_connect(button, "clicked", G_CALLBACK(handler), data); + toolbar.add(button); return; } if (type == IToolbarButton::eToggleButton) { - auto button = gtk_toggle_tool_button_new(); - gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(button), GTK_WIDGET(new_plugin_image(icon))); - gtk_tool_button_set_label(GTK_TOOL_BUTTON(button), text); - gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip); - gtk_widget_show_all(GTK_WIDGET(button)); - g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(handler), data); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); + auto button = ui::ToolButton(GTK_TOOL_BUTTON(gtk_toggle_tool_button_new())); + gtk_tool_button_set_icon_widget(button, GTK_WIDGET(new_plugin_image(icon))); + gtk_tool_button_set_label(button, text); + gtk_widget_set_tooltip_text(button, tooltip); + gtk_widget_show_all(button); + g_signal_connect(button, "toggled", G_CALLBACK(handler), data); + toolbar.add(button); return; } ERROR_MESSAGE( "invalid toolbar button type" ); @@ -86,7 +86,7 @@ void ActivateToolbarButton( GtkToolButton *widget, gpointer data ){ (const_cast( reinterpret_cast( data )))->activate(); } -void PlugInToolbar_AddButton( GtkToolbar* toolbar, const IToolbarButton* button ){ +void PlugInToolbar_AddButton( ui::Toolbar toolbar, const IToolbarButton* button ){ toolbar_insert( toolbar, button->getImage(), button->getText(), button->getTooltip(), button->getType(), G_CALLBACK( ActivateToolbarButton ), reinterpret_cast( const_cast( button ) ) ); } @@ -95,9 +95,9 @@ ui::Toolbar g_plugin_toolbar{nullptr}; void PluginToolbar_populate(){ class AddToolbarItemVisitor : public ToolbarModules::Visitor { - GtkToolbar* m_toolbar; + ui::Toolbar m_toolbar; public: - AddToolbarItemVisitor( GtkToolbar* toolbar ) + AddToolbarItemVisitor( ui::Toolbar toolbar ) : m_toolbar( toolbar ){ } void visit( const char* name, const _QERPlugToolbarTable& table ) const { diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 15d216a6..d1ae9e15 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -320,7 +320,7 @@ ui::Window CGameDialog::BuildDialog(){ auto frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN ); auto vbox2 = create_dialog_vbox( 0, 4 ); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) ); + frame.add(vbox2); { PreferencesPage preferencesPage( *this, ui::Widget(GTK_WIDGET( vbox2 )) ); @@ -641,14 +641,14 @@ ui::Widget PreferencePages_addPage( ui::Widget notebook, const char* name ){ ui::Widget preflabel = ui::Label( name ); preflabel.show(); - ui::Widget pageframe = ui::Frame( name ); + auto pageframe = ui::Frame( name ); gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 ); pageframe.show(); ui::Widget vbox = ui::VBox( FALSE, 4 ); vbox.show(); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 ); - gtk_container_add( GTK_CONTAINER( pageframe ), vbox ); + pageframe.add(vbox); // Add the page to the notebook gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel ); @@ -684,7 +684,7 @@ ui::Window PrefsDlg::BuildDialog(){ { ui::Widget mainvbox = ui::VBox( FALSE, 5 ); - gtk_container_add( GTK_CONTAINER( dialog ), mainvbox ); + dialog.add(mainvbox); gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 ); mainvbox.show(); @@ -713,7 +713,7 @@ ui::Window PrefsDlg::BuildDialog(){ hbox.show(); { - ui::Widget sc_win = ui::ScrolledWindow(); + auto sc_win = ui::ScrolledWindow(); gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC ); gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 ); sc_win.show(); @@ -746,7 +746,7 @@ ui::Window PrefsDlg::BuildDialog(){ view.show(); - gtk_container_add( GTK_CONTAINER( sc_win ), view ); + sc_win.add(view); { /********************************************************************/ diff --git a/radiant/select.cpp b/radiant/select.cpp index d2cfed61..f88cf1aa 100644 --- a/radiant/select.cpp +++ b/radiant/select.cpp @@ -914,8 +914,8 @@ void DoRotateDlg(){ g_rotate_dialog.window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( g_rotate_dialog.window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + g_rotate_dialog.window.add(hbox); { GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); @@ -1067,8 +1067,8 @@ void DoScaleDlg(){ g_scale_dialog.window.add_accel_group( accel ); { - GtkHBox* hbox = create_dialog_hbox( 4, 4 ); - gtk_container_add( GTK_CONTAINER( g_scale_dialog.window ), GTK_WIDGET( hbox ) ); + auto hbox = create_dialog_hbox( 4, 4 ); + g_scale_dialog.window.add(hbox); { GtkTable* table = create_dialog_table( 3, 2, 4, 4 ); gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index dcc5ab5b..8209a16a 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -593,7 +593,7 @@ ui::Window SurfaceInspector::BuildDialog(){ // replaced by only the vbox: ui::Widget vbox = ui::VBox( FALSE, 5 ); vbox.show(); - gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) ); + window.add(vbox); gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); { @@ -816,13 +816,13 @@ ui::Window SurfaceInspector::BuildDialog(){ } { - ui::Widget frame = ui::Frame( "Texturing" ); + auto frame = ui::Frame( "Texturing" ); frame.show(); gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 ); { ui::Widget table = ui::Table( 4, 4, FALSE ); table.show(); - gtk_container_add( GTK_CONTAINER( frame ), table ); + frame.add(table); gtk_table_set_row_spacings( GTK_TABLE( table ), 5 ); gtk_table_set_col_spacings( GTK_TABLE( table ), 5 ); gtk_container_set_border_width( GTK_CONTAINER( table ), 5 ); @@ -943,7 +943,7 @@ ui::Window SurfaceInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 8, 4, FALSE ); table.show(); @@ -978,7 +978,7 @@ ui::Window SurfaceInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 4 ); //gtk_container_set_border_width(GTK_CONTAINER(vbox3), 4); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto table = ui::Table( 8, 4, FALSE ); @@ -1017,7 +1017,7 @@ ui::Window SurfaceInspector::BuildDialog(){ auto vbox3 = ui::VBox( FALSE, 4 ); gtk_container_set_border_width( GTK_CONTAINER( vbox3 ), 4 ); vbox3.show(); - gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox3 ) ); + frame.add(vbox3); { auto entry = ui::Entry(); @@ -1046,7 +1046,7 @@ ui::Window SurfaceInspector::BuildDialog(){ // <-- end stuff... TexTool::g_textoolWin.show(); gtk_widget_set_size_request( TexTool::g_textoolWin, -1, 240 ); //Yeah! - gtk_container_add( GTK_CONTAINER( frame ), TexTool::g_textoolWin ); + frame.add(TexTool::g_textoolWin); g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "size_allocate", G_CALLBACK( TexTool::size_allocate ), NULL ); g_signal_connect( G_OBJECT( TexTool::g_textoolWin ), "expose_event", G_CALLBACK( TexTool::expose ), NULL ); @@ -1068,7 +1068,7 @@ ui::Window SurfaceInspector::BuildDialog(){ //Instead of this, we probably need to create a vbox to put into the frame, then the //window, then the hbox. !!! FIX !!! -// gtk_container_add(GTK_CONTAINER(frame), hbox); +// frame.add(hbox); //Hmm. Do we really need g_object_set_data? Mebbe not... And we don't! :-) // g_object_set_data(G_OBJECT(flipX), "handler", gint_to_pointer(g_signal_connect(G_OBJECT(flipX), "toggled", G_CALLBACK(TexTool::flipX), 0))); diff --git a/radiant/textureentry.h b/radiant/textureentry.h index 19c72e84..67238a60 100644 --- a/radiant/textureentry.h +++ b/radiant/textureentry.h @@ -41,7 +41,7 @@ public: EntryCompletion() : m_store( 0 ), m_idleUpdate( UpdateCaller( *this ) ){ } -void connect( GtkEntry* entry ){ +void connect( ui::Entry entry ){ if ( !m_store ) { m_store = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING )); @@ -50,7 +50,7 @@ void connect( GtkEntry* entry ){ StringList().connect( IdleDraw::QueueDrawCaller( m_idleUpdate ) ); } - GtkEntryCompletion* completion = gtk_entry_completion_new(); + auto completion = ui::EntryCompletion(gtk_entry_completion_new()); gtk_entry_set_completion( entry, completion ); gtk_entry_completion_set_model( completion, GTK_TREE_MODEL( m_store ) ); gtk_entry_completion_set_text_column( completion, 0 ); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 7a79eb05..3cf2939c 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -259,7 +259,7 @@ ui::Widget m_gl_widget; ui::Widget m_texture_scroll; ui::Widget m_treeViewTree; ui::Widget m_treeViewTags; -ui::Widget m_tag_frame; +ui::Frame m_tag_frame{ui::null}; ui::ListStore m_assigned_store{nullptr}; ui::ListStore m_available_store{nullptr}; ui::Widget m_assigned_tree; @@ -267,7 +267,7 @@ ui::Widget m_available_tree; ui::Widget m_scr_win_tree; ui::Widget m_scr_win_tags; ui::Widget m_tag_notebook; -ui::Widget m_search_button; +ui::Button m_search_button{ui::null}; ui::Widget m_shader_info_item; std::set m_all_tags; @@ -1941,7 +1941,7 @@ void TextureBrowser_constructSearchButton(){ g_TextureBrowser.m_search_button = ui::Button(); g_signal_connect( G_OBJECT( g_TextureBrowser.m_search_button ), "clicked", G_CALLBACK( TextureBrowser_searchTags ), NULL ); gtk_widget_set_tooltip_text(g_TextureBrowser.m_search_button, "Search with selected tags"); - gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_search_button ), image ); + g_TextureBrowser.m_search_button.add(image); } void TextureBrowser_checkTagFile(){ @@ -2122,7 +2122,7 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ frame_table.show(); - gtk_container_add( GTK_CONTAINER( g_TextureBrowser.m_tag_frame ), frame_table ); + g_TextureBrowser.m_tag_frame.add(frame_table); } { // assigned tag list ui::Widget scrolled_win = ui::ScrolledWindow(); @@ -2182,12 +2182,12 @@ ui::Widget TextureBrowser_constructWindow( ui::Window toplevel ){ gtk_table_attach( GTK_TABLE( frame_table ), scrolled_win, 2, 3, 1, 3, GTK_FILL, GTK_FILL, 0, 0 ); } { // tag arrow buttons - ui::Widget m_btn_left = ui::Button(); - ui::Widget m_btn_right = ui::Button(); - ui::Widget m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); - ui::Widget m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); - gtk_container_add( GTK_CONTAINER( m_btn_left ), m_arrow_left ); - gtk_container_add( GTK_CONTAINER( m_btn_right ), m_arrow_right ); + auto m_btn_left = ui::Button(); + auto m_btn_right = ui::Button(); + auto m_arrow_left = ui::Widget(gtk_arrow_new( GTK_ARROW_LEFT, GTK_SHADOW_OUT )); + auto m_arrow_right = ui::Widget(gtk_arrow_new( GTK_ARROW_RIGHT, GTK_SHADOW_OUT )); + m_btn_left.add(m_arrow_left); + m_btn_right.add(m_arrow_right); // workaround. the size of the tag frame depends of the requested size of the arrow buttons. gtk_widget_set_size_request( m_arrow_left, -1, 68 );