File libfm-0.1.14-fix_sf3089624.patch of Package libfm
From 96fa31c757189c7c5f60d4de4c2df236d2cba0ea Mon Sep 17 00:00:00 2001
From: Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
Date: Wed, 20 Oct 2010 06:40:51 +0800
Subject: [PATCH] Fix #3089625 - Filenames with spaces not supported in copy/paste.
---
src/base/fm-file-launcher.c | 2 +-
src/base/fm-folder.c | 6 +-
src/base/fm-path.c | 2 +-
src/gtk/fm-folder-view.c | 130 +++++++++++++++++++++---------------------
src/gtk/fm-gtk-utils.c | 10 +--
src/gtk/fm-path-entry.c | 2 +-
6 files changed, 75 insertions(+), 77 deletions(-)
diff --git a/src/base/fm-file-launcher.c b/src/base/fm-file-launcher.c
index 3857c33..c356249 100644
--- a/src/base/fm-file-launcher.c
+++ b/src/base/fm-file-launcher.c
@@ -91,7 +91,7 @@ gboolean fm_launch_desktop_entry(GAppLaunchContext* ctx, const char* file_or_id,
* e.g: If this URL points to the another desktop entry file, and it
* points to yet another desktop entry file, this can create a
* infinite loop. This is a extremely rare case. */
- FmPath* path = fm_path_new(url);
+ FmPath* path = fm_path_new_for_uri(url);
_uris = g_list_prepend(_uris, path);
ret = fm_launch_paths(ctx, _uris, launcher, user_data);
g_list_free(_uris);
diff --git a/src/base/fm-folder.c b/src/base/fm-folder.c
index ccbb3cc..3474937 100644
--- a/src/base/fm-folder.c
+++ b/src/base/fm-folder.c
@@ -334,8 +334,8 @@ static void on_job_finished(FmDirListJob* job, FmFolder* folder)
static FmJobErrorAction on_job_err(FmDirListJob* job, GError* err, FmJobErrorSeverity severity, FmFolder* folder)
{
- FmJobErrorAction ret;
- g_signal_emit(folder, signals[ERROR], 0, err, severity, &ret);
+ FmJobErrorAction ret;
+ g_signal_emit(folder, signals[ERROR], 0, err, severity, &ret);
return ret;
}
@@ -470,7 +470,7 @@ FmFolder* fm_folder_get_for_path(FmPath* path)
FmFolder* fm_folder_get_for_path_name(const char* path)
{
- FmPath* fm_path = fm_path_new(path);
+ FmPath* fm_path = fm_path_new_for_str(path);
FmFolder* folder = fm_folder_get_internal(fm_path, NULL);
fm_path_unref(fm_path);
return folder;
diff --git a/src/base/fm-path.c b/src/base/fm-path.c
index ca62256..8b31de2 100644
--- a/src/base/fm-path.c
+++ b/src/base/fm-path.c
@@ -926,7 +926,7 @@ FmPathList* fm_path_list_new_from_uris(const char** uris)
FmPathList* pl = fm_path_list_new();
for(uri = uris; *uri; ++uri)
{
- FmPath* path = fm_path_new(*uri);
+ FmPath* path = fm_path_new_for_uri(*uri);
fm_list_push_tail_noref(pl, path);
}
return pl;
diff --git a/src/gtk/fm-folder-view.c b/src/gtk/fm-folder-view.c
index fab88c0..9943015 100644
--- a/src/gtk/fm-folder-view.c
+++ b/src/gtk/fm-folder-view.c
@@ -41,8 +41,8 @@
enum{
CHDIR,
- LOADED,
- STATUS,
+ LOADED,
+ STATUS,
CLICKED,
SEL_CHANGED,
SORT_CHANGED,
@@ -82,7 +82,7 @@ static void fm_folder_view_class_init(FmFolderViewClass *klass)
{
GObjectClass *g_object_class;
GtkWidgetClass *widget_class;
- FmFolderViewClass *fv_class;
+ FmFolderViewClass *fv_class;
g_object_class = G_OBJECT_CLASS(klass);
g_object_class->finalize = fm_folder_view_finalize;
widget_class = GTK_WIDGET_CLASS(klass);
@@ -165,19 +165,19 @@ gboolean on_folder_view_focus_in(GtkWidget* widget, GdkEventFocus* evt)
void on_chdir(FmFolderView* fv, FmPath* dir_path)
{
- GtkWidget* toplevel = gtk_widget_get_toplevel((GtkWidget*)fv);
- if(GTK_WIDGET_REALIZED(toplevel))
- {
- GdkCursor* cursor = gdk_cursor_new(GDK_WATCH);
- gdk_window_set_cursor(toplevel->window, cursor);
- }
+ GtkWidget* toplevel = gtk_widget_get_toplevel((GtkWidget*)fv);
+ if(GTK_WIDGET_REALIZED(toplevel))
+ {
+ GdkCursor* cursor = gdk_cursor_new(GDK_WATCH);
+ gdk_window_set_cursor(toplevel->window, cursor);
+ }
}
void on_loaded(FmFolderView* fv, FmPath* dir_path)
{
- GtkWidget* toplevel = gtk_widget_get_toplevel((GtkWidget*)fv);
- if(GTK_WIDGET_REALIZED(toplevel))
- gdk_window_set_cursor(toplevel->window, NULL);
+ GtkWidget* toplevel = gtk_widget_get_toplevel((GtkWidget*)fv);
+ if(GTK_WIDGET_REALIZED(toplevel))
+ gdk_window_set_cursor(toplevel->window, NULL);
}
void on_status(FmFolderView* fv, const char* msg)
@@ -187,15 +187,15 @@ void on_status(FmFolderView* fv, const char* msg)
void on_model_loaded(FmFolderModel* model, FmFolderView* fv)
{
- FmFolder* folder = model->dir;
- char* msg;
- /* FIXME: prevent direct access to data members */
- g_signal_emit(fv, signals[LOADED], 0, folder->dir_path);
+ FmFolder* folder = model->dir;
+ char* msg;
+ /* FIXME: prevent direct access to data members */
+ g_signal_emit(fv, signals[LOADED], 0, folder->dir_path);
/* FIXME: show number of hidden files and available disk spaces. */
- msg = g_strdup_printf("%d files are listed.", fm_list_get_length(folder->files) );
- g_signal_emit(fv, signals[STATUS], 0, msg);
- g_free(msg);
+ msg = g_strdup_printf("%d files are listed.", fm_list_get_length(folder->files) );
+ g_signal_emit(fv, signals[STATUS], 0, msg);
+ g_free(msg);
}
FmJobErrorAction on_folder_err(FmFolder* folder, GError* err, FmJobErrorSeverity severity, FmFolderView* fv)
@@ -326,8 +326,8 @@ static void fm_folder_view_finalize(GObject *object)
if( self->model )
g_object_unref(self->model);
}
- g_object_unref(self->dnd_src);
- g_object_unref(self->dnd_dest);
+ g_object_unref(self->dnd_src);
+ g_object_unref(self->dnd_dest);
if(self->cwd)
fm_path_unref(self->cwd);
@@ -715,15 +715,15 @@ void fm_folder_view_set_mode(FmFolderView* fv, FmFolderViewMode mode)
/* FIXME: maybe calling set_icon_size here is a good idea */
- gtk_drag_source_set(fv->view, GDK_BUTTON1_MASK,
- fm_default_dnd_src_targets, N_FM_DND_SRC_DEFAULT_TARGETS,
- GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
+ gtk_drag_source_set(fv->view, GDK_BUTTON1_MASK,
+ fm_default_dnd_src_targets, N_FM_DND_SRC_DEFAULT_TARGETS,
+ GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
fm_dnd_src_set_widget(fv->dnd_src, fv->view);
- gtk_drag_dest_set(fv->view, 0,
- fm_default_dnd_dest_targets, N_FM_DND_DEST_DEFAULT_TARGETS,
- GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
- fm_dnd_dest_set_widget(fv->dnd_dest, fv->view);
+ gtk_drag_dest_set(fv->view, 0,
+ fm_default_dnd_dest_targets, N_FM_DND_DEST_DEFAULT_TARGETS,
+ GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_LINK|GDK_ACTION_ASK);
+ fm_dnd_dest_set_widget(fv->dnd_dest, fv->view);
g_signal_connect_after(fv->view, "drag-motion", G_CALLBACK(on_drag_motion), fv);
g_signal_connect(fv->view, "drag-leave", G_CALLBACK(on_drag_leave), fv);
g_signal_connect(fv->view, "drag-drop", G_CALLBACK(on_drag_drop), fv);
@@ -739,9 +739,9 @@ void fm_folder_view_set_mode(FmFolderView* fv, FmFolderViewMode mode)
gtk_widget_grab_focus(fv->view);
}
else
- {
+ {
/* g_debug("same mode"); */
- }
+ }
}
FmFolderViewMode fm_folder_view_get_mode(FmFolderView* fv)
@@ -785,7 +785,7 @@ void fm_folder_view_sort(FmFolderView* fv, GtkSortType type, int by)
fv->sort_by = by;
if(fv->model)
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(fv->model),
- fv->sort_by, fv->sort_type);
+ fv->sort_by, fv->sort_type);
}
GtkSortType fm_folder_view_get_sort_type(FmFolderView* fv)
@@ -815,18 +815,18 @@ gboolean fm_folder_view_get_show_hidden(FmFolderView* fv)
gboolean fm_folder_view_chdir_by_name(FmFolderView* fv, const char* path_str)
{
- gboolean ret;
- FmPath* path;
+ gboolean ret;
+ FmPath* path;
if( G_UNLIKELY( !path_str ) )
return FALSE;
- path = fm_path_new(path_str);
- if(!path) /* might be a malformed path */
- return FALSE;
- ret = fm_folder_view_chdir(fv, path);
- fm_path_unref(path);
- return ret;
+ path = fm_path_new_for_str(path_str);
+ if(!path) /* might be a malformed path */
+ return FALSE;
+ ret = fm_folder_view_chdir(fv, path);
+ fm_path_unref(path);
+ return ret;
}
static void on_folder_unmounted(FmFolder* folder, FmFolderView* fv)
@@ -912,10 +912,10 @@ gboolean fm_folder_view_chdir(FmFolderView* fv, FmPath* path)
}
}
- /* FIXME: the signal handler should be able to cancel the loading. */
- g_signal_emit(fv, signals[CHDIR], 0, path);
- if(fv->cwd)
- fm_path_unref(fv->cwd);
+ /* FIXME: the signal handler should be able to cancel the loading. */
+ g_signal_emit(fv, signals[CHDIR], 0, path);
+ if(fv->cwd)
+ fm_path_unref(fv->cwd);
fv->cwd = fm_path_ref(path);
fv->folder = folder = fm_folder_get_for_path(path);
@@ -1041,12 +1041,12 @@ gboolean on_btn_pressed(GtkWidget* view, GdkEventButton* evt, FmFolderView* fv)
if(!fv->model)
return FALSE;
- /* FIXME: handle single click activation */
+ /* FIXME: handle single click activation */
if( evt->type == GDK_BUTTON_PRESS )
{
- /* special handling for ExoIconView */
- if(evt->button != 1)
- {
+ /* special handling for ExoIconView */
+ if(evt->button != 1)
+ {
if(fv->mode==FM_FV_ICON_VIEW || fv->mode==FM_FV_COMPACT_VIEW || fv->mode==FM_FV_THUMBNAIL_VIEW)
{
/* select the item on right click for ExoIconView */
@@ -1089,27 +1089,27 @@ gboolean on_btn_pressed(GtkWidget* view, GdkEventButton* evt, FmFolderView* fv)
gtk_tree_path_free(tp);
}
}
- }
+ }
- if(evt->button == 2) /* middle click */
- type = FM_FV_MIDDLE_CLICK;
- else if(evt->button == 3) /* right click */
- type = FM_FV_CONTEXT_MENU;
+ if(evt->button == 2) /* middle click */
+ type = FM_FV_MIDDLE_CLICK;
+ else if(evt->button == 3) /* right click */
+ type = FM_FV_CONTEXT_MENU;
}
- if( type != FM_FV_CLICK_NONE )
- {
- sels = fm_folder_view_get_selected_tree_paths(fv);
- if( sels || type == FM_FV_CONTEXT_MENU )
- {
- item_clicked(fv, sels ? sels->data : NULL, type);
- if(sels)
- {
- g_list_foreach(sels, (GFunc)gtk_tree_path_free, NULL);
- g_list_free(sels);
- }
- }
- }
+ if( type != FM_FV_CLICK_NONE )
+ {
+ sels = fm_folder_view_get_selected_tree_paths(fv);
+ if( sels || type == FM_FV_CONTEXT_MENU )
+ {
+ item_clicked(fv, sels ? sels->data : NULL, type);
+ if(sels)
+ {
+ g_list_foreach(sels, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free(sels);
+ }
+ }
+ }
return FALSE;
}
diff --git a/src/gtk/fm-gtk-utils.c b/src/gtk/fm-gtk-utils.c
index 23b6f33..07df7d5 100644
--- a/src/gtk/fm-gtk-utils.c
+++ b/src/gtk/fm-gtk-utils.c
@@ -149,7 +149,7 @@ FmPath* fm_get_user_input_path(GtkWindow* parent, const char* title, const char*
}
str = _fm_user_input_dialog_run( dlg, GTK_ENTRY( entry ) );
- path = fm_path_new(str);
+ path = fm_path_new_for_str(str);
g_free(path_str);
g_free(str);
@@ -261,11 +261,9 @@ FmPath* fm_select_folder(GtkWindow* parent)
GTK_RESPONSE_OK, NULL);
if( gtk_dialog_run((GtkDialog*)chooser) == GTK_RESPONSE_OK )
{
- char* file = gtk_file_chooser_get_filename(chooser);
- if(!file)
- file = gtk_file_chooser_get_uri(chooser);
- path = fm_path_new(file);
- g_free(file);
+ GFile* file = gtk_file_chooser_get_file(chooser);
+ path = fm_path_new_for_gfile(file);
+ g_object_unref(file);
}
else
path = NULL;
diff --git a/src/gtk/fm-path-entry.c b/src/gtk/fm-path-entry.c
index a57b58d..af60d03 100644
--- a/src/gtk/fm-path-entry.c
+++ b/src/gtk/fm-path-entry.c
@@ -163,7 +163,7 @@ static void fm_path_entry_changed(GtkEditable *editable)
if( !fm_path_equal_str(priv->path, original_key, key_dir_len) )
{
gchar* new_path = g_path_get_dirname(original_key);
- FmPath *new_fm_path = fm_path_new(new_path);
+ FmPath *new_fm_path = fm_path_new_for_str(new_path);
g_free(new_path);
if( new_fm_path != NULL )
{
--
1.7.0.1