2 * Sylpheed -- 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 * - GUI handling functions
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.
25 #include "claws-features.h"
29 #include <glib/gi18n.h>
34 #include "mainwindow.h"
35 #include "inputdialog.h"
36 #include "folderview.h"
37 #include "alertpanel.h"
38 #include "summaryview.h"
44 #include "feedprops.h"
46 #include "rssyl_cb_gtk.h"
47 #include "rssyl_cb_menu.h"
48 #include "rssyl_gtk.h"
49 #include "rssyl_prefs.h"
51 static char *rssyl_popup_menu_labels[] =
54 N_("Refresh _all feeds"),
55 N_("Subscribe _new feed..."),
56 N_("_Unsubscribe feed..."),
57 N_("Feed pr_operties..."),
58 N_("Import feed list..."),
60 N_("_Create new folder..."),
61 N_("_Delete folder..."),
62 N_("Remove folder _tree..."),
66 static GtkActionEntry rssyl_popup_entries[] =
68 {"FolderViewPopup/RefreshFeed", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_refresh_cb) },
69 {"FolderViewPopup/RefreshAllFeeds", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_refresh_all_cb) },
71 {"FolderViewPopup/NewFeed", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_new_feed_cb) },
72 {"FolderViewPopup/RemoveFeed", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_remove_feed_cb) },
73 {"FolderViewPopup/FeedProperties", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_prop_cb) },
74 {"FolderViewPopup/ImportFeedlist", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_import_feed_list_cb) },
76 {"FolderViewPopup/RenameFolder", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_rename_cb) },
78 {"FolderViewPopup/NewFolder", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_new_folder_cb) },
79 {"FolderViewPopup/RemoveFolder", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_remove_folder_cb) },
81 {"FolderViewPopup/RemoveMailbox", NULL, NULL, NULL, NULL, G_CALLBACK(rssyl_remove_rss_cb) },
85 static void rssyl_add_menuitems(GtkUIManager *ui_manager, FolderItem *item)
87 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RefreshFeed", "FolderViewPopup/RefreshFeed", GTK_UI_MANAGER_MENUITEM)
88 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RefreshAllFeeds", "FolderViewPopup/RefreshAllFeeds", GTK_UI_MANAGER_MENUITEM)
89 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorRSS1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
90 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "NewFeed", "FolderViewPopup/NewFeed", GTK_UI_MANAGER_MENUITEM)
91 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RemoveFeed", "FolderViewPopup/RemoveFeed", GTK_UI_MANAGER_MENUITEM)
92 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "FeedProperties", "FolderViewPopup/FeedProperties", GTK_UI_MANAGER_MENUITEM)
93 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "ImportFeedlist", "FolderViewPopup/ImportFeedlist", GTK_UI_MANAGER_MENUITEM)
94 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorRSS2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
95 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM)
96 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorRSS3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
97 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "NewFolder", "FolderViewPopup/NewFolder", GTK_UI_MANAGER_MENUITEM)
98 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RemoveFolder", "FolderViewPopup/RemoveFolder", GTK_UI_MANAGER_MENUITEM)
99 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorRSS4", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
100 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RemoveMailbox", "FolderViewPopup/RemoveMailbox", GTK_UI_MANAGER_MENUITEM)
101 MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SeparatorRSS5", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR)
104 static void rssyl_set_sensitivity(GtkUIManager *ui_manager, FolderItem *item)
106 #define SET_SENS(name, sens) \
107 cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
109 RSSylFolderItem *ritem = (RSSylFolderItem *)item;
110 SET_SENS("FolderViewPopup/RefreshFeed", folder_item_parent(item) != NULL && ritem->url);
111 SET_SENS("FolderViewPopup/RefreshAllFeeds", folder_item_parent(item) == NULL );
112 SET_SENS("FolderViewPopup/NewFeed", TRUE);
113 SET_SENS("FolderViewPopup/ImportFeedlist", TRUE );
114 SET_SENS("FolderViewPopup/RemoveFeed", folder_item_parent(item) != NULL && ritem->url );
115 SET_SENS("FolderViewPopup/FeedProperties", folder_item_parent(item) != NULL && ritem->url );
116 SET_SENS("FolderViewPopup/RenameFolder", folder_item_parent(item) != NULL );
117 SET_SENS("FolderViewPopup/NewFolder", TRUE );
118 SET_SENS("FolderViewPopup/RemoveFolder", folder_item_parent(item) != NULL && !ritem->url );
119 SET_SENS("FolderViewPopup/RemoveMailbox", folder_item_parent(item) == NULL );
124 static FolderViewPopup rssyl_popup =
129 G_N_ELEMENTS(rssyl_popup_entries),
133 rssyl_set_sensitivity
136 static void rssyl_fill_popup_menu_labels(void)
140 for( i = 0; rssyl_popup_menu_labels[i] != NULL; i++ ) {
141 (rssyl_popup_entries[i]).label = _(rssyl_popup_menu_labels[i]);
145 static void rssyl_add_mailbox(GtkAction *action, gpointer callback_data)
147 MainWindow *mainwin = (MainWindow *) callback_data;
152 path = input_dialog(_("Add RSS folder tree"),
153 _("Enter name for a new RSS folder tree."),
154 RSSYL_DEFAULT_MAILBOX);
157 if( folder_find_from_path(path) ) {
158 alertpanel_error(_("The mailbox '%s' already exists."), path);
163 base = g_path_get_basename(path);
164 folder = folder_new(folder_get_class_from_string("rssyl"),
168 if( folder->klass->create_tree(folder) < 0 ) {
169 alertpanel_error(_("Creation of folder tree failed.\n"
170 "Maybe some files already exist, or you don't have the permission "
172 folder_destroy(folder);
177 folder_scan_tree(folder, TRUE);
179 folderview_set(mainwin->folderview);
182 static GtkActionEntry mainwindow_add_mailbox[] = {{
183 "File/AddMailbox/RSSyl",
184 NULL, N_("RSSyl..."), NULL, NULL, G_CALLBACK(rssyl_add_mailbox)
187 static guint main_menu_id = 0;
189 void rssyl_gtk_init(void)
191 MainWindow *mainwin = mainwindow_get_mainwindow();
193 gtk_action_group_add_actions(mainwin->action_group, mainwindow_add_mailbox,
194 1, (gpointer)mainwin);
195 MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager, "/Menu/File/AddMailbox", "RSSyl",
196 "File/AddMailbox/RSSyl", GTK_UI_MANAGER_MENUITEM,
200 rssyl_fill_popup_menu_labels();
201 folderview_register_popup(&rssyl_popup);
204 void rssyl_gtk_done(void)
206 MainWindow *mainwin = mainwindow_get_mainwindow();
207 FolderView *folderview = NULL;
208 FolderItem *fitem = NULL;
210 if (mainwin == NULL || claws_is_exiting())
213 folderview = mainwin->folderview;
214 fitem = folderview->summaryview->folder_item;
216 if( fitem && IS_RSSYL_FOLDER_ITEM(fitem) ) {
217 folderview_unselect(folderview);
218 summary_clear_all(folderview->summaryview);
221 folderview_unregister_popup(&rssyl_popup);
223 MENUITEM_REMUI_MANAGER(mainwin->ui_manager,mainwin->action_group, "File/AddMailbox/RSSyl", main_menu_id);
227 /***********************************************/
229 static RSSylFeedProp *rssyl_gtk_prop_real(RSSylFolderItem *ritem)
231 MainWindow *mainwin = mainwindow_get_mainwindow();
232 RSSylFeedProp *feedprop;
233 GtkWidget *vbox, *urllabel, *urlframe, *urlalign, *table, *refresh_label,
234 *expired_label, *hsep, *sep, *bbox, *cancel_button, *cancel_align,
235 *cancel_hbox, *cancel_image, *cancel_label, *ok_button, *ok_align,
236 *ok_hbox, *ok_image, *ok_label, *silent_update_label;
237 GtkObject *refresh_adj, *expired_adj, *fetch_comments_for_adj;
238 gint refresh, expired;
241 g_return_val_if_fail(ritem != NULL, NULL);
243 feedprop = g_new0(RSSylFeedProp, 1);
245 /* Create required widgets */
248 feedprop->window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "rssyl_gtk");
251 feedprop->url = gtk_entry_new();
252 gtk_entry_set_text(GTK_ENTRY(feedprop->url), ritem->url);
254 /* "Use default refresh interval" checkbutton */
255 feedprop->default_refresh_interval = gtk_check_button_new_with_mnemonic(
256 _("Use default refresh interval"));
257 gtk_toggle_button_set_active(
258 GTK_TOGGLE_BUTTON(feedprop->default_refresh_interval),
259 ritem->default_refresh_interval);
261 if( ritem->refresh_interval >= 0 && !ritem->default_refresh_interval )
262 refresh = ritem->refresh_interval;
264 refresh = rssyl_prefs_get()->refresh;
266 /* "Keep default number of expired items" checkbutton */
267 feedprop->default_expired_num = gtk_check_button_new_with_mnemonic(
268 _("Keep default number of expired entries"));
269 gtk_toggle_button_set_active(
270 GTK_TOGGLE_BUTTON(feedprop->default_expired_num),
271 ritem->default_expired_num);
273 feedprop->fetch_comments = gtk_check_button_new_with_mnemonic(
274 _("Fetch comments if possible"));
275 gtk_toggle_button_set_active(
276 GTK_TOGGLE_BUTTON(feedprop->fetch_comments),
277 ritem->fetch_comments);
279 /* Refresh interval spinbutton */
280 fetch_comments_for_adj = gtk_adjustment_new(ritem->fetch_comments_for,
281 -1, 100000, 1, 10, 0);
282 feedprop->fetch_comments_for = gtk_spin_button_new(GTK_ADJUSTMENT(fetch_comments_for_adj),
285 if( ritem->default_expired_num )
286 expired = rssyl_prefs_get()->expired;
288 expired = ritem->expired_num;
290 /* Refresh interval spinbutton */
291 refresh_adj = gtk_adjustment_new(refresh,
292 0, 100000, 1, 10, 0);
293 feedprop->refresh_interval = gtk_spin_button_new(GTK_ADJUSTMENT(refresh_adj),
296 /* Expired num spinbutton */
297 expired_adj = gtk_adjustment_new(ritem->expired_num, -1, 100000, 1, 10, 0);
298 feedprop->expired_num = gtk_spin_button_new(GTK_ADJUSTMENT(expired_adj),
301 vbox = gtk_vbox_new(FALSE, 0);
302 gtk_container_add(GTK_CONTAINER(feedprop->window), vbox);
305 urlframe = gtk_frame_new(NULL);
306 gtk_container_set_border_width(GTK_CONTAINER(urlframe), 5);
307 gtk_frame_set_label_align(GTK_FRAME(urlframe), 0.05, 0.5);
308 gtk_frame_set_shadow_type(GTK_FRAME(urlframe), GTK_SHADOW_ETCHED_OUT);
309 gtk_box_pack_start(GTK_BOX(vbox), urlframe, FALSE, FALSE, 0);
311 /* Label for URL frame */
312 urllabel = gtk_label_new(_("<b>Source URL:</b>"));
313 gtk_label_set_use_markup(GTK_LABEL(urllabel), TRUE);
314 gtk_misc_set_padding(GTK_MISC(urllabel), 5, 0);
315 gtk_frame_set_label_widget(GTK_FRAME(urlframe), urllabel);
317 /* URL entry (+ alignment in frame) */
318 urlalign = gtk_alignment_new(0, 0.5, 1, 1);
319 gtk_alignment_set_padding(GTK_ALIGNMENT(urlalign), 5, 5, 5, 5);
320 gtk_container_add(GTK_CONTAINER(urlframe), urlalign);
322 gtk_entry_set_activates_default(GTK_ENTRY(feedprop->url), TRUE);
323 gtk_container_add(GTK_CONTAINER(urlalign), feedprop->url);
325 /* Table for remaining properties */
326 table = gtk_table_new(8, 2, FALSE);
327 gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
329 /* Fetch comments - checkbutton */
330 gtk_table_attach(GTK_TABLE(table), feedprop->fetch_comments,
332 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
333 (GtkAttachOptions) (0), 10, 0);
334 g_signal_connect(G_OBJECT(feedprop->fetch_comments), "toggled",
335 G_CALLBACK(rssyl_fetch_comments_toggled_cb),
336 (gpointer)feedprop->fetch_comments_for);
339 /* Fetch comments for - label */
340 refresh_label = gtk_label_new(_("<b>Fetch comments on posts aged less than:</b>\n"
341 "<small>(In days; set to -1 to fetch all comments)"
343 gtk_label_set_use_markup(GTK_LABEL(refresh_label), TRUE);
344 gtk_misc_set_alignment(GTK_MISC(refresh_label), 0, 0.5);
345 gtk_table_attach(GTK_TABLE(table), refresh_label, 0, 1, row, row+1,
346 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
347 (GtkAttachOptions) (0), 10, 5);
349 /* Fetch comments for - spinbutton */
350 gtk_widget_set_sensitive(feedprop->fetch_comments_for,
351 ritem->fetch_comments);
352 gtk_table_attach(GTK_TABLE(table), feedprop->fetch_comments_for, 1, 2, row, row+1,
353 (GtkAttachOptions) (0),
354 (GtkAttachOptions) (0), 10, 5);
357 hsep = gtk_hseparator_new();
358 gtk_widget_set_size_request(hsep, -1, 10);
359 gtk_table_attach(GTK_TABLE(table), hsep, 0, 2, row, row+1,
360 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
361 (GtkAttachOptions) (0), 10, 5);
364 /* Use default refresh interval - checkbutton */
365 gtk_table_attach(GTK_TABLE(table), feedprop->default_refresh_interval,
367 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
368 (GtkAttachOptions) (0), 10, 0);
369 g_signal_connect(G_OBJECT(feedprop->default_refresh_interval), "toggled",
370 G_CALLBACK(rssyl_default_refresh_interval_toggled_cb),
371 (gpointer)feedprop->refresh_interval);
373 /* Refresh interval - label */
374 refresh_label = gtk_label_new(_("<b>Refresh interval in minutes:</b>\n"
375 "<small>(Set to 0 to disable automatic refreshing for this feed)"
377 gtk_label_set_use_markup(GTK_LABEL(refresh_label), TRUE);
378 gtk_misc_set_alignment(GTK_MISC(refresh_label), 0, 0.5);
379 gtk_table_attach(GTK_TABLE(table), refresh_label, 0, 1, row, row+1,
380 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
381 (GtkAttachOptions) (0), 10, 5);
383 /* Refresh interval - spinbutton */
384 gtk_widget_set_sensitive(feedprop->refresh_interval,
385 !ritem->default_refresh_interval);
386 gtk_table_attach(GTK_TABLE(table), feedprop->refresh_interval, 1, 2, row, row+1,
387 (GtkAttachOptions) (0),
388 (GtkAttachOptions) (0), 10, 5);
390 hsep = gtk_hseparator_new();
391 gtk_widget_set_size_request(hsep, -1, 10);
392 gtk_table_attach(GTK_TABLE(table), hsep, 0, 2, row, row+1,
393 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
394 (GtkAttachOptions) (0), 10, 5);
397 /* Use default number for expired - checkbutton */
398 gtk_table_attach(GTK_TABLE(table), feedprop->default_expired_num, 0, 2, row, row+1,
399 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
400 (GtkAttachOptions) (0), 10, 0);
401 g_signal_connect(G_OBJECT(feedprop->default_expired_num), "toggled",
402 G_CALLBACK(rssyl_default_expired_num_toggled_cb),
403 (gpointer)feedprop->expired_num);
406 /* Expired items - label */
407 expired_label = gtk_label_new(_("<b>Number of expired entries to keep:"
408 "</b>\n<small>(Set to -1 if you want to keep expired entries)"
410 gtk_label_set_use_markup(GTK_LABEL(expired_label), TRUE);
411 gtk_misc_set_alignment(GTK_MISC(expired_label), 0, 0.5);
412 gtk_table_attach(GTK_TABLE(table), expired_label, 0, 1, row, row+1,
413 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
414 (GtkAttachOptions) (0), 10, 5);
416 /* Expired items - spinbutton */
417 gtk_widget_set_sensitive(feedprop->expired_num,
418 !ritem->default_expired_num);
419 gtk_table_attach(GTK_TABLE(table), feedprop->expired_num, 1, 2, row, row+1,
420 (GtkAttachOptions) (0),
421 (GtkAttachOptions) (0), 10, 5);
424 hsep = gtk_hseparator_new();
425 gtk_widget_set_size_request(hsep, -1, 10);
426 gtk_table_attach(GTK_TABLE(table), hsep, 0, 2, row, row+1,
427 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
428 (GtkAttachOptions) (0), 10, 5);
431 /* Silent update - label */
432 silent_update_label =
433 gtk_label_new(_("<b>If an item changes, do not mark it as unread:</b>"));
434 gtk_label_set_use_markup(GTK_LABEL(silent_update_label), TRUE);
435 gtk_misc_set_alignment(GTK_MISC(silent_update_label), 0, 0.5);
436 gtk_table_attach(GTK_TABLE(table), silent_update_label, 0, 1, row, row+1,
437 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
438 (GtkAttachOptions) (0), 10, 5);
440 /* Silent update - combobox */
441 feedprop->silent_update = gtk_combo_box_new_text();
442 gtk_combo_box_append_text(GTK_COMBO_BOX(feedprop->silent_update),
443 _("Always mark as unread"));
444 gtk_combo_box_append_text(GTK_COMBO_BOX(feedprop->silent_update),
445 _("If only its text changed"));
446 gtk_combo_box_append_text(GTK_COMBO_BOX(feedprop->silent_update),
447 _("Never mark as unread"));
448 gtk_table_attach(GTK_TABLE(table), feedprop->silent_update, 1, 2, row, row+1,
449 (GtkAttachOptions) (0),
450 (GtkAttachOptions) (0), 10, 5);
451 gtk_combo_box_set_active(GTK_COMBO_BOX(feedprop->silent_update),
452 ritem->silent_update);
454 /* Separator above the button box */
455 sep = gtk_hseparator_new();
456 gtk_widget_set_size_request(sep, -1, 10);
457 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
460 bbox = gtk_hbutton_box_new();
461 gtk_container_set_border_width(GTK_CONTAINER(bbox), 5);
462 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
463 gtk_box_set_spacing(GTK_BOX(bbox), 5);
464 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
467 cancel_button = gtk_button_new();
468 gtk_container_add(GTK_CONTAINER(bbox), cancel_button);
470 cancel_align = gtk_alignment_new(0.5, 0.5, 0, 0);
471 gtk_container_add(GTK_CONTAINER(cancel_button), cancel_align);
473 cancel_hbox = gtk_hbox_new(FALSE, 2);
474 gtk_container_add(GTK_CONTAINER(cancel_align), cancel_hbox);
476 cancel_image = gtk_image_new_from_stock(GTK_STOCK_CANCEL,
477 GTK_ICON_SIZE_BUTTON);
478 gtk_box_pack_start(GTK_BOX(cancel_hbox), cancel_image, FALSE, FALSE, 0);
480 cancel_label = gtk_label_new_with_mnemonic(_("_Cancel"));
481 gtk_box_pack_end(GTK_BOX(cancel_hbox), cancel_label, FALSE, FALSE, 0);
483 g_signal_connect(G_OBJECT(cancel_button), "clicked",
484 G_CALLBACK(rssyl_props_cancel_cb), ritem);
487 ok_button = gtk_button_new();
488 gtk_container_add(GTK_CONTAINER(bbox), ok_button);
489 gtkut_widget_set_can_default(ok_button, TRUE);
491 ok_align = gtk_alignment_new(0.5, 0.5, 0, 0);
492 gtk_container_add(GTK_CONTAINER(ok_button), ok_align);
494 ok_hbox = gtk_hbox_new(FALSE, 2);
495 gtk_container_add(GTK_CONTAINER(ok_align), ok_hbox);
497 ok_image = gtk_image_new_from_stock(GTK_STOCK_OK,
498 GTK_ICON_SIZE_BUTTON);
499 gtk_box_pack_start(GTK_BOX(ok_hbox), ok_image, FALSE, FALSE, 0);
501 ok_label = gtk_label_new_with_mnemonic(_("_OK"));
502 gtk_box_pack_end(GTK_BOX(ok_hbox), ok_label, FALSE, FALSE, 0);
504 g_signal_connect(G_OBJECT(ok_button), "clicked",
505 G_CALLBACK(rssyl_props_ok_cb), ritem);
507 /* Set some misc. stuff */
508 gtk_window_set_title(GTK_WINDOW(feedprop->window),
509 g_strdup(_("Set feed properties")) );
510 gtk_window_set_modal(GTK_WINDOW(feedprop->window), TRUE);
511 gtk_window_set_transient_for(GTK_WINDOW(feedprop->window),
512 GTK_WINDOW(mainwin->window) );
514 /* Attach callbacks to handle Enter and Escape keys */
515 g_signal_connect(G_OBJECT(feedprop->window), "key_press_event",
516 G_CALLBACK(rssyl_props_key_press_cb), ritem);
519 gtk_widget_show_all(feedprop->window);
520 gtk_widget_grab_default(ok_button);
522 /* Unselect the text in URL entry */
523 gtk_editable_select_region(GTK_EDITABLE(feedprop->url), 0, 0);
525 ritem->feedprop = feedprop;
530 void rssyl_gtk_prop(RSSylFolderItem *ritem)
532 g_return_if_fail(ritem != NULL);
534 rssyl_gtk_prop_real(ritem);
537 void rssyl_gtk_prop_store(RSSylFolderItem *ritem)
540 gint x, old_ri, old_ex, old_fetch_comments;
541 gboolean use_default_ri = FALSE, use_default_ex = FALSE;
543 g_return_if_fail(ritem != NULL);
544 g_return_if_fail(ritem->feedprop != NULL);
546 url = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->url));
552 ritem->url = g_strdup(url);
555 use_default_ri = gtk_toggle_button_get_active(
556 GTK_TOGGLE_BUTTON(ritem->feedprop->default_refresh_interval));
557 ritem->default_refresh_interval = use_default_ri;
558 debug_print("store: default is %s\n", ( use_default_ri ? "ON" : "OFF" ) );
560 /* Use default if checkbutton is set */
562 x = rssyl_prefs_get()->refresh;
564 x = gtk_spin_button_get_value_as_int(
565 GTK_SPIN_BUTTON(ritem->feedprop->refresh_interval) );
567 old_ri = ritem->refresh_interval;
568 ritem->refresh_interval = x;
570 /* Update refresh interval setting if it has changed and has a sane value */
571 if( old_ri != x && x >= 0 ) {
572 debug_print("RSSyl: GTK - refresh interval changed to %d , updating "
573 "timeout\n", ritem->refresh_interval);
574 /* Value of 0 means we do not want to update automatically */
576 rssyl_start_refresh_timeout(ritem);
579 old_fetch_comments = ritem->fetch_comments;
580 ritem->fetch_comments = gtk_toggle_button_get_active(
581 GTK_TOGGLE_BUTTON(ritem->feedprop->fetch_comments));
583 ritem->fetch_comments_for = gtk_spin_button_get_value_as_int(
584 GTK_SPIN_BUTTON(ritem->feedprop->fetch_comments_for));
586 if (!old_fetch_comments && ritem->fetch_comments) {
587 /* reset the RSSylFolderItem's mtime to be sure we get all
588 * available comments */
589 ritem->item.mtime = 0;
592 use_default_ex = gtk_toggle_button_get_active(
593 GTK_TOGGLE_BUTTON(ritem->feedprop->default_expired_num));
594 ritem->default_expired_num = use_default_ex;
595 debug_print("store: default is %s\n", ( use_default_ex ? "ON" : "OFF" ) );
597 /* Use default if checkbutton is set */
599 x = rssyl_prefs_get()->expired;
601 x = gtk_spin_button_get_value_as_int(
602 GTK_SPIN_BUTTON(ritem->feedprop->expired_num) );
604 old_ex = ritem->expired_num;
605 ritem->expired_num = x;
607 ritem->silent_update =
608 gtk_combo_box_get_active(GTK_COMBO_BOX(ritem->feedprop->silent_update));
609 if( ritem->silent_update < 0 )
610 ritem->silent_update = 0;
612 rssyl_store_feed_props(ritem);
614 debug_print("last_count %d, x %d, old_ex %d\n", ritem->last_count, x, old_ex);
616 /* update if new setting is lower, or if it was changed from -1 */
617 if( ritem->last_count != 0 && x != -1 && (old_ex > x || old_ex == -1) ) {
618 debug_print("RSSyl: GTK - expired_num has changed to %d, expiring\n",
620 rssyl_expire_items(ritem);
624 GtkWidget *rssyl_feed_removal_dialog(gchar *name, GtkWidget **rmcache_widget)
627 GtkWidget *dialog, *vbox, *hbox, *image, *vbox2, *label, *cb, *aa,
629 MainWindow *mainwin = mainwindow_get_mainwindow();
631 g_return_val_if_fail(name != NULL, NULL);
633 dialog = gtk_dialog_new();
634 gtk_window_set_title(GTK_WINDOW(dialog), _("Unsubscribe feed"));
635 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
637 vbox = GTK_DIALOG(dialog)->vbox;
639 hbox = gtk_hbox_new(FALSE, 0);
640 gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
643 image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
644 GTK_ICON_SIZE_DIALOG);
645 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.30);
646 gtk_misc_set_padding(GTK_MISC(image), 12, 0);
647 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
649 vbox2 = gtk_vbox_new(FALSE, 0);
650 gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
652 /* Dialog text label */
653 label = gtk_label_new("");
654 gtk_misc_set_alignment(GTK_MISC(label), 0.1, 0);
655 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
656 gtk_misc_set_padding(GTK_MISC(label), 0, 12);
657 message = g_markup_printf_escaped("<span size='x-large'><b>%s</b></span>"
658 "\n\n%s '%s' ?", _("Unsubscribe feed"),
659 _("Do you really want to remove feed"), name);
660 gtk_label_set_markup(GTK_LABEL(label), message);
662 gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 0);
664 /* Remove cache checkbutton */
665 cb = gtk_check_button_new_with_mnemonic(_("Remove cached entries"));
666 gtk_button_set_focus_on_click(GTK_BUTTON(cb), FALSE);
667 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cb), TRUE);
668 gtk_box_pack_start(GTK_BOX(vbox2), cb, FALSE, FALSE, 0);
669 *rmcache_widget = cb;
671 aa = GTK_DIALOG(dialog)->action_area;
672 gtk_button_box_set_layout(GTK_BUTTON_BOX(aa), GTK_BUTTONBOX_END);
674 bno = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
675 gtk_dialog_add_action_widget(GTK_DIALOG(dialog), bno, GTK_RESPONSE_NO);
676 gtkut_widget_set_can_default(bno, TRUE);
678 byes = gtk_button_new_with_mnemonic(_("_Unsubscribe"));
679 gtk_dialog_add_action_widget(GTK_DIALOG(dialog), byes, GTK_RESPONSE_YES);
681 gtk_widget_grab_default(bno);
682 gtk_window_set_transient_for(GTK_WINDOW(dialog),
683 GTK_WINDOW(mainwin->window) );