Clean up for Juno
This commit is contained in:
parent
7b3dbfe7e6
commit
a3d4ae932d
|
@ -1,8 +1,9 @@
|
|||
.mode .button{
|
||||
.mode .toggle{
|
||||
border-radius:0px;
|
||||
border-top:none;
|
||||
border-bottom:none;
|
||||
padding:10px;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
.button_avatar{
|
||||
|
@ -12,8 +13,8 @@
|
|||
background:none;
|
||||
}
|
||||
|
||||
.toot-text{
|
||||
background: none;
|
||||
.toot-text, .toot-text text{
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.header{
|
||||
|
|
|
@ -6,7 +6,7 @@ Build-Depends: meson,
|
|||
valac (>= 0.26),
|
||||
debhelper (>= 9),
|
||||
libgranite-dev,
|
||||
libgtk-3-dev,
|
||||
libgtk-3-dev (>= 3.22.0),
|
||||
libglib2.0-dev (>= 2.30.0),
|
||||
libsoup2.4-dev,
|
||||
libjson-glib-dev
|
||||
|
|
|
@ -66,7 +66,7 @@ executable(
|
|||
'src/Views/SearchView.vala',
|
||||
'src/Views/HashtagView.vala',
|
||||
dependencies: [
|
||||
dependency('gtk+-3.0'),
|
||||
dependency('gtk+-3.0', version: '>=3.22.0'),
|
||||
dependency('glib-2.0', version: '>=2.30.0'),
|
||||
dependency('granite'),
|
||||
dependency('json-glib-1.0'),
|
||||
|
|
|
@ -17,8 +17,8 @@ public class Tootle.Account{
|
|||
|
||||
public Relationship? rs;
|
||||
|
||||
public Account(int64 id){
|
||||
this.id = id;
|
||||
public Account (int64 _id){
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public static Account parse(Json.Object obj) {
|
||||
|
@ -81,14 +81,14 @@ public class Tootle.Account{
|
|||
var url = "%s/api/v1/accounts/%lld/%s".printf (Tootle.accounts.formal.instance, id, action);
|
||||
var msg = new Soup.Message("POST", url);
|
||||
msg.priority = Soup.MessagePriority.HIGH;
|
||||
Tootle.network.queue (msg, (sess, mess) => {
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try{
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
rs = Relationship.parse (root);
|
||||
updated ();
|
||||
}
|
||||
catch (GLib.Error e) {
|
||||
Tootle.app.error (_("Error"), e.message);
|
||||
app.error (_("Error"), e.message);
|
||||
warning (e.message);
|
||||
}
|
||||
});
|
||||
|
@ -97,17 +97,17 @@ public class Tootle.Account{
|
|||
|
||||
public Soup.Message set_muted (bool mute = true){
|
||||
var action = mute ? "mute" : "unmute";
|
||||
var url = "%s/api/v1/accounts/%lld/%s".printf (Tootle.accounts.formal.instance, id, action);
|
||||
var url = "%s/api/v1/accounts/%lld/%s".printf (accounts.formal.instance, id, action);
|
||||
var msg = new Soup.Message("POST", url);
|
||||
msg.priority = Soup.MessagePriority.HIGH;
|
||||
Tootle.network.queue (msg, (sess, mess) => {
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try{
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
rs = Relationship.parse (root);
|
||||
updated ();
|
||||
}
|
||||
catch (GLib.Error e) {
|
||||
Tootle.app.error (_("Error"), e.message);
|
||||
app.error (_("Error"), e.message);
|
||||
warning (e.message);
|
||||
}
|
||||
});
|
||||
|
@ -116,17 +116,17 @@ public class Tootle.Account{
|
|||
|
||||
public Soup.Message set_blocked (bool block = true){
|
||||
var action = block ? "block" : "unblock";
|
||||
var url = "%s/api/v1/accounts/%lld/%s".printf (Tootle.accounts.formal.instance, id, action);
|
||||
var url = "%s/api/v1/accounts/%lld/%s".printf (accounts.formal.instance, id, action);
|
||||
var msg = new Soup.Message("POST", url);
|
||||
msg.priority = Soup.MessagePriority.HIGH;
|
||||
Tootle.network.queue (msg, (sess, mess) => {
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try{
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
rs = Relationship.parse (root);
|
||||
updated ();
|
||||
}
|
||||
catch (GLib.Error e) {
|
||||
Tootle.app.error (_("Error"), e.message);
|
||||
app.error (_("Error"), e.message);
|
||||
warning (e.message);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,8 +6,8 @@ public class Tootle.Attachment{
|
|||
public string preview_url;
|
||||
public string? description;
|
||||
|
||||
public Attachment(int64 id){
|
||||
this.id = id;
|
||||
public Attachment(int64 _id){
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public static Attachment parse (Json.Object obj){
|
||||
|
|
|
@ -5,14 +5,15 @@ public class Tootle.Mention{
|
|||
public string acct;
|
||||
public string url;
|
||||
|
||||
public Mention (int64 id){
|
||||
this.id = id;
|
||||
public Mention (int64 _id){
|
||||
id = _id;
|
||||
}
|
||||
public Mention.from_account(Account account){
|
||||
this.id = account.id;
|
||||
this.username = account.username;
|
||||
this.acct = account.acct;
|
||||
this.url = account.url;
|
||||
|
||||
public Mention.from_account (Account account){
|
||||
id = account.id;
|
||||
username = account.username;
|
||||
acct = account.acct;
|
||||
url = account.url;
|
||||
}
|
||||
|
||||
public static Mention parse (Json.Object obj){
|
||||
|
|
|
@ -7,8 +7,8 @@ public class Tootle.Notification{
|
|||
public Status? status;
|
||||
public Account? account;
|
||||
|
||||
public Notification(int64 id) {
|
||||
this.id = id;
|
||||
public Notification (int64 _id) {
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public static Notification parse(Json.Object obj) {
|
||||
|
|
|
@ -3,8 +3,8 @@ public enum Tootle.NotificationType {
|
|||
REBLOG,
|
||||
FAVORITE,
|
||||
FOLLOW,
|
||||
FOLLOW_REQUEST,
|
||||
WATCHLIST; // Internal
|
||||
FOLLOW_REQUEST, // Internal
|
||||
WATCHLIST; // Internal
|
||||
|
||||
public string to_string() {
|
||||
switch (this) {
|
||||
|
|
|
@ -9,8 +9,8 @@ public class Tootle.Relationship{
|
|||
public bool requested;
|
||||
public bool domain_blocking;
|
||||
|
||||
public Relationship(int64 id){
|
||||
this.id = id;
|
||||
public Relationship (int64 _id){
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public static Relationship parse (Json.Object obj){
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
public class Tootle.Status {
|
||||
|
||||
public abstract signal void updated ();
|
||||
public signal void updated ();
|
||||
|
||||
public Account account;
|
||||
public int64 id;
|
||||
|
@ -20,11 +20,11 @@ public class Tootle.Status {
|
|||
public Mention[]? mentions;
|
||||
public Attachment[]? attachments;
|
||||
|
||||
public Status(int64 id) {
|
||||
this.id = id;
|
||||
public Status (int64 _id) {
|
||||
id = _id;
|
||||
}
|
||||
|
||||
public Status get_formal (){
|
||||
public Status get_formal () {
|
||||
return reblog != null ? reblog : this;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class Tootle.Status {
|
|||
}
|
||||
|
||||
public bool is_owned (){
|
||||
return get_formal ().account.id == Tootle.accounts.current.id;
|
||||
return get_formal ().account.id == accounts.current.id;
|
||||
}
|
||||
|
||||
public string get_reply_mentions () {
|
||||
|
@ -105,57 +105,57 @@ 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 (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 (() => {
|
||||
reblogged = rebl;
|
||||
updated ();
|
||||
if(rebl)
|
||||
Tootle.app.toast (_("Boosted!"));
|
||||
app.toast (_("Boosted!"));
|
||||
else
|
||||
Tootle.app.toast (_("Removed boost"));
|
||||
app.toast (_("Removed boost"));
|
||||
});
|
||||
Tootle.network.queue (msg);
|
||||
network.queue (msg);
|
||||
}
|
||||
|
||||
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 (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 (() => {
|
||||
favorited = fav;
|
||||
updated ();
|
||||
if(fav)
|
||||
Tootle.app.toast (_("Favorited!"));
|
||||
if (fav)
|
||||
app.toast (_("Favorited!"));
|
||||
else
|
||||
Tootle.app.toast (_("Removed from favorites"));
|
||||
app.toast (_("Removed from favorites"));
|
||||
});
|
||||
Tootle.network.queue (msg);
|
||||
network.queue (msg);
|
||||
}
|
||||
|
||||
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 (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 (() => {
|
||||
muted = mute;
|
||||
updated ();
|
||||
if (mute)
|
||||
Tootle.app.toast (_("Conversation muted"));
|
||||
app.toast (_("Conversation muted"));
|
||||
else
|
||||
Tootle.app.toast (_("Conversation unmuted"));
|
||||
app.toast (_("Conversation unmuted"));
|
||||
});
|
||||
Tootle.network.queue (msg);
|
||||
network.queue (msg);
|
||||
}
|
||||
|
||||
public void poof (){
|
||||
var msg = new Soup.Message("DELETE", "%s/api/v1/statuses/%lld".printf (Tootle.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 (() => {
|
||||
Tootle.app.toast (_("Poof!"));
|
||||
Tootle.network.status_removed (this.id);
|
||||
app.toast (_("Poof!"));
|
||||
network.status_removed (this.id);
|
||||
});
|
||||
Tootle.network.queue (msg);
|
||||
network.queue (msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ public enum Tootle.StatusVisibility {
|
|||
PRIVATE,
|
||||
DIRECT;
|
||||
|
||||
public string to_string() {
|
||||
public string to_string () {
|
||||
switch (this) {
|
||||
case PUBLIC:
|
||||
return "public";
|
||||
|
@ -34,7 +34,7 @@ public enum Tootle.StatusVisibility {
|
|||
}
|
||||
}
|
||||
|
||||
public string get_desc() {
|
||||
public string get_desc () {
|
||||
switch (this) {
|
||||
case PUBLIC:
|
||||
return _("Post to public timelines");
|
||||
|
@ -49,7 +49,7 @@ public enum Tootle.StatusVisibility {
|
|||
}
|
||||
}
|
||||
|
||||
public string get_icon() {
|
||||
public string get_icon () {
|
||||
switch (this) {
|
||||
case PUBLIC:
|
||||
return "network-workgroup-symbolic";
|
||||
|
@ -64,4 +64,8 @@ public enum Tootle.StatusVisibility {
|
|||
}
|
||||
}
|
||||
|
||||
public static StatusVisibility[] get_all () {
|
||||
return {StatusVisibility.PUBLIC, StatusVisibility.UNLISTED, StatusVisibility.PRIVATE, StatusVisibility.DIRECT};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ public class Tootle.Tag{
|
|||
public string name;
|
||||
public string url;
|
||||
|
||||
public Tag(string name, string url){
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
public Tag (string _name, string _url){
|
||||
name = _name;
|
||||
url = _url;
|
||||
}
|
||||
|
||||
public static Tag parse (Json.Object obj){
|
||||
|
|
|
@ -12,8 +12,7 @@ public class Tootle.Accounts : Object{
|
|||
public InstanceAccount? formal {get; set;}
|
||||
public Account? current {get; set;}
|
||||
|
||||
public Accounts (){
|
||||
Object();
|
||||
public Accounts () {
|
||||
dir_path = "%s/%s".printf (GLib.Environment.get_user_config_dir (), Tootle.app.application_id);
|
||||
file_path = "%s/%s".printf (dir_path, "accounts.json");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Gtk;
|
||||
using Granite;
|
||||
|
||||
namespace Tootle{
|
||||
namespace Tootle {
|
||||
|
||||
public static Application app;
|
||||
public static MainWindow? window;
|
||||
|
|
|
@ -21,13 +21,11 @@ public class Tootle.NewAccountDialog : Gtk.Dialog {
|
|||
private string? username;
|
||||
|
||||
public NewAccountDialog () {
|
||||
Object (
|
||||
border_width: 6,
|
||||
deletable: true,
|
||||
resizable: false,
|
||||
title: _("New Account"),
|
||||
transient_for: window
|
||||
);
|
||||
border_width = 6;
|
||||
deletable = true;
|
||||
resizable = false;
|
||||
title = _("New Account");
|
||||
transient_for = window;
|
||||
|
||||
logo = new Image.from_resource ("/com/github/bleakgrey/tootle/logo128");
|
||||
logo.halign = Gtk.Align.CENTER;
|
||||
|
|
|
@ -4,31 +4,30 @@ using Tootle;
|
|||
public class Tootle.PostDialog : Gtk.Dialog {
|
||||
|
||||
private static PostDialog dialog;
|
||||
protected Gtk.TextView text;
|
||||
private Gtk.ScrolledWindow scroll;
|
||||
private Gtk.Label counter;
|
||||
private ImageToggleButton spoiler;
|
||||
private Gtk.MenuButton visibility;
|
||||
private Gtk.Button attach;
|
||||
private Gtk.Button cancel;
|
||||
private Gtk.Button publish;
|
||||
private AttachmentBox attachments;
|
||||
|
||||
private Gtk.Revealer spoiler_revealer;
|
||||
private Gtk.Entry spoiler_text;
|
||||
protected TextView text;
|
||||
private ScrolledWindow scroll;
|
||||
private Label counter;
|
||||
private ImageToggleButton spoiler;
|
||||
private MenuButton visibility;
|
||||
private Button attach;
|
||||
private Button cancel;
|
||||
private Button publish;
|
||||
private AttachmentBox attachments;
|
||||
private Revealer spoiler_revealer;
|
||||
private Entry spoiler_text;
|
||||
|
||||
protected Status? in_reply_to;
|
||||
protected StatusVisibility visibility_opt = StatusVisibility.PUBLIC;
|
||||
protected int char_limit;
|
||||
|
||||
public PostDialog (Status? status = null) {
|
||||
Object (
|
||||
border_width: 6,
|
||||
deletable: false,
|
||||
resizable: false,
|
||||
title: _("Toot"),
|
||||
transient_for: Tootle.window
|
||||
);
|
||||
border_width = 6;
|
||||
deletable = false;
|
||||
resizable = true;
|
||||
title = _("Toot");
|
||||
transient_for = window;
|
||||
|
||||
char_limit = settings.char_limit;
|
||||
in_reply_to = status;
|
||||
if (in_reply_to != null)
|
||||
|
@ -83,11 +82,14 @@ public class Tootle.PostDialog : Gtk.Dialog {
|
|||
text.get_style_context ().add_class ("toot-text");
|
||||
text.wrap_mode = Gtk.WrapMode.WORD;
|
||||
text.accepts_tab = false;
|
||||
text.vexpand = true;
|
||||
text.buffer.changed.connect (validate);
|
||||
|
||||
scroll = new Gtk.ScrolledWindow (null, null);
|
||||
scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
|
||||
scroll.min_content_height = 120;
|
||||
scroll.vexpand = true;
|
||||
scroll.propagate_natural_height = true;
|
||||
scroll.margin_start = 6;
|
||||
scroll.margin_end = 6;
|
||||
scroll.add (text);
|
||||
|
@ -121,15 +123,13 @@ public class Tootle.PostDialog : Gtk.Dialog {
|
|||
var button = new Gtk.MenuButton ();
|
||||
var menu = new Gtk.Popover (null);
|
||||
var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
|
||||
box.margin = 6;
|
||||
box.margin = 12;
|
||||
menu.add (box);
|
||||
button.direction = Gtk.ArrowType.DOWN;
|
||||
button.image = new Gtk.Image.from_icon_name (visibility_opt.get_icon (), Gtk.IconSize.BUTTON);
|
||||
|
||||
StatusVisibility[] opts = {StatusVisibility.PUBLIC, StatusVisibility.UNLISTED, StatusVisibility.PRIVATE, StatusVisibility.DIRECT};
|
||||
|
||||
Gtk.RadioButton* first = null;
|
||||
foreach (StatusVisibility opt in opts){
|
||||
Gtk.RadioButton? first = null;
|
||||
foreach (StatusVisibility opt in StatusVisibility.get_all ()){
|
||||
var item = new Gtk.RadioButton.with_label_from_widget (first, opt.get_desc ());
|
||||
if (first == null)
|
||||
first = item;
|
||||
|
@ -180,7 +180,7 @@ public class Tootle.PostDialog : Gtk.Dialog {
|
|||
|
||||
public void publish_post () {
|
||||
var pars = "?status=%s&visibility=%s".printf (Html.uri_encode (text.buffer.text), visibility_opt.to_string ());
|
||||
pars += attachments.get_uri_array ();
|
||||
pars += attachments.get_uri_array ();
|
||||
if (in_reply_to != null)
|
||||
pars += "&in_reply_to_id=%s".printf (in_reply_to.id.to_string ());
|
||||
|
||||
|
@ -189,11 +189,11 @@ public class Tootle.PostDialog : Gtk.Dialog {
|
|||
pars += "&spoiler_text=" + Html.uri_encode (spoiler_text.buffer.text);
|
||||
}
|
||||
|
||||
var url = "%s/api/v1/statuses%s".printf (Tootle.accounts.formal.instance, pars);
|
||||
var msg = new Soup.Message("POST", url);
|
||||
Tootle.network.queue(msg, (sess, mess) => {
|
||||
var url = "%s/api/v1/statuses%s".printf (accounts.formal.instance, pars);
|
||||
var msg = new Soup.Message ("POST", url);
|
||||
network.queue(msg, (sess, mess) => {
|
||||
try {
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
var status = Status.parse (root);
|
||||
debug ("Posted: %s", status.id.to_string ()); //TODO: Live updates
|
||||
this.destroy ();
|
||||
|
|
|
@ -16,7 +16,7 @@ public class Tootle.SettingsDialog : Gtk.Dialog {
|
|||
deletable = false;
|
||||
resizable = false;
|
||||
title = _("Settings");
|
||||
transient_for = Tootle.window;
|
||||
transient_for = window;
|
||||
|
||||
int i = 0;
|
||||
grid = new Gtk.Grid ();
|
||||
|
|
|
@ -8,15 +8,18 @@ private struct CachedImage {
|
|||
public string uri;
|
||||
public int size;
|
||||
|
||||
public CachedImage(string uri, int size) { this.uri=uri; this.size=size; }
|
||||
|
||||
public static uint hash(CachedImage? c) {
|
||||
assert(c != null);
|
||||
assert(c.uri != null);
|
||||
return GLib.int64_hash(c.size) ^ c.uri.hash();
|
||||
public CachedImage (string _uri, int _size) {
|
||||
uri = _uri;
|
||||
size = _size;
|
||||
}
|
||||
|
||||
public static bool equal(CachedImage? a, CachedImage? b) {
|
||||
public static uint hash(CachedImage? c) {
|
||||
assert (c != null);
|
||||
assert (c.uri != null);
|
||||
return GLib.int64_hash (c.size) ^ c.uri.hash ();
|
||||
}
|
||||
|
||||
public static bool equal (CachedImage? a, CachedImage? b) {
|
||||
if (a == null || b == null)
|
||||
return false;
|
||||
return a.size == b.size && a.uri == b.uri;
|
||||
|
@ -35,8 +38,8 @@ public class Tootle.ImageCache : GLib.Object {
|
|||
private string cache_path;
|
||||
|
||||
construct {
|
||||
pixbufs = new GLib.HashTable<CachedImage?, Gdk.Pixbuf>(CachedImage.hash, CachedImage.equal);
|
||||
in_progress = new GLib.HashTable<CachedImage?, Soup.Message>(CachedImage.hash, CachedImage.equal);
|
||||
pixbufs = new GLib.HashTable<CachedImage?, Gdk.Pixbuf> (CachedImage.hash, CachedImage.equal);
|
||||
in_progress = new GLib.HashTable<CachedImage?, Soup.Message> (CachedImage.hash, CachedImage.equal);
|
||||
total_size_est = 0;
|
||||
cache_path = "%s/%s".printf (GLib.Environment.get_user_cache_dir (), app.application_id);
|
||||
|
||||
|
@ -44,9 +47,7 @@ public class Tootle.ImageCache : GLib.Object {
|
|||
on_settings_changed ();
|
||||
}
|
||||
|
||||
public ImageCache() {
|
||||
GLib.Object();
|
||||
}
|
||||
public ImageCache() {}
|
||||
|
||||
private void on_settings_changed () {
|
||||
// assume 32BPP (divide bytes by 4 to get # pixels) and raw, overhead-free storage
|
||||
|
@ -133,15 +134,15 @@ public class Tootle.ImageCache : GLib.Object {
|
|||
}
|
||||
|
||||
public void load_avatar (string uri, Granite.Widgets.Avatar avatar, int size) {
|
||||
get_image.begin(uri, size, (pixbuf) => avatar.pixbuf = pixbuf.scale_simple (size, size, Gdk.InterpType.BILINEAR));
|
||||
get_image.begin (uri, size, (pixbuf) => avatar.pixbuf = pixbuf.scale_simple (size, size, Gdk.InterpType.BILINEAR));
|
||||
}
|
||||
|
||||
public void load_image (string uri, Gtk.Image image) {
|
||||
load_scaled_image(uri, image, -1);
|
||||
load_scaled_image (uri, image, -1);
|
||||
}
|
||||
|
||||
public void load_scaled_image (string uri, Gtk.Image image, int size) {
|
||||
get_image.begin(uri, size, image.set_from_pixbuf);
|
||||
get_image.begin (uri, size, image.set_from_pixbuf);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,7 @@ public class Tootle.InstanceAccount : GLib.Object {
|
|||
|
||||
private Notificator? notificator;
|
||||
|
||||
public InstanceAccount (){
|
||||
Object ();
|
||||
}
|
||||
public InstanceAccount () {}
|
||||
|
||||
public string get_pretty_instance () {
|
||||
return instance
|
||||
|
@ -68,7 +66,7 @@ public class Tootle.InstanceAccount : GLib.Object {
|
|||
return acc;
|
||||
}
|
||||
|
||||
public void notification (ref Notification obj) {
|
||||
public void notification (Notification obj) {
|
||||
var title = Html.remove_tags (obj.type.get_desc (obj.account));
|
||||
var notification = new GLib.Notification (title);
|
||||
if (obj.status != null) {
|
||||
|
@ -83,7 +81,7 @@ public class Tootle.InstanceAccount : GLib.Object {
|
|||
app.send_notification (app.application_id + ":" + obj.id.to_string (), notification);
|
||||
|
||||
if (accounts.formal.token == this.token)
|
||||
network.notification (ref obj);
|
||||
network.notification (obj);
|
||||
}
|
||||
|
||||
private void status_removed (int64 id) {
|
||||
|
@ -91,7 +89,7 @@ public class Tootle.InstanceAccount : GLib.Object {
|
|||
network.status_removed (id);
|
||||
}
|
||||
|
||||
private void status_added (ref Status status) {
|
||||
private void status_added (Status status) {
|
||||
if (accounts.formal.token != this.token)
|
||||
return;
|
||||
|
||||
|
@ -102,7 +100,7 @@ public class Tootle.InstanceAccount : GLib.Object {
|
|||
obj.status = status;
|
||||
watchlist.users.@foreach (item => {
|
||||
if (item == acct || item == "@" + acct)
|
||||
notification (ref obj);
|
||||
notification (obj);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
|
||||
button_mode = new Granite.Widgets.ModeButton ();
|
||||
button_mode.get_style_context ().add_class ("mode");
|
||||
button_mode.vexpand = true;
|
||||
button_mode.valign = Gtk.Align.FILL;
|
||||
button_mode.mode_changed.connect (widget => {
|
||||
secondary_stack.set_visible_child_name (widget.tooltip_text);
|
||||
});
|
||||
|
@ -69,6 +71,7 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
header.pack_end (button_accounts);
|
||||
header.pack_end (spinner);
|
||||
header.show_all ();
|
||||
set_titlebar (header);
|
||||
|
||||
grid = new Gtk.Grid ();
|
||||
grid.attach (primary_stack, 0, 0, 1, 1);
|
||||
|
@ -86,18 +89,14 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
overlay.set_size_request (450, 600);
|
||||
add (overlay);
|
||||
show_all ();
|
||||
|
||||
button_mode.valign = Gtk.Align.FILL;
|
||||
}
|
||||
|
||||
public MainWindow (Gtk.Application application) {
|
||||
Object (application: application,
|
||||
icon_name: "com.github.bleakgrey.tootle",
|
||||
resizable: true
|
||||
);
|
||||
public MainWindow (Gtk.Application _app) {
|
||||
application = _app;
|
||||
icon_name = "com.github.bleakgrey.tootle";
|
||||
resizable = true;
|
||||
window_position = WindowPosition.CENTER;
|
||||
update_header ();
|
||||
set_titlebar (header);
|
||||
|
||||
app.toast.connect (on_toast);
|
||||
network.started.connect (() => spinner.show ());
|
||||
|
@ -106,11 +105,11 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
}
|
||||
|
||||
private void add_header_view (AbstractView view) {
|
||||
var img = new Gtk.Image.from_icon_name(view.get_icon (), Gtk.IconSize.LARGE_TOOLBAR);
|
||||
var img = new Gtk.Image.from_icon_name (view.get_icon (), Gtk.IconSize.LARGE_TOOLBAR);
|
||||
img.tooltip_text = view.get_name ();
|
||||
button_mode.append (img);
|
||||
view.image = img;
|
||||
secondary_stack.add_named(view, view.get_name ());
|
||||
secondary_stack.add_named (view, view.get_name ());
|
||||
|
||||
if (view is NotificationsView)
|
||||
img.pixel_size = 20; // For some reason Notifications icon is too small without this
|
||||
|
@ -153,9 +152,9 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
|
||||
public override bool delete_event (Gdk.EventAny event) {
|
||||
this.destroy.connect (() => {
|
||||
if (!Tootle.settings.always_online || Tootle.accounts.is_empty ())
|
||||
Tootle.app.remove_window (Tootle.window_dummy);
|
||||
Tootle.window = null;
|
||||
if (!settings.always_online || accounts.is_empty ())
|
||||
app.remove_window (window_dummy);
|
||||
window = null;
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
@ -171,7 +170,8 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
|
||||
private void update_header () {
|
||||
bool primary_mode = get_visible_id () == 0;
|
||||
button_mode.set_visible (primary_mode);
|
||||
button_mode.sensitive = primary_mode;
|
||||
button_mode.opacity = primary_mode ? 1 : 0; //Prevent HeaderBar height jitter
|
||||
button_toot.set_visible (primary_mode);
|
||||
button_back.set_visible (!primary_mode);
|
||||
button_accounts.set_visible (true);
|
||||
|
|
|
@ -5,11 +5,11 @@ using Json;
|
|||
|
||||
public class Tootle.Network : GLib.Object {
|
||||
|
||||
public abstract signal void started ();
|
||||
public abstract signal void finished ();
|
||||
public signal void started ();
|
||||
public signal void finished ();
|
||||
|
||||
public abstract signal void notification (ref Notification notification);
|
||||
public abstract signal void status_removed (int64 id);
|
||||
public signal void notification (Notification notification);
|
||||
public signal void status_removed (int64 id);
|
||||
|
||||
private int requests_processing = 0;
|
||||
private Soup.Session session;
|
||||
|
@ -30,9 +30,7 @@ public class Tootle.Network : GLib.Object {
|
|||
// session.add_feature (logger);
|
||||
}
|
||||
|
||||
public Network () {
|
||||
GLib.Object();
|
||||
}
|
||||
public Network () {}
|
||||
|
||||
public async WebsocketConnection stream (Soup.Message msg) throws GLib.Error {
|
||||
return yield session.websocket_connect_async (msg, null, null, null);
|
||||
|
|
|
@ -8,15 +8,14 @@ public class Tootle.Notificator : GLib.Object {
|
|||
private bool closing = false;
|
||||
private int timeout = 2;
|
||||
|
||||
public abstract signal void notification (ref Notification notification);
|
||||
public abstract signal void status_added (ref Status status);
|
||||
public abstract signal void status_removed (int64 id);
|
||||
public signal void notification (Notification notification);
|
||||
public signal void status_added (Status status);
|
||||
public signal void status_removed (int64 id);
|
||||
|
||||
public Notificator (Soup.Message msg){
|
||||
Object ();
|
||||
this.msg = msg;
|
||||
this.msg.priority = Soup.MessagePriority.VERY_HIGH;
|
||||
this.msg.set_flags (Soup.MessageFlags.IGNORE_CONNECTION_LIMITS);
|
||||
public Notificator (Soup.Message _msg){
|
||||
msg = _msg;
|
||||
msg.priority = Soup.MessagePriority.VERY_HIGH;
|
||||
msg.set_flags (Soup.MessageFlags.IGNORE_CONNECTION_LIMITS);
|
||||
}
|
||||
|
||||
public string get_url () {
|
||||
|
@ -92,7 +91,7 @@ public class Tootle.Notificator : GLib.Object {
|
|||
return;
|
||||
|
||||
var status = Status.parse (sanitize (root));
|
||||
status_added (ref status);
|
||||
status_added (status);
|
||||
break;
|
||||
case "delete":
|
||||
if (!settings.live_updates)
|
||||
|
@ -103,7 +102,7 @@ public class Tootle.Notificator : GLib.Object {
|
|||
break;
|
||||
case "notification":
|
||||
var notif = Notification.parse (sanitize (root));
|
||||
notification (ref notif);
|
||||
notification (notif);
|
||||
break;
|
||||
default:
|
||||
warning ("Unknown push event: %s", type);
|
||||
|
|
|
@ -114,11 +114,11 @@ public class Tootle.AccountView : TimelineView {
|
|||
|
||||
add_counter (_("Toots"), 1, account.statuses_count);
|
||||
add_counter (_("Follows"), 2, account.following_count).clicked.connect (() => {
|
||||
var view = new FollowingView (ref account);
|
||||
var view = new FollowingView (account);
|
||||
window.open_view (view);
|
||||
});
|
||||
add_counter (_("Followers"), 3, account.followers_count).clicked.connect (() => {
|
||||
var view = new FollowersView (ref account);
|
||||
var view = new FollowersView (account);
|
||||
window.open_view (view);
|
||||
});
|
||||
|
||||
|
@ -179,7 +179,7 @@ public class Tootle.AccountView : TimelineView {
|
|||
relationship.hide ();
|
||||
}
|
||||
|
||||
public override bool is_status_owned (ref Status status) {
|
||||
public override bool is_status_owned (Status status) {
|
||||
return status.is_owned ();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,18 @@ using Gtk;
|
|||
|
||||
public class Tootle.FollowersView : TimelineView {
|
||||
|
||||
public FollowersView (ref Account account) {
|
||||
public FollowersView (Account account) {
|
||||
base (account.id.to_string ());
|
||||
}
|
||||
|
||||
public new void append (ref Account account){
|
||||
public new void append (Account account){
|
||||
if (empty != null)
|
||||
empty.destroy ();
|
||||
|
||||
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
|
||||
separator.show ();
|
||||
|
||||
var widget = new AccountWidget (ref account);
|
||||
var widget = new AccountWidget (account);
|
||||
widget.separator = separator;
|
||||
view.pack_start(separator, false, false, 0);
|
||||
view.pack_start(widget, false, false, 0);
|
||||
|
@ -30,13 +30,13 @@ public class Tootle.FollowersView : TimelineView {
|
|||
public override void request (){
|
||||
var msg = new Soup.Message("GET", get_url ());
|
||||
msg.finished.connect (() => empty_state ());
|
||||
Tootle.network.queue(msg, (sess, mess) => {
|
||||
try{
|
||||
Tootle.network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
network.queue(msg, (sess, mess) => {
|
||||
try {
|
||||
network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
var object = node.get_object ();
|
||||
if (object != null){
|
||||
var status = Account.parse (object);
|
||||
append (ref status);
|
||||
append (status);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
public class Tootle.FollowingView : FollowersView {
|
||||
|
||||
public FollowingView (ref Account account) {
|
||||
base (ref account);
|
||||
public FollowingView (Account account) {
|
||||
base (account);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ public class Tootle.NotificationsView : AbstractView {
|
|||
public NotificationsView () {
|
||||
base ();
|
||||
view.remove.connect (on_remove);
|
||||
accounts.switched.connect(on_account_changed);
|
||||
app.refresh.connect(on_refresh);
|
||||
accounts.switched.connect (on_account_changed);
|
||||
app.refresh.connect (on_refresh);
|
||||
network.notification.connect (prepend);
|
||||
|
||||
request ();
|
||||
|
@ -21,18 +21,18 @@ public class Tootle.NotificationsView : AbstractView {
|
|||
return _("Notifications");
|
||||
}
|
||||
|
||||
public void prepend (ref Notification notification) {
|
||||
append (ref notification, true);
|
||||
public void prepend (Notification notification) {
|
||||
append (notification, true);
|
||||
}
|
||||
|
||||
public void append (ref Notification notification, bool reverse = false) {
|
||||
public void append (Notification notification, bool reverse = false) {
|
||||
if (empty != null)
|
||||
empty.destroy ();
|
||||
|
||||
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
|
||||
separator.show ();
|
||||
|
||||
var widget = new NotificationWidget(notification);
|
||||
var widget = new NotificationWidget (notification);
|
||||
widget.separator = separator;
|
||||
image.icon_name = Desktop.fallback_icon ("notification-new-symbolic", "user-available-symbolic");
|
||||
view.pack_start(separator, false, false, 0);
|
||||
|
@ -65,7 +65,7 @@ public class Tootle.NotificationsView : AbstractView {
|
|||
}
|
||||
|
||||
public virtual void on_account_changed (Account? account) {
|
||||
if(account == null)
|
||||
if (account == null)
|
||||
return;
|
||||
|
||||
on_refresh ();
|
||||
|
@ -78,14 +78,14 @@ public class Tootle.NotificationsView : AbstractView {
|
|||
}
|
||||
|
||||
var url = "%s/api/v1/follow_requests".printf (accounts.formal.instance);
|
||||
var msg = new Soup.Message("GET", url);
|
||||
network.queue(msg, (sess, mess) => {
|
||||
try{
|
||||
var msg = new Soup.Message ("GET", url);
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try {
|
||||
network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
var obj = node.get_object ();
|
||||
if (obj != null){
|
||||
var notification = Notification.parse_follow_request(obj);
|
||||
append (ref notification);
|
||||
var notification = Notification.parse_follow_request (obj);
|
||||
append (notification);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ public class Tootle.NotificationsView : AbstractView {
|
|||
});
|
||||
|
||||
var url2 = "%s/api/v1/notifications?limit=30".printf (accounts.formal.instance);
|
||||
var msg2 = new Soup.Message("GET", url2);
|
||||
network.queue(msg2, (sess, mess) => {
|
||||
try{
|
||||
var msg2 = new Soup.Message ("GET", url2);
|
||||
network.queue (msg2, (sess, mess) => {
|
||||
try {
|
||||
network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
var obj = node.get_object ();
|
||||
if (obj != null){
|
||||
var notification = Notification.parse(obj);
|
||||
append (ref notification);
|
||||
var notification = Notification.parse (obj);
|
||||
append (notification);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class Tootle.SearchView : AbstractView {
|
|||
entry.width_chars = 25;
|
||||
entry.text = query;
|
||||
entry.show ();
|
||||
Tootle.window.header.pack_start (entry);
|
||||
window.header.pack_start (entry);
|
||||
|
||||
destroy.connect (() => entry.destroy ());
|
||||
entry.activate.connect (() => request ());
|
||||
|
@ -25,13 +25,13 @@ public class Tootle.SearchView : AbstractView {
|
|||
entry.grab_focus_without_selecting ();
|
||||
}
|
||||
|
||||
private void append_account (ref Account acc) {
|
||||
var widget = new AccountWidget (ref acc);
|
||||
private void append_account (Account acc) {
|
||||
var widget = new AccountWidget (acc);
|
||||
view.pack_start (widget, false, false, 0);
|
||||
}
|
||||
|
||||
private void append_status (ref Status status) {
|
||||
var widget = new StatusWidget (ref status);
|
||||
private void append_status (Status status) {
|
||||
var widget = new StatusWidget (status);
|
||||
widget.button_press_event.connect(widget.open);
|
||||
view.pack_start (widget, false, false, 0);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Tootle.SearchView : AbstractView {
|
|||
}
|
||||
|
||||
private void append_hashtag (string name) {
|
||||
var text = "<a href=\"%s/tags/%s\">#%s</a>".printf (Tootle.accounts.formal.instance, Soup.URI.encode (name, null), name);
|
||||
var text = "<a href=\"%s/tags/%s\">#%s</a>".printf (accounts.formal.instance, Soup.URI.encode (name, null), name);
|
||||
var widget = new RichLabel (text);
|
||||
widget.use_markup = true;
|
||||
widget.halign = Gtk.Align.START;
|
||||
|
@ -63,14 +63,14 @@ public class Tootle.SearchView : AbstractView {
|
|||
clear ();
|
||||
return;
|
||||
}
|
||||
Tootle.window.reopen_view (this.stack_pos);
|
||||
window.reopen_view (this.stack_pos);
|
||||
|
||||
var query_encoded = Soup.URI.encode (query, null);
|
||||
var url = "%s/api/v1/search?q=%s".printf (Tootle.accounts.formal.instance, query_encoded);
|
||||
var url = "%s/api/v1/search?q=%s".printf (accounts.formal.instance, query_encoded);
|
||||
var msg = new Soup.Message("GET", url);
|
||||
Tootle.network.queue(msg, (sess, mess) => {
|
||||
try{
|
||||
var root = Tootle.network.parse (mess);
|
||||
network.queue(msg, (sess, mess) => {
|
||||
try {
|
||||
var root = network.parse (mess);
|
||||
var accounts = root.get_array_member ("accounts");
|
||||
var statuses = root.get_array_member ("statuses");
|
||||
var hashtags = root.get_array_member ("hashtags");
|
||||
|
@ -82,7 +82,7 @@ public class Tootle.SearchView : AbstractView {
|
|||
accounts.foreach_element ((array, i, node) => {
|
||||
var obj = node.get_object ();
|
||||
var acc = Account.parse (obj);
|
||||
append_account (ref acc);
|
||||
append_account (acc);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class Tootle.SearchView : AbstractView {
|
|||
statuses.foreach_element ((array, i, node) => {
|
||||
var obj = node.get_object ();
|
||||
var status = Status.parse (obj);
|
||||
append_status (ref status);
|
||||
append_status (status);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,20 +5,20 @@ public class Tootle.StatusView : AbstractView {
|
|||
private Status root_status;
|
||||
bool last_was_a_root = false;
|
||||
|
||||
public StatusView (ref Status status) {
|
||||
public StatusView (Status status) {
|
||||
base ();
|
||||
root_status = status;
|
||||
request_context ();
|
||||
}
|
||||
|
||||
private void prepend (ref Status status, bool is_root = false){
|
||||
private void prepend (Status status, bool is_root = false){
|
||||
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
|
||||
separator.show ();
|
||||
|
||||
var widget = new StatusWidget (ref status);
|
||||
widget.avatar.button_press_event.connect(widget.open_account);
|
||||
var widget = new StatusWidget (status);
|
||||
widget.avatar.button_press_event.connect (widget.open_account);
|
||||
if (!is_root)
|
||||
widget.button_press_event.connect(widget.open);
|
||||
widget.button_press_event.connect (widget.open);
|
||||
else
|
||||
widget.highlight ();
|
||||
|
||||
|
@ -31,29 +31,29 @@ public class Tootle.StatusView : AbstractView {
|
|||
}
|
||||
|
||||
public Soup.Message request_context (){
|
||||
var url = "%s/api/v1/statuses/%lld/context".printf (Tootle.accounts.formal.instance, root_status.id);
|
||||
var url = "%s/api/v1/statuses/%lld/context".printf (accounts.formal.instance, root_status.id);
|
||||
var msg = new Soup.Message("GET", url);
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try{
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
|
||||
var ancestors = root.get_array_member ("ancestors");
|
||||
ancestors.foreach_element ((array, i, node) => {
|
||||
var object = node.get_object ();
|
||||
if (object != null) {
|
||||
var status = Status.parse (object);
|
||||
prepend (ref status);
|
||||
prepend (status);
|
||||
}
|
||||
});
|
||||
|
||||
prepend (ref root_status, true);
|
||||
prepend (root_status, true);
|
||||
|
||||
var descendants = root.get_array_member ("descendants");
|
||||
descendants.foreach_element ((array, i, node) => {
|
||||
var object = node.get_object ();
|
||||
if (object != null) {
|
||||
var status = Status.parse (object);
|
||||
prepend (ref status);
|
||||
prepend (status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -70,13 +70,13 @@ public class Tootle.StatusView : AbstractView {
|
|||
var msg = new Soup.Message("GET", url);
|
||||
msg.priority = Soup.MessagePriority.HIGH;
|
||||
network.queue (msg, (sess, mess) => {
|
||||
try{
|
||||
try {
|
||||
var root = network.parse (mess);
|
||||
var statuses = root.get_array_member ("statuses");
|
||||
var object = statuses.get_element (0).get_object ();
|
||||
if (object != null){
|
||||
var st = Status.parse (object);
|
||||
window.open_view (new StatusView (ref st));
|
||||
window.open_view (new StatusView (st));
|
||||
}
|
||||
else
|
||||
app.toast (_("Toot not found"));
|
||||
|
|
|
@ -36,29 +36,29 @@ public class Tootle.TimelineView : AbstractView {
|
|||
return _("Home");
|
||||
}
|
||||
|
||||
public virtual void on_status_added (ref Status status) {
|
||||
prepend (ref status);
|
||||
public virtual void on_status_added (Status status) {
|
||||
prepend (status);
|
||||
}
|
||||
|
||||
public virtual bool is_status_owned (ref Status status) {
|
||||
public virtual bool is_status_owned (Status status) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void prepend (ref Status status) {
|
||||
append (ref status, true);
|
||||
public void prepend (Status status) {
|
||||
append (status, true);
|
||||
}
|
||||
|
||||
public void append (ref Status status, bool first = false){
|
||||
public void append (Status status, bool first = false){
|
||||
if (empty != null)
|
||||
empty.destroy ();
|
||||
|
||||
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
|
||||
separator.show ();
|
||||
|
||||
var widget = new StatusWidget (ref status);
|
||||
var widget = new StatusWidget (status);
|
||||
widget.separator = separator;
|
||||
widget.button_press_event.connect(widget.open);
|
||||
if (!is_status_owned (ref status))
|
||||
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);
|
||||
|
@ -101,7 +101,7 @@ public class Tootle.TimelineView : AbstractView {
|
|||
if (page_next != null)
|
||||
return page_next;
|
||||
|
||||
var url = "%s/api/v1/timelines/%s?limit=%i".printf (Tootle.accounts.formal.instance, this.timeline, this.limit);
|
||||
var url = "%s/api/v1/timelines/%s?limit=%i".printf (accounts.formal.instance, this.timeline, this.limit);
|
||||
url += this.pars;
|
||||
return url;
|
||||
}
|
||||
|
@ -115,12 +115,12 @@ public class Tootle.TimelineView : AbstractView {
|
|||
var msg = new Soup.Message("GET", get_url ());
|
||||
msg.finished.connect (() => empty_state ());
|
||||
network.queue(msg, (sess, mess) => {
|
||||
try{
|
||||
Tootle.network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
try {
|
||||
network.parse_array (mess).foreach_element ((array, i, node) => {
|
||||
var object = node.get_object ();
|
||||
if (object != null){
|
||||
var status = Status.parse(object);
|
||||
append (ref status);
|
||||
append (status);
|
||||
}
|
||||
});
|
||||
get_pages (mess.response_headers.get_one ("Link"));
|
||||
|
@ -167,9 +167,9 @@ public class Tootle.TimelineView : AbstractView {
|
|||
return;
|
||||
|
||||
notificator = new Notificator (stream);
|
||||
notificator.status_added.connect ((ref status) => {
|
||||
notificator.status_added.connect ((status) => {
|
||||
if (can_stream ())
|
||||
on_status_added (ref status);
|
||||
on_status_added (status);
|
||||
});
|
||||
notificator.start ();
|
||||
}
|
||||
|
|
|
@ -13,9 +13,7 @@ public class Tootle.Watchlist : GLib.Object {
|
|||
accounts.switched.connect (on_account_changed);
|
||||
}
|
||||
|
||||
public Watchlist () {
|
||||
GLib.Object();
|
||||
}
|
||||
public Watchlist () {}
|
||||
|
||||
public virtual void on_account_changed (Account? account){
|
||||
if(account != null)
|
||||
|
@ -75,12 +73,12 @@ public class Tootle.Watchlist : GLib.Object {
|
|||
return notificator;
|
||||
}
|
||||
|
||||
private void on_status_added (ref Status status) {
|
||||
private void on_status_added (Status status) {
|
||||
var obj = new Notification (-1);
|
||||
obj.type = NotificationType.WATCHLIST;
|
||||
obj.account = status.account;
|
||||
obj.status = status;
|
||||
accounts.formal.notification (ref obj);
|
||||
accounts.formal.notification (obj);
|
||||
}
|
||||
|
||||
public void add (string entity, bool is_hashtag) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
public class Tootle.AccountWidget : StatusWidget {
|
||||
|
||||
public AccountWidget (ref Account account) {
|
||||
public AccountWidget (Account account) {
|
||||
var status = new Status (-1);
|
||||
status.account = account;
|
||||
status.url = account.url;
|
||||
status.content = "<a href=\"%s\">@%s</a>".printf (account.url, account.acct);
|
||||
status.created_at = account.created_at;
|
||||
|
||||
base (ref status);
|
||||
base (status);
|
||||
|
||||
counters.visible = false;
|
||||
title_acct.visible = false;
|
||||
|
|
|
@ -87,11 +87,11 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
|
|||
var buffer = new Soup.Buffer.take (contents);
|
||||
var multipart = new Soup.Multipart (Soup.FORM_MIME_TYPE_MULTIPART);
|
||||
multipart.append_form_file ("file", mime.replace ("/", "."), mime, buffer);
|
||||
var url = "%s/api/v1/media".printf (Tootle.accounts.formal.instance);
|
||||
var url = "%s/api/v1/media".printf (accounts.formal.instance);
|
||||
var msg = Soup.Form.request_new_from_multipart (url, multipart);
|
||||
|
||||
network.queue(msg, (sess, mess) => {
|
||||
var root = Tootle.network.parse (mess);
|
||||
var root = network.parse (mess);
|
||||
attachment = Attachment.parse (root);
|
||||
editable = true;
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class Tootle.AttachmentWidget : Gtk.EventBox {
|
|||
}
|
||||
catch (Error e) {
|
||||
error (e.message);
|
||||
Tootle.app.error (_("File read error"), _("Can't read file %s: %s").printf (uri, e.message));
|
||||
app.error (_("File read error"), _("Can't read file %s: %s").printf (uri, e.message));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ public class Tootle.NotificationWidget : Gtk.Grid {
|
|||
construct {
|
||||
margin = 6;
|
||||
|
||||
image = new Gtk.Image.from_icon_name("notification-symbolic", Gtk.IconSize.BUTTON);
|
||||
image = new Gtk.Image.from_icon_name ("notification-symbolic", Gtk.IconSize.BUTTON);
|
||||
image.margin_start = 32;
|
||||
image.margin_end = 6;
|
||||
label = new RichLabel (_("Unknown Notification"));
|
||||
|
@ -55,7 +55,7 @@ public class Tootle.NotificationWidget : Gtk.Grid {
|
|||
});
|
||||
|
||||
if (notification.status != null){
|
||||
status_widget = new StatusWidget (ref notification.status);
|
||||
status_widget = new StatusWidget (notification.status);
|
||||
status_widget.is_notification = true;
|
||||
status_widget.button_press_event.connect(status_widget.open);
|
||||
status_widget.avatar.button_press_event.connect(status_widget.open_account);
|
||||
|
|
|
@ -113,7 +113,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
this.button_press_event.connect (on_clicked);
|
||||
}
|
||||
|
||||
public StatusWidget (ref Status status) {
|
||||
public StatusWidget (Status status) {
|
||||
this.status = status;
|
||||
this.status.updated.connect (rebind);
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
|
||||
public bool open (EventButton ev) {
|
||||
var formal = status.get_formal ();
|
||||
var view = new StatusView (ref formal);
|
||||
var view = new StatusView (formal);
|
||||
window.open_view (view);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue