Add shortcuts

Partially implements #12.
This commit is contained in:
Çağatay Yiğit Şahin 2018-08-27 04:45:25 +03:00
parent 458b2a3087
commit 5a4bc57355
2 changed files with 44 additions and 0 deletions

View File

@ -19,6 +19,13 @@ namespace Tootle{
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";
flags = ApplicationFlags.FLAGS_NONE;
@ -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 () {
@ -69,6 +86,23 @@ namespace Tootle{
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

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