Handle status clicks properly

This commit is contained in:
bleakgrey 2018-04-25 14:45:50 +03:00
parent d6280d3b8d
commit 1851188711
3 changed files with 14 additions and 94 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ build
build.sh
build-po.sh
install.sh
*~

View File

@ -1,84 +0,0 @@
using Gtk;
public class Tootle.AccountsButton : Gtk.MenuButton{
Granite.Widgets.Avatar avatar;
Gtk.Grid grid;
Gtk.Popover menu;
AccountView default_account;
private class AccountView : Gtk.Grid{
public Gtk.Label display_name;
public Gtk.Label user;
public Gtk.Button logout;
construct {
margin = 6;
margin_start = 14;
display_name = new Gtk.Label ("<b>Anonymous</b>");
display_name.hexpand = true;
display_name.halign = Gtk.Align.START;
display_name.use_markup = true;
user = new Gtk.Label ("@error");
user.halign = Gtk.Align.START;
logout = new Gtk.Button.from_icon_name ("pane-hide-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
logout.receives_default = false;
logout.tooltip_text = _("Log out");
logout.clicked.connect (() => AccountManager.instance.logout ());
show_all ();
attach(display_name, 1, 0, 1, 1);
attach(user, 1, 1, 1, 1);
attach(logout, 2, 0, 2, 2);
}
public AccountView (){}
}
construct{
avatar = new Granite.Widgets.Avatar.with_default_icon (24);
avatar.button_press_event.connect(event => {
return false;
});
default_account = new AccountView ();
var item_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
item_separator.hexpand = true;
var item_settings = new Gtk.ModelButton ();
item_settings.text = _("Settings");
grid = new Gtk.Grid ();
grid.orientation = Gtk.Orientation.VERTICAL;
grid.width_request = 200;
grid.attach(default_account, 0, 1, 1, 1);
grid.attach(item_separator, 0, 2, 1, 1);
grid.attach(item_settings, 0, 3, 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 ();
AccountManager.instance.switched.connect (account => {
if (account != null){
CacheManager.instance.load_avatar (account.avatar, avatar, 24);
default_account.display_name.label = "<b>"+account.display_name+"</b>";
default_account.user.label = "@"+account.username;
}
});
}
public AccountsButton(){
Object();
}
}

View File

@ -1,7 +1,7 @@
using Gtk;
using Granite;
public class Tootle.StatusWidget : Gtk.Grid {
public class Tootle.StatusWidget : Gtk.EventBox {
public Status status;
@ -12,6 +12,7 @@ public class Tootle.StatusWidget : Gtk.Grid {
public Gtk.Label content;
public Gtk.Separator? separator;
public Gtk.Label? spoiler_content;
Gtk.Grid grid;
Gtk.Box counters;
Gtk.Label reblogs;
Gtk.Label favorites;
@ -21,7 +22,8 @@ public class Tootle.StatusWidget : Gtk.Grid {
Gtk.Button? spoiler_button;
construct {
margin = 6;
grid = new Gtk.Grid ();
grid.margin = 6;
avatar_size = 32;
avatar = new Granite.Widgets.Avatar.with_default_icon (avatar_size);
@ -72,10 +74,11 @@ public class Tootle.StatusWidget : Gtk.Grid {
counters.add (reply);
counters.show_all ();
attach (avatar, 1, 1, 1, 4);
attach (user, 2, 2, 1, 1);
attach (revealer, 2, 4, 1, 1);
attach (counters, 2, 5, 1, 1);
grid.attach (avatar, 1, 1, 1, 4);
grid.attach (user, 2, 2, 1, 1);
grid.attach (revealer, 2, 4, 1, 1);
grid.attach (counters, 2, 5, 1, 1);
add (grid);
show_all (); //TODO: display conversations
}
@ -96,8 +99,8 @@ public class Tootle.StatusWidget : Gtk.Grid {
label.margin_bottom = 8;
label.show ();
attach (image, 1, 0, 1, 1);
attach (label, 2, 0, 2, 1);
grid.attach (image, 1, 0, 1, 1);
grid.attach (label, 2, 0, 2, 1);
}
if (status.spoiler_text != null){
@ -111,7 +114,7 @@ public class Tootle.StatusWidget : Gtk.Grid {
spoiler_box.show_all ();
spoiler_button.clicked.connect (() => revealer.set_reveal_child (!revealer.child_revealed));
attach (spoiler_box, 2, 3, 1, 1);
grid.attach (spoiler_box, 2, 3, 1, 1);
}
destroy.connect (() => {