Skip to content
Merged
9 changes: 9 additions & 0 deletions libcore/gof-directory-async.vala
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ public class Async : Object {
if (file_loaded_func == null) {
done_loading ();
}

if (file.is_directory) { /* Fails for non-existent directories */
file.set_expanded (true);
}
}

public void block_monitor () {
Expand Down Expand Up @@ -1121,6 +1125,11 @@ public class Async : Object {
}

public static bool remove_dir_from_cache (Async dir) {
if (dir.file.is_directory) {
dir.file.is_expanded = false;
dir.file.changed ();
}

if (directory_cache.remove (dir.creation_key)) {
directory_cache.remove (dir.location);
dir.removed_from_cache = true;
Expand Down
2 changes: 1 addition & 1 deletion src/IconRenderer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace Marlin {
}

} else if (file.is_directory) {
bool expanded = (flags & Gtk.CellRendererState.EXPANDED) > 0;
bool expanded = (flags & Gtk.CellRendererState.EXPANDED) > 0 || file.is_expanded;
if (expanded) {
special_icon_name = "folder-open";
}
Expand Down
1 change: 0 additions & 1 deletion src/View/ViewContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ namespace Marlin.View {

public void on_slot_directory_loaded (GOF.Directory.Async dir) {
can_show_folder = dir.can_load;

/* First deal with all cases where directory could not be loaded */
if (!can_show_folder) {
if (!dir.file.exists) {
Expand Down
36 changes: 21 additions & 15 deletions src/View/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,13 @@ namespace Marlin.View {
});

tabs.tab_moved.connect ((tab, x, y) => {
/* Called when tab dragged out of notebook */
var vc = tab.page as ViewContainer;
/* Close view now to disconnect signal handler closures which can trigger after slot destruction */
vc.close ();
((Marlin.Application) application).create_window (vc.location, real_mode (vc.view_mode), x, y);
/* A crash occurs if the original tab is removed while processing the signal */
GLib.Idle.add (() => {

Idle.add (() => {
remove_tab (vc);
return false;
});
Expand Down Expand Up @@ -354,14 +357,13 @@ namespace Marlin.View {
this.title = title;
}

public void change_tab (int offset) {
private void change_tab (int offset) {
if (restoring_tabs) {
return;
}

ViewContainer? old_tab = current_tab;
current_tab = (tabs.get_tab_by_index (offset)).page as ViewContainer;

if (current_tab == null || old_tab == current_tab) {
return;
}
Expand All @@ -371,7 +373,6 @@ namespace Marlin.View {
}

loading_uri (current_tab.uri);

current_tab.set_active_state (true, false); /* changing tab should not cause animated scrolling */
top_menu.working = current_tab.is_frozen;
}
Expand Down Expand Up @@ -416,9 +417,10 @@ namespace Marlin.View {
var tab = new Granite.Widgets.Tab ("", null, content);
tab.ellipsize_mode = Pango.EllipsizeMode.MIDDLE;

/* Capturing ViewContainer reference in closure prevents its proper destruction */
content.tab_name_changed.connect ((tab_name) => {
Idle.add (() => {
tab.label = check_for_tab_with_same_name (content);
tab.label = check_for_tab_with_same_name ();
return false;
});
});
Expand All @@ -438,15 +440,18 @@ namespace Marlin.View {
tabs.current = tab;
}

private string check_for_tab_with_same_name (ViewContainer vc) {
string name = vc.tab_name;
private string check_for_tab_with_same_name () {
assert_nonnull (current_tab);

var vc = current_tab;
var name = vc.tab_name;

if (name == Marlin.INVALID_TAB_NAME) {
return name;
return name;
}

string path = Uri.unescape_string (vc.uri);
string new_name = name;
var path = Uri.unescape_string (vc.uri);
var new_name = name;

foreach (Granite.Widgets.Tab tab in tabs.tabs) {
var content = (ViewContainer)(tab.page);
Expand Down Expand Up @@ -497,13 +502,14 @@ namespace Marlin.View {
}

public void remove_tab (ViewContainer view_container) {
actual_remove_tab (tabs.get_tab_by_widget (view_container as Gtk.Widget));
var tab = tabs.get_tab_by_widget (view_container as Gtk.Widget);
if (tab != null) {
actual_remove_tab (tab);
}
}

private void actual_remove_tab (Granite.Widgets.Tab tab) {
/* signal for restore_data to be set and a new tab to be created if this is last tab */
tabs.close_tab_requested (tab);
/* now close the tab */
/* close_tab_signal will be emitted first. Tab actually closes if this returns true */
tab.close ();
}

Expand Down