Merge lp:~optimisme/pantheon-files/fix-995762 into lp:~elementary-apps/pantheon-files/trunk

Proposed by Albert
Status: Merged
Approved by: Cody Garver
Approved revision: 1198
Merged at revision: 1195
Proposed branch: lp:~optimisme/pantheon-files/fix-995762
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 419 lines (+183/-23)
13 files modified
libcore/gof-file.c (+40/-13)
libcore/gof-file.h (+4/-1)
libcore/marlincore-C.vapi (+5/-3)
plugins/CMakeLists.txt (+1/-0)
plugins/network-places/CMakeLists.txt (+37/-0)
plugins/network-places/network-places.plug (+3/-0)
plugins/network-places/plugin.vala (+49/-0)
src/fm-directory-view.c (+5/-1)
src/marlin-connect-server-dialog.c (+13/-0)
src/marlin-connect-server-dialog.h (+1/-0)
src/marlin-places-sidebar.c (+24/-3)
src/marlin-places-sidebar.h (+1/-0)
src/pantheon-files-ui.xml (+0/-2)
To merge this branch: bzr merge lp:~optimisme/pantheon-files/fix-995762
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Victor Martinez (community) Approve
Review via email: mp+165707@code.launchpad.net

Commit message

- Mounting network drives now works! Bug #998555.
- Added a "Connect to server" banner to fix bug #995762.
- Added a "Connect to Server" right click option for "Entire network".
- Removed "Connect to Server" from appmenu.

Description of the change

- Added a button "Connect to server" at the "network" folder (like the Empty trash at Trash)
- Added a right click option for "Entire network" with "Connect to Server"
- Removed "Connect to server" from Menu

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

"Connecto to Server..." to "Connect to Server..."

review: Needs Fixing
1193. By Albert

changed connecto to connect

Revision history for this message
Victor Martinez (victored) wrote :

Superb work!

A couple of suggestions:

* Instead of the new marlin.vapi file, "extern void marlin_connect_server_dialog (Gtk.Widget widget);" could be added to plugin.vala
* Coding style for vala code: http://master.elementaryos.org/docs/code/code-style
* Coding style for C code: follow style of source file.
* Remove the related code from pantheon-files-ui.xml instead of commenting it out. Having dead code is not desired.

Everything else seems nicely done.

review: Needs Fixing
1194. By Albert

small style fixes

Revision history for this message
Albert (optimisme) wrote :

Hi Victor:

- I don't know how to use "extern void" if you have an example of it I will be pleased to learn from it and change my source.
- I fixed the "vala" line jump styles, I copied my source from the other plugins and I assumed their source was properly styled.
- I do not see important style differences with my source and the rest of the c files, in fact I copied/pasted most of the source from the "trash" functions.
- I removed the non used source from "pantheon-files-ui.xml"

Revision history for this message
Victor Martinez (victored) wrote :

Albert, thank you very much for adding the corrections. Here's how to use extern: lp:~elementary-apps/pantheon-files/network-places

1195. By Albert

replaced cserver by network-places

1196. By Albert

merged with victor suggestions and fixed bug 998555

1197. By Albert

merged with victor suggestions and fixed bug 998555

Revision history for this message
Albert (optimisme) wrote :

Hi Victor,

- I added your code suggestions and I am using the new "gof_file_is_network_uri_scheme" and "gof_file_is_smb_uri_scheme" functions

- The plugin is also using "network-places" instead of "marlin-cserver"

- I fixed the bug number "998555" in this code and removed the other branch because I don't want to fix merge problems with small changes.

Revision history for this message
Victor Martinez (victored) wrote :

Albert,

fantastic work!

I don't mind the fact that you've merged the fixes into a single branch, since they are closely related.

I have no objections code-wise. Just some coding-style suggestions (diff line numbers):

- 156: indentation misalignment.
- 258: add spaces before opening parenthesis.
- 355: align "item" and "sidebar" vertically.
- 369: Use the respective Unicode character instead of three dots "..." => "…", as in network-places/plugin.vala.

I also preferred your single call to gof_file_is_root_network_folder from the other merge request instead of calling the two methods I suggested (diff line 258). Feel free to re-add your method to gof-file.c and marlincore-C.vapi, even if it's just a wrapper for gof_file_is_smb_uri_scheme and gof_file_is_network_uri_scheme.

I'm approving now since these issues are not critical, but it'd be great if you could land these changes before merging.

review: Approve
1198. By Albert

final fixes

Revision history for this message
Albert (optimisme) wrote :

Hi Victor,

Fixes commited, let's see if Luna can have local network connections soon!

Revision history for this message
Cody Garver (codygarver) wrote :

This is great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libcore/gof-file.c'
2--- libcore/gof-file.c 2013-05-19 05:37:59 +0000
3+++ libcore/gof-file.c 2013-05-27 22:35:30 +0000
4@@ -174,27 +174,54 @@
5 file->can_unmount = FALSE;
6 }
7
8-gboolean
9-gof_file_is_remote_uri_scheme (GOFFile *file)
10+static gboolean
11+gof_file_compare_uri_schemes (GOFFile *file, const char **schemes)
12 {
13- /* try to determinate what appear to be remote. This is quite hazardous but gio doesn't offer any better option */
14+ int iterator;
15 char *scheme = g_file_get_uri_scheme (file->location);
16
17- /* g_vfs does not have a function to know if a supported protocol is remote */
18- if (!strcmp (scheme, "afp")
19- || !strcmp (scheme, "dav")
20- || !strcmp (scheme, "davs")
21- || !strcmp (scheme, "ftp")
22- || !strcmp (scheme, "sftp")
23- || !strcmp (scheme, "smb")) {
24- g_free (scheme);
25- return TRUE;
26+ for (iterator = 0; iterator < G_N_ELEMENTS (schemes); iterator++) {
27+ if (!strcmp (scheme, schemes[iterator])) {
28+ g_free (scheme);
29+ return TRUE;
30+ }
31 }
32
33 g_free (scheme);
34 return FALSE;
35 }
36
37+gboolean
38+gof_file_is_remote_uri_scheme (GOFFile *file)
39+{
40+ if (gof_file_is_root_network_folder (file))
41+ return TRUE;
42+
43+ const char* SCHEMES[] = { "afp", "dav", "davs", "ftp", "sftp" };
44+ return gof_file_compare_uri_schemes (file, SCHEMES);
45+}
46+
47+gboolean
48+gof_file_is_root_network_folder (GOFFile *file)
49+{
50+ if (gof_file_is_network_uri_scheme (file) || gof_file_is_smb_uri_scheme (file))
51+ return TRUE;
52+}
53+
54+gboolean
55+gof_file_is_network_uri_scheme (GOFFile *file)
56+{
57+ const char* SCHEMES[] = { "network" };
58+ return gof_file_compare_uri_schemes (file, SCHEMES);
59+}
60+
61+gboolean
62+gof_file_is_smb_uri_scheme (GOFFile *file)
63+{
64+ const char* SCHEMES[] = { "smb" };
65+ return gof_file_compare_uri_schemes (file, SCHEMES);
66+}
67+
68 void gof_file_get_folder_icon_from_uri_or_path (GOFFile *file)
69 {
70 if (!file->is_hidden && file->uri != NULL && file->icon == NULL) {
71@@ -413,7 +440,7 @@
72 if (file->is_directory) {
73 gof_file_get_folder_icon_from_uri_or_path (file);
74 } else if (g_file_info_get_file_type(file->info) == G_FILE_TYPE_MOUNTABLE) {
75- file->icon = g_themed_icon_new_with_default_fallbacks ("folder-remote-symbolic");
76+ file->icon = g_themed_icon_new_with_default_fallbacks ("folder-remote");
77 } else {
78 const gchar *ftype = gof_file_get_ftype (file);
79 if (ftype != NULL && file->icon == NULL)
80
81=== modified file 'libcore/gof-file.h'
82--- libcore/gof-file.h 2012-05-30 18:07:43 +0000
83+++ libcore/gof-file.h 2013-05-27 22:35:30 +0000
84@@ -153,7 +153,7 @@
85 GOFFileOperationCallback callback;
86 gpointer callback_data;
87 gboolean is_rename;
88-
89+
90 gpointer data;
91 GDestroyNotify free_data;
92 } GOFFileOperation;
93@@ -253,6 +253,9 @@
94 gboolean gof_file_can_unmount (GOFFile *file);
95
96 gboolean gof_file_is_remote_uri_scheme (GOFFile *file);
97+gboolean gof_file_is_root_network_folder (GOFFile *file);
98+gboolean gof_file_is_network_uri_scheme (GOFFile *file);
99+gboolean gof_file_is_smb_uri_scheme (GOFFile *file);
100 gboolean gof_file_thumb_can_frame (GOFFile *file);
101
102 G_END_DECLS
103
104=== modified file 'libcore/marlincore-C.vapi'
105--- libcore/marlincore-C.vapi 2012-06-02 10:39:14 +0000
106+++ libcore/marlincore-C.vapi 2013-05-27 22:35:30 +0000
107@@ -118,7 +118,7 @@
108 namespace GOF {
109
110 [CCode (cheader_filename = "gof-file.h")]
111- public class File : GLib.Object {
112+ public class File : GLib.Object {
113 [CCode (cheader_filename = "gof-file.h")]
114 enum ThumbState {
115 READY
116@@ -159,7 +159,7 @@
117 public bool is_trashed();
118 public bool link_known_target;
119 public uint flags;
120-
121+
122 public unowned string get_display_name ();
123 public unowned GLib.File get_target_location ();
124 public unowned string get_ftype ();
125@@ -196,6 +196,8 @@
126 public static int compare_by_display_name (File file1, File file2);
127
128 public bool is_remote_uri_scheme ();
129+ public bool is_network_uri_scheme ();
130+ public bool is_smb_uri_scheme ();
131 }
132
133 [CCode (cheader_filename = "gof-file.h")]
134@@ -204,7 +206,7 @@
135 NONE,
136 USE_THUMBNAILS
137 }
138-
139+
140 [CCode (cheader_filename = "gof-abstract-slot.h")]
141 public class AbstractSlot : GLib.Object {
142 public void add_extra_widget(Gtk.Widget widget);
143
144=== modified file 'plugins/CMakeLists.txt'
145--- plugins/CMakeLists.txt 2013-04-22 10:28:47 +0000
146+++ plugins/CMakeLists.txt 2013-05-27 22:35:30 +0000
147@@ -1,3 +1,4 @@
148 add_subdirectory(contractor)
149 add_subdirectory(marlin-trash)
150 add_subdirectory(marlin-ctags)
151+add_subdirectory(network-places)
152
153=== added directory 'plugins/network-places'
154=== added file 'plugins/network-places/CMakeLists.txt'
155--- plugins/network-places/CMakeLists.txt 1970-01-01 00:00:00 +0000
156+++ plugins/network-places/CMakeLists.txt 2013-05-27 22:35:30 +0000
157@@ -0,0 +1,37 @@
158+# Check http://elementaryos.org/docs/developer-guide/cmake for documentation
159+
160+set(PLUGIN_LIB_NAME "network-places")
161+
162+find_package(PkgConfig)
163+pkg_check_modules(DEPS REQUIRED
164+ gtk+-3.0
165+ gee-1.0
166+)
167+
168+set(CFLAGS ${DEPS_CFLAGS} ${DEPS_CFLAGS_OTHER})
169+
170+include_directories(${CMAKE_SOURCE_DIR}/libcore/)
171+include_directories(${CMAKE_BINARY_DIR}/libcore/)
172+
173+vala_precompile(VALA_C marlincserver
174+ plugin.vala
175+PACKAGES
176+ gtk+-3.0
177+ gee-1.0
178+ marlincore-C
179+ marlincore
180+OPTIONS
181+ --thread
182+ --vapidir=${CMAKE_SOURCE_DIR}/libcore/
183+ --vapidir=${CMAKE_SOURCE_DIR}/plugins/marlin-cserver/
184+ --vapidir=${CMAKE_BINARY_DIR}/libcore/
185+)
186+add_definitions(${CFLAGS} "-DGETTEXT_PACKAGE=\"pantheon-files\"")
187+
188+link_directories(${LIB_PATHS})
189+
190+add_library(${PLUGIN_LIB_NAME} SHARED ${VALA_C})
191+target_link_libraries(${PLUGIN_LIB_NAME} ${DEPS_LIBRARIES} marlincore)
192+install(TARGETS ${PLUGIN_LIB_NAME} DESTINATION lib/pantheon-files/plugins/core/)
193+install(FILES ${PLUGIN_LIB_NAME}.plug DESTINATION lib/pantheon-files/plugins/core/)
194+include_directories(${CMAKE_BINARY_DIR}/plugins/)
195
196=== added file 'plugins/network-places/network-places.plug'
197--- plugins/network-places/network-places.plug 1970-01-01 00:00:00 +0000
198+++ plugins/network-places/network-places.plug 2013-05-27 22:35:30 +0000
199@@ -0,0 +1,3 @@
200+[Plugin]
201+Name=Connect to server!
202+File=libnetwork-places.so
203
204=== added file 'plugins/network-places/plugin.vala'
205--- plugins/network-places/plugin.vala 1970-01-01 00:00:00 +0000
206+++ plugins/network-places/plugin.vala 2013-05-27 22:35:30 +0000
207@@ -0,0 +1,49 @@
208+/*
209+ *
210+ * Marlin is free software: you can redistribute it and/or modify it
211+ * under the terms of the GNU General Public License as published by the
212+ * Free Software Foundation, either version 3 of the License, or
213+ * (at your option) any later version.
214+ *
215+ * Marlin is distributed in the hope that it will be useful, but
216+ * WITHOUT ANY WARRANTY; without even the implied warranty of
217+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
218+ * See the GNU General Public License for more details.
219+ *
220+ * You should have received a copy of the GNU General Public License along
221+ * with this program. If not, see <http://www.gnu.org/licenses/>.
222+ */
223+
224+// See src/marlin-connect-server-dialog.c
225+extern void marlin_connect_server_dialog_show (Gtk.Widget widget);
226+
227+public class Files.Plugins.NetworkInfobar : Gtk.InfoBar {
228+ public NetworkInfobar () {
229+ message_type = Gtk.MessageType.INFO;
230+ add_button (_("Connect to Server…"), 0);
231+ }
232+
233+ public override void response (int response_id) {
234+ marlin_connect_server_dialog_show (this);
235+ }
236+}
237+
238+public class Files.Plugins.NetworkPlaces : Marlin.Plugins.Base {
239+ public override void directory_loaded (void* user_data) {
240+ var file = ((Object[]) user_data)[2] as GOF.File;
241+ return_if_fail (file != null);
242+
243+ if (file.is_network_uri_scheme ()) {
244+ var slot = ((Object[]) user_data)[1] as GOF.AbstractSlot;
245+ return_if_fail (slot != null);
246+
247+ var infobar = new NetworkInfobar ();
248+ slot.add_extra_widget (infobar);
249+ infobar.show_all ();
250+ }
251+ }
252+}
253+
254+public Marlin.Plugins.Base module_init () {
255+ return new Files.Plugins.NetworkPlaces ();
256+}
257
258=== modified file 'src/fm-directory-view.c'
259--- src/fm-directory-view.c 2013-02-27 21:42:16 +0000
260+++ src/fm-directory-view.c 2013-05-27 22:35:30 +0000
261@@ -693,7 +693,11 @@
262 break;
263 }
264 } else {
265- gof_file_open_single (file, screen, view->details->default_app);
266+ if (gof_file_is_root_network_folder (file)) {
267+ fm_directory_view_load_location (view, file->target_location);
268+ } else {
269+ gof_file_open_single (file, screen, view->details->default_app);
270+ }
271 }
272 }
273
274
275=== modified file 'src/marlin-connect-server-dialog.c'
276--- src/marlin-connect-server-dialog.c 2013-05-18 09:24:36 +0000
277+++ src/marlin-connect-server-dialog.c 2013-05-27 22:35:30 +0000
278@@ -441,6 +441,19 @@
279 static GSimpleAsyncResult *display_location_res = NULL;
280
281 void
282+marlin_connect_server_dialog_show (GtkWidget *widget)
283+{
284+ GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
285+ if (gtk_widget_is_toplevel (toplevel)) {
286+ GtkWindow *window = GTK_WINDOW (toplevel);
287+ g_return_if_fail (window != NULL);
288+
289+ MarlinConnectServerDialog *dialog = marlin_connect_server_dialog_new (window);
290+ gtk_widget_show (GTK_WIDGET (dialog));
291+ }
292+}
293+
294+void
295 marlin_connect_server_dialog_display_location_async (MarlinConnectServerDialog *self,
296 GFile *location,
297 GAsyncReadyCallback callback,
298
299=== modified file 'src/marlin-connect-server-dialog.h'
300--- src/marlin-connect-server-dialog.h 2012-02-05 16:29:37 +0000
301+++ src/marlin-connect-server-dialog.h 2013-05-27 22:35:30 +0000
302@@ -54,6 +54,7 @@
303
304 MarlinConnectServerDialog *marlin_connect_server_dialog_new (GtkWindow *window);
305
306+void marlin_connect_server_dialog_show (GtkWidget *widget);
307 void marlin_connect_server_dialog_display_location_async (MarlinConnectServerDialog *self,
308 GFile *location,
309 GAsyncReadyCallback callback,
310
311=== modified file 'src/marlin-places-sidebar.c'
312--- src/marlin-places-sidebar.c 2013-04-21 19:25:05 +0000
313+++ src/marlin-places-sidebar.c 2013-05-27 22:35:30 +0000
314@@ -40,6 +40,7 @@
315 #include "marlin-trash-monitor.h"
316 #include "marlin-dnd.h"
317 #include "marlincore.h"
318+#include "marlin-connect-server-dialog.h"
319
320 #define ROOT_INDENTATION_XPAD 2
321 #define EJECT_BUTTON_XPAD 4
322@@ -1450,6 +1451,7 @@
323 sidebar->popup_menu_start_item = NULL;
324 sidebar->popup_menu_stop_item = NULL;
325 sidebar->popup_menu_empty_trash_item = NULL;
326+ sidebar->popup_menu_connect_server_item = NULL;
327 }
328
329 static void
330@@ -1530,6 +1532,7 @@
331 gboolean show_start;
332 gboolean show_stop;
333 gboolean show_empty_trash;
334+ gboolean show_connect_server;
335 char *uri = NULL;
336
337 type = PLACES_BUILT_IN;
338@@ -1567,9 +1570,10 @@
339 */
340
341 show_empty_trash = (uri != NULL) && (!strcmp (uri, MARLIN_TRASH_URI));
342+ show_connect_server = (uri != NULL) && (!strcmp (uri, MARLIN_NETWORK_URI));
343
344 eel_gtk_widget_set_shown (sidebar->popup_menu_separator_item2,
345- show_eject || show_unmount || show_mount || show_empty_trash);
346+ show_eject || show_unmount || show_mount || show_empty_trash || show_connect_server);
347 eel_gtk_widget_set_shown (sidebar->popup_menu_mount_item, show_mount);
348 eel_gtk_widget_set_shown (sidebar->popup_menu_unmount_item, show_unmount);
349 eel_gtk_widget_set_shown (sidebar->popup_menu_eject_item, show_eject);
350@@ -1578,6 +1582,7 @@
351 eel_gtk_widget_set_shown (sidebar->popup_menu_start_item, show_start);
352 eel_gtk_widget_set_shown (sidebar->popup_menu_stop_item, show_stop);*/
353 eel_gtk_widget_set_shown (sidebar->popup_menu_empty_trash_item, show_empty_trash);
354+ eel_gtk_widget_set_shown (sidebar->popup_menu_connect_server_item, show_connect_server);
355
356 //TODO check this
357 #if 0
358@@ -2319,11 +2324,17 @@
359 #endif
360
361 static void
362-empty_trash_cb (GtkMenuItem *item,
363- MarlinPlacesSidebar *sidebar)
364+empty_trash_cb (GtkMenuItem *item,
365+ MarlinPlacesSidebar *sidebar)
366 {
367 marlin_file_operations_empty_trash (GTK_WIDGET (sidebar->window));
368 }
369+static void
370+connect_server_cb (GtkMenuItem *item,
371+ MarlinPlacesSidebar *sidebar)
372+{
373+ marlin_connect_server_dialog_show(GTK_WIDGET (sidebar->window));
374+}
375
376 /* Handler for GtkWidget::key-press-event on the shortcuts list */
377 static gboolean
378@@ -2447,6 +2458,16 @@
379 gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
380
381 bookmarks_check_popup_sensitivity (sidebar);
382+
383+ /* Connect to server menu item */
384+ item = gtk_menu_item_new_with_mnemonic (_("Connect to Server…"));
385+ sidebar->popup_menu_connect_server_item = item;
386+ g_signal_connect (item, "activate",
387+ G_CALLBACK (connect_server_cb), sidebar);
388+ gtk_widget_show (item);
389+ gtk_menu_shell_append (GTK_MENU_SHELL (sidebar->popup_menu), item);
390+
391+ bookmarks_check_popup_sensitivity (sidebar);
392 }
393
394 static void
395
396=== modified file 'src/marlin-places-sidebar.h'
397--- src/marlin-places-sidebar.h 2012-11-06 17:21:39 +0000
398+++ src/marlin-places-sidebar.h 2013-05-27 22:35:30 +0000
399@@ -79,6 +79,7 @@
400 GtkWidget *popup_menu_rescan_item;
401 GtkWidget *popup_menu_format_item;
402 GtkWidget *popup_menu_empty_trash_item;
403+ GtkWidget *popup_menu_connect_server_item;
404 GtkWidget *popup_menu_start_item;
405 GtkWidget *popup_menu_stop_item;
406
407
408=== modified file 'src/pantheon-files-ui.xml'
409--- src/pantheon-files-ui.xml 2013-05-13 19:43:25 +0000
410+++ src/pantheon-files-ui.xml 2013-05-27 22:35:30 +0000
411@@ -74,8 +74,6 @@
412 <menuitem name="New Tab" action="New Tab"/>
413 <menuitem name="New Window" action="New Window"/>
414 <separator/>
415- <menuitem name="Connect to Server" action="Connect to Server"/>
416- <separator/>
417 <menuitem name="About" action="About"/>
418 </popup>
419 </ui>

Subscribers

People subscribed via source and target branches

to all changes: