]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/dialog.cpp
Purge gtk_widget_show from radiant/*
[xonotic/netradiant.git] / radiant / dialog.cpp
index b93bf00bd538ea754209e35397f3e0ee64bfda05..b3ba1f1a07a6885f37d1a73d86c9c42a5db19b4f 100644 (file)
@@ -35,8 +35,6 @@
 
 #include <stdlib.h>
 
-#include <gtk/gtk.h>
-
 #include "stream/stringstream.h"
 #include "convert.h"
 #include "gtkutil/dialog.h"
@@ -48,8 +46,8 @@
 
 
 GtkEntry* DialogEntry_new(){
-       GtkEntry* entry = ui::Entry();
-       gtk_widget_show( GTK_WIDGET( entry ) );
+       auto entry = ui::Entry();
+       entry.show();
        gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
        return entry;
 }
@@ -65,7 +63,7 @@ GtkEntry* m_entry;
 
 DialogEntryRow DialogEntryRow_new( const char* name ){
        ui::Widget alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
-       gtk_widget_show( alignment );
+       alignment.show();
 
        GtkEntry* entry = DialogEntry_new();
        gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) );
@@ -81,8 +79,8 @@ GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int
        {
                ++digits;
        }
-       GtkSpinButton* spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
-       gtk_widget_show( GTK_WIDGET( spin ) );
+       auto spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
+       spin.show();
        gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
        return spin;
 }
@@ -98,7 +96,7 @@ 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 );
-       gtk_widget_show( alignment );
+       alignment.show();
 
        GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction );
        gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) );
@@ -159,7 +157,7 @@ typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> Te
 
 
 void IntEntryImport( GtkEntry& widget, int value ){
-       entry_set_int( &widget, value );
+       entry_set_int( ui::Entry(&widget), value );
 }
 void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){
        importCallback( atoi( gtk_entry_get_text( &widget ) ) );
@@ -168,7 +166,7 @@ typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImpo
 
 
 void SizeEntryImport( GtkEntry& widget, std::size_t value ){
-       entry_set_int( &widget, int(value) );
+       entry_set_int( ui::Entry(&widget), int(value) );
 }
 void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){
        int value = atoi( gtk_entry_get_text( &widget ) );
@@ -181,7 +179,7 @@ typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> Si
 
 
 void FloatEntryImport( GtkEntry& widget, float value ){
-       entry_set_float( &widget, value );
+       entry_set_float( ui::Entry(&widget), value );
 }
 void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){
        importCallback( (float)atof( gtk_entry_get_text( &widget ) ) );
@@ -313,7 +311,7 @@ Dialog::~Dialog(){
 void Dialog::ShowDlg(){
        ASSERT_MESSAGE( m_window, "dialog was not constructed" );
        importData();
-       gtk_widget_show( GTK_WIDGET( m_window ) );
+       m_window.show();
 }
 
 void Dialog::HideDlg(){
@@ -455,10 +453,10 @@ EMessageBoxReturn Dialog::DoModal(){
 
 ui::CheckButton Dialog::addCheckBox( ui::Widget vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
        auto check = ui::CheckButton( flag );
-       gtk_widget_show( check );
+       check.show();
        AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
 
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), ui::Widget(GTK_WIDGET( DialogRow_new( name, check ) ) ));
        return check;
 }
 
@@ -468,7 +466,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 );
-       gtk_widget_show( alignment );
+       alignment.show();
        {
                ui::Widget combo = ui::ComboBoxText();
 
@@ -479,12 +477,12 @@ void Dialog::addCombo( ui::Widget vbox, const char* name, StringArrayRange value
 
                AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer );
 
-               gtk_widget_show( combo );
+               combo.show();
                gtk_container_add( GTK_CONTAINER( alignment ), combo );
        }
 
-       GtkTable* row = DialogRow_new( name, alignment );
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+       auto row = DialogRow_new( name, alignment );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX(vbox)), row );
 }
 
 void Dialog::addCombo( ui::Widget vbox, const char* name, int& data, StringArrayRange values ){
@@ -495,16 +493,16 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d
 #if 0
        if ( draw_value == FALSE ) {
                ui::Widget hbox2 = ui::HBox( FALSE, 0 );
-               gtk_widget_show( hbox2 );
+               hbox2.show();
                gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
                {
                        ui::Widget label = ui::Label( low );
-                       gtk_widget_show( label );
+                       label.show();
                        gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
                }
                {
                        ui::Widget label = ui::Label( high );
-                       gtk_widget_show( label );
+                       label.show();
                        gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
                }
        }
@@ -516,31 +514,31 @@ void Dialog::addSlider( ui::Widget vbox, const char* name, int& data, gboolean d
 
        // scale
        ui::Widget alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
-       gtk_widget_show( alignment );
+       alignment.show();
 
        ui::Widget scale = ui::HScale( adj );
        gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT );
-       gtk_widget_show( scale );
+       scale.show();
        gtk_container_add( GTK_CONTAINER( alignment ), scale );
 
        gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
        gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
 
-       GtkTable* row = DialogRow_new( name, alignment );
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+       auto row = DialogRow_new( name, alignment );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
 }
 
 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 );
-       gtk_widget_show( alignment );
+       alignment.show();;
        {
                RadioHBox radioBox = RadioHBox_new( names );
                gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) );
                AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
        }
 
-       GtkTable* row = DialogRow_new( name, alignment );
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+       auto row = DialogRow_new( name, alignment );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
 }
 
 void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArrayRange names ){
@@ -549,7 +547,7 @@ void Dialog::addRadio( ui::Widget vbox, const char* name, int& data, StringArray
 
 void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
        ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE );
-       gtk_widget_show( table );
+       table.show();;
 
        gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
        gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
@@ -559,14 +557,14 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange
        for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon )
        {
                guint pos = static_cast<guint>( icon - icons.first );
-               GtkImage* image = new_local_image( *icon );
-               gtk_widget_show( GTK_WIDGET( image ) );
+               auto image = new_local_image( *icon );
+               image.show();
                gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( image ), pos, pos + 1, 0, 1,
                                                  (GtkAttachOptions) ( 0 ),
                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
 
                radio = ui::Widget(gtk_radio_button_new( group ));
-               gtk_widget_show( radio );
+               radio.show();
                gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2,
                                                  (GtkAttachOptions) ( 0 ),
                                                  (GtkAttachOptions) ( 0 ), 0, 0 );
@@ -576,7 +574,7 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, StringArrayRange
 
        AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
 
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), DialogRow_new( name, table ) );
 }
 
 void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, StringArrayRange icons ){
@@ -586,21 +584,21 @@ void Dialog::addRadioIcons( ui::Widget vbox, const char* name, int& data, String
 ui::Widget Dialog::addIntEntry( ui::Widget vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddIntEntryData( *row.m_entry, importViewer, exportViewer );
-       DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
        return row.m_row;
 }
 
 ui::Widget Dialog::addSizeEntry( ui::Widget vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddSizeEntryData( *row.m_entry, importViewer, exportViewer );
-       DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
        return row.m_row;
 }
 
 ui::Widget Dialog::addFloatEntry( ui::Widget vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
        DialogEntryRow row( DialogEntryRow_new( name ) );
        AddFloatEntryData( *row.m_entry, importViewer, exportViewer );
-       DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
        return row.m_row;
 }
 
@@ -610,8 +608,8 @@ ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, bool browse_
 
        AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer );
 
-       GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) );
-       DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
+       auto row = DialogRow_new( name, ui::Widget(GTK_WIDGET( pathEntry.m_frame )) );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row );
 
        return ui::Widget(GTK_WIDGET( row ));
 }
@@ -623,7 +621,7 @@ ui::Widget Dialog::addPathEntry( ui::Widget vbox, const char* name, CopiedString
 ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
        DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
        AddIntSpinnerData( *row.m_spin, importViewer, exportViewer );
-       DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
        return ui::SpinButton(row.m_spin);
 }
 
@@ -634,6 +632,6 @@ ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, int& data,
 ui::SpinButton Dialog::addSpinner( ui::Widget vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
        DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
        AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer );
-       DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
+       DialogVBox_packRow( ui::VBox(GTK_VBOX( vbox )), row.m_row );
        return ui::SpinButton(row.m_spin);
 }