RSSyl: when user chooses a different folder name for a newly subscribed feed, store...
authorAndrej Kacian <ticho@claws-mail.org>
Mon, 20 Oct 2014 19:00:57 +0000 (21:00 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Mon, 20 Oct 2014 19:02:36 +0000 (21:02 +0200)
src/plugins/rssyl/rssyl_subscribe.c
src/plugins/rssyl/rssyl_subscribe_gtk.c
src/plugins/rssyl/rssyl_subscribe_gtk.h

index ac5453d..7cc30e9 100644 (file)
@@ -66,6 +66,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
        gint i = 1;
        RSubCtx *sctx;
        gboolean edit_properties = FALSE;
+       gchar *official_title = NULL;
 
        g_return_val_if_fail(parent != NULL, FALSE);
        g_return_val_if_fail(url != NULL, FALSE);
@@ -108,10 +109,16 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
                }
 
                edit_properties = sctx->edit_properties;
+               if (sctx->official_title != NULL) {
+                       debug_print("RSSyl: custom official title\n");
+                       official_title = g_strdup(sctx->official_title);
+               }
+
                if (sctx->edit_properties)
                        debug_print("RSSyl: User wants to edit properties of the new feed.\n");
                else
                        debug_print("RSSyl: User does not want to edit properties of the new feed.\n");
+               g_free(sctx->official_title);
                g_free(sctx);
        }
 
@@ -150,6 +157,11 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
        ritem = (RFolderItem *)new_item;
        ritem->url = g_strdup(ctx->feed->url);
 
+       if (official_title != NULL) {
+               debug_print("RSSyl: storing official feed title '%s'\n", official_title);
+               ritem->official_title = official_title;
+       }
+
        if (feed_n_items(ctx->feed) > 0)
                feed_foreach_item(ctx->feed, rssyl_subscribe_foreach_func, (gpointer)ritem);
 
index 73a6728..932883c 100644 (file)
@@ -100,7 +100,8 @@ void rssyl_subscribe_dialog(RSubCtx *ctx) {
                /* Modify ctx->feed based on user changes in dialog */
                newtitle = (gchar *)gtk_entry_get_text(GTK_ENTRY(title));
                if (strcmp(feed_get_title(ctx->feed), newtitle)) {
-                       debug_print("RSSyl: Using feed title '%s'\n", newtitle);
+                       debug_print("RSSyl: Using user-supplied feed title '%s', instead of '%s'\n", newtitle, feed_get_title(ctx->feed));
+                       ctx->official_title = g_strdup(feed_get_title(ctx->feed));
                        feed_set_title(ctx->feed, newtitle);
                }
                ctx->edit_properties =
index e5c9e72..1023022 100644 (file)
@@ -6,6 +6,7 @@
 struct _RSubCtx {
        Feed *feed;
        gboolean edit_properties;
+       gchar *official_title;
 };
 
 typedef struct _RSubCtx RSubCtx;