Commit bc0e26c1 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

Add initial support for GFile type properties

parent ad26702a
...@@ -1918,13 +1918,14 @@ glade_eprop_text_changed_common (GladeEditorProperty *eprop, ...@@ -1918,13 +1918,14 @@ glade_eprop_text_changed_common (GladeEditorProperty *eprop,
if (pspec->value_type == G_TYPE_STRV || if (pspec->value_type == G_TYPE_STRV ||
pspec->value_type == value_array_type || 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); GladeWidget *gwidget = glade_property_get_widget (eprop->priv->property);
val = glade_property_class_make_gvalue_from_string (eprop->priv->klass, val = glade_property_class_make_gvalue_from_string (eprop->priv->klass,
text, text,
glade_widget_get_project (gwidget)); glade_widget_get_project (gwidget));
} }
else else
{ {
...@@ -2254,6 +2255,15 @@ glade_eprop_text_show_resource_dialog (GladeEditorProperty *eprop) ...@@ -2254,6 +2255,15 @@ glade_eprop_text_show_resource_dialog (GladeEditorProperty *eprop)
if (glade_editor_property_show_resource_dialog (project, GTK_WIDGET (eprop), &text)) 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_eprop_text_changed_common (eprop, text, eprop->priv->use_command);
glade_editor_property_load (eprop, eprop->priv->property); glade_editor_property_load (eprop, eprop->priv->property);
...@@ -2460,7 +2470,8 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop) ...@@ -2460,7 +2470,8 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
g_signal_connect (G_OBJECT (eprop_text->text_entry), "changed", g_signal_connect (G_OBJECT (eprop_text->text_entry), "changed",
G_CALLBACK (glade_eprop_text_changed), eprop); 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_set_icon_from_icon_name (GTK_ENTRY (eprop_text->text_entry),
GTK_ENTRY_ICON_SECONDARY, GTK_ENTRY_ICON_SECONDARY,
......
...@@ -1528,11 +1528,12 @@ update_project_for_resource_path (GladeProject *project) ...@@ -1528,11 +1528,12 @@ update_project_for_resource_path (GladeProject *project)
pspec = glade_property_class_get_pspec (klass); pspec = glade_property_class_get_pspec (klass);
/* XXX We should have a "resource" flag on properties that need /* 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 * that they can serialize both ways (custom properties are only
* required to generate unique strings for value comparisons). * required to generate unique strings for value comparisons).
*/ */
if (pspec->value_type == GDK_TYPE_PIXBUF) if (pspec->value_type == GDK_TYPE_PIXBUF ||
pspec->value_type == G_TYPE_FILE)
{ {
GValue *value; GValue *value;
gchar *string; gchar *string;
......
...@@ -411,6 +411,11 @@ glade_property_class_make_string_from_object (GladePropertyClass * ...@@ -411,6 +411,11 @@ glade_property_class_make_string_from_object (GladePropertyClass *
if ((filename = g_object_get_data (object, "GladeFileName")) != NULL) if ((filename = g_object_get_data (object, "GladeFileName")) != NULL)
string = g_strdup (filename); 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) else if ((gwidget = glade_widget_get_from_gobject (object)) != NULL)
string = g_strdup (glade_widget_get_name (gwidget)); string = g_strdup (glade_widget_get_name (gwidget));
else else
...@@ -714,10 +719,10 @@ glade_property_class_make_object_from_string (GladePropertyClass * ...@@ -714,10 +719,10 @@ glade_property_class_make_object_from_string (GladePropertyClass *
GObject *object = NULL; GObject *object = NULL;
gchar *fullpath; gchar *fullpath;
if (string == NULL) if (string == NULL || project == NULL)
return NULL; return NULL;
if (property_class->pspec->value_type == GDK_TYPE_PIXBUF && project) if (property_class->pspec->value_type == GDK_TYPE_PIXBUF)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
...@@ -744,7 +749,20 @@ glade_property_class_make_object_from_string (GladePropertyClass * ...@@ -744,7 +749,20 @@ glade_property_class_make_object_from_string (GladePropertyClass *
g_free (fullpath); 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; GladeWidget *gwidget;
if ((gwidget = glade_project_get_widget_by_name (project, string)) != NULL) if ((gwidget = glade_project_get_widget_by_name (project, string)) != NULL)
...@@ -1292,7 +1310,8 @@ glade_property_class_is_object (GladePropertyClass * klass) ...@@ -1292,7 +1310,8 @@ glade_property_class_is_object (GladePropertyClass * klass)
return (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec) || return (GLADE_IS_PARAM_SPEC_OBJECTS (klass->pspec) ||
(G_IS_PARAM_SPEC_OBJECT (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 void
......
...@@ -1263,7 +1263,8 @@ glade_widget_adaptor_get_eprop_type (GParamSpec *pspec) ...@@ -1263,7 +1263,8 @@ glade_widget_adaptor_get_eprop_type (GParamSpec *pspec)
type = GLADE_TYPE_EPROP_UNICHAR; type = GLADE_TYPE_EPROP_UNICHAR;
else if (G_IS_PARAM_SPEC_OBJECT (pspec)) 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; type = GLADE_TYPE_EPROP_TEXT;
else else
type = GLADE_TYPE_EPROP_OBJECT; type = GLADE_TYPE_EPROP_OBJECT;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment