Merge lp:~jeremywootten/pantheon-files/refactor-location-bar-preparation into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1958
Merged at revision: 1981
Proposed branch: lp:~jeremywootten/pantheon-files/refactor-location-bar-preparation
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 1080 lines (+435/-101)
21 files modified
filechooser-module/CMakeLists.txt (+2/-2)
libcore/AbstractSlot.vala (+1/-0)
libcore/CMakeLists.txt (+5/-0)
libcore/DndHandler.vala (+2/-2)
libcore/Enums.vala (+7/-0)
libwidgets/CMakeLists.txt (+17/-3)
libwidgets/Chrome/TopMenu.vala (+27/-13)
libwidgets/Chrome/ViewSwicher.vala (+0/-3)
libwidgets/Chrome/ViewWindowInterface.vala (+35/-0)
libwidgets/Chrome/Viewable.vala (+32/-0)
libwidgets/Dialogs/ChooseAppDialog.vala (+62/-0)
libwidgets/FileUtils.vala (+149/-0)
libwidgets/LocationBar.vala (+16/-18)
libwidgets/SearchResults.vala (+4/-9)
src/CMakeLists.txt (+1/-24)
src/View/AbstractDirectoryView.vala (+13/-19)
src/View/Miller.vala (+4/-0)
src/View/Sidebar.vala (+1/-1)
src/View/Slot.vala (+5/-0)
src/View/ViewContainer.vala (+8/-3)
src/View/Window.vala (+44/-4)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/refactor-location-bar-preparation
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+273316@code.launchpad.net

Commit message

Move TopMenu widgets into libwidgets and some supporting classes into libcore

Description of the change

This branch is the first of a series aimed at refactoring the location bar in particular and the topmenu in general. The intention is to make these widgets self-contained and testable with defined interfaces. See lp:~jeremywootten/pantheon-files/experimental-refactor-fix-1461060-browser-like-search for the (almost) final version. The refactored location bar will have a more browser-like search behaviour. A separate LocationBarChooser widget will not be needed.

This branch moves the existing topmenu widgets into libwidgets but does not changes their behaviour. Consequential changes are made so that they still work.

The linked bug is fixed in passing.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'filechooser-module/CMakeLists.txt'
--- filechooser-module/CMakeLists.txt 2015-10-01 08:43:51 +0000
+++ filechooser-module/CMakeLists.txt 2015-11-14 13:22:20 +0000
@@ -9,8 +9,8 @@
99
10vala_precompile (VALA_C ${MODULE_NAME}10vala_precompile (VALA_C ${MODULE_NAME}
11 ${CMAKE_SOURCE_DIR}/libwidgets/Resources.vala11 ${CMAKE_SOURCE_DIR}/libwidgets/Resources.vala
12 ${CMAKE_SOURCE_DIR}/libwidgets/LocationBar.vala12 ${CMAKE_SOURCE_DIR}/libwidgets/Chrome/LocationBar.vala
13 ${CMAKE_SOURCE_DIR}/libwidgets/BreadcrumbsElements.vala13 ${CMAKE_SOURCE_DIR}/libwidgets/Chrome/BreadcrumbsElements.vala
14 LocationBarChooser.vala14 LocationBarChooser.vala
15 FileChooserDialog.vala15 FileChooserDialog.vala
16 Plugin.vala16 Plugin.vala
1717
=== modified file 'libcore/AbstractSlot.vala'
--- libcore/AbstractSlot.vala 2015-07-24 08:01:21 +0000
+++ libcore/AbstractSlot.vala 2015-11-14 13:22:20 +0000
@@ -65,6 +65,7 @@
6565
66 public abstract unowned GLib.List<unowned GOF.File>? get_selected_files ();66 public abstract unowned GLib.List<unowned GOF.File>? get_selected_files ();
67 public abstract void set_active_state (bool set_active);67 public abstract void set_active_state (bool set_active);
68 public abstract void set_frozen_state (bool is_frozen);
68 public abstract unowned AbstractSlot? get_current_slot ();69 public abstract unowned AbstractSlot? get_current_slot ();
69 public abstract void reload (bool non_local_only = false);70 public abstract void reload (bool non_local_only = false);
70 public abstract void grab_focus ();71 public abstract void grab_focus ();
7172
=== renamed file 'src/Bookmark.vala' => 'libcore/Bookmark.vala'
=== renamed file 'src/BookmarkList.vala' => 'libcore/BookmarkList.vala'
=== modified file 'libcore/CMakeLists.txt'
--- libcore/CMakeLists.txt 2015-05-03 06:44:42 +0000
+++ libcore/CMakeLists.txt 2015-11-14 13:22:20 +0000
@@ -16,6 +16,11 @@
16vala_precompile(VALA_C ${PKGNAME}16vala_precompile(VALA_C ${PKGNAME}
17 AbstractSidebar.vala17 AbstractSidebar.vala
18 AbstractSlot.vala18 AbstractSlot.vala
19 Bookmark.vala
20 BookmarkList.vala
21 DndHandler.vala
22 Enums.vala
23 MimeActions.vala
19 gof-callwhenready.vala24 gof-callwhenready.vala
20 gof-directory-async.vala25 gof-directory-async.vala
21 gof-preferences.vala26 gof-preferences.vala
2227
=== renamed file 'src/DndHandler.vala' => 'libcore/DndHandler.vala'
--- src/DndHandler.vala 2015-07-03 13:48:11 +0000
+++ libcore/DndHandler.vala 2015-11-14 13:22:20 +0000
@@ -19,7 +19,7 @@
19 Authors: Jeremy Wootten <jeremy@elementaryos.org>19 Authors: Jeremy Wootten <jeremy@elementaryos.org>
20***/20***/
2121
22namespace FM {22namespace Marlin {
23 public class DndHandler : GLib.Object {23 public class DndHandler : GLib.Object {
24 Gdk.DragAction chosen = Gdk.DragAction.DEFAULT;24 Gdk.DragAction chosen = Gdk.DragAction.DEFAULT;
2525
@@ -249,7 +249,7 @@
249 public bool selection_data_is_uri_list (Gtk.SelectionData selection_data, uint info, out string? text) {249 public bool selection_data_is_uri_list (Gtk.SelectionData selection_data, uint info, out string? text) {
250 text = null;250 text = null;
251251
252 if (info == AbstractDirectoryView.TargetType.TEXT_URI_LIST &&252 if (info == Marlin.TargetType.TEXT_URI_LIST &&
253 selection_data.get_format () == 8 &&253 selection_data.get_format () == 8 &&
254 selection_data.get_length () > 0) {254 selection_data.get_length () > 0) {
255255
256256
=== renamed file 'src/Enums.vala' => 'libcore/Enums.vala'
--- src/Enums.vala 2015-08-17 08:16:55 +0000
+++ libcore/Enums.vala 2015-11-14 13:22:20 +0000
@@ -142,4 +142,11 @@
142 assert_not_reached ();142 assert_not_reached ();
143 }143 }
144 }144 }
145
146 public enum TargetType {
147 STRING,
148 TEXT_URI_LIST,
149 XDND_DIRECT_SAVE0,
150 NETSCAPE_URL
151 }
145}152}
146153
=== renamed file 'src/MimeActions.vala' => 'libcore/MimeActions.vala'
=== added directory 'libwidgets/Animations'
=== renamed file 'libwidgets/Animations.vala' => 'libwidgets/Animations/Animations.vala'
=== modified file 'libwidgets/CMakeLists.txt'
--- libwidgets/CMakeLists.txt 2015-11-05 11:26:27 +0000
+++ libwidgets/CMakeLists.txt 2015-11-14 13:22:20 +0000
@@ -33,25 +33,39 @@
33)33)
34link_directories(${LIB_PATHS})34link_directories(${LIB_PATHS})
3535
36include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../libcore/)
37include_directories (${CMAKE_CURRENT_BINARY_DIR}/../libcore/)
36include_directories (${CMAKE_CURRENT_BINARY_DIR})38include_directories (${CMAKE_CURRENT_BINARY_DIR})
37include_directories (${CMAKE_BINARY_DIR})39include_directories (${CMAKE_BINARY_DIR})
3840
39vala_precompile(VALA_C ${PKGNAME}41vala_precompile(VALA_C ${PKGNAME}
42 FileUtils.vala
40 Resources.vala43 Resources.vala
41 Animations.vala
42 LocationBar.vala44 LocationBar.vala
43 BreadcrumbsElements.vala45 SearchResults.vala
46 Animations/Animations.vala
47 Chrome/LocationBar.vala
48 Chrome/BreadcrumbsElements.vala
49 Chrome/TopMenu.vala
50 Chrome/ButtonWithMenu.vala
51 Chrome/ViewSwicher.vala
52 Chrome/XsEntry.vala
53 Chrome/ImgEventBox.vala
54 Chrome/Viewable.vala
55 Dialogs/ChooseAppDialog.vala
44 Welcome.vala56 Welcome.vala
45PACKAGES57PACKAGES
46 gtk+-3.058 gtk+-3.0
47 granite59 granite
48 gee-0.860 gee-0.8
49 posix61 posix
62 zeitgeist-2.0
50 pantheon-files-core63 pantheon-files-core
51 pantheon-files-core-C64 pantheon-files-core-C
52OPTIONS65OPTIONS
53 --vapidir=${CMAKE_SOURCE_DIR}/libcore66 --vapidir=${CMAKE_SOURCE_DIR}/libcore
54 --vapidir=${CMAKE_BINARY_DIR}/libcore67 --vapidir=${CMAKE_BINARY_DIR}/libcore
68 --target-glib=2.32 # Needed for new thread API
55 --thread69 --thread
56GENERATE_VAPI70GENERATE_VAPI
57 pantheon-files-widgets71 pantheon-files-widgets
@@ -66,4 +80,4 @@
66 SOVERSION ${PANTHEON_FILES_WIDGETS_SOVERSION})80 SOVERSION ${PANTHEON_FILES_WIDGETS_SOVERSION})
6781
68install (TARGETS ${PKGNAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)82install (TARGETS ${PKGNAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/)
69target_link_libraries(${PKGNAME} ${DEPS_LIBRARIES})83target_link_libraries(${PKGNAME} pantheon-files-core ${DEPS_LIBRARIES})
7084
=== added directory 'libwidgets/Chrome'
=== renamed file 'libwidgets/BreadcrumbsElements.vala' => 'libwidgets/Chrome/BreadcrumbsElements.vala'
=== renamed file 'src/View/Chrome/ButtonWithMenu.vala' => 'libwidgets/Chrome/ButtonWithMenu.vala'
=== renamed file 'src/View/Chrome/ImgEventBox.vala' => 'libwidgets/Chrome/ImgEventBox.vala'
=== renamed file 'libwidgets/LocationBar.vala' => 'libwidgets/Chrome/LocationBar.vala'
=== renamed file 'src/View/Chrome/TopMenu.vala' => 'libwidgets/Chrome/TopMenu.vala'
--- src/View/Chrome/TopMenu.vala 2015-05-03 06:44:42 +0000
+++ libwidgets/Chrome/TopMenu.vala 2015-11-14 13:22:20 +0000
@@ -26,7 +26,7 @@
26 public class TopMenu : Gtk.HeaderBar {26 public class TopMenu : Gtk.HeaderBar {
27 public ViewSwitcher? view_switcher;27 public ViewSwitcher? view_switcher;
28 public LocationBar? location_bar;28 public LocationBar? location_bar;
29 public Marlin.View.Window win;29 public Marlin.Viewable win;
30 public Chrome.ButtonWithMenu button_forward;30 public Chrome.ButtonWithMenu button_forward;
31 public Chrome.ButtonWithMenu button_back;31 public Chrome.ButtonWithMenu button_back;
3232
@@ -40,7 +40,12 @@
40 button_forward.set_sensitive (can);40 button_forward.set_sensitive (can);
41 }41 }
4242
43 public TopMenu (Marlin.View.Window window) {43 public signal void focus_location_request (GLib.File? location);
44 public signal void path_change_request (string path, Marlin.OpenFlag flag);
45 public signal void escape ();
46 public signal void reload_request ();
47
48 public TopMenu (ViewSwitcher switcher, Marlin.Viewable window) {
44 win = window;49 win = window;
4550
46 button_back = new Marlin.View.Chrome.ButtonWithMenu.from_icon_name ("go-previous-symbolic", Gtk.IconSize.LARGE_TOOLBAR);51 button_back = new Marlin.View.Chrome.ButtonWithMenu.from_icon_name ("go-previous-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
@@ -62,27 +67,36 @@
62 back (1);67 back (1);
63 });68 });
6469
6570 view_switcher = switcher;
66 view_switcher = new ViewSwitcher (win.win_actions.lookup_action ("view_mode") as GLib.SimpleAction);71 view_switcher.margin_right = 20;
67
68 view_switcher.show_all ();72 view_switcher.show_all ();
69 pack_start (view_switcher);73 pack_start (view_switcher);
7074
71 location_bar = new LocationBar (win);75 location_bar = new LocationBar (win);
76 connect_location_bar_signals ();
77 location_bar.show_all ();
78 pack_start (location_bar);
79
80 show ();
81 }
82
83 private void connect_location_bar_signals () {
72 location_bar.escape.connect (win.grab_focus);84 location_bar.escape.connect (win.grab_focus);
73 location_bar.activate.connect (win.file_path_change_request);85 location_bar.activate.connect (win.file_path_change_request);
74 location_bar.activate_alternate.connect ((file) => {86 location_bar.activate_alternate.connect ((file) => {
75 win.add_tab (file, Marlin.ViewMode.CURRENT);87 win.add_tab (file, Marlin.ViewMode.CURRENT);
76 });88 });
7789 location_bar.reload_request.connect (() => {
7890 reload_request ();
79 location_bar.show_all ();91 });
80 view_switcher.margin_right = 20;92 location_bar.focus_in_event.connect ((event) => {
81 pack_start (location_bar);93 return focus_in_event (event);
8294 });
83 show ();95 location_bar.focus_out_event.connect ((event) => {
96 return focus_out_event (event);
97 });
84 }98 }
8599
86 public void set_back_menu (Gee.List<string> path_list) {100 public void set_back_menu (Gee.List<string> path_list) {
87 /* Clear the back menu and re-add the correct entries. */101 /* Clear the back menu and re-add the correct entries. */
88 var back_menu = new Gtk.Menu ();102 var back_menu = new Gtk.Menu ();
89103
=== renamed file 'src/View/Chrome/ViewSwicher.vala' => 'libwidgets/Chrome/ViewSwicher.vala'
--- src/View/Chrome/ViewSwicher.vala 2015-05-03 06:44:42 +0000
+++ libwidgets/Chrome/ViewSwicher.vala 2015-11-14 13:22:20 +0000
@@ -48,7 +48,6 @@
48 break;48 break;
49 }49 }
5050
51 Preferences.settings.set_enum ("default-viewmode", value);
52 freeze_update = true;51 freeze_update = true;
53 switcher.set_active (active_index);52 switcher.set_active (active_index);
54 freeze_update = false;53 freeze_update = false;
@@ -92,8 +91,6 @@
92 switcher.append (miller);91 switcher.append (miller);
93 miller_sv = new GLib.Variant.string ("MILLER");92 miller_sv = new GLib.Variant.string ("MILLER");
9493
95 mode = (Marlin.ViewMode) Preferences.settings.get_enum("default-viewmode");
96
97 switcher.mode_changed.connect ((image) => {94 switcher.mode_changed.connect ((image) => {
98 if (freeze_update) {95 if (freeze_update) {
99 return;96 return;
10097
=== added file 'libwidgets/Chrome/ViewWindowInterface.vala'
--- libwidgets/Chrome/ViewWindowInterface.vala 1970-01-01 00:00:00 +0000
+++ libwidgets/Chrome/ViewWindowInterface.vala 2015-11-14 13:22:20 +0000
@@ -0,0 +1,35 @@
1/*
2 * ViewWindowInterface.vala
3 *
4 * Copyright 2015 jeremy <jeremy@jeremy-W54-55SU1-SUW>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301, USA.
20 *
21 *
22 */
23
24
25public interface Marlin.Viewable : Gtk.ApplicationWindow {
26 public abstract new void grab_focus ();
27 public abstract void file_path_change_request (GLib.File file);
28 public abstract void focus_location_request (GLib.File loc);
29 public abstract void add_tab (GLib.File location = GLib.File.new_for_commandline_arg (GLib.Environment.get_home_dir ()),
30 Marlin.ViewMode mode = Marlin.ViewMode.PREFERRED);
31 public abstract GLib.File get_current_location ();
32 public abstract bool get_frozen ();
33 public abstract void refresh_view ();
34 public abstract void go_to_parent ();
35}
036
=== added file 'libwidgets/Chrome/Viewable.vala'
--- libwidgets/Chrome/Viewable.vala 1970-01-01 00:00:00 +0000
+++ libwidgets/Chrome/Viewable.vala 2015-11-14 13:22:20 +0000
@@ -0,0 +1,32 @@
1/***
2 Copyright (C) 2015 elementary Developers
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License version 3, as published
6 by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranties of
10 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 Authors : Jeremy Wootten <jeremy@elementaryos.org>
17***/
18
19
20public interface Marlin.Viewable : Gtk.ApplicationWindow {
21 public abstract new void grab_focus ();
22 public abstract void file_path_change_request (GLib.File file);
23 public abstract void focus_location_request (GLib.File? loc,
24 bool select_in_current_only = false,
25 bool unselect_others = false);
26 public abstract void add_tab (GLib.File location = GLib.File.new_for_commandline_arg (GLib.Environment.get_home_dir ()),
27 Marlin.ViewMode mode = Marlin.ViewMode.PREFERRED);
28 public abstract GLib.File get_current_location ();
29 public abstract bool get_frozen ();
30 public abstract void refresh_view ();
31 public abstract void go_to_parent ();
32}
033
=== renamed file 'src/View/Chrome/XsEntry.vala' => 'libwidgets/Chrome/XsEntry.vala'
=== added directory 'libwidgets/Dialogs'
=== added file 'libwidgets/Dialogs/ChooseAppDialog.vala'
--- libwidgets/Dialogs/ChooseAppDialog.vala 1970-01-01 00:00:00 +0000
+++ libwidgets/Dialogs/ChooseAppDialog.vala 2015-11-14 13:22:20 +0000
@@ -0,0 +1,62 @@
1/***
2 Copyright (C) 2015 elementary Developers
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License version 3, as published
6 by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranties of
10 MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 Authors : Jeremy Wootten <jeremy@elementaryos.org>
17***/
18
19namespace PF {
20 class ChooseAppDialog {
21 Gtk.AppChooserDialog dialog;
22 Gtk.CheckButton check_default;
23 GLib.File file_to_open;
24 public ChooseAppDialog (Gtk.Window parent, GLib.File file) {
25 file_to_open = file;
26 dialog = new Gtk.AppChooserDialog (parent,
27 Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
28 file_to_open);
29
30 dialog.set_deletable (false);
31 var app_chooser = dialog.get_widget () as Gtk.AppChooserWidget;
32 app_chooser.set_show_recommended (true);
33 check_default = new Gtk.CheckButton.with_label (_("Set as default"));
34 check_default.set_active (true);
35 check_default.show ();
36 var action_area = dialog.get_action_area () as Gtk.ButtonBox;
37 action_area.add (check_default);
38 action_area.set_child_secondary (check_default, true);
39 dialog.show ();
40 }
41
42 public AppInfo? get_app_info () {
43 AppInfo? app = null;
44 int response = dialog.run ();
45 if (response == Gtk.ResponseType.OK) {
46 app = dialog.get_app_info ();
47 if (check_default.get_active ()) {
48 try {
49 var info = file_to_open.query_info (FileAttribute.STANDARD_CONTENT_TYPE,
50 FileQueryInfoFlags.NONE, null);
51 app.set_as_default_for_type (info.get_content_type ());
52 }
53 catch (GLib.Error error) {
54 critical ("Could not set as default: %s", error.message);
55 }
56 }
57 }
58 dialog.destroy ();
59 return app;
60 }
61 }
62}
063
=== added file 'libwidgets/FileUtils.vala'
--- libwidgets/FileUtils.vala 1970-01-01 00:00:00 +0000
+++ libwidgets/FileUtils.vala 2015-11-14 13:22:20 +0000
@@ -0,0 +1,149 @@
1namespace PF.FileUtils {
2 const string reserved_chars = (GLib.Uri.RESERVED_CHARS_GENERIC_DELIMITERS + GLib.Uri.RESERVED_CHARS_SUBCOMPONENT_DELIMITERS + " ");
3
4 /**
5 * Gets a properly escaped GLib.File for the given path
6 **/
7 public File? get_file_for_path (string? path) {
8 File? file = null;
9 string new_path = sanitize_path (path);
10 if (path.length > 0) {
11 file = File.new_for_commandline_arg (new_path);
12 }
13 return file;
14 }
15
16 public string get_parent_path_from_path (string path) {
17 File? file = File.new_for_commandline_arg (path);
18 string parent_path = path;
19 if (file != null) {
20 File? parent = file.get_parent ();
21 if (parent != null) {
22 parent_path = parent.get_path ();
23 } else {
24 parent_path = construct_parent_path (path);
25 }
26 }
27 return parent_path;
28 }
29
30 private string construct_parent_path (string path) {
31 if (path.length < 2) {
32 return Path.DIR_SEPARATOR_S;
33 }
34 StringBuilder sb = new StringBuilder (path);
35 if (path.has_suffix (Path.DIR_SEPARATOR_S)) {
36 sb.erase (sb.str.length - 1,-1);
37 }
38 int last_separator = sb.str.last_index_of (Path.DIR_SEPARATOR_S);
39 if (last_separator < 0) {
40 last_separator = 0;
41 }
42 sb.erase (last_separator, -1);
43 string parent_path = sb.str + Path.DIR_SEPARATOR_S;
44 return parent_path;
45 }
46
47 public bool path_has_parent (string new_path) {
48 var file = File.new_for_commandline_arg (new_path);
49 return file.get_parent () != null;
50 }
51
52 public string? escape_uri (string uri, bool allow_utf8 = true) {
53 reserved_chars.replace("#", "");
54 return Uri.escape_string ((Uri.unescape_string (uri) ?? uri), reserved_chars, allow_utf8);
55 }
56
57 /** Produce a valid unescaped path **/
58 public string sanitize_path (string? p, string? cp = null) {
59 string path = "";
60 string scheme = "";
61 string? current_path = null;
62 string? current_scheme = null;
63
64 if (p == null || p == "") {
65 return cp ?? "";
66 }
67 string? unescaped_p = Uri.unescape_string (p, null);
68 if (unescaped_p == null) {
69 unescaped_p = p;
70 }
71
72 split_protocol_from_path (unescaped_p, out scheme, out path);
73 path = path.strip ().replace ("//", "/");
74 StringBuilder sb = new StringBuilder (path);
75 if (cp != null) {
76 split_protocol_from_path (cp, out current_scheme, out current_path);
77 /* current_path is assumed already sanitized */
78 if (scheme == "" && path.has_prefix ("/./")) {
79 sb.erase (0, 2);
80 sb.prepend (cp);
81 split_protocol_from_path (sb.str , out scheme, out path);
82 sb.assign (path);
83 } else if (path.has_prefix ("/../")) {
84 sb.erase (0, 3);
85 sb.prepend (get_parent_path_from_path (current_path));
86 sb.prepend (current_scheme);
87 split_protocol_from_path (sb.str , out scheme, out path);
88 sb.assign (path);
89 }
90 }
91
92 if (path.length > 0) {
93 if (scheme == "" && path.has_prefix ("/~/")) {
94 sb.erase (0, 2);
95 sb.prepend (Environment.get_home_dir ());
96 }
97 }
98
99 path = sb.str;
100 do {
101 path = path.replace ("//", "/");
102 } while (path.contains ("//"));
103
104 string new_path = (scheme + path).replace("////", "///");
105
106 if (new_path.length > 0) {
107 if (scheme != Marlin.ROOT_FS_URI && path != "/") {
108 new_path = new_path.replace ("///", "//");
109 }
110 new_path = new_path.replace("ssh:", "sftp:");
111 }
112
113 return new_path;
114 }
115
116 /** Splits the path into a protocol ending in '://" (unless it is file:// which is replaced by "")
117 * and a path beginning "/".
118 **/
119 public void split_protocol_from_path (string path, out string protocol, out string new_path) {
120 protocol = "";
121 new_path = path;
122
123 string[] explode_protocol = new_path.split ("://");
124 if (explode_protocol.length > 2) {
125 new_path = "";
126 return;
127 }
128 if (explode_protocol.length > 1) {
129 if (explode_protocol[0] == "mtp") {
130 string[] explode_path = explode_protocol[1].split ("]", 2);
131 protocol = (explode_protocol[0] + "://" + explode_path[0] + "]").replace ("///", "//");
132 /* If path is being manually edited there may not be "]" so explode_path[1] may be null*/
133 new_path = explode_path [1] ?? "";
134 } else {
135 protocol = explode_protocol[0] + "://";
136 new_path = explode_protocol[1];
137 }
138 } else {
139 protocol = Marlin.ROOT_FS_URI;
140 }
141
142 if (Marlin.ROOT_FS_URI.has_prefix (protocol)) {
143 protocol = "";
144 }
145 if (!new_path.has_prefix (Path.DIR_SEPARATOR_S)) {
146 new_path = Path.DIR_SEPARATOR_S + new_path;
147 }
148 }
149}
0\ No newline at end of file150\ No newline at end of file
1151
=== renamed file 'src/View/LocationBar.vala' => 'libwidgets/LocationBar.vala'
--- src/View/LocationBar.vala 2015-11-13 18:58:58 +0000
+++ libwidgets/LocationBar.vala 2015-11-14 13:22:20 +0000
@@ -31,7 +31,7 @@
31 if (new_path != null) {31 if (new_path != null) {
32 _path = new_path;32 _path = new_path;
3333
34 if (!bread.is_focus && !win.freeze_view_changes) {34 if (!bread.is_focus && !win.get_frozen ()) {
35 bread.text = "";35 bread.text = "";
36 bread.change_breadcrumbs (new_path);36 bread.change_breadcrumbs (new_path);
37 }37 }
@@ -45,26 +45,26 @@
45 }45 }
46 }46 }
4747
48 Marlin.View.Window win;48 Marlin.Viewable win;
4949
50 public new signal void activate (GLib.File file);50 public new signal void activate (GLib.File file);
51 public signal void activate_alternate (GLib.File file);51 public signal void activate_alternate (GLib.File file);
52 public signal void escape ();52 public signal void escape ();
53 public signal void search_mode_left ();53 public signal void search_mode_left ();
5454 public signal void reload_request ();
55 public override void get_preferred_width (out int minimum_width, out int natural_width) {55 public override void get_preferred_width (out int minimum_width, out int natural_width) {
56 minimum_width = -1;56 minimum_width = -1;
57 natural_width = 3000;57 natural_width = 3000;
58 }58 }
5959
60 public LocationBar (Marlin.View.Window win) {60 public LocationBar (Marlin.Viewable win) {
61 this.win = win;61 this.win = win;
62 bread = new Breadcrumbs (win);62 bread = new Breadcrumbs (win);
63 bread.escape.connect (() => { escape(); });63 bread.escape.connect (() => { escape(); });
64 bread.path_changed.connect (on_path_changed);64 bread.path_changed.connect (on_path_changed);
6565
66 bread.reload.connect (() => {66 bread.reload.connect (() => {
67 win.win_actions.activate_action ("refresh", null);67 win.refresh_view ();
68 });68 });
6969
70 bread.activate_alternate.connect ((file) => { activate_alternate(file); });70 bread.activate_alternate.connect ((file) => { activate_alternate(file); });
@@ -92,7 +92,8 @@
92 }92 }
9393
94 private void on_path_changed (File? file) {94 private void on_path_changed (File? file) {
95 if (file == null || win.freeze_view_changes)95 if (file == null || win.get_frozen ())
96 if (file == null)
96 return;97 return;
9798
98 win.grab_focus ();99 win.grab_focus ();
@@ -116,7 +117,7 @@
116117
117 bool autocompleted = false;118 bool autocompleted = false;
118119
119 Marlin.View.Window win;120 Marlin.Viewable win;
120121
121 double menu_x_root;122 double menu_x_root;
122 double menu_y_root;123 double menu_y_root;
@@ -124,14 +125,14 @@
124 private bool drop_data_ready = false; /* whether the drop data was received already */125 private bool drop_data_ready = false; /* whether the drop data was received already */
125 private bool drop_occurred = false; /* whether the data was dropped */126 private bool drop_occurred = false; /* whether the data was dropped */
126 private GLib.List<GLib.File> drop_file_list = null; /* the list of URIs in the drop data */127 private GLib.List<GLib.File> drop_file_list = null; /* the list of URIs in the drop data */
127 protected static FM.DndHandler dnd_handler = new FM.DndHandler ();128 protected static Marlin.DndHandler dnd_handler = new Marlin.DndHandler ();
128129
129 Gdk.DragAction current_suggested_action = 0; /* No action */130 Gdk.DragAction current_suggested_action = 0; /* No action */
130 Gdk.DragAction current_actions = 0; /* No action */131 Gdk.DragAction current_actions = 0; /* No action */
131132
132 GOF.File? drop_target_file = null;133 GOF.File? drop_target_file = null;
133134
134 public Breadcrumbs (Marlin.View.Window win)135 public Breadcrumbs (Marlin.Viewable win)
135 {136 {
136 this.win = win;137 this.win = win;
137 /* FIXME the string split of the path url is kinda too basic, we should use the Gile to split our uris and determine the protocol (if any) with g_uri_parse_scheme or g_file_get_uri_scheme */138 /* FIXME the string split of the path url is kinda too basic, we should use the Gile to split our uris and determine the protocol (if any) with g_uri_parse_scheme or g_file_get_uri_scheme */
@@ -230,7 +231,7 @@
230 if (parent != null && file.get_uri () != parent.get_uri ())231 if (parent != null && file.get_uri () != parent.get_uri ())
231 change_breadcrumbs (parent.get_uri ());232 change_breadcrumbs (parent.get_uri ());
232233
233 win.go_up ();234 win.go_to_parent ();
234 grab_focus ();235 grab_focus ();
235 });236 });
236237
@@ -262,18 +263,15 @@
262263
263 search_results.file_selected.connect ((file) => {264 search_results.file_selected.connect ((file) => {
264 win.grab_focus ();265 win.grab_focus ();
265 win.current_tab.focus_location (file);266 win.focus_location_request (file, false, true);
266
267 search_mode = false;
268 escape ();
269 });267 });
270268
271 search_results.cursor_changed.connect ((file) => {269 search_results.cursor_changed.connect ((file) => {
272 win.current_tab.focus_location_if_in_current_directory (file, true);270 win.focus_location_request (file, true, true);
273 });271 });
274272
275 search_results.first_match_found.connect ((file) => {273 search_results.first_match_found.connect ((file) => {
276 win.current_tab.focus_location_if_in_current_directory (file, true);274 win.focus_location_request (file, true, true);
277 });275 });
278276
279 search_results.hide.connect (() => {277 search_results.hide.connect (() => {
@@ -281,7 +279,7 @@
281 });279 });
282280
283 search_changed.connect ((text) => {281 search_changed.connect ((text) => {
284 search_results.search (text, win.current_tab.location);282 search_results.search (text, win.get_current_location ());
285 });283 });
286 }284 }
287285
@@ -372,7 +370,7 @@
372370
373 bool at_least_one = false;371 bool at_least_one = false;
374 foreach (AppInfo app_info in app_info_list) {372 foreach (AppInfo app_info in app_info_list) {
375 if (app_info.get_executable () != APP_NAME) {373 if (app_info.get_executable () != Environment.get_application_name ()) {
376 at_least_one = true;374 at_least_one = true;
377 var menu_item = new Gtk.ImageMenuItem.with_label (app_info.get_name ());375 var menu_item = new Gtk.ImageMenuItem.with_label (app_info.get_name ());
378 menu_item.set_data ("appinfo", app_info);376 menu_item.set_data ("appinfo", app_info);
379377
=== renamed file 'src/View/SearchResults.vala' => 'libwidgets/SearchResults.vala'
--- src/View/SearchResults.vala 2015-05-03 06:44:42 +0000
+++ libwidgets/SearchResults.vala 2015-11-14 13:22:20 +0000
@@ -101,8 +101,6 @@
101 Gtk.TreeModelFilter filter;101 Gtk.TreeModelFilter filter;
102 Gtk.ScrolledWindow scroll;102 Gtk.ScrolledWindow scroll;
103103
104 ulong cursor_changed_handler_id;
105
106 public SearchResults (Gtk.Entry entry)104 public SearchResults (Gtk.Entry entry)
107 {105 {
108 Object (entry: entry,106 Object (entry: entry,
@@ -210,7 +208,6 @@
210 Gtk.TreePath path;208 Gtk.TreePath path;
211 Gtk.TreeIter iter;209 Gtk.TreeIter iter;
212210
213 SignalHandler.block (view, cursor_changed_handler_id);
214 view.get_path_at_pos ((int) e.x, (int) e.y, out path, null, null, null);211 view.get_path_at_pos ((int) e.x, (int) e.y, out path, null, null, null);
215212
216 if (path != null) {213 if (path != null) {
@@ -218,12 +215,9 @@
218 filter.convert_iter_to_child_iter (out iter, iter);215 filter.convert_iter_to_child_iter (out iter, iter);
219 accept (iter);216 accept (iter);
220 }217 }
221 SignalHandler.unblock (view, cursor_changed_handler_id);
222 return true;218 return true;
223 });219 });
224220
225 cursor_changed_handler_id = view.cursor_changed.connect (on_cursor_changed);
226
227 key_release_event.connect (key_event);221 key_release_event.connect (key_event);
228 key_press_event.connect (key_event);222 key_press_event.connect (key_event);
229223
@@ -504,6 +498,7 @@
504 || is_grabbing)498 || is_grabbing)
505 return;499 return;
506500
501 view.cursor_changed.connect (on_cursor_changed);
507 resize_popup ();502 resize_popup ();
508503
509 var toplevel = entry.get_toplevel ();504 var toplevel = entry.get_toplevel ();
@@ -527,6 +522,7 @@
527522
528 void popdown ()523 void popdown ()
529 {524 {
525 view.cursor_changed.disconnect (on_cursor_changed);
530 entry.reset_im_context ();526 entry.reset_im_context ();
531527
532 if (is_grabbing && device != null) {528 if (is_grabbing && device != null) {
@@ -644,10 +640,9 @@
644 Gdk.beep ();640 Gdk.beep ();
645 return;641 return;
646 }642 }
647643 /* The order of these two lines is critical to prevent unwanted cursor-changed signals */
644 popdown ();
648 file_selected (file);645 file_selected (file);
649
650 popdown ();
651 }646 }
652647
653 File? get_file_at_iter (Gtk.TreeIter? iter)648 File? get_file_at_iter (Gtk.TreeIter? iter)
654649
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-11-03 15:58:50 +0000
+++ src/CMakeLists.txt 2015-11-14 13:22:20 +0000
@@ -51,17 +51,12 @@
51IF (WITH_UNITY AND UNITY_FOUND)51IF (WITH_UNITY AND UNITY_FOUND)
52 vala_precompile (VALA_C pantheon-files52 vala_precompile (VALA_C pantheon-files
53 Application.vala53 Application.vala
54 Bookmark.vala
55 BookmarkList.vala
56 ConnectServerOperation.vala54 ConnectServerOperation.vala
57 DndHandler.vala
58 Enums.vala
59 AbstractEditableLabel.vala55 AbstractEditableLabel.vala
60 SingleLineEditableLabel.vala56 SingleLineEditableLabel.vala
61 MultiLineEditableLabel.vala57 MultiLineEditableLabel.vala
62 main.vala58 main.vala
63 marlin-deep-count.vala59 marlin-deep-count.vala
64 MimeActions.vala
65 ProgressInfoWidget.vala60 ProgressInfoWidget.vala
66 ProgressUIHandler.vala61 ProgressUIHandler.vala
67 TextRenderer.vala62 TextRenderer.vala
@@ -75,21 +70,15 @@
75 View/IconSpinnerRenderer.vala70 View/IconSpinnerRenderer.vala
76 View/DirectoryNotFound.vala71 View/DirectoryNotFound.vala
77 View/AbstractDirectoryView.vala72 View/AbstractDirectoryView.vala
78 View/SearchResults.vala
79 View/Window.vala73 View/Window.vala
80 View/ViewContainer.vala74 View/ViewContainer.vala
81 View/OverlayBar.vala75 View/OverlayBar.vala
82 View/PropertiesWindow.vala76 View/PropertiesWindow.vala
83 View/Browser.vala77 View/Browser.vala
84 View/LocationBar.vala
85 View/Sidebar.vala78 View/Sidebar.vala
86 View/Slot.vala79 View/Slot.vala
87 View/Miller.vala80 View/Miller.vala
88 View/Chrome/TopMenu.vala81
89 View/Chrome/ButtonWithMenu.vala
90 View/Chrome/ViewSwicher.vala
91 View/Chrome/XsEntry.vala
92 View/Chrome/ImgEventBox.vala
93 PACKAGES82 PACKAGES
94 gtk+-3.083 gtk+-3.0
95 gio-2.084 gio-2.0
@@ -118,17 +107,12 @@
118ELSE (WITH_UNITY AND UNITY_FOUND)107ELSE (WITH_UNITY AND UNITY_FOUND)
119 vala_precompile (VALA_C pantheon-files108 vala_precompile (VALA_C pantheon-files
120 Application.vala109 Application.vala
121 Bookmark.vala
122 BookmarkList.vala
123 ConnectServerOperation.vala110 ConnectServerOperation.vala
124 DndHandler.vala
125 Enums.vala
126 AbstractEditableLabel.vala111 AbstractEditableLabel.vala
127 SingleLineEditableLabel.vala112 SingleLineEditableLabel.vala
128 MultiLineEditableLabel.vala113 MultiLineEditableLabel.vala
129 main.vala114 main.vala
130 marlin-deep-count.vala115 marlin-deep-count.vala
131 MimeActions.vala
132 ProgressInfoWidget.vala116 ProgressInfoWidget.vala
133 ProgressUIHandler.vala117 ProgressUIHandler.vala
134 TextRenderer.vala118 TextRenderer.vala
@@ -137,7 +121,6 @@
137 View/IconView.vala121 View/IconView.vala
138 View/ListView.vala122 View/ListView.vala
139 ZeitgeistManager.vala123 ZeitgeistManager.vala
140 View/SearchResults.vala
141 View/DiskRenderer.vala124 View/DiskRenderer.vala
142 View/DirectoryNotFound.vala125 View/DirectoryNotFound.vala
143 View/AbstractDirectoryView.vala126 View/AbstractDirectoryView.vala
@@ -147,15 +130,9 @@
147 View/OverlayBar.vala130 View/OverlayBar.vala
148 View/PropertiesWindow.vala131 View/PropertiesWindow.vala
149 View/Browser.vala132 View/Browser.vala
150 View/LocationBar.vala
151 View/Sidebar.vala133 View/Sidebar.vala
152 View/Slot.vala134 View/Slot.vala
153 View/Miller.vala135 View/Miller.vala
154 View/Chrome/TopMenu.vala
155 View/Chrome/ButtonWithMenu.vala
156 View/Chrome/ViewSwicher.vala
157 View/Chrome/XsEntry.vala
158 View/Chrome/ImgEventBox.vala
159 PACKAGES136 PACKAGES
160 gtk+-3.0137 gtk+-3.0
161 gio-2.0138 gio-2.0
162139
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2015-09-21 13:50:55 +0000
+++ src/View/AbstractDirectoryView.vala 2015-11-14 13:22:20 +0000
@@ -25,13 +25,6 @@
25namespace FM {25namespace FM {
26 public abstract class AbstractDirectoryView : Gtk.ScrolledWindow {26 public abstract class AbstractDirectoryView : Gtk.ScrolledWindow {
2727
28 public enum TargetType {
29 STRING,
30 TEXT_URI_LIST,
31 XDND_DIRECT_SAVE0,
32 NETSCAPE_URL
33 }
34
35 protected enum ClickZone {28 protected enum ClickZone {
36 EXPANDER,29 EXPANDER,
37 HELPER,30 HELPER,
@@ -46,15 +39,15 @@
46 const int MAX_TEMPLATES = 32;39 const int MAX_TEMPLATES = 32;
4740
48 const Gtk.TargetEntry [] drag_targets = {41 const Gtk.TargetEntry [] drag_targets = {
49 {"text/plain", Gtk.TargetFlags.SAME_APP, TargetType.STRING},42 {"text/plain", Gtk.TargetFlags.SAME_APP, Marlin.TargetType.STRING},
50 {"text/uri-list", Gtk.TargetFlags.SAME_APP, TargetType.TEXT_URI_LIST}43 {"text/uri-list", Gtk.TargetFlags.SAME_APP, Marlin.TargetType.TEXT_URI_LIST}
51 };44 };
5245
53 const Gtk.TargetEntry [] drop_targets = {46 const Gtk.TargetEntry [] drop_targets = {
54 {"text/uri-list", Gtk.TargetFlags.SAME_APP, TargetType.TEXT_URI_LIST},47 {"text/uri-list", Gtk.TargetFlags.SAME_APP, Marlin.TargetType.TEXT_URI_LIST},
55 {"text/uri-list", Gtk.TargetFlags.OTHER_APP, TargetType.TEXT_URI_LIST},48 {"text/uri-list", Gtk.TargetFlags.OTHER_APP, Marlin.TargetType.TEXT_URI_LIST},
56 {"XdndDirectSave0", Gtk.TargetFlags.OTHER_APP, TargetType.XDND_DIRECT_SAVE0},49 {"XdndDirectSave0", Gtk.TargetFlags.OTHER_APP, Marlin.TargetType.XDND_DIRECT_SAVE0},
57 {"_NETSCAPE_URL", Gtk.TargetFlags.OTHER_APP, TargetType.NETSCAPE_URL}50 {"_NETSCAPE_URL", Gtk.TargetFlags.OTHER_APP, Marlin.TargetType.NETSCAPE_URL}
58 };51 };
5952
60 const Gdk.DragAction file_drag_actions = (Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK);53 const Gdk.DragAction file_drag_actions = (Gdk.DragAction.COPY | Gdk.DragAction.MOVE | Gdk.DragAction.LINK);
@@ -235,7 +228,7 @@
235 protected Marlin.IconRenderer icon_renderer;228 protected Marlin.IconRenderer icon_renderer;
236 protected unowned Marlin.View.Slot slot;229 protected unowned Marlin.View.Slot slot;
237 protected unowned Marlin.View.Window window; /*For convenience - this can be derived from slot */230 protected unowned Marlin.View.Window window; /*For convenience - this can be derived from slot */
238 protected static DndHandler dnd_handler = new FM.DndHandler ();231 protected static Marlin.DndHandler dnd_handler = new Marlin.DndHandler ();
239232
240 protected unowned Gtk.RecentManager recent;233 protected unowned Gtk.RecentManager recent;
241234
@@ -394,9 +387,10 @@
394 Gtk.TreePath path = model.get_path (iter);387 Gtk.TreePath path = model.get_path (iter);
395 if (path != null) {388 if (path != null) {
396 select_path (path);389 select_path (path);
397 if (focus_location != null && focus_location.equal (file.location))390 if (focus_location != null && focus_location.equal (file.location)) {
398 /* set cursor and scroll to focus location*/391 /* set cursor and scroll to focus location*/
399 set_cursor (path, false, false, true); 392 set_cursor (path, false, false, true);
393 }
400 }394 }
401 }395 }
402 });396 });
@@ -1536,19 +1530,19 @@
1536 slot.reload (true); /* non-local only */1530 slot.reload (true); /* non-local only */
15371531
1538 switch (info) {1532 switch (info) {
1539 case TargetType.XDND_DIRECT_SAVE0:1533 case Marlin.TargetType.XDND_DIRECT_SAVE0:
1540 success = dnd_handler.handle_xdnddirectsave (context,1534 success = dnd_handler.handle_xdnddirectsave (context,
1541 drop_target_file,1535 drop_target_file,
1542 selection_data);1536 selection_data);
1543 break;1537 break;
15441538
1545 case TargetType.NETSCAPE_URL:1539 case Marlin.TargetType.NETSCAPE_URL:
1546 success = dnd_handler.handle_netscape_url (context,1540 success = dnd_handler.handle_netscape_url (context,
1547 drop_target_file,1541 drop_target_file,
1548 selection_data);1542 selection_data);
1549 break;1543 break;
15501544
1551 case TargetType.TEXT_URI_LIST:1545 case Marlin.TargetType.TEXT_URI_LIST:
1552 if ((current_actions & file_drag_actions) != 0) {1546 if ((current_actions & file_drag_actions) != 0) {
1553 if (selected_files != null)1547 if (selected_files != null)
1554 unselect_all ();1548 unselect_all ();
15551549
=== modified file 'src/View/Miller.vala'
--- src/View/Miller.vala 2015-07-24 08:01:21 +0000
+++ src/View/Miller.vala 2015-11-14 13:22:20 +0000
@@ -428,5 +428,9 @@
428 public override bool set_all_selected (bool all) {428 public override bool set_all_selected (bool all) {
429 return ((Marlin.View.Slot)(current_slot)).set_all_selected (all);429 return ((Marlin.View.Slot)(current_slot)).set_all_selected (all);
430 }430 }
431
432 public override void set_frozen_state (bool freeze) {
433 current_slot.set_frozen_state (freeze);
434 }
431 }435 }
432}436}
433437
=== modified file 'src/View/Sidebar.vala'
--- src/View/Sidebar.vala 2015-11-03 15:58:50 +0000
+++ src/View/Sidebar.vala 2015-11-14 13:22:20 +0000
@@ -37,7 +37,7 @@
37 private const int ICON_XPAD = 6 + ROOT_INDENTATION_XPAD;37 private const int ICON_XPAD = 6 + ROOT_INDENTATION_XPAD;
38 private const int PROP_0 = 0;38 private const int PROP_0 = 0;
3939
40 private static FM.DndHandler dnd_handler = new FM.DndHandler ();40 private static Marlin.DndHandler dnd_handler = new Marlin.DndHandler ();
4141
42 Gtk.TreeView tree_view;42 Gtk.TreeView tree_view;
43 Gtk.CellRenderer indent_renderer;43 Gtk.CellRenderer indent_renderer;
4444
=== modified file 'src/View/Slot.vala'
--- src/View/Slot.vala 2015-09-12 09:33:43 +0000
+++ src/View/Slot.vala 2015-11-14 13:22:20 +0000
@@ -351,5 +351,10 @@
351 directory.update_files ();351 directory.update_files ();
352 }352 }
353 }353 }
354
355 public override void set_frozen_state (bool freeze) {
356 set_view_updates_frozen (freeze);
357 frozen_changed (freeze);
358 }
354 }359 }
355}360}
356361
=== modified file 'src/View/ViewContainer.vala'
--- src/View/ViewContainer.vala 2015-11-05 11:26:27 +0000
+++ src/View/ViewContainer.vala 2015-11-14 13:22:20 +0000
@@ -396,11 +396,16 @@
396 if (aslot != null)396 if (aslot != null)
397 aslot.set_active_state (is_active);397 aslot.set_active_state (is_active);
398 }398 }
399399
400 public void set_frozen_state (bool is_frozen) {
401 var aslot = get_current_slot ();
402 if (aslot != null)
403 aslot.set_frozen_state (is_frozen);
404 }
405
400 public void focus_location (GLib.File? file,406 public void focus_location (GLib.File? file,
401 bool select_in_current_only = false,407 bool select_in_current_only = false,
402 bool unselect_others = false) {408 bool unselect_others = false) {
403
404 if (unselect_others || file == null) {409 if (unselect_others || file == null) {
405 get_current_slot ().set_all_selected (false);410 get_current_slot ().set_all_selected (false);
406 selected_locations = null;411 selected_locations = null;
@@ -417,7 +422,7 @@
417 File? parent = file.get_parent ();422 File? parent = file.get_parent ();
418 if (parent != null && location.equal (file.get_parent ())) {423 if (parent != null && location.equal (file.get_parent ())) {
419 if (select_in_current_only || file.query_file_type (0) != FileType.DIRECTORY) {424 if (select_in_current_only || file.query_file_type (0) != FileType.DIRECTORY) {
420 var list = new List<File> ();425 var list = new List<File> ();
421 list.prepend (file);426 list.prepend (file);
422 get_current_slot ().select_glib_files (list, file);427 get_current_slot ().select_glib_files (list, file);
423 } else428 } else
424429
=== modified file 'src/View/Window.vala'
--- src/View/Window.vala 2015-08-17 14:25:36 +0000
+++ src/View/Window.vala 2015-11-14 13:22:20 +0000
@@ -23,7 +23,7 @@
2323
24namespace Marlin.View {24namespace Marlin.View {
2525
26 public class Window : Gtk.ApplicationWindow26 public class Window : Gtk.ApplicationWindow, Marlin.Viewable
27 {27 {
28 static const GLib.ActionEntry [] win_entries = {28 static const GLib.ActionEntry [] win_entries = {
29 {"new_window", action_new_window},29 {"new_window", action_new_window},
@@ -54,6 +54,7 @@
54 public Gtk.Builder ui;54 public Gtk.Builder ui;
55 private unowned UndoManager undo_manager;55 private unowned UndoManager undo_manager;
56 public Chrome.TopMenu top_menu;56 public Chrome.TopMenu top_menu;
57 public Chrome.ViewSwitcher view_switcher;
57 public Gtk.InfoBar info_bar;58 public Gtk.InfoBar info_bar;
58 public Granite.Widgets.DynamicNotebook tabs;59 public Granite.Widgets.DynamicNotebook tabs;
59 public Marlin.Places.Sidebar sidebar;60 public Marlin.Places.Sidebar sidebar;
@@ -167,11 +168,13 @@
167 }168 }
168169
169 private void construct_top_menu () {170 private void construct_top_menu () {
170 top_menu = new Chrome.TopMenu(this);171 view_switcher = new Chrome.ViewSwitcher (win_actions.lookup_action ("view_mode") as SimpleAction);
172 view_switcher.mode = Preferences.settings.get_enum("default-viewmode");
173 top_menu = new Chrome.TopMenu(view_switcher, this as Marlin.Viewable);
171 top_menu.set_show_close_button (true);174 top_menu.set_show_close_button (true);
172 top_menu.set_custom_title (new Gtk.Label (null));175 top_menu.set_custom_title (new Gtk.Label (null));
173 }176 }
174177
175 private void construct_info_bar () {178 private void construct_info_bar () {
176 info_bar = new Gtk.InfoBar ();179 info_bar = new Gtk.InfoBar ();
177180
@@ -210,6 +213,20 @@
210213
211 top_menu.forward.connect (on_go_forward);214 top_menu.forward.connect (on_go_forward);
212 top_menu.back.connect (on_go_back);215 top_menu.back.connect (on_go_back);
216 top_menu.focus_in_event.connect (() => {
217 current_tab.set_frozen_state (true);
218 return false;
219 });
220 top_menu.focus_out_event.connect (() => {
221 current_tab.set_frozen_state (false);
222 grab_focus ();
223 return true;
224 });
225 top_menu.escape.connect (() => {
226 current_tab.set_frozen_state (false);
227 grab_focus ();
228 });
229 top_menu.reload_request.connect (action_reload);
213230
214 undo_manager.request_menu_update.connect (undo_redo_menu_update_callback);231 undo_manager.request_menu_update.connect (undo_redo_menu_update_callback);
215232
@@ -461,7 +478,7 @@
461 (application as Marlin.Application).quit ();478 (application as Marlin.Application).quit ();
462 }479 }
463480
464 private void action_reload (GLib.SimpleAction action, GLib.Variant? param) {481 private void action_reload () {
465 /* avoid spawning reload when key kept pressed */482 /* avoid spawning reload when key kept pressed */
466 if (tabs.current.working || !current_tab.ready)483 if (tabs.current.working || !current_tab.ready)
467 return;484 return;
@@ -928,6 +945,7 @@
928 top_menu.set_back_menu (current_tab.get_go_back_path_list ());945 top_menu.set_back_menu (current_tab.get_go_back_path_list ());
929 top_menu.set_forward_menu (current_tab.get_go_forward_path_list ());946 top_menu.set_forward_menu (current_tab.get_go_forward_path_list ());
930 top_menu.view_switcher.mode = current_tab.view_mode;947 top_menu.view_switcher.mode = current_tab.view_mode;
948 Preferences.settings.set_enum ("default-viewmode", (int)(current_tab.view_mode));
931 }949 }
932 }950 }
933951
@@ -997,5 +1015,27 @@
997 application.set_accels_for_action ("win.info::HELP", {"F1"});1015 application.set_accels_for_action ("win.info::HELP", {"F1"});
998 application.set_accels_for_action ("win.info::ABOUT", {"F3"});1016 application.set_accels_for_action ("win.info::ABOUT", {"F3"});
999 }1017 }
1018
1019 public bool get_frozen () {
1020 return freeze_view_changes;
1021 }
1022
1023 public GLib.File get_current_location () {
1024 return current_tab.location;
1025 }
1026
1027 public void refresh_view () {
1028 action_reload ();
1029 }
1030
1031 public void focus_location_request (GLib.File? loc,
1032 bool select_in_current_only = false,
1033 bool unselect_others = false) {
1034 current_tab.focus_location (loc, select_in_current_only, unselect_others);
1035 }
1036
1037 public void go_to_parent () {
1038 go_up ();
1039 }
1000 }1040 }
1001}1041}

Subscribers

People subscribed via source and target branches

to all changes: