]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/dialogs/dialogs-gtk.cpp
Wrap more GTK
[xonotic/netradiant.git] / contrib / bobtoolz / dialogs / dialogs-gtk.cpp
index fb9c180633332506db486bc5352f2fc5b64f0d72..dd08de2bf9fea88c80f88b3943b148939ca32d88 100644 (file)
    ---------------------------------*/
 
 typedef struct {
-       ui::Widget cbTexChange;
-       ui::Widget editTexOld, editTexNew;
+       ui::Widget cbTexChange{ui::null};
+       ui::Widget editTexOld{ui::null}, editTexNew{ui::null};
 
-       ui::Widget cbScaleHor, cbScaleVert;
-       ui::Widget editScaleHor, editScaleVert;
+       ui::Widget cbScaleHor{ui::null}, cbScaleVert{ui::null};
+       ui::Widget editScaleHor{ui::null}, editScaleVert{ui::null};
 
-       ui::Widget cbShiftHor, cbShiftVert;
-       ui::Widget editShiftHor, editShiftVert;
+       ui::Widget cbShiftHor{ui::null}, cbShiftVert{ui::null};
+       ui::Widget editShiftHor{ui::null}, editShiftVert{ui::null};
 
-       ui::Widget cbRotation;
-       ui::Widget editRotation;
+       ui::Widget cbRotation{ui::null};
+       ui::Widget editRotation{ui::null};
 }dlg_texReset_t;
 
 dlg_texReset_t dlgTexReset;
@@ -91,13 +91,10 @@ static void dialog_button_callback( GtkWidget *widget, gpointer data ){
        *ret = (EMessageBoxReturn)gpointer_to_int( data );
 }
 
-static gint dialog_delete_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
-       int *loop;
-
-       gtk_widget_hide( widget );
-       loop = (int*)g_object_get_data( G_OBJECT( widget ), "loop" );
+static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
+       widget.hide();
+       int *loop = (int *) g_object_get_data(G_OBJECT(widget), "loop");
        *loop = 0;
-
        return TRUE;
 }
 
@@ -209,7 +206,7 @@ bool ValidateTextInt( const char* pData, const char* error_title, int* value ){
  */
 
 EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMessageBoxType type ){
-       ui::Widget w, vbox, hbox;
+       ui::Widget w{ui::null};
        EMessageBoxReturn ret;
        int loop = 1;
 
@@ -222,7 +219,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
        g_object_set_data( G_OBJECT( window ), "ret", &ret );
        gtk_widget_realize( window );
 
-       vbox = ui::VBox( FALSE, 10 );
+       auto vbox = ui::VBox( FALSE, 10 );
        window.add(vbox);
        gtk_widget_show( vbox );
 
@@ -235,7 +232,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
        gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 2 );
        gtk_widget_show( w );
 
-       hbox = ui::HBox( FALSE, 10 );
+       auto hbox = ui::HBox( FALSE, 10 );
        gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
        gtk_widget_show( hbox );
 
@@ -305,7 +302,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
                gtk_main_iteration();
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -400,7 +397,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
        rs->bDuplicateOnly = gtk_toggle_button_get_active( (GtkToggleButton*)check2 ) ? true : false;
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -567,7 +564,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -822,7 +819,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 // -djbob
@@ -1037,17 +1034,14 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 //-djbob
 }
 
 EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
-       ui::Widget w, hbox;
-
-       ui::Entry text1, text2, text3;
-       ui::Widget check1, check2;
+       ui::Widget w{ui::null};
 
        EMessageBoxReturn ret;
        int loop = 1;
@@ -1073,13 +1067,13 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ---- vbox ----
 
-       hbox = ui::HBox( FALSE, 10 );
+       auto hbox = ui::HBox( FALSE, 10 );
        gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
        gtk_widget_show( hbox );
 
        // ---- hbox ----
 
-       text1 = ui::Entry( 256 );
+       auto text1 = ui::Entry( 256 );
        gtk_entry_set_text( text1, "25" );
        gtk_box_pack_start( GTK_BOX( hbox ), text1, FALSE, FALSE, 2 );
        gtk_widget_show( text1 );
@@ -1097,7 +1091,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ---- hbox ----
 
-       text2 = ui::Entry( 256 );
+       auto text2 = ui::Entry( 256 );
        gtk_entry_set_text( text2, "3" );
        gtk_box_pack_start( GTK_BOX( hbox ), text2, FALSE, FALSE, 2 );
        gtk_widget_show( text2 );
@@ -1120,7 +1114,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ---- hbox ----
 
-       text3 = ui::Entry( 256 );
+       auto text3 = ui::Entry( 256 );
        gtk_entry_set_text( text3, "-800" );
        gtk_box_pack_start( GTK_BOX( hbox ), text3, FALSE, FALSE, 2 );
        gtk_widget_show( text3 );
@@ -1136,11 +1130,11 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
        gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0 );
        gtk_widget_show( w );
 
-       check1 = ui::CheckButton( "No Dynamic Update" );
+       auto check1 = ui::CheckButton( "No Dynamic Update" );
        gtk_box_pack_start( GTK_BOX( vbox ), check1, FALSE, FALSE, 0 );
        gtk_widget_show( check1 );
 
-       check2 = ui::CheckButton( "Show Bounding Lines" );
+       auto check2 = ui::CheckButton( "Show Bounding Lines" );
        gtk_box_pack_start( GTK_BOX( vbox ), check2, FALSE, FALSE, 0 );
        gtk_widget_show( check2 );
 
@@ -1213,13 +1207,13 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
 
 EMessageBoxReturn DoCTFColourChangeBox(){
-       ui::Widget w, hbox;
+       ui::Widget w{ui::null};
        EMessageBoxReturn ret;
        int loop = 1;
 
@@ -1244,7 +1238,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
 
        // ---- vbox ----
 
-       hbox = ui::HBox( FALSE, 10 );
+       auto hbox = ui::HBox( FALSE, 10 );
        gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
        gtk_widget_show( hbox );
 
@@ -1281,7 +1275,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
                gtk_main_iteration();
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -1289,7 +1283,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
 EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        Str texSelected;
 
-       ui::Widget w, hbox;
+       ui::Widget w{ui::null};
 
        EMessageBoxReturn ret;
        int loop = 1;
@@ -1313,7 +1307,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
 
        // ---- vbox ----
 
-       hbox = ui::HBox( FALSE, 10 );
+       auto hbox = ui::HBox( FALSE, 10 );
        gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
        gtk_widget_show( hbox );
 
@@ -1612,7 +1606,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
@@ -1620,12 +1614,12 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
 EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        Str texSelected;
 
-       ui::Widget w, hbox;
+       ui::Widget w{ui::null};
 
-       ui::Widget radiusX, radiusY;
-       ui::Widget angleStart, angleEnd;
-       ui::Widget heightStart, heightEnd;
-       ui::Widget numPoints;
+       ui::Widget radiusX{ui::null}, radiusY{ui::null};
+       ui::Widget angleStart{ui::null}, angleEnd{ui::null};
+       ui::Widget heightStart{ui::null}, heightEnd{ui::null};
+       ui::Widget numPoints{ui::null};
 
        EMessageBoxReturn ret;
        int loop = 1;
@@ -1649,7 +1643,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
 
        // ---- vbox ----
 
-       hbox = ui::HBox( FALSE, 10 );
+       auto hbox = ui::HBox( FALSE, 10 );
        gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 2 );
        gtk_widget_show( hbox );
 
@@ -1879,15 +1873,15 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }
 // ailmanki
 // add a simple input for the MakeChain thing..
 EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
-       ui::Widget   w;
-       ui::Entry textlinkNum, textlinkName;
+       ui::Widget   w{ui::null};
+       ui::Entry textlinkNum{ui::null}, textlinkName{ui::null};
        EMessageBoxReturn ret;
        int loop = 1;
 
@@ -1991,7 +1985,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
        }
 
        gtk_grab_remove( window );
-       gtk_widget_destroy( window );
+       window.destroy();
 
        return ret;
 }