Clean up things
This commit is contained in:
parent
275436b779
commit
adb44697bf
|
@ -8,6 +8,7 @@ public class Tootle.Status {
|
|||
public string url;
|
||||
public string? spoiler_text;
|
||||
public string content;
|
||||
public int64 replies_count;
|
||||
public int64 reblogs_count;
|
||||
public int64 favourites_count;
|
||||
public string created_at;
|
||||
|
@ -36,6 +37,7 @@ public class Tootle.Status {
|
|||
status.account = Account.parse (obj.get_object_member ("account"));
|
||||
status.uri = obj.get_string_member ("uri");
|
||||
status.created_at = obj.get_string_member ("created_at");
|
||||
status.replies_count = obj.get_int_member ("replies_count");
|
||||
status.reblogs_count = obj.get_int_member ("reblogs_count");
|
||||
status.favourites_count = obj.get_int_member ("favourites_count");
|
||||
status.content = Html.simplify ( obj.get_string_member ("content"));
|
||||
|
@ -108,12 +110,12 @@ public class Tootle.Status {
|
|||
|
||||
public void set_reblogged (bool rebl = true){
|
||||
var action = rebl ? "reblog" : "unreblog";
|
||||
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (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 (() => {
|
||||
reblogged = rebl;
|
||||
updated ();
|
||||
if(rebl)
|
||||
if (rebl)
|
||||
app.toast (_("Boosted!"));
|
||||
else
|
||||
app.toast (_("Removed boost"));
|
||||
|
@ -123,7 +125,7 @@ public class Tootle.Status {
|
|||
|
||||
public void set_favorited (bool fav = true){
|
||||
var action = fav ? "favourite" : "unfavourite";
|
||||
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (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 (() => {
|
||||
favorited = fav;
|
||||
|
@ -138,7 +140,7 @@ public class Tootle.Status {
|
|||
|
||||
public void set_muted (bool mute = true){
|
||||
var action = mute ? "mute" : "unmute";
|
||||
var msg = new Soup.Message("POST", "%s/api/v1/statuses/%lld/%s".printf (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 (() => {
|
||||
muted = mute;
|
||||
|
@ -153,7 +155,7 @@ 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 (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;
|
||||
|
@ -167,11 +169,11 @@ public class Tootle.Status {
|
|||
}
|
||||
|
||||
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.finished.connect (() => {
|
||||
app.toast (_("Poof!"));
|
||||
network.status_removed (this.id);
|
||||
network.status_removed (id);
|
||||
});
|
||||
network.queue (msg);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ public class Tootle.Notificator : GLib.Object {
|
|||
}
|
||||
|
||||
private void on_error (Error e) {
|
||||
warning ("Error in %s: %s", get_name (), e.message);
|
||||
if (!closing)
|
||||
warning ("Error in %s: %s", get_name (), e.message);
|
||||
}
|
||||
|
||||
private void on_message (int i, Bytes bytes) {
|
||||
|
|
|
@ -5,21 +5,13 @@ public abstract class Tootle.AbstractView : ScrolledWindow {
|
|||
public int stack_pos = -1;
|
||||
public Image? image;
|
||||
public Box view;
|
||||
protected Grid grid;
|
||||
protected Box? empty;
|
||||
protected Gtk.Grid? header;
|
||||
|
||||
construct {
|
||||
view = new Box (Orientation.VERTICAL, 0);
|
||||
view.valign = Align.START;
|
||||
|
||||
grid = new Grid ();
|
||||
grid.hexpand = true;
|
||||
grid.vexpand = true;
|
||||
grid.attach (view, 0, 2);
|
||||
|
||||
add (view);
|
||||
hscrollbar_policy = PolicyType.NEVER;
|
||||
add (grid);
|
||||
|
||||
edge_reached.connect(pos => {
|
||||
if (pos == PositionType.BOTTOM)
|
||||
bottom_reached ();
|
||||
|
@ -39,7 +31,10 @@ public abstract class Tootle.AbstractView : ScrolledWindow {
|
|||
}
|
||||
|
||||
public virtual void clear (){
|
||||
view.forall (widget => widget.destroy ());
|
||||
view.forall (widget => {
|
||||
if (widget != header)
|
||||
widget.destroy ();
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void bottom_reached (){}
|
||||
|
|
|
@ -4,75 +4,74 @@ using Granite;
|
|||
public class Tootle.AccountView : TimelineView {
|
||||
|
||||
const int AVATAR_SIZE = 128;
|
||||
Account account;
|
||||
protected Account account;
|
||||
|
||||
Gtk.Grid header;
|
||||
Gtk.Grid header_image;
|
||||
Gtk.Box header_info;
|
||||
Granite.Widgets.Avatar avatar;
|
||||
RichLabel display_name;
|
||||
Gtk.Label username;
|
||||
Gtk.Label relationship;
|
||||
RichLabel note;
|
||||
Gtk.Grid counters;
|
||||
Gtk.Box actions;
|
||||
Gtk.Button button_follow;
|
||||
protected Grid header_image;
|
||||
protected Box header_info;
|
||||
protected Granite.Widgets.Avatar avatar;
|
||||
protected RichLabel display_name;
|
||||
protected Label username;
|
||||
protected Label relationship;
|
||||
protected RichLabel note;
|
||||
protected Grid counters;
|
||||
protected Box actions;
|
||||
protected Button button_follow;
|
||||
|
||||
protected Gtk.Menu menu;
|
||||
protected Gtk.MenuItem menu_edit;
|
||||
protected Gtk.MenuItem menu_mention;
|
||||
protected Gtk.MenuItem menu_mute;
|
||||
protected Gtk.MenuItem menu_block;
|
||||
protected Gtk.MenuItem menu_report;
|
||||
protected Gtk.MenuButton button_menu;
|
||||
|
||||
Gtk.Menu menu;
|
||||
Gtk.MenuItem menu_edit;
|
||||
Gtk.MenuItem menu_mention;
|
||||
Gtk.MenuItem menu_mute;
|
||||
Gtk.MenuItem menu_block;
|
||||
Gtk.MenuItem menu_report;
|
||||
Gtk.MenuButton button_menu;
|
||||
|
||||
//public override void pre_construct () {
|
||||
construct {
|
||||
header = new Gtk.Grid ();
|
||||
header_info = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
|
||||
header = new Grid ();
|
||||
header_info = new Box (Orientation.VERTICAL, 0);
|
||||
header_info.margin = 12;
|
||||
actions = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
|
||||
actions = new Box (Orientation.HORIZONTAL, 0);
|
||||
actions.hexpand = false;
|
||||
actions.halign = Gtk.Align.END;
|
||||
actions.halign = Align.END;
|
||||
actions.vexpand = false;
|
||||
actions.valign = Gtk.Align.START;
|
||||
actions.valign = Align.START;
|
||||
actions.margin = 12;
|
||||
|
||||
relationship = new Gtk.Label ("");
|
||||
relationship = new Label ("");
|
||||
relationship.get_style_context ().add_class ("relationship");
|
||||
relationship.halign = Gtk.Align.START;
|
||||
relationship.valign = Gtk.Align.START;
|
||||
relationship.halign = Align.START;
|
||||
relationship.valign = Align.START;
|
||||
relationship.margin = 12;
|
||||
header.attach (relationship, 0, 0, 1, 1);
|
||||
|
||||
avatar = new Granite.Widgets.Avatar.with_default_icon (AVATAR_SIZE);
|
||||
avatar.hexpand = true;
|
||||
avatar.margin_bottom = 6;
|
||||
header_info.pack_start(avatar, false, false, 0);
|
||||
header_info.pack_start (avatar, false, false, 0);
|
||||
|
||||
display_name = new RichLabel ("");
|
||||
display_name.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL);
|
||||
header_info.pack_start(display_name, false, false, 0);
|
||||
header_info.pack_start (display_name, false, false, 0);
|
||||
|
||||
username = new Gtk.Label ("");
|
||||
header_info.pack_start(username, false, false, 0);
|
||||
header_info.pack_start (username, false, false, 0);
|
||||
|
||||
note = new RichLabel ("");
|
||||
note.set_line_wrap (true);
|
||||
note.selectable = true;
|
||||
note.margin_top = 12;
|
||||
note.can_focus = false;
|
||||
note.justify = Gtk.Justification.CENTER;
|
||||
header_info.pack_start(note, false, false, 0);
|
||||
note.justify = Justification.CENTER;
|
||||
header_info.pack_start (note, false, false, 0);
|
||||
header_info.show_all ();
|
||||
header.attach (header_info, 0, 0, 1, 1);
|
||||
|
||||
counters = new Gtk.Grid ();
|
||||
counters = new Grid ();
|
||||
counters.column_homogeneous = true;
|
||||
counters.get_style_context ().add_class ("header-counters");
|
||||
header.attach (counters, 0, 1, 1, 1);
|
||||
|
||||
header_image = new Gtk.Grid ();
|
||||
header_image = new Grid ();
|
||||
header_image.get_style_context ().add_class ("header");
|
||||
header.attach (header_image, 0, 0, 2, 2);
|
||||
|
||||
|
@ -92,10 +91,10 @@ public class Tootle.AccountView : TimelineView {
|
|||
|
||||
button_follow = add_counter ("contact-new-symbolic");
|
||||
button_menu = new Gtk.MenuButton ();
|
||||
button_menu.image = new Gtk.Image.from_icon_name ("view-more-symbolic", Gtk.IconSize.LARGE_TOOLBAR);
|
||||
button_menu.image = new Image.from_icon_name ("view-more-symbolic", IconSize.LARGE_TOOLBAR);
|
||||
button_menu.tooltip_text = _("More Actions");
|
||||
button_menu.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
|
||||
(button_menu as Gtk.Widget).set_focus_on_click (false);
|
||||
(button_menu as Widget).set_focus_on_click (false);
|
||||
button_menu.can_default = false;
|
||||
button_menu.can_focus = false;
|
||||
button_menu.popup = menu;
|
||||
|
@ -105,8 +104,7 @@ public class Tootle.AccountView : TimelineView {
|
|||
button_follow.hide ();
|
||||
header.attach (actions, 0, 0, 2, 2);
|
||||
|
||||
grid.attach (header, 0, 1);
|
||||
//view.pack_start (header, false, false, 0);
|
||||
view.pack_start (header, false, false, 0);
|
||||
}
|
||||
|
||||
public AccountView (Account acc) {
|
||||
|
@ -155,11 +153,11 @@ public class Tootle.AccountView : TimelineView {
|
|||
button_follow.show ();
|
||||
if (account.rs.following) {
|
||||
button_follow.tooltip_text = _("Unfollow");
|
||||
(button_follow.get_image () as Gtk.Image).icon_name = "close-symbolic";
|
||||
(button_follow.get_image () as Image).icon_name = "close-symbolic";
|
||||
}
|
||||
else{
|
||||
button_follow.tooltip_text = _("Follow");
|
||||
(button_follow.get_image () as Gtk.Image).icon_name = "contact-new-symbolic";
|
||||
(button_follow.get_image () as Image).icon_name = "contact-new-symbolic";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,20 +184,20 @@ public class Tootle.AccountView : TimelineView {
|
|||
}
|
||||
|
||||
private Gtk.Button add_counter (string name, int? i = null, int64? val = null) {
|
||||
Gtk.Button btn;
|
||||
Button btn;
|
||||
if (val != null){
|
||||
btn = new Gtk.Button ();
|
||||
var label = new Gtk.Label ("<b>%s</b>\n%s".printf (name.up (), val.to_string ()));
|
||||
label.justify = Gtk.Justification.CENTER;
|
||||
btn = new Button ();
|
||||
var label = new Label ("<b>%s</b>\n%s".printf (name.up (), val.to_string ()));
|
||||
label.justify = Justification.CENTER;
|
||||
label.use_markup = true;
|
||||
label.margin = 8;
|
||||
btn.add (label);
|
||||
}
|
||||
else
|
||||
btn = new Gtk.Button.from_icon_name (name, Gtk.IconSize.LARGE_TOOLBAR);
|
||||
btn = new Button.from_icon_name (name, IconSize.LARGE_TOOLBAR);
|
||||
|
||||
btn.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
|
||||
(btn as Gtk.Widget).set_focus_on_click (false);
|
||||
(btn as Widget).set_focus_on_click (false);
|
||||
btn.can_default = false;
|
||||
btn.can_focus = false;
|
||||
|
||||
|
|
|
@ -57,15 +57,16 @@ public class Tootle.TimelineView : AbstractView {
|
|||
|
||||
var widget = new StatusWidget (status);
|
||||
widget.separator = separator;
|
||||
widget.button_press_event.connect(widget.open);
|
||||
widget.button_press_event.connect (widget.open);
|
||||
if (!is_status_owned (status))
|
||||
widget.avatar.button_press_event.connect(widget.open_account);
|
||||
view.pack_start(separator, false, false, 0);
|
||||
view.pack_start(widget, false, false, 0);
|
||||
widget.avatar.button_press_event.connect (widget.open_account);
|
||||
view.pack_start (separator, false, false, 0);
|
||||
view.pack_start (widget, false, false, 0);
|
||||
|
||||
if (first || status.pinned) {
|
||||
view.reorder_child (widget, 0);
|
||||
view.reorder_child (separator, 0);
|
||||
var new_index = header == null ? 1 : 0;
|
||||
view.reorder_child (widget, new_index);
|
||||
view.reorder_child (separator, new_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,36 +8,38 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
public bool is_notification = false;
|
||||
public const int AVATAR_SIZE = 32;
|
||||
|
||||
public Gtk.Separator? separator;
|
||||
public Gtk.Grid grid;
|
||||
public Separator? separator;
|
||||
public Granite.Widgets.Avatar avatar;
|
||||
public RichLabel title_user;
|
||||
public Gtk.Label title_date;
|
||||
public Gtk.Label title_acct;
|
||||
public Gtk.Revealer revealer;
|
||||
public RichLabel content_label;
|
||||
public RichLabel? content_spoiler;
|
||||
public Gtk.Button? spoiler_button;
|
||||
public Gtk.Box title_box;
|
||||
public AttachmentBox attachments;
|
||||
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;
|
||||
protected Grid grid;
|
||||
protected RichLabel title_user;
|
||||
protected Label title_date;
|
||||
protected Label title_acct;
|
||||
protected Revealer revealer;
|
||||
protected RichLabel content_label;
|
||||
protected RichLabel? content_spoiler;
|
||||
protected Button? spoiler_button;
|
||||
protected Box title_box;
|
||||
protected AttachmentBox attachments;
|
||||
protected Image pin_indicator;
|
||||
|
||||
protected Box counters;
|
||||
protected Label replies;
|
||||
protected Label reblogs;
|
||||
protected Label favorites;
|
||||
protected ImageToggleButton reblog;
|
||||
protected ImageToggleButton favorite;
|
||||
protected ImageToggleButton reply;
|
||||
|
||||
construct {
|
||||
grid = new Gtk.Grid ();
|
||||
grid = new Grid ();
|
||||
|
||||
avatar = new Granite.Widgets.Avatar.with_default_icon (AVATAR_SIZE);
|
||||
avatar.valign = Gtk.Align.START;
|
||||
avatar.valign = Align.START;
|
||||
avatar.margin_top = 6;
|
||||
avatar.margin_start = 6;
|
||||
avatar.margin_end = 6;
|
||||
|
||||
title_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
|
||||
title_box = new Box (Gtk.Orientation.HORIZONTAL, 6);
|
||||
title_box.hexpand = true;
|
||||
title_box.margin_end = 12;
|
||||
title_box.margin_top = 6;
|
||||
|
@ -65,16 +67,17 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
attachments = new AttachmentBox ();
|
||||
|
||||
var revealer_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
|
||||
var revealer_box = new Box (Orientation.VERTICAL, 6);
|
||||
revealer_box.margin_end = 12;
|
||||
revealer_box.add (content_label);
|
||||
revealer_box.add (attachments);
|
||||
revealer_box.add (content_label);
|
||||
revealer_box.add (attachments);
|
||||
revealer = new Revealer ();
|
||||
revealer.reveal_child = true;
|
||||
revealer.add (revealer_box);
|
||||
|
||||
reblogs = new Gtk.Label ("0");
|
||||
favorites = new Gtk.Label ("0");
|
||||
reblogs = new Label ("0");
|
||||
favorites = new Label ("0");
|
||||
replies = new Label ("0");
|
||||
|
||||
reblog = new ImageToggleButton ("media-playlist-repeat-symbolic");
|
||||
reblog.set_action ();
|
||||
|
@ -98,7 +101,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
PostDialog.open_reply (status.get_formal ());
|
||||
});
|
||||
|
||||
counters = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
|
||||
counters = new Box (Orientation.HORIZONTAL, 6);
|
||||
counters.margin_top = 6;
|
||||
counters.margin_bottom = 6;
|
||||
counters.add (reblog);
|
||||
|
@ -106,6 +109,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
counters.add (favorite);
|
||||
counters.add (favorites);
|
||||
counters.add (reply);
|
||||
counters.add (replies);
|
||||
counters.show_all ();
|
||||
|
||||
add (grid);
|
||||
|
@ -123,15 +127,15 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
this.status.updated.connect (rebind);
|
||||
|
||||
if (this.status.reblog != null) {
|
||||
var image = new Gtk.Image.from_icon_name("media-playlist-repeat-symbolic", Gtk.IconSize.BUTTON);
|
||||
image.halign = Gtk.Align.END;
|
||||
var image = new Image.from_icon_name("media-playlist-repeat-symbolic", IconSize.BUTTON);
|
||||
image.halign = Align.END;
|
||||
image.margin_end = 6;
|
||||
image.margin_top = 6;
|
||||
image.show ();
|
||||
|
||||
var label_text = _("<a href=\"%s\"><b>%s</b></a> boosted").printf (this.status.account.url, this.status.account.display_name);
|
||||
var label = new RichLabel (label_text);
|
||||
label.halign = Gtk.Align.START;
|
||||
label.halign = Align.START;
|
||||
label.margin_top = 6;
|
||||
label.show ();
|
||||
|
||||
|
@ -141,7 +145,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
if (is_spoiler ()) {
|
||||
revealer.reveal_child = false;
|
||||
var spoiler_box = new Box (Gtk.Orientation.HORIZONTAL, 6);
|
||||
var spoiler_box = new Box (Orientation.HORIZONTAL, 6);
|
||||
spoiler_box.margin_end = 12;
|
||||
|
||||
var spoiler_button_text = _("Toggle content");
|
||||
|
@ -155,7 +159,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
spoiler_button = new Button.with_label (spoiler_button_text);
|
||||
}
|
||||
spoiler_button.hexpand = true;
|
||||
spoiler_button.halign = Gtk.Align.END;
|
||||
spoiler_button.halign = Align.END;
|
||||
spoiler_button.clicked.connect (() => revealer.set_reveal_child (!revealer.child_revealed));
|
||||
|
||||
var spoiler_text = _("[ This post contains sensitive content ]");
|
||||
|
@ -180,7 +184,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
destroy.connect (() => {
|
||||
avatar.show_default (AVATAR_SIZE);
|
||||
if(separator != null)
|
||||
if (separator != null)
|
||||
separator.destroy ();
|
||||
});
|
||||
|
||||
|
@ -215,6 +219,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
reblogs.label = formal.reblogs_count.to_string ();
|
||||
favorites.label = formal.favourites_count.to_string ();
|
||||
replies.label = formal.replies_count.to_string ();
|
||||
|
||||
reblog.sensitive = false;
|
||||
reblog.active = formal.reblogged;
|
||||
|
|
Loading…
Reference in New Issue