mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
builder: Remove priv pointer
This commit is contained in:
parent
01d4538223
commit
da4d8b7d94
241
gtk/gtkbuilder.c
241
gtk/gtkbuilder.c
@ -238,7 +238,7 @@ enum {
|
||||
|
||||
static GParamSpec *builder_props[LAST_PROP];
|
||||
|
||||
struct _GtkBuilderPrivate
|
||||
typedef struct
|
||||
{
|
||||
gchar *domain;
|
||||
GHashTable *objects;
|
||||
@ -250,7 +250,7 @@ struct _GtkBuilderPrivate
|
||||
gchar *resource_prefix;
|
||||
GType template_type;
|
||||
GtkApplication *application;
|
||||
};
|
||||
} GtkBuilderPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkBuilder, gtk_builder, G_TYPE_OBJECT)
|
||||
|
||||
@ -288,10 +288,12 @@ gtk_builder_class_init (GtkBuilderClass *klass)
|
||||
static void
|
||||
gtk_builder_init (GtkBuilder *builder)
|
||||
{
|
||||
builder->priv = gtk_builder_get_instance_private (builder);
|
||||
builder->priv->domain = NULL;
|
||||
builder->priv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
priv = gtk_builder_get_instance_private (builder);
|
||||
priv->domain = NULL;
|
||||
priv->objects = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_object_unref);
|
||||
}
|
||||
|
||||
|
||||
@ -302,7 +304,7 @@ gtk_builder_init (GtkBuilder *builder)
|
||||
static void
|
||||
gtk_builder_finalize (GObject *object)
|
||||
{
|
||||
GtkBuilderPrivate *priv = GTK_BUILDER (object)->priv;
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (GTK_BUILDER (object));
|
||||
|
||||
g_free (priv->domain);
|
||||
g_free (priv->filename);
|
||||
@ -343,11 +345,12 @@ gtk_builder_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkBuilder *builder = GTK_BUILDER (object);
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TRANSLATION_DOMAIN:
|
||||
g_value_set_string (value, builder->priv->domain);
|
||||
g_value_set_string (value, priv->domain);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -511,6 +514,7 @@ gtk_builder_get_parameters (GtkBuilder *builder,
|
||||
ObjectProperties **parameters,
|
||||
ObjectProperties **filtered_parameters)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *l;
|
||||
DelayedProperty *property;
|
||||
GError *error = NULL;
|
||||
@ -532,7 +536,7 @@ gtk_builder_get_parameters (GtkBuilder *builder,
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PAINTABLE) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
|
||||
{
|
||||
GObject *object = g_hash_table_lookup (builder->priv->objects,
|
||||
GObject *object = g_hash_table_lookup (priv->objects,
|
||||
prop->text->str);
|
||||
|
||||
if (object)
|
||||
@ -556,8 +560,8 @@ gtk_builder_get_parameters (GtkBuilder *builder,
|
||||
property->value = g_strdup (prop->text->str);
|
||||
property->line = prop->line;
|
||||
property->col = prop->col;
|
||||
builder->priv->delayed_properties =
|
||||
g_slist_prepend (builder->priv->delayed_properties, property);
|
||||
priv->delayed_properties = g_slist_prepend (priv->delayed_properties,
|
||||
property);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -655,8 +659,10 @@ _gtk_builder_add_object (GtkBuilder *builder,
|
||||
const gchar *id,
|
||||
GObject *object)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
object_set_name (object, id);
|
||||
g_hash_table_insert (builder->priv->objects, g_strdup (id), g_object_ref (object));
|
||||
g_hash_table_insert (priv->objects, g_strdup (id), g_object_ref (object));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -664,6 +670,7 @@ gtk_builder_take_bindings (GtkBuilder *builder,
|
||||
GObject *target,
|
||||
GSList *bindings)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *l;
|
||||
|
||||
for (l = bindings; l; l = l->next)
|
||||
@ -672,7 +679,7 @@ gtk_builder_take_bindings (GtkBuilder *builder,
|
||||
info->target = target;
|
||||
}
|
||||
|
||||
builder->priv->bindings = g_slist_concat (builder->priv->bindings, bindings);
|
||||
priv->bindings = g_slist_concat (priv->bindings, bindings);
|
||||
}
|
||||
|
||||
GObject *
|
||||
@ -680,6 +687,7 @@ _gtk_builder_construct (GtkBuilder *builder,
|
||||
ObjectInfo *info,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
ObjectProperties *parameters, *construct_parameters;
|
||||
GObject *obj;
|
||||
int i;
|
||||
@ -690,15 +698,15 @@ _gtk_builder_construct (GtkBuilder *builder,
|
||||
|
||||
g_assert (info->type != G_TYPE_INVALID);
|
||||
|
||||
if (builder->priv->template_type != 0 &&
|
||||
g_type_is_a (info->type, builder->priv->template_type))
|
||||
if (priv->template_type != 0 &&
|
||||
g_type_is_a (info->type, priv->template_type))
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED,
|
||||
"Refused to build object of type '%s' because it "
|
||||
"conforms to the template type '%s', avoiding infinite recursion.",
|
||||
g_type_name (info->type), g_type_name (builder->priv->template_type));
|
||||
g_type_name (info->type), g_type_name (priv->template_type));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -731,7 +739,7 @@ _gtk_builder_construct (GtkBuilder *builder,
|
||||
{
|
||||
GObject *constructor;
|
||||
|
||||
constructor = g_hash_table_lookup (builder->priv->objects, info->constructor);
|
||||
constructor = g_hash_table_lookup (priv->objects, info->constructor);
|
||||
if (constructor == NULL)
|
||||
{
|
||||
g_set_error (error,
|
||||
@ -929,13 +937,16 @@ void
|
||||
_gtk_builder_add_signals (GtkBuilder *builder,
|
||||
GSList *signals)
|
||||
{
|
||||
builder->priv->signals = g_slist_concat (builder->priv->signals,
|
||||
g_slist_copy (signals));
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
priv->signals = g_slist_concat (priv->signals,
|
||||
g_slist_copy (signals));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_builder_apply_delayed_properties (GtkBuilder *builder)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *l, *props;
|
||||
|
||||
/* take the list over from the builder->priv.
|
||||
@ -943,15 +954,15 @@ gtk_builder_apply_delayed_properties (GtkBuilder *builder)
|
||||
* g_slist_reverse does not copy the list, so the list now
|
||||
* belongs to us (and we free it at the end of this function).
|
||||
*/
|
||||
props = g_slist_reverse (builder->priv->delayed_properties);
|
||||
builder->priv->delayed_properties = NULL;
|
||||
props = g_slist_reverse (priv->delayed_properties);
|
||||
priv->delayed_properties = NULL;
|
||||
|
||||
for (l = props; l; l = l->next)
|
||||
{
|
||||
DelayedProperty *property = l->data;
|
||||
GObject *object, *obj;
|
||||
|
||||
object = g_hash_table_lookup (builder->priv->objects, property->object);
|
||||
object = g_hash_table_lookup (priv->objects, property->object);
|
||||
g_assert (object != NULL);
|
||||
|
||||
obj = _gtk_builder_lookup_object (builder, property->value, property->line, property->col);
|
||||
@ -979,9 +990,10 @@ free_binding_info (gpointer data,
|
||||
static inline void
|
||||
gtk_builder_create_bindings (GtkBuilder *builder)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *l;
|
||||
|
||||
for (l = builder->priv->bindings; l; l = l->next)
|
||||
for (l = priv->bindings; l; l = l->next)
|
||||
{
|
||||
BindingInfo *info = l->data;
|
||||
GObject *source;
|
||||
@ -995,8 +1007,8 @@ gtk_builder_create_bindings (GtkBuilder *builder)
|
||||
free_binding_info (info, NULL);
|
||||
}
|
||||
|
||||
g_slist_free (builder->priv->bindings);
|
||||
builder->priv->bindings = NULL;
|
||||
g_slist_free (priv->bindings);
|
||||
priv->bindings = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1056,6 +1068,7 @@ gtk_builder_add_from_file (GtkBuilder *builder,
|
||||
const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gchar *buffer;
|
||||
gsize length;
|
||||
GError *tmp_error;
|
||||
@ -1072,10 +1085,10 @@ gtk_builder_add_from_file (GtkBuilder *builder,
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (filename);
|
||||
builder->priv->resource_prefix = NULL;
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (filename);
|
||||
priv->resource_prefix = NULL;
|
||||
|
||||
_gtk_builder_parser_parse_buffer (builder, filename,
|
||||
buffer, length,
|
||||
@ -1120,6 +1133,7 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
|
||||
gchar **object_ids,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gchar *buffer;
|
||||
gsize length;
|
||||
GError *tmp_error;
|
||||
@ -1137,10 +1151,10 @@ gtk_builder_add_objects_from_file (GtkBuilder *builder,
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (filename);
|
||||
builder->priv->resource_prefix = NULL;
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (filename);
|
||||
priv->resource_prefix = NULL;
|
||||
|
||||
_gtk_builder_parser_parse_buffer (builder, filename,
|
||||
buffer, length,
|
||||
@ -1184,6 +1198,7 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
|
||||
gsize length,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GError *tmp_error;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
|
||||
@ -1194,11 +1209,11 @@ gtk_builder_extend_with_template (GtkBuilder *builder,
|
||||
|
||||
tmp_error = NULL;
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (".");
|
||||
builder->priv->resource_prefix = NULL;
|
||||
builder->priv->template_type = template_type;
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (".");
|
||||
priv->resource_prefix = NULL;
|
||||
priv->template_type = template_type;
|
||||
|
||||
gtk_builder_expose_object (builder, g_type_name (template_type), G_OBJECT (widget));
|
||||
_gtk_builder_parser_parse_buffer (builder, "<input>",
|
||||
@ -1241,6 +1256,7 @@ gtk_builder_add_from_resource (GtkBuilder *builder,
|
||||
const gchar *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GError *tmp_error;
|
||||
GBytes *data;
|
||||
char *filename_for_errors;
|
||||
@ -1259,17 +1275,15 @@ gtk_builder_add_from_resource (GtkBuilder *builder,
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (".");
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (".");
|
||||
|
||||
slash = strrchr (resource_path, '/');
|
||||
if (slash != NULL)
|
||||
builder->priv->resource_prefix =
|
||||
g_strndup (resource_path, slash - resource_path + 1);
|
||||
priv->resource_prefix = g_strndup (resource_path, slash - resource_path + 1);
|
||||
else
|
||||
builder->priv->resource_prefix =
|
||||
g_strdup ("/");
|
||||
priv->resource_prefix = g_strdup ("/");
|
||||
|
||||
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
|
||||
|
||||
@ -1317,6 +1331,7 @@ gtk_builder_add_objects_from_resource (GtkBuilder *builder,
|
||||
gchar **object_ids,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GError *tmp_error;
|
||||
GBytes *data;
|
||||
char *filename_for_errors;
|
||||
@ -1336,17 +1351,15 @@ gtk_builder_add_objects_from_resource (GtkBuilder *builder,
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (".");
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (".");
|
||||
|
||||
slash = strrchr (resource_path, '/');
|
||||
if (slash != NULL)
|
||||
builder->priv->resource_prefix =
|
||||
g_strndup (resource_path, slash - resource_path + 1);
|
||||
priv->resource_prefix = g_strndup (resource_path, slash - resource_path + 1);
|
||||
else
|
||||
builder->priv->resource_prefix =
|
||||
g_strdup ("/");
|
||||
priv->resource_prefix = g_strdup ("/");
|
||||
|
||||
filename_for_errors = g_strconcat ("<resource>", resource_path, NULL);
|
||||
|
||||
@ -1394,6 +1407,7 @@ gtk_builder_add_from_string (GtkBuilder *builder,
|
||||
gsize length,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GError *tmp_error;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
|
||||
@ -1402,10 +1416,10 @@ gtk_builder_add_from_string (GtkBuilder *builder,
|
||||
|
||||
tmp_error = NULL;
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (".");
|
||||
builder->priv->resource_prefix = NULL;
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (".");
|
||||
priv->resource_prefix = NULL;
|
||||
|
||||
_gtk_builder_parser_parse_buffer (builder, "<input>",
|
||||
buffer, length,
|
||||
@ -1448,6 +1462,7 @@ gtk_builder_add_objects_from_string (GtkBuilder *builder,
|
||||
gchar **object_ids,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GError *tmp_error;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), 0);
|
||||
@ -1457,10 +1472,10 @@ gtk_builder_add_objects_from_string (GtkBuilder *builder,
|
||||
|
||||
tmp_error = NULL;
|
||||
|
||||
g_free (builder->priv->filename);
|
||||
g_free (builder->priv->resource_prefix);
|
||||
builder->priv->filename = g_strdup (".");
|
||||
builder->priv->resource_prefix = NULL;
|
||||
g_free (priv->filename);
|
||||
g_free (priv->resource_prefix);
|
||||
priv->filename = g_strdup (".");
|
||||
priv->resource_prefix = NULL;
|
||||
|
||||
_gtk_builder_parser_parse_buffer (builder, "<input>",
|
||||
buffer, length,
|
||||
@ -1491,10 +1506,12 @@ GObject *
|
||||
gtk_builder_get_object (GtkBuilder *builder,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
return g_hash_table_lookup (builder->priv->objects, name);
|
||||
return g_hash_table_lookup (priv->objects, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1512,13 +1529,14 @@ gtk_builder_get_object (GtkBuilder *builder,
|
||||
GSList *
|
||||
gtk_builder_get_objects (GtkBuilder *builder)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *objects = NULL;
|
||||
GObject *object;
|
||||
GHashTableIter iter;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
|
||||
|
||||
g_hash_table_iter_init (&iter, builder->priv->objects);
|
||||
g_hash_table_iter_init (&iter, priv->objects);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&object))
|
||||
objects = g_slist_prepend (objects, object);
|
||||
|
||||
@ -1537,13 +1555,14 @@ void
|
||||
gtk_builder_set_translation_domain (GtkBuilder *builder,
|
||||
const gchar *domain)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gchar *new_domain;
|
||||
|
||||
g_return_if_fail (GTK_IS_BUILDER (builder));
|
||||
|
||||
new_domain = g_strdup (domain);
|
||||
g_free (builder->priv->domain);
|
||||
builder->priv->domain = new_domain;
|
||||
g_free (priv->domain);
|
||||
priv->domain = new_domain;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (builder), builder_props[PROP_TRANSLATION_DOMAIN]);
|
||||
}
|
||||
@ -1560,9 +1579,11 @@ gtk_builder_set_translation_domain (GtkBuilder *builder,
|
||||
const gchar *
|
||||
gtk_builder_get_translation_domain (GtkBuilder *builder)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
|
||||
|
||||
return builder->priv->domain;
|
||||
return priv->domain;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1579,12 +1600,14 @@ gtk_builder_expose_object (GtkBuilder *builder,
|
||||
const gchar *name,
|
||||
GObject *object)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_if_fail (GTK_IS_BUILDER (builder));
|
||||
g_return_if_fail (name && name[0]);
|
||||
g_return_if_fail (!g_hash_table_contains (builder->priv->objects, name));
|
||||
g_return_if_fail (!g_hash_table_contains (priv->objects, name));
|
||||
|
||||
object_set_name (object, name);
|
||||
g_hash_table_insert (builder->priv->objects,
|
||||
g_hash_table_insert (priv->objects,
|
||||
g_strdup (name),
|
||||
g_object_ref (object));
|
||||
}
|
||||
@ -1713,6 +1736,7 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
|
||||
GtkBuilderConnectFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GSList *l;
|
||||
GObject *object;
|
||||
GObject *connect_object;
|
||||
@ -1721,11 +1745,11 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
|
||||
g_return_if_fail (GTK_IS_BUILDER (builder));
|
||||
g_return_if_fail (func != NULL);
|
||||
|
||||
if (!builder->priv->signals)
|
||||
if (!priv->signals)
|
||||
return;
|
||||
|
||||
builder->priv->signals = g_slist_reverse (builder->priv->signals);
|
||||
for (l = builder->priv->signals; l; l = l->next)
|
||||
priv->signals = g_slist_reverse (priv->signals);
|
||||
for (l = priv->signals; l; l = l->next)
|
||||
{
|
||||
SignalInfo *signal = (SignalInfo*)l->data;
|
||||
const gchar *signal_name;
|
||||
@ -1735,15 +1759,14 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
|
||||
|
||||
signal_name = g_signal_name (signal->id);
|
||||
|
||||
object = g_hash_table_lookup (builder->priv->objects,
|
||||
signal->object_name);
|
||||
object = g_hash_table_lookup (priv->objects, signal->object_name);
|
||||
g_assert (object != NULL);
|
||||
|
||||
connect_object = NULL;
|
||||
|
||||
if (signal->connect_object_name)
|
||||
{
|
||||
connect_object = g_hash_table_lookup (builder->priv->objects,
|
||||
connect_object = g_hash_table_lookup (priv->objects,
|
||||
signal->connect_object_name);
|
||||
if (!connect_object)
|
||||
g_warning ("Could not lookup object %s on signal %s of object %s",
|
||||
@ -1765,8 +1788,8 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
|
||||
connect_object, signal->flags, user_data);
|
||||
}
|
||||
|
||||
g_slist_free_full (builder->priv->signals, (GDestroyNotify)_free_signal_info);
|
||||
builder->priv->signals = NULL;
|
||||
g_slist_free_full (priv->signals, (GDestroyNotify)_free_signal_info);
|
||||
priv->signals = NULL;
|
||||
|
||||
if (detailed_id)
|
||||
g_string_free (detailed_id, TRUE);
|
||||
@ -1876,6 +1899,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
GValue *value,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gboolean ret = TRUE;
|
||||
|
||||
g_return_val_if_fail (string != NULL, FALSE);
|
||||
@ -2059,7 +2083,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GObject *object;
|
||||
|
||||
object = g_hash_table_lookup (builder->priv->objects, string);
|
||||
object = g_hash_table_lookup (priv->objects, string);
|
||||
|
||||
if (object)
|
||||
{
|
||||
@ -2137,7 +2161,7 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
if (g_hash_table_contains (builder->priv->objects, string))
|
||||
if (g_hash_table_contains (priv->objects, string))
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
@ -2425,30 +2449,33 @@ gtk_builder_error_quark (void)
|
||||
gchar *
|
||||
_gtk_builder_get_resource_path (GtkBuilder *builder, const gchar *string)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
if (g_str_has_prefix (string, "resource:///"))
|
||||
return g_uri_unescape_string (string + 11, "/");
|
||||
|
||||
if (g_path_is_absolute (string) ||
|
||||
builder->priv->resource_prefix == NULL)
|
||||
priv->resource_prefix == NULL)
|
||||
return NULL;
|
||||
|
||||
return g_build_path ("/", builder->priv->resource_prefix, string, NULL);
|
||||
return g_build_path ("/", priv->resource_prefix, string, NULL);
|
||||
}
|
||||
|
||||
gchar *
|
||||
_gtk_builder_get_absolute_filename (GtkBuilder *builder,
|
||||
const gchar *string)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gchar *filename;
|
||||
gchar *dirname = NULL;
|
||||
|
||||
if (g_path_is_absolute (string))
|
||||
return g_strdup (string);
|
||||
|
||||
if (builder->priv->filename &&
|
||||
strcmp (builder->priv->filename, ".") != 0)
|
||||
if (priv->filename &&
|
||||
strcmp (priv->filename, ".") != 0)
|
||||
{
|
||||
dirname = g_path_get_dirname (builder->priv->filename);
|
||||
dirname = g_path_get_dirname (priv->filename);
|
||||
|
||||
if (strcmp (dirname, ".") == 0)
|
||||
{
|
||||
@ -2468,7 +2495,9 @@ _gtk_builder_get_absolute_filename (GtkBuilder *builder,
|
||||
GType
|
||||
_gtk_builder_get_template_type (GtkBuilder *builder)
|
||||
{
|
||||
return builder->priv->template_type;
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
return priv->template_type;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2489,15 +2518,17 @@ gtk_builder_add_callback_symbol (GtkBuilder *builder,
|
||||
const gchar *callback_name,
|
||||
GCallback callback_symbol)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_if_fail (GTK_IS_BUILDER (builder));
|
||||
g_return_if_fail (callback_name && callback_name[0]);
|
||||
g_return_if_fail (callback_symbol != NULL);
|
||||
|
||||
if (!builder->priv->callbacks)
|
||||
builder->priv->callbacks = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
if (!priv->callbacks)
|
||||
priv->callbacks = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
|
||||
g_hash_table_insert (builder->priv->callbacks, g_strdup (callback_name), callback_symbol);
|
||||
g_hash_table_insert (priv->callbacks, g_strdup (callback_name), callback_symbol);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2561,13 +2592,15 @@ GCallback
|
||||
gtk_builder_lookup_callback_symbol (GtkBuilder *builder,
|
||||
const gchar *callback_name)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
|
||||
g_return_val_if_fail (callback_name && callback_name[0], NULL);
|
||||
|
||||
if (!builder->priv->callbacks)
|
||||
if (!priv->callbacks)
|
||||
return NULL;
|
||||
|
||||
return g_hash_table_lookup (builder->priv->callbacks, callback_name);
|
||||
return g_hash_table_lookup (priv->callbacks, callback_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2666,13 +2699,15 @@ void
|
||||
gtk_builder_set_application (GtkBuilder *builder,
|
||||
GtkApplication *application)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_if_fail (GTK_IS_BUILDER (builder));
|
||||
g_return_if_fail (GTK_IS_APPLICATION (application));
|
||||
|
||||
if (builder->priv->application)
|
||||
g_object_unref (builder->priv->application);
|
||||
if (priv->application)
|
||||
g_object_unref (priv->application);
|
||||
|
||||
builder->priv->application = g_object_ref (application);
|
||||
priv->application = g_object_ref (application);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2694,18 +2729,20 @@ gtk_builder_set_application (GtkBuilder *builder,
|
||||
GtkApplication *
|
||||
gtk_builder_get_application (GtkBuilder *builder)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_BUILDER (builder), NULL);
|
||||
|
||||
if (!builder->priv->application)
|
||||
if (!priv->application)
|
||||
{
|
||||
GApplication *application;
|
||||
|
||||
application = g_application_get_default ();
|
||||
if (application && GTK_IS_APPLICATION (application))
|
||||
builder->priv->application = g_object_ref (GTK_APPLICATION (application));
|
||||
priv->application = g_object_ref (GTK_APPLICATION (application));
|
||||
}
|
||||
|
||||
return builder->priv->application;
|
||||
return priv->application;
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@ -2727,10 +2764,11 @@ _gtk_builder_prefix_error (GtkBuilder *builder,
|
||||
GMarkupParseContext *context,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gint line, col;
|
||||
|
||||
g_markup_parse_context_get_position (context, &line, &col);
|
||||
g_prefix_error (error, "%s:%d:%d ", builder->priv->filename, line, col);
|
||||
g_prefix_error (error, "%s:%d:%d ", priv->filename, line, col);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
@ -2753,6 +2791,7 @@ _gtk_builder_error_unhandled_tag (GtkBuilder *builder,
|
||||
const gchar *element_name,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
gint line, col;
|
||||
|
||||
g_markup_parse_context_get_position (context, &line, &col);
|
||||
@ -2760,7 +2799,7 @@ _gtk_builder_error_unhandled_tag (GtkBuilder *builder,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_UNHANDLED_TAG,
|
||||
"%s:%d:%d Unsupported tag for %s: <%s>",
|
||||
builder->priv->filename, line, col,
|
||||
priv->filename, line, col,
|
||||
object, element_name);
|
||||
}
|
||||
|
||||
@ -2784,6 +2823,7 @@ _gtk_builder_check_parent (GtkBuilder *builder,
|
||||
const gchar *parent_name,
|
||||
GError **error)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
const GSList *stack;
|
||||
gint line, col;
|
||||
const gchar *parent;
|
||||
@ -2803,7 +2843,7 @@ _gtk_builder_check_parent (GtkBuilder *builder,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_TAG,
|
||||
"%s:%d:%d Can't use <%s> here",
|
||||
builder->priv->filename, line, col, element);
|
||||
priv->filename, line, col, element);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -2829,10 +2869,11 @@ _gtk_builder_lookup_object (GtkBuilder *builder,
|
||||
gint line,
|
||||
gint col)
|
||||
{
|
||||
GtkBuilderPrivate *priv = gtk_builder_get_instance_private (builder);
|
||||
GObject *obj;
|
||||
GError *error = NULL;
|
||||
|
||||
obj = g_hash_table_lookup (builder->priv->objects, name);
|
||||
obj = g_hash_table_lookup (priv->objects, name);
|
||||
error = (GError *) g_object_get_data (G_OBJECT (builder), "lookup-error");
|
||||
|
||||
if (!obj && !error)
|
||||
@ -2840,7 +2881,7 @@ _gtk_builder_lookup_object (GtkBuilder *builder,
|
||||
g_set_error (&error,
|
||||
GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_INVALID_ID,
|
||||
"%s:%d:%d Object with ID %s not found",
|
||||
builder->priv->filename, line, col, name);
|
||||
priv->filename, line, col, name);
|
||||
g_object_set_data_full (G_OBJECT (builder), "lookup-error",
|
||||
error, (GDestroyNotify)g_error_free);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ G_BEGIN_DECLS
|
||||
#define GTK_BUILDER_ERROR (gtk_builder_error_quark ())
|
||||
|
||||
typedef struct _GtkBuilderClass GtkBuilderClass;
|
||||
typedef struct _GtkBuilderPrivate GtkBuilderPrivate;
|
||||
|
||||
/**
|
||||
* GtkBuilderError:
|
||||
@ -93,14 +92,12 @@ GQuark gtk_builder_error_quark (void);
|
||||
struct _GtkBuilder
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkBuilderPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkBuilderClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
|
||||
GType (* get_type_from_name) (GtkBuilder *builder,
|
||||
const char *type_name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user