mirror of
https://gitlab.gnome.org/World/tootle
synced 2025-02-16 19:40:41 +01:00
parent
21e0089cf8
commit
68ee41dc1a
@ -15,6 +15,7 @@ public class Tootle.Status {
|
|||||||
public bool favorited = false;
|
public bool favorited = false;
|
||||||
public bool sensitive = false;
|
public bool sensitive = false;
|
||||||
public bool muted = false;
|
public bool muted = false;
|
||||||
|
public bool pinned = false;
|
||||||
public StatusVisibility visibility;
|
public StatusVisibility visibility;
|
||||||
public Status? reblog;
|
public Status? reblog;
|
||||||
public Mention[]? mentions;
|
public Mention[]? mentions;
|
||||||
@ -56,6 +57,8 @@ public class Tootle.Status {
|
|||||||
status.favorited = obj.get_boolean_member ("favourited");
|
status.favorited = obj.get_boolean_member ("favourited");
|
||||||
if (obj.has_member ("muted"))
|
if (obj.has_member ("muted"))
|
||||||
status.muted = obj.get_boolean_member ("muted");
|
status.muted = obj.get_boolean_member ("muted");
|
||||||
|
if (obj.has_member ("pinned"))
|
||||||
|
status.pinned = obj.get_boolean_member ("pinned");
|
||||||
|
|
||||||
if (obj.has_member ("reblog") && obj.get_null_member("reblog") != true)
|
if (obj.has_member ("reblog") && obj.get_null_member("reblog") != true)
|
||||||
status.reblog = Status.parse (obj.get_object_member ("reblog"));
|
status.reblog = Status.parse (obj.get_object_member ("reblog"));
|
||||||
@ -148,6 +151,21 @@ public class Tootle.Status {
|
|||||||
network.queue (msg);
|
network.queue (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
msg.priority = Soup.MessagePriority.HIGH;
|
||||||
|
msg.finished.connect (() => {
|
||||||
|
pinned = pin;
|
||||||
|
updated ();
|
||||||
|
if (pin)
|
||||||
|
Tootle.app.toast (_("Pinned!"));
|
||||||
|
else
|
||||||
|
Tootle.app.toast (_("Unpinned"));
|
||||||
|
});
|
||||||
|
Tootle.network.queue (msg);
|
||||||
|
}
|
||||||
|
|
||||||
public void poof (){
|
public void poof (){
|
||||||
var msg = new Soup.Message("DELETE", "%s/api/v1/statuses/%lld".printf (accounts.formal.instance, id));
|
var msg = new Soup.Message("DELETE", "%s/api/v1/statuses/%lld".printf (accounts.formal.instance, id));
|
||||||
msg.priority = Soup.MessagePriority.HIGH;
|
msg.priority = Soup.MessagePriority.HIGH;
|
||||||
|
@ -271,8 +271,11 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||||||
var menu = new Gtk.Menu ();
|
var menu = new Gtk.Menu ();
|
||||||
|
|
||||||
var is_muted = status.muted;
|
var is_muted = status.muted;
|
||||||
|
var is_pinned = status.pinned;
|
||||||
var item_muting = new Gtk.MenuItem.with_label (is_muted ? _("Unmute Conversation") : _("Mute Conversation"));
|
var item_muting = new Gtk.MenuItem.with_label (is_muted ? _("Unmute Conversation") : _("Mute Conversation"));
|
||||||
item_muting.activate.connect (() => status.set_muted (!is_muted));
|
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"));
|
||||||
|
item_pin.activate.connect (() => status.set_pinned (!is_pinned));
|
||||||
var item_delete = new Gtk.MenuItem.with_label (_("Delete"));
|
var item_delete = new Gtk.MenuItem.with_label (_("Delete"));
|
||||||
item_delete.activate.connect (() => status.poof ());
|
item_delete.activate.connect (() => status.poof ());
|
||||||
var item_open_link = new Gtk.MenuItem.with_label (_("Open in Browser"));
|
var item_open_link = new Gtk.MenuItem.with_label (_("Open in Browser"));
|
||||||
@ -286,6 +289,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.status.is_owned ()) {
|
if (this.status.is_owned ()) {
|
||||||
|
menu.add (item_pin);
|
||||||
menu.add (item_delete);
|
menu.add (item_delete);
|
||||||
menu.add (new Gtk.SeparatorMenuItem ());
|
menu.add (new Gtk.SeparatorMenuItem ());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user