RSSyl: Convenience checkbox allowing user to open feed properties window after subscr...
authorAndrej Kacian <ticho@claws-mail.org>
Sat, 26 Jul 2014 13:46:49 +0000 (15:46 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 26 Jul 2014 13:46:49 +0000 (15:46 +0200)
src/plugins/rssyl/rssyl_subscribe.c
src/plugins/rssyl/rssyl_subscribe_gtk.c
src/plugins/rssyl/rssyl_subscribe_gtk.h

index 3bdbc73..ac5453d 100644 (file)
@@ -40,6 +40,7 @@
 #include "rssyl.h"
 #include "rssyl_add_item.h"
 #include "rssyl_feed.h"
+#include "rssyl_gtk.h"
 #include "rssyl_update_feed.h"
 #include "rssyl_subscribe_gtk.h"
 #include "strutils.h"
@@ -64,6 +65,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
        RFolderItem *ritem;
        gint i = 1;
        RSubCtx *sctx;
+       gboolean edit_properties = FALSE;
 
        g_return_val_if_fail(parent != NULL, FALSE);
        g_return_val_if_fail(url != NULL, FALSE);
@@ -94,6 +96,7 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
        if (verbose) {
                sctx = g_new0(RSubCtx, 1);
                sctx->feed = ctx->feed;
+               sctx->edit_properties = FALSE;
 
                debug_print("RSSyl: Calling subscribe dialog routine...\n");
                rssyl_subscribe_dialog(sctx);
@@ -103,6 +106,13 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
                        g_free(sctx);
                        return FALSE;
                }
+
+               edit_properties = sctx->edit_properties;
+               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);
        }
 
        /* OK, feed is succesfully fetched and correct, let's add it to CM. */
@@ -145,6 +155,10 @@ gboolean rssyl_subscribe(FolderItem *parent, const gchar *url,
 
        folder_item_scan(new_item);
        folder_write_list();
+
+       if (edit_properties)
+               rssyl_gtk_prop(ritem);
+
        folder_item_update_thaw();
 
        return TRUE;
index 3f63440..73a6728 100644 (file)
@@ -36,7 +36,7 @@
 #include "rssyl_subscribe_gtk.h"
 
 void rssyl_subscribe_dialog(RSubCtx *ctx) {
-       GtkWidget *win, *vbox, *titleframe, *titlelabel;
+       GtkWidget *win, *vbox, *title, *titleframe, *titlelabel, *editprops;
 #if !(GTK_CHECK_VERSION(2, 12, 0))
        GtkTooltips *tooltips;
 #endif
@@ -74,19 +74,23 @@ void rssyl_subscribe_dialog(RSubCtx *ctx) {
        gtk_misc_set_padding(GTK_MISC(titlelabel), 5, 0);
        gtk_frame_set_label_widget(GTK_FRAME(titleframe), titlelabel);
 
-       ctx->title = gtk_entry_new();
-       gtk_entry_set_text(GTK_ENTRY(ctx->title), feed_get_title(ctx->feed));
-       gtk_entry_set_activates_default(GTK_ENTRY(ctx->title), TRUE);
+       title = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(title), feed_get_title(ctx->feed));
+       gtk_entry_set_activates_default(GTK_ENTRY(title), TRUE);
 #if !(GTK_CHECK_VERSION(2, 12, 0))
-       gtk_tooltips_set_tip(tooltips, ctx->title,
+       gtk_tooltips_set_tip(tooltips, title,
                        _("Instead of using official title, you can enter a different folder "
                                "name for the feed."), NULL);
 #else
-       gtk_widget_set_tooltip_text(ctx->title,
+       gtk_widget_set_tooltip_text(title,
                        _("Instead of using official title, you can enter a different folder "
                                "name for the feed."));
 #endif
-       gtk_container_add(GTK_CONTAINER(titleframe), ctx->title);
+       gtk_container_add(GTK_CONTAINER(titleframe), title);
+
+       editprops = gtk_check_button_new_with_mnemonic(_("_Edit feed properties after subscribing"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(editprops), FALSE);
+       gtk_box_pack_start(GTK_BOX(vbox), editprops, FALSE, FALSE, 0);
 
        gtk_widget_show_all(vbox);
 
@@ -94,11 +98,13 @@ void rssyl_subscribe_dialog(RSubCtx *ctx) {
 
        if (ret == GTK_RESPONSE_ACCEPT) {
                /* Modify ctx->feed based on user changes in dialog */
-               newtitle = (gchar *)gtk_entry_get_text(GTK_ENTRY(ctx->title));
+               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);
                        feed_set_title(ctx->feed, newtitle);
                }
+               ctx->edit_properties =
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(editprops));
        } else {
                /* Destroy the feed to signal outside that user cancelled subscribing */
                feed_free(ctx->feed);
index 2d40b13..e5c9e72 100644 (file)
@@ -5,7 +5,7 @@
 
 struct _RSubCtx {
        Feed *feed;
-       GtkWidget *title;
+       gboolean edit_properties;
 };
 
 typedef struct _RSubCtx RSubCtx;