From ef2b9f55fbf18f27767fc3dfc7698f27d959ec7b Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Sun, 17 Jun 2018 12:48:58 +0300 Subject: [PATCH] Add direct timeline --- meson.build | 1 + src/Views/DirectView.vala | 25 +++++++++++++++++++++++++ src/Widgets/AccountsButton.vala | 14 ++++++++++---- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/Views/DirectView.vala diff --git a/meson.build b/meson.build index 43fd001..71eb90c 100644 --- a/meson.build +++ b/meson.build @@ -55,6 +55,7 @@ executable( 'src/Views/LocalView.vala', 'src/Views/FederatedView.vala', 'src/Views/NotificationsView.vala', + 'src/Views/DirectView.vala', 'src/Views/StatusView.vala', 'src/Views/AccountView.vala', 'src/Views/FollowersView.vala', diff --git a/src/Views/DirectView.vala b/src/Views/DirectView.vala new file mode 100644 index 0000000..e4a0822 --- /dev/null +++ b/src/Views/DirectView.vala @@ -0,0 +1,25 @@ +public class Tootle.DirectView : TimelineView { + + public DirectView () { + base ("direct"); + notificator = new Notificator (get_stream ()); + notificator.status_added.connect ((ref status) => { + if (settings.live_updates) + on_status_added (ref status); + }); + } + + public override string get_icon () { + return "mail-send-symbolic"; + } + + public override string get_name () { + return _("Direct Messages"); + } + + protected Soup.Message get_stream () { + var url = "%s/api/v1/streaming/?stream=direct&access_token=%s".printf (accounts.formal.instance, accounts.formal.token); + return new Soup.Message("GET", url); + } + +} diff --git a/src/Widgets/AccountsButton.vala b/src/Widgets/AccountsButton.vala index 5b7a7e9..8f0ee48 100644 --- a/src/Widgets/AccountsButton.vala +++ b/src/Widgets/AccountsButton.vala @@ -11,6 +11,7 @@ public class Tootle.AccountsButton : Gtk.MenuButton{ Gtk.ModelButton item_refresh; Gtk.ModelButton item_search; Gtk.ModelButton item_favs; + Gtk.ModelButton item_direct; private class AccountView : Gtk.ListBoxRow{ @@ -68,6 +69,10 @@ public class Tootle.AccountsButton : Gtk.MenuButton{ item_favs = new Gtk.ModelButton (); item_favs.text = _("Favorites"); item_favs.clicked.connect (() => window.open_view (new FavoritesView ())); + + item_direct = new Gtk.ModelButton (); + item_direct.text = _("Direct Messages"); + item_direct.clicked.connect (() => window.open_view (new DirectView ())); item_search = new Gtk.ModelButton (); item_search.text = _("Search"); @@ -83,10 +88,11 @@ public class Tootle.AccountsButton : Gtk.MenuButton{ grid.attach(list, 0, 1, 1, 1); grid.attach(item_separator, 0, 3, 1, 1); grid.attach(item_favs, 0, 4, 1, 1); - grid.attach(new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 5, 1, 1); - grid.attach(item_refresh, 0, 6, 1, 1); - grid.attach(item_search, 0, 7, 1, 1); - grid.attach(item_settings, 0, 8, 1, 1); + grid.attach(item_direct, 0, 5, 1, 1); + grid.attach(new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 6, 1, 1); + grid.attach(item_refresh, 0, 7, 1, 1); + grid.attach(item_search, 0, 8, 1, 1); + grid.attach(item_settings, 0, 9, 1, 1); grid.show_all (); menu = new Gtk.Popover (null);