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,
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,
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
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