Commit fa0146bc authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Bug 518481 – URL shortcuts do not open query part

2009-04-01  Alexander Larsson  <alexl@redhat.com>

	Bug 518481 – URL shortcuts do not open query part

	* libnautilus-private/nautilus-file-private.h:
	* libnautilus-private/nautilus-file.[ch]:
	* libnautilus-private/nautilus-desktop-icon-file.c:
        (update_info_from_link):
	* libnautilus-private/nautilus-directory-async.c:
        (lacks_mount):
        (link_info_done):
	* libnautilus-private/nautilus-search-directory-file.c:
        (nautilus_search_directory_file_init):
	Store NautilusFile activation uri as char *uri, not
	GFile, as we sometimes handle links that are not true
	GFile locations such as mailto: links in desktop files.

	* libnautilus-private/nautilus-desktop-link.[ch]:
        Add nautilus_desktop_link_get_activation_uri

	* libnautilus-private/nautilus-directory.c:
        (nautilus_directory_notify_files_added_by_uri):
        (nautilus_directory_notify_files_changed_by_uri):
        (nautilus_directory_notify_files_removed_by_uri):
        (nautilus_directory_schedule_metadata_remove_by_uri):
	Use public nautilus_file_list_from_uris instead of local
	copy of it.

	* libnautilus-private/nautilus-mime-actions.c:
	Store both NautilusFile and char *uri in ApplicationLaunchParameters.
	This allows us to correctly handle uris that don't work well as
	GFiles and pass them unmodified to the launched applications.

	* libnautilus-private/nautilus-program-choosing.[ch]:
	Add nautilus_launch_application_by_uri() that launches an application
	by specifying the file as a uri, so that we can handle uris that
	don't work well as GFile/NautilusFiles.



svn path=/trunk/; revision=15157
parent 4bee77be
2009-04-01 Alexander Larsson <alexl@redhat.com>
Bug 518481 – URL shortcuts do not open query part
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.[ch]:
* libnautilus-private/nautilus-desktop-icon-file.c:
(update_info_from_link):
* libnautilus-private/nautilus-directory-async.c:
(lacks_mount):
(link_info_done):
* libnautilus-private/nautilus-search-directory-file.c:
(nautilus_search_directory_file_init):
Store NautilusFile activation uri as char *uri, not
GFile, as we sometimes handle links that are not true
GFile locations such as mailto: links in desktop files.
* libnautilus-private/nautilus-desktop-link.[ch]:
Add nautilus_desktop_link_get_activation_uri
* libnautilus-private/nautilus-directory.c:
(nautilus_directory_notify_files_added_by_uri):
(nautilus_directory_notify_files_changed_by_uri):
(nautilus_directory_notify_files_removed_by_uri):
(nautilus_directory_schedule_metadata_remove_by_uri):
Use public nautilus_file_list_from_uris instead of local
copy of it.
* libnautilus-private/nautilus-mime-actions.c:
Store both NautilusFile and char *uri in ApplicationLaunchParameters.
This allows us to correctly handle uris that don't work well as
GFiles and pass them unmodified to the launched applications.
* libnautilus-private/nautilus-program-choosing.[ch]:
Add nautilus_launch_application_by_uri() that launches an application
by specifying the file as a uri, so that we can handle uris that
don't work well as GFile/NautilusFiles.
2009-03-31 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-directory-view.c:
......
......@@ -205,10 +205,8 @@ update_info_from_link (NautilusDesktopIconFile *icon_file)
g_object_unref (file->details->icon);
}
file->details->icon = nautilus_desktop_link_get_icon (link);
if (file->details->activation_location) {
g_object_unref (file->details->activation_location);
}
file->details->activation_location = nautilus_desktop_link_get_activation_location (link);
g_free (file->details->activation_uri);
file->details->activation_uri = nautilus_desktop_link_get_activation_uri (link);
file->details->got_link_info = TRUE;
file->details->link_info_is_up_to_date = TRUE;
......
......@@ -319,6 +319,16 @@ nautilus_desktop_link_get_activation_location (NautilusDesktopLink *link)
return NULL;
}
char *
nautilus_desktop_link_get_activation_uri (NautilusDesktopLink *link)
{
if (link->details->activation_location) {
return g_file_get_uri (link->details->activation_location);
}
return NULL;
}
gboolean
nautilus_desktop_link_get_date (NautilusDesktopLink *link,
NautilusDateType date_type,
......
......@@ -67,6 +67,7 @@ char * nautilus_desktop_link_get_file_name (NautilusD
char * nautilus_desktop_link_get_display_name (NautilusDesktopLink *link);
GIcon * nautilus_desktop_link_get_icon (NautilusDesktopLink *link);
GFile * nautilus_desktop_link_get_activation_location (NautilusDesktopLink *link);
char * nautilus_desktop_link_get_activation_uri (NautilusDesktopLink *link);
gboolean nautilus_desktop_link_get_date (NautilusDesktopLink *link,
NautilusDateType date_type,
time_t *date);
......
......@@ -1770,7 +1770,7 @@ lacks_mount (NautilusFile *file)
/* Mountable with a target_uri, could be a mountpoint */
(file->details->type == G_FILE_TYPE_MOUNTABLE &&
file->details->activation_location != NULL)
file->details->activation_uri != NULL)
)
);
......@@ -3622,12 +3622,10 @@ link_info_done (NautilusDirectory *directory,
g_free (file->details->custom_icon);
file->details->custom_icon = NULL;
if (uri) {
if (file->details->activation_location) {
g_object_unref (file->details->activation_location);
file->details->activation_location = NULL;
}
file->details->got_custom_activation_location = TRUE;
file->details->activation_location = g_file_new_for_uri (uri);
g_free (file->details->activation_uri);
file->details->activation_uri = NULL;
file->details->got_custom_activation_uri = TRUE;
file->details->activation_uri = g_strdup (uri);
}
if (is_trusted) {
file->details->custom_icon = g_strdup (icon);
......
......@@ -1038,24 +1038,6 @@ nautilus_directory_notify_files_added (GList *files)
g_hash_table_destroy (parent_directories);
}
static GList *
uri_list_to_file_list (GList *uris)
{
GList *l, *file_list;
const char *uri;
GFile *file;
file_list = NULL;
for (l = uris; l != NULL; l = l->next) {
uri = l->data;
file = g_file_new_for_uri (uri);
file_list = g_list_prepend (file_list, file);
}
return g_list_reverse (file_list);
}
static void
g_file_pair_free (GFilePair *pair)
{
......@@ -1089,7 +1071,7 @@ nautilus_directory_notify_files_added_by_uri (GList *uris)
{
GList *files;
files = uri_list_to_file_list (uris);
files = nautilus_file_list_from_uris (uris);
nautilus_directory_notify_files_added (files);
eel_g_object_list_free (files);
}
......@@ -1136,7 +1118,7 @@ nautilus_directory_notify_files_changed_by_uri (GList *uris)
{
GList *files;
files = uri_list_to_file_list (uris);
files = nautilus_file_list_from_uris (uris);
nautilus_directory_notify_files_changed (files);
eel_g_object_list_free (files);
}
......@@ -1194,7 +1176,7 @@ nautilus_directory_notify_files_removed_by_uri (GList *uris)
{
GList *files;
files = uri_list_to_file_list (uris);
files = nautilus_file_list_from_uris (uris);
nautilus_directory_notify_files_changed (files);
eel_g_object_list_free (files);
}
......@@ -1595,7 +1577,7 @@ nautilus_directory_schedule_metadata_remove_by_uri (GList *uris)
{
GList *files;
files = uri_list_to_file_list (uris);
files = nautilus_file_list_from_uris (uris);
nautilus_directory_schedule_metadata_remove (files);
eel_g_object_list_free (files);
}
......
......@@ -111,7 +111,7 @@ struct NautilusFileDetails
/* Info you might get from a link (.desktop, .directory or nautilus link) */
char *custom_icon;
GFile *activation_location;
char *activation_uri;
/* used during DND, for checking whether source and destination are on
* the same file system.
......@@ -183,7 +183,7 @@ struct NautilusFileDetails
eel_boolean_bit got_link_info : 1;
eel_boolean_bit link_info_is_up_to_date : 1;
eel_boolean_bit got_custom_display_name : 1;
eel_boolean_bit got_custom_activation_location : 1;
eel_boolean_bit got_custom_activation_uri : 1;
eel_boolean_bit thumbnail_is_up_to_date : 1;
eel_boolean_bit thumbnail_wants_original : 1;
......
......@@ -279,10 +279,10 @@ nautilus_file_clear_info (NautilusFile *file)
nautilus_file_clear_display_name (file);
}
if (!file->details->got_custom_activation_location &&
file->details->activation_location != NULL) {
g_object_unref (file->details->activation_location);
file->details->activation_location = NULL;
if (!file->details->got_custom_activation_uri &&
file->details->activation_uri != NULL) {
g_free (file->details->activation_uri);
file->details->activation_uri = NULL;
}
if (file->details->icon != NULL) {
......@@ -650,9 +650,7 @@ finalize (GObject *object)
g_free (file->details->description);
g_free (file->details->top_left_text);
g_free (file->details->custom_icon);
if (file->details->activation_location) {
g_object_unref (file->details->activation_location);
}
g_free (file->details->activation_uri);
g_free (file->details->compare_by_emblem_cache);
if (file->details->thumbnail) {
......@@ -1556,7 +1554,7 @@ update_info_internal (NautilusFile *file,
const char *symlink_name, *mime_type, *selinux_context, *name, *thumbnail_path;
GFileType file_type;
GIcon *icon;
GFile *old_activation_location;
char *old_activation_uri;
const char *activation_uri;
const char *description;
const char *filesystem_id;
......@@ -1599,24 +1597,24 @@ update_info_internal (NautilusFile *file,
}
file->details->type = file_type;
if (!file->details->got_custom_activation_location) {
if (!file->details->got_custom_activation_uri) {
activation_uri = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
if (activation_uri == NULL) {
if (file->details->activation_location) {
g_object_unref (file->details->activation_location);
file->details->activation_location = NULL;
if (file->details->activation_uri) {
g_free (file->details->activation_uri);
file->details->activation_uri = NULL;
changed = TRUE;
}
} else {
old_activation_location = file->details->activation_location;
file->details->activation_location = g_file_new_for_uri (activation_uri);
old_activation_uri = file->details->activation_uri;
file->details->activation_uri = g_strdup (activation_uri);
if (old_activation_location) {
if (!g_file_equal (old_activation_location,
file->details->activation_location)) {
if (old_activation_uri) {
if (strcmp (old_activation_uri,
file->details->activation_uri) != 0) {
changed = TRUE;
}
g_object_unref (old_activation_location);
g_free (old_activation_uri);
} else {
changed = TRUE;
}
......@@ -3236,7 +3234,7 @@ nautilus_file_is_trusted_link (NautilusFile *file)
gboolean
nautilus_file_has_activation_uri (NautilusFile *file)
{
return file->details->activation_location != NULL;
return file->details->activation_uri != NULL;
}
......@@ -3249,8 +3247,8 @@ nautilus_file_get_activation_uri (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (file->details->activation_location != NULL) {
return g_file_get_uri (file->details->activation_location);
if (file->details->activation_uri != NULL) {
return g_strdup (file->details->activation_uri);
}
return nautilus_file_get_uri (file);
......@@ -3261,8 +3259,8 @@ nautilus_file_get_activation_location (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
if (file->details->activation_location != NULL) {
return g_object_ref (file->details->activation_location);
if (file->details->activation_uri != NULL) {
return g_file_new_for_uri (file->details->activation_uri);
}
return nautilus_file_get_location (file);
......@@ -6846,6 +6844,23 @@ nautilus_file_list_copy (GList *list)
return g_list_copy (nautilus_file_list_ref (list));
}
GList *
nautilus_file_list_from_uris (GList *uri_list)
{
GList *l, *file_list;
const char *uri;
GFile *file;
file_list = NULL;
for (l = uri_list; l != NULL; l = l->next) {
uri = l->data;
file = g_file_new_for_uri (uri);
file_list = g_list_prepend (file_list, file);
}
return g_list_reverse (file_list);
}
static int
compare_by_display_name_cover (gconstpointer a, gconstpointer b)
{
......
......@@ -434,6 +434,7 @@ GList * nautilus_file_list_ref (GList
void nautilus_file_list_unref (GList *file_list);
void nautilus_file_list_free (GList *file_list);
GList * nautilus_file_list_copy (GList *file_list);
GList * nautilus_file_list_from_uris (GList *uri_list);
GList * nautilus_file_list_sort_by_display_name (GList *file_list);
void nautilus_file_list_call_when_ready (GList *file_list,
NautilusFileAttributes attributes,
......
This diff is collapsed.
......@@ -138,16 +138,33 @@ application_cannot_open_location (GAppInfo *application,
* parameter. Provide a parent window for error dialogs.
*
* @application: The application to be launched.
* @files: The files whose locations should be passed as a parameter to the application.
* @uris: The files whose locations should be passed as a parameter to the application.
* @parent_window: A window to use as the parent for any error dialogs.
*/
void
nautilus_launch_application (GAppInfo *application,
GList *files,
GtkWindow *parent_window)
{
GList *uris, *l;
uris = NULL;
for (l = files; l != NULL; l = l->next) {
uris = g_list_prepend (uris, nautilus_file_get_activation_uri (l->data));
}
uris = g_list_reverse (uris);
nautilus_launch_application_by_uri (application, uris,
parent_window);
eel_g_list_free_deep (uris);
}
void
nautilus_launch_application_by_uri (GAppInfo *application,
GList *uris,
GtkWindow *parent_window)
{
char *uri, *uri_scheme;
GList *locations, *uris, *l;
GList *locations, *l;
GFile *location;
NautilusFile *file;
gboolean result;
......@@ -156,25 +173,20 @@ nautilus_launch_application (GAppInfo *application,
NautilusIconInfo *icon;
int count, total;
g_assert (files != NULL);
g_assert (uris != NULL);
/* count the number of uris with local paths */
count = 0;
total = g_list_length (files);
total = g_list_length (uris);
locations = NULL;
uris = NULL;
for (l = files; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
for (l = uris; l != NULL; l = l->next) {
uri = l->data;
location = nautilus_file_get_activation_location (file);
uri = nautilus_file_get_activation_uri (file);
location = g_file_new_for_uri (uri);
if (g_file_is_native (location)) {
count++;
}
locations = g_list_prepend (locations, location);
uris = g_list_prepend (uris, uri);
}
locations = g_list_reverse (locations);
......@@ -183,8 +195,9 @@ nautilus_launch_application (GAppInfo *application,
gdk_app_launch_context_set_screen (launch_context,
gtk_window_get_screen (parent_window));
file = NAUTILUS_FILE (files->data);
file = nautilus_file_get_by_uri (uris->data);
icon = nautilus_file_get_icon (file, 48, 0);
nautilus_file_unref (file);
if (icon) {
gdk_app_launch_context_set_icon_name (launch_context,
nautilus_icon_info_get_used_name (icon));
......@@ -215,7 +228,7 @@ nautilus_launch_application (GAppInfo *application,
if (!result) {
if (error->domain == G_IO_ERROR &&
error->code == G_IO_ERROR_NOT_SUPPORTED) {
uri_scheme = nautilus_file_get_uri_scheme (NAUTILUS_FILE (files->data));
uri_scheme = g_uri_parse_scheme (uris->data);
application_cannot_open_location (application,
file,
uri_scheme,
......@@ -231,15 +244,14 @@ nautilus_launch_application (GAppInfo *application,
}
g_error_free (error);
} else {
for (l = files; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
for (l = uris; l != NULL; l = l->next) {
file = nautilus_file_get_by_uri (l->data);
nautilus_recent_add_file (file, application);
nautilus_file_unref (file);
}
}
eel_g_object_list_free (locations);
eel_g_list_free_deep (uris);
}
/**
......
......@@ -36,6 +36,9 @@ typedef void (*NautilusApplicationChoiceCallback) (GAppInfo
void nautilus_launch_application (GAppInfo *application,
GList *files,
GtkWindow *parent_window);
void nautilus_launch_application_by_uri (GAppInfo *application,
GList *uris,
GtkWindow *parent_window);
void nautilus_launch_application_from_command (GdkScreen *screen,
const char *name,
const char *command_string,
......
......@@ -213,7 +213,7 @@ nautilus_search_directory_file_init (NautilusSearchDirectoryFile *search_file)
file->details->file_info_is_up_to_date = TRUE;
file->details->custom_icon = NULL;
file->details->activation_location = NULL;
file->details->activation_uri = NULL;
file->details->got_link_info = TRUE;
file->details->link_info_is_up_to_date = TRUE;
......
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