2018-04-14 12:09:06 +00:00
|
|
|
using Gtk;
|
|
|
|
|
|
|
|
public class Tootle.AccountsButton : Gtk.MenuButton{
|
|
|
|
|
|
|
|
Granite.Widgets.Avatar avatar;
|
|
|
|
Gtk.Grid grid;
|
|
|
|
Gtk.Popover menu;
|
|
|
|
|
|
|
|
construct{
|
|
|
|
avatar = new Granite.Widgets.Avatar.with_default_icon (24);
|
|
|
|
avatar.button_press_event.connect(event => {
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
var item_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
|
|
|
|
item_separator.hexpand = true;
|
|
|
|
item_separator.margin_top = 6;
|
|
|
|
|
|
|
|
var item_settings = new Gtk.ModelButton ();
|
2018-04-14 17:53:09 +00:00
|
|
|
item_settings.text = _("Settings");
|
2018-04-14 12:09:06 +00:00
|
|
|
|
|
|
|
grid = new Gtk.Grid ();
|
|
|
|
grid.orientation = Gtk.Orientation.VERTICAL;
|
|
|
|
grid.width_request = 200;
|
|
|
|
grid.attach(item_separator, 0, 1, 1, 1);
|
|
|
|
grid.attach(item_settings, 0, 2, 1, 1);
|
|
|
|
grid.show_all ();
|
|
|
|
|
|
|
|
menu = new Gtk.Popover (null);
|
|
|
|
menu.add (grid);
|
|
|
|
|
|
|
|
get_style_context ().add_class ("button_avatar");
|
|
|
|
popover = menu;
|
|
|
|
add(avatar);
|
|
|
|
show_all ();
|
2018-04-14 17:18:42 +00:00
|
|
|
|
|
|
|
AccountManager.instance.changed_current.connect (account => {
|
2018-04-14 17:53:09 +00:00
|
|
|
if (account != null)
|
|
|
|
CacheManager.instance.load_avatar (account.avatar, avatar, 24);
|
2018-04-14 17:18:42 +00:00
|
|
|
});
|
2018-04-14 12:09:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public AccountsButton(){
|
|
|
|
Object();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|