~thrrgilag/squeak

04a6746bd74f8afeb508245f52439abd0b7a1cb9 — Morgan McMillian 3 months ago de8f5a3
added menu options to copy/open link to post
2 files changed, 26 insertions(+), 0 deletions(-)

M src/menu.ui
M src/widgets.py
M src/menu.ui => src/menu.ui +8 -0
@@ 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>

M src/widgets.py => src/widgets.py +18 -0
@@ 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__ = {