Re: [gtkmm] Gtk::TreeView and float



On  0, Murray Cumming <murrayc usa net> wrote:
> I think that's already in gtkmm 2.4 in cvs. Actually, it might really be
> OK to add it to gtkmm 2.2.

I want to be compatible to the Debian packages and I can't patch and recompile them!

So I tried to write a simple workarround (the code isn't very nice and fast! Was just
a fast "hack")

template <typename T>
class workarround {
  gchar *array;
  std::size_t s;
public:
  workarround() : array(NULL) { }
  workarround(T obj) : array(NULL) { value(obj); }
  workarround(const Glib::ustring &p)
    : s(p.length()+1)
  {
    array=new gchar[s];
    std::memcpy(array,p.c_str(),s);
  }
  ~workarround() { delete []array; }
  workarround(const workarround &obj) : array(new gchar[obj.s]),s(obj.s)
  { std::memcpy(array,obj.array,s); }
  workarround &operator=(const workarround &obj) {
    if(&obj!=this) {
      delete []array;
      s=obj.s;
      array=new gchar[s];
      std::memcpy(array,obj.array,s);
    }
    return *this;
  }
  void value(T obj) {
    std::stringstream sstr;
    sstr << obj;
    delete []array;
    s=sstr.str().length()+1;
    array=new gchar[s];
    std::memcpy(array,sstr.str().c_str(),s);
  }
  T value() const {
    std::stringstream sstr(array);
    T obj;
    sstr >> obj;
    return obj;
  }
  operator gchar*() { return array; }
};

the code compiles without any warning but if I try to run the program
it prints the following messages and nothing is displayed in the column!

(a.out:612): GLib-GObject-WARNING **: unable to set property `text' of type `gchararray' from value of type `glibmm__CustomBoxed_11workarroundIfE'

regards,
Ruediger Sonderfeld <cplusplushelp gmx net>



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