2 * Claws-Mail-- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4 * This file (C) 2005 Andrej Kacian <andrej@kacian.sk>
6 * - Dialog which appears when manually subscribing a new feed.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include <glib/gi18n.h>
31 /* Claws Mail includes */
32 #include <mainwindow.h>
35 #include "libfeed/feed.h"
36 #include "rssyl_subscribe_gtk.h"
38 void rssyl_subscribe_dialog(RSubCtx *ctx) {
39 GtkWidget *win, *vbox, *titleframe, *titlelabel;
40 #if !(GTK_CHECK_VERSION(2, 12, 0))
41 GtkTooltips *tooltips;
46 g_return_if_fail(ctx != NULL);
47 g_return_if_fail(ctx->feed != NULL);
50 win = gtk_dialog_new_with_buttons(_("Subscribe new feed?"),
51 GTK_WINDOW(mainwindow_get_mainwindow()->window),
52 GTK_DIALOG_DESTROY_WITH_PARENT,
53 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
54 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
56 gtk_dialog_set_default_response(GTK_DIALOG(win), GTK_RESPONSE_ACCEPT);
58 vbox = gtk_dialog_get_content_area(GTK_DIALOG(win));
60 #if !(GTK_CHECK_VERSION(2, 12, 0))
61 tooltips = gtk_tooltips_new();
62 gtk_tooltips_enable(tooltips);
66 titleframe = gtk_frame_new(NULL);
67 gtk_container_set_border_width(GTK_CONTAINER(titleframe), 5);
68 gtk_frame_set_label_align(GTK_FRAME(titleframe), 0.05, 0.5);
69 gtk_frame_set_shadow_type(GTK_FRAME(titleframe), GTK_SHADOW_ETCHED_OUT);
70 gtk_box_pack_start(GTK_BOX(vbox), titleframe, FALSE, FALSE, 0);
72 titlelabel = gtk_label_new(_("<b>Feed folder:</b>"));
73 gtk_label_set_use_markup(GTK_LABEL(titlelabel), TRUE);
74 gtk_misc_set_padding(GTK_MISC(titlelabel), 5, 0);
75 gtk_frame_set_label_widget(GTK_FRAME(titleframe), titlelabel);
77 ctx->title = gtk_entry_new();
78 gtk_entry_set_text(GTK_ENTRY(ctx->title), feed_get_title(ctx->feed));
79 gtk_entry_set_activates_default(GTK_ENTRY(ctx->title), TRUE);
80 #if !(GTK_CHECK_VERSION(2, 12, 0))
81 gtk_tooltips_set_tip(tooltips, ctx->title,
82 _("Instead of using official title, you can enter a different folder "
83 "name for the feed."), NULL);
85 gtk_widget_set_tooltip_text(ctx->title,
86 _("Instead of using official title, you can enter a different folder "
87 "name for the feed."));
89 gtk_container_add(GTK_CONTAINER(titleframe), ctx->title);
91 gtk_widget_show_all(vbox);
93 ret = gtk_dialog_run(GTK_DIALOG(win));
95 if (ret == GTK_RESPONSE_ACCEPT) {
96 /* Modify ctx->feed based on user changes in dialog */
97 newtitle = (gchar *)gtk_entry_get_text(GTK_ENTRY(ctx->title));
98 if (strcmp(feed_get_title(ctx->feed), newtitle)) {
99 debug_print("RSSyl: Using feed title '%s'\n", newtitle);
100 feed_set_title(ctx->feed, newtitle);
103 /* Destroy the feed to signal outside that user cancelled subscribing */
104 feed_free(ctx->feed);
108 gtk_widget_destroy(win);