diff --git a/src/Application.vala b/src/Application.vala index 9b1215c..1300f7d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -18,6 +18,13 @@ namespace Tootle{ 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 = { + {"compose-toot", compose_toot_activated }, + {"back", back_activated }, + {"refresh", refresh_activated }, + {"switch-timeline", switch_timeline_activated, "i" } + }; construct { application_id = "com.github.bleakgrey.tootle"; @@ -47,6 +54,16 @@ namespace Tootle{ window_dummy = new Window (); add_window (window_dummy); + + this.set_accels_for_action ("app.compose-toot", {"T"}); + this.set_accels_for_action ("app.back", {"BackSpace", "Left"}); + this.set_accels_for_action ("app.refresh", {"R", "F5"}); + this.set_accels_for_action ("app.switch-timeline(0)", {"1"}); + this.set_accels_for_action ("app.switch-timeline(1)", {"2"}); + this.set_accels_for_action ("app.switch-timeline(2)", {"3"}); + this.set_accels_for_action ("app.switch-timeline(3)", {"4"}); + + this.add_action_entries (app_entries, this); } protected override void activate () { @@ -68,6 +85,23 @@ namespace Tootle{ message_dialog.run (); message_dialog.destroy (); } + + private void compose_toot_activated () { + PostDialog.open (); + } + + private void back_activated () { + window.back (); + } + + private void refresh_activated () { + refresh (); + } + + private void switch_timeline_activated (SimpleAction a, Variant? parameter) { + int32 timeline_no = parameter.get_int32 (); + window.switch_timeline (timeline_no); + } } diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 746a200..25e05cf 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -103,6 +103,13 @@ public class Tootle.MainWindow: Gtk.Window { network.started.connect (() => spinner.show ()); network.finished.connect (() => spinner.hide ()); accounts.updated (accounts.saved_accounts); + button_release_event.connect ((event) => { + // On back mouse button pressed + if (event.button == 8) { + back (); + } + return false; + }); } private void add_header_view (AbstractView view) { @@ -177,4 +184,7 @@ public class Tootle.MainWindow: Gtk.Window { button_accounts.set_visible (true); } + public void switch_timeline (int32 timeline_no) { + button_mode.set_active (timeline_no); + } }