Remove redundant signal
This commit is contained in:
parent
54605b898c
commit
f5e9b4f2dc
|
@ -2,7 +2,7 @@ using GLib;
|
|||
|
||||
public class Tootle.AccountManager : Object{
|
||||
|
||||
public abstract signal void changed_current(Account account);
|
||||
public abstract signal void changed_current(Account? account);
|
||||
public abstract signal void added(Account account);
|
||||
public abstract signal void removed(Account account);
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class Tootle.AccountManager : Object{
|
|||
var access_token = root.get_string_member ("access_token");
|
||||
settings.access_token = access_token;
|
||||
debug ("Got access token");
|
||||
Tootle.app.state_updated ();
|
||||
update_current ();
|
||||
}
|
||||
catch (GLib.Error e) {
|
||||
warning ("Can't get access token");
|
||||
|
@ -114,5 +114,10 @@ public class Tootle.AccountManager : Object{
|
|||
});
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void logout (){
|
||||
current = null;
|
||||
changed_current ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace Tootle{
|
|||
|
||||
public class Application : Granite.Application {
|
||||
|
||||
public abstract signal void state_updated();
|
||||
public abstract signal void toast(string title);
|
||||
public abstract signal void error(string error);
|
||||
|
||||
|
@ -32,6 +31,11 @@ namespace Tootle{
|
|||
|
||||
protected override void activate () {
|
||||
window.present ();
|
||||
var has_token = AccountManager.instance.has_access_token();
|
||||
if(has_token)
|
||||
AccountManager.instance.update_current ();
|
||||
else
|
||||
AccountManager.instance.changed_current (null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
set_titlebar (header);
|
||||
window_position = WindowPosition.CENTER;
|
||||
|
||||
Tootle.app.state_updated.connect(on_state_update);
|
||||
on_state_update ();
|
||||
AccountManager.instance.changed_current.connect(on_account_changed);
|
||||
}
|
||||
|
||||
construct {
|
||||
|
@ -72,19 +71,16 @@ public class Tootle.MainWindow: Gtk.Window {
|
|||
NetManager.instance.finished.connect (() => spinner.hide ());
|
||||
}
|
||||
|
||||
private void on_state_update(){
|
||||
private void on_account_changed(Account? account){
|
||||
mode.hide ();
|
||||
button_toot.hide ();
|
||||
accounts.hide ();
|
||||
stack.forall (widget => stack.remove (widget));
|
||||
|
||||
var has_token = AccountManager.instance.has_access_token();
|
||||
if(!has_token)
|
||||
if(account == null)
|
||||
show_setup_views ();
|
||||
else
|
||||
show_main_views ();
|
||||
|
||||
AccountManager.instance.update_current ();
|
||||
}
|
||||
|
||||
private void show_setup_views (){
|
||||
|
|
|
@ -28,7 +28,8 @@ public class Tootle.HomeView : Tootle.AbstractView {
|
|||
this.pars = pars;
|
||||
|
||||
show_all();
|
||||
request_update ();
|
||||
|
||||
AccountManager.instance.changed_current.connect(on_account_changed);
|
||||
|
||||
// var s = new Status(1);
|
||||
// s.content = "Test content, wow!";
|
||||
|
@ -49,7 +50,10 @@ public class Tootle.HomeView : Tootle.AbstractView {
|
|||
view.pack_end (widget, false, false, 0);
|
||||
}
|
||||
|
||||
public virtual Soup.Message request_update (){
|
||||
public virtual void on_account_changed (Account? account){
|
||||
if(account == null)
|
||||
return;
|
||||
|
||||
var url = Settings.instance.instance_url;
|
||||
url += "api/v1/timelines/";
|
||||
url += this.timeline;
|
||||
|
@ -71,7 +75,6 @@ public class Tootle.HomeView : Tootle.AbstractView {
|
|||
warning (e.message);
|
||||
}
|
||||
});
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class Tootle.AccountsButton : Gtk.MenuButton{
|
|||
item_separator.margin_top = 6;
|
||||
|
||||
var item_settings = new Gtk.ModelButton ();
|
||||
item_settings.text = _("Settings");
|
||||
item_settings.text = _("Settings");
|
||||
|
||||
grid = new Gtk.Grid ();
|
||||
grid.orientation = Gtk.Orientation.VERTICAL;
|
||||
|
@ -35,7 +35,8 @@ public class Tootle.AccountsButton : Gtk.MenuButton{
|
|||
show_all ();
|
||||
|
||||
AccountManager.instance.changed_current.connect (account => {
|
||||
CacheManager.instance.load_avatar (account.avatar, avatar, 24);
|
||||
if (account != null)
|
||||
CacheManager.instance.load_avatar (account.avatar, avatar, 24);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue