[baobab/add-notification: 1/3] application: Make sure only one window is created
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/add-notification: 1/3] application: Make sure only one window is created
- Date: Wed, 10 Oct 2018 14:00:53 +0000 (UTC)
commit ede655f829fc7d5bf30219735b2e413d0d6e7395
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Oct 10 15:46:15 2018 +0200
application: Make sure only one window is created
src/baobab-application.vala | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/baobab-application.vala b/src/baobab-application.vala
index d895f76..5fb6d24 100644
--- a/src/baobab-application.vala
+++ b/src/baobab-application.vala
@@ -24,6 +24,8 @@ namespace Baobab {
public class Application : Gtk.Application {
+ private Window window;
+
const OptionEntry[] option_entries = {
{ "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
{ null }
@@ -34,13 +36,18 @@ namespace Baobab {
};
protected override void activate () {
- new Window (this);
+ ensure_window ();
+ window.present ();
}
protected override void open (File[] files, string hint) {
- foreach (var file in files) {
- var window = new Window (this);
- window.scan_directory (file, ScanFlags.EXCLUDE_MOUNTS);
+ ensure_window ();
+ window.scan_directory (files[0], ScanFlags.EXCLUDE_MOUNTS);
+ }
+
+ void ensure_window () {
+ if (window == null) {
+ window = new Window (this);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]