talons

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

commit ab4842412cb3e7da1c69a5c48038d5350e46c78f
parent fef812a139f470f0805aa5db55f58c14062d385d
Author: wwp <subscript@free.fr>
Date:   Wed, 22 Sep 2021 13:31:10 +0200

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

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;