I am trying to set the \"ellipsize\" enum property on a GtkCellRendererText object.
I am trying to use g_object_set_property
as follows:
Gtk
Using g_object_set
instead works:
g_object_set (G_OBJECT(renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
You need to initialise the GValue
container with the type of the enumeration that the property expects. G_TYPE_ENUM
is the generic, abstract enumeration type.
The "ellipsize" property of GtkCellRendererText
expects a PangoEllipsizeMode
enumeration value, which has a GType of PANGO_TYPE_ELLIPSIZE_MODE
.
GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GValue val = G_VALUE_INIT;
g_value_init (&val, PANGO_TYPE_ELLIPSIZE_MODE);
g_value_set_enum (&val, PANGO_ELLIPSIZE_END);
g_object_set_property (G_OBJECT(renderer), "ellipsize", &val);
// Always unset your value to release any memory that may be associated with it
g_value_unset (&val);