node_free ((Node *)the_type);
}
+static char *
+get_prop_enum_flag_cast (Property *prop)
+{
+ char *tmp, *ret;
+ if (prop->extra_gtktype == NULL ||
+ /* HACK! just in case someone made this
+ * work with 2.0.0 by using the TYPE
+ * macro directly */
+ ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
+ strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
+ strchr (prop->extra_gtktype, ':') == NULL)) {
+ if (prop->ptype != NULL)
+ return get_type (prop->ptype, TRUE);
+ else
+ return g_strdup ("");
+ }
+ tmp = remove_sep (prop->extra_gtktype);
+ ret = g_strdup_printf ("(%s) ", tmp);
+ g_free (tmp);
+ return ret;
+}
+
static void
property_link_and_export (Node *node)
{
get = g_strdup_printf("g_value_set_string (VAL, %s->%s);",
root, prop->name);
} else if (strcmp (prop->gtktype, "OBJECT") == 0) {
- set = g_strdup_printf("{ GtkObject *___old = (GtkObject *)%s->%s; "
- "GtkObject *___new = (GtkObject *)gtk_value_get_object (VAL); "
- "if (___new != NULL) { "
- "gtk_object_ref (GTK_OBJECT (___new)); "
- "%s->%s = GTK_OBJECT (___new); "
- "} else { "
- "%s->%s = NULL; "
- "} "
+ char *cast;
+ if (prop->extra_gtktype != NULL) {
+ cast = remove_sep (prop->extra_gtktype);
+ } else {
+ cast = "void";
+ }
+ set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; "
+ "%s->%s = (%s *)g_value_dup_object (VAL); "
"if (___old != NULL) { "
- "gtk_object_unref (GTK_OBJECT (___old)); "
+ "g_object_unref (G_OBJECT (___old)); "
"} "
"}",
root, prop->name,
root, prop->name,
- root, prop->name);
- get = g_strdup_printf("g_value_set_object (VAL, %s->%s);",
- root, prop->name);
+ cast);
+ get = g_strdup_printf ("g_value_set_object (VAL, "
+ "(gpointer)%s->%s);",
+ root, prop->name);
+ g_free (cast);
} else if (strcmp (prop->gtktype, "BOXED") == 0) {
if (prop->extra_gtktype == NULL) {
error_print (GOB_ERROR, prop->line_no,
"boxed_type not set"));
}
set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; "
- "gpointer ___new = (gpointer)gtk_value_get_boxed (VAL); "
+ "gpointer ___new = (gpointer)g_value_get_boxed (VAL); "
"if (___new != ___old) { "
"if (___old != NULL) g_boxed_free (%s, ___old); "
"if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); "
} else {
char *set_func;
char *get_func;
+ const char *getcast = "";
+ const char *setcast = "";
+ char *to_free = NULL;
set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype);
g_strdown (set_func);
get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype);
g_strdown (get_func);
- set = g_strdup_printf("%s->%s = %s (VAL);",
+ if (strcmp (prop->gtktype, "FLAGS") == 0) {
+ setcast = "(guint) ";
+ getcast = to_free =
+ get_prop_enum_flag_cast (prop);
+ } else if (strcmp (prop->gtktype, "ENUM") == 0) {
+ setcast = "(gint) ";
+ getcast = to_free =
+ get_prop_enum_flag_cast (prop);
+ }
+
+ set = g_strdup_printf("%s->%s = %s%s (VAL);",
root, prop->name,
+ getcast,
get_func);
- get = g_strdup_printf("%s (VAL, %s->%s);",
+ get = g_strdup_printf("%s (VAL, %s%s->%s);",
set_func,
+ setcast,
root, prop->name);
g_free (get_func);
g_free (set_func);
+ g_free (to_free);
}
node_set (node,
"ptype:steal", type,
NULL);
}
+ | FLAGS_TYPE '=' TYPETOKEN {
+ ensure_property ();
+ node_set ((Node *)property,
+ "extra_gtktype:steal", $<id>3,
+ NULL);
+ }
| FLAGS_TYPE '=' TOKEN {
ensure_property ();
node_set ((Node *)property,
"extra_gtktype:steal", $<id>3,
NULL);
}
+ | ENUM_TYPE '=' TYPETOKEN {
+ ensure_property ();
+ node_set ((Node *)property,
+ "extra_gtktype:steal", $<id>3,
+ NULL);
+ }
| ENUM_TYPE '=' TOKEN {
ensure_property ();
node_set ((Node *)property,
"extra_gtktype:steal", $<id>3,
NULL);
}
+ | PARAM_TYPE '=' TYPETOKEN {
+ ensure_property ();
+ node_set ((Node *)property,
+ "extra_gtktype:steal", $<id>3,
+ NULL);
+ }
| PARAM_TYPE '=' TOKEN {
ensure_property ();
node_set ((Node *)property,
"extra_gtktype:steal", $<id>3,
NULL);
}
+ | BOXED_TYPE '=' TYPETOKEN {
+ ensure_property ();
+ node_set ((Node *)property,
+ "extra_gtktype:steal", $<id>3,
+ NULL);
+ }
| BOXED_TYPE '=' TOKEN {
ensure_property ();
node_set ((Node *)property,
"extra_gtktype:steal", $<id>3,
NULL);
}
+ | OBJECT_TYPE '=' TYPETOKEN {
+ ensure_property ();
+ node_set ((Node *)property,
+ "extra_gtktype:steal", $<id>3,
+ NULL);
+ }
| OBJECT_TYPE '=' TOKEN {
ensure_property ();
node_set ((Node *)property,