Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Dialogs/PreferencesDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public class Scratch.Dialogs.Preferences : Granite.Dialog {
realize.connect (() => {
stack.set_visible_child_name ("behavior");
});

show_all ();
}

private class SettingSwitch : Gtk.Grid {
Expand Down
65 changes: 38 additions & 27 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -951,13 +951,12 @@ namespace Scratch {

private void action_preferences () {
var preferences_dialog = new Scratch.Dialogs.Preferences (this, plugins);
preferences_dialog.show_all ();

preferences_dialog.response.connect (() => {
preferences_dialog.destroy ();
});

preferences_dialog.present ();
preferences_dialog.show ();
}

private void action_close_window () {
Expand Down Expand Up @@ -989,19 +988,22 @@ namespace Scratch {
file_chooser.select_multiple = true;
file_chooser.set_current_folder_uri (Utils.last_path ?? GLib.Environment.get_home_dir ());

var response = file_chooser.run ();
file_chooser.destroy (); // Close now so it does not stay open during lengthy or failed loading

if (response == Gtk.ResponseType.ACCEPT) {
foreach (string uri in file_chooser.get_uris ()) {
// Update last visited path
Utils.last_path = Path.get_dirname (uri);
// Open the file
var file = File.new_for_uri (uri);
var doc = new Scratch.Services.Document (actions, file);
open_document.begin (doc);
file_chooser.response.connect ((res) => {
var uris = file_chooser.get_uris ();
file_chooser.destroy (); // Close now so it does not stay open during lengthy or failed loading
if (res == Gtk.ResponseType.ACCEPT) {
foreach (string uri in file_chooser.get_uris ()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you've cached the list of URIs but then try to get them from the chooser again here?

// Update last visited path
Utils.last_path = Path.get_dirname (uri);
// Open the file
var file = File.new_for_uri (uri);
var doc = new Scratch.Services.Document (actions, file);
open_document.begin (doc);
}
}
}
});

file_chooser.show ();
}

private void action_open_in_new_window (SimpleAction action, Variant? param) {
Expand Down Expand Up @@ -1031,14 +1033,18 @@ namespace Scratch {

chooser.select_multiple = true;

if (chooser.run () == Gtk.ResponseType.ACCEPT) {
chooser.get_files ().foreach ((glib_file) => {
var foldermanager_file = new FolderManager.File (glib_file.get_path ());
folder_manager_view.open_folder (foldermanager_file);
});
}
chooser.response.connect ((res) => {
var files = chooser.get_files ();
chooser.destroy ();
if (res == Gtk.ResponseType.ACCEPT) {
files.foreach ((glib_file) => {
var foldermanager_file = new FolderManager.File (glib_file.get_path ());
folder_manager_view.open_folder (foldermanager_file);
});
}
});

chooser.destroy ();
chooser.show ();
}

private void action_open_folder (SimpleAction action, Variant? param) {
Expand Down Expand Up @@ -1155,13 +1161,18 @@ namespace Scratch {

private void action_revert () {
var confirmation_dialog = new Scratch.Dialogs.RestoreConfirmationDialog (this);
if (confirmation_dialog.run () == Gtk.ResponseType.ACCEPT) {
var doc = get_current_document ();
if (doc != null) {
doc.revert ();
confirmation_dialog.response.connect ((res) => {
if (res == Gtk.ResponseType.ACCEPT) {
var doc = get_current_document ();
if (doc != null) {
doc.revert ();
}
}
}
confirmation_dialog.destroy ();

confirmation_dialog.destroy ();
});

confirmation_dialog.show ();
}

private void action_duplicate () {
Expand Down
Loading