1 /* Notification plugin for Claws-Mail
2 * Copyright (C) 2005-2015 Hiroyuki Yamamoto and the Claws Mail team
3 * Copyright (C) 2005-2015 Holger Berndt
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # include "claws-features.h"
25 #include <glib/gi18n.h>
29 #include "prefs_gtk.h"
30 #include "common/prefs.h"
31 #include "common/utils.h"
32 #include "common/defs.h"
33 #include "gtk/gtkutils.h"
36 #include "notification_prefs.h"
37 #include "notification_plugin.h"
38 #include "notification_core.h"
40 #include "notification_popup.h"
41 #include "notification_command.h"
42 #include "notification_lcdproc.h"
43 #include "notification_trayicon.h"
44 #include "notification_indicator.h"
45 #include "notification_hotkeys.h"
47 #include "notification_foldercheck.h"
50 /* allow infinite timeout with libnotify */
51 # define TIMEOUT_SPINNER_MIN 0.0
53 /* don't allow infinite timeout with self-handled popups */
54 # define TIMEOUT_SPINNER_MIN 0.2
57 #define TIMEOUT_SPINNER_MAX 3600.0
58 #define TIMEOUT_SPINNER_STEP 0.5
63 GtkWidget *include_mail;
64 GtkWidget *include_news;
65 GtkWidget *include_rss;
66 GtkWidget *include_calendar;
67 GtkWidget *urgency_hint_new;
68 GtkWidget *urgency_hint_unread;
69 #ifdef HAVE_LIBCANBERRA_GTK
70 GtkWidget *canberra_play_sounds;
74 NotifyPrefs notify_config;
75 NotifyPage notify_page;
77 #ifdef NOTIFICATION_BANNER
80 GtkWidget *banner_show;
81 GtkWidget *banner_speed;
82 GtkWidget *banner_width;
83 GtkWidget *banner_include_unread;
84 GtkWidget *banner_max_msgs;
85 GtkWidget *banner_sticky;
86 GtkWidget *banner_folder_specific;
87 GtkWidget *banner_enable_colors;
88 GtkWidget *banner_color_bg;
89 GtkWidget *banner_color_fg;
90 GtkWidget *banner_cont_enable;
91 GtkWidget *banner_cont_folder_specific;
92 GtkWidget *banner_cont_color_sel;
94 NotifyBannerPage banner_page;
95 #endif /* NOTIFICATION_BANNER */
97 #ifdef NOTIFICATION_POPUP
100 GtkWidget *popup_show;
101 GtkWidget *popup_timeout;
102 GtkWidget *popup_folder_specific;
103 GtkWidget *popup_cont_enable;
104 GtkWidget *popup_cont_folder_specific;
105 #ifndef HAVE_LIBNOTIFY
106 GtkWidget *popup_sticky;
107 GtkWidget *popup_enable_colors;
108 GtkWidget *popup_color_bg;
109 GtkWidget *popup_color_fg;
110 GtkWidget *popup_cont_color_sel;
111 #else /* HAVE_LIBNOTIFY */
112 GtkWidget *popup_display_folder_name;
113 #endif /* HAVE_LIBNOTIFY */
115 NotifyPopupPage popup_page;
116 #endif /* NOTIFICATION_POPUP */
118 #ifdef NOTIFICATION_COMMAND
121 GtkWidget *command_enabled;
122 GtkWidget *command_timeout;
123 GtkWidget *command_folder_specific;
124 GtkWidget *command_line;
125 GtkWidget *command_cont_enable;
126 GtkWidget *command_cont_folder_specific;
128 NotifyCommandPage command_page;
129 #endif /* NOTIFICATION_COMMAND */
131 #ifdef NOTIFICATION_LCDPROC
134 GtkWidget *lcdproc_enabled;
135 GtkWidget *lcdproc_cont_enable;
136 GtkWidget *lcdproc_hostname;
137 GtkWidget *lcdproc_port;
139 NotifyLCDProcPage lcdproc_page;
142 #ifdef NOTIFICATION_TRAYICON
145 GtkWidget *trayicon_enabled;
146 GtkWidget *trayicon_cont_enable;
147 GtkWidget *trayicon_hide_at_startup;
148 GtkWidget *trayicon_close_to_tray;
149 GtkWidget *trayicon_hide_when_iconified;
150 GtkWidget *trayicon_folder_specific;
151 GtkWidget *trayicon_cont_folder_specific;
152 #ifdef HAVE_LIBNOTIFY
153 GtkWidget *trayicon_display_folder_name;
154 GtkWidget *trayicon_popup_enabled;
155 GtkWidget *trayicon_popup_cont_enable;
156 GtkWidget *trayicon_popup_timeout;
159 NotifyTrayiconPage trayicon_page;
162 #ifdef NOTIFICATION_INDICATOR
165 GtkWidget *indicator_enabled;
166 GtkWidget *indicator_cont_enable;
167 GtkWidget *indicator_register;
168 GtkWidget *indicator_hide_minimized;
169 }NotifyIndicatorPage;
170 NotifyIndicatorPage indicator_page;
173 #ifdef NOTIFICATION_HOTKEYS
176 GtkWidget *hotkeys_enabled;
177 GtkWidget *hotkeys_cont_enable;
178 GtkWidget *hotkeys_toggle_mainwindow;
180 NotifyHotkeysPage hotkeys_page;
188 { "include_mail", "TRUE", ¬ify_config.include_mail, P_BOOL, NULL,
190 { "include_news", "TRUE", ¬ify_config.include_news, P_BOOL, NULL,
192 { "include_rss", "TRUE", ¬ify_config.include_rss, P_BOOL, NULL,
194 { "include_calendar", "TRUE", ¬ify_config.include_calendar, P_BOOL,
196 { "urgency_hint_new", "FALSE", ¬ify_config.urgency_hint_new, P_BOOL,
198 { "urgency_hint_unread", "FALSE", ¬ify_config.urgency_hint_unread, P_BOOL,
201 #ifdef HAVE_LIBCANBERRA_GTK
202 { "canberra_play_sounds", "TRUE", ¬ify_config.canberra_play_sounds, P_BOOL,
206 #ifdef NOTIFICATION_BANNER
207 { "banner_show", "0", ¬ify_config.banner_show, P_INT, NULL, NULL, NULL},
208 { "banner_speed", "30", ¬ify_config.banner_speed, P_INT, NULL, NULL, NULL},
209 { "banner_width", "0", ¬ify_config.banner_width, P_INT, NULL, NULL, NULL},
210 { "banner_include_unread", "FALSE", ¬ify_config.banner_include_unread,
211 P_BOOL, NULL, NULL, NULL},
212 { "banner_max_msgs", "100", ¬ify_config.banner_max_msgs, P_INT,
214 { "banner_sticky", "FALSE", ¬ify_config.banner_sticky,
215 P_BOOL, NULL, NULL, NULL},
216 { "banner_root_x", "0", ¬ify_config.banner_root_x, P_INT,
218 { "banner_root_y", "10", ¬ify_config.banner_root_y, P_INT,
220 { "banner_folder_specific", "FALSE", ¬ify_config.banner_folder_specific,
221 P_BOOL, NULL, NULL, NULL},
222 { "banner_enable_colors", "FALSE", ¬ify_config.banner_enable_colors,
223 P_BOOL, NULL, NULL, NULL},
224 { "banner_color_bg", "0", ¬ify_config.banner_color_bg, P_COLOR,
226 { "banner_color_fg", "16776704", ¬ify_config.banner_color_fg, P_COLOR,
230 #ifdef NOTIFICATION_POPUP
231 { "popup_show", "TRUE", ¬ify_config.popup_show, P_BOOL, NULL, NULL, NULL},
232 { "popup_timeout", "5000", ¬ify_config.popup_timeout,
233 P_INT, NULL, NULL, NULL},
234 { "popup_folder_specific", "FALSE", ¬ify_config.popup_folder_specific,
235 P_BOOL, NULL, NULL, NULL},
236 #ifndef HAVE_LIBNOTIFY
237 { "popup_sticky", "TRUE", ¬ify_config.popup_sticky, P_BOOL,
239 { "popup_root_x", "10", ¬ify_config.popup_root_x,
240 P_INT, NULL, NULL, NULL},
241 { "popup_root_y", "10", ¬ify_config.popup_root_y,
242 P_INT, NULL, NULL, NULL},
243 { "popup_width", "100", ¬ify_config.popup_width,
244 P_INT, NULL, NULL, NULL},
245 { "popup_enable_colors", "FALSE", ¬ify_config.popup_enable_colors, P_BOOL,
247 { "popup_color_bg", "0", ¬ify_config.popup_color_bg, P_COLOR,
249 { "popup_color_fg", "16776704", ¬ify_config.popup_color_fg, P_COLOR,
251 #else /* HAVE_LIBNOTIFY */
252 { "popup_display_folder_name", "FALSE", ¬ify_config.popup_display_folder_name,
253 P_BOOL, NULL, NULL, NULL},
254 #endif /* HAVE_LIBNOTIFY */
257 #ifdef NOTIFICATION_COMMAND
258 { "command_enabled", "FALSE", ¬ify_config.command_enabled, P_BOOL,
260 { "command_timeout", "60000", ¬ify_config.command_timeout, P_INT,
262 { "command_folder_specific", "FALSE", ¬ify_config.command_folder_specific,
263 P_BOOL, NULL, NULL, NULL},
264 { "command_line", "", ¬ify_config.command_line, P_STRING,
268 #ifdef NOTIFICATION_LCDPROC
269 { "lcdproc_enabled", "FALSE", ¬ify_config.lcdproc_enabled, P_BOOL,
271 { "lcdproc_hostname", "localhost", ¬ify_config.lcdproc_hostname, P_STRING,
273 { "lcdproc_port", "13666", ¬ify_config.lcdproc_port, P_INT,
277 #ifdef NOTIFICATION_TRAYICON
279 { "trayicon_enabled", "FALSE", ¬ify_config.trayicon_enabled, P_BOOL,
282 { "trayicon_enabled", "TRUE", ¬ify_config.trayicon_enabled, P_BOOL,
285 { "trayicon_hide_at_startup", "FALSE",
286 ¬ify_config.trayicon_hide_at_startup, P_BOOL, NULL, NULL, NULL},
287 { "trayicon_close_to_tray", "FALSE",
288 ¬ify_config.trayicon_close_to_tray, P_BOOL, NULL, NULL, NULL},
289 { "trayicon_hide_when_iconified", "FALSE",
290 ¬ify_config.trayicon_hide_when_iconified, P_BOOL, NULL, NULL, NULL},
291 { "trayicon_folder_specific", "FALSE",
292 ¬ify_config.trayicon_folder_specific,
293 P_BOOL, NULL, NULL, NULL},
294 #ifdef HAVE_LIBNOTIFY
295 { "trayicon_display_folder_name", "FALSE",
296 ¬ify_config.trayicon_display_folder_name,
297 P_BOOL, NULL, NULL, NULL},
298 { "trayicon_popup_enabled", "TRUE", ¬ify_config.trayicon_popup_enabled,
299 P_BOOL, NULL, NULL, NULL},
300 { "trayicon_popup_timeout", "5000", ¬ify_config.trayicon_popup_timeout,
301 P_INT, NULL, NULL, NULL},
302 #endif /* HAVE_LIBNOTIFY */
305 #ifdef NOTIFICATION_INDICATOR
306 { "indicator_enabled", "FALSE", ¬ify_config.indicator_enabled, P_BOOL,
308 { "indicator_hide_minimized", "FALSE", ¬ify_config.indicator_hide_minimized, P_BOOL,
310 #endif /* NOTIFICATION_INDICATOR */
311 #ifdef NOTIFICATION_HOTKEYS
312 { "hotkeys_enabled", "FALSE", ¬ify_config.hotkeys_enabled, P_BOOL,
314 { "hotkeys_toggle_mainwindow", "", ¬ify_config.hotkeys_toggle_mainwindow,
315 P_STRING, NULL, NULL, NULL},
316 #endif /* NOTIFICATION_HOTKEYS */
317 { NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL } };
319 static void notify_create_prefs_page(PrefsPage*, GtkWindow*, gpointer);
320 static void notify_destroy_prefs_page(PrefsPage*);
321 static void notify_save_prefs(PrefsPage*);
323 #ifdef NOTIFICATION_BANNER
324 static void notify_create_banner_page(PrefsPage*, GtkWindow*, gpointer);
325 static void notify_destroy_banner_page(PrefsPage*);
326 static void notify_save_banner(PrefsPage*);
327 static void notify_banner_enable_set_sensitivity(GtkComboBox*, gpointer);
328 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
329 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton*,
333 #ifdef NOTIFICATION_POPUP
334 static void notify_create_popup_page(PrefsPage*, GtkWindow*, gpointer);
335 static void notify_destroy_popup_page(PrefsPage*);
336 static void notify_save_popup(PrefsPage*);
337 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton*,
339 static void notify_popup_enable_set_sensitivity(GtkToggleButton*, gpointer);
340 #ifndef HAVE_LIBNOTIFY
341 static void notify_popup_set_done_cb(GtkWidget*, gpointer);
342 static void notify_popup_set_cb(GtkWidget*, gpointer);
343 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
344 #endif /* !HAVE_LIBNOTIFY */
347 #ifdef NOTIFICATION_COMMAND
348 static void notify_command_browse_cb(GtkWidget* widget, gpointer data);
349 static void notify_create_command_page(PrefsPage*, GtkWindow*, gpointer);
350 static void notify_destroy_command_page(PrefsPage*);
351 static void notify_save_command(PrefsPage*);
352 static void notify_command_enable_set_sensitivity(GtkToggleButton*, gpointer);
353 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton*,
357 #ifdef NOTIFICATION_LCDPROC
358 static void notify_create_lcdproc_page(PrefsPage*, GtkWindow*, gpointer);
359 static void notify_destroy_lcdproc_page(PrefsPage*);
360 static void notify_save_lcdproc(PrefsPage*);
361 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton*, gpointer);
364 #ifdef NOTIFICATION_TRAYICON
365 static void notify_create_trayicon_page(PrefsPage*, GtkWindow*, gpointer);
366 static void notify_destroy_trayicon_page(PrefsPage*);
367 static void notify_save_trayicon(PrefsPage*);
368 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton*, gpointer);
369 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton*,
371 #ifdef HAVE_LIBNOTIFY
372 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton*,
377 #ifdef NOTIFICATION_INDICATOR
378 static void notify_create_indicator_page(PrefsPage*, GtkWindow*, gpointer);
379 static void notify_destroy_indicator_page(PrefsPage*);
380 static void notify_save_indicator(PrefsPage*);
381 static void notify_indicator_enable_set_sensitivity(GtkToggleButton*, gpointer);
382 #endif /* NOTIFICATION_INDICATOR */
384 #ifdef NOTIFICATION_HOTKEYS
385 static void notify_create_hotkeys_page(PrefsPage*, GtkWindow*, gpointer);
386 static void notify_destroy_hotkeys_page(PrefsPage*);
387 static void notify_save_hotkeys(PrefsPage*);
388 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton*, gpointer);
389 #endif /* NOTIFICATION_HOTKEYS */
392 static gint conv_color_to_int(GdkColor*);
394 void notify_gtk_init(void)
396 static gchar *path[3];
398 path[0] = _("Plugins");
399 path[1] = _("Notification");
402 notify_page.page.path = path;
403 notify_page.page.create_widget = notify_create_prefs_page;
404 notify_page.page.destroy_widget = notify_destroy_prefs_page;
405 notify_page.page.save_page = notify_save_prefs;
406 prefs_gtk_register_page((PrefsPage*) ¬ify_page);
408 #ifdef NOTIFICATION_HOTKEYS
410 static gchar *hotkeys_path[4];
412 hotkeys_path[0] = _("Plugins");
413 hotkeys_path[1] = _("Notification");
414 hotkeys_path[2] = _("Hotkeys");
415 hotkeys_path[3] = NULL;
417 hotkeys_page.page.path = hotkeys_path;
418 hotkeys_page.page.create_widget = notify_create_hotkeys_page;
419 hotkeys_page.page.destroy_widget = notify_destroy_hotkeys_page;
420 hotkeys_page.page.save_page = notify_save_hotkeys;
421 prefs_gtk_register_page((PrefsPage*) &hotkeys_page);
423 #endif /* NOTIFICATION_HOTKEYS */
426 #ifdef NOTIFICATION_BANNER
428 static gchar *banner_path[4];
430 banner_path[0] = _("Plugins");
431 banner_path[1] = _("Notification");
432 banner_path[2] = _("Banner");
433 banner_path[3] = NULL;
435 banner_page.page.path = banner_path;
436 banner_page.page.create_widget = notify_create_banner_page;
437 banner_page.page.destroy_widget = notify_destroy_banner_page;
438 banner_page.page.save_page = notify_save_banner;
439 prefs_gtk_register_page((PrefsPage*) &banner_page);
441 #endif /* NOTIFICATION_BANNER */
443 #ifdef NOTIFICATION_POPUP
445 static gchar *popup_path[4];
447 popup_path[0] = _("Plugins");
448 popup_path[1] = _("Notification");
449 popup_path[2] = _("Popup");
450 popup_path[3] = NULL;
452 popup_page.page.path = popup_path;
453 popup_page.page.create_widget = notify_create_popup_page;
454 popup_page.page.destroy_widget = notify_destroy_popup_page;
455 popup_page.page.save_page = notify_save_popup;
456 prefs_gtk_register_page((PrefsPage*) &popup_page);
458 #endif /* NOTIFICATION_POPUP */
460 #ifdef NOTIFICATION_COMMAND
462 static gchar *command_path[4];
464 command_path[0] = _("Plugins");
465 command_path[1] = _("Notification");
466 command_path[2] = _("Command");
467 command_path[3] = NULL;
469 command_page.page.path = command_path;
470 command_page.page.create_widget = notify_create_command_page;
471 command_page.page.destroy_widget = notify_destroy_command_page;
472 command_page.page.save_page = notify_save_command;
473 prefs_gtk_register_page((PrefsPage*) &command_page);
475 #endif /* NOTIFICATION_COMMAND */
477 #ifdef NOTIFICATION_LCDPROC
479 static gchar *lcdproc_path[4];
481 lcdproc_path[0] = _("Plugins");
482 lcdproc_path[1] = _("Notification");
483 lcdproc_path[2] = _("LCD");
484 lcdproc_path[3] = NULL;
486 lcdproc_page.page.path = lcdproc_path;
487 lcdproc_page.page.create_widget = notify_create_lcdproc_page;
488 lcdproc_page.page.destroy_widget = notify_destroy_lcdproc_page;
489 lcdproc_page.page.save_page = notify_save_lcdproc;
490 prefs_gtk_register_page((PrefsPage*) &lcdproc_page);
492 #endif /* NOTIFICATION_LCDPROC */
494 #ifdef NOTIFICATION_TRAYICON
496 static gchar *trayicon_path[4];
498 trayicon_path[0] = _("Plugins");
499 trayicon_path[1] = _("Notification");
500 trayicon_path[2] = _("SysTrayicon");
501 trayicon_path[3] = NULL;
503 trayicon_page.page.path = trayicon_path;
504 trayicon_page.page.create_widget = notify_create_trayicon_page;
505 trayicon_page.page.destroy_widget = notify_destroy_trayicon_page;
506 trayicon_page.page.save_page = notify_save_trayicon;
507 prefs_gtk_register_page((PrefsPage*) &trayicon_page);
509 #endif /* NOTIFICATION_TRAYICON */
511 #ifdef NOTIFICATION_INDICATOR
513 static gchar *indicator_path[4];
515 indicator_path[0] = _("Plugins");
516 indicator_path[1] = _("Notification");
517 indicator_path[2] = _("Indicator");
518 indicator_path[3] = NULL;
520 indicator_page.page.path = indicator_path;
521 indicator_page.page.create_widget = notify_create_indicator_page;
522 indicator_page.page.destroy_widget = notify_destroy_indicator_page;
523 indicator_page.page.save_page = notify_save_indicator;
524 prefs_gtk_register_page((PrefsPage*) &indicator_page);
526 #endif /* NOTIFICATION_INDICATOR */
529 void notify_gtk_done(void)
531 if (claws_is_exiting())
533 prefs_gtk_unregister_page((PrefsPage*) ¬ify_page);
534 #ifdef NOTIFICATION_BANNER
535 prefs_gtk_unregister_page((PrefsPage*) &banner_page);
537 #ifdef NOTIFICATION_POPUP
538 prefs_gtk_unregister_page((PrefsPage*) &popup_page);
540 #ifdef NOTIFICATION_COMMAND
541 prefs_gtk_unregister_page((PrefsPage*) &command_page);
543 #ifdef NOTIFICATION_LCDPROC
544 prefs_gtk_unregister_page((PrefsPage*) &lcdproc_page);
546 #ifdef NOTIFICATION_TRAYICON
547 prefs_gtk_unregister_page((PrefsPage*) &trayicon_page);
549 #ifdef NOTIFICATION_INDICATOR
550 prefs_gtk_unregister_page((PrefsPage*) &indicator_page);
552 #ifdef NOTIFICATION_HOTKEYS
553 prefs_gtk_unregister_page((PrefsPage*) &hotkeys_page);
557 void notify_save_config(void)
562 debug_print("Saving Notification plugin configuration...\n");
564 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
565 pfile = prefs_write_open(rcpath);
567 if (!pfile || (prefs_set_block_label(pfile, "NotificationPlugin") < 0))
570 if (prefs_write_param(notify_param, pfile->fp) < 0) {
571 debug_print("failed!\n");
572 g_warning(_("\nNotification Plugin: Failed to write plugin configuration "
574 prefs_file_close_revert(pfile);
577 if (fprintf(pfile->fp, "\n") < 0) {
578 FILE_OP_ERROR(rcpath, "fprintf");
579 prefs_file_close_revert(pfile);
582 prefs_file_close(pfile);
583 debug_print("done.\n");
586 static void notify_create_prefs_page(PrefsPage *page, GtkWindow *window,
596 pvbox = gtk_vbox_new(FALSE, 0);
599 PACK_FRAME (pvbox, frame, _("Include folder types"))
600 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
603 vbox = gtk_vbox_new(FALSE, 4);
604 gtk_container_add(GTK_CONTAINER(frame), vbox);
605 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
607 /* Include mail folders */
608 checkbox = gtk_check_button_new_with_label(_("Mail folders"));
609 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
610 notify_config.include_mail);
611 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
612 gtk_widget_show(checkbox);
613 notify_page.include_mail = checkbox;
615 /* Include news folders */
616 checkbox = gtk_check_button_new_with_label(_("News folders"));
617 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
618 notify_config.include_news);
619 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
620 gtk_widget_show(checkbox);
621 notify_page.include_news = checkbox;
623 /* Include RSSyl folders */
624 checkbox = gtk_check_button_new_with_label(_("RSSyl folders"));
625 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
626 notify_config.include_rss);
627 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
628 gtk_widget_show(checkbox);
629 notify_page.include_rss = checkbox;
631 /* Include calendar folders */
632 checkbox = gtk_check_button_new_with_label(_("vCalendar folders"));
633 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
634 notify_config.include_calendar);
635 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
636 gtk_widget_show(checkbox);
637 notify_page.include_calendar = checkbox;
640 label = gtk_label_new(_("These settings override folder-specific "
642 gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
643 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
644 gtk_widget_show(label);
646 /* done with the frame */
647 gtk_widget_show(frame);
648 gtk_widget_show(vbox);
651 PACK_FRAME (pvbox, frame, _("Global notification settings"));
652 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
655 vbox = gtk_vbox_new(FALSE, 4);
656 gtk_container_add(GTK_CONTAINER(frame), vbox);
657 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
659 /* urgency hint new */
660 checkbox = gtk_check_button_new_with_label(_("Set window manager "
661 "urgency hint when new messages exist"));
662 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
663 notify_config.urgency_hint_new);
664 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
665 gtk_widget_show(checkbox);
666 notify_page.urgency_hint_new = checkbox;
668 /* urgency hint new */
669 checkbox = gtk_check_button_new_with_label(_("Set window manager "
670 "urgency hint when unread messages exist"));
671 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
672 notify_config.urgency_hint_unread);
673 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
674 gtk_widget_show(checkbox);
675 notify_page.urgency_hint_unread = checkbox;
677 #ifdef HAVE_LIBCANBERRA_GTK
679 checkbox = gtk_check_button_new_with_label(_("Use sound theme"));
680 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
681 notify_config.canberra_play_sounds);
682 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
683 gtk_widget_show(checkbox);
684 notify_page.canberra_play_sounds = checkbox;
687 /* done with the frame */
688 gtk_widget_show(frame);
689 gtk_widget_show(vbox);
691 /* done with the page */
692 gtk_widget_show(pvbox);
693 page->widget = pvbox;
696 static void notify_destroy_prefs_page(PrefsPage *page)
700 static void notify_save_prefs(PrefsPage *page)
702 notify_config.include_mail =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_mail));
703 notify_config.include_news =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_news));
704 notify_config.include_rss =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_rss));
705 notify_config.include_calendar
706 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_calendar));
707 notify_config.urgency_hint_new = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_new));
708 notify_config.urgency_hint_unread = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_unread));
709 #ifdef HAVE_LIBCANBERRA_GTK
710 notify_config.canberra_play_sounds = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.canberra_play_sounds));
713 notification_core_global_includes_changed();
716 #ifdef NOTIFICATION_BANNER
717 static void notify_banner_slider_add_cb(GtkWidget *widget, gpointer data)
719 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
720 gtk_range_set_value(slider, gtk_range_get_value(slider) - 1.0);
723 static void notify_banner_slider_remove_cb(GtkWidget *widget, gpointer data)
725 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
726 gtk_range_set_value(slider, gtk_range_get_value(slider) + 1.0);
729 static void notify_create_banner_page(PrefsPage *page, GtkWindow *window,
732 GtkRequisition requisition;
736 GtkWidget *chbox, *cvbox, *cframe;
743 GtkWidget *color_sel;
747 pvbox = gtk_vbox_new(FALSE, 20);
748 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
750 /* Always / Never / Only when non-empty */
751 hbox = gtk_hbox_new(FALSE, 20);
752 gtk_box_pack_start(GTK_BOX(pvbox), hbox, FALSE, FALSE, 0);
753 label = gtk_label_new(_("Show banner"));
754 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
755 gtk_widget_show(label);
756 combo = gtk_combo_box_new_text();
757 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NEVER,
759 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_ALWAYS,
761 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NONEMPTY,
762 _("Only when not empty"));
763 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), notify_config.banner_show);
764 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
765 g_signal_connect(G_OBJECT(combo), "changed",
766 G_CALLBACK(notify_banner_enable_set_sensitivity), NULL);
767 gtk_widget_show(combo);
768 gtk_widget_show(hbox);
769 banner_page.banner_show = combo;
771 /* Container vbox for greying out everything */
772 vbox = gtk_vbox_new(FALSE, 10);
773 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
774 gtk_widget_show(vbox);
775 banner_page.banner_cont_enable = vbox;
778 hbox = gtk_hbox_new(FALSE, 10);
779 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
781 label = gtk_label_new(_("Banner speed"));
782 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
783 gtk_widget_show(label);
785 slider = gtk_hscale_new_with_range(10., 70., 10.);
786 gtk_scale_set_digits(GTK_SCALE(slider), 0);
787 gtk_widget_size_request(combo, &requisition);
788 gtk_widget_set_size_request(slider, requisition.width, -1);
789 gtk_range_set_increments(GTK_RANGE(slider), 10., 10.);
790 gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
791 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
792 gtk_range_set_value(GTK_RANGE(slider), notify_config.banner_speed);
794 button = gtk_button_new();
795 gtk_button_set_image(GTK_BUTTON(button),
796 gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
797 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
798 g_signal_connect(G_OBJECT(button), "clicked",
799 G_CALLBACK(notify_banner_slider_remove_cb), slider);
800 gtk_widget_show(button);
802 gtk_box_pack_start(GTK_BOX(hbox), slider, TRUE, TRUE, 0);
803 gtk_widget_show(slider);
805 button = gtk_button_new();
806 gtk_button_set_image(GTK_BUTTON(button),
807 gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
808 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
809 g_signal_connect(G_OBJECT(button), "clicked",
810 G_CALLBACK(notify_banner_slider_add_cb), slider);
811 gtk_widget_show(button);
813 gtk_widget_show(hbox);
814 banner_page.banner_speed = slider;
816 /* Maximum number of messages in banner */
817 hbox = gtk_hbox_new(FALSE, 10);
818 label = gtk_label_new(_("Maximum number of messages"));
819 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
820 gtk_widget_show(label);
821 spinner = gtk_spin_button_new_with_range(0., 1000., 1.);
822 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
823 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), notify_config.banner_max_msgs);
824 CLAWS_SET_TIP (spinner, _("Limit the number of messages shown, use 0 for unlimited"));
825 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
826 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
827 gtk_widget_show(spinner);
828 gtk_widget_show(hbox);
829 banner_page.banner_max_msgs = spinner;
832 hbox = gtk_hbox_new(FALSE, 10);
833 label = gtk_label_new(_("Banner width"));
834 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
835 gtk_widget_show(label);
836 spinner = gtk_spin_button_new_with_range(0.,5000., 50);
837 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner),0);
838 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),notify_config.banner_width);
839 CLAWS_SET_TIP (spinner, _("Limit the size of banner, use 0 for screen width"));
840 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
841 label = gtk_label_new(_("pixel(s)"));
842 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
843 gtk_widget_show(label);
844 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
845 gtk_widget_show(spinner);
846 gtk_widget_show(hbox);
847 banner_page.banner_width = spinner;
850 checkbox = gtk_check_button_new_with_label(_("Include unread mails in banner"));
851 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
852 notify_config.banner_include_unread);
853 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
854 gtk_widget_show(checkbox);
855 banner_page.banner_include_unread = checkbox;
857 /* Check button sticky */
858 checkbox = gtk_check_button_new_with_label(_("Make banner sticky"));
859 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
860 notify_config.banner_sticky);
861 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
862 gtk_widget_show(checkbox);
863 banner_page.banner_sticky = checkbox;
865 /* Check box for enabling folder specific selection */
866 hbox = gtk_hbox_new(FALSE, 10);
867 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
868 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
869 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
870 notify_config.banner_folder_specific);
871 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
872 g_signal_connect(G_OBJECT(checkbox), "toggled",
873 G_CALLBACK(notify_banner_folder_specific_set_sensitivity),
875 gtk_widget_show(checkbox);
876 banner_page.banner_folder_specific = checkbox;
877 button = gtk_button_new_with_label(_("Select folders..."));
878 g_signal_connect(G_OBJECT(button), "clicked",
879 G_CALLBACK(notification_foldercheck_sel_folders_cb),
880 BANNER_SPECIFIC_FOLDER_ID_STR);
881 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
882 banner_page.banner_cont_folder_specific = button;
883 gtk_widget_show(button);
884 gtk_widget_show(hbox);
886 /* Check box for enabling custom colors */
887 cvbox = gtk_vbox_new(FALSE, 10);
888 gtk_widget_show(cvbox);
889 PACK_FRAME (vbox, cframe, _("Banner colors"))
890 gtk_container_set_border_width(GTK_CONTAINER(cvbox), 5);
891 gtk_container_add(GTK_CONTAINER(cframe), cvbox);
893 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
894 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
895 notify_config.banner_enable_colors);
896 gtk_box_pack_start(GTK_BOX(cvbox), checkbox, FALSE, FALSE, 0);
897 g_signal_connect(G_OBJECT(checkbox), "toggled",
898 G_CALLBACK(notify_banner_color_sel_set_sensitivity), NULL);
899 gtk_widget_show(checkbox);
900 banner_page.banner_enable_colors = checkbox;
902 /* Color selection dialogs for foreground and background color */
904 chbox = gtk_hbox_new(FALSE, 10);
905 gtk_box_pack_start(GTK_BOX(cvbox), chbox, FALSE, FALSE, 0);
906 gtk_widget_show(chbox);
908 label = gtk_label_new(_("Foreground"));
909 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
910 gtk_widget_show(label);
911 color_sel = gtk_color_button_new();
912 gtkut_convert_int_to_gdk_color(notify_config.banner_color_fg,&fg);
913 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
914 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
915 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
916 gtk_widget_show(color_sel);
917 banner_page.banner_color_fg = color_sel;
919 label = gtk_label_new(_("Background"));
920 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
921 gtk_widget_show(label);
922 color_sel = gtk_color_button_new();
923 gtkut_convert_int_to_gdk_color(notify_config.banner_color_bg,&bg);
924 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
925 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel), _("Background color"));
926 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
927 gtk_widget_show(color_sel);
928 banner_page.banner_color_bg = color_sel;
929 banner_page.banner_cont_color_sel = chbox;
931 notify_banner_color_sel_set_sensitivity
932 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors), NULL);
933 notify_banner_folder_specific_set_sensitivity
934 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific), NULL);
935 notify_banner_enable_set_sensitivity(GTK_COMBO_BOX(combo), NULL);
936 gtk_widget_show(pvbox);
937 banner_page.page.widget = pvbox;
940 static void notify_destroy_banner_page(PrefsPage *page)
944 static void notify_save_banner(PrefsPage *page)
949 notify_config.banner_show =
950 gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
951 notify_config.banner_max_msgs =
952 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_max_msgs));
953 notify_config.banner_width =
954 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_width));
955 notify_config.banner_include_unread =
956 gtk_toggle_button_get_active
957 (GTK_TOGGLE_BUTTON(banner_page.banner_include_unread));
958 range_val= gtk_range_get_value(GTK_RANGE(banner_page.banner_speed));
959 notify_config.banner_speed = (gint)ceil(range_val);
961 notify_config.banner_sticky =
962 gtk_toggle_button_get_active
963 (GTK_TOGGLE_BUTTON(banner_page.banner_sticky));
965 notify_config.banner_folder_specific =
966 gtk_toggle_button_get_active
967 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
969 notify_config.banner_enable_colors =
970 gtk_toggle_button_get_active
971 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
973 /* Color dialogs are a bit more complicated */
974 gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_fg),
976 notify_config.banner_color_fg = conv_color_to_int(&color);
977 gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_bg),
979 notify_config.banner_color_bg = conv_color_to_int(&color);
981 notification_banner_destroy();
982 notification_update_banner();
985 static void notify_banner_enable_set_sensitivity(GtkComboBox *combo,
988 NotifyBannerShow show;
990 show = gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
991 gtk_widget_set_sensitive(banner_page.banner_cont_enable,
992 (show == NOTIFY_BANNER_SHOW_NEVER) ? FALSE : TRUE);
995 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton *button,
999 active = gtk_toggle_button_get_active
1000 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
1001 gtk_widget_set_sensitive(banner_page.banner_cont_color_sel, active);
1004 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton *bu,
1008 active = gtk_toggle_button_get_active
1009 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
1010 gtk_widget_set_sensitive(banner_page.banner_cont_folder_specific, active);
1012 #endif /* NOTIFICATION_BANNER */
1014 #ifdef NOTIFICATION_POPUP
1015 static void notify_create_popup_page(PrefsPage *page, GtkWindow *window,
1021 GtkWidget *checkbox;
1026 #ifndef HAVE_LIBNOTIFY
1030 GtkWidget *color_sel;
1031 #endif /* !HAVE_LIBNOTIFY */
1033 pvbox = gtk_vbox_new(FALSE, 20);
1034 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1037 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1038 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1039 notify_config.popup_show);
1040 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1041 g_signal_connect(G_OBJECT(checkbox), "toggled",
1042 G_CALLBACK(notify_popup_enable_set_sensitivity), NULL);
1043 gtk_widget_show(checkbox);
1044 popup_page.popup_show = checkbox;
1046 /* Container vbox for greying out everything */
1047 vbox = gtk_vbox_new(FALSE, 10);
1048 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1049 gtk_widget_show(vbox);
1050 popup_page.popup_cont_enable = vbox;
1053 hbox = gtk_hbox_new(FALSE, 10);
1054 label = gtk_label_new(_("Popup timeout"));
1055 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1056 gtk_widget_show(label);
1057 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1058 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1059 timeout = notify_config.popup_timeout/1000.;
1060 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1061 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1062 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1063 gtk_widget_show(spinner);
1064 label = gtk_label_new(_("second(s)"));
1065 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1066 gtk_widget_show(label);
1067 gtk_widget_show(hbox);
1068 popup_page.popup_timeout = spinner;
1070 /* Check box for enabling folder specific selection */
1071 hbox = gtk_hbox_new(FALSE, 10);
1072 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1073 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1074 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1075 notify_config.popup_folder_specific);
1076 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1077 g_signal_connect(G_OBJECT(checkbox), "toggled",
1078 G_CALLBACK(notify_popup_folder_specific_set_sensitivity),
1080 gtk_widget_show(checkbox);
1081 popup_page.popup_folder_specific = checkbox;
1082 button = gtk_button_new_with_label(_("Select folders..."));
1083 g_signal_connect(G_OBJECT(button), "clicked",
1084 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1085 POPUP_SPECIFIC_FOLDER_ID_STR);
1086 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1087 popup_page.popup_cont_folder_specific = button;
1088 gtk_widget_show(button);
1089 gtk_widget_show(hbox);
1091 #ifndef HAVE_LIBNOTIFY
1092 /* Sticky check button */
1093 checkbox = gtk_check_button_new_with_label(_("Make popup sticky"));
1094 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1095 notify_config.popup_sticky);
1096 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1097 gtk_widget_show(checkbox);
1098 popup_page.popup_sticky = checkbox;
1100 /* Button to set size and position of popup window */
1101 hbox = gtk_hbox_new(FALSE, 10);
1102 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1103 button = gtk_button_new_with_label(_("Set popup window width and position"));
1104 g_signal_connect(G_OBJECT(button), "clicked",
1105 G_CALLBACK(notify_popup_set_cb), NULL);
1106 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1107 gtk_widget_show(button);
1108 label = gtk_label_new(_("(the window manager is free to ignore this)"));
1109 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1110 gtk_widget_show(label);
1111 gtk_widget_show(hbox);
1113 /* Check box for enabling custom colors */
1114 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
1115 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1116 notify_config.popup_enable_colors);
1117 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1118 g_signal_connect(G_OBJECT(checkbox), "toggled",
1119 G_CALLBACK(notify_popup_color_sel_set_sensitivity), NULL);
1120 gtk_widget_show(checkbox);
1121 popup_page.popup_enable_colors = checkbox;
1123 /* Color selection dialogs for foreground and background color */
1124 table = gtk_table_new(2,2,FALSE);
1125 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
1127 label = gtk_label_new(_("Foreground"));
1128 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
1129 gtk_widget_show(label);
1130 color_sel = gtk_color_button_new();
1131 gtkut_convert_int_to_gdk_color(notify_config.popup_color_fg,&fg);
1132 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
1133 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
1134 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,0,1);
1135 gtk_widget_show(color_sel);
1136 popup_page.popup_color_fg = color_sel;
1138 label = gtk_label_new(_("Background"));
1139 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
1140 gtk_widget_show(label);
1141 color_sel = gtk_color_button_new();
1142 gtkut_convert_int_to_gdk_color(notify_config.popup_color_bg,&bg);
1143 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
1144 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Background color"));
1145 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,1,2);
1146 gtk_widget_show(color_sel);
1147 gtk_widget_show(table);
1148 popup_page.popup_color_bg = color_sel;
1149 popup_page.popup_cont_color_sel = table;
1151 notify_popup_color_sel_set_sensitivity
1152 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors), NULL);
1153 #else /* HAVE_LIBNOTIFY */
1154 hbox = gtk_hbox_new(FALSE, 10);
1155 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1156 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1157 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1158 notify_config.popup_display_folder_name);
1159 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1160 gtk_widget_show(checkbox);
1161 gtk_widget_show(hbox);
1162 popup_page.popup_display_folder_name = checkbox;
1163 #endif /* HAVE_LIBNOTIFY */
1165 notify_popup_enable_set_sensitivity
1166 (GTK_TOGGLE_BUTTON(popup_page.popup_show), NULL);
1167 notify_popup_folder_specific_set_sensitivity
1168 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific), NULL);
1169 gtk_widget_show(pvbox);
1170 popup_page.page.widget = pvbox;
1173 static void notify_destroy_popup_page(PrefsPage *page)
1177 static void notify_save_popup(PrefsPage *page)
1181 #ifndef HAVE_LIBNOTIFY
1183 #endif /* !HAVE_LIBNOTIFY */
1185 notify_config.popup_show =
1186 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_show));
1188 gtk_spin_button_get_value(GTK_SPIN_BUTTON(popup_page.popup_timeout));
1189 notify_config.popup_timeout = (gint)floor(timeout*1000+0.5);
1190 notify_config.popup_folder_specific =
1191 gtk_toggle_button_get_active
1192 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1194 #ifndef HAVE_LIBNOTIFY
1195 notify_config.popup_sticky =
1196 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_sticky));
1197 notify_config.popup_enable_colors =
1198 gtk_toggle_button_get_active
1199 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1201 /* Color dialogs are a bit more complicated */
1202 gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_fg),
1204 notify_config.popup_color_fg = conv_color_to_int(&color);
1205 gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_bg),
1207 notify_config.popup_color_bg = conv_color_to_int(&color);
1208 #else /* HAVE_LIBNOTIFY */
1209 notify_config.popup_display_folder_name =
1210 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_display_folder_name));
1211 #endif /* HAVE_LIBNOTIFY */
1214 #ifndef HAVE_LIBNOTIFY
1215 static void notify_popup_set_cb(GtkWidget *widget, gpointer data)
1220 win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "notification_prefs");
1221 gtk_window_set_title(GTK_WINDOW(win), _("Sample popup window"));
1222 gtk_window_set_modal(GTK_WINDOW(win), TRUE);
1223 gtk_window_set_keep_above(GTK_WINDOW(win), TRUE);
1224 gtk_window_set_resizable(GTK_WINDOW(win), TRUE);
1225 gtk_container_set_border_width(GTK_CONTAINER(win), 5);
1227 button = gtk_button_new_with_label(_("Done"));
1228 g_signal_connect(G_OBJECT(button), "clicked",
1229 G_CALLBACK(notify_popup_set_done_cb), win);
1230 gtk_container_add(GTK_CONTAINER(win), button);
1232 gtk_widget_show_all(win);
1235 static void notify_popup_set_done_cb(GtkWidget *widget, gpointer data)
1237 GtkWidget *win = data;
1240 gtk_window_get_position(GTK_WINDOW(win),
1241 &(notify_config.popup_root_x),
1242 &(notify_config.popup_root_y));
1243 gtk_window_get_size(GTK_WINDOW(win),
1244 &(notify_config.popup_width), &dummy);
1245 gtk_widget_destroy(win);
1248 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton *button,
1252 active = gtk_toggle_button_get_active
1253 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1254 gtk_widget_set_sensitive(popup_page.popup_cont_color_sel, active);
1256 #endif /* !HAVE_LIBNOTIFY */
1258 static void notify_popup_enable_set_sensitivity(GtkToggleButton *button,
1262 active = gtk_toggle_button_get_active
1263 (GTK_TOGGLE_BUTTON(popup_page.popup_show));
1264 gtk_widget_set_sensitive(popup_page.popup_cont_enable, active);
1267 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton *bu,
1271 active = gtk_toggle_button_get_active
1272 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1273 gtk_widget_set_sensitive(popup_page.popup_cont_folder_specific, active);
1276 #endif /* NOTIFICATION_POPUP */
1278 #ifdef NOTIFICATION_COMMAND
1279 static void notify_command_browse_cb(GtkWidget* widget, gpointer data)
1282 gchar *utf8_filename;
1283 GtkEntry *dest = GTK_ENTRY(data);
1285 filename = filesel_select_file_open(_("Select command"), NULL);
1286 if (!filename) return;
1288 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1289 if (!utf8_filename) {
1290 g_warning("notify_command_browse_cb(): failed to convert character set.");
1291 utf8_filename = g_strdup(filename);
1293 gtk_entry_set_text(GTK_ENTRY(dest), utf8_filename);
1294 g_free(utf8_filename);
1297 static void notify_create_command_page(PrefsPage *page, GtkWindow *window,
1302 GtkWidget *checkbox;
1307 GtkWidget *button, *buttonb;
1310 pvbox = gtk_vbox_new(FALSE, 20);
1311 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1313 /* Enable command */
1314 checkbox = gtk_check_button_new_with_label(_("Enable command"));
1315 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1316 notify_config.command_enabled);
1317 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1318 g_signal_connect(G_OBJECT(checkbox), "toggled",
1319 G_CALLBACK(notify_command_enable_set_sensitivity), NULL);
1320 gtk_widget_show(checkbox);
1321 command_page.command_enabled = checkbox;
1323 /* Container vbox for greying out everything */
1324 vbox = gtk_vbox_new(FALSE, 10);
1325 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1326 gtk_widget_show(vbox);
1327 command_page.command_cont_enable = vbox;
1329 /* entry field for command to execute */
1330 hbox = gtk_hbox_new(FALSE, 10);
1331 label = gtk_label_new(_("Command to execute"));
1332 gtk_widget_show(label);
1333 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1334 entry = gtk_entry_new();
1335 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.command_line);
1336 gtk_widget_show(entry);
1337 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1338 buttonb = gtkut_get_browse_file_btn(_("Bro_wse"));
1339 gtk_box_pack_start(GTK_BOX(hbox), buttonb, FALSE, FALSE, 0);
1340 g_signal_connect(G_OBJECT(buttonb), "clicked",
1341 G_CALLBACK(notify_command_browse_cb), entry);
1342 gtk_widget_show(buttonb);
1343 gtk_widget_show(hbox);
1344 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1345 command_page.command_line = entry;
1347 /* Spin button for command timeout */
1348 hbox = gtk_hbox_new(FALSE, 10);
1349 label = gtk_label_new(_("Block command after execution for"));
1350 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1351 gtk_widget_show(label);
1352 spinner = gtk_spin_button_new_with_range(0., 600., 1.);
1353 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1354 timeout = notify_config.command_timeout/1000.;
1355 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1356 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1357 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1358 gtk_widget_show(spinner);
1359 label = gtk_label_new(_("second(s)"));
1360 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1361 gtk_widget_show(label);
1362 gtk_widget_show(hbox);
1363 command_page.command_timeout = spinner;
1365 /* Check box for enabling folder specific selection */
1366 hbox = gtk_hbox_new(FALSE, 10);
1367 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1368 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1369 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1370 notify_config.command_folder_specific);
1371 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1372 g_signal_connect(G_OBJECT(checkbox), "toggled",
1373 G_CALLBACK(notify_command_folder_specific_set_sensitivity),
1375 gtk_widget_show(checkbox);
1376 command_page.command_folder_specific = checkbox;
1377 button = gtk_button_new_with_label(_("Select folders..."));
1378 g_signal_connect(G_OBJECT(button), "clicked",
1379 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1380 COMMAND_SPECIFIC_FOLDER_ID_STR);
1381 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1382 command_page.command_cont_folder_specific = button;
1383 gtk_widget_show(button);
1384 gtk_widget_show(hbox);
1386 notify_command_enable_set_sensitivity
1387 (GTK_TOGGLE_BUTTON(command_page.command_enabled), NULL);
1388 notify_command_folder_specific_set_sensitivity
1389 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific), NULL);
1390 gtk_widget_show(pvbox);
1391 command_page.page.widget = pvbox;
1394 static void notify_destroy_command_page(PrefsPage *page)
1398 static void notify_save_command(PrefsPage *page)
1401 const gchar *tmp_str;
1403 notify_config.command_enabled =
1404 gtk_toggle_button_get_active
1405 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1408 gtk_spin_button_get_value(GTK_SPIN_BUTTON(command_page.command_timeout));
1409 notify_config.command_timeout = (gint)floor(timeout*1000+0.5);
1410 notify_config.command_folder_specific =
1411 gtk_toggle_button_get_active
1412 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1414 tmp_str = gtk_entry_get_text(GTK_ENTRY(command_page.command_line));
1415 if(notify_config.command_line)
1416 g_free(notify_config.command_line);
1417 notify_config.command_line = g_strdup(tmp_str);
1420 static void notify_command_enable_set_sensitivity(GtkToggleButton *button,
1424 active = gtk_toggle_button_get_active
1425 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1426 gtk_widget_set_sensitive(command_page.command_cont_enable, active);
1429 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton *bu,
1433 active = gtk_toggle_button_get_active
1434 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1435 gtk_widget_set_sensitive(command_page.command_cont_folder_specific, active);
1438 #endif /* NOTIFICATION_COMMAND */
1440 #ifdef NOTIFICATION_LCDPROC
1441 static void notify_create_lcdproc_page(PrefsPage *page, GtkWindow *window,
1449 GtkWidget *checkbox;
1452 pvbox = gtk_vbox_new(FALSE, 20);
1453 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1455 /* Enable lcdproc */
1456 checkbox = gtk_check_button_new_with_label(_("Enable LCD"));
1457 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1458 notify_config.lcdproc_enabled);
1459 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1460 g_signal_connect(G_OBJECT(checkbox), "toggled",
1461 G_CALLBACK(notify_lcdproc_enable_set_sensitivity), NULL);
1462 gtk_widget_show(checkbox);
1463 lcdproc_page.lcdproc_enabled = checkbox;
1465 /* Container vbox for greying out everything */
1466 vbox = gtk_vbox_new(FALSE, 10);
1467 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1468 gtk_widget_show(vbox);
1469 lcdproc_page.lcdproc_cont_enable = vbox;
1471 /* Hostname and port information */
1472 hbox = gtk_hbox_new(FALSE, 10);
1473 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1474 gtk_widget_show(hbox);
1475 label = gtk_label_new(_("Hostname:Port of LCDd server"));
1476 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1477 entry = gtk_entry_new();
1478 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.lcdproc_hostname);
1479 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1480 gtk_widget_show(entry);
1481 gtk_widget_show(label);
1482 label = gtk_label_new(":");
1483 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1484 gtk_widget_show(label);
1485 spinner = gtk_spin_button_new_with_range(1., 65535., 1.);
1486 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1487 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),
1488 notify_config.lcdproc_port);
1489 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1490 gtk_widget_show(spinner);
1491 lcdproc_page.lcdproc_hostname = entry;
1492 lcdproc_page.lcdproc_port = spinner;
1494 notify_lcdproc_enable_set_sensitivity
1495 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled), NULL);
1496 gtk_widget_show(pvbox);
1497 lcdproc_page.page.widget = pvbox;
1500 static void notify_destroy_lcdproc_page(PrefsPage *page)
1504 static void notify_save_lcdproc(PrefsPage *page)
1506 notify_config.lcdproc_enabled =
1507 gtk_toggle_button_get_active
1508 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1510 if(notify_config.lcdproc_hostname)
1511 g_free(notify_config.lcdproc_hostname);
1512 notify_config.lcdproc_hostname =
1513 g_strdup(gtk_entry_get_text(GTK_ENTRY(lcdproc_page.lcdproc_hostname)));
1515 notify_config.lcdproc_port =
1516 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lcdproc_page.lcdproc_port));
1518 if(notify_config.lcdproc_enabled)
1519 notification_lcdproc_connect();
1521 notification_lcdproc_disconnect();
1524 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton *button,
1528 active = gtk_toggle_button_get_active
1529 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1530 gtk_widget_set_sensitive(lcdproc_page.lcdproc_cont_enable, active);
1532 #endif /* NOTIFICATION_LCDPROC */
1534 #ifdef NOTIFICATION_TRAYICON
1535 static void notify_create_trayicon_page(PrefsPage *page, GtkWindow *window,
1540 GtkWidget *checkbox;
1544 #if defined(HAVE_LIBNOTIFY)
1550 #ifdef HAVE_LIBNOTIFY
1556 pvbox = gtk_vbox_new(FALSE, 20);
1557 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1559 /* Enable trayicon */
1560 checkbox = gtk_check_button_new_with_label(_("Enable Trayicon"));
1561 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1562 notify_config.trayicon_enabled);
1563 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1564 g_signal_connect(G_OBJECT(checkbox), "toggled",
1565 G_CALLBACK(notify_trayicon_enable_set_sensitivity), NULL);
1566 gtk_widget_show(checkbox);
1567 trayicon_page.trayicon_enabled = checkbox;
1569 /* Container vbox for greying out everything */
1570 vbox = gtk_vbox_new(FALSE, 10);
1571 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1572 gtk_widget_show(vbox);
1573 trayicon_page.trayicon_cont_enable = vbox;
1575 /* Hide at startup */
1576 checkbox = gtk_check_button_new_with_label(_("Hide at start-up"));
1577 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1578 notify_config.trayicon_hide_at_startup);
1579 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1580 gtk_widget_show(checkbox);
1581 trayicon_page.trayicon_hide_at_startup = checkbox;
1584 checkbox = gtk_check_button_new_with_label(_("Close to tray"));
1585 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1586 notify_config.trayicon_close_to_tray);
1587 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1588 gtk_widget_show(checkbox);
1589 trayicon_page.trayicon_close_to_tray = checkbox;
1591 /* Hide when iconified */
1592 checkbox = gtk_check_button_new_with_label(_("Hide when iconified"));
1593 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1594 notify_config.trayicon_hide_when_iconified);
1595 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1596 gtk_widget_show(checkbox);
1597 trayicon_page.trayicon_hide_when_iconified = checkbox;
1599 /* folder specific */
1600 hbox = gtk_hbox_new(FALSE, 10);
1601 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1602 gtk_widget_show(hbox);
1603 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1604 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1605 notify_config.trayicon_folder_specific);
1606 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1607 g_signal_connect(G_OBJECT(checkbox), "toggled",
1608 G_CALLBACK(notify_trayicon_folder_specific_set_sensitivity),
1610 gtk_widget_show(checkbox);
1611 trayicon_page.trayicon_folder_specific = checkbox;
1612 button = gtk_button_new_with_label(_("Select folders..."));
1613 g_signal_connect(G_OBJECT(button), "clicked",
1614 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1615 TRAYICON_SPECIFIC_FOLDER_ID_STR);
1616 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1617 trayicon_page.trayicon_cont_folder_specific = button;
1618 gtk_widget_show(button);
1620 #ifdef HAVE_LIBNOTIFY
1621 /* Frame for trayicon popup stuff */
1623 /* TRANSLATORS: "Toaster" does not refer to the kitchen appliance.
1624 A toast is a small passive (non-focus-stealing)
1625 notification bubble. If your language does not have a word
1626 for that, go for something along the lines of "passive popup"
1628 http://en.wikipedia.org/wiki/Toast_(computing) */
1629 PACK_FRAME (vbox, frame, _("Passive toaster popup"))
1631 /* vbox for frame */
1632 svbox = gtk_vbox_new(FALSE, 10);
1633 gtk_container_set_border_width(GTK_CONTAINER(svbox), 5);
1634 gtk_container_add(GTK_CONTAINER(frame), svbox);
1635 gtk_widget_show(svbox);
1637 /* Enable popup for the tray icon */
1638 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1639 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1640 notify_config.trayicon_popup_enabled);
1641 g_signal_connect(G_OBJECT(checkbox), "toggled",
1642 G_CALLBACK(notify_trayicon_popup_enable_set_sensitivity),
1644 gtk_box_pack_start(GTK_BOX(svbox), checkbox, FALSE, FALSE, 0);
1645 gtk_widget_show(checkbox);
1646 trayicon_page.trayicon_popup_enabled = checkbox;
1648 /* vbox for trayicon popup stuff enabled/disabled container */
1649 ssvbox = gtk_vbox_new(FALSE, 10);
1650 gtk_box_pack_start(GTK_BOX(svbox), ssvbox, FALSE, FALSE, 0);
1651 gtk_widget_show(ssvbox);
1652 trayicon_page.trayicon_popup_cont_enable = ssvbox;
1655 hbox = gtk_hbox_new(FALSE, 10);
1656 label = gtk_label_new(_("Popup timeout"));
1657 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1658 gtk_widget_show(label);
1659 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1660 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1661 timeout = notify_config.trayicon_popup_timeout/1000.;
1662 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1663 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1664 gtk_box_pack_start(GTK_BOX(ssvbox), hbox, FALSE, FALSE, 0);
1665 label = gtk_label_new(_("second(s)"));
1666 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1668 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1669 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1670 notify_config.trayicon_display_folder_name);
1671 gtk_box_pack_start(GTK_BOX(ssvbox), checkbox, FALSE, FALSE, 0);
1672 trayicon_page.trayicon_display_folder_name = checkbox;
1673 gtk_widget_show(checkbox);
1675 gtk_widget_show(spinner);
1676 gtk_widget_show(label);
1677 gtk_widget_show(hbox);
1678 trayicon_page.trayicon_popup_timeout = spinner;
1682 notify_trayicon_enable_set_sensitivity
1683 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled), NULL);
1685 #ifdef HAVE_LIBNOTIFY
1686 notify_trayicon_popup_enable_set_sensitivity
1687 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled), NULL);
1690 notify_trayicon_folder_specific_set_sensitivity
1691 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific), NULL);
1693 gtk_widget_show(pvbox);
1694 trayicon_page.page.widget = pvbox;
1697 static void notify_destroy_trayicon_page(PrefsPage *page)
1701 static void notify_save_trayicon(PrefsPage *page)
1703 #ifdef HAVE_LIBNOTIFY
1707 notify_config.trayicon_enabled =
1708 gtk_toggle_button_get_active
1709 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1711 notify_config.trayicon_hide_at_startup =
1712 gtk_toggle_button_get_active
1713 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_at_startup));
1715 notify_config.trayicon_close_to_tray =
1716 gtk_toggle_button_get_active
1717 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_close_to_tray));
1719 notify_config.trayicon_hide_when_iconified =
1720 gtk_toggle_button_get_active
1721 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_when_iconified));
1723 #ifdef HAVE_LIBNOTIFY
1724 notify_config.trayicon_popup_enabled =
1725 gtk_toggle_button_get_active
1726 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1729 gtk_spin_button_get_value(GTK_SPIN_BUTTON
1730 (trayicon_page.trayicon_popup_timeout));
1731 notify_config.trayicon_popup_timeout = (gint)floor(timeout*1000+0.5);
1733 notify_config.trayicon_display_folder_name =
1734 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trayicon_page.trayicon_display_folder_name));
1737 notify_config.trayicon_folder_specific =
1738 gtk_toggle_button_get_active
1739 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1741 if(notify_config.trayicon_enabled)
1742 notification_update_msg_counts(NULL);
1744 notification_trayicon_destroy();
1747 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton *button,
1751 active = gtk_toggle_button_get_active
1752 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1753 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_enable, active);
1756 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton *bu,
1760 active = gtk_toggle_button_get_active
1761 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1762 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_folder_specific, active);
1765 #ifdef HAVE_LIBNOTIFY
1766 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton *bu,
1770 active = gtk_toggle_button_get_active
1771 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1772 gtk_widget_set_sensitive(trayicon_page.trayicon_popup_cont_enable, active);
1775 #endif /* HAVE_LIBNOTIFY */
1777 #endif /* NOTIFICATION_TRAYICON */
1779 #ifdef NOTIFICATION_INDICATOR
1781 #define NOTIFICATION_INDICATOR_REGISTER_PATH ".config/indicators/messages/applications"
1783 static gboolean indicator_register_file_exists(void)
1787 filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1788 retval = is_file_exist(filepath);
1793 static gboolean indicator_register_file_create(void)
1796 gchar *path, *filepath;
1799 /* make sure directory path exists */
1800 path = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH, NULL);
1801 if(!is_dir_exist(path)) {
1802 if(make_dir_hier(path) != -1)
1803 debug_print("Notification plugin: Created directory '%s'\n", path);
1805 debug_print("Notification plugin: Error creating directory '%s'\n", path);
1811 /* create register file */
1812 filepath = g_strconcat(path, "/claws-mail", NULL);
1814 fp = fopen(filepath, "w");
1815 success = (fp != NULL);
1817 fprintf(fp, "%s\n", get_desktop_file());
1819 debug_print("Notification plugin: Created desktop indicator file '%s'\n", filepath);
1822 debug_print("Notification plugin: Could not create desktop indicator file '%s'\n", filepath);
1828 static gboolean indicator_register_file_remove(void)
1833 filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1834 retval = claws_unlink(filepath);
1836 debug_print("Notification plugin: Deleted file '%s'\n", filepath);
1838 debug_print("Notification plugin: Error deleting file '%s'\n", filepath);
1841 return (retval != -1);
1844 static void notify_create_indicator_page(PrefsPage *page, GtkWindow *window,
1849 GtkWidget *checkbox;
1852 pvbox = gtk_vbox_new(FALSE, 20);
1853 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1855 /* Enable indicator */
1856 checkbox = gtk_check_button_new_with_label(_("Add to Indicator Applet"));
1857 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1858 notify_config.indicator_enabled);
1859 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1860 g_signal_connect(G_OBJECT(checkbox), "toggled",
1861 G_CALLBACK(notify_indicator_enable_set_sensitivity), NULL);
1862 indicator_page.indicator_enabled = checkbox;
1864 /* Container vbox for greying out everything */
1865 vbox = gtk_vbox_new(FALSE, 10);
1866 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1867 indicator_page.indicator_cont_enable = vbox;
1869 /* hide when minimized */
1870 checkbox = gtk_check_button_new_with_label(_("Hide mainwindow when minimized"));
1871 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), checkbox, FALSE, FALSE, 0);
1872 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.indicator_hide_minimized);
1873 indicator_page.indicator_hide_minimized = checkbox;
1876 ind_reg = gtk_check_button_new_with_label(_("Register Claws Mail"));
1877 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), ind_reg, FALSE, FALSE, 0);
1878 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ind_reg), indicator_register_file_exists());
1879 indicator_page.indicator_register = ind_reg;
1881 notify_indicator_enable_set_sensitivity(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled), NULL);
1882 gtk_widget_show_all(pvbox);
1883 indicator_page.page.widget = pvbox;
1886 static void notify_destroy_indicator_page(PrefsPage *page)
1890 static void notify_save_indicator(PrefsPage *page)
1894 notify_config.indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1896 notify_config.indicator_hide_minimized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_hide_minimized));
1898 ind_reg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_register));
1900 if(!indicator_register_file_exists())
1901 indicator_register_file_create();
1904 if(indicator_register_file_exists())
1905 indicator_register_file_remove();
1908 notification_indicator_destroy();
1909 notification_update_indicator();
1912 static void notify_indicator_enable_set_sensitivity(GtkToggleButton *button,
1916 active = gtk_toggle_button_get_active
1917 (GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1918 gtk_widget_set_sensitive(indicator_page.indicator_cont_enable, active);
1920 #endif /* NOTIFICATION_INDICATOR */
1922 #ifdef NOTIFICATION_HOTKEYS
1923 static void notify_create_hotkeys_page(PrefsPage *page, GtkWindow *window, gpointer data)
1927 GtkWidget *checkbox;
1933 pvbox = gtk_vbox_new(FALSE, 20);
1934 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1936 /* Enable hotkeys */
1937 checkbox = gtk_check_button_new_with_label(_("Enable global hotkeys"));
1938 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.hotkeys_enabled);
1939 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1940 g_signal_connect(G_OBJECT(checkbox), "toggled",
1941 G_CALLBACK(notify_hotkeys_enable_set_sensitivity), NULL);
1942 hotkeys_page.hotkeys_enabled = checkbox;
1944 /* Container vbox for greying out everything */
1945 vbox = gtk_vbox_new(FALSE, 10);
1946 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1947 hotkeys_page.hotkeys_cont_enable = vbox;
1950 label = gtk_label_new("");
1951 markup = g_markup_printf_escaped(_("Examples for hotkeys include <b>%s</b> and <b>%s</b>"), _("<control><shift>F11"), _("<alt>N"));
1952 gtk_label_set_markup(GTK_LABEL(label), markup);
1953 gtk_misc_set_alignment(GTK_MISC(label), 0., 0.);
1955 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), label, FALSE, FALSE, 0);
1957 /* hbox for entry fields */
1958 hbox = gtk_hbox_new(FALSE, 6);
1959 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), hbox, FALSE, FALSE, 0);
1961 /* toggle mainwindow */
1962 label = gtk_label_new(_("Toggle minimize"));
1963 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1964 entry = gtk_entry_new();
1965 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1966 if(notify_config.hotkeys_toggle_mainwindow)
1967 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.hotkeys_toggle_mainwindow);
1968 hotkeys_page.hotkeys_toggle_mainwindow = entry;
1970 notify_hotkeys_enable_set_sensitivity(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled), NULL);
1971 gtk_widget_show_all(pvbox);
1972 hotkeys_page.page.widget = pvbox;
1975 static void notify_destroy_hotkeys_page(PrefsPage *page)
1979 static void notify_save_hotkeys(PrefsPage *page)
1981 const gchar *tmp_str;
1982 notify_config.hotkeys_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1984 tmp_str = gtk_entry_get_text(GTK_ENTRY(hotkeys_page.hotkeys_toggle_mainwindow));
1985 if(notify_config.hotkeys_toggle_mainwindow)
1986 g_free(notify_config.hotkeys_toggle_mainwindow);
1987 notify_config.hotkeys_toggle_mainwindow = g_strdup(tmp_str);
1989 notification_hotkeys_update_bindings();
1992 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton *button,
1996 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1997 gtk_widget_set_sensitive(hotkeys_page.hotkeys_cont_enable, active);
1999 #endif /* hotkeys */
2002 /* This feels so wrong... */
2003 static gint conv_color_to_int(GdkColor *color)
2006 guint red, green, blue;
2008 red = (guint) ((gdouble)(color->red) /65535.*255.);
2009 green = (guint) ((gdouble)(color->green) /65535.*255.);
2010 blue = (guint) ((gdouble)(color->blue) /65535.*255.);
2012 result = (gint) (blue | (green<<8)| (red<<16));