]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/dialog.cpp
h2data: do not redefine if unused
[xonotic/netradiant.git] / radiant / dialog.cpp
index e32f81c8528aa2e22a1eb7f2d63ccbb7d10854cc..66f2d998a31cc2993816d6402d77f5d9c37d9719 100644 (file)
@@ -256,24 +256,28 @@ public:
        }
 };
 
+template<class Widget, class Self, class T, class native>
+struct AddDataCustom_Wrapper {
+    static void Export(const native &self, const Callback<void(T)> &returnz) {
+        native *p = &const_cast<native &>(self);
+        auto widget = Self::from(p);
+        Widget::Get::thunk_(widget, returnz);
+    }
+
+    static void Import(native &self, T value) {
+        native *p = &self;
+        auto widget = Self::from(p);
+        Widget::Set::thunk_(widget, value);
+    }
+};
+
 template<class Widget>
 void AddDataCustom(DialogDataList &self, typename Widget::Type widget, Property<typename Widget::Other> const &property) {
     using Self = typename Widget::Type;
     using T = typename Widget::Other;
     using native = typename std::remove_pointer<typename Self::native>::type;
-    struct Wrapper {
-        static void Export(const native &self, const Callback<void(T)> &returnz) {
-                       native *p = &const_cast<native &>(self);
-                       auto widget = Self(p);
-                       Widget::Get::thunk_(widget, returnz);
-        }
-
-        static void Import(native &self, T value) {
-                       native *p = &self;
-                       auto widget = Self(p);
-                       Widget::Set::thunk_(widget, value);
-        }
-    };
+    using Wrapper = AddDataCustom_Wrapper<Widget, Self, T, native>;
+    
     self.push_back(new CallbackDialogData<typename Widget::Other>(
             make_property<PropertyAdaptor<native, T, Wrapper>>(*static_cast<native *>(widget)),
             property
@@ -288,7 +292,7 @@ void AddData(DialogDataList &self, typename Widget::Type widget, D &data) {
 // =============================================================================
 // Dialog class
 
-Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
+Dialog::Dialog() : m_window( ui::null ), m_parent( ui::null ){
 }
 
 Dialog::~Dialog(){
@@ -553,7 +557,7 @@ void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange ic
                image.show();
         table.attach(image, {pos, pos + 1, 0, 1}, {0, 0});
 
-               radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group )));
+               radio = ui::RadioButton::from(gtk_radio_button_new( group ));
                radio.show();
         table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0});