Add --hidden flag

This commit is contained in:
bleakgrey 2018-10-27 11:55:40 +03:00
parent 11a01f7fea
commit 102e0a4a42
3 changed files with 34 additions and 10 deletions

View File

@ -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 ())

View File

@ -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 ();
}

View File

@ -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);