]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/dialog.cpp
Callback: remove fixed-arity wrappers
[xonotic/netradiant.git] / radiant / dialog.cpp
index 2a6e4138fe548c639f4f93efd34d432d3859b31e..bb8705f2446191bbf78b4a431c9bf6586d471938 100644 (file)
@@ -50,7 +50,7 @@
 ui::Entry DialogEntry_new(){
        auto entry = ui::Entry(ui::New);
        entry.show();
-       gtk_widget_set_size_request( entry , 64, -1 );
+       entry.dimensions(64, -1);
        return entry;
 }
 
@@ -83,14 +83,14 @@ ui::SpinButton DialogSpinner_new( double value, double lower, double upper, int
        }
        auto spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
        spin.show();
-       gtk_widget_set_size_request( spin , 64, -1 );
+       spin.dimensions(64, -1);
        return spin;
 }
 
 class DialogSpinnerRow
 {
 public:
-DialogSpinnerRow( ui::Widget row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){
+DialogSpinnerRow( ui::Widget row, ui::SpinButton spin ) : m_row( row ), m_spin( spin ){
 }
 ui::Widget m_row;
 ui::SpinButton m_spin;
@@ -112,7 +112,7 @@ template<
        typename Type_,
        typename Other_,
        void( *Import ) ( Type_&, Other_ ),
-       void( *Export ) ( Type_&, const Callback1<Other_>& )
+       void( *Export ) ( Type_&, const Callback<void(Other_)>& )
        >
 class ImportExport
 {
@@ -120,8 +120,8 @@ public:
 typedef Type_ Type;
 typedef Other_ Other;
 
-typedef ReferenceCaller1<Type, Other, Import> ImportCaller;
-typedef ReferenceCaller1<Type, const Callback1<Other>&, Export> ExportCaller;
+typedef ReferenceCaller<Type, void(Other), Import> ImportCaller;
+typedef ReferenceCaller<Type, void(const Callback<void(Other)>&), Export> ExportCaller;
 };
 
 typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
@@ -229,8 +229,8 @@ template<typename FirstArgument>
 class CallbackDialogData : public DLG_DATA
 {
 public:
-typedef Callback1<FirstArgument> ImportCallback;
-typedef Callback1<const ImportCallback&> ExportCallback;
+typedef Callback<void(FirstArgument)> ImportCallback;
+typedef Callback<void(const ImportCallback&)> ExportCallback;
 
 private:
 ImportCallback m_importWidget;
@@ -281,8 +281,8 @@ AddCustomData( DialogDataList& data ) : m_data( data ){
 }
 void apply(
        typename Widget::Type& widget,
-       const Callback1<typename Widget::Other>& importViewer,
-       const Callback1<const Callback1<typename Widget::Other>&>& exportViewer
+       const Callback<void(typename Widget::Other)>& importViewer,
+       const Callback<void(const Callback<void(typename Widget::Other)>&)>& exportViewer
        ) const {
        m_data.push_back(
                new CallbackDialogData<typename Widget::Other>(
@@ -548,11 +548,11 @@ void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRa
 }
 
 void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
-       ui::Widget table = ui::Table( 2, icons.last - icons.first, FALSE );
-       table.show();;
+    auto table = ui::Table(2, icons.last - icons.first, FALSE);
+    table.show();
 
-       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);
 
        GSList* group = 0;
        ui::RadioButton radio{ui::null};
@@ -561,15 +561,11 @@ void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange ic
                guint pos = static_cast<guint>( icon - icons.first );
                auto image = new_local_image( *icon );
                image.show();
-               gtk_table_attach( GTK_TABLE( table ), image , pos, pos + 1, 0, 1,
-                                                 (GtkAttachOptions) ( 0 ),
-                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+        table.attach(image, {pos, pos + 1, 0, 1}, {0, 0});
 
                radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group )));
                radio.show();
-               gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2,
-                                                 (GtkAttachOptions) ( 0 ),
-                                                 (GtkAttachOptions) ( 0 ), 0, 0 );
+        table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0});
 
                group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
        }