[gtkmm] ScaleButton: Correct the constructor.



commit 26f94d231da9481d74acdd94e56168ed6b38609a
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Dec 7 19:51:27 2014 +0100

    ScaleButton: Correct the constructor.
    
    gtk_scale_button_new() does more than just call g_object_new() so
    we cannot just assume that the parameters correspond to
    GObject property names.
    This has apparently been wrong from the start, many years ago.
    Probably few people, if any, need to use this.

 gtk/src/scalebutton.ccg |    8 ++++++++
 gtk/src/scalebutton.hg  |    6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/src/scalebutton.ccg b/gtk/src/scalebutton.ccg
index 51c0aaa..1dd6d0d 100644
--- a/gtk/src/scalebutton.ccg
+++ b/gtk/src/scalebutton.ccg
@@ -23,5 +23,13 @@
 namespace Gtk
 {
 
+ScaleButton::ScaleButton(IconSize size, double min, double max, double step, const 
std::vector<Glib::ustring>& icons)
+:
+  _CONSTRUCT("size", static_cast<GtkIconSize>(int(size)), "icons", 
Glib::ArrayHandler<Glib::ustring>::vector_to_array(icons).data(), static_cast<char*>(0))
+{
+  Glib::RefPtr<Adjustment> adjustment = Adjustment::create(min, min, max, step, 10 * step, 0);
+  set_adjustment(adjustment);
+}
+
 } // namespace Gtk
 
diff --git a/gtk/src/scalebutton.hg b/gtk/src/scalebutton.hg
index 7f1f6b4..5516cc1 100644
--- a/gtk/src/scalebutton.hg
+++ b/gtk/src/scalebutton.hg
@@ -47,9 +47,11 @@ class ScaleButton
   _IMPLEMENTS_INTERFACE(Orientable)
 
 public:
-#m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const 
gchar**',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ()')
-  _WRAP_CTOR(ScaleButton(IconSize size, double min, double max, double step, const 
std::vector<Glib::ustring>& icons), gtk_scale_button_new)
+  //We custom-implement the constructor because gtk_scale_button_new() does more than just call 
g_object_new():
+  explicit ScaleButton(IconSize size, double min, double max, double step, const std::vector<Glib::ustring>& 
icons);
+  _IGNORE(gtk_scale_button_new)
 
+#m4 _CONVERSION(`const std::vector<Glib::ustring>&',`const 
gchar**',`Glib::ArrayHandler<Glib::ustring>::vector_to_array($3).data ()')
   _WRAP_METHOD(void set_icons(const std::vector<Glib::ustring>& icons), gtk_scale_button_set_icons)
   _WRAP_METHOD(double get_value() const, gtk_scale_button_get_value)
   _WRAP_METHOD(void set_value(double value), gtk_scale_button_set_value)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]