Merge lp:~jeremywootten/pantheon-files/drag-tab-to-new-window into lp:~elementary-apps/pantheon-files/trunk
- drag-tab-to-new-window
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Danielle Foré | ||||||||
Approved revision: | 1970 | ||||||||
Merged at revision: | 2121 | ||||||||
Proposed branch: | lp:~jeremywootten/pantheon-files/drag-tab-to-new-window | ||||||||
Merge into: | lp:~elementary-apps/pantheon-files/trunk | ||||||||
Diff against target: |
371 lines (+162/-51) 4 files modified
src/Application.vala (+81/-26) src/QuicklistHandler.vala (+1/-1) src/View/Sidebar.vala (+1/-1) src/View/Window.vala (+79/-23) |
||||||||
To merge this branch: | bzr merge lp:~jeremywootten/pantheon-files/drag-tab-to-new-window | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danielle Foré | ux | Approve | |
Review via email: mp+291111@code.launchpad.net |
Commit message
Form new windows by dragging tabs; limit rate and number of new windows.
Description of the change
This branch addresses some issues around window creation.
1) Implement forming new windows by dragging tabs out of the window. The window is created where dropped.
2) A limit is put on the rate of window creation using the keyboard (Ctrl-N).
3) Only one function in Application is now allowed to create windows.
Danielle Foré (danrabbit) wrote : | # |
The expander is super ugly :/
Jeremy Wootten (jeremywootten) wrote : | # |
Expander now removed. Instead the sidebar is allowed to shrink to zero width and is hidden or revealed just by changing the position of the paned (mouse) or by pressing F9 (keyboard). The shortcut only affects the currently focused window and does not change the "show-sidebar" setting.
The visible sidebar width (paned position not the sidebar allocated width) is saved when the first window is closed.
On reopening the visible width of the sidebar is restored to the larger of the minimum sidebar width (default = 96) or the saved width, unless the "show-sidebar" setting is false.
- 1970. By Jeremy Wootten
-
Implement drag tab to new window
Jeremy Wootten (jeremywootten) wrote : | # |
As requested, the branch has been pruned to contain only the drag to new tab feature. A new branch will be created based on this one, to implement the auto-tiling and sidebar in new window management.
Danielle Foré (danrabbit) wrote : | # |
I can confirm that this branch solves the two issues now attached to it.
Preview Diff
1 | === modified file 'src/Application.vala' | |||
2 | --- src/Application.vala 2015-08-17 08:55:18 +0000 | |||
3 | +++ src/Application.vala 2016-04-21 11:55:35 +0000 | |||
4 | @@ -31,6 +31,7 @@ | |||
5 | 31 | private Gtk.RecentManager recent; | 31 | private Gtk.RecentManager recent; |
6 | 32 | 32 | ||
7 | 33 | private const int MARLIN_ACCEL_MAP_SAVE_DELAY = 15; | 33 | private const int MARLIN_ACCEL_MAP_SAVE_DELAY = 15; |
8 | 34 | private const uint MAX_WINDOWS = 25; | ||
9 | 34 | 35 | ||
10 | 35 | public int window_count { get; private set; } | 36 | public int window_count { get; private set; } |
11 | 36 | 37 | ||
12 | @@ -109,7 +110,7 @@ | |||
13 | 109 | #endif | 110 | #endif |
14 | 110 | 111 | ||
15 | 111 | window_count = 0; | 112 | window_count = 0; |
17 | 112 | this.window_added.connect (() => {window_count++;}); | 113 | this.window_added.connect_after (() => {window_count++;}); |
18 | 113 | this.window_removed.connect (() => {window_count--;}); | 114 | this.window_removed.connect (() => {window_count--;}); |
19 | 114 | } | 115 | } |
20 | 115 | 116 | ||
21 | @@ -273,38 +274,78 @@ | |||
22 | 273 | open_tabs (files); | 274 | open_tabs (files); |
23 | 274 | else { | 275 | else { |
24 | 275 | /* Open windows at each requested location. */ | 276 | /* Open windows at each requested location. */ |
46 | 276 | foreach (var file in files) | 277 | foreach (var file in files) { |
47 | 277 | open_window (file); | 278 | create_window (file); |
48 | 278 | } | 279 | } |
49 | 279 | } | 280 | } |
50 | 280 | 281 | } | |
51 | 281 | public void create_window (File location = File.new_for_path (Environment.get_home_dir ()), | 282 | |
52 | 282 | Gdk.Screen screen = Gdk.Screen.get_default (), | 283 | /* All window creation should be done via this function */ |
53 | 283 | Marlin.ViewMode viewmode = Marlin.ViewMode.PREFERRED) { | 284 | public Marlin.View.Window? create_window (File location = File.new_for_path (Environment.get_home_dir ()), |
54 | 284 | 285 | Marlin.ViewMode viewmode = Marlin.ViewMode.PREFERRED, | |
55 | 285 | open_window (location, screen, viewmode); | 286 | int x = -1, int y = -1) { |
56 | 286 | } | 287 | |
57 | 287 | 288 | if (this.get_windows ().length () >= MAX_WINDOWS) { | |
58 | 288 | private void open_window (File? location, Gdk.Screen screen = Gdk.Screen.get_default (), Marlin.ViewMode viewmode = Marlin.ViewMode.PREFERRED) { | 289 | return null; |
59 | 289 | (add_view_window (screen)).add_tab (location, viewmode); | 290 | } |
60 | 290 | } | 291 | |
61 | 291 | 292 | Marlin.View.Window win; | |
62 | 292 | private Marlin.View.Window add_view_window (Gdk.Screen screen) { | 293 | Gdk.Rectangle? new_win_rect = null; |
63 | 293 | var window = new Marlin.View.Window (this, screen); | 294 | Gdk.Screen screen = Gdk.Screen.get_default (); |
64 | 294 | this.add_window (window as Gtk.Window); | 295 | var aw = this.get_active_window (); |
65 | 295 | plugins.interface_loaded (window as Gtk.Widget); | 296 | if (aw != null) { |
66 | 296 | return window; | 297 | /* This is not the first window - determine size and position of new window */ |
67 | 298 | int w, h; | ||
68 | 299 | aw.get_size (out w, out h); | ||
69 | 300 | /* Calculate difference between the visible width of the window and the width returned by Gtk+, | ||
70 | 301 | * which might include client side decorations (shadow) in some versions (bug 756618). | ||
71 | 302 | * Assumes top_menu stretches full visible width. */ | ||
72 | 303 | var tm_aw = ((Marlin.View.Window)aw).top_menu.get_allocated_width (); | ||
73 | 304 | int shadow_width = (w - tm_aw) / 2; | ||
74 | 305 | shadow_width -= 10; //Allow a small gap between adjacent windows | ||
75 | 306 | screen = aw.get_screen (); | ||
76 | 307 | if (x <= 0 || y <= 0) { | ||
77 | 308 | /* Place holder for auto-tiling code. If missing then new window will be placed | ||
78 | 309 | * at the default position (centre of screen) */ | ||
79 | 310 | } else { /* New window is a dropped tab */ | ||
80 | 311 | /* Move new window so that centre of upper edge just inside the window is at mouse | ||
81 | 312 | * cursor position. This makes it easier for used to readjust window position with mouse if required. | ||
82 | 313 | */ | ||
83 | 314 | x -= (shadow_width + w / 2); | ||
84 | 315 | y -= (shadow_width + 6); | ||
85 | 316 | new_win_rect = {x, y, w, h}; | ||
86 | 317 | } | ||
87 | 318 | } | ||
88 | 319 | |||
89 | 320 | /* New window will not size or show itself if new_win_rect is not null */ | ||
90 | 321 | win = new Marlin.View.Window (this, screen, new_win_rect == null); | ||
91 | 322 | this.add_window (win as Gtk.Window); | ||
92 | 323 | plugins.interface_loaded (win as Gtk.Widget); | ||
93 | 324 | |||
94 | 325 | if (!win.is_first_window) { /* First window will restore tabs itself */ | ||
95 | 326 | win.add_tab (location, viewmode); | ||
96 | 327 | } | ||
97 | 328 | |||
98 | 329 | if (new_win_rect != null) { | ||
99 | 330 | move_resize_window (win, new_win_rect); | ||
100 | 331 | win.show (); | ||
101 | 332 | } | ||
102 | 333 | |||
103 | 334 | return win; | ||
104 | 297 | } | 335 | } |
105 | 298 | 336 | ||
106 | 299 | private void open_tabs (File[]? files, Gdk.Screen screen = Gdk.Screen.get_default ()) { | 337 | private void open_tabs (File[]? files, Gdk.Screen screen = Gdk.Screen.get_default ()) { |
107 | 300 | Marlin.View.Window window = null; | 338 | Marlin.View.Window window = null; |
108 | 301 | 339 | ||
109 | 302 | /* Get the first window, if any, else create a new window */ | 340 | /* Get the first window, if any, else create a new window */ |
111 | 303 | if (windows_exist ()) | 341 | if (windows_exist ()) { |
112 | 304 | window = (this.get_windows ()).data as Marlin.View.Window; | 342 | window = (this.get_windows ()).data as Marlin.View.Window; |
116 | 305 | else | 343 | } else { |
117 | 306 | window = add_view_window (screen); | 344 | window = create_window (); |
118 | 307 | 345 | if (window == null) { /* Maximum number of windows reached */ | |
119 | 346 | return; | ||
120 | 347 | } | ||
121 | 348 | } | ||
122 | 308 | if (files == null) { | 349 | if (files == null) { |
123 | 309 | /* Restore session if settings allow */ | 350 | /* Restore session if settings allow */ |
124 | 310 | if (!Preferences.settings.get_boolean ("restore-tabs") || window.restore_tabs () < 1) { | 351 | if (!Preferences.settings.get_boolean ("restore-tabs") || window.restore_tabs () < 1) { |
125 | @@ -323,4 +364,18 @@ | |||
126 | 323 | unowned List<weak Gtk.Window> windows = this.get_windows (); | 364 | unowned List<weak Gtk.Window> windows = this.get_windows (); |
127 | 324 | return (windows != null && windows.data != null); | 365 | return (windows != null && windows.data != null); |
128 | 325 | } | 366 | } |
129 | 367 | |||
130 | 368 | private void move_resize_window (Gtk.Window win, Gdk.Rectangle? rect) { | ||
131 | 369 | if (rect == null) { | ||
132 | 370 | return; | ||
133 | 371 | } | ||
134 | 372 | |||
135 | 373 | if (rect.x > 0 && rect.y > 0) { | ||
136 | 374 | win.move (rect.x, rect.y); | ||
137 | 375 | } | ||
138 | 376 | if (rect.width > 0 && rect.height > 0) { | ||
139 | 377 | win.resize (rect.width, rect.height); | ||
140 | 378 | } | ||
141 | 379 | win.show (); | ||
142 | 380 | } | ||
143 | 326 | } | 381 | } |
144 | 327 | 382 | ||
145 | === modified file 'src/QuicklistHandler.vala' | |||
146 | --- src/QuicklistHandler.vala 2015-05-03 06:44:42 +0000 | |||
147 | +++ src/QuicklistHandler.vala 2016-04-21 11:55:35 +0000 | |||
148 | @@ -104,7 +104,7 @@ | |||
149 | 104 | menuitem.property_set ("label", bookmark.label); | 104 | menuitem.property_set ("label", bookmark.label); |
150 | 105 | menuitem.item_activated.connect (() => { | 105 | menuitem.item_activated.connect (() => { |
151 | 106 | var location = bookmark.get_location (); | 106 | var location = bookmark.get_location (); |
153 | 107 | Marlin.Application.get ().create_window (location, Gdk.Screen.get_default ()); | 107 | Marlin.Application.get ().create_window (location); |
154 | 108 | }); | 108 | }); |
155 | 109 | 109 | ||
156 | 110 | ql.child_add_position (menuitem, index); | 110 | ql.child_add_position (menuitem, index); |
157 | 111 | 111 | ||
158 | === modified file 'src/View/Sidebar.vala' | |||
159 | --- src/View/Sidebar.vala 2016-04-17 21:21:55 +0000 | |||
160 | +++ src/View/Sidebar.vala 2016-04-21 11:55:35 +0000 | |||
161 | @@ -1214,7 +1214,7 @@ | |||
162 | 1214 | var location = mount.get_default_location (); | 1214 | var location = mount.get_default_location (); |
163 | 1215 | if (flags == Marlin.OpenFlag.NEW_WINDOW) { | 1215 | if (flags == Marlin.OpenFlag.NEW_WINDOW) { |
164 | 1216 | var app = Marlin.Application.get (); | 1216 | var app = Marlin.Application.get (); |
166 | 1217 | app.create_window (location, window.get_screen ()); | 1217 | app.create_window (location); |
167 | 1218 | } else if (flags == Marlin.OpenFlag.NEW_TAB) { | 1218 | } else if (flags == Marlin.OpenFlag.NEW_TAB) { |
168 | 1219 | window.add_tab (location, Marlin.ViewMode.CURRENT); | 1219 | window.add_tab (location, Marlin.ViewMode.CURRENT); |
169 | 1220 | } else { | 1220 | } else { |
170 | 1221 | 1221 | ||
171 | === modified file 'src/View/Window.vala' | |||
172 | --- src/View/Window.vala 2016-04-12 08:47:09 +0000 | |||
173 | +++ src/View/Window.vala 2016-04-21 11:55:35 +0000 | |||
174 | @@ -57,6 +57,7 @@ | |||
175 | 57 | public Chrome.ViewSwitcher view_switcher; | 57 | public Chrome.ViewSwitcher view_switcher; |
176 | 58 | public Gtk.InfoBar info_bar; | 58 | public Gtk.InfoBar info_bar; |
177 | 59 | public Granite.Widgets.DynamicNotebook tabs; | 59 | public Granite.Widgets.DynamicNotebook tabs; |
178 | 60 | private Gtk.Paned lside_pane; | ||
179 | 60 | public Marlin.Places.Sidebar sidebar; | 61 | public Marlin.Places.Sidebar sidebar; |
180 | 61 | public ViewContainer? current_tab = null; | 62 | public ViewContainer? current_tab = null; |
181 | 62 | public uint window_number; | 63 | public uint window_number; |
182 | @@ -86,7 +87,8 @@ | |||
183 | 86 | action_edit_path (); | 87 | action_edit_path (); |
184 | 87 | } | 88 | } |
185 | 88 | 89 | ||
187 | 89 | public Window (Marlin.Application app, Gdk.Screen myscreen) { | 90 | public Window (Marlin.Application app, Gdk.Screen myscreen, bool show_window = true) { |
188 | 91 | |||
189 | 90 | /* Capture application window_count and active_window before they can change */ | 92 | /* Capture application window_count and active_window before they can change */ |
190 | 91 | window_number = app.window_count; | 93 | window_number = app.window_count; |
191 | 92 | application = app; | 94 | application = app; |
192 | @@ -107,12 +109,23 @@ | |||
193 | 107 | 109 | ||
194 | 108 | connect_signals (); | 110 | connect_signals (); |
195 | 109 | make_bindings (); | 111 | make_bindings (); |
197 | 110 | show (); | 112 | |
198 | 113 | if (show_window) { /* otherwise Application will size and show window */ | ||
199 | 114 | if (Preferences.settings.get_boolean("maximized")) { | ||
200 | 115 | maximize(); | ||
201 | 116 | } else { | ||
202 | 117 | resize (Preferences.settings.get_int("window-width"), | ||
203 | 118 | Preferences.settings.get_int("window-height")); | ||
204 | 119 | } | ||
205 | 120 | show (); | ||
206 | 121 | } | ||
207 | 111 | } | 122 | } |
208 | 112 | 123 | ||
209 | 113 | private void build_window () { | 124 | private void build_window () { |
211 | 114 | var lside_pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); | 125 | lside_pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); |
212 | 115 | lside_pane.show (); | 126 | lside_pane.show (); |
213 | 127 | /* Only show side bar in first window - (to be confirmed) */ | ||
214 | 128 | |||
215 | 116 | lside_pane.pack1 (sidebar, false, false); | 129 | lside_pane.pack1 (sidebar, false, false); |
216 | 117 | lside_pane.pack2 (tabs, true, false); | 130 | lside_pane.pack2 (tabs, true, false); |
217 | 118 | 131 | ||
218 | @@ -131,20 +144,30 @@ | |||
219 | 131 | } | 144 | } |
220 | 132 | 145 | ||
221 | 133 | /** Apply preferences */ | 146 | /** Apply preferences */ |
222 | 134 | lside_pane.position = Preferences.settings.get_int ("sidebar-width"); | ||
223 | 135 | get_action ("show_sidebar").set_state (Preferences.settings.get_boolean ("show-sidebar")); | ||
224 | 136 | get_action ("show_hidden").set_state (Preferences.settings.get_boolean ("show-hiddenfiles")); | 147 | get_action ("show_hidden").set_state (Preferences.settings.get_boolean ("show-hiddenfiles")); |
225 | 137 | 148 | ||
228 | 138 | set_default_size (Preferences.settings.get_int("window-width"), | 149 | var show_sidebar_pref = Preferences.settings.get_boolean ("show-sidebar"); |
229 | 139 | Preferences.settings.get_int("window-height")); | 150 | get_action ("show_sidebar").set_state (show_sidebar_pref); |
230 | 151 | show_sidebar (true); | ||
231 | 140 | 152 | ||
234 | 141 | if (Preferences.settings.get_boolean("maximized")) | 153 | if (is_first_window) { |
235 | 142 | maximize(); | 154 | window_position = Gtk.WindowPosition.CENTER; |
236 | 155 | } else { /* Allow new window created by tab dragging to be positioned where dropped */ | ||
237 | 156 | window_position = Gtk.WindowPosition.NONE; | ||
238 | 157 | } | ||
239 | 143 | } | 158 | } |
240 | 144 | 159 | ||
241 | 145 | private void construct_sidebar () { | 160 | private void construct_sidebar () { |
242 | 146 | sidebar = new Marlin.Places.Sidebar (this); | 161 | sidebar = new Marlin.Places.Sidebar (this); |
244 | 147 | sidebar.show (); | 162 | } |
245 | 163 | |||
246 | 164 | public void show_sidebar (bool show = true) { | ||
247 | 165 | var show_sidebar = (get_action ("show_sidebar")).state.get_boolean (); | ||
248 | 166 | if (show && show_sidebar) { | ||
249 | 167 | lside_pane.position = Preferences.settings.get_int ("sidebar-width"); | ||
250 | 168 | } else { | ||
251 | 169 | lside_pane.position = 0; | ||
252 | 170 | } | ||
253 | 148 | } | 171 | } |
254 | 149 | 172 | ||
255 | 150 | private void construct_notebook () { | 173 | private void construct_notebook () { |
256 | @@ -152,6 +175,8 @@ | |||
257 | 152 | tabs.show_tabs = true; | 175 | tabs.show_tabs = true; |
258 | 153 | tabs.allow_restoring = true; | 176 | tabs.allow_restoring = true; |
259 | 154 | tabs.allow_duplication = true; | 177 | tabs.allow_duplication = true; |
260 | 178 | tabs.allow_new_window = true; | ||
261 | 179 | |||
262 | 155 | this.configure_event.connect_after ((e) => { | 180 | this.configure_event.connect_after ((e) => { |
263 | 156 | tabs.set_size_request (e.width / 2, -1); | 181 | tabs.set_size_request (e.width / 2, -1); |
264 | 157 | return false; | 182 | return false; |
265 | @@ -296,6 +321,16 @@ | |||
266 | 296 | add_tab (File.new_for_uri (((tab.page as ViewContainer).uri))); | 321 | add_tab (File.new_for_uri (((tab.page as ViewContainer).uri))); |
267 | 297 | }); | 322 | }); |
268 | 298 | 323 | ||
269 | 324 | tabs.tab_moved.connect ((tab, x, y) => { | ||
270 | 325 | var vc = tab.page as ViewContainer; | ||
271 | 326 | ((Marlin.Application) application).create_window (vc.location, real_mode (vc.view_mode), x, y); | ||
272 | 327 | /* A crash occurs if the original tab is removed while processing the signal */ | ||
273 | 328 | GLib.Idle.add (() => { | ||
274 | 329 | remove_tab (vc); | ||
275 | 330 | return false; | ||
276 | 331 | }); | ||
277 | 332 | }); | ||
278 | 333 | |||
279 | 299 | sidebar.request_focus.connect (() => { | 334 | sidebar.request_focus.connect (() => { |
280 | 300 | return !current_tab.locked_focus && !top_menu.locked_focus; | 335 | return !current_tab.locked_focus && !top_menu.locked_focus; |
281 | 301 | }); | 336 | }); |
282 | @@ -306,11 +341,12 @@ | |||
283 | 306 | } | 341 | } |
284 | 307 | 342 | ||
285 | 308 | private void make_bindings () { | 343 | private void make_bindings () { |
288 | 309 | /*Preference bindings */ | 344 | if (is_first_window) { |
289 | 310 | Preferences.settings.bind("show-sidebar", sidebar, "visible", SettingsBindFlags.DEFAULT); | 345 | /*Preference bindings */ |
290 | 346 | Preferences.settings.bind("show-sidebar", sidebar, "visible", SettingsBindFlags.GET); | ||
291 | 347 | Preferences.settings.bind("sidebar-width", lside_pane, "position", SettingsBindFlags.DEFAULT); | ||
292 | 311 | 348 | ||
295 | 312 | /* keyboard shortcuts bindings */ | 349 | /* keyboard shortcuts bindings */ |
294 | 313 | if (is_first_window) { | ||
296 | 314 | unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ()); | 350 | unowned Gtk.BindingSet binding_set = Gtk.BindingSet.by_class (get_class ()); |
297 | 315 | Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("BackSpace"), 0, "go_up", 0); | 351 | Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("BackSpace"), 0, "go_up", 0); |
298 | 316 | Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("XF86Back"), 0, "go_back", 0); | 352 | Gtk.BindingEntry.add_signal (binding_set, Gdk.keyval_from_name ("XF86Back"), 0, "go_back", 0); |
299 | @@ -444,8 +480,10 @@ | |||
300 | 444 | tab.close (); | 480 | tab.close (); |
301 | 445 | } | 481 | } |
302 | 446 | 482 | ||
305 | 447 | public void add_window(File location, Marlin.ViewMode mode){ | 483 | public void add_window (File location = File.new_for_path (Environment.get_home_dir ()), |
306 | 448 | ((Marlin.Application) application).create_window (location, screen, real_mode (mode)); | 484 | Marlin.ViewMode mode = Marlin.ViewMode.PREFERRED, |
307 | 485 | int x = -1, int y = -1) { | ||
308 | 486 | ((Marlin.Application) application).create_window (location, real_mode (mode), x, y); | ||
309 | 449 | } | 487 | } |
310 | 450 | 488 | ||
311 | 451 | private void undo_actions_set_insensitive () { | 489 | private void undo_actions_set_insensitive () { |
312 | @@ -491,8 +529,19 @@ | |||
313 | 491 | } | 529 | } |
314 | 492 | } | 530 | } |
315 | 493 | 531 | ||
316 | 532 | private bool adding_window = false; | ||
317 | 494 | private void action_new_window (GLib.SimpleAction action, GLib.Variant? param) { | 533 | private void action_new_window (GLib.SimpleAction action, GLib.Variant? param) { |
319 | 495 | (application as Marlin.Application).create_window (); | 534 | /* Limit rate of adding new windows using the keyboard */ |
320 | 535 | if (adding_window) { | ||
321 | 536 | return; | ||
322 | 537 | } else { | ||
323 | 538 | adding_window = true; | ||
324 | 539 | add_window (); | ||
325 | 540 | GLib.Timeout.add (500, () => { | ||
326 | 541 | adding_window = false; | ||
327 | 542 | return false; | ||
328 | 543 | }); | ||
329 | 544 | } | ||
330 | 496 | } | 545 | } |
331 | 497 | 546 | ||
332 | 498 | private void action_quit (GLib.SimpleAction action, GLib.Variant? param) { | 547 | private void action_quit (GLib.SimpleAction action, GLib.Variant? param) { |
333 | @@ -680,7 +729,10 @@ | |||
334 | 680 | private void change_state_show_sidebar (GLib.SimpleAction action) { | 729 | private void change_state_show_sidebar (GLib.SimpleAction action) { |
335 | 681 | bool state = !action.state.get_boolean (); | 730 | bool state = !action.state.get_boolean (); |
336 | 682 | action.set_state (new GLib.Variant.boolean (state)); | 731 | action.set_state (new GLib.Variant.boolean (state)); |
338 | 683 | Preferences.settings.set_boolean ("show-sidebar", state); | 732 | if (!state) { |
339 | 733 | Preferences.settings.set_int ("sidebar-width", lside_pane.position); | ||
340 | 734 | } | ||
341 | 735 | show_sidebar (state); | ||
342 | 684 | } | 736 | } |
343 | 685 | 737 | ||
344 | 686 | private void connect_to_server () { | 738 | private void connect_to_server () { |
345 | @@ -789,11 +841,7 @@ | |||
346 | 789 | } | 841 | } |
347 | 790 | 842 | ||
348 | 791 | private void save_geometries () { | 843 | private void save_geometries () { |
354 | 792 | Gtk.Allocation sidebar_alloc; | 844 | save_sidebar_width (); |
350 | 793 | sidebar.get_allocation (out sidebar_alloc); | ||
351 | 794 | |||
352 | 795 | if (sidebar_alloc.width > 1) | ||
353 | 796 | Preferences.settings.set_int("sidebar-width", sidebar_alloc.width); | ||
355 | 797 | 845 | ||
356 | 798 | bool is_maximized = (bool) get_window().get_state() & Gdk.WindowState.MAXIMIZED; | 846 | bool is_maximized = (bool) get_window().get_state() & Gdk.WindowState.MAXIMIZED; |
357 | 799 | 847 | ||
358 | @@ -807,6 +855,14 @@ | |||
359 | 807 | Preferences.settings.set_boolean("maximized", is_maximized); | 855 | Preferences.settings.set_boolean("maximized", is_maximized); |
360 | 808 | } | 856 | } |
361 | 809 | 857 | ||
362 | 858 | private void save_sidebar_width () { | ||
363 | 859 | var sw = lside_pane.get_position (); | ||
364 | 860 | var mw = Preferences.settings.get_int("minimum-sidebar-width"); | ||
365 | 861 | |||
366 | 862 | sw = int.max (sw, mw); | ||
367 | 863 | Preferences.settings.set_int("sidebar-width", sw); | ||
368 | 864 | } | ||
369 | 865 | |||
370 | 810 | private void save_tabs () { | 866 | private void save_tabs () { |
371 | 811 | VariantBuilder vb = new VariantBuilder (new VariantType ("a(uss)")); | 867 | VariantBuilder vb = new VariantBuilder (new VariantType ("a(uss)")); |
372 | 812 | 868 |
I think your idea about hiding the sidebar on new windows makes sense, but you've introduced an issue where if you close that first window it's impossible to get the sidebar back. Even killing everything and resetting the dconf key, I can't get the sidebar back. We should probably enforce that if you close the "main window" the sidebar will show on one of the other windows.
If I hold down Ctrl N, after the 3rd window everything crashes