Correctly display spoilers
This commit is contained in:
parent
c45ef06e92
commit
03e1c87fcf
|
@ -4,6 +4,7 @@ public class Tootle.Status{
|
||||||
public int64 id;
|
public int64 id;
|
||||||
public string uri;
|
public string uri;
|
||||||
public string url;
|
public string url;
|
||||||
|
public string? spoiler_text;
|
||||||
public string content;
|
public string content;
|
||||||
public int64 reblogs_count;
|
public int64 reblogs_count;
|
||||||
public int64 favourites_count;
|
public int64 favourites_count;
|
||||||
|
@ -48,6 +49,9 @@ public class Tootle.Status{
|
||||||
status.reblogs_count = obj.get_int_member ("reblogs_count");
|
status.reblogs_count = obj.get_int_member ("reblogs_count");
|
||||||
status.favourites_count = obj.get_int_member ("favourites_count");
|
status.favourites_count = obj.get_int_member ("favourites_count");
|
||||||
status.content = escape_html ( obj.get_string_member ("content"));
|
status.content = escape_html ( obj.get_string_member ("content"));
|
||||||
|
var spoiler = obj.get_string_member ("spoiler_text");
|
||||||
|
if (spoiler != "")
|
||||||
|
status.spoiler_text = escape_html (spoiler);
|
||||||
|
|
||||||
if(obj.has_member ("reblogged"))
|
if(obj.has_member ("reblogged"))
|
||||||
status.reblogged = obj.get_boolean_member ("reblogged");
|
status.reblogged = obj.get_boolean_member ("reblogged");
|
||||||
|
|
|
@ -14,10 +14,13 @@ public class Tootle.StatusWidget : Gtk.Grid {
|
||||||
Gtk.Box counters;
|
Gtk.Box counters;
|
||||||
Gtk.Label reblogs;
|
Gtk.Label reblogs;
|
||||||
Gtk.Label favorites;
|
Gtk.Label favorites;
|
||||||
|
|
||||||
Gtk.ToggleButton reblog;
|
Gtk.ToggleButton reblog;
|
||||||
Gtk.ToggleButton favorite;
|
Gtk.ToggleButton favorite;
|
||||||
|
|
||||||
|
Gtk.Box? spoiler_box;
|
||||||
|
Gtk.Label? spoiler_content;
|
||||||
|
Gtk.Button? spoiler_button;
|
||||||
|
|
||||||
construct {
|
construct {
|
||||||
margin = 6;
|
margin = 6;
|
||||||
|
|
||||||
|
@ -60,10 +63,10 @@ public class Tootle.StatusWidget : Gtk.Grid {
|
||||||
counters.add(favorites);
|
counters.add(favorites);
|
||||||
counters.show_all ();
|
counters.show_all ();
|
||||||
|
|
||||||
attach(avatar, 1, 1, 1, 3);
|
attach(avatar, 1, 1, 1, 4);
|
||||||
attach(user, 2, 2, 1, 1);
|
attach(user, 2, 2, 1, 1);
|
||||||
attach(content, 2, 3, 1, 1);
|
attach(content, 2, 4, 1, 1);
|
||||||
attach(counters, 2, 4, 1, 1);
|
attach(counters, 2, 5, 1, 1);
|
||||||
show_all(); //TODO: display conversations
|
show_all(); //TODO: display conversations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +91,18 @@ public class Tootle.StatusWidget : Gtk.Grid {
|
||||||
attach (label, 2, 0, 2, 1);
|
attach (label, 2, 0, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status.spoiler_text != null){
|
||||||
|
content.hide ();
|
||||||
|
spoiler_button = new Button.with_label (_("Show content"));
|
||||||
|
spoiler_button.clicked.connect (() => content.visible = !content.visible);
|
||||||
|
spoiler_content = new Label (status.spoiler_text);
|
||||||
|
spoiler_box = new Box (Gtk.Orientation.HORIZONTAL, 6);
|
||||||
|
spoiler_box.add (spoiler_content);
|
||||||
|
spoiler_box.add (spoiler_button);
|
||||||
|
spoiler_box.show_all ();
|
||||||
|
attach(spoiler_box, 2, 3, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
destroy.connect (() => {
|
destroy.connect (() => {
|
||||||
if(separator != null)
|
if(separator != null)
|
||||||
separator.destroy ();
|
separator.destroy ();
|
||||||
|
@ -96,6 +111,8 @@ public class Tootle.StatusWidget : Gtk.Grid {
|
||||||
|
|
||||||
public void highlight (){
|
public void highlight (){
|
||||||
content.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
|
content.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
|
||||||
|
if (spoiler_content != null)
|
||||||
|
spoiler_content.get_style_context ().add_class (Granite.STYLE_CLASS_H3_LABEL);
|
||||||
avatar_size = 48;
|
avatar_size = 48;
|
||||||
avatar.show_default (avatar_size);
|
avatar.show_default (avatar_size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue