Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounts states #13

Merged
merged 1 commit into from
Jan 24, 2024
Merged
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
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ deps = [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gio-2.0'),
dependency('gio-unix-2.0'),
dependency('gee-0.8'),
dependency('gtk+-3.0'),
dependency('json-glib-1.0')
Expand All @@ -32,4 +33,4 @@ executable('cryptor',
dependencies: deps,
sources: src,
vala_args: [],
install: true)
install: true)
24 changes: 24 additions & 0 deletions resources/ui/CryptorWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,30 @@
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use-underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem" id="mi_refresh">
<property name="label">gtk-refresh</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
<signal name="activate" handler="on_mi_refresh_activate" swapped="no"/>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
Expand Down
16 changes: 12 additions & 4 deletions src/ui/CryptorWindow.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Gtk;
using Cryptor.Data;
using GLib;

namespace Cryptor.UI {
[GtkTemplate (ui = "/org/moson/cryptor/ui/CryptorWindow.ui")]
Expand Down Expand Up @@ -55,7 +56,6 @@ namespace Cryptor.UI {
}
}
this.delete_event.connect (save_before_quit);

show_tray_icon ();
}

Expand Down Expand Up @@ -186,6 +186,11 @@ namespace Cryptor.UI {
show_vault_window (-1);
}

[GtkCallback]
private void on_mi_refresh_activate (Gtk.MenuItem mi) {
sync_treeview_from_conf ();
}

private void show_tray_icon () {
if (!config.show_tray_icon) {
if (tray != null) {
Expand All @@ -201,6 +206,7 @@ namespace Cryptor.UI {
this.hide ();
} else {
this.show_all ();
sync_treeview_from_conf ();
}
} else if (ev.button == 3) {
var menu = new Gtk.Menu ();
Expand All @@ -211,6 +217,7 @@ namespace Cryptor.UI {
this.hide ();
} else {
this.show_all ();
sync_treeview_from_conf ();
}
});
menu.append (show);
Expand Down Expand Up @@ -241,15 +248,13 @@ namespace Cryptor.UI {
}
try {
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse, vault.custom_options);
vault.is_mounted = true;
sync_treeview_from_conf ();
} catch (Error e) {
if (e.message.contains ("fusermount exited with code 256")) {
if (Utils.show_question (this, "%s\n\n%s\n%s".printf (e.message, _("Vault might be mounted already."), _("Shall I retry unmounting it first?"))) == ResponseType.YES) {
try {
Gocrypt.unmount_vault (vault.mount_point);
Gocrypt.mount_vault (vault.path, vault.mount_point, password, (vault.mode == "r"), vault.reverse, vault.custom_options);
vault.is_mounted = true;
sync_treeview_from_conf ();
} catch (Error e) {
Utils.show_error (this, "%s\n%s".printf (_("Error re-mounting vault:"), e.message));
Expand All @@ -262,7 +267,6 @@ namespace Cryptor.UI {
} else {
try {
Gocrypt.unmount_vault (vault.mount_point);
vault.is_mounted = false;
sync_treeview_from_conf ();
} catch (Error e) {
Utils.show_error (this, "%s\n%s".printf (_("Error unmounting vault:"), e.message));
Expand Down Expand Up @@ -340,6 +344,10 @@ namespace Cryptor.UI {
}

private void sync_treeview_from_conf () {
foreach (var vault in config.vaults) {
var entry = new UnixMountEntry (vault.mount_point, null);
vault.is_mounted = entry != null;
}
list_store.clear ();
foreach (var v in config.vaults) {
TreeIter iter;
Expand Down
Loading