Commit ff4fc92a authored by pg mr's avatar pg mr
Browse files

Added open link in notification

parent 72f489b4
Pipeline #7692 failed with stages
in 0 seconds
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
from gajim.common import helpers from gajim.common import helpers
from gajim.common.app import interface from gajim.common.app import interface
from gajim.common.exceptions import GajimGeneralException from gajim.common.exceptions import GajimGeneralException
from gajim.common.regex import LINK_REGEX
from gajim import dialogs from gajim import dialogs
from gajim.gui.dialogs import ShortcutsWindow from gajim.gui.dialogs import ShortcutsWindow
...@@ -257,6 +258,18 @@ def on_remove_event(_action, param): ...@@ -257,6 +258,18 @@ def on_remove_event(_action, param):
win.redraw_tab(win.get_control(jid, account)) win.redraw_tab(win.get_control(jid, account))
win.show_title() win.show_title()
def on_open_link_from_msg_event(_action, param):
dict_ = param.unpack()
account, jid, type_ = dict_['account'], dict_['jid'], dict_['type_']
to_search = app.events.get_events(account,jid)[-1].message # something better might be needed
search_result =LINK_REGEX.search(to_search).group()
if search_result is not None:
if search_result.startswith("www."): #for "legacy_prefixes"
search_result = "http://%s"%search_result
if search_result.startswith("ftp."): #for "legacy_prefixes"
search_result = "ftp://%s"%search_result
Gtk.show_uri_on_window(None,search_result,Gdk.CURRENT_TIME)
# Other Actions # Other Actions
def toggle_ipython(_action, _param): def toggle_ipython(_action, _param):
......
...@@ -470,6 +470,7 @@ def _get_account_actions(account): ...@@ -470,6 +470,7 @@ def _get_account_actions(account):
('-delete-motd', a.on_delete_motd, 'online', 's'), ('-delete-motd', a.on_delete_motd, 'online', 's'),
('-open-event', a.on_open_event, 'always', 'a{sv}'), ('-open-event', a.on_open_event, 'always', 'a{sv}'),
('-remove-event', a.on_remove_event, 'always', 'a{sv}'), ('-remove-event', a.on_remove_event, 'always', 'a{sv}'),
('-open-link-from-msg-event', a.on_open_link_from_msg_event, 'always', 'a{sv}'),
('-import-contacts', a.on_import_contacts, 'online', 's'), ('-import-contacts', a.on_import_contacts, 'online', 's'),
] ]
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
from gajim.common.const import StyleAttr from gajim.common.const import StyleAttr
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.common.nec import EventHelper from gajim.common.nec import EventHelper
from gajim.common.regex import LINK_REGEX
from .util import get_builder from .util import get_builder
from .util import get_icon_name from .util import get_icon_name
...@@ -207,6 +209,10 @@ def popup(self, event_type, jid, account, type_='', icon_name=None, ...@@ -207,6 +209,10 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
action = 'app.{}-remove-event'.format(account) action = 'app.{}-remove-event'.format(account)
notification.add_button_with_target( notification.add_button_with_target(
_('Mark as Read'), action, variant_dict) _('Mark as Read'), action, variant_dict)
if text is not None:
if LINK_REGEX.search(text) is not None:
action = 'app.{}-open-link-from-msg-event'.format(account)
notification.add_button_with_target(_('Open link'), action, variant_dict)
# Only one notification per JID # Only one notification per JID
if event_type == _('Contact Changed Status'): if event_type == _('Contact Changed Status'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment