Re: Getting GValue* from Glib::Value

Thanks, Kjell. I missed that gobj() returns a pointer to gobject_.
However, the returned type is not a pure C gtype. Let me illustrate
this by example:

  Glib::Value<Glib::DateTime> data;


  const GValue *val = data.gobj();
  std::cout << "val type is " << G_VALUE_TYPE_NAME(val) << std::endl;

  GValue *val2 = g_new0(GValue, 1);
  g_value_init(val2, G_TYPE_DATE_TIME);
  std::cout << "val2 type is " << G_VALUE_TYPE_NAME(val2) << std::endl;

In stdout I see

val type is glibmm__CustomBoxed_N4Glib8DateTimeE
val2 type is GDateTime

I know that GDateTime is a boxed type and Glib::Value registers it own
type. If I use built-in type, e.g. int, I see the same type for C++ and
C parts. Basically, my question should be refined and tailed to the
conversion of C++ gtype (boxed equivalent) to the C-like gtype. 


On Tue, 2019-04-23 at 10:46 +0200, Kjell Ahlstedt wrote:
What's wrong with Glib::ValueBase::gobj()? It returns a pointer to
gobject_. What else do you want? How should your proposed
Glib::ValueBase::get_gvalue() differ from Glib::ValueBase::gobj()?
On 2019-04-23 06:14, Pavlo Solntsev via gtkmm-list wrote:

I have 

Glib::Value<Foo> data;

How can I get pure C GValue*? I need it to use with the C API.
data.gobj() returns C++ based type, which is not acceptable by C
see protected gobject_ in the base class. Does it make sense to
have an
API, e.g.  const GValue* Glib::ValueBase::get_gvalue() to fetch
thepointer for underlying GValue? 

Any other suggestion? 

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