Indicate pinned posts

This commit is contained in:
bleakgrey 2018-10-24 12:29:36 +03:00
parent 68ee41dc1a
commit 275436b779
5 changed files with 36 additions and 24 deletions

View File

@ -153,17 +153,17 @@ public class Tootle.Status {
public void set_pinned (bool pin = true){
var action = pin ? "pin" : "unpin";
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (Tootle.accounts.formal.instance, id, action));
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (accounts.formal.instance, id, action));
msg.priority = Soup.MessagePriority.HIGH;
msg.finished.connect (() => {
pinned = pin;
updated ();
if (pin)
Tootle.app.toast (_("Pinned!"));
app.toast (_("Pinned on Profile"));
else
Tootle.app.toast (_("Unpinned"));
app.toast (_("Unpinned from Profile"));
});
Tootle.network.queue (msg);
network.queue (msg);
}
public void poof (){

View File

@ -1,24 +1,29 @@
using Gtk;
public abstract class Tootle.AbstractView : Gtk.ScrolledWindow {
public abstract class Tootle.AbstractView : ScrolledWindow {
public int stack_pos = -1;
public Gtk.Image? image;
public Gtk.Box view;
protected Gtk.Box? empty;
public Image? image;
public Box view;
protected Grid grid;
protected Box? empty;
construct {
view = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
view.valign = Gtk.Align.START;
hscrollbar_policy = Gtk.PolicyType.NEVER;
add (view);
view = new Box (Orientation.VERTICAL, 0);
view.valign = Align.START;
grid = new Grid ();
grid.hexpand = true;
grid.vexpand = true;
grid.attach (view, 0, 2);
hscrollbar_policy = PolicyType.NEVER;
add (grid);
edge_reached.connect(pos => {
if (pos == Gtk.PositionType.BOTTOM)
if (pos == PositionType.BOTTOM)
bottom_reached ();
});
pre_construct ();
}
public AbstractView () {
@ -35,11 +40,8 @@ public abstract class Tootle.AbstractView : Gtk.ScrolledWindow {
public virtual void clear (){
view.forall (widget => widget.destroy ());
pre_construct ();
}
public virtual void pre_construct () {}
public virtual void bottom_reached (){}
public virtual bool is_empty () {
@ -52,14 +54,15 @@ public abstract class Tootle.AbstractView : Gtk.ScrolledWindow {
if (!is_empty ())
return false;
empty = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
empty = new Box (Orientation.VERTICAL, 0);
empty.margin = 64;
var image = new Image.from_resource ("/com/github/bleakgrey/tootle/empty_state");
var text = new Gtk.Label (_("Nothing to see here"));
var text = new Label (_("Nothing to see here"));
text.get_style_context ().add_class ("h2");
text.opacity = 0.5;
empty.hexpand = true;
empty.vexpand = true;
empty.valign = Gtk.Align.FILL;
empty.valign = Align.FILL;
empty.pack_start (image, false, false, 0);
empty.pack_start (text, false, false, 12);
empty.show_all ();

View File

@ -26,7 +26,8 @@ public class Tootle.AccountView : TimelineView {
Gtk.MenuItem menu_report;
Gtk.MenuButton button_menu;
public override void pre_construct () {
//public override void pre_construct () {
construct {
header = new Gtk.Grid ();
header_info = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
header_info.margin = 12;
@ -104,7 +105,8 @@ public class Tootle.AccountView : TimelineView {
button_follow.hide ();
header.attach (actions, 0, 0, 2, 2);
view.pack_start (header, false, false, 0);
grid.attach (header, 0, 1);
//view.pack_start (header, false, false, 0);
}
public AccountView (Account acc) {

View File

@ -63,7 +63,7 @@ public class Tootle.TimelineView : AbstractView {
view.pack_start(separator, false, false, 0);
view.pack_start(widget, false, false, 0);
if (first) {
if (first || status.pinned) {
view.reorder_child (widget, 0);
view.reorder_child (separator, 0);
}

View File

@ -23,6 +23,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
public Gtk.Box counters;
public Gtk.Label reblogs;
public Gtk.Label favorites;
private Image pin_indicator;
public ImageToggleButton reblog;
public ImageToggleButton favorite;
public ImageToggleButton reply;
@ -55,6 +56,10 @@ public class Tootle.StatusWidget : Gtk.EventBox {
title_box.pack_end (title_date, false, false, 0);
title_box.show_all ();
pin_indicator = new Image.from_icon_name ("view-pin-symbolic", IconSize.MENU);
pin_indicator.opacity = 0.5;
title_box.pack_end (pin_indicator, false, false, 0);
content_label = new RichLabel ("");
content_label.wrap_words ();
@ -203,6 +208,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
title_acct.label = "@" + formal.account.acct;
content_label.label = formal.content;
content_label.mentions = formal.mentions;
pin_indicator.visible = status.pinned;
var datetime = parse_date_iso8601 (formal.created_at);
title_date.label = Granite.DateTime.get_relative_datetime (datetime);
@ -272,6 +278,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
var is_muted = status.muted;
var is_pinned = status.pinned;
var item_muting = new Gtk.MenuItem.with_label (is_muted ? _("Unmute Conversation") : _("Mute Conversation"));
item_muting.activate.connect (() => status.set_muted (!is_muted));
var item_pin = new Gtk.MenuItem.with_label (is_pinned ? _("Unpin from Profile") : _("Pin on Profile"));