summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2018-07-26 20:16:28 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2018-07-26 20:16:28 -0300
commitbc0e26c1d05b0b62266e0d2a320ed40f1a6460e7 (patch)
tree5217558a358fd6915b420f11ac20c4c3f9f5b344
parentad26702a7c6a9472c83b94f452965913a6c742b7 (diff)
downloadglade-bc0e26c1d05b0b62266e0d2a320ed40f1a6460e7.tar.gz
Add initial support for GFile type properties
-rw-r--r--gladeui/glade-editor-property.c19
-rw-r--r--gladeui/glade-project.c9
-rw-r--r--gladeui/glade-property-class.c27
-rw-r--r--gladeui/glade-widget-adaptor.c3
4 files changed, 45 insertions, 13 deletions
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index ef58844d..0162c04e 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -1918,13 +1918,14 @@ glade_eprop_text_changed_common (GladeEditorProperty *eprop,
if (pspec->value_type == G_TYPE_STRV ||
pspec->value_type == value_array_type ||
- pspec->value_type == GDK_TYPE_PIXBUF)
+ pspec->value_type == GDK_TYPE_PIXBUF ||
+ pspec->value_type == G_TYPE_FILE)
{
GladeWidget *gwidget = glade_property_get_widget (eprop->priv->property);
val = glade_property_class_make_gvalue_from_string (eprop->priv->klass,
- text,
- glade_widget_get_project (gwidget));
+ text,
+ glade_widget_get_project (gwidget));
}
else
{
@@ -2254,6 +2255,15 @@ glade_eprop_text_show_resource_dialog (GladeEditorProperty *eprop)
if (glade_editor_property_show_resource_dialog (project, GTK_WIDGET (eprop), &text))
{
+ GParamSpec *pspec = glade_property_class_get_pspec (eprop->priv->klass);
+
+ if (G_PARAM_SPEC_VALUE_TYPE (pspec) == G_TYPE_FILE)
+ {
+ gchar *path = text;
+ text = g_strconcat ("file://", path, NULL);
+ g_free (path);
+ }
+
glade_eprop_text_changed_common (eprop, text, eprop->priv->use_command);
glade_editor_property_load (eprop, eprop->priv->property);
@@ -2460,7 +2470,8 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
g_signal_connect (G_OBJECT (eprop_text->text_entry), "changed",
G_CALLBACK (glade_eprop_text_changed), eprop);
- if (pspec->value_type == GDK_TYPE_PIXBUF)
+ if (pspec->value_type == GDK_TYPE_PIXBUF ||
+ pspec->value_type == G_TYPE_FILE)
{
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (eprop_text->text_entry),
GTK_ENTRY_ICON_SECONDARY,
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index f19611ef..ac677efa 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -1528,11 +1528,12 @@ update_project_for_resource_path (GladeProject *project)
pspec = glade_property_class_get_pspec (klass);
/* XXX We should have a "resource" flag on properties that need
- * to be loaded from the resource path, but that would require
+ * to be loaded from the resource path, but that would require
* that they can serialize both ways (custom properties are only
- * required to generate unique strings for value comparisons).
- */
- if (pspec->value_type == GDK_TYPE_PIXBUF)
+ * required to generate unique strings for value comparisons).
+ */
+ if (pspec->value_type == GDK_TYPE_PIXBUF ||
+ pspec->value_type == G_TYPE_FILE)
{
GValue *value;
gchar *string;
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index b5f13c7f..849b47b3 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -411,6 +411,11 @@ glade_property_class_make_string_from_object (GladePropertyClass *
if ((filename = g_object_get_data (object, "GladeFileName")) != NULL)
string = g_strdup (filename);
}
+ else if (property_class->pspec->value_type == G_TYPE_FILE)
+ {
+ if ((filename = g_object_get_data (object, "GladeFileURI")) != NULL)
+ string = g_strdup (filename);
+ }
else if ((gwidget = glade_widget_get_from_gobject (object)) != NULL)
string = g_strdup (glade_widget_get_name (gwidget));
else
@@ -714,10 +719,10 @@ glade_property_class_make_object_from_string (GladePropertyClass *
GObject *object = NULL;
gchar *fullpath;
- if (string == NULL)
+ if (string == NULL || project == NULL)
return NULL;
- if (property_class->pspec->value_type == GDK_TYPE_PIXBUF && project)
+ if (property_class->pspec->value_type == GDK_TYPE_PIXBUF)
{
GdkPixbuf *pixbuf;
@@ -744,7 +749,20 @@ glade_property_class_make_object_from_string (GladePropertyClass *
g_free (fullpath);
}
- else if (project)
+ else if (property_class->pspec->value_type == G_TYPE_FILE)
+ {
+ GFile *file;
+
+ if (*string == '\0')
+ return NULL;
+
+ file = g_file_new_for_uri (string);
+
+ object = G_OBJECT (file);
+ g_object_set_data_full (object, "GladeFileURI",
+ g_strdup (string), g_free);
+ }
+ else
{
GladeWidget *gwidget;
if ((gwidget = glade_project_get_widget_by_name (project, string)) != NULL)
@@ -1292,7 +1310,8 @@ glade_property_class_is_object (GladePropertyClass * klass)
return (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec) ||
(G_IS_PARAM_SPEC_OBJECT (klass->pspec) &&
- klass->pspec->value_type != GDK_TYPE_PIXBUF));
+ klass->pspec->value_type != GDK_TYPE_PIXBUF &&
+ klass->pspec->value_type != G_TYPE_FILE));
}
void
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 9a00b546..dc44f9b7 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -1263,7 +1263,8 @@ glade_widget_adaptor_get_eprop_type (GParamSpec *pspec)
type = GLADE_TYPE_EPROP_UNICHAR;
else if (G_IS_PARAM_SPEC_OBJECT (pspec))
{
- if (pspec->value_type == GDK_TYPE_PIXBUF)
+ if (pspec->value_type == GDK_TYPE_PIXBUF ||
+ pspec->value_type == G_TYPE_FILE)
type = GLADE_TYPE_EPROP_TEXT;
else
type = GLADE_TYPE_EPROP_OBJECT;