[Commits] [SCM] claws branch, master, updated. 3.18.0-151-gab4842412

wwp at claws-mail.org wwp at claws-mail.org
Wed Sep 22 13:31:57 CEST 2021


The branch, master has been updated
       via  ab4842412cb3e7da1c69a5c48038d5350e46c78f (commit)
      from  fef812a139f470f0805aa5db55f58c14062d385d (commit)

Summary of changes:
 src/plugins/rssyl/rssyl_cb_menu.c | 41 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit ab4842412cb3e7da1c69a5c48038d5350e46c78f
Author: wwp <subscript at free.fr>
Date:   Wed Sep 22 13:31:10 2021 +0200

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

diff --git a/src/plugins/rssyl/rssyl_cb_menu.c b/src/plugins/rssyl/rssyl_cb_menu.c
index da91c9afe..6ead891f7 100644
--- 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 at kacian.sk> and the
+ * This file (C) 2005-2021 Andrej Kacian <andrej at 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;
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list