diff --git a/data/com.fyralabs.Enigma.gresources.xml b/data/com.fyralabs.Enigma.gresources.xml
index 8ace79c..dc8d687 100644
--- a/data/com.fyralabs.Enigma.gresources.xml
+++ b/data/com.fyralabs.Enigma.gresources.xml
@@ -5,7 +5,6 @@
style-dark.css
ui/main_window.ui
- ui/menu.ui
ui/prefs.ui
ui/sidebar.ui
ui/docrow.ui
diff --git a/data/ui/contentview.ui b/data/ui/contentview.ui
index a20b82e..6991048 100644
--- a/data/ui/contentview.ui
+++ b/data/ui/contentview.ui
@@ -1,6 +1,18 @@
+
true
@@ -13,6 +25,7 @@
diff --git a/data/ui/main_window.ui b/data/ui/main_window.ui
index 58c4811..a0701ec 100644
--- a/data/ui/main_window.ui
+++ b/data/ui/main_window.ui
@@ -84,6 +84,9 @@
EnigmaMainWindow
+
+ EnigmaMainWindow
+
diff --git a/data/ui/menu.ui b/data/ui/menu.ui
deleted file mode 100644
index caadb90..0000000
--- a/data/ui/menu.ui
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index a7bba50..666ce02 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -25,16 +25,20 @@ namespace Enigma {
[GtkChild]
public unowned Sidebar sidebar;
+ [GtkChild]
+ public unowned ContentView doccontent;
public SimpleActionGroup actions { get; construct; }
public const string ACTION_PREFIX = "win.";
public const string ACTION_ABOUT = "action_about";
public const string ACTION_PREFS = "action_prefs";
+ public const string ACTION_SAVE = "action_save";
public static Gee.MultiMap action_accelerators = new Gee.HashMultiMap ();
private const GLib.ActionEntry[] ACTION_ENTRIES = {
{ ACTION_ABOUT, action_about },
{ ACTION_PREFS, action_prefs },
+ { ACTION_SAVE, action_save },
};
// Custom
@@ -66,7 +70,8 @@ namespace Enigma {
app.set_accels_for_action (ACTION_PREFIX + action, accels_array);
}
- app.set_accels_for_action("app.quit", {"q"});
+ app.set_accels_for_action ("app.quit", {"q"});
+ app.set_accels_for_action ("win.action_save", {"s"});
var theme = Gtk.IconTheme.get_for_display (Gdk.Display.get_default ());
theme.add_resource_path ("/com/fyralabs/Enigma/");
@@ -111,6 +116,9 @@ namespace Enigma {
settings.parent = this;
settings.present ();
}
+ public void action_save () {
+ doccontent.save.begin ();
+ }
public void load (GLib.File file) {
uint8[] t;
diff --git a/src/Utils/MiscUtils.vala b/src/Utils/MiscUtils.vala
index 3048501..2ba0cbb 100644
--- a/src/Utils/MiscUtils.vala
+++ b/src/Utils/MiscUtils.vala
@@ -18,9 +18,10 @@
*/
namespace Enigma.Utils {
public unowned MainWindow win;
- public async File? display_open_dialog () {
+ public async File? display_open_dialog (Gtk.Window? win) {
var dialog = new Gtk.FileChooserNative (null, win, Gtk.FileChooserAction.OPEN, null, null);
dialog.set_transient_for(win);
+ dialog.modal = true;
var filter1 = new Gtk.FileFilter ();
filter1.set_filter_name (_("Text files"));
filter1.add_pattern ("*.txt");
@@ -39,9 +40,10 @@ namespace Enigma.Utils {
return null;
}
- public async File? display_save_dialog () {
+ public async File? display_save_dialog (Gtk.Window? win) {
var dialog = new Gtk.FileChooserNative (null, win, Gtk.FileChooserAction.SAVE, null, null);
dialog.set_transient_for(win);
+ dialog.modal = true;
var filter1 = new Gtk.FileFilter ();
filter1.set_filter_name (_("Text files"));
filter1.add_pattern ("*.txt");
diff --git a/src/Views/ContentView.vala b/src/Views/ContentView.vala
index 9ff8f47..e9f541c 100644
--- a/src/Views/ContentView.vala
+++ b/src/Views/ContentView.vala
@@ -26,8 +26,6 @@ public class Enigma.ContentView : He.Bin {
[GtkChild]
public unowned Gtk.SearchEntry search_entry;
[GtkChild]
- unowned Gtk.MenuButton menu_button;
- [GtkChild]
unowned Gtk.Button open_button;
[GtkChild]
unowned Gtk.Button save_as_button;
@@ -44,6 +42,7 @@ public class Enigma.ContentView : He.Bin {
private GtkSource.VimIMContext? vim_im_context;
private Gtk.EventControllerKey? vim_event_controller;
+ public He.Application app { get; construct set; }
Doc? _doc;
public Doc? doc {
@@ -106,16 +105,14 @@ public class Enigma.ContentView : He.Bin {
}
}
- public ContentView (DocViewModel? vm) {
+ public ContentView (DocViewModel? vm, He.Application app) {
Object (
- vm: vm
+ vm: vm,
+ app: app
);
}
construct {
- var builder = new Gtk.Builder.from_resource ("/com/fyralabs/Enigma/menu.ui");
- menu_button.menu_model = (MenuModel)builder.get_object ("menu");
-
open_button.clicked.connect (() => { open.begin (); });
save_as_button.clicked.connect (() => { save.begin (); });
@@ -143,7 +140,7 @@ public class Enigma.ContentView : He.Bin {
}
public async void open () {
- var file = yield Utils.display_open_dialog ();
+ var file = yield Utils.display_open_dialog (app.active_window);
uint8[] t;
try {
file.load_contents (null, out t, null);
@@ -170,7 +167,7 @@ public class Enigma.ContentView : He.Bin {
}
public async void save () {
- var file = yield Utils.display_save_dialog ();
+ var file = yield Utils.display_save_dialog (app.active_window);
Gtk.TextIter start, end;
textbox.get_buffer ().get_bounds (out start, out end);
try {