Add direct timeline

This commit is contained in:
bleakgrey 2018-06-17 12:48:58 +03:00
parent 68757c7d8e
commit ef2b9f55fb
3 changed files with 36 additions and 4 deletions

View File

@ -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',

25
src/Views/DirectView.vala Normal file
View File

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

View File

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