]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/patchmanip.cpp
Remove <gtk/gtk.h> from most of radiant/*
[xonotic/netradiant.git] / radiant / patchmanip.cpp
index d5471e98313b49a89f9735313759c9446043f411..6baad5ecd695be70682ca9113fc019ce43ae2089 100644 (file)
@@ -19,6 +19,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <gdk/gdkkeysyms.h>
 #include "patchmanip.h"
 
 #include "debugging/debugging.h"
@@ -67,6 +68,32 @@ void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const cha
        }
 }
 
+void PatchAutoCapTexture( Patch& patch ) {
+
+       AABB box = patch.localAABB();
+       float x = box.extents.x();
+       float y = box.extents.y();
+       float z = box.extents.z();
+
+       int cap_direction = -1;
+       if ( x < y  && x < z )
+               cap_direction = 0;
+       else if ( y < x  && y < z )
+               cap_direction = 1;
+       else if ( z < x  && z < x )
+               cap_direction = 2;
+
+       if ( cap_direction >= 0 )
+               patch.ProjectTexture(cap_direction);
+       else
+               patch.NaturalTexture();
+}
+
+void Patch_AutoCapTexture(){
+       UndoableCommand command( "patchAutoCapTexture" );
+       Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture );
+       SceneChangeNotify();
+}
 
 void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){
        if ( ( type == eCapEndCap || type == eCapIEndCap )
@@ -89,8 +116,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
                NodeSmartReference cap( g_patchCreator->createPatch() );
                Node_getTraversable( instance.path().parent() )->insert( cap );
 
-               patch.MakeCap( Node_getPatch( cap ), type, ROW, true );
-               Node_getPatch( cap )->SetShader( shader );
+               Patch* cap_patch = Node_getPatch( cap );
+               patch.MakeCap( cap_patch, type, ROW, true );
+               cap_patch->SetShader( shader );
+               PatchAutoCapTexture(*cap_patch);
 
                scene::Path path( instance.path() );
                path.pop();
@@ -102,8 +131,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co
                NodeSmartReference cap( g_patchCreator->createPatch() );
                Node_getTraversable( instance.path().parent() )->insert( cap );
 
-               patch.MakeCap( Node_getPatch( cap ), type, ROW, false );
-               Node_getPatch( cap )->SetShader( shader );
+               Patch* cap_patch = Node_getPatch( cap );
+               patch.MakeCap( cap_patch, type, ROW, false );
+               cap_patch->SetShader( shader );
+               PatchAutoCapTexture(*cap_patch);
 
                scene::Path path( instance.path() );
                path.pop();
@@ -585,8 +616,25 @@ void Patch_NaturalTexture(){
        Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
 }
 
+void Patch_CapTexture(){
+       UndoableCommand command( "patchCapTexture" );
 
+       Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+}
 
+void Patch_ResetTexture(){
+       float fx, fy;
+       if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
+               UndoableCommand command( "patchTileTexture" );
+               Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
+       }
+}
+
+void Patch_FitTexture(){
+       UndoableCommand command( "patchFitTexture" );
+
+       Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
+}
 
 #include "ifilter.h"
 
@@ -661,10 +709,6 @@ void PatchPreferences_construct(){
 void Patch_registerCommands(){
        GlobalCommands_insert( "InvertCurveTextureX", FreeCaller<Patch_FlipTextureX>(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
        GlobalCommands_insert( "InvertCurveTextureY", FreeCaller<Patch_FlipTextureY>(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) );
-       GlobalCommands_insert( "IncPatchColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-       GlobalCommands_insert( "IncPatchRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
-       GlobalCommands_insert( "DecPatchColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-       GlobalCommands_insert( "DecPatchRow", FreeCaller<Patch_DeleteLastRow>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "NaturalizePatch", FreeCaller<Patch_NaturalTexture>(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "PatchCylinder", FreeCaller<Patch_Cylinder>() );
        GlobalCommands_insert( "PatchDenseCylinder", FreeCaller<Patch_DenseCylinder>() );
@@ -680,13 +724,13 @@ void Patch_registerCommands(){
        GlobalCommands_insert( "PatchCone", FreeCaller<Patch_Cone>() );
        GlobalCommands_insert( "PatchSphere", FreeCaller<Patch_Sphere>() );
        GlobalCommands_insert( "SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) );
-       GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>() );
+       GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
        GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>() );
-       GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>() );
+       GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller<Patch_InsertInsertRow>(), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "PatchInsertAddRow", FreeCaller<Patch_InsertAddRow>() );
        GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller<Patch_DeleteFirstColumn>() );
-       GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>() );
-       GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>() );
+       GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller<Patch_DeleteLastColumn>(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller<Patch_DeleteFirstRow>(), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller<Patch_DeleteLastRow>() );
        GlobalCommands_insert( "InvertCurve", FreeCaller<Patch_Invert>(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) );
@@ -700,14 +744,14 @@ void Patch_registerCommands(){
        GlobalCommands_insert( "ClearPatchOverlays", FreeCaller<Patch_OverlayOff>(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) );
 }
 
-void Patch_constructToolbar( GtkToolbar* toolbar ){
-       toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.bmp", "CapCurrentCurve" );
+void Patch_constructToolbar( ui::Toolbar toolbar ){
+       toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" );
 }
 
-void Patch_constructMenu( GtkMenu* menu ){
+void Patch_constructMenu( ui::Menu menu ){
        create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -720,7 +764,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        create_menu_item_with_mnemonic( menu, "End cap", "PatchEndCap" );
        create_menu_item_with_mnemonic( menu, "Bevel", "PatchBevel" );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More End caps, Bevels" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -737,7 +781,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        create_menu_item_with_mnemonic( menu, "Simple Patch Mesh...", "SimplePatchMesh" );
        menu_separator( menu );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Insert" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -748,7 +792,7 @@ void Patch_constructMenu( GtkMenu* menu ){
                create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" );
        }
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -760,18 +804,18 @@ void Patch_constructMenu( GtkMenu* menu ){
        }
        menu_separator( menu );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Matrix" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
                create_menu_item_with_mnemonic( menu_in_menu, "Invert", "InvertCurve" );
-               GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
+               auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Re-disperse" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_3 );
                }
                create_menu_item_with_mnemonic( menu_3, "Rows", "RedisperseRows" );
                create_menu_item_with_mnemonic( menu_3, "Columns", "RedisperseCols" );
-               GtkMenu* menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
+               auto menu_4 = create_sub_menu_with_mnemonic( menu_in_menu, "Smooth" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_4 );
                }
@@ -784,7 +828,7 @@ void Patch_constructMenu( GtkMenu* menu ){
        create_menu_item_with_mnemonic( menu, "Cycle Cap Texture", "CycleCapTexturePatch" );
        menu_separator( menu );
        {
-               GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
+               auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Overlay" );
                if ( g_Layout_enableDetachableMenus.m_value ) {
                        menu_tearoff( menu_in_menu );
                }
@@ -794,12 +838,6 @@ void Patch_constructMenu( GtkMenu* menu ){
 }
 
 
-#include <gtk/gtkbox.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkradiobutton.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtklabel.h>
 #include "gtkutil/dialog.h"
 #include "gtkutil/widget.h"
 
@@ -808,10 +846,10 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
        GtkComboBox* width;
        GtkComboBox* height;
 
-       GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch density", G_CALLBACK( dialog_delete_callback ), &dialog );
+       ui::Window window = MainFrame_getWindow().create_dialog_window("Patch density", G_CALLBACK(dialog_delete_callback ), &dialog );
 
-       GtkAccelGroup* accel = gtk_accel_group_new();
-       gtk_window_add_accel_group( window, accel );
+       auto accel = ui::AccelGroup();
+       window.add_accel_group( accel );
 
        {
                GtkHBox* hbox = create_dialog_hbox( 4, 4 );
@@ -820,7 +858,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                        GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
                        gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
                        {
-                               GtkLabel* label = GTK_LABEL( gtk_label_new( "Width:" ) );
+                               GtkLabel* label = GTK_LABEL( ui::Label( "Width:" ) );
                                gtk_widget_show( GTK_WIDGET( label ) );
                                gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -828,7 +866,7 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                                gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
                        }
                        {
-                               GtkLabel* label = GTK_LABEL( gtk_label_new( "Height:" ) );
+                               GtkLabel* label = GTK_LABEL( ui::Label( "Height:" ) );
                                gtk_widget_show( GTK_WIDGET( label ) );
                                gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
                                                                  (GtkAttachOptions) ( GTK_FILL ),
@@ -837,8 +875,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                        }
 
                        {
-                               GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
-#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_append_text( combo, # x )
+                               auto combo = ui::ComboBoxText();
+#define D_ITEM( x ) if ( x >= mincols && ( !maxcols || x <= maxcols ) ) gtk_combo_box_text_append_text( combo, # x )
                                D_ITEM( 3 );
                                D_ITEM( 5 );
                                D_ITEM( 7 );
@@ -863,8 +901,8 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                                width = combo;
                        }
                        {
-                               GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
-#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_append_text( combo, # x )
+                               auto combo = ui::ComboBoxText();
+#define D_ITEM( x ) if ( x >= minrows && ( !maxrows || x <= maxrows ) ) gtk_combo_box_text_append_text( combo, # x )
                                D_ITEM( 3 );
                                D_ITEM( 5 );
                                D_ITEM( 7 );
@@ -894,9 +932,9 @@ void DoNewPatchDlg( EPatchPrefab prefab, int minrows, int mincols, int defrows,
                        GtkVBox* vbox = create_dialog_vbox( 4 );
                        gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
                        {
-                               GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+                               auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
                                gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
-                               widget_make_default( GTK_WIDGET( button ) );
+                               widget_make_default( button );
                                gtk_widget_grab_focus( GTK_WIDGET( button ) );
                                gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
                        }
@@ -929,16 +967,16 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
        ModalDialog dialog;
        ModalDialogButton ok_button( dialog, eIDOK );
        ModalDialogButton cancel_button( dialog, eIDCANCEL );
-       GtkWidget* bevel;
-       GtkWidget* ibevel;
-       GtkWidget* endcap;
-       GtkWidget* iendcap;
-       GtkWidget* cylinder;
+       ui::Widget bevel;
+       ui::Widget ibevel;
+       ui::Widget endcap;
+       ui::Widget iendcap;
+       ui::Widget cylinder;
 
-       GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Cap", dialog );
+       ui::Window window = MainFrame_getWindow().create_modal_dialog_window( "Cap", dialog );
 
-       GtkAccelGroup *accel_group = gtk_accel_group_new();
-       gtk_window_add_accel_group( window, accel_group );
+       auto accel_group = ui::AccelGroup();
+       window.add_accel_group( accel_group );
 
        {
                GtkHBox* hbox = create_dialog_hbox( 4, 4 );
@@ -950,42 +988,42 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
                        gtk_container_add( GTK_CONTAINER( hbox ), GTK_WIDGET( radio_vbox ) );
 
                        {
-                               GtkTable* table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );
+                               GtkTable* table = ui::Table( 5, 2, FALSE );
                                gtk_widget_show( GTK_WIDGET( table ) );
                                gtk_box_pack_start( GTK_BOX( radio_vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
                                gtk_table_set_row_spacings( table, 5 );
                                gtk_table_set_col_spacings( table, 5 );
 
                                {
-                                       GtkImage* image = new_local_image( "cap_bevel.bmp" );
+                                       GtkImage* image = new_local_image( "cap_bevel.png" );
                                        gtk_widget_show( GTK_WIDGET( image ) );
                                        gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1,
                                                                          (GtkAttachOptions) ( GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
                                }
                                {
-                                       GtkImage* image = new_local_image( "cap_endcap.bmp" );
+                                       GtkImage* image = new_local_image( "cap_endcap.png" );
                                        gtk_widget_show( GTK_WIDGET( image ) );
                                        gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2,
                                                                          (GtkAttachOptions) ( GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
                                }
                                {
-                                       GtkImage* image = new_local_image( "cap_ibevel.bmp" );
+                                       GtkImage* image = new_local_image( "cap_ibevel.png" );
                                        gtk_widget_show( GTK_WIDGET( image ) );
                                        gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3,
                                                                          (GtkAttachOptions) ( GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
                                }
                                {
-                                       GtkImage* image = new_local_image( "cap_iendcap.bmp" );
+                                       GtkImage* image = new_local_image( "cap_iendcap.png" );
                                        gtk_widget_show( GTK_WIDGET( image ) );
                                        gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_FILL ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
                                }
                                {
-                                       GtkImage* image = new_local_image( "cap_cylinder.bmp" );
+                                       GtkImage* image = new_local_image( "cap_cylinder.png" );
                                        gtk_widget_show( GTK_WIDGET( image ) );
                                        gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5,
                                                                          (GtkAttachOptions) ( GTK_FILL ),
@@ -994,52 +1032,52 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
 
                                GSList* group = 0;
                                {
-                                       GtkWidget* button = gtk_radio_button_new_with_label( group, "Bevel" );
+                                       ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Bevel" ));
                                        gtk_widget_show( button );
                                        gtk_table_attach( table, button, 1, 2, 0, 1,
                                                                          (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+                                       group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
 
                                        bevel = button;
                                }
                                {
-                                       GtkWidget* button = gtk_radio_button_new_with_label( group, "Endcap" );
+                                       ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Endcap" ));
                                        gtk_widget_show( button );
                                        gtk_table_attach( table, button, 1, 2, 1, 2,
                                                                          (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+                                       group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
 
                                        endcap = button;
                                }
                                {
-                                       GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Bevel" );
+                                       ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Bevel" ));
                                        gtk_widget_show( button );
                                        gtk_table_attach( table, button, 1, 2, 2, 3,
                                                                          (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+                                       group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
 
                                        ibevel = button;
                                }
                                {
-                                       GtkWidget* button = gtk_radio_button_new_with_label( group, "Inverted Endcap" );
+                                       ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Inverted Endcap" ));
                                        gtk_widget_show( button );
                                        gtk_table_attach( table, button, 1, 2, 3, 4,
                                                                          (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+                                       group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
 
                                        iendcap = button;
                                }
                                {
-                                       GtkWidget* button = gtk_radio_button_new_with_label( group, "Cylinder" );
+                                       ui::Widget button = ui::Widget(gtk_radio_button_new_with_label( group, "Cylinder" ));
                                        gtk_widget_show( button );
                                        gtk_table_attach( table, button, 1, 2, 4, 5,
                                                                          (GtkAttachOptions) ( GTK_FILL | GTK_EXPAND ),
                                                                          (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       group = gtk_radio_button_group( GTK_RADIO_BUTTON( button ) );
+                                       group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( button ) );
 
                                        cylinder = button;
                                }
@@ -1050,9 +1088,9 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){
                        GtkVBox* vbox = create_dialog_vbox( 4 );
                        gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
                        {
-                               GtkButton* button = create_modal_dialog_button( "OK", ok_button );
+                               auto button = create_modal_dialog_button( "OK", ok_button );
                                gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
-                               widget_make_default( GTK_WIDGET( button ) );
+                               widget_make_default( button );
                                gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
                        }
                        {