From 102e0a4a42c539a9d1575ade3b519316905edbc6 Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Sat, 27 Oct 2018 11:55:40 +0300 Subject: [PATCH] Add --hidden flag --- src/Application.vala | 28 ++++++++++++++++++++++++++-- src/InstanceAccount.vala | 10 +++++----- src/Views/NotificationsView.vala | 6 +++--- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 1061bd8..12286b5 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -13,13 +13,20 @@ namespace Tootle { public static ImageCache image_cache; public static Watchlist watchlist; + public static bool start_hidden = false; + public class Application : Granite.Application { public abstract signal void refresh (); public abstract signal void toast (string title); public abstract signal void error (string title, string text); - const GLib.ActionEntry[] app_entries = { + public const GLib.OptionEntry[] app_options = { + { "hidden", 0, 0, OptionArg.NONE, ref start_hidden, "Do not show main window on start", null }, + { null } + }; + + public const GLib.ActionEntry[] app_entries = { {"compose-toot", compose_toot_activated }, {"back", back_activated }, {"refresh", refresh_activated }, @@ -35,6 +42,16 @@ namespace Tootle { public static int main (string[] args) { Gtk.init (ref args); + + try { + var opt_context = new OptionContext ("- Options"); + opt_context.add_main_entries (app_options, null); + opt_context.parse (ref args); + } + catch (GLib.OptionError e) { + warning (e.message); + } + app = new Application (); return app.run (args); } @@ -66,8 +83,15 @@ namespace Tootle { } protected override void activate () { - if (window != null) + if (window != null) { + window.present (); return; + } + + if (start_hidden) { + start_hidden = false; + return; + } debug ("Creating new window"); if (accounts.is_empty ()) diff --git a/src/InstanceAccount.vala b/src/InstanceAccount.vala index 5e64f16..ce9df98 100644 --- a/src/InstanceAccount.vala +++ b/src/InstanceAccount.vala @@ -43,15 +43,15 @@ public class Tootle.InstanceAccount : GLib.Object { builder.set_member_name ("hash"); builder.add_string_value ("test"); builder.set_member_name ("username"); - builder.add_string_value (this.username); + builder.add_string_value (username); builder.set_member_name ("instance"); - builder.add_string_value (this.instance); + builder.add_string_value (instance); builder.set_member_name ("id"); - builder.add_string_value (this.client_id); + builder.add_string_value (client_id); builder.set_member_name ("secret"); - builder.add_string_value (this.client_secret); + builder.add_string_value (client_secret); builder.set_member_name ("token"); - builder.add_string_value (this.token); + builder.add_string_value (token); builder.end_object (); return builder.get_root (); } diff --git a/src/Views/NotificationsView.vala b/src/Views/NotificationsView.vala index 7da664c..710b3d1 100644 --- a/src/Views/NotificationsView.vala +++ b/src/Views/NotificationsView.vala @@ -29,14 +29,14 @@ public class Tootle.NotificationsView : AbstractView { if (empty != null) empty.destroy (); - var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL); + var separator = new Gtk.Separator (Orientation.HORIZONTAL); separator.show (); var widget = new NotificationWidget (notification); widget.separator = separator; image.icon_name = Desktop.fallback_icon ("notification-new-symbolic", "user-available-symbolic"); - view.pack_start(separator, false, false, 0); - view.pack_start(widget, false, false, 0); + view.pack_start (separator, false, false, 0); + view.pack_start (widget, false, false, 0); if (reverse) { view.reorder_child (widget, 0);