nautilus r13734 - in trunk: . libnautilus-private src/file-manager
- From: alexl svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r13734 - in trunk: . libnautilus-private src/file-manager
- Date: Wed, 13 Feb 2008 12:22:40 +0000 (GMT)
Author: alexl
Date: Wed Feb 13 12:22:39 2008
New Revision: 13734
URL: http://svn.gnome.org/viewvc/nautilus?rev=13734&view=rev
Log:
2008-02-13 Alexander Larsson <alexl redhat com>
* libnautilus-private/nautilus-file.[ch]:
* libnautilus-private/nautilus-file-private.h:
Add nautilus_file_is_launcher()
* libnautilus-private/nautilus-directory-async.c:
* libnautilus-private/nautilus-dnd.c:
* libnautilus-private/nautilus-link.[ch]
* libnautilus-private/nautilus-mime-actions.c:
* libnautilus-private/nautilus-program-choosing.[ch]:
* src/file-manager/fm-directory-view.c:
* src/file-manager/fm-tree-view.c:
Remove weird desktop-file: and command: hacks, and
replace with usage and implementation of
nautilus_file_is_launcher().
This fixes some problems where the old desktop-file uri
was interpreted as an actual file.
Modified:
trunk/ChangeLog
trunk/libnautilus-private/nautilus-directory-async.c
trunk/libnautilus-private/nautilus-dnd.c
trunk/libnautilus-private/nautilus-file-private.h
trunk/libnautilus-private/nautilus-file.c
trunk/libnautilus-private/nautilus-file.h
trunk/libnautilus-private/nautilus-link.c
trunk/libnautilus-private/nautilus-link.h
trunk/libnautilus-private/nautilus-mime-actions.c
trunk/libnautilus-private/nautilus-program-choosing.c
trunk/libnautilus-private/nautilus-program-choosing.h
trunk/src/file-manager/fm-directory-view.c
trunk/src/file-manager/fm-tree-view.c
Modified: trunk/libnautilus-private/nautilus-directory-async.c
==============================================================================
--- trunk/libnautilus-private/nautilus-directory-async.c (original)
+++ trunk/libnautilus-private/nautilus-directory-async.c Wed Feb 13 12:22:39 2008
@@ -191,7 +191,8 @@
NautilusFile *file,
const char *uri,
const char *name,
- const char *icon);
+ const char *icon,
+ gboolean is_launcher);
static void move_file_to_low_priority_queue (NautilusDirectory *directory,
NautilusFile *file);
static void move_file_to_extension_queue (NautilusDirectory *directory,
@@ -1687,7 +1688,7 @@
if (nautilus_file_is_nautilus_link (file)) {
return TRUE;
} else {
- link_info_done (file->details->directory, file, NULL, NULL, NULL);
+ link_info_done (file->details->directory, file, NULL, NULL, NULL, FALSE);
return FALSE;
}
} else {
@@ -3469,7 +3470,8 @@
NautilusFile *file,
const char *uri,
const char *name,
- const char *icon)
+ const char *icon,
+ gboolean is_launcher)
{
file->details->link_info_is_up_to_date = TRUE;
@@ -3486,6 +3488,7 @@
file->details->activation_location = g_file_new_for_uri (uri);
}
file->details->custom_icon = g_strdup (icon);
+ file->details->is_launcher = is_launcher;
nautilus_directory_async_state_changed (directory);
}
@@ -3531,23 +3534,25 @@
char *file_contents)
{
char *uri, *name, *icon;
+ gboolean is_launcher;
nautilus_directory_ref (directory);
uri = NULL;
name = NULL;
icon = NULL;
+ is_launcher = FALSE;
/* Handle the case where we read the Nautilus link. */
if (result) {
nautilus_link_get_link_info_given_file_contents (file_contents, bytes_read,
- &uri, &name, &icon);
+ &uri, &name, &icon, &is_launcher);
} else {
/* FIXME bugzilla.gnome.org 42433: We should report this error to the user. */
}
nautilus_file_ref (file);
- link_info_done (directory, file, uri, name, icon);
+ link_info_done (directory, file, uri, name, icon, is_launcher);
nautilus_file_changed (file);
nautilus_file_unref (file);
@@ -3633,7 +3638,7 @@
/* If it's not a link we are done. If it is, we need to read it. */
if (!nautilus_style_link) {
- link_info_done (directory, file, NULL, NULL, NULL);
+ link_info_done (directory, file, NULL, NULL, NULL, FALSE);
} else if (should_read_link_info_sync (file)) {
result = g_file_load_contents (location, NULL, &file_contents, &file_size, NULL, NULL);
link_info_got_data (directory, file, result, file_size, file_contents);
Modified: trunk/libnautilus-private/nautilus-dnd.c
==============================================================================
--- trunk/libnautilus-private/nautilus-dnd.c (original)
+++ trunk/libnautilus-private/nautilus-dnd.c Wed Feb 13 12:22:39 2008
@@ -368,6 +368,7 @@
const char *dropped_uri;
GFile *target, *dropped;
GdkDragAction actions;
+ NautilusFile *target_file;
if (target_uri_string == NULL) {
*action = 0;
@@ -388,6 +389,7 @@
}
dropped_uri = ((NautilusDragSelectionItem *)items->data)->uri;
+ target_file = nautilus_file_get_existing_by_uri (dropped_uri);
/*
* Check for trash URI. We do a find_directory for any Trash directory.
@@ -400,13 +402,14 @@
*action = GDK_ACTION_MOVE;
}
+ nautilus_file_unref (target_file);
return;
- } else if (g_str_has_prefix (target_uri_string, NAUTILUS_COMMAND_SPECIFIER) ||
- g_str_has_prefix (target_uri_string, NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ) {
+ } else if (target_file != NULL && nautilus_file_is_launcher (target_file)) {
if (actions & GDK_ACTION_MOVE) {
*action = GDK_ACTION_MOVE;
}
+ nautilus_file_unref (target_file);
return;
} else if (eel_uri_is_desktop (target_uri_string)) {
target = nautilus_get_desktop_location ();
@@ -416,12 +419,15 @@
*action = GDK_ACTION_MOVE;
}
+ nautilus_file_unref (target_file);
return;
}
} else {
target = g_file_new_for_uri (target_uri_string);
}
+ nautilus_file_unref (target_file);
+
/* Compare the first dropped uri with the target uri for same fs match. */
dropped = g_file_new_for_uri (dropped_uri);
same_fs = check_same_fs (target, dropped);
Modified: trunk/libnautilus-private/nautilus-file-private.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file-private.h (original)
+++ trunk/libnautilus-private/nautilus-file-private.h Wed Feb 13 12:22:39 2008
@@ -189,6 +189,7 @@
/* TRUE if the file is open in a spatial window */
eel_boolean_bit has_open_window : 1;
+ eel_boolean_bit is_launcher : 1;
eel_boolean_bit is_symlink : 1;
eel_boolean_bit is_mountpoint : 1;
eel_boolean_bit is_hidden : 1;
Modified: trunk/libnautilus-private/nautilus-file.c
==============================================================================
--- trunk/libnautilus-private/nautilus-file.c (original)
+++ trunk/libnautilus-private/nautilus-file.c Wed Feb 13 12:22:39 2008
@@ -322,6 +322,7 @@
file->details->thumbnail_path = NULL;
file->details->thumbnailing_failed = FALSE;
+ file->details->is_launcher = FALSE;
file->details->is_symlink = FALSE;
file->details->is_hidden = FALSE;
file->details->is_backup = FALSE;
@@ -3031,6 +3032,12 @@
}
gboolean
+nautilus_file_is_launcher (NautilusFile *file)
+{
+ return file->details->is_launcher;
+}
+
+gboolean
nautilus_file_has_activation_uri (NautilusFile *file)
{
return file->details->activation_location != NULL;
Modified: trunk/libnautilus-private/nautilus-file.h
==============================================================================
--- trunk/libnautilus-private/nautilus-file.h (original)
+++ trunk/libnautilus-private/nautilus-file.h Wed Feb 13 12:22:39 2008
@@ -376,6 +376,7 @@
/* Get the URI that's used when activating the file.
* Getting this can require reading the contents of the file.
*/
+gboolean nautilus_file_is_launcher (NautilusFile *file);
gboolean nautilus_file_has_activation_uri (NautilusFile *file);
char * nautilus_file_get_activation_uri (NautilusFile *file);
GFile * nautilus_file_get_activation_location (NautilusFile *file);
Modified: trunk/libnautilus-private/nautilus-link.c
==============================================================================
--- trunk/libnautilus-private/nautilus-link.c (original)
+++ trunk/libnautilus-private/nautilus-link.c Wed Feb 13 12:22:39 2008
@@ -298,7 +298,6 @@
static char *
nautilus_link_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
{
- const char *launch_string;
const char *type;
char *retval;
@@ -309,15 +308,7 @@
return NULL;
}
- if (strcmp (type, "Application") == 0) {
- launch_string = gnome_desktop_item_get_string (desktop_file, "Exec");
- if (launch_string == NULL) {
- return NULL;
- }
-
- launch_string = gnome_desktop_item_get_location (desktop_file);
- retval = g_strconcat (NAUTILUS_DESKTOP_COMMAND_SPECIFIER, launch_string, NULL);
- } else if (strcmp (type, "URL") == 0) {
+ if (strcmp (type, "URL") == 0) {
/* Some old broken desktop files use this nonstandard feature, we need handle it though */
retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "Exec"));
} else if ((strcmp (type, NAUTILUS_LINK_GENERIC_TAG) == 0) ||
@@ -405,9 +396,11 @@
int link_file_size,
char **uri,
char **name,
- char **icon)
+ char **icon,
+ gboolean *is_launcher)
{
GnomeDesktopItem *desktop_file;
+ const char *type;
if (!is_link_data (file_contents, link_file_size)) {
return;
@@ -422,6 +415,14 @@
*name = nautilus_link_get_link_name_from_desktop (desktop_file);
*icon = nautilus_link_get_link_icon_from_desktop (desktop_file);
+ *is_launcher = FALSE;
+ type = gnome_desktop_item_get_string (desktop_file, "Type");
+ if (type != NULL &&
+ strcmp (type, "Application") == 0 &&
+ gnome_desktop_item_get_string (desktop_file, "Exec") != NULL) {
+ *is_launcher = TRUE;
+ }
+
gnome_desktop_item_unref (desktop_file);
}
Modified: trunk/libnautilus-private/nautilus-link.h
==============================================================================
--- trunk/libnautilus-private/nautilus-link.h (original)
+++ trunk/libnautilus-private/nautilus-link.h Wed Feb 13 12:22:39 2008
@@ -45,7 +45,8 @@
int link_file_size,
char **uri,
char **name,
- char **icon);
+ char **icon,
+ gboolean *is_launcher);
void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *entry,
const char *dest_uri,
const GdkPoint *position,
Modified: trunk/libnautilus-private/nautilus-mime-actions.c
==============================================================================
--- trunk/libnautilus-private/nautilus-mime-actions.c (original)
+++ trunk/libnautilus-private/nautilus-mime-actions.c Wed Feb 13 12:22:39 2008
@@ -45,7 +45,6 @@
typedef enum {
ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE,
- ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND,
ACTIVATION_ACTION_ASK,
ACTIVATION_ACTION_LAUNCH,
ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
@@ -736,6 +735,10 @@
{
ActivationAction action;
char *activation_uri;
+
+ if (nautilus_file_is_launcher (file)) {
+ return ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE;
+ }
activation_uri = nautilus_file_get_activation_uri (file);
if (activation_uri == NULL) {
@@ -743,12 +746,7 @@
}
action = ACTIVATION_ACTION_DO_NOTHING;
-
- if (eel_str_has_prefix (activation_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
- action = ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE;
- } else if (eel_str_has_prefix (activation_uri, NAUTILUS_COMMAND_SPECIFIER)) {
- action = ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND;
- } else if (nautilus_file_is_launchable (file)) {
+ if (nautilus_file_is_launchable (file)) {
char *executable_path;
action = ACTIVATION_ACTION_LAUNCH;
@@ -1004,7 +1002,6 @@
{
NautilusFile *file;
GList *launch_desktop_files;
- GList *launch_from_command_files;
GList *launch_files;
GList *launch_in_terminal_files;
GList *open_in_app_files;
@@ -1023,7 +1020,6 @@
screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));
launch_desktop_files = NULL;
- launch_from_command_files = NULL;
launch_files = NULL;
launch_in_terminal_files = NULL;
open_in_app_files = NULL;
@@ -1048,9 +1044,6 @@
case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE :
launch_desktop_files = g_list_prepend (launch_desktop_files, file);
break;
- case ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND :
- launch_from_command_files = g_list_prepend (launch_from_command_files, file);
- break;
case ACTIVATION_ACTION_LAUNCH :
launch_files = g_list_prepend (launch_files, file);
break;
@@ -1084,22 +1077,6 @@
g_free (uri);
}
- launch_from_command_files = g_list_reverse (launch_from_command_files);
- for (l = launch_from_command_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_activation_uri (file);
-
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "directory view activate_callback launch_application_from_command window=%p: %s",
- parameters->parent_window, uri);
-
- nautilus_launch_application_from_command (
- screen, NULL, uri + strlen (NAUTILUS_COMMAND_SPECIFIER),
- NULL, FALSE);
- g_free (uri);
- }
-
old_working_dir = NULL;
if (parameters->activation_directory &&
(launch_files != NULL || launch_in_terminal_files != NULL)) {
@@ -1240,7 +1217,6 @@
}
g_list_free (launch_desktop_files);
- g_list_free (launch_from_command_files);
g_list_free (launch_files);
g_list_free (launch_in_terminal_files);
g_list_free (open_in_view_files);
@@ -1407,9 +1383,7 @@
* about the attributes for that, not for the original file.
*/
uri = nautilus_file_get_activation_uri (file);
- if (uri != NULL &&
- !(g_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ||
- g_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER))) {
+ if (uri != NULL) {
NautilusFile *actual_file;
actual_file = nautilus_file_get_by_uri (uri);
Modified: trunk/libnautilus-private/nautilus-program-choosing.c
==============================================================================
--- trunk/libnautilus-private/nautilus-program-choosing.c (original)
+++ trunk/libnautilus-private/nautilus-program-choosing.c Wed Feb 13 12:22:39 2008
@@ -369,11 +369,6 @@
GFile *file;
Time timestamp;
- /* strip the leading command specifier */
- if (eel_str_has_prefix (desktop_file_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
- desktop_file_uri += strlen (NAUTILUS_DESKTOP_COMMAND_SPECIFIER);
- }
-
/* Don't allow command execution from remote locations where the
* uri scheme isn't file:// (This is because files on for example
* nfs are treated as remote) to partially mitigate the security
Modified: trunk/libnautilus-private/nautilus-program-choosing.h
==============================================================================
--- trunk/libnautilus-private/nautilus-program-choosing.h (original)
+++ trunk/libnautilus-private/nautilus-program-choosing.h Wed Feb 13 12:22:39 2008
@@ -30,9 +30,6 @@
#include <gio/gio.h>
#include <libnautilus-private/nautilus-file.h>
-#define NAUTILUS_COMMAND_SPECIFIER "command:"
-#define NAUTILUS_DESKTOP_COMMAND_SPECIFIER "desktop-file:"
-
typedef void (*NautilusApplicationChoiceCallback) (GAppInfo *application,
gpointer callback_data);
Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c (original)
+++ trunk/src/file-manager/fm-directory-view.c Wed Feb 13 12:22:39 2008
@@ -6623,11 +6623,13 @@
file = NAUTILUS_FILE (l->data);
if (nautilus_file_is_nautilus_link (file) &&
!NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
+ if (nautilus_file_is_launcher (file)) {
+ return FALSE;
+ }
+
activation_uri = nautilus_file_get_activation_uri (file);
- if (activation_uri == NULL ||
- eel_str_has_prefix (activation_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ||
- eel_str_has_prefix (activation_uri, NAUTILUS_COMMAND_SPECIFIER)) {
+ if (activation_uri == NULL) {
g_free (activation_uri);
return FALSE;
}
@@ -8176,8 +8178,7 @@
int x, int y,
FMDirectoryView *view)
{
- char *parameters, *temp;
- GList *p;
+ NautilusFile *target_file;
g_assert (relative_item_points == NULL
|| relative_item_points->len == 0
@@ -8186,32 +8187,17 @@
/* add the drop location to the icon offsets */
offset_drop_points (relative_item_points, x, y);
+ target_file = nautilus_file_get_existing_by_uri (target_uri);
/* special-case "command:" here instead of starting a move/copy */
- if (eel_str_has_prefix (target_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ if (target_file != NULL && nautilus_file_is_launcher (target_file)) {
+ nautilus_file_unref (target_file);
nautilus_launch_desktop_file (
gtk_widget_get_screen (GTK_WIDGET (view)),
target_uri, item_uris,
fm_directory_view_get_containing_window (view));
return;
- } else if (eel_str_has_prefix (target_uri, NAUTILUS_COMMAND_SPECIFIER)) {
- parameters = NULL;
- for (p = (GList *) item_uris; p != NULL; p = p->next) {
- temp = g_strconcat ((char *) p->data, " ", parameters, NULL);
- if (parameters != NULL) {
- g_free (parameters);
- }
- parameters = temp;
- }
-
- target_uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
-
- nautilus_launch_application_from_command (
- gtk_widget_get_screen (GTK_WIDGET (view)),
- NULL, target_uri, parameters, FALSE);
- g_free (parameters);
-
- return;
}
+ nautilus_file_unref (target_file);
nautilus_file_operations_copy_move
(item_uris, relative_item_points,
Modified: trunk/src/file-manager/fm-tree-view.c
==============================================================================
--- trunk/src/file-manager/fm-tree-view.c (original)
+++ trunk/src/file-manager/fm-tree-view.c Wed Feb 13 12:22:39 2008
@@ -344,28 +344,14 @@
mode = view->details->activation_in_new_window ? NAUTILUS_WINDOW_OPEN_IN_NAVIGATION : NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE;
- /* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
-
uri = nautilus_file_get_activation_uri (file);
- if (uri != NULL
- && g_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
-
- uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "tree view launch_application_from_command window=%p: %s",
- view->details->window, uri);
- nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
-
- } else if (uri != NULL
- && g_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
-
+ if (nautilus_file_is_launcher (file)) {
file_uri = nautilus_file_get_uri (file);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"tree view launch_desktop_file window=%p: %s",
view->details->window, file_uri);
nautilus_launch_desktop_file (screen, file_uri, NULL, NULL);
g_free (file_uri);
-
} else if (uri != NULL
&& nautilus_file_is_executable (file)
&& nautilus_file_can_execute (file)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]