Merge pull request #77 from cagatay-y/shortcuts

Add shortcuts
This commit is contained in:
Bleak Grey 2018-10-23 13:11:12 +03:00 committed by GitHub
commit bbffaa8b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 0 deletions

View File

@ -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", {"<Ctrl>T"});
this.set_accels_for_action ("app.back", {"<Alt>BackSpace", "<Alt>Left"});
this.set_accels_for_action ("app.refresh", {"<Ctrl>R", "F5"});
this.set_accels_for_action ("app.switch-timeline(0)", {"<Alt>1"});
this.set_accels_for_action ("app.switch-timeline(1)", {"<Alt>2"});
this.set_accels_for_action ("app.switch-timeline(2)", {"<Alt>3"});
this.set_accels_for_action ("app.switch-timeline(3)", {"<Alt>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);
}
}

View File

@ -102,6 +102,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);
}
}