Installed unwanted garbage to pass distcheck.

* src/Makefile.am, widgets/Makefile.am: Installed unwanted garbage
	  to pass distcheck.

	* src/glade-devhelp.c: Navigational buttons insensitive at startup.

	* src/glade-catalog.c: Unexposed a private function.

	* src/glade-xml-utils.c: made alloc_string glade_xml_alloc_string,
	  alloc_propname: ditto.

	* src/glade-property.c, src/glade-signal.c:
	  Adjustemtnts made for glade-xml api above

	* src/glade-widget.c:
	  o Adjustemtnts made for glade-xml api above
	  o Properties applied to new objects in two steps now,
	    code around build_object cleaned up... now build_object
	    used also in load code.
This commit is contained in:
Tristan Van Berkom 2006-05-22 20:54:54 +00:00
parent adc5b5594e
commit fbb818c1ba
15 changed files with 364 additions and 260 deletions

View File

@ -1,3 +1,24 @@
2006-05-22 Tristan Van Berkom <tvb@gnome.org>
* src/Makefile.am, widgets/Makefile.am: Installed unwanted garbage
to pass distcheck.
* src/glade-devhelp.c: Navigational buttons insensitive at startup.
* src/glade-catalog.c: Unexposed a private function.
* src/glade-xml-utils.c: made alloc_string glade_xml_alloc_string,
alloc_propname: ditto.
* src/glade-property.c, src/glade-signal.c:
Adjustemtnts made for glade-xml api above
* src/glade-widget.c:
o Adjustemtnts made for glade-xml api above
o Properties applied to new objects in two steps now,
code around build_object cleaned up... now build_object
used also in load code.
2006-05-18 Tristan Van Berkom <tvb@gnome.org> 2006-05-18 Tristan Van Berkom <tvb@gnome.org>
* src/glade.h, src/glade-catalog.c, src/glade-widget-class.[ch]: * src/glade.h, src/glade-catalog.c, src/glade-widget-class.[ch]:

View File

@ -27,6 +27,7 @@ classes; it also provides an abstraction later to container apis.
@type: @type:
@name: @name:
@catalog: @catalog:
@book:
@icon: @icon:
@generic_name: @generic_name:
@palette_name: @palette_name:
@ -145,6 +146,7 @@ classes; it also provides an abstraction later to container apis.
@catname: @catname:
@library: @library:
@domain: @domain:
@book:
@Returns: @Returns:

View File

@ -38,9 +38,11 @@ libgladegtk_la_CFLAGS = \
-I$(top_builddir) \ -I$(top_builddir) \
$(GTK_CFLAGS) $(GTK_CFLAGS)
libgladegtk_la_SOURCES = glade-gtk.c libgladegtk_la_SOURCES = glade-gtk.c
libgladegtk_la_LDFLAGS = -module -avoid-version libgladegtk_la_LDFLAGS = -module -avoid-version
libgladegtk_la_LIBADD = libgladeui-1.la $(GTK_LIBS) libgladegtk_la_LIBADD = libgladeui-1.la $(GTK_LIBS)
libgladegtkincludedir = $(includedir)/libgladeui-1.0/libgladeui
libgladegtkinclude_HEADERS = glade-gtk.h
# The Devhelp plugin # The Devhelp plugin
@ -55,9 +57,11 @@ libgladedevhelp_la_CFLAGS = \
-I$(top_builddir) \ -I$(top_builddir) \
$(DEVHELP_CFLAGS) $(DEVHELP_CFLAGS)
libgladedevhelp_la_SOURCES = glade-devhelp.c libgladedevhelp_la_SOURCES = glade-devhelp.c
libgladedevhelp_la_LDFLAGS = -module -avoid-version libgladedevhelp_la_LDFLAGS = -module -avoid-version
libgladedevhelp_la_LIBADD = $(DEVHELP_LIBS) libgladedevhelp_la_LIBADD = $(DEVHELP_LIBS)
libgladedevhelpincludedir = $(includedir)/libgladeui-1.0/libgladeui
libgladedevhelpinclude_HEADERS = glade-devhelp.h
endif endif

View File

@ -83,7 +83,7 @@ static gboolean catalog_load_classes (GladeCatalog *catalog,
static gboolean catalog_load_group (GladeCatalog *catalog, static gboolean catalog_load_group (GladeCatalog *catalog,
GladeXmlNode *group_node); GladeXmlNode *group_node);
void widget_group_free (GladeWidgetGroup *group); static void widget_group_free (GladeWidgetGroup *group);
/* List of catalog names successfully loaded. /* List of catalog names successfully loaded.
*/ */
@ -370,7 +370,7 @@ catalog_load_group (GladeCatalog *catalog, GladeXmlNode *group_node)
return TRUE; return TRUE;
} }
void static void
widget_group_free (GladeWidgetGroup *group) widget_group_free (GladeWidgetGroup *group)
{ {
g_return_if_fail (group != NULL); g_return_if_fail (group != NULL);

View File

@ -246,6 +246,9 @@ widget_create_nav_button (NavButtonType type)
gtk_widget_show_all (align); gtk_widget_show_all (align);
if (type == NAV_FORWARD || type == NAV_BACK)
gtk_widget_set_sensitive (button, FALSE);
gtk_container_add (GTK_CONTAINER (button), align); gtk_container_add (GTK_CONTAINER (button), align);
return button; return button;

View File

@ -125,9 +125,9 @@ create_widget_info(GladeInterface *interface, const xmlChar **attrs)
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("class"))) if (!xmlStrcmp(attrs[i], BAD_CAST("class")))
info->classname = alloc_string (interface, CAST_BAD(attrs[i+1])); info->classname = glade_xml_alloc_string (interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("id"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("id")))
info->name = alloc_string (interface, CAST_BAD(attrs[i+1])); info->name = glade_xml_alloc_string (interface, CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <widget>.", attrs[i]); g_warning("unknown attribute `%s' for <widget>.", attrs[i]);
} }
@ -233,9 +233,9 @@ handle_atk_action(GladeParseState *state, const xmlChar **attrs)
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("action_name"))) if (!xmlStrcmp(attrs[i], BAD_CAST("action_name")))
info.action_name = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.action_name = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("description"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("description")))
info.description = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.description = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <action>.", attrs[i]); g_warning("unknown attribute `%s' for <action>.", attrs[i]);
} }
@ -259,9 +259,9 @@ handle_atk_relation(GladeParseState *state, const xmlChar **attrs)
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("target"))) if (!xmlStrcmp(attrs[i], BAD_CAST("target")))
info.target = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.target = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("type"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("type")))
info.type = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.type = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <signal>.", attrs[i]); g_warning("unknown attribute `%s' for <signal>.", attrs[i]);
} }
@ -286,15 +286,15 @@ handle_signal(GladeParseState *state, const xmlChar **attrs)
info.after = FALSE; info.after = FALSE;
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("name"))) if (!xmlStrcmp(attrs[i], BAD_CAST("name")))
info.name = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.name = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("handler"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("handler")))
info.handler = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.handler = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("after"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("after")))
info.after = attrs[i+1][0] == 'y'; info.after = attrs[i+1][0] == 'y';
else if (!xmlStrcmp(attrs[i], BAD_CAST("lookup"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("lookup")))
info.lookup = attrs[i+1][0] == 'y'; info.lookup = attrs[i+1][0] == 'y';
else if (!xmlStrcmp(attrs[i], BAD_CAST("object"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("object")))
info.object = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.object = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("last_modification_time"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("last_modification_time")))
/* Do nothing. */; /* Do nothing. */;
else else
@ -378,7 +378,7 @@ handle_accel(GladeParseState *state, const xmlChar **attrs)
} else } else
pos++; pos++;
} else if (!xmlStrcmp(attrs[i], BAD_CAST("signal"))) } else if (!xmlStrcmp(attrs[i], BAD_CAST("signal")))
info.signal = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info.signal = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <accelerator>.", attrs[i]); g_warning("unknown attribute `%s' for <accelerator>.", attrs[i]);
} }
@ -416,7 +416,7 @@ handle_child(GladeParseState *state, const xmlChar **attrs)
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("internal-child"))) if (!xmlStrcmp(attrs[i], BAD_CAST("internal-child")))
info->internal_child = alloc_string(state->interface, CAST_BAD(attrs[i+1])); info->internal_child = glade_xml_alloc_string(state->interface, CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <child>.", attrs[i]); g_warning("unknown attribute `%s' for <child>.", attrs[i]);
} }
@ -499,7 +499,7 @@ glade_parser_start_element(GladeParseState *state,
iface->requires = g_renew(gchar *, iface->requires, iface->requires = g_renew(gchar *, iface->requires,
iface->n_requires); iface->n_requires);
iface->requires[iface->n_requires-1] = iface->requires[iface->n_requires-1] =
alloc_string(iface, CAST_BAD(attrs[i+1])); glade_xml_alloc_string(iface, CAST_BAD(attrs[i+1]));
} else } else
g_warning("unknown attribute `%s' for <requires>.", g_warning("unknown attribute `%s' for <requires>.",
attrs[i]); attrs[i]);
@ -547,14 +547,14 @@ glade_parser_start_element(GladeParseState *state,
state->translate_prop = FALSE; state->translate_prop = FALSE;
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("name"))) if (!xmlStrcmp(attrs[i], BAD_CAST("name")))
state->prop_name = alloc_propname(state->interface, state->prop_name = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable")))
state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("context"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("context")))
state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("comments"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("comments")))
state->comment = alloc_propname(state->interface, state->comment = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("agent"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("agent")))
bad_agent = xmlStrcmp(attrs[i], BAD_CAST("libglade")) != 0; bad_agent = xmlStrcmp(attrs[i], BAD_CAST("libglade")) != 0;
@ -608,14 +608,14 @@ glade_parser_start_element(GladeParseState *state,
state->translate_prop = FALSE; state->translate_prop = FALSE;
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("name"))) if (!xmlStrcmp(attrs[i], BAD_CAST("name")))
state->prop_name = alloc_propname(state->interface, state->prop_name = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable")))
state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("context"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("context")))
state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("comments"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("comments")))
state->comment = alloc_propname(state->interface, state->comment = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else else
g_warning("unknown attribute `%s' for <atkproperty>.", g_warning("unknown attribute `%s' for <atkproperty>.",
@ -764,14 +764,14 @@ glade_parser_start_element(GladeParseState *state,
state->translate_prop = FALSE; state->translate_prop = FALSE;
for (i = 0; attrs && attrs[i] != NULL; i += 2) { for (i = 0; attrs && attrs[i] != NULL; i += 2) {
if (!xmlStrcmp(attrs[i], BAD_CAST("name"))) if (!xmlStrcmp(attrs[i], BAD_CAST("name")))
state->prop_name = alloc_propname(state->interface, state->prop_name = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("translatable")))
state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->translate_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("context"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("context")))
state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes")); state->context_prop = !xmlStrcmp(attrs[i+1], BAD_CAST("yes"));
else if (!xmlStrcmp(attrs[i], BAD_CAST("comments"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("comments")))
state->comment = alloc_propname(state->interface, state->comment = glade_xml_alloc_propname(state->interface,
CAST_BAD(attrs[i+1])); CAST_BAD(attrs[i+1]));
else if (!xmlStrcmp(attrs[i], BAD_CAST("agent"))) else if (!xmlStrcmp(attrs[i], BAD_CAST("agent")))
bad_agent = xmlStrcmp(attrs[i], BAD_CAST("libglade")) != 0; bad_agent = xmlStrcmp(attrs[i], BAD_CAST("libglade")) != 0;
@ -890,7 +890,7 @@ glade_parser_end_element(GladeParseState *state, const xmlChar *name)
prop.has_context = state->context_prop; prop.has_context = state->context_prop;
prop.translatable = state->translate_prop; prop.translatable = state->translate_prop;
prop.comment = state->comment; prop.comment = state->comment;
prop.value = alloc_string(state->interface, state->content->str); prop.value = glade_xml_alloc_string(state->interface, state->content->str);
g_array_append_val(state->props, prop); g_array_append_val(state->props, prop);
state->prop_name = NULL; state->prop_name = NULL;
@ -912,7 +912,7 @@ glade_parser_end_element(GladeParseState *state, const xmlChar *name)
prop.has_context = state->context_prop; prop.has_context = state->context_prop;
prop.translatable = state->translate_prop; prop.translatable = state->translate_prop;
prop.comment = state->comment; prop.comment = state->comment;
prop.value = alloc_string(state->interface, state->content->str); prop.value = glade_xml_alloc_string(state->interface, state->content->str);
g_array_append_val(state->props, prop); g_array_append_val(state->props, prop);
state->prop_name = NULL; state->prop_name = NULL;
@ -976,7 +976,7 @@ glade_parser_end_element(GladeParseState *state, const xmlChar *name)
prop.has_context = state->context_prop; prop.has_context = state->context_prop;
prop.translatable = state->translate_prop; prop.translatable = state->translate_prop;
prop.comment = state->comment; prop.comment = state->comment;
prop.value = alloc_string(state->interface, state->content->str); prop.value = glade_xml_alloc_string(state->interface, state->content->str);
g_array_append_val(state->props, prop); g_array_append_val(state->props, prop);
state->prop_name = NULL; state->prop_name = NULL;

View File

@ -1600,5 +1600,6 @@ glade_property_class_void_value (GladePropertyClass *class,
else if (G_IS_PARAM_SPEC_BOXED (class->pspec) && else if (G_IS_PARAM_SPEC_BOXED (class->pspec) &&
g_value_get_boxed (value) == NULL) g_value_get_boxed (value) == NULL)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@ -102,15 +102,30 @@ glade_property_reset_impl (GladeProperty *property)
gboolean gboolean
glade_property_default_impl (GladeProperty *property) glade_property_default_impl (GladeProperty *property)
{ {
return !g_param_values_cmp (property->class->pspec, return GLADE_PROPERTY_GET_KLASS (property)->equals_value
property->value, (property, property->class->def);
property->class->def);
} }
gboolean gboolean
glade_property_equals_value_impl (GladeProperty *property, glade_property_equals_value_impl (GladeProperty *property,
const GValue *value) const GValue *value)
{ {
if (G_IS_PARAM_SPEC_STRING (property->class->pspec))
{
gchar *prop_str, *value_str;
/* in string specs; NULL and '\0' are
* treated as equivalent.
*/
prop_str = g_value_get_string (property->value);
value_str = g_value_get_string (value);
if (prop_str == NULL && value_str && value_str[0] == '\0')
return TRUE;
else if (value_str == NULL && prop_str && prop_str[0] == '\0')
return TRUE;
}
return !g_param_values_cmp (property->class->pspec, return !g_param_values_cmp (property->class->pspec,
property->value, value); property->value, value);
} }
@ -392,13 +407,12 @@ glade_property_write_impl (GladeProperty *property,
} }
/* convert the value of this property to a string */ /* convert the value of this property to a string */
/* XXX Is this right to return here ??? */
if ((value = glade_property_class_make_string_from_gvalue if ((value = glade_property_class_make_string_from_gvalue
(property->class, property->value)) == NULL) (property->class, property->value)) == NULL)
{ /* make sure we keep the empty string, also... upcomming
g_free (name); * funcs that may not like NULL.
return FALSE; */
} value = g_strdup ("");
switch (property->class->atk_type) switch (property->class->atk_type)
{ {
@ -408,15 +422,15 @@ glade_property_write_impl (GladeProperty *property,
name = tmp; name = tmp;
/* Dont break here ... */ /* Dont break here ... */
case GPC_ATK_NONE: case GPC_ATK_NONE:
info.name = alloc_propname(interface, name); info.name = glade_xml_alloc_propname(interface, name);
info.value = alloc_string(interface, value); info.value = glade_xml_alloc_string(interface, value);
if (property->class->translatable) if (property->class->translatable)
{ {
info.translatable = property->i18n_translatable; info.translatable = property->i18n_translatable;
info.has_context = property->i18n_has_context; info.has_context = property->i18n_has_context;
if (property->i18n_comment) if (property->i18n_comment)
info.comment = alloc_string info.comment = glade_xml_alloc_string
(interface, property->i18n_comment); (interface, property->i18n_comment);
} }
g_array_append_val (props, info); g_array_append_val (props, info);
@ -427,16 +441,16 @@ glade_property_write_impl (GladeProperty *property,
for (i = 0; split[i] != NULL; i++) for (i = 0; split[i] != NULL; i++)
{ {
GladeAtkRelationInfo rinfo = { 0, }; GladeAtkRelationInfo rinfo = { 0, };
rinfo.type = alloc_string(interface, name); rinfo.type = glade_xml_alloc_string(interface, name);
rinfo.target = alloc_string(interface, split[i]); rinfo.target = glade_xml_alloc_string(interface, split[i]);
g_array_append_val (props, rinfo); g_array_append_val (props, rinfo);
} }
g_strfreev (split); g_strfreev (split);
} }
break; break;
case GPC_ATK_ACTION: case GPC_ATK_ACTION:
ainfo.action_name = alloc_string(interface, name); ainfo.action_name = glade_xml_alloc_string(interface, name);
ainfo.description = alloc_string(interface, value); ainfo.description = glade_xml_alloc_string(interface, value);
g_array_append_val (props, ainfo); g_array_append_val (props, ainfo);
break; break;
default: default:
@ -901,6 +915,8 @@ glade_property_read_atk_action (GladeProperty *property,
if (!strcmp (id, class_id)) if (!strcmp (id, class_id))
{ {
/* Need special case for NULL values here ??? */
gvalue = glade_property_class_make_gvalue_from_string gvalue = glade_property_class_make_gvalue_from_string
(pclass, ainfo->description, project); (pclass, ainfo->description, project);

View File

@ -127,11 +127,11 @@ gboolean
glade_signal_write (GladeSignalInfo *info, GladeSignal *signal, glade_signal_write (GladeSignalInfo *info, GladeSignal *signal,
GladeInterface *interface) GladeInterface *interface)
{ {
info->name = alloc_string(interface, signal->name); info->name = glade_xml_alloc_string(interface, signal->name);
info->handler = alloc_string(interface, signal->handler); info->handler = glade_xml_alloc_string(interface, signal->handler);
info->object = info->object =
signal->userdata ? signal->userdata ?
alloc_string(interface, signal->userdata) : NULL; glade_xml_alloc_string(interface, signal->userdata) : NULL;
info->after = signal->after; info->after = signal->after;
info->lookup = signal->lookup; info->lookup = signal->lookup;
return TRUE; return TRUE;

View File

@ -1186,6 +1186,90 @@ glade_widget_class_get_child_support (GladeWidgetClass *class,
} }
/**
* glade_widget_class_default_params:
* @class: a #GladeWidgetClass
* @construct: whether to return construct params or not construct params
* @n_params: return location if any defaults are specified for this class.
*
* Returns: A list of params for use in g_object_newv ()
*/
GParameter *
glade_widget_class_default_params (GladeWidgetClass *class,
gboolean construct,
guint *n_params)
{
GArray *params;
GObjectClass *oclass;
GParamSpec **pspec;
GladePropertyClass *pclass;
guint n_props, i;
g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL);
g_return_val_if_fail (n_params != NULL, NULL);
/* As a slight optimization, we never unref the class
*/
oclass = g_type_class_ref (class->type);
pspec = g_object_class_list_properties (oclass, &n_props);
params = g_array_new (FALSE, FALSE, sizeof (GParameter));
for (i = 0; i < n_props; i++)
{
GParameter parameter = { 0, };
pclass = glade_widget_class_get_property_class
(class, pspec[i]->name);
/* Ignore properties based on some criteria
*/
if (pclass == NULL || /* Unaccounted for in the builder */
pclass->set_function || /* should not be set before
GladeWidget wrapper exists */
pclass->ignore) /* Catalog explicitly ignores the object */
continue;
if (construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0)
continue;
else if (!construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0)
continue;
if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
pspec[i]->value_type) == FALSE)
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, class->name);
continue;
}
if (g_param_values_cmp (pspec[i],
pclass->def,
pclass->orig_def) == 0)
continue;
#if 0
if (glade_property_class_void_value (pclass, pclass->def))
continue;
#endif
parameter.name = pspec[i]->name; /* These are not copied/freed */
g_value_init (&parameter.value, pspec[i]->value_type);
g_value_copy (pclass->def, &parameter.value);
g_array_append_val (params, parameter);
}
g_free (pspec);
*n_params = params->len;
return (GParameter *)g_array_free (params, FALSE);
}
void void
glade_widget_class_container_add (GladeWidgetClass *class, glade_widget_class_container_add (GladeWidgetClass *class,
GObject *container, GObject *container,

View File

@ -285,7 +285,10 @@ GladePropertyClass *glade_widget_class_get_property_class (GladeWidgetClass *cl
LIBGLADEUI_API LIBGLADEUI_API
GladeSupportedChild *glade_widget_class_get_child_support (GladeWidgetClass *class, GladeSupportedChild *glade_widget_class_get_child_support (GladeWidgetClass *class,
GType child_type); GType child_type);
LIBGLADEUI_API
GParameter *glade_widget_class_default_params (GladeWidgetClass *class,
gboolean construct,
guint *n_params);
LIBGLADEUI_API LIBGLADEUI_API
void glade_widget_class_container_add (GladeWidgetClass *class, void glade_widget_class_container_add (GladeWidgetClass *class,
GObject *container, GObject *container,

View File

@ -540,28 +540,41 @@ glade_widget_dup_properties (GList *template_props)
return g_list_reverse (properties); return g_list_reverse (properties);
} }
/** static void
* glade_widget_build_object: glade_widget_params_free (GParameter *params, guint n_params)
* @klass: a #GladeWidgetClass
* @widget: a #GladeWidget
*
* This function creates a new GObject who's parameters are based
* on the GType of the GladeWidgetClass and its default values, if a
* GladeWidget is specified, it will be used to apply the values currently in use.
*
* Returns: A newly created GObject
*/
static GObject *
glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget)
{ {
gint i;
for (i = 0; i < n_params; i++)
g_value_unset (&(params[i].value));
g_free (params);
}
/*
* This function creates new GObject parameters based on the GType of the
* GladeWidgetClass and its default values.
*
* If a GladeWidget is specified, it will be used to apply the
* values currently in use.
*/
static GParameter *
glade_widget_template_params (GladeWidget *widget,
gboolean construct,
guint *n_params)
{
GladeWidgetClass *klass;
GArray *params; GArray *params;
GObjectClass *oclass; GObjectClass *oclass;
GParamSpec **pspec; GParamSpec **pspec;
GladeProperty *glade_property; GladeProperty *glade_property;
GladePropertyClass *glade_property_class; GladePropertyClass *pclass;
GObject *object;
guint n_props, i; guint n_props, i;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
g_return_val_if_fail (n_params != NULL, NULL);
klass = widget->widget_class;
/* As a slight optimization, we never unref the class /* As a slight optimization, we never unref the class
*/ */
oclass = g_type_class_ref (klass->type); oclass = g_type_class_ref (klass->type);
@ -572,85 +585,149 @@ glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget)
{ {
GParameter parameter = { 0, }; GParameter parameter = { 0, };
glade_property_class = glade_property = glade_widget_get_property (widget, pspec[i]->name);
glade_widget_class_get_property_class (klass, pclass = glade_property->class;
pspec[i]->name);
if (glade_property_class == NULL || /* Ignore properties based on some criteria
glade_property_class->set_function || */
glade_property_class->ignore) if (pclass == NULL || /* Unaccounted for in the builder */
/* Ignore properties that are not accounted for pclass->set_function || /* should not be set before
* by the GladeWidgetClass GladeWidget wrapper exists */
*/ pclass->ignore) /* Catalog explicitly ignores the object */
continue; continue;
parameter.name = pspec[i]->name; /* No need to dup this */ if (construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0)
continue;
else if (!construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0)
continue;
if (g_value_type_compatible (G_VALUE_TYPE (pclass->def),
pspec[i]->value_type) == FALSE)
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, klass->name);
continue;
}
if (g_param_values_cmp (pspec[i],
glade_property->value,
pclass->orig_def) == 0)
continue;
parameter.name = pspec[i]->name; /* These are not copied/freed */
g_value_init (&parameter.value, pspec[i]->value_type); g_value_init (&parameter.value, pspec[i]->value_type);
g_value_copy (glade_property->value, &parameter.value);
/* If a widget is specified and has a value set for that
* property, then that value will be used (otherwise, we
* use the default value)
*/
if (widget &&
(glade_property =
glade_widget_get_property (widget, parameter.name)) != NULL)
{
if (g_value_type_compatible (G_VALUE_TYPE (glade_property->value),
G_VALUE_TYPE (&parameter.value)))
g_value_copy (glade_property->value, &parameter.value);
else
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, klass->name);
continue;
}
}
/* If the class has a default, use it.
*/
else if (glade_property_class->def != NULL)
{
if (g_value_type_compatible (G_VALUE_TYPE (glade_property_class->def),
G_VALUE_TYPE (&parameter.value)))
{
if (glade_property_class_void_value
(glade_property_class,
glade_property_class->def))
continue;
#if 0
if (g_type_is_a (G_VALUE_TYPE (glade_property_class->def), G_TYPE_OBJECT))
if (g_value_get_object (glade_property_class->def) == NULL)
continue;
#endif
g_value_copy (glade_property_class->def, &parameter.value);
}
else
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, klass->name);
continue;
}
}
else
g_param_value_set_default (pspec[i], &parameter.value);
g_array_append_val (params, parameter); g_array_append_val (params, parameter);
} }
g_free (pspec); g_free (pspec);
*n_params = params->len;
return (GParameter *)g_array_free (params, FALSE);
}
static GParameter *
glade_widget_info_params (GladeWidgetClass *widget_class,
GladeWidgetInfo *info,
gboolean construct,
guint *n_params)
{
GladePropertyClass *glade_property_class;
GObjectClass *oclass;
GParamSpec **pspec;
GArray *params;
guint i, n_props;
oclass = g_type_class_ref (widget_class->type);
pspec = g_object_class_list_properties (oclass, &n_props);
params = g_array_new (FALSE, FALSE, sizeof (GParameter));
/* prepare parameters that have glade_property_class->def */
for (i = 0; i < n_props; i++)
{
GParameter parameter = { 0, };
GValue *value;
glade_property_class =
glade_widget_class_get_property_class (widget_class,
pspec[i]->name);
if (glade_property_class == NULL ||
glade_property_class->set_function ||
glade_property_class->ignore)
continue;
if (construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) == 0)
continue;
else if (!construct &&
(pspec[i]->flags &
(G_PARAM_CONSTRUCT|G_PARAM_CONSTRUCT_ONLY)) != 0)
continue;
/* Try filling parameter with value from widget info.
*/
if ((value = glade_property_read (NULL, glade_property_class,
loading_project, info, FALSE)) != NULL)
{
parameter.name = pspec[i]->name;
g_value_init (&parameter.value, pspec[i]->value_type);
g_value_copy (value, &parameter.value);
g_value_unset (value);
g_free (value);
g_array_append_val (params, parameter);
}
}
g_free(pspec);
g_type_class_unref (oclass);
*n_params = params->len;
return (GParameter *)g_array_free (params, FALSE);
}
static GObject *
glade_widget_build_object (GladeWidgetClass *klass, GladeWidget *widget, GladeWidgetInfo *info)
{
GParameter *params;
GObject *object;
guint n_params, i;
if (widget)
params = glade_widget_template_params (widget, TRUE, &n_params);
else if (info)
params = glade_widget_info_params (klass, info, TRUE, &n_params);
else
params = glade_widget_class_default_params (klass, TRUE, &n_params);
/* Create the new object with the correct parameters. /* Create the new object with the correct parameters.
*/ */
object = g_object_newv (klass->type, params->len, object = g_object_newv (klass->type, n_params, params);
(GParameter *)params->data);
/* Cleanup parameters glade_widget_params_free (params, n_params);
*/
for (i = 0; i < params->len; i++) if (widget)
params = glade_widget_template_params (widget, FALSE, &n_params);
else if (info)
params = glade_widget_info_params (klass, info, FALSE, &n_params);
else
params = glade_widget_class_default_params (klass, FALSE, &n_params);
for (i = 0; i < n_params; i++)
{ {
GParameter parameter = g_array_index (params, GParameter, i); g_object_set_property (object, params[i].name, &(params[i].value));
g_value_unset (&parameter.value);
} }
g_array_free (params, TRUE);
glade_widget_params_free (params, n_params);
return object; return object;
} }
@ -711,7 +788,7 @@ glade_widget_internal_new (const gchar *name,
GObject *glade_widget; GObject *glade_widget;
GList *properties = NULL; GList *properties = NULL;
object = glade_widget_build_object(klass, template); object = glade_widget_build_object(klass, template, NULL);
if (template) if (template)
properties = glade_widget_dup_properties (template->properties); properties = glade_widget_dup_properties (template->properties);
@ -1048,7 +1125,7 @@ glade_widget_rebuild (GladeWidget *glade_widget)
/* Hold a reference to the old widget while we transport properties /* Hold a reference to the old widget while we transport properties
* and children from it * and children from it
*/ */
new_object = glade_widget_build_object(klass, glade_widget); new_object = glade_widget_build_object(klass, glade_widget, NULL);
old_object = g_object_ref(glade_widget_get_object(glade_widget)); old_object = g_object_ref(glade_widget_get_object(glade_widget));
glade_widget_set_object(glade_widget, new_object); glade_widget_set_object(glade_widget, new_object);
@ -2541,8 +2618,8 @@ glade_widget_write (GladeWidget *widget, GladeInterface *interface)
info = g_new0 (GladeWidgetInfo, 1); info = g_new0 (GladeWidgetInfo, 1);
info->classname = alloc_string (interface, widget->widget_class->name); info->classname = glade_xml_alloc_string (interface, widget->widget_class->name);
info->name = alloc_string (interface, widget->name); info->name = glade_xml_alloc_string (interface, widget->name);
/* Write the properties */ /* Write the properties */
props = g_array_new (FALSE, FALSE, sizeof (GladePropInfo)); props = g_array_new (FALSE, FALSE, sizeof (GladePropInfo));
@ -2649,8 +2726,8 @@ glade_widget_write_special_child_prop (GArray *props,
if (support && support->special_child_type && buff) if (support && support->special_child_type && buff)
{ {
info.name = alloc_propname (interface, support->special_child_type); info.name = glade_xml_alloc_propname (interface, support->special_child_type);
info.value = alloc_string (interface, buff); info.value = glade_xml_alloc_string (interface, buff);
g_array_append_val (props, info); g_array_append_val (props, info);
return TRUE; return TRUE;
} }
@ -2690,7 +2767,7 @@ glade_widget_write_child (GArray *children,
return FALSE; return FALSE;
if (child_widget->internal) if (child_widget->internal)
info.internal_child = alloc_string(interface, child_widget->internal); info.internal_child = glade_xml_alloc_string(interface, child_widget->internal);
info.child = glade_widget_write (child_widget, interface); info.child = glade_widget_write (child_widget, interface);
if (!info.child) if (!info.child)
@ -2786,18 +2863,6 @@ glade_widget_fill_from_widget_info (GladeWidgetInfo *info,
} }
} }
static void
glade_widget_params_free (GArray *params)
{
guint i;
for (i = 0; i < params->len; i++)
{
GParameter parameter = g_array_index (params, GParameter, i);
g_value_unset (&parameter.value);
}
g_array_free (params, TRUE);
}
static GList * static GList *
glade_widget_properties_from_widget_info (GladeWidgetClass *class, glade_widget_properties_from_widget_info (GladeWidgetClass *class,
GladeWidgetInfo *info) GladeWidgetInfo *info)
@ -2823,93 +2888,6 @@ glade_widget_properties_from_widget_info (GladeWidgetClass *class,
return g_list_reverse (properties); return g_list_reverse (properties);
} }
static GArray *
glade_widget_params_from_widget_info (GladeWidgetClass *widget_class,
GladeWidgetInfo *info)
{
GladePropertyClass *glade_property_class;
GObjectClass *oclass;
GParamSpec **pspec;
GArray *params;
guint i, n_props;
oclass = g_type_class_ref (widget_class->type);
pspec = g_object_class_list_properties (oclass, &n_props);
params = g_array_new (FALSE, FALSE, sizeof (GParameter));
/* prepare parameters that have glade_property_class->def */
for (i = 0; i < n_props; i++)
{
GParameter parameter = { 0, };
GValue *value;
glade_property_class =
glade_widget_class_get_property_class (widget_class,
pspec[i]->name);
if (glade_property_class == NULL ||
glade_property_class->set_function ||
glade_property_class->ignore)
continue;
parameter.name = pspec[i]->name;
g_value_init (&parameter.value, pspec[i]->value_type);
/* Try filling parameter with value from widget info.
*/
if ((value = glade_property_read (NULL, glade_property_class,
loading_project, info, FALSE)) != NULL)
{
if (g_value_type_compatible (G_VALUE_TYPE (value),
G_VALUE_TYPE (&parameter.value)))
{
g_value_copy (value, &parameter.value);
g_value_unset (value);
g_free (value);
}
else
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, widget_class->name);
g_value_unset (value);
g_free (value);
continue;
}
}
/* Now try filling the parameter with the default on the GladeWidgetClass.
*/
else if (g_value_type_compatible (G_VALUE_TYPE (glade_property_class->orig_def),
G_VALUE_TYPE (&parameter.value)))
{
if (glade_property_class_void_value
(glade_property_class,
glade_property_class->orig_def))
continue;
#if 0
/* If its a NULL object property; disregard it.
*/
if (g_type_is_a (G_VALUE_TYPE (glade_property_class->orig_def),
G_TYPE_OBJECT))
if (g_value_get_object (glade_property_class->orig_def) == NULL)
continue;
#endif
g_value_copy (glade_property_class->orig_def, &parameter.value);
}
else
{
g_critical ("Type mismatch on %s property of %s",
parameter.name, widget_class->name);
continue;
}
g_array_append_val (params, parameter);
}
g_free(pspec);
g_type_class_unref (oclass);
return params;
}
static GladeWidget * static GladeWidget *
glade_widget_new_from_widget_info (GladeWidgetInfo *info, glade_widget_new_from_widget_info (GladeWidgetInfo *info,
GladeProject *project, GladeProject *project,
@ -2918,7 +2896,6 @@ glade_widget_new_from_widget_info (GladeWidgetInfo *info,
GladeWidgetClass *klass; GladeWidgetClass *klass;
GladeWidget *widget; GladeWidget *widget;
GObject *object; GObject *object;
GArray *params;
GList *properties; GList *properties;
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
@ -2931,21 +2908,15 @@ glade_widget_new_from_widget_info (GladeWidgetInfo *info,
return NULL; return NULL;
} }
params = glade_widget_params_from_widget_info (klass, info); object = glade_widget_build_object (klass, NULL, info);
properties = glade_widget_properties_from_widget_info (klass, info); properties = glade_widget_properties_from_widget_info (klass, info);
widget = g_object_new (GLADE_TYPE_WIDGET,
object = g_object_newv (klass->type, params->len, "parent", parent,
(GParameter *)params->data); "properties", properties,
"class", klass,
glade_widget_params_free (params); "project", project,
"name", info->name,
widget = g_object_new (GLADE_TYPE_WIDGET, "object", object, NULL);
"parent", parent,
"properties", properties,
"class", klass,
"project", project,
"name", info->name,
"object", object, NULL);
/* Only call this once the GladeWidget is completely built */ /* Only call this once the GladeWidget is completely built */
if (klass->post_create_function) if (klass->post_create_function)

View File

@ -695,7 +695,7 @@ glade_xml_doc_get_root (GladeXmlDoc *doc)
} }
gchar * gchar *
alloc_string(GladeInterface *interface, const gchar *string) glade_xml_alloc_string(GladeInterface *interface, const gchar *string)
{ {
gchar *s; gchar *s;
@ -709,7 +709,7 @@ alloc_string(GladeInterface *interface, const gchar *string)
} }
gchar * gchar *
alloc_propname(GladeInterface *interface, const gchar *string) glade_xml_alloc_propname(GladeInterface *interface, const gchar *string)
{ {
static GString *norm_str; static GString *norm_str;
guint i; guint i;
@ -724,7 +724,7 @@ alloc_propname(GladeInterface *interface, const gchar *string)
if (norm_str->str[i] == '-') if (norm_str->str[i] == '-')
norm_str->str[i] = '_'; norm_str->str[i] = '_';
return alloc_string(interface, norm_str->str); return glade_xml_alloc_string(interface, norm_str->str);
} }
@ -734,7 +734,6 @@ glade_xml_load_sym_from_node (GladeXmlNode *node_in,
gchar *tagname, gchar *tagname,
gpointer *sym_location) gpointer *sym_location)
{ {
xmlNodePtr node = (xmlNodePtr) node_in;
gchar *buff; gchar *buff;
if ((buff = glade_xml_get_value_string (node_in, tagname)) != NULL) if ((buff = glade_xml_get_value_string (node_in, tagname)) != NULL)

View File

@ -70,8 +70,8 @@ GladeXmlContext * glade_xml_context_new_from_path (const gchar *full_path,
const gchar *root_name); const gchar *root_name);
GladeXmlDoc * glade_xml_context_get_doc (GladeXmlContext *context); GladeXmlDoc * glade_xml_context_get_doc (GladeXmlContext *context);
gchar * alloc_string (GladeInterface *interface, const gchar *string); gchar * glade_xml_alloc_string (GladeInterface *interface, const gchar *string);
gchar * alloc_propname (GladeInterface *interface, const gchar *string); gchar * glade_xml_alloc_propname (GladeInterface *interface, const gchar *string);
void glade_xml_load_sym_from_node (GladeXmlNode *node_in, void glade_xml_load_sym_from_node (GladeXmlNode *node_in,
GModule *module, GModule *module,

View File

@ -4,12 +4,12 @@ CLEANFILES = gtk+.xml
catalogsdir = $(glade_catalogsdir) catalogsdir = $(glade_catalogsdir)
catalogs_DATA = gtk+.xml catalogs_DATA = gtk+.xml gtk+.xml.in
if BUILD_GNOME if BUILD_GNOME
GNOME_CATALOGS = bonobo.xml canvas.xml gnome.xml GNOME_CATALOGS = bonobo.xml canvas.xml gnome.xml
CLEANFILES += $(GNOME_CATALOGS) CLEANFILES += $(GNOME_CATALOGS)
catalogs_DATA += $(GNOME_CATALOGS) catalogs_DATA += $(GNOME_CATALOGS) bonobo.xml.in canvas.xml.in gnome.xml.in
endif endif
EXTRA_DIST = \ EXTRA_DIST = \