Skip to content

Commit

Permalink
Add option to start minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
phpony authored and moson-mo committed Jan 22, 2024
1 parent cf51fbe commit 59402e0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
14 changes: 14 additions & 0 deletions resources/ui/SettingsWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_start_minimized">
<property name="label" translatable="yes">Start minimized to tray</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</template>
Expand Down
2 changes: 2 additions & 0 deletions src/Config.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Cryptor {
public bool autosave_on_quit { get; set; }
public bool show_tray_icon { get; set; }
public bool send_to_tray { get; set; }
public bool start_minimized { get; set; }

public Gee.ArrayList<Vault> vaults { get; set; }

Expand All @@ -17,6 +18,7 @@ namespace Cryptor {
autosave_on_quit = true;
show_tray_icon = false;
send_to_tray = false;
start_minimized = false;
vaults = new Gee.ArrayList<Vault> ();
}

Expand Down
2 changes: 1 addition & 1 deletion src/CryptorApp.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Cryptor {

protected override void activate () {
var win = new UI.CryptorWindow (this);
win.show_all ();
win.show_or_not_show ();
}

public static int main (string[] args) {
Expand Down
8 changes: 8 additions & 0 deletions src/ui/CryptorWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ namespace Cryptor.UI {
show_tray_icon ();
}

public void show_or_not_show () {
if (config.start_minimized && tray != null) {
this.hide ();
} else {
this.show_all ();
}
}

[GtkCallback]
private void on_mi_quit_activate (Gtk.MenuItem mi) {
save_before_quit (null, null);
Expand Down
12 changes: 11 additions & 1 deletion src/ui/SettingsWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Cryptor.UI {
public class SettingsWindow : Dialog {
private Config config;
bool prev_send_to_tray;
bool prev_start_minimized;

[GtkChild]
private unowned CheckButton check_unmount;
Expand All @@ -19,6 +20,8 @@ namespace Cryptor.UI {
[GtkChild]
private unowned CheckButton check_send_to_tray;

[GtkChild]
private unowned CheckButton check_start_minimized;

public SettingsWindow (Window parent, Config config) {
Object (
Expand All @@ -29,7 +32,9 @@ namespace Cryptor.UI {
check_autosave.active = config.autosave_on_quit;
check_show_tray.active = config.show_tray_icon;
check_send_to_tray.active = config.send_to_tray;
check_start_minimized.active = config.start_minimized;
prev_send_to_tray = config.send_to_tray;
prev_start_minimized = config.start_minimized;
}

[GtkCallback]
Expand All @@ -38,6 +43,7 @@ namespace Cryptor.UI {
config.autosave_on_quit = check_autosave.active;
config.show_tray_icon = check_show_tray.active;
config.send_to_tray = check_send_to_tray.active;
config.start_minimized = check_start_minimized.active;
config.changes_made = true;
this.close ();
}
Expand All @@ -52,10 +58,14 @@ namespace Cryptor.UI {
if (cb.active) {
check_send_to_tray.sensitive = true;
check_send_to_tray.active = prev_send_to_tray;
check_start_minimized.sensitive = true;
check_start_minimized.active = prev_start_minimized;
} else {
check_send_to_tray.active = false;
check_send_to_tray.sensitive = false;
check_start_minimized.active = false;
check_start_minimized.sensitive = false;
}
}
}
}
}

0 comments on commit 59402e0

Please sign in to comment.