334
private void make_new_tab (File location = File.new_for_commandline_arg (Environment.get_home_dir ())) {
335
var content = new View.ViewContainer (this, location,
336
current_tab != null ? current_tab.view_mode : Preferences.settings.get_enum("default-viewmode"));
342
private void make_new_tab (File location = File.new_for_commandline_arg (Environment.get_home_dir ()),
345
if (current_tab != null)
346
viewmode = current_tab.view_mode;
348
viewmode = Preferences.settings.get_enum ("default-viewmode");
351
var content = new View.ViewContainer (this, location, viewmode);
338
352
var tab = new Granite.Widgets.Tab ("", null, content);
340
353
content.tab_name_changed.connect ((tab_name) => {
341
354
tab.label = tab_name;
344
tabs.insert_tab (tab, -1);
357
change_tab ((int)tabs.insert_tab (tab, -1));
346
358
tabs.current = tab;
347
change_tab (tabs.get_tab_position (tab));
350
public void add_tab (File location) {
351
make_new_tab (location);
361
public void add_tab (File location, int viewmode = -1) {
362
make_new_tab (location, viewmode);
353
363
/* The following fixes a bug where upon first opening
354
364
Files, the overlay status bar is shown empty. */
355
365
if (tabs.n_tabs == 1) {
431
447
Preferences.settings.set_boolean("maximized", is_maximized);
450
private void save_tabs () {
451
VariantBuilder vb = new VariantBuilder (new VariantType ("a(uss)"));
453
foreach (var tab in tabs.tabs) {
454
assert (tab != null);
455
var view = tab.page as ViewContainer;
457
/* Do not save if "File does not exist" or "Does not belong to you" */
458
if (!view.can_show_folder)
463
GLib.Uri.escape_string (view.get_root_uri () ?? Environment.get_home_dir ()),
464
GLib.Uri.escape_string (view.get_tip_uri () ?? "")
468
Preferences.settings.set_value ("tab-info-list", vb.end ());
469
Preferences.settings.set_int ("active-tab-position", tabs.get_tab_position (tabs.current));
472
public uint restore_tabs () {
473
GLib.Variant tab_info_array = Preferences.settings.get_value ("tab-info-list");
474
GLib.VariantIter iter = new GLib.VariantIter (tab_info_array);
477
string root_uri = null;
478
string tip_uri = null;
480
/* inhibit unnecessary changes of view and rendering of location bar while restoring tabs
481
* as this causes all sorts of problems */
482
freeze_view_changes = true;
483
while (iter.next ("(uss)", out viewmode, out root_uri, out tip_uri)) {
484
if (viewmode < 0 || viewmode > 2 || root_uri == null || root_uri == "" || tip_uri == null)
487
GLib.File root_location = GLib.File.new_for_uri (GLib.Uri.unescape_string (root_uri));
489
add_tab (root_location, viewmode);
491
if (viewmode == ViewMode.MILLER && tip_uri != root_uri)
492
expand_miller_view (tip_uri, root_location);
500
freeze_view_changes = false;
502
int active_tab_position = Preferences.settings.get_int ("active-tab-position");
503
if (active_tab_position >=0 && active_tab_position < tabs_added) {
504
tabs.current = tabs.get_tab_by_index (active_tab_position);
505
change_tab (active_tab_position);
508
string path = current_tab.get_tip_uri ();
510
path = current_tab.get_root_uri ();
512
/* Render the final path in the location bar without animation */
513
top_menu.location_bar.bread.animation_visible = false;
514
top_menu.location_bar.path = path;
515
/* restore location bar animation */
516
top_menu.location_bar.bread.animation_visible = true;
520
private void expand_miller_view (string tip_uri, GLib.File root_location) {
521
var tab = tabs.current;
522
var view = tab.page as ViewContainer;
523
var mwcols = view.mwcol;
524
var unescaped_tip_uri = GLib.Uri.unescape_string (tip_uri);
525
var tip_location = GLib.File.new_for_uri (unescaped_tip_uri);
526
var relative_path = root_location.get_relative_path (tip_location);
527
var slot = mwcols.active_slot;
530
FM.Directory.View dview;
532
if (relative_path != null) {
533
string [] dirs = relative_path.split (GLib.Path.DIR_SEPARATOR_S);
534
string uri = root_location.get_uri ();
536
foreach (string dir in dirs) {
537
uri += (GLib.Path.DIR_SEPARATOR_S + dir);
538
gfile = GLib.File.new_for_uri (uri);
539
dview = slot.view_box as FM.Directory.View;
541
dview.column_add_location (gfile);
542
slot = mwcols.get_last_slot ();
545
warning ("Invalid tip uri for Miller View");
434
549
public Gtk.ActionGroup get_actiongroup () {
435
550
return this.main_actions;