]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/dialogs/dialogs-gtk.cpp
Merge commit 'a59855266c41b68a8bfd063713c941eff7449181' into garux-merge
[xonotic/netradiant.git] / contrib / bobtoolz / dialogs / dialogs-gtk.cpp
index 15ccf8e171354ebd3c5350e16589a1a51228b071..9329f306a2817e7823d6e95fb456ee9e310861b3 100644 (file)
@@ -51,7 +51,7 @@ dlg_texReset_t dlgTexReset;
 
 void Update_TextureReseter();
 
-static void dialog_button_callback_texreset_update( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_texreset_update(ui::Widget widget, gpointer data ){
        Update_TextureReseter();
 }
 
@@ -78,12 +78,11 @@ void Update_TextureReseter(){
        gtk_editable_set_editable( GTK_EDITABLE( dlgTexReset.editRotation ), check );
 }
 
-static void dialog_button_callback( GtkWidget *widget, gpointer data ){
-       GtkWidget *parent;
+static void dialog_button_callback( ui::Widget widget, gpointer data ){
        int *loop;
        EMessageBoxReturn *ret;
 
-       parent = gtk_widget_get_toplevel( widget );
+       auto parent = widget.window();
        loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" );
        ret = (EMessageBoxReturn*)g_object_get_data( G_OBJECT( parent ), "ret" );
 
@@ -98,11 +97,11 @@ static gint dialog_delete_callback( ui::Widget widget, GdkEvent* event, gpointer
        return TRUE;
 }
 
-static void dialog_button_callback_settex( GtkWidget *widget, gpointer data ){
+static void dialog_button_callback_settex(ui::Widget widget, gpointer data ){
        TwinWidget* tw = (TwinWidget*)data;
 
-       GtkEntry* entry = GTK_ENTRY( tw->one );
-       auto* combo = GTK_BIN(tw->two);
+    auto entry = ui::Entry::from( tw->one );
+       auto combo = tw->two;
 
        const gchar *tex = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(combo)));
        gtk_entry_set_text( entry, tex );
@@ -213,7 +212,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
        auto window = ui::Window( ui::window_type::TOP );
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
-       gtk_window_set_title( GTK_WINDOW( window ), lpCaption );
+       gtk_window_set_title( window, lpCaption );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
        g_object_set_data( G_OBJECT( window ), "ret", &ret );
@@ -228,7 +227,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
        gtk_label_set_justify( GTK_LABEL( w ), GTK_JUSTIFY_LEFT );
        w.show();
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 2 );
        w.show();
 
@@ -294,7 +293,7 @@ EMessageBoxReturn DoMessageBox( const char* lpText, const char* lpCaption, EMess
                ret = eIDNO;
        }
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -316,7 +315,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Intersect" );
+       gtk_window_set_title( window, "Intersect" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -333,15 +332,15 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
        // ---- vbox ----
 
 
-       auto radio1 = ui::Widget(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
+       auto radio1 = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Use Whole Map" ));
        vbox.pack_start( radio1, FALSE, FALSE, 2 );
        radio1.show();
 
-       auto radio2 = ui::Widget(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
+       auto radio2 = ui::Widget::from(gtk_radio_button_new_with_label( gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1)), "Use Selected Brushes" ));
        vbox.pack_start( radio2, FALSE, FALSE, 2 );
        radio2.show();
 
-       auto hsep = ui::Widget(gtk_hseparator_new());
+       auto hsep = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( hsep, FALSE, FALSE, 2 );
        hsep.show();
 
@@ -377,7 +376,7 @@ EMessageBoxReturn DoIntersectBox( IntersectRS* rs ){
 
        // ---- /vbox ----
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -409,7 +408,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Polygon Builder" );
+       gtk_window_set_title( window, "Polygon Builder" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -445,7 +444,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        // ---- hbox2 ----
 
     auto text1 = ui::Entry( 256 );
-       gtk_entry_set_text( (GtkEntry*)text1, "3" );
+       gtk_entry_set_text( text1, "3" );
        hbox2.pack_start( text1, FALSE, FALSE, 2 );
        text1.show();
 
@@ -463,7 +462,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
        // ---- hbox2 ----
 
     auto text2 = ui::Entry( 256 );
-       gtk_entry_set_text( (GtkEntry*)text2, "8" );
+       gtk_entry_set_text( text2, "8" );
        hbox2.pack_start( text2, FALSE, FALSE, 2 );
        text2.show();
 
@@ -526,7 +525,7 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
 
        // ---- /vbox ----
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -544,12 +543,12 @@ EMessageBoxReturn DoPolygonBox( PolygonRS* rs ){
                        rs->bInverse = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check2) ) ? true : false;
                        rs->bAlignTop = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(check3) ) ? true : false;
 
-                       if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
+                       if ( !ValidateTextIntRange( gtk_entry_get_text( text1 ), 3, 32, "Number Of Sides", &rs->nSides ) ) {
                                dialogError = TRUE;
                        }
 
                        if ( rs->bUseBorder ) {
-                               if ( !ValidateTextIntRange( gtk_entry_get_text( (GtkEntry*)text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
+                               if ( !ValidateTextIntRange( gtk_entry_get_text( text2 ), 8, 256, "Border Width", &rs->nBorderWidth ) ) {
                                        dialogError = TRUE;
                                }
                        }
@@ -577,7 +576,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Stair Builder" );
+       gtk_window_set_title( window, "Stair Builder" );
 
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
@@ -600,7 +599,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        hbox.pack_start( w, FALSE, FALSE, 0 ); // not entirely sure on all the parameters / what they do ...
        w.show();
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -641,25 +640,25 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        // djbob: actually it looks very nice :), slightly better than the way i did it
        // edit: actually it doesn't work :P, you must pass the last radio item each time, ugh
 
-    auto radioNorth = ui::Widget(gtk_radio_button_new_with_label( NULL, "North" ));
+    auto radioNorth = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North" ));
        hbox.pack_start( radioNorth, FALSE, FALSE, 3 );
        radioNorth.show();
 
        radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNorth ) );
 
-    auto radioSouth = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "South" ));
+    auto radioSouth = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "South" ));
        hbox.pack_start( radioSouth, FALSE, FALSE, 2 );
        radioSouth.show();
 
        radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioSouth ) );
 
-    auto radioEast = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "East" ));
+    auto radioEast = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "East" ));
        hbox.pack_start( radioEast, FALSE, FALSE, 1 );
        radioEast.show();
 
        radioDirection = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioEast ) );
 
-    auto radioWest = ui::Widget(gtk_radio_button_new_with_label( radioDirection, "West" ));
+    auto radioWest = ui::Widget::from(gtk_radio_button_new_with_label( radioDirection, "West" ));
        hbox.pack_start( radioWest, FALSE, FALSE, 0 );
        radioWest.show();
 
@@ -679,19 +678,19 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        vbox.pack_start( hbox, FALSE, FALSE, 0 );
        hbox.show();
 
-    auto radioOldStyle = ui::Widget(gtk_radio_button_new_with_label( NULL, "Original" ));
+    auto radioOldStyle = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "Original" ));
        hbox.pack_start( radioOldStyle, FALSE, FALSE, 0 );
        radioOldStyle.show();
 
        radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioOldStyle ) );
 
-    auto radioBobStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
+    auto radioBobStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Bob's Style" ));
        hbox.pack_start( radioBobStyle, FALSE, FALSE, 0 );
        radioBobStyle.show();
 
        radioStyle = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioBobStyle ) );
 
-    auto radioCornerStyle = ui::Widget(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
+    auto radioCornerStyle = ui::Widget::from(gtk_radio_button_new_with_label( radioStyle, "Corner Style" ));
        hbox.pack_start( radioCornerStyle, FALSE, FALSE, 0 );
        radioCornerStyle.show();
 
@@ -736,7 +735,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        w.show();
 
        // -------------------------- //
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -759,7 +758,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
        ret = eIDCANCEL;
 
 // +djbob: need our "little" modal loop mars :P
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -775,8 +774,8 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
                if ( ret == eIDOK ) {
                        rs->bUseDetail = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(checkUseDetail) ) ? true : false;
 
-                       strcpy( rs->riserTexture, gtk_entry_get_text( (GtkEntry*)textRiserTex ) );
-                       strcpy( rs->mainTexture, gtk_entry_get_text( (GtkEntry*)textMainTex ) );
+                       strcpy( rs->riserTexture, gtk_entry_get_text( textRiserTex ) );
+                       strcpy( rs->mainTexture, gtk_entry_get_text( textMainTex ) );
 
                        if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(radioNorth) ) ) {
                                rs->direction = MOVE_NORTH;
@@ -791,7 +790,7 @@ EMessageBoxReturn DoBuildStairsBox( BuildStairsRS* rs ){
                                rs->direction = MOVE_WEST;
                        }
 
-                       if ( !ValidateTextInt( gtk_entry_get_text( (GtkEntry*)textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
+                       if ( !ValidateTextInt( gtk_entry_get_text( textStairHeight ), "Stair Height", &rs->stairHeight ) ) {
                                dialogError = TRUE;
                        }
 
@@ -827,7 +826,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Door Builder" );
+       gtk_window_set_title( window, "Door Builder" );
 
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
@@ -837,8 +836,8 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        gtk_widget_realize( window );
 
        char buffer[256];
-       ui::ListStore listMainTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
-       ui::ListStore listTrimTextures = ui::ListStore(gtk_list_store_new( 1, G_TYPE_STRING ));
+       auto listMainTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
+       auto listTrimTextures = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
        LoadGList( GetFilename( buffer, "plugins/bt/door-tex.txt" ), listMainTextures );
        LoadGList( GetFilename( buffer, "plugins/bt/door-tex-trim.txt" ), listTrimTextures );
 
@@ -916,7 +915,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
 
        // djbob: lists added
 
-       auto comboMain = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listMainTextures))));
+       auto comboMain = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listMainTextures));
        gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
        hbox.pack_start( comboMain, FALSE, FALSE, 0 );
        comboMain.show();
@@ -935,7 +934,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        vbox.pack_start( hbox, FALSE, FALSE, 0 );
        hbox.show();
 
-       auto comboTrim = ui::ComboBox(GTK_COMBO_BOX(gtk_combo_box_new_with_model_and_entry(GTK_TREE_MODEL(listTrimTextures))));
+       auto comboTrim = ui::ComboBox::from(gtk_combo_box_new_with_model_and_entry(listTrimTextures));
        gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(comboMain), 0);
        hbox.pack_start( comboTrim, FALSE, FALSE, 0 );
        comboTrim.show();
@@ -959,19 +958,19 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        w.show();
 
        // argh more radio buttons!
-    auto radioNS = ui::Widget(gtk_radio_button_new_with_label( NULL, "North - South" ));
+    auto radioNS = ui::Widget::from(gtk_radio_button_new_with_label( NULL, "North - South" ));
        hbox.pack_start( radioNS, FALSE, FALSE, 0 );
        radioNS.show();
 
        radioOrientation = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radioNS ) );
 
-    auto radioEW = ui::Widget(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
+    auto radioEW = ui::Widget::from(gtk_radio_button_new_with_label( radioOrientation, "East - West" ));
        hbox.pack_start( radioEW, FALSE, FALSE, 0 );
        radioEW.show();
 
        // ----------------- //
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -997,7 +996,7 @@ EMessageBoxReturn DoDoorsBox( DoorRS* rs ){
        // ----------------- //
 
 //+djbob
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -1037,7 +1036,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
+       gtk_window_set_title( window, "Texture Reset" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -1112,7 +1111,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ---- /hbox ----
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -1129,7 +1128,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ----------------- //
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -1161,7 +1160,7 @@ EMessageBoxReturn DoPathPlotterBox( PathPlotterRS* rs ){
 
        // ----------------- //
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -1208,7 +1207,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "CTF Colour Changer" );
+       gtk_window_set_title( window, "CTF Colour Changer" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -1253,7 +1252,7 @@ EMessageBoxReturn DoCTFColourChangeBox(){
 
        // ---- /vbox ----
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -1279,7 +1278,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Texture Reset" );
+       gtk_window_set_title( window, "Texture Reset" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -1316,8 +1315,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
@@ -1325,34 +1324,24 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        dlgTexReset.cbTexChange = ui::CheckButton( "Enabled" );
        dlgTexReset.cbTexChange.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
        dlgTexReset.cbTexChange.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbTexChange, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbTexChange, {0, 1, 0, 1}, {GTK_FILL, 0});
 
        w = ui::Label( "Old Name: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editTexOld = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexOld ), rs->textureName );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexOld, 2, 3, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editTexOld, {2, 3, 0, 1}, {GTK_FILL, 0});
        dlgTexReset.editTexOld.show();
 
        w = ui::Label( "New Name: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editTexNew = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editTexNew ), rs->textureName );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editTexNew, 2, 3, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editTexNew, {2, 3, 1, 2}, {GTK_FILL, 0});
        dlgTexReset.editTexNew.show();
 
        // ---- /frame ----
@@ -1364,8 +1353,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
@@ -1373,42 +1362,30 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        dlgTexReset.cbScaleHor = ui::CheckButton( "Enabled" );
        dlgTexReset.cbScaleHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
        dlgTexReset.cbScaleHor.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleHor, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbScaleHor, {0, 1, 0, 1}, {GTK_FILL, 0});
 
        w = ui::Label( "New Horizontal Scale: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editScaleHor = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleHor ), "0.5" );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleHor, 2, 3, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editScaleHor, {2, 3, 0, 1}, {GTK_FILL, 0});
        dlgTexReset.editScaleHor.show();
 
 
        dlgTexReset.cbScaleVert = ui::CheckButton( "Enabled" );
        dlgTexReset.cbScaleVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
        dlgTexReset.cbScaleVert.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbScaleVert, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbScaleVert, {0, 1, 1, 2}, {GTK_FILL, 0});
 
        w = ui::Label( "New Vertical Scale: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editScaleVert = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editScaleVert ), "0.5" );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editScaleVert, 2, 3, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editScaleVert, {2, 3, 1, 2}, {GTK_FILL, 0});
        dlgTexReset.editScaleVert.show();
 
        // ---- /frame ----
@@ -1420,8 +1397,8 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
@@ -1429,42 +1406,30 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        dlgTexReset.cbShiftHor = ui::CheckButton( "Enabled" );
        dlgTexReset.cbShiftHor.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
        dlgTexReset.cbShiftHor.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftHor, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbShiftHor, {0, 1, 0, 1}, {GTK_FILL, 0});
 
        w = ui::Label( "New Horizontal Shift: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editShiftHor = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftHor ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftHor, 2, 3, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editShiftHor, {2, 3, 0, 1}, {GTK_FILL, 0});
        dlgTexReset.editShiftHor.show();
 
 
        dlgTexReset.cbShiftVert = ui::CheckButton( "Enabled" );
        dlgTexReset.cbShiftVert.connect( "toggled", G_CALLBACK( dialog_button_callback_texreset_update ), NULL );
        dlgTexReset.cbShiftVert.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbShiftVert, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbShiftVert, {0, 1, 1, 2}, {GTK_FILL, 0});
 
        w = ui::Label( "New Vertical Shift: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editShiftVert = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editShiftVert ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editShiftVert, 2, 3, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editShiftVert, {2, 3, 1, 2}, {GTK_FILL, 0});
        dlgTexReset.editShiftVert.show();
 
        // ---- /frame ----
@@ -1476,29 +1441,23 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
        table = ui::Table( 1, 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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
 
        dlgTexReset.cbRotation = ui::CheckButton( "Enabled" );
        dlgTexReset.cbRotation.show();
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.cbRotation, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.cbRotation, {0, 1, 0, 1}, {GTK_FILL, 0});
 
        w = ui::Label( "New Rotation Value: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {1, 2, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        dlgTexReset.editRotation = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( dlgTexReset.editRotation ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), dlgTexReset.editRotation, 2, 3, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(dlgTexReset.editRotation, {2, 3, 0, 1}, {GTK_FILL, 0});
        dlgTexReset.editRotation.show();
 
        // ---- /frame ----
@@ -1532,7 +1491,7 @@ EMessageBoxReturn DoResetTextureBox( ResetTextureRS* rs ){
 
        // ---- /vbox ----
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -1615,7 +1574,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Train Thing" );
+       gtk_window_set_title( window, "Train Thing" );
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
        g_object_set_data( G_OBJECT( window ), "loop", &loop );
@@ -1642,38 +1601,30 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
 
        w = ui::Label( "X: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        radiusX = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( radiusX ), "100" );
-       gtk_table_attach( GTK_TABLE( table ), radiusX, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(radiusX, {1, 2, 0, 1}, {GTK_FILL, 0});
        radiusX.show();
 
 
 
        w = ui::Label( "Y: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        radiusY = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( radiusY ), "100" );
-       gtk_table_attach( GTK_TABLE( table ), radiusY, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(radiusY, {1, 2, 1, 2}, {GTK_FILL, 0});
        radiusY.show();
 
 
@@ -1685,38 +1636,30 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        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_table_set_row_spacings((table), 5);
+       gtk_table_set_col_spacings((table), 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
 
        w = ui::Label( "Start: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        angleStart = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( angleStart ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), angleStart, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(angleStart, {1, 2, 0, 1}, {GTK_FILL, 0});
        angleStart.show();
 
 
 
        w = ui::Label( "End: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        angleEnd = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( angleEnd ), "90" );
-       gtk_table_attach( GTK_TABLE( table ), angleEnd, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(angleEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
        angleEnd.show();
 
 
@@ -1727,38 +1670,30 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
 
        w = ui::Label( "Start: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        heightStart = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( heightStart ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), heightStart, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(heightStart, {1, 2, 0, 1}, {GTK_FILL, 0});
        heightStart.show();
 
 
 
        w = ui::Label( "End: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 1, 2}, {GTK_FILL, 0});
        w.show();
 
        heightEnd = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( heightEnd ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), heightEnd, 1, 2, 1, 2,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(heightEnd, {1, 2, 1, 2}, {GTK_FILL, 0});
        heightEnd.show();
 
 
@@ -1770,23 +1705,19 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
        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_table_set_row_spacings(table, 5);
+       gtk_table_set_col_spacings(table, 5);
        gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
 
        // ---- frame ----
 
        w = ui::Label( "Number: " );
-       gtk_table_attach( GTK_TABLE( table ), w, 0, 1, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(w, {0, 1, 0, 1}, {GTK_FILL, 0});
        w.show();
 
        numPoints = ui::Entry( 256 );
        gtk_entry_set_text( GTK_ENTRY( numPoints ), "0" );
-       gtk_table_attach( GTK_TABLE( table ), numPoints, 1, 2, 0, 1,
-                                         (GtkAttachOptions) ( GTK_FILL ),
-                                         (GtkAttachOptions) ( 0 ), 0, 0 );
+       table.attach(numPoints, {1, 2, 0, 1}, {GTK_FILL, 0});
        numPoints.show();
 
 
@@ -1814,7 +1745,7 @@ EMessageBoxReturn DoTrainThingBox( TrainThingRS* rs ){
 
 
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position( window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );
 
@@ -1878,7 +1809,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
        window.connect( "delete_event", G_CALLBACK( dialog_delete_callback ), NULL );
        window.connect( "destroy", G_CALLBACK( gtk_widget_destroy ), NULL );
 
-       gtk_window_set_title( GTK_WINDOW( window ), "Make Chain" );
+       gtk_window_set_title( window, "Make Chain" );
 
        gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
 
@@ -1901,7 +1832,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
        hbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
-       w = ui::Widget(gtk_hseparator_new());
+       w = ui::Widget::from(gtk_hseparator_new());
        vbox.pack_start( w, FALSE, FALSE, 0 );
        w.show();
 
@@ -1949,7 +1880,7 @@ EMessageBoxReturn DoMakeChainBox( MakeChainRS* rs ){
 
        ret = eIDCANCEL;
 
-       gtk_window_set_position( GTK_WINDOW( window ),GTK_WIN_POS_CENTER );
+       gtk_window_set_position(  window, GTK_WIN_POS_CENTER );
        window.show();
        gtk_grab_add( window );