[gtk+/wip/matthiasc/help-overlay] builder: Support creating GFile objects
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/help-overlay] builder: Support creating GFile objects
- Date: Tue, 13 Oct 2015 12:16:56 +0000 (UTC)
commit 916235523eab948b2aaaa91761df0d34c93d4359
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 11 18:54:27 2015 -0400
builder: Support creating GFile objects
This is useful, e.g. when creating GFileIcon objects.
gtk/gtkbuilder.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 5b61334..fd22036 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -478,7 +478,8 @@ gtk_builder_get_parameters (GtkBuilder *builder,
parameter.name = prop->pspec->name;
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_PIXBUF) &&
+ (G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
{
GObject *object = g_hash_table_lookup (builder->priv->objects,
prop->text->str);
@@ -2035,6 +2036,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
break;
case G_TYPE_OBJECT:
+ case G_TYPE_INTERFACE:
if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF))
{
gchar *filename;
@@ -2095,6 +2097,27 @@ G_GNUC_END_IGNORE_DEPRECATIONS
ret = TRUE;
}
+ else if (G_VALUE_HOLDS (value, G_TYPE_FILE))
+ {
+ GFile *file;
+
+ if (g_hash_table_contains (builder->priv->objects, string))
+ {
+ g_set_error (error,
+ GTK_BUILDER_ERROR,
+ GTK_BUILDER_ERROR_INVALID_VALUE,
+ "Could not create file '%s': "
+ " '%s' is already used as object id",
+ string, string);
+ return FALSE;
+ }
+
+ file = g_file_new_for_uri (string);
+ g_value_set_object (value, file);
+ g_object_unref (G_OBJECT (file));
+
+ ret = TRUE;
+ }
else
ret = FALSE;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]