talons

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

commit c78b7acfa576f8a4edb645edbf58b310a7af83bb
parent 686ce43bd9b1576ec10b5c2c224c780167b8d12d
Author: wwp <subscript@free.fr>
Date:   Wed, 22 Sep 2021 14:02:28 +0200

Add new RSSyl feed: use any URI found in the clipboard.

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

diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c @@ -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;