Context menus for account widgets
This commit is contained in:
parent
4a1549fadf
commit
c012754ff3
|
@ -3,6 +3,7 @@ public class Tootle.AccountWidget : StatusWidget {
|
|||
public AccountWidget (ref 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;
|
||||
|
||||
|
@ -16,5 +17,25 @@ public class Tootle.AccountWidget : StatusWidget {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public override bool open_menu (uint button, uint32 time) {
|
||||
var menu = new Gtk.Menu ();
|
||||
menu.selection_done.connect (() => {
|
||||
menu.detach ();
|
||||
menu.destroy ();
|
||||
});
|
||||
|
||||
var item_open_link = new Gtk.MenuItem.with_label (_("Open in Browser"));
|
||||
item_open_link.activate.connect (() => Utils.open_url (status.url));
|
||||
var item_copy_link = new Gtk.MenuItem.with_label (_("Copy Link"));
|
||||
item_copy_link.activate.connect (() => Utils.copy (status.url));
|
||||
menu.add (item_open_link);
|
||||
menu.add (item_copy_link);
|
||||
|
||||
menu.show_all ();
|
||||
menu.attach_widget = this;
|
||||
menu.popup (null, null, null, button, time);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool open_menu (uint button, uint32 time) {
|
||||
public virtual bool open_menu (uint button, uint32 time) {
|
||||
var menu = new Gtk.Menu ();
|
||||
menu.selection_done.connect (() => {
|
||||
menu.detach ();
|
||||
|
@ -270,10 +270,10 @@ public class Tootle.StatusWidget : Gtk.EventBox {
|
|||
var sanitized = Utils.escape_html (status.content);
|
||||
Utils.copy (sanitized);
|
||||
});
|
||||
menu.add (item_open_link);
|
||||
menu.add (new Gtk.SeparatorMenuItem ());
|
||||
menu.add (item_copy_link);
|
||||
menu.add (item_copy);
|
||||
menu.add (item_open_link);
|
||||
menu.add (new Gtk.SeparatorMenuItem ());
|
||||
menu.add (item_copy_link);
|
||||
menu.add (item_copy);
|
||||
|
||||
menu.show_all ();
|
||||
menu.attach_widget = this;
|
||||
|
|
Loading…
Reference in New Issue