Commit f061314d authored by Christian Neumair's avatar Christian Neumair Committed by Christian Neumair

Pass link info's URI to nautilus_link_get_link_info_given_file_contents().

2008-09-27  Christian Neumair  <cneumair@gnome.org>

	* libnautilus-private/nautilus-directory-async.c
	(link_info_got_data):
	Pass link info's URI to
	nautilus_link_get_link_info_given_file_contents().

	* libnautilus-private/nautilus-link.c
	(nautilus_link_get_link_uri_from_desktop),
	(nautilus_link_get_link_info_given_file_contents):
	* libnautilus-private/nautilus-link.h:
	Add an input parameter for the link info's URI to
	nautilus_link_get_link_info_given_file_contents().
	In nautilus_link_get_link_uri_from_desktop(), when
	a desktop icon has an "URI=filename" entry resolve
	it like a symbolic link name relative to the link
	info parent. Ideally, we'd have
	g_file_parse_name_relative() which could do that for us,
	but it would mangle URI's fragments and queries anyway.

svn path=/trunk/; revision=14668
parent a6f76dc3
2008-09-27 Christian Neumair <cneumair@gnome.org>
* libnautilus-private/nautilus-directory-async.c
(link_info_got_data):
Pass link info's URI to
nautilus_link_get_link_info_given_file_contents().
* libnautilus-private/nautilus-link.c
(nautilus_link_get_link_uri_from_desktop),
(nautilus_link_get_link_info_given_file_contents):
* libnautilus-private/nautilus-link.h:
Add an input parameter for the link info's URI to
nautilus_link_get_link_info_given_file_contents().
In nautilus_link_get_link_uri_from_desktop(), when
a desktop icon has an "URI=filename" entry resolve
it like a symbolic link name relative to the link
info parent. Ideally, we'd have
g_file_parse_name_relative() which could do that for us,
but it would mangle URI's fragments and queries anyway.
2008-09-24 Christian Neumair <cneumair@gnome.org>
* src/nautilus-application.c (count_slots_of_windows),
......
......@@ -3620,7 +3620,7 @@ link_info_got_data (NautilusDirectory *directory,
goffset bytes_read,
char *file_contents)
{
char *uri, *name, *icon;
char *link_uri, *uri, *name, *icon;
gboolean is_launcher;
nautilus_directory_ref (directory);
......@@ -3632,8 +3632,10 @@ link_info_got_data (NautilusDirectory *directory,
/* Handle the case where we read the Nautilus link. */
if (result) {
nautilus_link_get_link_info_given_file_contents (file_contents, bytes_read,
link_uri = nautilus_file_get_uri (file);
nautilus_link_get_link_info_given_file_contents (file_contents, bytes_read, link_uri,
&uri, &name, &icon, &is_launcher);
g_free (link_uri);
} else {
/* FIXME bugzilla.gnome.org 42433: We should report this error to the user. */
}
......
......@@ -298,8 +298,10 @@ nautilus_link_local_get_additional_text (const char *path)
static char *
nautilus_link_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
{
GFile *file, *parent;
const char *type;
char *retval;
char *scheme;
retval = NULL;
......@@ -318,6 +320,28 @@ nautilus_link_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "URL"));
}
if (retval != NULL) {
/* Handle local file names.
* Ideally, we'd be able to use
* g_file_parse_name(), but it does not know how to resolve
* relative file names, since the base directory is unknown.
*/
scheme = g_uri_parse_scheme (retval);
if (scheme == NULL) {
file = g_file_new_for_uri (gnome_desktop_item_get_location (desktop_file));
parent = g_file_get_parent (file);
g_object_unref (file);
if (parent != NULL) {
file = g_file_resolve_relative_path (parent, retval);
g_free (retval);
retval = g_file_get_uri (file);
g_object_unref (file);
g_object_unref (parent);
}
}
}
return retval;
}
......@@ -409,6 +433,7 @@ nautilus_link_local_get_link_uri (const char *uri)
void
nautilus_link_get_link_info_given_file_contents (const char *file_contents,
int link_file_size,
const char *file_uri,
char **uri,
char **name,
char **icon,
......@@ -426,6 +451,8 @@ nautilus_link_get_link_info_given_file_contents (const char *file_contents,
return;
}
gnome_desktop_item_set_location (desktop_file, file_uri);
*uri = nautilus_link_get_link_uri_from_desktop (desktop_file);
*name = nautilus_link_get_link_name_from_desktop (desktop_file);
*icon = nautilus_link_get_link_icon_from_desktop (desktop_file);
......
......@@ -43,6 +43,7 @@ char * nautilus_link_local_get_additional_text (const char
char * nautilus_link_local_get_link_uri (const char *uri);
void nautilus_link_get_link_info_given_file_contents (const char *file_contents,
int link_file_size,
const char *file_uri,
char **uri,
char **name,
char **icon,
......
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