From 77b34c26939b460678874366f47950a7b5f196bf Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Tue, 23 Oct 2018 13:22:43 +0300 Subject: [PATCH] Fix Back mouse button --- src/Application.vala | 17 ++++++++--------- src/MainWindow.vala | 7 +++++-- src/Widgets/AttachmentWidget.vala | 5 ++++- src/Widgets/StatusWidget.vala | 8 +++++++- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 2f5849c..1061bd8 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -55,15 +55,14 @@ 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); + set_accels_for_action ("app.compose-toot", {"T"}); + set_accels_for_action ("app.back", {"BackSpace", "Left"}); + set_accels_for_action ("app.refresh", {"R", "F5"}); + set_accels_for_action ("app.switch-timeline(0)", {"1"}); + set_accels_for_action ("app.switch-timeline(1)", {"2"}); + set_accels_for_action ("app.switch-timeline(2)", {"3"}); + set_accels_for_action ("app.switch-timeline(3)", {"4"}); + add_action_entries (app_entries, this); } protected override void activate () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index d3148a7..078d7bd 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -102,10 +102,10 @@ 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 + button_press_event.connect ((event) => { if (event.button == 8) { back (); + return true; } return false; }); @@ -138,6 +138,9 @@ public class Tootle.MainWindow: Gtk.Window { public void back () { var i = get_visible_id (); + if (i == 0) + return; + var child = primary_stack.get_child_by_name (i.to_string ()); primary_stack.set_visible_child_name ((i-1).to_string ()); child.destroy (); diff --git a/src/Widgets/AttachmentWidget.vala b/src/Widgets/AttachmentWidget.vala index 851d2fd..6ca9bde 100644 --- a/src/Widgets/AttachmentWidget.vala +++ b/src/Widgets/AttachmentWidget.vala @@ -68,7 +68,7 @@ public class Tootle.AttachmentWidget : Gtk.EventBox { break; } show (); - button_press_event.connect(on_clicked); + button_press_event.connect (on_clicked); } public AttachmentWidget.upload (string uri) { @@ -106,6 +106,9 @@ public class Tootle.AttachmentWidget : Gtk.EventBox { } private bool on_clicked (EventButton ev){ + if (ev.button == 8) + return false; + if (ev.button == 3) return open_menu (ev.button, ev.time); diff --git a/src/Widgets/StatusWidget.vala b/src/Widgets/StatusWidget.vala index 0c5e0e4..7a81d37 100644 --- a/src/Widgets/StatusWidget.vala +++ b/src/Widgets/StatusWidget.vala @@ -110,7 +110,7 @@ public class Tootle.StatusWidget : Gtk.EventBox { grid.attach (counters, 2, 5, 1, 1); show_all (); - this.button_press_event.connect (on_clicked); + button_press_event.connect (on_clicked); } public StatusWidget (Status status) { @@ -245,6 +245,9 @@ public class Tootle.StatusWidget : Gtk.EventBox { } public bool open (EventButton ev) { + if (ev.button == 8) + return false; + var formal = status.get_formal (); var view = new StatusView (formal); window.open_view (view); @@ -252,6 +255,9 @@ public class Tootle.StatusWidget : Gtk.EventBox { } private bool on_clicked (EventButton ev) { + if (ev.button == 8) + return false; + if (ev.button == 3) return open_menu (ev.button, ev.time); else