Merge branch 'matthiasc/for-master' into 'master'

builder: Drop unused part of private api

See merge request GNOME/gtk!3979
This commit is contained in:
Matthias Clasen 2021-09-20 04:29:54 +00:00
commit 6a69b4e475
4 changed files with 119 additions and 124 deletions

View File

@ -459,7 +459,6 @@ typedef struct
{
GPtrArray *names;
GArray *values;
guint len;
} ObjectProperties;
@ -468,8 +467,6 @@ object_properties_init (ObjectProperties *self)
{
self->names = NULL;
self->values = NULL;
self->len = 0;
}
static void
@ -483,8 +480,6 @@ object_properties_destroy (ObjectProperties *self)
if (self->values)
g_array_unref (self->values);
self->len = 0;
}
static void
@ -493,10 +488,8 @@ object_properties_add (ObjectProperties *self,
const GValue *value)
{
if (!self->names)
self->names = g_ptr_array_sized_new (8);
if (!self->values)
{
self->names = g_ptr_array_sized_new (8);
self->values = g_array_sized_new (FALSE, FALSE, sizeof (GValue), 8);
g_array_set_clear_func (self->values, (GDestroyNotify) g_value_unset);
}
@ -505,8 +498,6 @@ object_properties_add (ObjectProperties *self,
g_array_append_vals (self->values, value, 1);
g_assert (self->names->len == self->values->len);
self->len += 1;
}
static const char *
@ -546,7 +537,7 @@ gtk_builder_get_parameters (GtkBuilder *builder,
for (guint i = 0; i < properties->len; i++)
{
PropertyInfo *prop = g_ptr_array_index (properties, i);
const char *property_name = g_intern_string (prop->pspec->name);
const char *property_name = prop->pspec->name;
GValue property_value = G_VALUE_INIT;
if (prop->value)
@ -566,12 +557,12 @@ gtk_builder_get_parameters (GtkBuilder *builder,
continue;
}
else if (G_IS_PARAM_SPEC_OBJECT (prop->pspec) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_TEXTURE) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PAINTABLE) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_TRIGGER) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_ACTION) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_TEXTURE) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PAINTABLE) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_TRIGGER) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_ACTION) &&
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
{
GObject *object = g_hash_table_lookup (priv->objects,
g_strstrip (prop->text->str));
@ -751,9 +742,6 @@ _gtk_builder_construct (GtkBuilder *builder,
ObjectProperties parameters, construct_parameters;
GObject *obj;
int i;
GtkBuildableIface *iface;
gboolean custom_set_property;
GtkBuildable *buildable;
GParamFlags param_filter_flags;
g_assert (info->type != G_TYPE_INVALID);
@ -821,7 +809,7 @@ _gtk_builder_construct (GtkBuilder *builder,
builder,
info->id);
g_assert (obj != NULL);
if (construct_parameters.len > 0)
if (construct_parameters.names->len > 0)
g_warning ("Can't pass in construct-only parameters to %s", info->id);
}
else if (info->parent &&
@ -836,7 +824,7 @@ _gtk_builder_construct (GtkBuilder *builder,
object_properties_destroy (&construct_parameters);
return NULL;
}
if (construct_parameters.len > 0)
if (construct_parameters.names)
g_warning ("Can't pass in construct-only parameters to %s", childname);
g_object_ref (obj);
}
@ -844,9 +832,9 @@ _gtk_builder_construct (GtkBuilder *builder,
{
ensure_special_construct_parameters (builder, info->type, &construct_parameters);
if (construct_parameters.len > 0)
if (construct_parameters.names)
obj = g_object_new_with_properties (info->type,
construct_parameters.len,
construct_parameters.names->len,
(const char **) construct_parameters.names->pdata,
(GValue *) construct_parameters.values->data);
else
@ -869,36 +857,60 @@ _gtk_builder_construct (GtkBuilder *builder,
}
object_properties_destroy (&construct_parameters);
custom_set_property = FALSE;
buildable = NULL;
iface = NULL;
if (GTK_IS_BUILDABLE (obj))
if (parameters.names)
{
buildable = GTK_BUILDABLE (obj);
iface = GTK_BUILDABLE_GET_IFACE (obj);
if (iface->set_buildable_property)
custom_set_property = TRUE;
}
GtkBuildableIface *iface = NULL;
gboolean custom_set_property = FALSE;
GtkBuildable *buildable = NULL;
for (i = 0; i < parameters.len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
if (GTK_IS_BUILDABLE (obj))
{
buildable = GTK_BUILDABLE (obj);
iface = GTK_BUILDABLE_GET_IFACE (obj);
if (iface->set_buildable_property)
custom_set_property = TRUE;
}
if (custom_set_property)
iface->set_buildable_property (buildable, builder, name, value);
else
g_object_set_property (obj, name, value);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
{
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
}
for (i = 0; i < parameters.names->len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
iface->set_buildable_property (buildable, builder, name, value);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
{
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
}
#endif
}
}
else
{
g_object_setv (obj,
parameters.names->len,
(const char **) parameters.names->pdata,
(GValue *) parameters.values->data);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
{
for (i = 0; i < parameters.names->len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
}
}
#endif
}
}
object_properties_destroy (&parameters);
if (info->bindings)
@ -919,10 +931,6 @@ _gtk_builder_apply_properties (GtkBuilder *builder,
GError **error)
{
ObjectProperties parameters;
GtkBuildableIface *iface;
GtkBuildable *buildable;
gboolean custom_set_property;
int i;
g_assert (info->object != NULL);
g_assert (info->type != G_TYPE_INVALID);
@ -936,36 +944,60 @@ _gtk_builder_apply_properties (GtkBuilder *builder,
G_PARAM_CONSTRUCT_ONLY,
&parameters, NULL);
custom_set_property = FALSE;
buildable = NULL;
iface = NULL;
if (GTK_IS_BUILDABLE (info->object))
if (parameters.names)
{
buildable = GTK_BUILDABLE (info->object);
iface = GTK_BUILDABLE_GET_IFACE (info->object);
if (iface->set_buildable_property)
custom_set_property = TRUE;
}
GtkBuildableIface *iface = NULL;
GtkBuildable *buildable = NULL;
gboolean custom_set_property = FALSE;
int i;
for (i = 0; i < parameters.len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
if (custom_set_property)
iface->set_buildable_property (buildable, builder, name, value);
else
g_object_set_property (info->object, name, value);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
if (GTK_IS_BUILDABLE (info->object))
{
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
buildable = GTK_BUILDABLE (info->object);
iface = GTK_BUILDABLE_GET_IFACE (info->object);
if (iface->set_buildable_property)
custom_set_property = TRUE;
}
if (custom_set_property)
{
for (i = 0; i < parameters.names->len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
iface->set_buildable_property (buildable, builder, name, value);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
{
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
}
#endif
}
}
else
{
g_object_setv (info->object,
parameters.names->len,
(const char **) parameters.names->pdata,
(GValue *) parameters.values->data);
#ifdef G_ENABLE_DEBUG
if (GTK_DEBUG_CHECK (BUILDER))
{
for (i = 0; i < parameters.names->len; i++)
{
const char *name = object_properties_get_name (&parameters, i);
const GValue *value = object_properties_get_value (&parameters, i);
char *str = g_strdup_value_contents (value);
g_message ("set %s: %s = %s", info->id, name, str);
g_free (str);
}
}
#endif
}
}
object_properties_destroy (&parameters);
}
@ -1923,9 +1955,9 @@ gboolean
_gtk_builder_finish (GtkBuilder *builder,
GError **error)
{
return gtk_builder_apply_delayed_properties (builder, error)
&& gtk_builder_create_bindings (builder, error)
&& gtk_builder_connect_signals (builder, error);
return gtk_builder_apply_delayed_properties (builder, error) &&
gtk_builder_create_bindings (builder, error) &&
gtk_builder_connect_signals (builder, error);
}
/**
@ -1971,7 +2003,7 @@ gtk_builder_value_from_string (GtkBuilder *builder,
{
gunichar c;
g_value_init (value, G_TYPE_UINT);
c = g_utf8_get_char_validated (string, strlen (string));
c = g_utf8_get_char_validated (string, -1);
if (c != 0 && c != (gunichar)-1 && c != (gunichar)-2)
g_value_set_uint (value, c);
return TRUE;
@ -2178,7 +2210,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
{
guint flags_value;
if (!_gtk_builder_flags_from_string (type, NULL, string, &flags_value, error))
if (!_gtk_builder_flags_from_string (type, string, &flags_value, error))
{
ret = FALSE;
break;
@ -2543,9 +2575,9 @@ _gtk_builder_enum_from_string (GType type,
else
{
eclass = g_type_class_ref (type);
ev = g_enum_get_value_by_name (eclass, string);
ev = g_enum_get_value_by_nick (eclass, string);
if (!ev)
ev = g_enum_get_value_by_nick (eclass, string);
ev = g_enum_get_value_by_name (eclass, string);
if (ev)
*enum_value = ev->value;
@ -2567,14 +2599,13 @@ _gtk_builder_enum_from_string (GType type,
gboolean
_gtk_builder_flags_from_string (GType type,
GFlagsValue *aliases,
const char *string,
guint *flags_value,
GError **error)
{
GFlagsClass *fclass;
char *endptr, *prevptr;
guint i, j, k, value;
guint i, j, value;
char *flagstr;
GFlagsValue *fv;
const char *flag;
@ -2637,18 +2668,6 @@ _gtk_builder_flags_from_string (GType type,
fv = NULL;
if (aliases)
{
for (k = 0; aliases[k].value_nick; k++)
{
if (g_ascii_strcasecmp (aliases[k].value_nick, flag) == 0)
{
fv = &aliases[k];
break;
}
}
}
if (!fv)
fv = g_flags_get_value_by_name (fclass, flag);

View File

@ -918,7 +918,7 @@ parse_property (ParserData *data,
if (bind_flags_str)
{
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error))
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;

View File

@ -238,10 +238,9 @@ gboolean _gtk_builder_enum_from_string (GType type,
int *enum_value,
GError **error);
gboolean _gtk_builder_flags_from_string (GType type,
GFlagsValue *aliases,
const char *string,
guint *value,
GError **error);
const char *string,
guint *value,
GError **error);
gboolean _gtk_builder_boolean_from_string (const char *string,
gboolean *value,
GError **error);

View File

@ -211,7 +211,6 @@ typedef struct
*/
guint need_default_size : 1;
guint builder_visible : 1;
guint decorated : 1;
guint deletable : 1;
guint destroy_with_parent : 1;
@ -472,10 +471,6 @@ static void gtk_window_buildable_add_child (GtkBuildable
GtkBuilder *builder,
GObject *child,
const char *type);
static void gtk_window_buildable_set_buildable_property (GtkBuildable *buildable,
GtkBuilder *builder,
const char *name,
const GValue *value);
static void gtk_window_shortcut_manager_interface_init (GtkShortcutManagerInterface *iface);
/* GtkRoot */
@ -1916,7 +1911,6 @@ static void
gtk_window_buildable_interface_init (GtkBuildableIface *iface)
{
parent_buildable_iface = g_type_interface_peek_parent (iface);
iface->set_buildable_property = gtk_window_buildable_set_buildable_property;
iface->add_child = gtk_window_buildable_add_child;
}
@ -1934,23 +1928,6 @@ gtk_window_buildable_add_child (GtkBuildable *buildable,
parent_buildable_iface->add_child (buildable, builder, child, type);
}
static void
gtk_window_buildable_set_buildable_property (GtkBuildable *buildable,
GtkBuilder *builder,
const char *name,
const GValue *value)
{
GtkWindow *window = GTK_WINDOW (buildable);
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
if (strcmp (name, "visible") == 0 && g_value_get_boolean (value))
priv->builder_visible = TRUE;
else if (parent_buildable_iface->set_buildable_property)
parent_buildable_iface->set_buildable_property (buildable, builder, name, value);
else
g_object_set_property (G_OBJECT (buildable), name, value);
}
static void
gtk_window_shortcut_manager_interface_init (GtkShortcutManagerInterface *iface)
{