Tweak timelines

This commit is contained in:
Bleak Grey 2020-06-03 15:41:21 +03:00
parent 3299048f4d
commit d24e10ace2
14 changed files with 127 additions and 114 deletions

View File

@ -62,7 +62,7 @@
</packing>
</child>
<child>
<object class="GtkModelButton" id="item_direct">
<object class="GtkModelButton" id="item_conversations">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>

View File

@ -2,10 +2,15 @@
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">user-bookmarks-symbolic</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-favorite-symbolic</property>
<property name="icon_name">non-starred-symbolic</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
@ -52,45 +57,8 @@
<property name="can_focus">False</property>
<property name="margin_top">8</property>
<property name="spacing">8</property>
<child>
<object class="GtkToggleButton" id="reblog_button">
<property name="label" translatable="yes">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">reblog_icon</property>
<property name="always_show_image">True</property>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="favorite_button">
<property name="label" translatable="yes">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image2</property>
<property name="always_show_image">True</property>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="reply_button">
<property name="label" translatable="yes">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -100,6 +68,40 @@
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="reblog_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">reblog_icon</property>
<property name="always_show_image">True</property>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="favorite_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image2</property>
<property name="always_show_image">True</property>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
@ -107,7 +109,44 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkToggleButton" id="bookmark_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="always_show_image">True</property>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>

View File

@ -77,7 +77,7 @@ executable(
'src/Views/Local.vala',
'src/Views/Federated.vala',
'src/Views/Notifications.vala',
'src/Views/Direct.vala',
'src/Views/Conversations.vala',
'src/Views/ExpandedStatus.vala',
'src/Views/Profile.vala',
'src/Views/Favorites.vala',

View File

View File

@ -1,9 +1,9 @@
public class Tootle.Views.Direct : Views.Timeline {
public class Tootle.Views.Conversations : Views.Timeline {
public Direct () {
public Conversations () {
Object (
timeline: "direct",
label: _("Direct Messages"),
url: "/api/v1/conversations",
label: _("Conversations"),
icon: "mail-send-symbolic"
);
}

View File

@ -1,14 +1,9 @@
public class Tootle.Views.Favorites : Views.Timeline {
public Favorites () {
Object (timeline: "favorites");
}
public override string get_url (){
if (page_next != null)
return page_next;
return @"/api/v1/favourites";
Object (
url: "/api/v1/favourites"
);
}
}

View File

@ -2,7 +2,7 @@ public class Tootle.Views.Federated : Views.Timeline {
public Federated () {
Object (
timeline: "public",
url: "/api/v1/timelines/public",
is_public: true,
label: _("Federated"),
icon: "network-workgroup-symbolic"

View File

@ -1,11 +1,13 @@
public class Tootle.Views.Hashtag : Views.Timeline {
public Hashtag (string tag) {
Object (timeline: @"tag/$tag");
Object (
url: @"/api/v1/timelines/tag/$tag"
);
}
public override string? get_stream_url () {
var tag = timeline.substring (4);
var tag = url.substring (4);
return account != null ? @"$(account.instance)/api/v1/streaming/?stream=hashtag&tag=$tag&access_token=$(account.token)" : null;
}

View File

@ -2,7 +2,7 @@ public class Tootle.Views.Home : Views.Timeline {
public Home () {
Object (
timeline: "home",
url: "/api/v1/timelines/home",
label: _("Home"),
icon: "user-home-symbolic"
);

View File

@ -7,6 +7,7 @@ public class Tootle.Views.Notifications : Views.Timeline, IAccountListener, IStr
public Notifications () {
Object (
url: "/api/v1/notifications",
label: _("Notifications"),
icon: Desktop.fallback_icon ("notification-symbolic", "preferences-system-notifications-symbolic", "user-invisible-symbolic")
);
@ -18,13 +19,6 @@ public class Tootle.Views.Notifications : Views.Timeline, IAccountListener, IStr
return account != null ? @"$(account.instance)/api/v1/streaming/?stream=user&access_token=$(account.token)" : null;
}
public override string get_url () {
if (page_next != null)
return page_next;
return "/api/v1/notifications";
}
public override void on_shown () {
if (has_unread ()) {
needs_attention = false;

View File

@ -138,7 +138,7 @@ public class Tootle.Views.Profile : Views.Timeline {
relationship.label = label;
}
public override string get_url () {
public override string get_req_url () {
if (page_next != null)
return page_next;

View File

@ -3,14 +3,15 @@ using Gdk;
public class Tootle.Views.Timeline : IAccountListener, IStreamListener, Views.Base {
public string timeline { get; construct set; }
public string url { get; construct set; }
public bool is_public { get; construct set; default = false; }
protected InstanceAccount? account = null;
protected bool is_last_page = false;
protected string? page_next;
protected string? page_prev;
protected string? stream;
protected bool is_last_page { get; set; default = false; }
protected string? page_next { get; set; }
protected string? page_prev { get; set; }
protected string? stream = null;
construct {
app.refresh.connect (on_refresh);
@ -89,11 +90,11 @@ public class Tootle.Views.Timeline : IAccountListener, IStreamListener, Views.Ba
is_last_page = page_prev != null & page_next == null;
}
public virtual string get_url () {
public virtual string get_req_url () {
if (page_next != null)
return page_next;
return @"/api/v1/timelines/$timeline";
return url;
}
public virtual Request append_params (Request req) {
@ -101,7 +102,7 @@ public class Tootle.Views.Timeline : IAccountListener, IStreamListener, Views.Ba
}
public virtual bool request () {
append_params (new Request.GET (get_url ()))
append_params (new Request.GET (get_req_url ()))
.with_account (account)
.then_parse_array ((node, msg) => {
var obj = node.get_object ();

View File

@ -61,7 +61,7 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
[GtkChild]
private ModelButton item_favs;
[GtkChild]
private ModelButton item_direct;
private ModelButton item_conversations;
construct {
connect_account ();
@ -70,9 +70,8 @@ public class Tootle.Widgets.AccountsButton : Gtk.MenuButton, IAccountListener {
Desktop.set_hotkey_tooltip (item_refresh, null, app.ACCEL_REFRESH);
item_favs.clicked.connect (() => window.open_view (new Views.Favorites ()));
item_direct.clicked.connect (() => window.open_view (new Views.Direct ()));
item_conversations.clicked.connect (() => window.open_view (new Views.Conversations ()));
item_search.clicked.connect (() => window.open_view (new Views.Search ()));
//item_watchlist.clicked.connect (() => Dialogs.WatchlistEditor.open ());
item_prefs.clicked.connect (() => Dialogs.Preferences.open ());
// network.started.connect (() => spinner.show ());

View File

@ -42,6 +42,10 @@ public class Tootle.Widgets.Status : EventBox {
protected Image reblog_icon;
[GtkChild]
protected ToggleButton favorite_button;
[GtkChild]
protected ToggleButton bookmark_button;
[GtkChild]
protected Button menu_button;
protected string escaped_spoiler {
owned get {
@ -78,7 +82,6 @@ public class Tootle.Widgets.Status : EventBox {
}
construct {
button_press_event.connect (on_clicked);
content.activate_link.connect (on_toggle_spoiler);
notify["kind"].connect (on_kind_changed);
@ -105,18 +108,6 @@ public class Tootle.Widgets.Status : EventBox {
bind_property ("handle", handle_label, "label", BindingFlags.SYNC_CREATE);
bind_property ("date", date_label, "label", BindingFlags.SYNC_CREATE);
status.formal.bind_property ("pinned", pin_indicator, "visible", BindingFlags.SYNC_CREATE);
status.formal.bind_property ("replies-count", reply_button, "label", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
target.set_string (((int64)src).to_string ());
return true;
});
status.formal.bind_property ("reblogs-count", reblog_button, "label", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
target.set_string (((int64)src).to_string ());
return true;
});
status.bind_property ("favourites-count", favorite_button, "label", BindingFlags.SYNC_CREATE, (b, src, ref target) => {
target.set_string (((int64)src).to_string ());
return true;
});
status.formal.bind_property ("has_spoiler", revealer_content, "visible", BindingFlags.SYNC_CREATE);
revealer.reveal_child = !status.formal.has_spoiler;
@ -142,14 +133,14 @@ public class Tootle.Widgets.Status : EventBox {
if (!attachments.populate (status.formal.attachments) || status.id <= 0) {
attachments.destroy ();
}
menu_button.clicked.connect (open_menu);
}
public Status (API.Status status, API.NotificationType? _kind = null) {
Object (status: status, kind: _kind);
}
~Status () {
button_press_event.disconnect (on_clicked);
notify["kind"].disconnect (on_kind_changed);
}
@ -187,13 +178,7 @@ public class Tootle.Widgets.Status : EventBox {
return false;
}
protected virtual bool on_clicked (EventButton ev) {
if (ev.button == 3)
return open_menu (ev.button, ev.time);
return false;
}
public virtual bool open_menu (uint button, uint32 time) {
protected void open_menu () {
var menu = new Gtk.Menu ();
var item_open_link = new Gtk.MenuItem.with_label (_("Open in Browser"));
@ -206,7 +191,20 @@ public class Tootle.Widgets.Status : EventBox {
Desktop.copy (sanitized);
});
// if (is_notification) {
// var item_muting = new Gtk.MenuItem.with_label (status.muted ? _("Unmute Conversation") : _("Mute Conversation"));
// item_muting.activate.connect (() => status.update_muted (!is_muted) );
// menu.add (item_muting);
// }
menu.add (item_open_link);
menu.add (new SeparatorMenuItem ());
menu.add (item_copy_link);
menu.add (item_copy);
if (status.is_owned ()) {
menu.add (new SeparatorMenuItem ());
var item_pin = new Gtk.MenuItem.with_label (status.pinned ? _("Unpin from Profile") : _("Pin on Profile"));
item_pin.activate.connect (() => {
status.action (status.formal.pinned ? "unpin" : "pin");
@ -220,25 +218,10 @@ public class Tootle.Widgets.Status : EventBox {
var item_redraft = new Gtk.MenuItem.with_label (_("Redraft"));
item_redraft.activate.connect (() => new Dialogs.Compose.redraft (status.formal));
menu.add (item_redraft);
menu.add (new SeparatorMenuItem ());
}
// if (is_notification) {
// var item_muting = new Gtk.MenuItem.with_label (status.muted ? _("Unmute Conversation") : _("Mute Conversation"));
// item_muting.activate.connect (() => status.update_muted (!is_muted) );
// menu.add (item_muting);
// }
menu.add (item_open_link);
menu.add (new SeparatorMenuItem ());
menu.add (item_copy_link);
menu.add (item_copy);
menu.show_all ();
menu.attach_widget = this;
menu.popup_at_pointer ();
return true;
menu.popup_at_widget (menu_button, Gravity.SOUTH_EAST, Gravity.SOUTH_EAST);
}
}