Commit c8f91e52 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

GladeProject: ignore resource:// uri on file properties

Add resources URL in file properties support to be on par with GtkBuilder

Fix issue #367 "Glade removes double/triple slashes from URLs"
parent 310ba91c
......@@ -2792,9 +2792,7 @@ update_project_resource_path (GladeProject *project, gchar *path)
if (pspec->value_type == GDK_TYPE_PIXBUF)
{
gchar *fullpath, *relpath;
const gchar *filename;
GFile *fullpath_file;
GObject *pixbuf;
glade_property_get (property, &pixbuf);
......@@ -2802,14 +2800,19 @@ update_project_resource_path (GladeProject *project, gchar *path)
continue;
filename = g_object_get_data (pixbuf, "GladeFileName");
fullpath = glade_project_resource_fullpath (project, filename);
fullpath_file = g_file_new_for_path (fullpath);
relpath = _glade_util_file_get_relative_path (new_resource_path,
fullpath_file);
g_object_set_data_full (pixbuf, "GladeFileName", relpath, g_free);
g_object_unref (fullpath_file);
g_free (fullpath);
if (!g_str_has_prefix (filename, "resource:///"))
{
g_autoptr(GFile) fullpath_file = NULL;
g_autofree gchar *fullpath = NULL;
gchar *relpath;
fullpath = glade_project_resource_fullpath (project, filename);
fullpath_file = g_file_new_for_path (fullpath);
relpath = _glade_util_file_get_relative_path (new_resource_path,
fullpath_file);
g_object_set_data_full (pixbuf, "GladeFileName", relpath, g_free);
}
}
}
}
......
......@@ -743,19 +743,22 @@ glade_property_def_make_object_from_string (GladePropertyDef *
GladeProject * project)
{
GObject *object = NULL;
gchar *fullpath;
if (string == NULL || project == NULL)
return NULL;
if (property_def->pspec->value_type == GDK_TYPE_PIXBUF)
{
g_autofree gchar *fullpath = NULL;
GdkPixbuf *pixbuf;
if (*string == '\0')
return NULL;
fullpath = glade_project_resource_fullpath (project, string);
if (g_str_has_prefix (string, "resource:///"))
fullpath = glade_project_resource_fullpath (project, &string[11]);
else
fullpath = glade_project_resource_fullpath (project, string);
if ((pixbuf = gdk_pixbuf_new_from_file (fullpath, NULL)) == NULL)
{
......@@ -772,8 +775,6 @@ glade_property_def_make_object_from_string (GladePropertyDef *
g_object_set_data_full (object, "GladeFileName",
g_strdup (string), g_free);
}
g_free (fullpath);
}
else if (property_def->pspec->value_type == G_TYPE_FILE)
{
......
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