1 /* Notification plugin for Claws-Mail
2 * Copyright (C) 2005-2007 Holger Berndt
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # include "claws-features.h"
24 #include <glib/gi18n.h>
28 #include "prefs_gtk.h"
29 #include "common/prefs.h"
30 #include "common/utils.h"
31 #include "common/defs.h"
32 #include "gtk/gtkutils.h"
35 #include "notification_prefs.h"
36 #include "notification_plugin.h"
37 #include "notification_core.h"
39 #include "notification_popup.h"
40 #include "notification_command.h"
41 #include "notification_lcdproc.h"
42 #include "notification_trayicon.h"
43 #include "notification_indicator.h"
44 #include "notification_hotkeys.h"
46 #include "notification_foldercheck.h"
49 /* allow infinite timeout with libnotify */
50 # define TIMEOUT_SPINNER_MIN 0.0
52 /* don't allow infinite timeout with self-handled popups */
53 # define TIMEOUT_SPINNER_MIN 0.2
56 #define TIMEOUT_SPINNER_MAX 3600.0
57 #define TIMEOUT_SPINNER_STEP 0.5
62 GtkWidget *include_mail;
63 GtkWidget *include_news;
64 GtkWidget *include_rss;
65 GtkWidget *include_calendar;
66 GtkWidget *urgency_hint_new;
67 GtkWidget *urgency_hint_unread;
68 #ifdef HAVE_LIBCANBERRA_GTK
69 GtkWidget *canberra_play_sounds;
73 NotifyPrefs notify_config;
74 NotifyPage notify_page;
76 #ifdef NOTIFICATION_BANNER
79 GtkWidget *banner_show;
80 GtkWidget *banner_speed;
81 GtkWidget *banner_width;
82 GtkWidget *banner_include_unread;
83 GtkWidget *banner_max_msgs;
84 GtkWidget *banner_sticky;
85 GtkWidget *banner_folder_specific;
86 GtkWidget *banner_enable_colors;
87 GtkWidget *banner_color_bg;
88 GtkWidget *banner_color_fg;
89 GtkWidget *banner_cont_enable;
90 GtkWidget *banner_cont_folder_specific;
91 GtkWidget *banner_cont_color_sel;
93 NotifyBannerPage banner_page;
94 #endif /* NOTIFICATION_BANNER */
96 #ifdef NOTIFICATION_POPUP
99 GtkWidget *popup_show;
100 GtkWidget *popup_timeout;
101 GtkWidget *popup_folder_specific;
102 GtkWidget *popup_cont_enable;
103 GtkWidget *popup_cont_folder_specific;
104 #ifndef HAVE_LIBNOTIFY
105 GtkWidget *popup_sticky;
106 GtkWidget *popup_enable_colors;
107 GtkWidget *popup_color_bg;
108 GtkWidget *popup_color_fg;
109 GtkWidget *popup_cont_color_sel;
110 #else /* HAVE_LIBNOTIFY */
111 GtkWidget *popup_display_folder_name;
112 #endif /* HAVE_LIBNOTIFY */
114 NotifyPopupPage popup_page;
115 #endif /* NOTIFICATION_POPUP */
117 #ifdef NOTIFICATION_COMMAND
120 GtkWidget *command_enabled;
121 GtkWidget *command_timeout;
122 GtkWidget *command_folder_specific;
123 GtkWidget *command_line;
124 GtkWidget *command_cont_enable;
125 GtkWidget *command_cont_folder_specific;
127 NotifyCommandPage command_page;
128 #endif /* NOTIFICATION_COMMAND */
130 #ifdef NOTIFICATION_LCDPROC
133 GtkWidget *lcdproc_enabled;
134 GtkWidget *lcdproc_cont_enable;
135 GtkWidget *lcdproc_hostname;
136 GtkWidget *lcdproc_port;
138 NotifyLCDProcPage lcdproc_page;
141 #ifdef NOTIFICATION_TRAYICON
144 GtkWidget *trayicon_enabled;
145 GtkWidget *trayicon_cont_enable;
146 GtkWidget *trayicon_hide_at_startup;
147 GtkWidget *trayicon_close_to_tray;
148 GtkWidget *trayicon_hide_when_iconified;
149 GtkWidget *trayicon_folder_specific;
150 GtkWidget *trayicon_cont_folder_specific;
151 #ifdef HAVE_LIBNOTIFY
152 GtkWidget *trayicon_display_folder_name;
153 GtkWidget *trayicon_popup_enabled;
154 GtkWidget *trayicon_popup_cont_enable;
155 GtkWidget *trayicon_popup_timeout;
158 NotifyTrayiconPage trayicon_page;
161 #ifdef NOTIFICATION_INDICATOR
164 GtkWidget *indicator_enabled;
165 GtkWidget *indicator_cont_enable;
166 GtkWidget *indicator_register;
167 GtkWidget *indicator_hide_minimized;
168 }NotifyIndicatorPage;
169 NotifyIndicatorPage indicator_page;
172 #ifdef NOTIFICATION_HOTKEYS
175 GtkWidget *hotkeys_enabled;
176 GtkWidget *hotkeys_cont_enable;
177 GtkWidget *hotkeys_toggle_mainwindow;
179 NotifyHotkeysPage hotkeys_page;
187 { "include_mail", "TRUE", ¬ify_config.include_mail, P_BOOL, NULL,
189 { "include_news", "TRUE", ¬ify_config.include_news, P_BOOL, NULL,
191 { "include_rss", "TRUE", ¬ify_config.include_rss, P_BOOL, NULL,
193 { "include_calendar", "TRUE", ¬ify_config.include_calendar, P_BOOL,
195 { "urgency_hint_new", "FALSE", ¬ify_config.urgency_hint_new, P_BOOL,
197 { "urgency_hint_unread", "FALSE", ¬ify_config.urgency_hint_unread, P_BOOL,
200 #ifdef HAVE_LIBCANBERRA_GTK
201 { "canberra_play_sounds", "TRUE", ¬ify_config.canberra_play_sounds, P_BOOL,
205 #ifdef NOTIFICATION_BANNER
206 { "banner_show", "0", ¬ify_config.banner_show, P_INT, NULL, NULL, NULL},
207 { "banner_speed", "30", ¬ify_config.banner_speed, P_INT, NULL, NULL, NULL},
208 { "banner_width", "0", ¬ify_config.banner_width, P_INT, NULL, NULL, NULL},
209 { "banner_include_unread", "FALSE", ¬ify_config.banner_include_unread,
210 P_BOOL, NULL, NULL, NULL},
211 { "banner_max_msgs", "100", ¬ify_config.banner_max_msgs, P_INT,
213 { "banner_sticky", "FALSE", ¬ify_config.banner_sticky,
214 P_BOOL, NULL, NULL, NULL},
215 { "banner_root_x", "0", ¬ify_config.banner_root_x, P_INT,
217 { "banner_root_y", "10", ¬ify_config.banner_root_y, P_INT,
219 { "banner_folder_specific", "FALSE", ¬ify_config.banner_folder_specific,
220 P_BOOL, NULL, NULL, NULL},
221 { "banner_enable_colors", "FALSE", ¬ify_config.banner_enable_colors,
222 P_BOOL, NULL, NULL, NULL},
223 { "banner_color_bg", "0", ¬ify_config.banner_color_bg, P_COLOR,
225 { "banner_color_fg", "16776704", ¬ify_config.banner_color_fg, P_COLOR,
229 #ifdef NOTIFICATION_POPUP
230 { "popup_show", "TRUE", ¬ify_config.popup_show, P_BOOL, NULL, NULL, NULL},
231 { "popup_timeout", "5000", ¬ify_config.popup_timeout,
232 P_INT, NULL, NULL, NULL},
233 { "popup_folder_specific", "FALSE", ¬ify_config.popup_folder_specific,
234 P_BOOL, NULL, NULL, NULL},
235 #ifndef HAVE_LIBNOTIFY
236 { "popup_sticky", "TRUE", ¬ify_config.popup_sticky, P_BOOL,
238 { "popup_root_x", "10", ¬ify_config.popup_root_x,
239 P_INT, NULL, NULL, NULL},
240 { "popup_root_y", "10", ¬ify_config.popup_root_y,
241 P_INT, NULL, NULL, NULL},
242 { "popup_width", "100", ¬ify_config.popup_width,
243 P_INT, NULL, NULL, NULL},
244 { "popup_enable_colors", "FALSE", ¬ify_config.popup_enable_colors, P_BOOL,
246 { "popup_color_bg", "0", ¬ify_config.popup_color_bg, P_COLOR,
248 { "popup_color_fg", "16776704", ¬ify_config.popup_color_fg, P_COLOR,
250 #else /* HAVE_LIBNOTIFY */
251 { "popup_display_folder_name", "FALSE", ¬ify_config.popup_display_folder_name,
252 P_BOOL, NULL, NULL, NULL},
253 #endif /* HAVE_LIBNOTIFY */
256 #ifdef NOTIFICATION_COMMAND
257 { "command_enabled", "FALSE", ¬ify_config.command_enabled, P_BOOL,
259 { "command_timeout", "60000", ¬ify_config.command_timeout, P_INT,
261 { "command_folder_specific", "FALSE", ¬ify_config.command_folder_specific,
262 P_BOOL, NULL, NULL, NULL},
263 { "command_line", "", ¬ify_config.command_line, P_STRING,
267 #ifdef NOTIFICATION_LCDPROC
268 { "lcdproc_enabled", "FALSE", ¬ify_config.lcdproc_enabled, P_BOOL,
270 { "lcdproc_hostname", "localhost", ¬ify_config.lcdproc_hostname, P_STRING,
272 { "lcdproc_port", "13666", ¬ify_config.lcdproc_port, P_INT,
276 #ifdef NOTIFICATION_TRAYICON
278 { "trayicon_enabled", "FALSE", ¬ify_config.trayicon_enabled, P_BOOL,
281 { "trayicon_enabled", "TRUE", ¬ify_config.trayicon_enabled, P_BOOL,
284 { "trayicon_hide_at_startup", "FALSE",
285 ¬ify_config.trayicon_hide_at_startup, P_BOOL, NULL, NULL, NULL},
286 { "trayicon_close_to_tray", "FALSE",
287 ¬ify_config.trayicon_close_to_tray, P_BOOL, NULL, NULL, NULL},
288 { "trayicon_hide_when_iconified", "FALSE",
289 ¬ify_config.trayicon_hide_when_iconified, P_BOOL, NULL, NULL, NULL},
290 { "trayicon_folder_specific", "FALSE",
291 ¬ify_config.trayicon_folder_specific,
292 P_BOOL, NULL, NULL, NULL},
293 #ifdef HAVE_LIBNOTIFY
294 { "trayicon_display_folder_name", "FALSE",
295 ¬ify_config.trayicon_display_folder_name,
296 P_BOOL, NULL, NULL, NULL},
297 { "trayicon_popup_enabled", "TRUE", ¬ify_config.trayicon_popup_enabled,
298 P_BOOL, NULL, NULL, NULL},
299 { "trayicon_popup_timeout", "5000", ¬ify_config.trayicon_popup_timeout,
300 P_INT, NULL, NULL, NULL},
301 #endif /* HAVE_LIBNOTIFY */
304 #ifdef NOTIFICATION_INDICATOR
305 { "indicator_enabled", "FALSE", ¬ify_config.indicator_enabled, P_BOOL,
307 { "indicator_hide_minimized", "FALSE", ¬ify_config.indicator_hide_minimized, P_BOOL,
309 #endif /* NOTIFICATION_INDICATOR */
310 #ifdef NOTIFICATION_HOTKEYS
311 { "hotkeys_enabled", "FALSE", ¬ify_config.hotkeys_enabled, P_BOOL,
313 { "hotkeys_toggle_mainwindow", "", ¬ify_config.hotkeys_toggle_mainwindow,
314 P_STRING, NULL, NULL, NULL},
315 #endif /* NOTIFICATION_HOTKEYS */
316 { NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL } };
318 static void notify_create_prefs_page(PrefsPage*, GtkWindow*, gpointer);
319 static void notify_destroy_prefs_page(PrefsPage*);
320 static void notify_save_prefs(PrefsPage*);
322 #ifdef NOTIFICATION_BANNER
323 static void notify_create_banner_page(PrefsPage*, GtkWindow*, gpointer);
324 static void notify_destroy_banner_page(PrefsPage*);
325 static void notify_save_banner(PrefsPage*);
326 static void notify_banner_enable_set_sensitivity(GtkComboBox*, gpointer);
327 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
328 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton*,
332 #ifdef NOTIFICATION_POPUP
333 static void notify_create_popup_page(PrefsPage*, GtkWindow*, gpointer);
334 static void notify_destroy_popup_page(PrefsPage*);
335 static void notify_save_popup(PrefsPage*);
336 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton*,
338 static void notify_popup_enable_set_sensitivity(GtkToggleButton*, gpointer);
339 #ifndef HAVE_LIBNOTIFY
340 static void notify_popup_set_done_cb(GtkWidget*, gpointer);
341 static void notify_popup_set_cb(GtkWidget*, gpointer);
342 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
343 #endif /* !HAVE_LIBNOTIFY */
346 #ifdef NOTIFICATION_COMMAND
347 static void notify_create_command_page(PrefsPage*, GtkWindow*, gpointer);
348 static void notify_destroy_command_page(PrefsPage*);
349 static void notify_save_command(PrefsPage*);
350 static void notify_command_enable_set_sensitivity(GtkToggleButton*, gpointer);
351 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton*,
355 #ifdef NOTIFICATION_LCDPROC
356 static void notify_create_lcdproc_page(PrefsPage*, GtkWindow*, gpointer);
357 static void notify_destroy_lcdproc_page(PrefsPage*);
358 static void notify_save_lcdproc(PrefsPage*);
359 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton*, gpointer);
362 #ifdef NOTIFICATION_TRAYICON
363 static void notify_create_trayicon_page(PrefsPage*, GtkWindow*, gpointer);
364 static void notify_destroy_trayicon_page(PrefsPage*);
365 static void notify_save_trayicon(PrefsPage*);
366 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton*, gpointer);
367 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton*,
369 #ifdef HAVE_LIBNOTIFY
370 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton*,
375 #ifdef NOTIFICATION_INDICATOR
376 static void notify_create_indicator_page(PrefsPage*, GtkWindow*, gpointer);
377 static void notify_destroy_indicator_page(PrefsPage*);
378 static void notify_save_indicator(PrefsPage*);
379 static void notify_indicator_enable_set_sensitivity(GtkToggleButton*, gpointer);
380 #endif /* NOTIFICATION_INDICATOR */
382 #ifdef NOTIFICATION_HOTKEYS
383 static void notify_create_hotkeys_page(PrefsPage*, GtkWindow*, gpointer);
384 static void notify_destroy_hotkeys_page(PrefsPage*);
385 static void notify_save_hotkeys(PrefsPage*);
386 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton*, gpointer);
387 #endif /* NOTIFICATION_HOTKEYS */
390 static gint conv_color_to_int(GdkColor*);
392 void notify_gtk_init(void)
394 static gchar *path[3];
396 path[0] = _("Plugins");
397 path[1] = _("Notification");
400 notify_page.page.path = path;
401 notify_page.page.create_widget = notify_create_prefs_page;
402 notify_page.page.destroy_widget = notify_destroy_prefs_page;
403 notify_page.page.save_page = notify_save_prefs;
404 prefs_gtk_register_page((PrefsPage*) ¬ify_page);
406 #ifdef NOTIFICATION_HOTKEYS
408 static gchar *hotkeys_path[4];
410 hotkeys_path[0] = _("Plugins");
411 hotkeys_path[1] = _("Notification");
412 hotkeys_path[2] = _("Hotkeys");
413 hotkeys_path[3] = NULL;
415 hotkeys_page.page.path = hotkeys_path;
416 hotkeys_page.page.create_widget = notify_create_hotkeys_page;
417 hotkeys_page.page.destroy_widget = notify_destroy_hotkeys_page;
418 hotkeys_page.page.save_page = notify_save_hotkeys;
419 prefs_gtk_register_page((PrefsPage*) &hotkeys_page);
421 #endif /* NOTIFICATION_HOTKEYS */
424 #ifdef NOTIFICATION_BANNER
426 static gchar *banner_path[4];
428 banner_path[0] = _("Plugins");
429 banner_path[1] = _("Notification");
430 banner_path[2] = _("Banner");
431 banner_path[3] = NULL;
433 banner_page.page.path = banner_path;
434 banner_page.page.create_widget = notify_create_banner_page;
435 banner_page.page.destroy_widget = notify_destroy_banner_page;
436 banner_page.page.save_page = notify_save_banner;
437 prefs_gtk_register_page((PrefsPage*) &banner_page);
439 #endif /* NOTIFICATION_BANNER */
441 #ifdef NOTIFICATION_POPUP
443 static gchar *popup_path[4];
445 popup_path[0] = _("Plugins");
446 popup_path[1] = _("Notification");
447 popup_path[2] = _("Popup");
448 popup_path[3] = NULL;
450 popup_page.page.path = popup_path;
451 popup_page.page.create_widget = notify_create_popup_page;
452 popup_page.page.destroy_widget = notify_destroy_popup_page;
453 popup_page.page.save_page = notify_save_popup;
454 prefs_gtk_register_page((PrefsPage*) &popup_page);
456 #endif /* NOTIFICATION_POPUP */
458 #ifdef NOTIFICATION_COMMAND
460 static gchar *command_path[4];
462 command_path[0] = _("Plugins");
463 command_path[1] = _("Notification");
464 command_path[2] = _("Command");
465 command_path[3] = NULL;
467 command_page.page.path = command_path;
468 command_page.page.create_widget = notify_create_command_page;
469 command_page.page.destroy_widget = notify_destroy_command_page;
470 command_page.page.save_page = notify_save_command;
471 prefs_gtk_register_page((PrefsPage*) &command_page);
473 #endif /* NOTIFICATION_COMMAND */
475 #ifdef NOTIFICATION_LCDPROC
477 static gchar *lcdproc_path[4];
479 lcdproc_path[0] = _("Plugins");
480 lcdproc_path[1] = _("Notification");
481 lcdproc_path[2] = _("LCD");
482 lcdproc_path[3] = NULL;
484 lcdproc_page.page.path = lcdproc_path;
485 lcdproc_page.page.create_widget = notify_create_lcdproc_page;
486 lcdproc_page.page.destroy_widget = notify_destroy_lcdproc_page;
487 lcdproc_page.page.save_page = notify_save_lcdproc;
488 prefs_gtk_register_page((PrefsPage*) &lcdproc_page);
490 #endif /* NOTIFICATION_LCDPROC */
492 #ifdef NOTIFICATION_TRAYICON
494 static gchar *trayicon_path[4];
496 trayicon_path[0] = _("Plugins");
497 trayicon_path[1] = _("Notification");
498 trayicon_path[2] = _("SysTrayicon");
499 trayicon_path[3] = NULL;
501 trayicon_page.page.path = trayicon_path;
502 trayicon_page.page.create_widget = notify_create_trayicon_page;
503 trayicon_page.page.destroy_widget = notify_destroy_trayicon_page;
504 trayicon_page.page.save_page = notify_save_trayicon;
505 prefs_gtk_register_page((PrefsPage*) &trayicon_page);
507 #endif /* NOTIFICATION_TRAYICON */
509 #ifdef NOTIFICATION_INDICATOR
511 static gchar *indicator_path[4];
513 indicator_path[0] = _("Plugins");
514 indicator_path[1] = _("Notification");
515 indicator_path[2] = _("Indicator");
516 indicator_path[3] = NULL;
518 indicator_page.page.path = indicator_path;
519 indicator_page.page.create_widget = notify_create_indicator_page;
520 indicator_page.page.destroy_widget = notify_destroy_indicator_page;
521 indicator_page.page.save_page = notify_save_indicator;
522 prefs_gtk_register_page((PrefsPage*) &indicator_page);
524 #endif /* NOTIFICATION_INDICATOR */
527 void notify_gtk_done(void)
529 if (claws_is_exiting())
531 prefs_gtk_unregister_page((PrefsPage*) ¬ify_page);
532 #ifdef NOTIFICATION_BANNER
533 prefs_gtk_unregister_page((PrefsPage*) &banner_page);
535 #ifdef NOTIFICATION_POPUP
536 prefs_gtk_unregister_page((PrefsPage*) &popup_page);
538 #ifdef NOTIFICATION_COMMAND
539 prefs_gtk_unregister_page((PrefsPage*) &command_page);
541 #ifdef NOTIFICATION_LCDPROC
542 prefs_gtk_unregister_page((PrefsPage*) &lcdproc_page);
544 #ifdef NOTIFICATION_TRAYICON
545 prefs_gtk_unregister_page((PrefsPage*) &trayicon_page);
547 #ifdef NOTIFICATION_INDICATOR
548 prefs_gtk_unregister_page((PrefsPage*) &indicator_page);
550 #ifdef NOTIFICATION_HOTKEYS
551 prefs_gtk_unregister_page((PrefsPage*) &hotkeys_page);
555 void notify_save_config(void)
560 debug_print("Saving Notification plugin configuration...\n");
562 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
563 pfile = prefs_write_open(rcpath);
565 if (!pfile || (prefs_set_block_label(pfile, "NotificationPlugin") < 0))
568 if (prefs_write_param(notify_param, pfile->fp) < 0) {
569 debug_print("failed!\n");
570 g_warning(_("\nNotification Plugin: Failed to write plugin configuration "
572 prefs_file_close_revert(pfile);
575 if (fprintf(pfile->fp, "\n") < 0) {
576 FILE_OP_ERROR(rcpath, "fprintf");
577 prefs_file_close_revert(pfile);
580 prefs_file_close(pfile);
581 debug_print("done.\n");
584 static void notify_create_prefs_page(PrefsPage *page, GtkWindow *window,
594 pvbox = gtk_vbox_new(FALSE, 0);
597 frame = gtk_frame_new(_("Include folder types"));
598 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
599 gtk_box_pack_start(GTK_BOX(pvbox), frame, FALSE, FALSE, 0);
602 vbox = gtk_vbox_new(FALSE, 4);
603 gtk_container_add(GTK_CONTAINER(frame), vbox);
604 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
606 /* Include mail folders */
607 checkbox = gtk_check_button_new_with_label(_("Mail folders"));
608 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
609 notify_config.include_mail);
610 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
611 gtk_widget_show(checkbox);
612 notify_page.include_mail = checkbox;
614 /* Include news folders */
615 checkbox = gtk_check_button_new_with_label(_("News folders"));
616 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
617 notify_config.include_news);
618 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
619 gtk_widget_show(checkbox);
620 notify_page.include_news = checkbox;
622 /* Include RSS folders */
623 checkbox = gtk_check_button_new_with_label(_("RSS folders"));
624 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
625 notify_config.include_rss);
626 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
627 gtk_widget_show(checkbox);
628 notify_page.include_rss = checkbox;
630 /* Include calendar folders */
631 checkbox = gtk_check_button_new_with_label(_("Calendar folders"));
632 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
633 notify_config.include_calendar);
634 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
635 gtk_widget_show(checkbox);
636 notify_page.include_calendar = checkbox;
639 label = gtk_label_new(_("These settings overwrite folder-specific "
641 gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
642 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
643 gtk_widget_show(label);
645 /* done with the frame */
646 gtk_widget_show(frame);
647 gtk_widget_show(vbox);
650 frame = gtk_frame_new(_("Global notification settings"));
651 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
652 gtk_box_pack_start(GTK_BOX(pvbox), frame, FALSE, FALSE, 0);
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_create_banner_page(PrefsPage *page, GtkWindow *window,
720 GtkRequisition requisition;
731 GtkWidget *color_sel;
735 pvbox = gtk_vbox_new(FALSE, 20);
736 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
738 /* Always / Never / Only when non-empty */
739 hbox = gtk_hbox_new(FALSE, 20);
740 gtk_box_pack_start(GTK_BOX(pvbox), hbox, FALSE, FALSE, 0);
741 label = gtk_label_new(_("Show banner"));
742 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
743 gtk_widget_show(label);
744 combo = gtk_combo_box_new_text();
745 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NEVER,
747 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_ALWAYS,
749 gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NONEMPTY,
750 _("Only when not empty"));
751 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), notify_config.banner_show);
752 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
753 g_signal_connect(G_OBJECT(combo), "changed",
754 G_CALLBACK(notify_banner_enable_set_sensitivity), NULL);
755 gtk_widget_show(combo);
756 gtk_widget_show(hbox);
757 banner_page.banner_show = combo;
759 /* Container vbox for greying out everything */
760 vbox = gtk_vbox_new(FALSE, 10);
761 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
762 gtk_widget_show(vbox);
763 banner_page.banner_cont_enable = vbox;
766 table = gtk_table_new(2, 3, FALSE);
767 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
768 label = gtk_label_new(_("slow"));
769 gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
770 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
771 gtk_widget_show(label);
772 label = gtk_label_new(_("fast"));
773 gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
774 gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
775 gtk_widget_show(label);
776 label = gtk_label_new(_("Banner speed"));
777 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
778 gtk_widget_show(label);
779 slider = gtk_hscale_new_with_range(10., 70., 10.);
780 gtk_scale_set_digits(GTK_SCALE(slider), 0);
781 gtk_widget_size_request(combo, &requisition);
782 gtk_widget_set_size_request(slider, requisition.width, -1);
783 gtk_range_set_increments(GTK_RANGE(slider), 10., 10.);
784 gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
785 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
786 gtk_range_set_value(GTK_RANGE(slider), notify_config.banner_speed);
787 gtk_table_attach_defaults(GTK_TABLE(table), slider, 1, 3, 1, 2);
788 gtk_widget_show(slider);
789 gtk_widget_show(table);
790 banner_page.banner_speed = slider;
792 /* Maximum number of messages in banner */
793 hbox = gtk_hbox_new(FALSE, 10);
794 label = gtk_label_new(_("Maximum number of messages (0 means unlimited)"));
795 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
796 gtk_widget_show(label);
797 spinner = gtk_spin_button_new_with_range(0., 1000., 1.);
798 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
799 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), notify_config.banner_max_msgs);
800 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
801 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
802 gtk_widget_show(spinner);
803 gtk_widget_show(hbox);
804 banner_page.banner_max_msgs = spinner;
807 hbox = gtk_hbox_new(FALSE, 10);
808 label = gtk_label_new(_("Banner width in pixels (0 means screen size)"));
809 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
810 gtk_widget_show(label);
811 spinner = gtk_spin_button_new_with_range(0.,5000., 50);
812 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner),0);
813 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),notify_config.banner_width);
814 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
815 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
816 gtk_widget_show(spinner);
817 gtk_widget_show(hbox);
818 banner_page.banner_width = spinner;
821 checkbox = gtk_check_button_new_with_label(_("Include unread mails in banner"));
822 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
823 notify_config.banner_include_unread);
824 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
825 gtk_widget_show(checkbox);
826 banner_page.banner_include_unread = checkbox;
828 /* Check button sticky */
829 checkbox = gtk_check_button_new_with_label(_("Make banner sticky"));
830 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
831 notify_config.banner_sticky);
832 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
833 gtk_widget_show(checkbox);
834 banner_page.banner_sticky = checkbox;
836 /* Check box for enabling folder specific selection */
837 hbox = gtk_hbox_new(FALSE, 10);
838 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
839 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
840 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
841 notify_config.banner_folder_specific);
842 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
843 g_signal_connect(G_OBJECT(checkbox), "toggled",
844 G_CALLBACK(notify_banner_folder_specific_set_sensitivity),
846 gtk_widget_show(checkbox);
847 banner_page.banner_folder_specific = checkbox;
848 button = gtk_button_new_with_label(_("Select folders..."));
849 g_signal_connect(G_OBJECT(button), "clicked",
850 G_CALLBACK(notification_foldercheck_sel_folders_cb),
851 BANNER_SPECIFIC_FOLDER_ID_STR);
852 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
853 banner_page.banner_cont_folder_specific = button;
854 gtk_widget_show(button);
855 gtk_widget_show(hbox);
857 /* Check box for enabling custom colors */
858 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
859 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
860 notify_config.banner_enable_colors);
861 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
862 g_signal_connect(G_OBJECT(checkbox), "toggled",
863 G_CALLBACK(notify_banner_color_sel_set_sensitivity), NULL);
864 gtk_widget_show(checkbox);
865 banner_page.banner_enable_colors = checkbox;
867 /* Color selection dialogs for foreground and background color */
869 table = gtk_table_new(2, 2, FALSE);
870 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
871 label = gtk_label_new(_("Foreground"));
872 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
873 gtk_widget_show(label);
874 color_sel = gtk_color_button_new();
875 gtkut_convert_int_to_gdk_color(notify_config.banner_color_fg,&fg);
876 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
877 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
878 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,0,1);
879 gtk_widget_show(color_sel);
880 banner_page.banner_color_fg = color_sel;
882 label = gtk_label_new(_("Background"));
883 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
884 gtk_widget_show(label);
885 color_sel = gtk_color_button_new();
886 gtkut_convert_int_to_gdk_color(notify_config.banner_color_bg,&bg);
887 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
888 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel), _("Background color"));
889 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,1,2);
890 gtk_widget_show(color_sel);
891 gtk_widget_show(table);
892 banner_page.banner_color_bg = color_sel;
893 banner_page.banner_cont_color_sel = table;
895 notify_banner_color_sel_set_sensitivity
896 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors), NULL);
897 notify_banner_folder_specific_set_sensitivity
898 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific), NULL);
899 notify_banner_enable_set_sensitivity(GTK_COMBO_BOX(combo), NULL);
900 gtk_widget_show(pvbox);
901 banner_page.page.widget = pvbox;
904 static void notify_destroy_banner_page(PrefsPage *page)
908 static void notify_save_banner(PrefsPage *page)
913 notify_config.banner_show =
914 gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
915 notify_config.banner_max_msgs =
916 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_max_msgs));
917 notify_config.banner_width =
918 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_width));
919 notify_config.banner_include_unread =
920 gtk_toggle_button_get_active
921 (GTK_TOGGLE_BUTTON(banner_page.banner_include_unread));
922 range_val= gtk_range_get_value(GTK_RANGE(banner_page.banner_speed));
923 notify_config.banner_speed = (gint)ceil(range_val);
925 notify_config.banner_sticky =
926 gtk_toggle_button_get_active
927 (GTK_TOGGLE_BUTTON(banner_page.banner_sticky));
929 notify_config.banner_folder_specific =
930 gtk_toggle_button_get_active
931 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
933 notify_config.banner_enable_colors =
934 gtk_toggle_button_get_active
935 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
937 /* Color dialogs are a bit more complicated */
938 gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_fg),
940 notify_config.banner_color_fg = conv_color_to_int(&color);
941 gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_bg),
943 notify_config.banner_color_bg = conv_color_to_int(&color);
945 notification_banner_destroy();
946 notification_update_banner();
949 static void notify_banner_enable_set_sensitivity(GtkComboBox *combo,
952 NotifyBannerShow show;
954 show = gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
955 gtk_widget_set_sensitive(banner_page.banner_cont_enable,
956 (show == NOTIFY_BANNER_SHOW_NEVER) ? FALSE : TRUE);
959 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton *button,
963 active = gtk_toggle_button_get_active
964 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
965 gtk_widget_set_sensitive(banner_page.banner_cont_color_sel, active);
968 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton *bu,
972 active = gtk_toggle_button_get_active
973 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
974 gtk_widget_set_sensitive(banner_page.banner_cont_folder_specific, active);
976 #endif /* NOTIFICATION_BANNER */
978 #ifdef NOTIFICATION_POPUP
979 static void notify_create_popup_page(PrefsPage *page, GtkWindow *window,
990 #ifndef HAVE_LIBNOTIFY
994 GtkWidget *color_sel;
995 #endif /* !HAVE_LIBNOTIFY */
997 pvbox = gtk_vbox_new(FALSE, 20);
998 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1001 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1002 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1003 notify_config.popup_show);
1004 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1005 g_signal_connect(G_OBJECT(checkbox), "toggled",
1006 G_CALLBACK(notify_popup_enable_set_sensitivity), NULL);
1007 gtk_widget_show(checkbox);
1008 popup_page.popup_show = checkbox;
1010 /* Container vbox for greying out everything */
1011 vbox = gtk_vbox_new(FALSE, 10);
1012 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1013 gtk_widget_show(vbox);
1014 popup_page.popup_cont_enable = vbox;
1017 hbox = gtk_hbox_new(FALSE, 10);
1018 label = gtk_label_new(_("Popup timeout:"));
1019 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1020 gtk_widget_show(label);
1021 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1022 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1023 timeout = notify_config.popup_timeout/1000.;
1024 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1025 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1026 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1027 gtk_widget_show(spinner);
1028 label = gtk_label_new(_("seconds"));
1029 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1030 gtk_widget_show(label);
1031 gtk_widget_show(hbox);
1032 popup_page.popup_timeout = spinner;
1034 /* Check box for enabling folder specific selection */
1035 hbox = gtk_hbox_new(FALSE, 10);
1036 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1037 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1038 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1039 notify_config.popup_folder_specific);
1040 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1041 g_signal_connect(G_OBJECT(checkbox), "toggled",
1042 G_CALLBACK(notify_popup_folder_specific_set_sensitivity),
1044 gtk_widget_show(checkbox);
1045 popup_page.popup_folder_specific = checkbox;
1046 button = gtk_button_new_with_label(_("Select folders..."));
1047 g_signal_connect(G_OBJECT(button), "clicked",
1048 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1049 POPUP_SPECIFIC_FOLDER_ID_STR);
1050 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1051 popup_page.popup_cont_folder_specific = button;
1052 gtk_widget_show(button);
1053 gtk_widget_show(hbox);
1055 #ifndef HAVE_LIBNOTIFY
1056 /* Sticky check button */
1057 checkbox = gtk_check_button_new_with_label(_("Make popup sticky"));
1058 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1059 notify_config.popup_sticky);
1060 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1061 gtk_widget_show(checkbox);
1062 popup_page.popup_sticky = checkbox;
1064 /* Button to set size and position of popup window */
1065 hbox = gtk_hbox_new(FALSE, 10);
1066 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1067 button = gtk_button_new_with_label(_("Set popup window width and position"));
1068 g_signal_connect(G_OBJECT(button), "clicked",
1069 G_CALLBACK(notify_popup_set_cb), NULL);
1070 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1071 gtk_widget_show(button);
1072 label = gtk_label_new(_("(the window manager is free to ignore this)"));
1073 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1074 gtk_widget_show(label);
1075 gtk_widget_show(hbox);
1077 /* Check box for enabling custom colors */
1078 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
1079 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1080 notify_config.popup_enable_colors);
1081 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1082 g_signal_connect(G_OBJECT(checkbox), "toggled",
1083 G_CALLBACK(notify_popup_color_sel_set_sensitivity), NULL);
1084 gtk_widget_show(checkbox);
1085 popup_page.popup_enable_colors = checkbox;
1087 /* Color selection dialogs for foreground and background color */
1088 table = gtk_table_new(2,2,FALSE);
1089 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
1091 label = gtk_label_new(_("Foreground"));
1092 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
1093 gtk_widget_show(label);
1094 color_sel = gtk_color_button_new();
1095 gtkut_convert_int_to_gdk_color(notify_config.popup_color_fg,&fg);
1096 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
1097 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
1098 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,0,1);
1099 gtk_widget_show(color_sel);
1100 popup_page.popup_color_fg = color_sel;
1102 label = gtk_label_new(_("Background"));
1103 gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
1104 gtk_widget_show(label);
1105 color_sel = gtk_color_button_new();
1106 gtkut_convert_int_to_gdk_color(notify_config.popup_color_bg,&bg);
1107 gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
1108 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Background color"));
1109 gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,1,2);
1110 gtk_widget_show(color_sel);
1111 gtk_widget_show(table);
1112 popup_page.popup_color_bg = color_sel;
1113 popup_page.popup_cont_color_sel = table;
1115 notify_popup_color_sel_set_sensitivity
1116 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors), NULL);
1117 #else /* HAVE_LIBNOTIFY */
1118 hbox = gtk_hbox_new(FALSE, 10);
1119 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1120 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1122 notify_config.popup_display_folder_name);
1123 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1124 gtk_widget_show(checkbox);
1125 gtk_widget_show(hbox);
1126 popup_page.popup_display_folder_name = checkbox;
1127 #endif /* HAVE_LIBNOTIFY */
1129 notify_popup_enable_set_sensitivity
1130 (GTK_TOGGLE_BUTTON(popup_page.popup_show), NULL);
1131 notify_popup_folder_specific_set_sensitivity
1132 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific), NULL);
1133 gtk_widget_show(pvbox);
1134 popup_page.page.widget = pvbox;
1137 static void notify_destroy_popup_page(PrefsPage *page)
1141 static void notify_save_popup(PrefsPage *page)
1145 #ifndef HAVE_LIBNOTIFY
1147 #endif /* !HAVE_LIBNOTIFY */
1149 notify_config.popup_show =
1150 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_show));
1152 gtk_spin_button_get_value(GTK_SPIN_BUTTON(popup_page.popup_timeout));
1153 notify_config.popup_timeout = (gint)floor(timeout*1000+0.5);
1154 notify_config.popup_folder_specific =
1155 gtk_toggle_button_get_active
1156 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1158 #ifndef HAVE_LIBNOTIFY
1159 notify_config.popup_sticky =
1160 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_sticky));
1161 notify_config.popup_enable_colors =
1162 gtk_toggle_button_get_active
1163 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1165 /* Color dialogs are a bit more complicated */
1166 gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_fg),
1168 notify_config.popup_color_fg = conv_color_to_int(&color);
1169 gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_bg),
1171 notify_config.popup_color_bg = conv_color_to_int(&color);
1172 #else /* HAVE_LIBNOTIFY */
1173 notify_config.popup_display_folder_name =
1174 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_display_folder_name));
1175 #endif /* HAVE_LIBNOTIFY */
1178 #ifndef HAVE_LIBNOTIFY
1179 static void notify_popup_set_cb(GtkWidget *widget, gpointer data)
1184 win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "notification_prefs");
1185 gtk_window_set_title(GTK_WINDOW(win), _("Sample popup window"));
1186 gtk_window_set_modal(GTK_WINDOW(win), TRUE);
1187 gtk_window_set_keep_above(GTK_WINDOW(win), TRUE);
1188 gtk_window_set_resizable(GTK_WINDOW(win), TRUE);
1189 gtk_container_set_border_width(GTK_CONTAINER(win), 5);
1191 button = gtk_button_new_with_label(_("Done"));
1192 g_signal_connect(G_OBJECT(button), "clicked",
1193 G_CALLBACK(notify_popup_set_done_cb), win);
1194 gtk_container_add(GTK_CONTAINER(win), button);
1196 gtk_widget_show_all(win);
1199 static void notify_popup_set_done_cb(GtkWidget *widget, gpointer data)
1201 GtkWidget *win = data;
1204 gtk_window_get_position(GTK_WINDOW(win),
1205 &(notify_config.popup_root_x),
1206 &(notify_config.popup_root_y));
1207 gtk_window_get_size(GTK_WINDOW(win),
1208 &(notify_config.popup_width), &dummy);
1209 gtk_widget_destroy(win);
1212 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton *button,
1216 active = gtk_toggle_button_get_active
1217 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1218 gtk_widget_set_sensitive(popup_page.popup_cont_color_sel, active);
1220 #endif /* !HAVE_LIBNOTIFY */
1222 static void notify_popup_enable_set_sensitivity(GtkToggleButton *button,
1226 active = gtk_toggle_button_get_active
1227 (GTK_TOGGLE_BUTTON(popup_page.popup_show));
1228 gtk_widget_set_sensitive(popup_page.popup_cont_enable, active);
1231 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton *bu,
1235 active = gtk_toggle_button_get_active
1236 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1237 gtk_widget_set_sensitive(popup_page.popup_cont_folder_specific, active);
1240 #endif /* NOTIFICATION_POPUP */
1242 #ifdef NOTIFICATION_COMMAND
1243 static void notify_create_command_page(PrefsPage *page, GtkWindow *window,
1248 GtkWidget *checkbox;
1256 pvbox = gtk_vbox_new(FALSE, 20);
1257 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1259 /* Enable command */
1260 checkbox = gtk_check_button_new_with_label(_("Enable command"));
1261 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1262 notify_config.command_enabled);
1263 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1264 g_signal_connect(G_OBJECT(checkbox), "toggled",
1265 G_CALLBACK(notify_command_enable_set_sensitivity), NULL);
1266 gtk_widget_show(checkbox);
1267 command_page.command_enabled = checkbox;
1269 /* Container vbox for greying out everything */
1270 vbox = gtk_vbox_new(FALSE, 10);
1271 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1272 gtk_widget_show(vbox);
1273 command_page.command_cont_enable = vbox;
1275 /* entry field for command to execute */
1276 hbox = gtk_hbox_new(FALSE, 10);
1277 label = gtk_label_new(_("Command to execute:"));
1278 gtk_widget_show(label);
1279 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1280 entry = gtk_entry_new();
1281 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.command_line);
1282 gtk_widget_show(entry);
1283 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1284 gtk_widget_show(hbox);
1285 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1286 command_page.command_line = entry;
1288 /* Spin button for command timeout */
1289 hbox = gtk_hbox_new(FALSE, 10);
1290 label = gtk_label_new(_("Block command after execution for"));
1291 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1292 gtk_widget_show(label);
1293 spinner = gtk_spin_button_new_with_range(0., 600., 1.);
1294 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1295 timeout = notify_config.command_timeout/1000.;
1296 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1297 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1298 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1299 gtk_widget_show(spinner);
1300 label = gtk_label_new(_("seconds"));
1301 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1302 gtk_widget_show(label);
1303 gtk_widget_show(hbox);
1304 command_page.command_timeout = spinner;
1306 /* Check box for enabling folder specific selection */
1307 hbox = gtk_hbox_new(FALSE, 10);
1308 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1309 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1310 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1311 notify_config.command_folder_specific);
1312 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1313 g_signal_connect(G_OBJECT(checkbox), "toggled",
1314 G_CALLBACK(notify_command_folder_specific_set_sensitivity),
1316 gtk_widget_show(checkbox);
1317 command_page.command_folder_specific = checkbox;
1318 button = gtk_button_new_with_label(_("Select folders..."));
1319 g_signal_connect(G_OBJECT(button), "clicked",
1320 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1321 COMMAND_SPECIFIC_FOLDER_ID_STR);
1322 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1323 command_page.command_cont_folder_specific = button;
1324 gtk_widget_show(button);
1325 gtk_widget_show(hbox);
1327 notify_command_enable_set_sensitivity
1328 (GTK_TOGGLE_BUTTON(command_page.command_enabled), NULL);
1329 notify_command_folder_specific_set_sensitivity
1330 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific), NULL);
1331 gtk_widget_show(pvbox);
1332 command_page.page.widget = pvbox;
1335 static void notify_destroy_command_page(PrefsPage *page)
1339 static void notify_save_command(PrefsPage *page)
1342 const gchar *tmp_str;
1344 notify_config.command_enabled =
1345 gtk_toggle_button_get_active
1346 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1349 gtk_spin_button_get_value(GTK_SPIN_BUTTON(command_page.command_timeout));
1350 notify_config.command_timeout = (gint)floor(timeout*1000+0.5);
1351 notify_config.command_folder_specific =
1352 gtk_toggle_button_get_active
1353 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1355 tmp_str = gtk_entry_get_text(GTK_ENTRY(command_page.command_line));
1356 if(notify_config.command_line)
1357 g_free(notify_config.command_line);
1358 notify_config.command_line = g_strdup(tmp_str);
1361 static void notify_command_enable_set_sensitivity(GtkToggleButton *button,
1365 active = gtk_toggle_button_get_active
1366 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1367 gtk_widget_set_sensitive(command_page.command_cont_enable, active);
1370 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton *bu,
1374 active = gtk_toggle_button_get_active
1375 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1376 gtk_widget_set_sensitive(command_page.command_cont_folder_specific, active);
1379 #endif /* NOTIFICATION_COMMAND */
1381 #ifdef NOTIFICATION_LCDPROC
1382 static void notify_create_lcdproc_page(PrefsPage *page, GtkWindow *window,
1390 GtkWidget *checkbox;
1393 pvbox = gtk_vbox_new(FALSE, 20);
1394 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1396 /* Enable lcdproc */
1397 checkbox = gtk_check_button_new_with_label(_("Enable LCD"));
1398 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1399 notify_config.lcdproc_enabled);
1400 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1401 g_signal_connect(G_OBJECT(checkbox), "toggled",
1402 G_CALLBACK(notify_lcdproc_enable_set_sensitivity), NULL);
1403 gtk_widget_show(checkbox);
1404 lcdproc_page.lcdproc_enabled = checkbox;
1406 /* Container vbox for greying out everything */
1407 vbox = gtk_vbox_new(FALSE, 10);
1408 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1409 gtk_widget_show(vbox);
1410 lcdproc_page.lcdproc_cont_enable = vbox;
1412 /* Hostname and port information */
1413 hbox = gtk_hbox_new(FALSE, 10);
1414 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1415 gtk_widget_show(hbox);
1416 label = gtk_label_new(_("Hostname:Port of LCDd server:"));
1417 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1418 entry = gtk_entry_new();
1419 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.lcdproc_hostname);
1420 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1421 gtk_widget_show(entry);
1422 gtk_widget_show(label);
1423 label = gtk_label_new(":");
1424 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1425 gtk_widget_show(label);
1426 spinner = gtk_spin_button_new_with_range(1., 65535., 1.);
1427 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1428 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),
1429 notify_config.lcdproc_port);
1430 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1431 gtk_widget_show(spinner);
1432 lcdproc_page.lcdproc_hostname = entry;
1433 lcdproc_page.lcdproc_port = spinner;
1435 notify_lcdproc_enable_set_sensitivity
1436 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled), NULL);
1437 gtk_widget_show(pvbox);
1438 lcdproc_page.page.widget = pvbox;
1441 static void notify_destroy_lcdproc_page(PrefsPage *page)
1445 static void notify_save_lcdproc(PrefsPage *page)
1447 notify_config.lcdproc_enabled =
1448 gtk_toggle_button_get_active
1449 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1451 if(notify_config.lcdproc_hostname)
1452 g_free(notify_config.lcdproc_hostname);
1453 notify_config.lcdproc_hostname =
1454 g_strdup(gtk_entry_get_text(GTK_ENTRY(lcdproc_page.lcdproc_hostname)));
1456 notify_config.lcdproc_port =
1457 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lcdproc_page.lcdproc_port));
1459 if(notify_config.lcdproc_enabled)
1460 notification_lcdproc_connect();
1462 notification_lcdproc_disconnect();
1465 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton *button,
1469 active = gtk_toggle_button_get_active
1470 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1471 gtk_widget_set_sensitive(lcdproc_page.lcdproc_cont_enable, active);
1473 #endif /* NOTIFICATION_LCDPROC */
1475 #ifdef NOTIFICATION_TRAYICON
1476 static void notify_create_trayicon_page(PrefsPage *page, GtkWindow *window,
1481 GtkWidget *checkbox;
1485 #if defined(HAVE_LIBNOTIFY)
1491 #ifdef HAVE_LIBNOTIFY
1497 pvbox = gtk_vbox_new(FALSE, 20);
1498 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1500 /* Enable trayicon */
1501 checkbox = gtk_check_button_new_with_label(_("Enable Trayicon"));
1502 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1503 notify_config.trayicon_enabled);
1504 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1505 g_signal_connect(G_OBJECT(checkbox), "toggled",
1506 G_CALLBACK(notify_trayicon_enable_set_sensitivity), NULL);
1507 gtk_widget_show(checkbox);
1508 trayicon_page.trayicon_enabled = checkbox;
1510 /* Container vbox for greying out everything */
1511 vbox = gtk_vbox_new(FALSE, 10);
1512 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1513 gtk_widget_show(vbox);
1514 trayicon_page.trayicon_cont_enable = vbox;
1516 /* Hide at startup */
1517 checkbox = gtk_check_button_new_with_label(_("Hide at start-up"));
1518 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1519 notify_config.trayicon_hide_at_startup);
1520 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1521 gtk_widget_show(checkbox);
1522 trayicon_page.trayicon_hide_at_startup = checkbox;
1525 checkbox = gtk_check_button_new_with_label(_("Close to tray"));
1526 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1527 notify_config.trayicon_close_to_tray);
1528 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1529 gtk_widget_show(checkbox);
1530 trayicon_page.trayicon_close_to_tray = checkbox;
1532 /* Hide when iconified */
1533 checkbox = gtk_check_button_new_with_label(_("Hide when iconified"));
1534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1535 notify_config.trayicon_hide_when_iconified);
1536 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1537 gtk_widget_show(checkbox);
1538 trayicon_page.trayicon_hide_when_iconified = checkbox;
1540 /* folder specific */
1541 hbox = gtk_hbox_new(FALSE, 10);
1542 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1543 gtk_widget_show(hbox);
1544 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1545 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1546 notify_config.trayicon_folder_specific);
1547 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1548 g_signal_connect(G_OBJECT(checkbox), "toggled",
1549 G_CALLBACK(notify_trayicon_folder_specific_set_sensitivity),
1551 gtk_widget_show(checkbox);
1552 trayicon_page.trayicon_folder_specific = checkbox;
1553 button = gtk_button_new_with_label(_("Select folders..."));
1554 g_signal_connect(G_OBJECT(button), "clicked",
1555 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1556 TRAYICON_SPECIFIC_FOLDER_ID_STR);
1557 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1558 trayicon_page.trayicon_cont_folder_specific = button;
1559 gtk_widget_show(button);
1561 #ifdef HAVE_LIBNOTIFY
1562 /* Frame for trayicon popup stuff */
1564 /* TRANSLATORS: "Toaster" does not refer to the kitchen appliance.
1565 A toast is a small passive (non-focus-stealing)
1566 notification bubble. If your language does not have a word
1567 for that, go for something along the lines of "passive popup"
1569 http://en.wikipedia.org/wiki/Toast_(computing) */
1570 frame = gtk_frame_new(_("Passive toaster popup"));
1571 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
1572 gtk_widget_show(frame);
1574 /* vbox for frame */
1575 svbox = gtk_vbox_new(FALSE, 10);
1576 gtk_container_set_border_width(GTK_CONTAINER(svbox), 5);
1577 gtk_container_add(GTK_CONTAINER(frame), svbox);
1578 gtk_widget_show(svbox);
1580 /* Enable popup for the tray icon */
1581 checkbox = gtk_check_button_new_with_label(_("Enable Popup"));
1582 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1583 notify_config.trayicon_popup_enabled);
1584 g_signal_connect(G_OBJECT(checkbox), "toggled",
1585 G_CALLBACK(notify_trayicon_popup_enable_set_sensitivity),
1587 gtk_box_pack_start(GTK_BOX(svbox), checkbox, FALSE, FALSE, 0);
1588 gtk_widget_show(checkbox);
1589 trayicon_page.trayicon_popup_enabled = checkbox;
1591 /* vbox for trayicon popup stuff enabled/disabled container */
1592 ssvbox = gtk_vbox_new(FALSE, 10);
1593 gtk_box_pack_start(GTK_BOX(svbox), ssvbox, FALSE, FALSE, 0);
1594 gtk_widget_show(ssvbox);
1595 trayicon_page.trayicon_popup_cont_enable = ssvbox;
1598 hbox = gtk_hbox_new(FALSE, 10);
1599 label = gtk_label_new(_("Popup timeout:"));
1600 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1601 gtk_widget_show(label);
1602 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1603 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1604 timeout = notify_config.trayicon_popup_timeout/1000.;
1605 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1606 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1607 gtk_box_pack_start(GTK_BOX(ssvbox), hbox, FALSE, FALSE, 0);
1608 label = gtk_label_new(_("seconds"));
1609 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1611 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1612 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1613 notify_config.trayicon_display_folder_name);
1614 gtk_box_pack_start(GTK_BOX(ssvbox), checkbox, FALSE, FALSE, 0);
1615 trayicon_page.trayicon_display_folder_name = checkbox;
1616 gtk_widget_show(checkbox);
1618 gtk_widget_show(spinner);
1619 gtk_widget_show(label);
1620 gtk_widget_show(hbox);
1621 trayicon_page.trayicon_popup_timeout = spinner;
1625 notify_trayicon_enable_set_sensitivity
1626 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled), NULL);
1628 #ifdef HAVE_LIBNOTIFY
1629 notify_trayicon_popup_enable_set_sensitivity
1630 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled), NULL);
1633 notify_trayicon_folder_specific_set_sensitivity
1634 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific), NULL);
1636 gtk_widget_show(pvbox);
1637 trayicon_page.page.widget = pvbox;
1640 static void notify_destroy_trayicon_page(PrefsPage *page)
1644 static void notify_save_trayicon(PrefsPage *page)
1646 #ifdef HAVE_LIBNOTIFY
1650 notify_config.trayicon_enabled =
1651 gtk_toggle_button_get_active
1652 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1654 notify_config.trayicon_hide_at_startup =
1655 gtk_toggle_button_get_active
1656 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_at_startup));
1658 notify_config.trayicon_close_to_tray =
1659 gtk_toggle_button_get_active
1660 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_close_to_tray));
1662 notify_config.trayicon_hide_when_iconified =
1663 gtk_toggle_button_get_active
1664 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_when_iconified));
1666 #ifdef HAVE_LIBNOTIFY
1667 notify_config.trayicon_popup_enabled =
1668 gtk_toggle_button_get_active
1669 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1672 gtk_spin_button_get_value(GTK_SPIN_BUTTON
1673 (trayicon_page.trayicon_popup_timeout));
1674 notify_config.trayicon_popup_timeout = (gint)floor(timeout*1000+0.5);
1676 notify_config.trayicon_display_folder_name =
1677 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trayicon_page.trayicon_display_folder_name));
1680 notify_config.trayicon_folder_specific =
1681 gtk_toggle_button_get_active
1682 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1684 if(notify_config.trayicon_enabled)
1685 notification_update_msg_counts(NULL);
1687 notification_trayicon_destroy();
1690 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton *button,
1694 active = gtk_toggle_button_get_active
1695 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1696 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_enable, active);
1699 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton *bu,
1703 active = gtk_toggle_button_get_active
1704 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1705 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_folder_specific, active);
1708 #ifdef HAVE_LIBNOTIFY
1709 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton *bu,
1713 active = gtk_toggle_button_get_active
1714 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1715 gtk_widget_set_sensitive(trayicon_page.trayicon_popup_cont_enable, active);
1718 #endif /* HAVE_LIBNOTIFY */
1720 #endif /* NOTIFICATION_TRAYICON */
1722 #ifdef NOTIFICATION_INDICATOR
1724 #define NOTIFICATION_INDICATOR_REGISTER_PATH ".config/indicators/messages/applications"
1726 static gboolean indicator_register_file_exists(void)
1730 filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1731 retval = is_file_exist(filepath);
1736 static gboolean indicator_register_file_create(void)
1739 gchar *path, *filepath;
1742 /* make sure directory path exists */
1743 path = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH, NULL);
1744 if(!is_dir_exist(path)) {
1745 if(make_dir_hier(path) != -1)
1746 debug_print("Notification plugin: Created directory '%s'\n", path);
1748 debug_print("Notification plugin: Error creating directory '%s'\n", path);
1754 /* create register file */
1755 filepath = g_strconcat(path, "/claws-mail", NULL);
1757 fp = fopen(filepath, "w");
1758 success = (fp != NULL);
1760 fprintf(fp, "%s\n", get_desktop_file());
1762 debug_print("Notification plugin: Created desktop indicator file '%s'\n", filepath);
1765 debug_print("Notification plugin: Could not create desktop indicator file '%s'\n", filepath);
1771 static gboolean indicator_register_file_remove(void)
1776 filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1777 retval = claws_unlink(filepath);
1779 debug_print("Notification plugin: Deleted file '%s'\n", filepath);
1781 debug_print("Notification plugin: Error deleting file '%s'\n", filepath);
1784 return (retval != -1);
1787 static void notify_create_indicator_page(PrefsPage *page, GtkWindow *window,
1792 GtkWidget *checkbox;
1795 pvbox = gtk_vbox_new(FALSE, 20);
1796 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1798 /* Enable indicator */
1799 checkbox = gtk_check_button_new_with_label(_("Add to Indicator Applet"));
1800 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1801 notify_config.indicator_enabled);
1802 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1803 g_signal_connect(G_OBJECT(checkbox), "toggled",
1804 G_CALLBACK(notify_indicator_enable_set_sensitivity), NULL);
1805 indicator_page.indicator_enabled = checkbox;
1807 /* Container vbox for greying out everything */
1808 vbox = gtk_vbox_new(FALSE, 10);
1809 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1810 indicator_page.indicator_cont_enable = vbox;
1812 /* hide when minimized */
1813 checkbox = gtk_check_button_new_with_label(_("Hide mainwindow when minimized"));
1814 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), checkbox, FALSE, FALSE, 0);
1815 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.indicator_hide_minimized);
1816 indicator_page.indicator_hide_minimized = checkbox;
1819 ind_reg = gtk_check_button_new_with_label(_("Register Claws Mail"));
1820 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), ind_reg, FALSE, FALSE, 0);
1821 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ind_reg), indicator_register_file_exists());
1822 indicator_page.indicator_register = ind_reg;
1824 notify_indicator_enable_set_sensitivity(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled), NULL);
1825 gtk_widget_show_all(pvbox);
1826 indicator_page.page.widget = pvbox;
1829 static void notify_destroy_indicator_page(PrefsPage *page)
1833 static void notify_save_indicator(PrefsPage *page)
1837 notify_config.indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1839 notify_config.indicator_hide_minimized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_hide_minimized));
1841 ind_reg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_register));
1843 if(!indicator_register_file_exists())
1844 indicator_register_file_create();
1847 if(indicator_register_file_exists())
1848 indicator_register_file_remove();
1851 notification_indicator_destroy();
1852 notification_update_indicator();
1855 static void notify_indicator_enable_set_sensitivity(GtkToggleButton *button,
1859 active = gtk_toggle_button_get_active
1860 (GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1861 gtk_widget_set_sensitive(indicator_page.indicator_cont_enable, active);
1863 #endif /* NOTIFICATION_INDICATOR */
1865 #ifdef NOTIFICATION_HOTKEYS
1866 static void notify_create_hotkeys_page(PrefsPage *page, GtkWindow *window, gpointer data)
1870 GtkWidget *checkbox;
1876 pvbox = gtk_vbox_new(FALSE, 20);
1877 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1879 /* Enable hotkeys */
1880 checkbox = gtk_check_button_new_with_label(_("Enable global hotkeys"));
1881 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.hotkeys_enabled);
1882 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1883 g_signal_connect(G_OBJECT(checkbox), "toggled",
1884 G_CALLBACK(notify_hotkeys_enable_set_sensitivity), NULL);
1885 hotkeys_page.hotkeys_enabled = checkbox;
1887 /* Container vbox for greying out everything */
1888 vbox = gtk_vbox_new(FALSE, 10);
1889 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1890 hotkeys_page.hotkeys_cont_enable = vbox;
1893 label = gtk_label_new("");
1894 markup = g_markup_printf_escaped(_("Examples for hotkeys include <b>%s</b> and <b>%s</b>"), _("<control><shift>F11"), _("<alt>N"));
1895 gtk_label_set_markup(GTK_LABEL(label), markup);
1896 gtk_misc_set_alignment(GTK_MISC(label), 0., 0.);
1898 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), label, FALSE, FALSE, 0);
1900 /* table for entry fields */
1901 table = gtk_table_new(1, 2, FALSE);
1902 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), table, FALSE, FALSE, 0);
1904 /* toggle mainwindow */
1905 label = gtk_label_new(_("Toggle minimize:"));
1906 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
1907 entry = gtk_entry_new();
1908 gtk_table_attach_defaults(GTK_TABLE(table), entry, 1, 2, 0, 1);
1909 if(notify_config.hotkeys_toggle_mainwindow)
1910 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.hotkeys_toggle_mainwindow);
1911 hotkeys_page.hotkeys_toggle_mainwindow = entry;
1913 notify_hotkeys_enable_set_sensitivity(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled), NULL);
1914 gtk_widget_show_all(pvbox);
1915 hotkeys_page.page.widget = pvbox;
1918 static void notify_destroy_hotkeys_page(PrefsPage *page)
1922 static void notify_save_hotkeys(PrefsPage *page)
1924 const gchar *tmp_str;
1925 notify_config.hotkeys_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1927 tmp_str = gtk_entry_get_text(GTK_ENTRY(hotkeys_page.hotkeys_toggle_mainwindow));
1928 if(notify_config.hotkeys_toggle_mainwindow)
1929 g_free(notify_config.hotkeys_toggle_mainwindow);
1930 notify_config.hotkeys_toggle_mainwindow = g_strdup(tmp_str);
1932 notification_hotkeys_update_bindings();
1935 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton *button,
1939 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1940 gtk_widget_set_sensitive(hotkeys_page.hotkeys_cont_enable, active);
1942 #endif /* hotkeys */
1945 /* This feels so wrong... */
1946 static gint conv_color_to_int(GdkColor *color)
1949 guint red, green, blue;
1951 red = (guint) ((gdouble)(color->red) /65535.*255.);
1952 green = (guint) ((gdouble)(color->green) /65535.*255.);
1953 blue = (guint) ((gdouble)(color->blue) /65535.*255.);
1955 result = (gint) (blue | (green<<8)| (red<<16));