added menu options to copy/open link to post

This commit is contained in:
Morgan McMillian 2021-01-01 13:26:29 -08:00
parent de8f5a3262
commit 04a6746bd7
2 changed files with 26 additions and 0 deletions

View file

@ -45,5 +45,13 @@
<attribute name="action">win.copy</attribute>
<attribute name="label" translatable="yes">Copy</attribute>
</item>
<item>
<attribute name="action">win.copylink</attribute>
<attribute name="label" translatable="yes">Copy URL</attribute>
</item>
<item>
<attribute name="action">win.openlink</attribute>
<attribute name="label" translatable="yes">Open URL</attribute>
</item>
</menu>
</interface>

View file

@ -242,6 +242,14 @@ class Timeline(Gtk.Box):
action.connect('activate', self.on_copy)
action_group.add_action(action)
action = Gio.SimpleAction.new('copylink', None)
action.connect('activate', self.on_copy_link)
action_group.add_action(action)
action = Gio.SimpleAction.new('openlink', None)
action.connect('activate', self.on_open_link)
action_group.add_action(action)
self.insert_action_group('win', action_group)
builder = Gtk.Builder.new_from_resource("/dev/thrrgilag/squeak/menu.ui")
@ -336,6 +344,16 @@ class Timeline(Gtk.Box):
def on_copy(self, action, param):
self.clipboard.set_text(self.post_data.content.text, -1)
def on_copy_link(self, action, param):
post_url = f"https://posts.pnut.io/{self.post_data.id}"
self.clipboard.set_text(post_url, -1)
def on_open_link(self, action, param):
logging.debug("open_link")
post_url = f"https://posts.pnut.io/{self.post_data.id}"
opened = Gtk.show_uri_on_window(None, post_url, Gdk.CURRENT_TIME)
logging.debug(opened)
class PostItem(Gtk.ListBoxRow):
__gsignals__ = {