summaryrefslogtreecommitdiff
path: root/extra/libfm/0001-filename-with-spaces-not-supported.patch
blob: 568f6dc381371ac2e534851c43f2ae6d837ad469 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
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