talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 448bb734cee352dad13e4c0cdc226e0580f707c6
parent daae4a1eaa474e1cf42d3c7ed06110414b11e67f
Author: Paul <paul@claws-mail.org>
Date:   Thu, 23 Sep 2021 18:21:39 +0100

Merge branch 'master' of ssh+git://git.claws-mail.org/home/git/claws

Diffstat:
Msrc/plugins/rssyl/rssyl_cb_menu.c | 41+++++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c @@ -1,7 +1,7 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client * Copyright (C) 1999-2004 Hiroyuki Yamamoto - * This file (C) 2005-2018 Andrej Kacian <andrej@kacian.sk> and the + * This file (C) 2005-2021 Andrej Kacian <andrej@kacian.sk> and the * Claws Mail team * * - callback handler functions for folderview rssyl context menu items @@ -54,6 +54,7 @@ void rssyl_new_feed_cb(GtkAction *action, FolderView *folderview = (FolderView*)data; FolderItem *item; gchar *url; + gchar *clip_text = NULL, *str = NULL; debug_print("RSSyl: new_feed_cb\n"); @@ -63,9 +64,45 @@ void rssyl_new_feed_cb(GtkAction *action, g_return_if_fail(item != NULL); g_return_if_fail(item->folder != NULL); + clip_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)); + + if (clip_text) { + str = clip_text; +#if GLIB_CHECK_VERSION(2,66,0) + GError *error = NULL; + GUri *uri = NULL; + + /* skip any leading white-space */ + while (str && *str && g_ascii_isspace(*str)) + str++; + uri = g_uri_parse(str, G_URI_FLAGS_PARSE_RELAXED, &error); + if (error) { + g_warning("could not parse clipboard text for URI: '%s'", error->message); + g_error_free(error); + } + if (uri) { + gchar* newstr = g_uri_to_string(uri); + + debug_print("URI: '%s' -> '%s'\n", str, newstr ? newstr : "N/A"); + if (newstr) + g_free(newstr); + g_uri_unref(uri); + } else { +#else + if (!is_uri_string(str)) { +#endif + /* if no URL, ignore clipboard text */ + str = NULL; + } + } + url = input_dialog(_("Subscribe feed"), _("Input the URL of the news feed you wish to subscribe:"), - ""); + str ? str : ""); + + if (clip_text) + g_free(clip_text); + if( url == NULL ) /* User cancelled */ return;