Remove inclusion of sys/socket.h from nntp-thread.c
[claws.git] / src / plugins / notification / notification_prefs.c
blob172a41bed1ec184204f0781ae51ac8f7ee8302e1
1 /*
2 * Notification plugin for Claws-Mail
3 * Claws Mail -- A GTK based, lightweight, and fast e-mail client
4 * Copyright (C) 2005-2021 the Claws Mail team and Holger Berndt
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 # include "claws-features.h"
23 #endif
25 #include <glib.h>
26 #include <glib/gi18n.h>
28 #include <math.h>
30 #include "prefs_gtk.h"
31 #include "common/prefs.h"
32 #include "common/utils.h"
33 #include "common/defs.h"
34 #include "gtk/gtkutils.h"
35 #include "gtk/filesel.h"
36 #include "main.h"
38 #include "notification_prefs.h"
39 #include "notification_plugin.h"
40 #include "notification_core.h"
42 #include "notification_popup.h"
43 #include "notification_command.h"
44 #include "notification_lcdproc.h"
45 #include "notification_trayicon.h"
46 #include "notification_indicator.h"
48 #ifdef GDK_WINDOWING_X11
49 #include "notification_hotkeys.h"
50 #include <gdk/gdkx.h>
51 #endif
53 #include "notification_foldercheck.h"
55 #ifdef HAVE_LIBNOTIFY
56 /* allow infinite timeout with libnotify */
57 # define TIMEOUT_SPINNER_MIN 0.0
58 #else
59 /* don't allow infinite timeout with self-handled popups */
60 # define TIMEOUT_SPINNER_MIN 0.2
61 #endif
63 #define TIMEOUT_SPINNER_MAX 3600.0
64 #define TIMEOUT_SPINNER_STEP 0.5
66 typedef struct
68 PrefsPage page;
69 GtkWidget *include_mail;
70 GtkWidget *include_news;
71 GtkWidget *include_rss;
72 GtkWidget *include_calendar;
73 GtkWidget *urgency_hint_new;
74 GtkWidget *urgency_hint_unread;
75 #ifdef HAVE_LIBCANBERRA_GTK
76 GtkWidget *canberra_play_sounds;
77 #endif
78 } NotifyPage;
80 NotifyPrefs notify_config;
81 NotifyPage notify_page;
83 #ifdef NOTIFICATION_BANNER
84 typedef struct {
85 PrefsPage page;
86 GtkWidget *banner_show;
87 GtkWidget *banner_speed;
88 GtkWidget *banner_width;
89 GtkWidget *banner_include_unread;
90 GtkWidget *banner_max_msgs;
91 GtkWidget *banner_sticky;
92 GtkWidget *banner_folder_specific;
93 GtkWidget *banner_enable_colors;
94 GtkWidget *banner_color_bg;
95 GtkWidget *banner_color_fg;
96 GtkWidget *banner_cont_enable;
97 GtkWidget *banner_cont_folder_specific;
98 GtkWidget *banner_cont_color_sel;
99 }NotifyBannerPage;
100 NotifyBannerPage banner_page;
101 #endif /* NOTIFICATION_BANNER */
103 #ifdef NOTIFICATION_POPUP
104 typedef struct {
105 PrefsPage page;
106 GtkWidget *popup_show;
107 GtkWidget *popup_timeout;
108 GtkWidget *popup_folder_specific;
109 GtkWidget *popup_cont_enable;
110 GtkWidget *popup_cont_folder_specific;
111 #ifndef HAVE_LIBNOTIFY
112 GtkWidget *popup_sticky;
113 GtkWidget *popup_enable_colors;
114 GtkWidget *popup_color_bg;
115 GtkWidget *popup_color_fg;
116 GtkWidget *popup_cont_color_sel;
117 #else /* HAVE_LIBNOTIFY */
118 GtkWidget *popup_display_folder_name;
119 #endif /* HAVE_LIBNOTIFY */
120 }NotifyPopupPage;
121 NotifyPopupPage popup_page;
122 #endif /* NOTIFICATION_POPUP */
124 #ifdef NOTIFICATION_COMMAND
125 typedef struct {
126 PrefsPage page;
127 GtkWidget *command_enabled;
128 GtkWidget *command_timeout;
129 GtkWidget *command_folder_specific;
130 GtkWidget *command_line;
131 GtkWidget *command_cont_enable;
132 GtkWidget *command_cont_folder_specific;
133 }NotifyCommandPage;
134 NotifyCommandPage command_page;
135 #endif /* NOTIFICATION_COMMAND */
137 #ifdef NOTIFICATION_LCDPROC
138 typedef struct {
139 PrefsPage page;
140 GtkWidget *lcdproc_enabled;
141 GtkWidget *lcdproc_cont_enable;
142 GtkWidget *lcdproc_hostname;
143 GtkWidget *lcdproc_port;
144 }NotifyLCDProcPage;
145 NotifyLCDProcPage lcdproc_page;
146 #endif
148 #ifdef NOTIFICATION_TRAYICON
149 typedef struct {
150 PrefsPage page;
151 GtkWidget *trayicon_enabled;
152 GtkWidget *trayicon_cont_enable;
153 GtkWidget *trayicon_hide_at_startup;
154 GtkWidget *trayicon_close_to_tray;
155 GtkWidget *trayicon_hide_when_iconified;
156 GtkWidget *trayicon_folder_specific;
157 GtkWidget *trayicon_cont_folder_specific;
158 #ifdef HAVE_LIBNOTIFY
159 GtkWidget *trayicon_display_folder_name;
160 GtkWidget *trayicon_popup_enabled;
161 GtkWidget *trayicon_popup_cont_enable;
162 GtkWidget *trayicon_popup_timeout;
163 #endif
164 }NotifyTrayiconPage;
165 NotifyTrayiconPage trayicon_page;
166 #endif
168 #ifdef NOTIFICATION_INDICATOR
169 typedef struct {
170 PrefsPage page;
171 GtkWidget *indicator_enabled;
172 GtkWidget *indicator_cont_enable;
173 GtkWidget *indicator_hide_minimized;
174 }NotifyIndicatorPage;
175 NotifyIndicatorPage indicator_page;
176 #endif
178 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
179 typedef struct {
180 PrefsPage page;
181 GtkWidget *hotkeys_enabled;
182 GtkWidget *hotkeys_cont_enable;
183 GtkWidget *hotkeys_toggle_mainwindow;
184 }NotifyHotkeysPage;
185 NotifyHotkeysPage hotkeys_page;
186 #endif
189 PrefParam
190 notify_param[] =
193 { "include_mail", "TRUE", &notify_config.include_mail, P_BOOL, NULL,
194 NULL, NULL },
195 { "include_news", "TRUE", &notify_config.include_news, P_BOOL, NULL,
196 NULL, NULL },
197 { "include_rss", "TRUE", &notify_config.include_rss, P_BOOL, NULL,
198 NULL, NULL },
199 { "include_calendar", "TRUE", &notify_config.include_calendar, P_BOOL,
200 NULL, NULL, NULL },
201 { "urgency_hint_new", "FALSE", &notify_config.urgency_hint_new, P_BOOL,
202 NULL, NULL, NULL },
203 { "urgency_hint_unread", "FALSE", &notify_config.urgency_hint_unread, P_BOOL,
204 NULL, NULL, NULL },
206 #ifdef HAVE_LIBCANBERRA_GTK
207 { "canberra_play_sounds", "TRUE", &notify_config.canberra_play_sounds, P_BOOL,
208 NULL, NULL, NULL },
209 #endif
211 #ifdef NOTIFICATION_BANNER
212 { "banner_show", "0", &notify_config.banner_show, P_INT, NULL, NULL, NULL},
213 { "banner_speed", "30", &notify_config.banner_speed, P_INT, NULL, NULL, NULL},
214 { "banner_width", "0", &notify_config.banner_width, P_INT, NULL, NULL, NULL},
215 { "banner_include_unread", "FALSE", &notify_config.banner_include_unread,
216 P_BOOL, NULL, NULL, NULL},
217 { "banner_max_msgs", "100", &notify_config.banner_max_msgs, P_INT,
218 NULL, NULL, NULL},
219 { "banner_sticky", "FALSE", &notify_config.banner_sticky,
220 P_BOOL, NULL, NULL, NULL},
221 { "banner_root_x", "0", &notify_config.banner_root_x, P_INT,
222 NULL, NULL, NULL},
223 { "banner_root_y", "10", &notify_config.banner_root_y, P_INT,
224 NULL, NULL, NULL},
225 { "banner_folder_specific", "FALSE", &notify_config.banner_folder_specific,
226 P_BOOL, NULL, NULL, NULL},
227 { "banner_enable_colors", "FALSE", &notify_config.banner_enable_colors,
228 P_BOOL, NULL, NULL, NULL},
229 { "banner_color_bg", "0", &notify_config.banner_color_bg, P_COLOR,
230 NULL, NULL, NULL},
231 { "banner_color_fg", "16776704", &notify_config.banner_color_fg, P_COLOR,
232 NULL, NULL, NULL},
233 #endif
235 #ifdef NOTIFICATION_POPUP
236 { "popup_show", "TRUE", &notify_config.popup_show, P_BOOL, NULL, NULL, NULL},
237 { "popup_timeout", "5000", &notify_config.popup_timeout,
238 P_INT, NULL, NULL, NULL},
239 { "popup_folder_specific", "FALSE", &notify_config.popup_folder_specific,
240 P_BOOL, NULL, NULL, NULL},
241 #ifndef HAVE_LIBNOTIFY
242 { "popup_sticky", "TRUE", &notify_config.popup_sticky, P_BOOL,
243 NULL, NULL, NULL},
244 { "popup_root_x", "10", &notify_config.popup_root_x,
245 P_INT, NULL, NULL, NULL},
246 { "popup_root_y", "10", &notify_config.popup_root_y,
247 P_INT, NULL, NULL, NULL},
248 { "popup_width", "100", &notify_config.popup_width,
249 P_INT, NULL, NULL, NULL},
250 { "popup_enable_colors", "FALSE", &notify_config.popup_enable_colors, P_BOOL,
251 NULL, NULL, NULL},
252 { "popup_color_bg", "0", &notify_config.popup_color_bg, P_COLOR,
253 NULL, NULL, NULL},
254 { "popup_color_fg", "16776704", &notify_config.popup_color_fg, P_COLOR,
255 NULL, NULL, NULL},
256 #else /* HAVE_LIBNOTIFY */
257 { "popup_display_folder_name", "FALSE", &notify_config.popup_display_folder_name,
258 P_BOOL, NULL, NULL, NULL},
259 #endif /* HAVE_LIBNOTIFY */
260 #endif
262 #ifdef NOTIFICATION_COMMAND
263 { "command_enabled", "FALSE", &notify_config.command_enabled, P_BOOL,
264 NULL, NULL, NULL},
265 { "command_timeout", "60000", &notify_config.command_timeout, P_INT,
266 NULL, NULL, NULL},
267 { "command_folder_specific", "FALSE", &notify_config.command_folder_specific,
268 P_BOOL, NULL, NULL, NULL},
269 { "command_line", "", &notify_config.command_line, P_STRING,
270 NULL, NULL, NULL},
271 #endif
273 #ifdef NOTIFICATION_LCDPROC
274 { "lcdproc_enabled", "FALSE", &notify_config.lcdproc_enabled, P_BOOL,
275 NULL, NULL, NULL},
276 { "lcdproc_hostname", "localhost", &notify_config.lcdproc_hostname, P_STRING,
277 NULL, NULL, NULL},
278 { "lcdproc_port", "13666", &notify_config.lcdproc_port, P_INT,
279 NULL, NULL, NULL},
280 #endif
282 #ifdef NOTIFICATION_TRAYICON
283 #ifndef G_OS_WIN32
284 { "trayicon_enabled", "FALSE", &notify_config.trayicon_enabled, P_BOOL,
285 NULL, NULL, NULL},
286 #else
287 { "trayicon_enabled", "TRUE", &notify_config.trayicon_enabled, P_BOOL,
288 NULL, NULL, NULL},
289 #endif
290 { "trayicon_hide_at_startup", "FALSE",
291 &notify_config.trayicon_hide_at_startup, P_BOOL, NULL, NULL, NULL},
292 { "trayicon_close_to_tray", "FALSE",
293 &notify_config.trayicon_close_to_tray, P_BOOL, NULL, NULL, NULL},
294 { "trayicon_hide_when_iconified", "FALSE",
295 &notify_config.trayicon_hide_when_iconified, P_BOOL, NULL, NULL, NULL},
296 { "trayicon_folder_specific", "FALSE",
297 &notify_config.trayicon_folder_specific,
298 P_BOOL, NULL, NULL, NULL},
299 #ifdef HAVE_LIBNOTIFY
300 { "trayicon_display_folder_name", "FALSE",
301 &notify_config.trayicon_display_folder_name,
302 P_BOOL, NULL, NULL, NULL},
303 { "trayicon_popup_enabled", "TRUE", &notify_config.trayicon_popup_enabled,
304 P_BOOL, NULL, NULL, NULL},
305 { "trayicon_popup_timeout", "5000", &notify_config.trayicon_popup_timeout,
306 P_INT, NULL, NULL, NULL},
307 #endif /* HAVE_LIBNOTIFY */
308 #endif
310 #ifdef NOTIFICATION_INDICATOR
311 { "indicator_enabled", "FALSE", &notify_config.indicator_enabled, P_BOOL,
312 NULL, NULL, NULL},
313 { "indicator_hide_minimized", "FALSE", &notify_config.indicator_hide_minimized, P_BOOL,
314 NULL, NULL, NULL},
315 #endif /* NOTIFICATION_INDICATOR */
316 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
317 { "hotkeys_enabled", "FALSE", &notify_config.hotkeys_enabled, P_BOOL,
318 NULL, NULL, NULL},
319 { "hotkeys_toggle_mainwindow", "", &notify_config.hotkeys_toggle_mainwindow,
320 P_STRING, NULL, NULL, NULL},
321 #endif /* NOTIFICATION_HOTKEYS */
322 { NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL } };
324 static void notify_create_prefs_page(PrefsPage*, GtkWindow*, gpointer);
325 static void notify_destroy_prefs_page(PrefsPage*);
326 static void notify_save_prefs(PrefsPage*);
328 #ifdef NOTIFICATION_BANNER
329 static void notify_create_banner_page(PrefsPage*, GtkWindow*, gpointer);
330 static void notify_destroy_banner_page(PrefsPage*);
331 static void notify_save_banner(PrefsPage*);
332 static void notify_banner_enable_set_sensitivity(GtkComboBox*, gpointer);
333 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
334 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton*,
335 gpointer);
336 #endif
338 #ifdef NOTIFICATION_POPUP
339 static void notify_create_popup_page(PrefsPage*, GtkWindow*, gpointer);
340 static void notify_destroy_popup_page(PrefsPage*);
341 static void notify_save_popup(PrefsPage*);
342 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton*,
343 gpointer);
344 static void notify_popup_enable_set_sensitivity(GtkToggleButton*, gpointer);
345 #ifndef HAVE_LIBNOTIFY
346 static void notify_popup_set_done_cb(GtkWidget*, gpointer);
347 static void notify_popup_set_cb(GtkWidget*, gpointer);
348 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
349 #endif /* !HAVE_LIBNOTIFY */
350 #endif
352 #ifdef NOTIFICATION_COMMAND
353 static void notify_command_browse_cb(GtkWidget* widget, gpointer data);
354 static void notify_create_command_page(PrefsPage*, GtkWindow*, gpointer);
355 static void notify_destroy_command_page(PrefsPage*);
356 static void notify_save_command(PrefsPage*);
357 static void notify_command_enable_set_sensitivity(GtkToggleButton*, gpointer);
358 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton*,
359 gpointer);
360 #endif
362 #ifdef NOTIFICATION_LCDPROC
363 static void notify_create_lcdproc_page(PrefsPage*, GtkWindow*, gpointer);
364 static void notify_destroy_lcdproc_page(PrefsPage*);
365 static void notify_save_lcdproc(PrefsPage*);
366 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton*, gpointer);
367 #endif
369 #ifdef NOTIFICATION_TRAYICON
370 static void notify_create_trayicon_page(PrefsPage*, GtkWindow*, gpointer);
371 static void notify_destroy_trayicon_page(PrefsPage*);
372 static void notify_save_trayicon(PrefsPage*);
373 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton*, gpointer);
374 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton*,
375 gpointer);
376 #ifdef HAVE_LIBNOTIFY
377 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton*,
378 gpointer);
379 #endif
380 #endif
382 #ifdef NOTIFICATION_INDICATOR
383 static void notify_create_indicator_page(PrefsPage*, GtkWindow*, gpointer);
384 static void notify_destroy_indicator_page(PrefsPage*);
385 static void notify_save_indicator(PrefsPage*);
386 static void notify_indicator_enable_set_sensitivity(GtkToggleButton*, gpointer);
387 #endif /* NOTIFICATION_INDICATOR */
389 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
390 static void notify_create_hotkeys_page(PrefsPage*, GtkWindow*, gpointer);
391 static void notify_destroy_hotkeys_page(PrefsPage*);
392 static void notify_save_hotkeys(PrefsPage*);
393 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton*, gpointer);
394 #endif /* NOTIFICATION_HOTKEYS */
397 void notify_gtk_init(void)
399 static gchar *path[3];
401 path[0] = _("Plugins");
402 path[1] = _("Notification");
403 path[2] = NULL;
405 notify_page.page.path = path;
406 notify_page.page.create_widget = notify_create_prefs_page;
407 notify_page.page.destroy_widget = notify_destroy_prefs_page;
408 notify_page.page.save_page = notify_save_prefs;
409 notify_page.page.weight = 40.0;
410 prefs_gtk_register_page((PrefsPage*) &notify_page);
412 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
413 if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
415 static gchar *hotkeys_path[4];
417 hotkeys_path[0] = _("Plugins");
418 hotkeys_path[1] = _("Notification");
419 hotkeys_path[2] = _("Hotkeys");
420 hotkeys_path[3] = NULL;
422 hotkeys_page.page.path = hotkeys_path;
423 hotkeys_page.page.create_widget = notify_create_hotkeys_page;
424 hotkeys_page.page.destroy_widget = notify_destroy_hotkeys_page;
425 hotkeys_page.page.save_page = notify_save_hotkeys;
426 hotkeys_page.page.weight = 10.0;
427 prefs_gtk_register_page((PrefsPage*) &hotkeys_page);
429 #endif /* NOTIFICATION_HOTKEYS */
432 #ifdef NOTIFICATION_BANNER
434 static gchar *banner_path[4];
436 banner_path[0] = _("Plugins");
437 banner_path[1] = _("Notification");
438 banner_path[2] = _("Banner");
439 banner_path[3] = NULL;
441 banner_page.page.path = banner_path;
442 banner_page.page.create_widget = notify_create_banner_page;
443 banner_page.page.destroy_widget = notify_destroy_banner_page;
444 banner_page.page.save_page = notify_save_banner;
445 banner_page.page.weight = 20.0;
446 prefs_gtk_register_page((PrefsPage*) &banner_page);
448 #endif /* NOTIFICATION_BANNER */
450 #ifdef NOTIFICATION_POPUP
452 static gchar *popup_path[4];
454 popup_path[0] = _("Plugins");
455 popup_path[1] = _("Notification");
456 popup_path[2] = _("Popup");
457 popup_path[3] = NULL;
459 popup_page.page.path = popup_path;
460 popup_page.page.create_widget = notify_create_popup_page;
461 popup_page.page.destroy_widget = notify_destroy_popup_page;
462 popup_page.page.save_page = notify_save_popup;
463 popup_page.page.weight = 30.0;
464 prefs_gtk_register_page((PrefsPage*) &popup_page);
466 #endif /* NOTIFICATION_POPUP */
468 #ifdef NOTIFICATION_COMMAND
470 static gchar *command_path[4];
472 command_path[0] = _("Plugins");
473 command_path[1] = _("Notification");
474 command_path[2] = _("Command");
475 command_path[3] = NULL;
477 command_page.page.path = command_path;
478 command_page.page.create_widget = notify_create_command_page;
479 command_page.page.destroy_widget = notify_destroy_command_page;
480 command_page.page.save_page = notify_save_command;
481 command_page.page.weight = 40.0;
482 prefs_gtk_register_page((PrefsPage*) &command_page);
484 #endif /* NOTIFICATION_COMMAND */
486 #ifdef NOTIFICATION_LCDPROC
488 static gchar *lcdproc_path[4];
490 lcdproc_path[0] = _("Plugins");
491 lcdproc_path[1] = _("Notification");
492 lcdproc_path[2] = _("LCD");
493 lcdproc_path[3] = NULL;
495 lcdproc_page.page.path = lcdproc_path;
496 lcdproc_page.page.create_widget = notify_create_lcdproc_page;
497 lcdproc_page.page.destroy_widget = notify_destroy_lcdproc_page;
498 lcdproc_page.page.save_page = notify_save_lcdproc;
499 lcdproc_page.page.weight = 50.0;
500 prefs_gtk_register_page((PrefsPage*) &lcdproc_page);
502 #endif /* NOTIFICATION_LCDPROC */
504 #ifdef NOTIFICATION_TRAYICON
506 static gchar *trayicon_path[4];
508 trayicon_path[0] = _("Plugins");
509 trayicon_path[1] = _("Notification");
510 trayicon_path[2] = _("SysTrayicon");
511 trayicon_path[3] = NULL;
513 trayicon_page.page.path = trayicon_path;
514 trayicon_page.page.create_widget = notify_create_trayicon_page;
515 trayicon_page.page.destroy_widget = notify_destroy_trayicon_page;
516 trayicon_page.page.save_page = notify_save_trayicon;
517 trayicon_page.page.weight = 60.0;
518 prefs_gtk_register_page((PrefsPage*) &trayicon_page);
520 #endif /* NOTIFICATION_TRAYICON */
522 #ifdef NOTIFICATION_INDICATOR
524 static gchar *indicator_path[4];
526 indicator_path[0] = _("Plugins");
527 indicator_path[1] = _("Notification");
528 indicator_path[2] = _("Indicator");
529 indicator_path[3] = NULL;
531 indicator_page.page.path = indicator_path;
532 indicator_page.page.create_widget = notify_create_indicator_page;
533 indicator_page.page.destroy_widget = notify_destroy_indicator_page;
534 indicator_page.page.save_page = notify_save_indicator;
535 indicator_page.page.weight = 70.0;
536 prefs_gtk_register_page((PrefsPage*) &indicator_page);
538 #endif /* NOTIFICATION_INDICATOR */
541 void notify_gtk_done(void)
543 if (claws_is_exiting())
544 return;
545 prefs_gtk_unregister_page((PrefsPage*) &notify_page);
546 #ifdef NOTIFICATION_BANNER
547 prefs_gtk_unregister_page((PrefsPage*) &banner_page);
548 #endif
549 #ifdef NOTIFICATION_POPUP
550 prefs_gtk_unregister_page((PrefsPage*) &popup_page);
551 #endif
552 #ifdef NOTIFICATION_COMMAND
553 prefs_gtk_unregister_page((PrefsPage*) &command_page);
554 #endif
555 #ifdef NOTIFICATION_LCDPROC
556 prefs_gtk_unregister_page((PrefsPage*) &lcdproc_page);
557 #endif
558 #ifdef NOTIFICATION_TRAYICON
559 prefs_gtk_unregister_page((PrefsPage*) &trayicon_page);
560 #endif
561 #ifdef NOTIFICATION_INDICATOR
562 prefs_gtk_unregister_page((PrefsPage*) &indicator_page);
563 #endif
564 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
565 prefs_gtk_unregister_page((PrefsPage*) &hotkeys_page);
566 #endif
569 void notify_save_config(void)
571 PrefFile *pfile;
572 gchar *rcpath;
574 debug_print("Saving Notification plugin configuration...\n");
576 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
577 pfile = prefs_write_open(rcpath);
578 g_free(rcpath);
579 if (!pfile || (prefs_set_block_label(pfile, "NotificationPlugin") < 0))
580 return;
582 if (prefs_write_param(notify_param, pfile->fp) < 0) {
583 debug_print("failed!\n");
584 g_warning("notification plugin: failed to write plugin configuration "
585 "to file");
586 prefs_file_close_revert(pfile);
587 return;
589 if (fprintf(pfile->fp, "\n") < 0) {
590 FILE_OP_ERROR(rcpath, "fprintf");
591 prefs_file_close_revert(pfile);
593 else
594 prefs_file_close(pfile);
595 debug_print("done.\n");
598 static void notify_create_prefs_page(PrefsPage *page, GtkWindow *window,
599 gpointer data)
601 GtkWidget *pvbox;
602 GtkWidget *vbox;
603 GtkWidget *checkbox;
604 GtkWidget *frame;
605 GtkWidget *label;
607 /* Page vbox */
608 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
610 /* Frame */
611 PACK_FRAME (pvbox, frame, _("Include folder types"))
612 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
614 /* Frame vbox */
615 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
616 gtk_container_add(GTK_CONTAINER(frame), vbox);
617 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
619 /* Include mail folders */
620 checkbox = gtk_check_button_new_with_label(_("Mail folders"));
621 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
622 notify_config.include_mail);
623 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
624 gtk_widget_show(checkbox);
625 notify_page.include_mail = checkbox;
627 /* Include news folders */
628 checkbox = gtk_check_button_new_with_label(_("News folders"));
629 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
630 notify_config.include_news);
631 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
632 gtk_widget_show(checkbox);
633 notify_page.include_news = checkbox;
635 /* Include RSSyl folders */
636 checkbox = gtk_check_button_new_with_label(_("RSSyl folders"));
637 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
638 notify_config.include_rss);
639 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
640 gtk_widget_show(checkbox);
641 notify_page.include_rss = checkbox;
643 /* Include calendar folders */
644 checkbox = gtk_check_button_new_with_label(_("vCalendar folders"));
645 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
646 notify_config.include_calendar);
647 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
648 gtk_widget_show(checkbox);
649 notify_page.include_calendar = checkbox;
651 /* Warning-Label */
652 label = gtk_label_new(_("These settings override folder-specific "
653 "selections."));
654 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
655 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
656 gtk_widget_show(label);
658 /* done with the frame */
659 gtk_widget_show(frame);
660 gtk_widget_show(vbox);
662 /* Frame */
663 PACK_FRAME (pvbox, frame, _("Global notification settings"));
664 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
666 /* Frame vbox */
667 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
668 gtk_container_add(GTK_CONTAINER(frame), vbox);
669 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
671 /* urgency hint new */
672 checkbox = gtk_check_button_new_with_label(_("Set window manager "
673 "urgency hint when new messages exist"));
674 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
675 notify_config.urgency_hint_new);
676 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
677 gtk_widget_show(checkbox);
678 notify_page.urgency_hint_new = checkbox;
680 /* urgency hint new */
681 checkbox = gtk_check_button_new_with_label(_("Set window manager "
682 "urgency hint when unread messages exist"));
683 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
684 notify_config.urgency_hint_unread);
685 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
686 gtk_widget_show(checkbox);
687 notify_page.urgency_hint_unread = checkbox;
689 #ifdef HAVE_LIBCANBERRA_GTK
690 /* canberra */
691 checkbox = gtk_check_button_new_with_label(_("Use sound theme"));
692 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
693 notify_config.canberra_play_sounds);
694 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
695 gtk_widget_show(checkbox);
696 notify_page.canberra_play_sounds = checkbox;
697 #endif
699 /* done with the frame */
700 gtk_widget_show(frame);
701 gtk_widget_show(vbox);
703 /* done with the page */
704 gtk_widget_show(pvbox);
705 page->widget = pvbox;
708 static void notify_destroy_prefs_page(PrefsPage *page)
712 static void notify_save_prefs(PrefsPage *page)
714 notify_config.include_mail =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_mail));
715 notify_config.include_news =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_news));
716 notify_config.include_rss =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_rss));
717 notify_config.include_calendar
718 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_calendar));
719 notify_config.urgency_hint_new = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_new));
720 notify_config.urgency_hint_unread = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_unread));
721 #ifdef HAVE_LIBCANBERRA_GTK
722 notify_config.canberra_play_sounds = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.canberra_play_sounds));
723 #endif
725 notification_core_global_includes_changed();
728 #ifdef NOTIFICATION_BANNER
729 static void notify_banner_slider_add_cb(GtkWidget *widget, gpointer data)
731 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
732 gtk_range_set_value(slider, gtk_range_get_value(slider) - 1.0);
735 static void notify_banner_slider_remove_cb(GtkWidget *widget, gpointer data)
737 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
738 gtk_range_set_value(slider, gtk_range_get_value(slider) + 1.0);
741 static void notify_create_banner_page(PrefsPage *page, GtkWindow *window,
742 gpointer data)
744 GtkRequisition requisition;
745 GtkWidget *pvbox;
746 GtkWidget *vbox;
747 GtkWidget *hbox;
748 GtkWidget *chbox, *cvbox, *cframe;
749 GtkWidget *checkbox;
750 GtkWidget *button;
751 GtkWidget *combo;
752 GtkWidget *spinner;
753 GtkWidget *label;
754 GtkWidget *slider;
755 GtkWidget *color_sel;
757 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
758 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
760 /* Always / Never / Only when non-empty */
761 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
762 gtk_box_pack_start(GTK_BOX(pvbox), hbox, FALSE, FALSE, 0);
763 label = gtk_label_new(_("Show banner"));
764 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
765 gtk_widget_show(label);
766 combo = gtk_combo_box_text_new();
767 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_NEVER,
768 _("Never"));
769 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_ALWAYS,
770 _("Always"));
771 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_NONEMPTY,
772 _("Only when not empty"));
773 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), notify_config.banner_show);
774 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
775 g_signal_connect(G_OBJECT(combo), "changed",
776 G_CALLBACK(notify_banner_enable_set_sensitivity), NULL);
777 gtk_widget_show(combo);
778 gtk_widget_show(hbox);
779 banner_page.banner_show = combo;
781 /* Container vbox for greying out everything */
782 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
783 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
784 gtk_widget_show(vbox);
785 banner_page.banner_cont_enable = vbox;
787 /* Banner speed */
788 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
789 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
791 label = gtk_label_new(_("Banner speed"));
792 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
793 gtk_widget_show(label);
795 slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 10., 70., 10.);
796 gtk_scale_set_digits(GTK_SCALE(slider), 0);
797 gtk_widget_get_preferred_size(combo, &requisition, NULL);
798 gtk_widget_set_size_request(slider, requisition.width, -1);
799 gtk_range_set_increments(GTK_RANGE(slider), 10., 10.);
800 gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
801 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
802 gtk_range_set_value(GTK_RANGE(slider), notify_config.banner_speed);
804 button = gtk_button_new();
805 gtk_button_set_image(GTK_BUTTON(button),
806 gtk_image_new_from_icon_name("list-remove", GTK_ICON_SIZE_MENU));
807 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
808 g_signal_connect(G_OBJECT(button), "clicked",
809 G_CALLBACK(notify_banner_slider_remove_cb), slider);
810 gtk_widget_show(button);
812 gtk_box_pack_start(GTK_BOX(hbox), slider, TRUE, TRUE, 0);
813 gtk_widget_show(slider);
815 button = gtk_button_new();
816 gtk_button_set_image(GTK_BUTTON(button),
817 gtk_image_new_from_icon_name("list-add", GTK_ICON_SIZE_MENU));
818 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
819 g_signal_connect(G_OBJECT(button), "clicked",
820 G_CALLBACK(notify_banner_slider_add_cb), slider);
821 gtk_widget_show(button);
823 gtk_widget_show(hbox);
824 banner_page.banner_speed = slider;
826 /* Maximum number of messages in banner */
827 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
828 label = gtk_label_new(_("Maximum number of messages"));
829 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
830 gtk_widget_show(label);
831 spinner = gtk_spin_button_new_with_range(0., 1000., 1.);
832 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
833 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), notify_config.banner_max_msgs);
834 CLAWS_SET_TIP (spinner, _("Limit the number of messages shown, use 0 for unlimited"));
835 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
836 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
837 gtk_widget_show(spinner);
838 gtk_widget_show(hbox);
839 banner_page.banner_max_msgs = spinner;
841 /* banner width */
842 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
843 label = gtk_label_new(_("Banner width"));
844 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
845 gtk_widget_show(label);
846 spinner = gtk_spin_button_new_with_range(0.,5000., 50);
847 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner),0);
848 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),notify_config.banner_width);
849 CLAWS_SET_TIP (spinner, _("Limit the size of banner, use 0 for screen width"));
850 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
851 label = gtk_label_new(_("pixel(s)"));
852 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
853 gtk_widget_show(label);
854 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
855 gtk_widget_show(spinner);
856 gtk_widget_show(hbox);
857 banner_page.banner_width = spinner;
859 /* Include unread */
860 checkbox = gtk_check_button_new_with_label(_("Include unread mails in banner"));
861 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
862 notify_config.banner_include_unread);
863 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
864 gtk_widget_show(checkbox);
865 banner_page.banner_include_unread = checkbox;
867 /* Check button sticky */
868 checkbox = gtk_check_button_new_with_label(_("Make banner sticky"));
869 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
870 notify_config.banner_sticky);
871 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
872 gtk_widget_show(checkbox);
873 banner_page.banner_sticky = checkbox;
875 /* Check box for enabling folder specific selection */
876 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
877 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
878 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
879 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
880 notify_config.banner_folder_specific);
881 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
882 g_signal_connect(G_OBJECT(checkbox), "toggled",
883 G_CALLBACK(notify_banner_folder_specific_set_sensitivity),
884 NULL);
885 gtk_widget_show(checkbox);
886 banner_page.banner_folder_specific = checkbox;
887 button = gtk_button_new_with_label(_("Select folders..."));
888 g_signal_connect(G_OBJECT(button), "clicked",
889 G_CALLBACK(notification_foldercheck_sel_folders_cb),
890 BANNER_SPECIFIC_FOLDER_ID_STR);
891 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
892 banner_page.banner_cont_folder_specific = button;
893 gtk_widget_show(button);
894 gtk_widget_show(hbox);
896 /* Check box for enabling custom colors */
897 cvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
898 gtk_widget_show(cvbox);
899 PACK_FRAME (vbox, cframe, _("Banner colors"))
900 gtk_container_set_border_width(GTK_CONTAINER(cvbox), 5);
901 gtk_container_add(GTK_CONTAINER(cframe), cvbox);
903 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
904 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
905 notify_config.banner_enable_colors);
906 gtk_box_pack_start(GTK_BOX(cvbox), checkbox, FALSE, FALSE, 0);
907 g_signal_connect(G_OBJECT(checkbox), "toggled",
908 G_CALLBACK(notify_banner_color_sel_set_sensitivity), NULL);
909 gtk_widget_show(checkbox);
910 banner_page.banner_enable_colors = checkbox;
912 /* Color selection dialogs for foreground and background color */
913 /* foreground */
914 chbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
915 gtk_box_pack_start(GTK_BOX(cvbox), chbox, FALSE, FALSE, 0);
916 gtk_widget_show(chbox);
918 label = gtk_label_new(_("Foreground"));
919 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
920 gtk_widget_show(label);
921 color_sel = gtk_color_button_new_with_rgba(&notify_config.banner_color_fg);
922 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
923 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
924 gtk_widget_show(color_sel);
925 banner_page.banner_color_fg = color_sel;
926 /* background */
927 label = gtk_label_new(_("Background"));
928 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
929 gtk_widget_show(label);
930 color_sel = gtk_color_button_new_with_rgba(&notify_config.banner_color_bg);
931 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel), _("Background color"));
932 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
933 gtk_widget_show(color_sel);
934 banner_page.banner_color_bg = color_sel;
935 banner_page.banner_cont_color_sel = chbox;
937 notify_banner_color_sel_set_sensitivity
938 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors), NULL);
939 notify_banner_folder_specific_set_sensitivity
940 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific), NULL);
941 notify_banner_enable_set_sensitivity(GTK_COMBO_BOX(combo), NULL);
942 gtk_widget_show(pvbox);
943 banner_page.page.widget = pvbox;
946 static void notify_destroy_banner_page(PrefsPage *page)
950 static void notify_save_banner(PrefsPage *page)
952 gdouble range_val;
954 notify_config.banner_show =
955 gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
956 notify_config.banner_max_msgs =
957 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_max_msgs));
958 notify_config.banner_width =
959 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_width));
960 notify_config.banner_include_unread =
961 gtk_toggle_button_get_active
962 (GTK_TOGGLE_BUTTON(banner_page.banner_include_unread));
963 range_val= gtk_range_get_value(GTK_RANGE(banner_page.banner_speed));
964 notify_config.banner_speed = (gint)ceil(range_val);
966 notify_config.banner_sticky =
967 gtk_toggle_button_get_active
968 (GTK_TOGGLE_BUTTON(banner_page.banner_sticky));
970 notify_config.banner_folder_specific =
971 gtk_toggle_button_get_active
972 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
974 notify_config.banner_enable_colors =
975 gtk_toggle_button_get_active
976 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
978 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(banner_page.banner_color_fg),
979 &notify_config.banner_color_fg);
980 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(banner_page.banner_color_bg),
981 &notify_config.banner_color_bg);
983 notification_banner_destroy();
984 notification_update_banner();
987 static void notify_banner_enable_set_sensitivity(GtkComboBox *combo,
988 gpointer data)
990 NotifyBannerShow show;
992 show = gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
993 gtk_widget_set_sensitive(banner_page.banner_cont_enable,
994 (show == NOTIFY_BANNER_SHOW_NEVER) ? FALSE : TRUE);
997 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton *button,
998 gpointer data)
1000 gboolean active;
1001 active = gtk_toggle_button_get_active
1002 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
1003 gtk_widget_set_sensitive(banner_page.banner_cont_color_sel, active);
1006 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton *bu,
1007 gpointer data)
1009 gboolean active;
1010 active = gtk_toggle_button_get_active
1011 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
1012 gtk_widget_set_sensitive(banner_page.banner_cont_folder_specific, active);
1014 #endif /* NOTIFICATION_BANNER */
1016 #ifdef NOTIFICATION_POPUP
1017 static void notify_create_popup_page(PrefsPage *page, GtkWindow *window,
1018 gpointer data)
1020 gdouble timeout;
1021 GtkWidget *pvbox;
1022 GtkWidget *vbox;
1023 GtkWidget *checkbox;
1024 GtkWidget *hbox;
1025 GtkWidget *spinner;
1026 GtkWidget *label;
1027 GtkWidget *button;
1028 #ifndef HAVE_LIBNOTIFY
1029 GtkWidget *table;
1030 GtkWidget *color_sel;
1031 #endif /* !HAVE_LIBNOTIFY */
1033 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1034 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1036 /* Enable popup */
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_box_new(GTK_ORIENTATION_VERTICAL, 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;
1052 /* Popup timeout */
1053 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 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(_("seconds"));
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_box_new(GTK_ORIENTATION_HORIZONTAL, 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),
1079 NULL);
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_box_new(GTK_ORIENTATION_HORIZONTAL, 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_grid_new();
1125 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
1127 /* foreground */
1128 label = gtk_label_new(_("Foreground"));
1129 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
1130 gtk_widget_show(label);
1131 color_sel = gtk_color_button_new();
1132 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(color_sel),
1133 &notify_config.popup_color_fg);
1134 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
1135 gtk_grid_attach(GTK_GRID(table), color_sel, 1, 0, 1, 1);
1136 gtk_widget_show(color_sel);
1137 popup_page.popup_color_fg = color_sel;
1139 /* background */
1140 label = gtk_label_new(_("Background"));
1141 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
1142 gtk_widget_show(label);
1143 color_sel = gtk_color_button_new();
1144 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(color_sel),
1145 &notify_config.popup_color_bg);
1146 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Background color"));
1147 gtk_grid_attach(GTK_GRID(table), color_sel, 1, 1, 1, 1);
1148 gtk_widget_show(color_sel);
1149 gtk_widget_show(table);
1150 popup_page.popup_color_bg = color_sel;
1151 popup_page.popup_cont_color_sel = table;
1153 notify_popup_color_sel_set_sensitivity
1154 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors), NULL);
1155 #else /* HAVE_LIBNOTIFY */
1156 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1157 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1158 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1159 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1160 notify_config.popup_display_folder_name);
1161 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1162 gtk_widget_show(checkbox);
1163 gtk_widget_show(hbox);
1164 popup_page.popup_display_folder_name = checkbox;
1165 #endif /* HAVE_LIBNOTIFY */
1167 notify_popup_enable_set_sensitivity
1168 (GTK_TOGGLE_BUTTON(popup_page.popup_show), NULL);
1169 notify_popup_folder_specific_set_sensitivity
1170 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific), NULL);
1171 gtk_widget_show(pvbox);
1172 popup_page.page.widget = pvbox;
1175 static void notify_destroy_popup_page(PrefsPage *page)
1179 static void notify_save_popup(PrefsPage *page)
1181 gdouble timeout;
1183 notify_config.popup_show =
1184 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_show));
1185 timeout =
1186 gtk_spin_button_get_value(GTK_SPIN_BUTTON(popup_page.popup_timeout));
1187 notify_config.popup_timeout = (gint)floor(timeout*1000+0.5);
1188 notify_config.popup_folder_specific =
1189 gtk_toggle_button_get_active
1190 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1192 #ifndef HAVE_LIBNOTIFY
1193 notify_config.popup_sticky =
1194 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_sticky));
1195 notify_config.popup_enable_colors =
1196 gtk_toggle_button_get_active
1197 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1199 /* Color dialogs are a bit more complicated */
1200 gtk_color_button_get_rgba(GTK_COLOR_BUTTON(popup_page.popup_color_fg),
1201 &notify_config.popup_color_fg);
1202 gtk_color_button_get_rgba(GTK_COLOR_BUTTON(popup_page.popup_color_bg),
1203 &notify_config.popup_color_bg);
1204 #else /* HAVE_LIBNOTIFY */
1205 notify_config.popup_display_folder_name =
1206 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_display_folder_name));
1207 #endif /* HAVE_LIBNOTIFY */
1210 #ifndef HAVE_LIBNOTIFY
1211 static void notify_popup_set_cb(GtkWidget *widget, gpointer data)
1213 GtkWidget *win;
1214 GtkWidget *button;
1216 win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "notification_prefs");
1217 gtk_window_set_title(GTK_WINDOW(win), _("Sample popup window"));
1218 gtk_window_set_modal(GTK_WINDOW(win), TRUE);
1219 gtk_window_set_keep_above(GTK_WINDOW(win), TRUE);
1220 gtk_window_set_resizable(GTK_WINDOW(win), TRUE);
1221 gtk_container_set_border_width(GTK_CONTAINER(win), 5);
1223 button = gtk_button_new_with_label(_("Done"));
1224 g_signal_connect(G_OBJECT(button), "clicked",
1225 G_CALLBACK(notify_popup_set_done_cb), win);
1226 gtk_container_add(GTK_CONTAINER(win), button);
1228 gtk_widget_show_all(win);
1231 static void notify_popup_set_done_cb(GtkWidget *widget, gpointer data)
1233 GtkWidget *win = data;
1234 gint dummy;
1236 gtk_window_get_position(GTK_WINDOW(win),
1237 &(notify_config.popup_root_x),
1238 &(notify_config.popup_root_y));
1239 gtk_window_get_size(GTK_WINDOW(win),
1240 &(notify_config.popup_width), &dummy);
1241 gtk_widget_destroy(win);
1244 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton *button,
1245 gpointer data)
1247 gboolean active;
1248 active = gtk_toggle_button_get_active
1249 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1250 gtk_widget_set_sensitive(popup_page.popup_cont_color_sel, active);
1252 #endif /* !HAVE_LIBNOTIFY */
1254 static void notify_popup_enable_set_sensitivity(GtkToggleButton *button,
1255 gpointer data)
1257 gboolean active;
1258 active = gtk_toggle_button_get_active
1259 (GTK_TOGGLE_BUTTON(popup_page.popup_show));
1260 gtk_widget_set_sensitive(popup_page.popup_cont_enable, active);
1263 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton *bu,
1264 gpointer data)
1266 gboolean active;
1267 active = gtk_toggle_button_get_active
1268 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1269 gtk_widget_set_sensitive(popup_page.popup_cont_folder_specific, active);
1272 #endif /* NOTIFICATION_POPUP */
1274 #ifdef NOTIFICATION_COMMAND
1275 static void notify_command_browse_cb(GtkWidget* widget, gpointer data)
1277 gchar *filename;
1278 gchar *utf8_filename;
1279 GtkEntry *dest = GTK_ENTRY(data);
1281 filename = filesel_select_file_open(_("Select command"), NULL);
1282 if (!filename) return;
1284 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1285 if (!utf8_filename) {
1286 g_warning("notify_command_browse_cb(): failed to convert character set");
1287 utf8_filename = g_strdup(filename);
1289 gtk_entry_set_text(GTK_ENTRY(dest), utf8_filename);
1290 g_free(utf8_filename);
1293 static void notify_create_command_page(PrefsPage *page, GtkWindow *window,
1294 gpointer data)
1296 GtkWidget *pvbox;
1297 GtkWidget *vbox;
1298 GtkWidget *checkbox;
1299 GtkWidget *hbox;
1300 GtkWidget *spinner;
1301 GtkWidget *entry;
1302 GtkWidget *label;
1303 GtkWidget *button, *buttonb;
1304 gdouble timeout;
1306 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1307 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1309 /* Enable command */
1310 checkbox = gtk_check_button_new_with_label(_("Enable command"));
1311 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1312 notify_config.command_enabled);
1313 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1314 g_signal_connect(G_OBJECT(checkbox), "toggled",
1315 G_CALLBACK(notify_command_enable_set_sensitivity), NULL);
1316 gtk_widget_show(checkbox);
1317 command_page.command_enabled = checkbox;
1319 /* Container vbox for greying out everything */
1320 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1321 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1322 gtk_widget_show(vbox);
1323 command_page.command_cont_enable = vbox;
1325 /* entry field for command to execute */
1326 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1327 label = gtk_label_new(_("Command to execute"));
1328 gtk_widget_show(label);
1329 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1330 entry = gtk_entry_new();
1331 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.command_line);
1332 gtk_widget_show(entry);
1333 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1334 buttonb = gtkut_get_browse_file_btn(_("Bro_wse"));
1335 gtk_box_pack_start(GTK_BOX(hbox), buttonb, FALSE, FALSE, 0);
1336 g_signal_connect(G_OBJECT(buttonb), "clicked",
1337 G_CALLBACK(notify_command_browse_cb), entry);
1338 gtk_widget_show(buttonb);
1339 gtk_widget_show(hbox);
1340 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1341 command_page.command_line = entry;
1343 /* Spin button for command timeout */
1344 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1345 label = gtk_label_new(_("Block command after execution for"));
1346 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1347 gtk_widget_show(label);
1348 spinner = gtk_spin_button_new_with_range(0., 600., 1.);
1349 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1350 timeout = notify_config.command_timeout/1000.;
1351 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1352 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1353 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1354 gtk_widget_show(spinner);
1355 label = gtk_label_new(_("seconds"));
1356 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1357 gtk_widget_show(label);
1358 gtk_widget_show(hbox);
1359 command_page.command_timeout = spinner;
1361 /* Check box for enabling folder specific selection */
1362 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1363 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1364 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1365 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1366 notify_config.command_folder_specific);
1367 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1368 g_signal_connect(G_OBJECT(checkbox), "toggled",
1369 G_CALLBACK(notify_command_folder_specific_set_sensitivity),
1370 NULL);
1371 gtk_widget_show(checkbox);
1372 command_page.command_folder_specific = checkbox;
1373 button = gtk_button_new_with_label(_("Select folders..."));
1374 g_signal_connect(G_OBJECT(button), "clicked",
1375 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1376 COMMAND_SPECIFIC_FOLDER_ID_STR);
1377 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1378 command_page.command_cont_folder_specific = button;
1379 gtk_widget_show(button);
1380 gtk_widget_show(hbox);
1382 notify_command_enable_set_sensitivity
1383 (GTK_TOGGLE_BUTTON(command_page.command_enabled), NULL);
1384 notify_command_folder_specific_set_sensitivity
1385 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific), NULL);
1386 gtk_widget_show(pvbox);
1387 command_page.page.widget = pvbox;
1390 static void notify_destroy_command_page(PrefsPage *page)
1394 static void notify_save_command(PrefsPage *page)
1396 gdouble timeout;
1397 const gchar *tmp_str;
1399 notify_config.command_enabled =
1400 gtk_toggle_button_get_active
1401 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1403 timeout =
1404 gtk_spin_button_get_value(GTK_SPIN_BUTTON(command_page.command_timeout));
1405 notify_config.command_timeout = (gint)floor(timeout*1000+0.5);
1406 notify_config.command_folder_specific =
1407 gtk_toggle_button_get_active
1408 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1410 tmp_str = gtk_entry_get_text(GTK_ENTRY(command_page.command_line));
1411 if(notify_config.command_line)
1412 g_free(notify_config.command_line);
1413 notify_config.command_line = g_strdup(tmp_str);
1416 static void notify_command_enable_set_sensitivity(GtkToggleButton *button,
1417 gpointer data)
1419 gboolean active;
1420 active = gtk_toggle_button_get_active
1421 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1422 gtk_widget_set_sensitive(command_page.command_cont_enable, active);
1425 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton *bu,
1426 gpointer data)
1428 gboolean active;
1429 active = gtk_toggle_button_get_active
1430 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1431 gtk_widget_set_sensitive(command_page.command_cont_folder_specific, active);
1434 #endif /* NOTIFICATION_COMMAND */
1436 #ifdef NOTIFICATION_LCDPROC
1437 static void notify_create_lcdproc_page(PrefsPage *page, GtkWindow *window,
1438 gpointer data)
1440 GtkWidget *pvbox;
1441 GtkWidget *vbox;
1442 GtkWidget *label;
1443 GtkWidget *entry;
1444 GtkWidget *spinner;
1445 GtkWidget *checkbox;
1446 GtkWidget *hbox;
1448 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1449 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1451 /* Enable lcdproc */
1452 checkbox = gtk_check_button_new_with_label(_("Enable LCD"));
1453 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1454 notify_config.lcdproc_enabled);
1455 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1456 g_signal_connect(G_OBJECT(checkbox), "toggled",
1457 G_CALLBACK(notify_lcdproc_enable_set_sensitivity), NULL);
1458 gtk_widget_show(checkbox);
1459 lcdproc_page.lcdproc_enabled = checkbox;
1461 /* Container vbox for greying out everything */
1462 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1463 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1464 gtk_widget_show(vbox);
1465 lcdproc_page.lcdproc_cont_enable = vbox;
1467 /* Hostname and port information */
1468 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1469 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1470 gtk_widget_show(hbox);
1471 label = gtk_label_new(_("Hostname:Port of LCDd server"));
1472 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1473 entry = gtk_entry_new();
1474 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.lcdproc_hostname);
1475 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1476 gtk_widget_show(entry);
1477 gtk_widget_show(label);
1478 label = gtk_label_new(":");
1479 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1480 gtk_widget_show(label);
1481 spinner = gtk_spin_button_new_with_range(1., 65535., 1.);
1482 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1483 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),
1484 notify_config.lcdproc_port);
1485 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1486 gtk_widget_show(spinner);
1487 lcdproc_page.lcdproc_hostname = entry;
1488 lcdproc_page.lcdproc_port = spinner;
1490 notify_lcdproc_enable_set_sensitivity
1491 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled), NULL);
1492 gtk_widget_show(pvbox);
1493 lcdproc_page.page.widget = pvbox;
1496 static void notify_destroy_lcdproc_page(PrefsPage *page)
1500 static void notify_save_lcdproc(PrefsPage *page)
1502 notify_config.lcdproc_enabled =
1503 gtk_toggle_button_get_active
1504 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1506 if(notify_config.lcdproc_hostname)
1507 g_free(notify_config.lcdproc_hostname);
1508 notify_config.lcdproc_hostname =
1509 g_strdup(gtk_entry_get_text(GTK_ENTRY(lcdproc_page.lcdproc_hostname)));
1511 notify_config.lcdproc_port =
1512 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lcdproc_page.lcdproc_port));
1514 if(notify_config.lcdproc_enabled)
1515 notification_lcdproc_connect();
1516 else
1517 notification_lcdproc_disconnect();
1520 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton *button,
1521 gpointer data)
1523 gboolean active;
1524 active = gtk_toggle_button_get_active
1525 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1526 gtk_widget_set_sensitive(lcdproc_page.lcdproc_cont_enable, active);
1528 #endif /* NOTIFICATION_LCDPROC */
1530 #ifdef NOTIFICATION_TRAYICON
1531 static void notify_create_trayicon_page(PrefsPage *page, GtkWindow *window,
1532 gpointer data)
1534 GtkWidget *pvbox;
1535 GtkWidget *vbox;
1536 GtkWidget *checkbox;
1537 GtkWidget *hbox;
1538 GtkWidget *button;
1540 #if defined(HAVE_LIBNOTIFY)
1541 GtkWidget *frame;
1542 GtkWidget *svbox;
1543 GtkWidget *label;
1544 #endif
1546 #ifdef HAVE_LIBNOTIFY
1547 GtkWidget *ssvbox;
1548 GtkWidget *spinner;
1549 gdouble timeout;
1550 #endif
1552 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1553 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1555 /* Enable trayicon */
1556 checkbox = gtk_check_button_new_with_label(_("Enable Trayicon"));
1557 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1558 notify_config.trayicon_enabled);
1559 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1560 g_signal_connect(G_OBJECT(checkbox), "toggled",
1561 G_CALLBACK(notify_trayicon_enable_set_sensitivity), NULL);
1562 gtk_widget_show(checkbox);
1563 trayicon_page.trayicon_enabled = checkbox;
1565 /* Container vbox for greying out everything */
1566 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1567 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1568 gtk_widget_show(vbox);
1569 trayicon_page.trayicon_cont_enable = vbox;
1571 /* Hide at startup */
1572 checkbox = gtk_check_button_new_with_label(_("Hide at start-up"));
1573 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1574 notify_config.trayicon_hide_at_startup);
1575 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1576 gtk_widget_show(checkbox);
1577 trayicon_page.trayicon_hide_at_startup = checkbox;
1579 /* Close to tray */
1580 checkbox = gtk_check_button_new_with_label(_("Close to tray"));
1581 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1582 notify_config.trayicon_close_to_tray);
1583 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1584 gtk_widget_show(checkbox);
1585 trayicon_page.trayicon_close_to_tray = checkbox;
1587 /* Hide when iconified */
1588 checkbox = gtk_check_button_new_with_label(_("Hide when iconified"));
1589 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1590 notify_config.trayicon_hide_when_iconified);
1591 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1592 gtk_widget_show(checkbox);
1593 trayicon_page.trayicon_hide_when_iconified = checkbox;
1595 /* folder specific */
1596 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1597 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1598 gtk_widget_show(hbox);
1599 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1600 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1601 notify_config.trayicon_folder_specific);
1602 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1603 g_signal_connect(G_OBJECT(checkbox), "toggled",
1604 G_CALLBACK(notify_trayicon_folder_specific_set_sensitivity),
1605 NULL);
1606 gtk_widget_show(checkbox);
1607 trayicon_page.trayicon_folder_specific = checkbox;
1608 button = gtk_button_new_with_label(_("Select folders..."));
1609 g_signal_connect(G_OBJECT(button), "clicked",
1610 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1611 TRAYICON_SPECIFIC_FOLDER_ID_STR);
1612 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1613 trayicon_page.trayicon_cont_folder_specific = button;
1614 gtk_widget_show(button);
1616 #ifdef HAVE_LIBNOTIFY
1617 /* Frame for trayicon popup stuff */
1619 /* TRANSLATORS: "Toaster" does not refer to the kitchen appliance.
1620 A toast is a small passive (non-focus-stealing)
1621 notification bubble. If your language does not have a word
1622 for that, go for something along the lines of "passive popup"
1623 instead.See also
1624 http://en.wikipedia.org/wiki/Toast_(computing) */
1625 PACK_FRAME (vbox, frame, _("Passive toaster popup"))
1627 /* vbox for frame */
1628 svbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1629 gtk_container_set_border_width(GTK_CONTAINER(svbox), 5);
1630 gtk_container_add(GTK_CONTAINER(frame), svbox);
1631 gtk_widget_show(svbox);
1633 /* Enable popup for the tray icon */
1634 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1635 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1636 notify_config.trayicon_popup_enabled);
1637 g_signal_connect(G_OBJECT(checkbox), "toggled",
1638 G_CALLBACK(notify_trayicon_popup_enable_set_sensitivity),
1639 NULL);
1640 gtk_box_pack_start(GTK_BOX(svbox), checkbox, FALSE, FALSE, 0);
1641 gtk_widget_show(checkbox);
1642 trayicon_page.trayicon_popup_enabled = checkbox;
1644 /* vbox for trayicon popup stuff enabled/disabled container */
1645 ssvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1646 gtk_box_pack_start(GTK_BOX(svbox), ssvbox, FALSE, FALSE, 0);
1647 gtk_widget_show(ssvbox);
1648 trayicon_page.trayicon_popup_cont_enable = ssvbox;
1650 /* timeout */
1651 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1652 label = gtk_label_new(_("Popup timeout"));
1653 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1654 gtk_widget_show(label);
1655 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1656 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1657 timeout = notify_config.trayicon_popup_timeout/1000.;
1658 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1659 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1660 gtk_box_pack_start(GTK_BOX(ssvbox), hbox, FALSE, FALSE, 0);
1661 label = gtk_label_new(_("seconds"));
1662 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1664 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1665 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1666 notify_config.trayicon_display_folder_name);
1667 gtk_box_pack_start(GTK_BOX(ssvbox), checkbox, FALSE, FALSE, 0);
1668 trayicon_page.trayicon_display_folder_name = checkbox;
1669 gtk_widget_show(checkbox);
1671 gtk_widget_show(spinner);
1672 gtk_widget_show(label);
1673 gtk_widget_show(hbox);
1674 trayicon_page.trayicon_popup_timeout = spinner;
1676 #endif
1678 notify_trayicon_enable_set_sensitivity
1679 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled), NULL);
1681 #ifdef HAVE_LIBNOTIFY
1682 notify_trayicon_popup_enable_set_sensitivity
1683 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled), NULL);
1684 #endif
1686 notify_trayicon_folder_specific_set_sensitivity
1687 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific), NULL);
1689 gtk_widget_show(pvbox);
1690 trayicon_page.page.widget = pvbox;
1693 static void notify_destroy_trayicon_page(PrefsPage *page)
1697 static void notify_save_trayicon(PrefsPage *page)
1699 #ifdef HAVE_LIBNOTIFY
1700 gdouble timeout;
1701 #endif
1703 notify_config.trayicon_enabled =
1704 gtk_toggle_button_get_active
1705 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1707 notify_config.trayicon_hide_at_startup =
1708 gtk_toggle_button_get_active
1709 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_at_startup));
1711 notify_config.trayicon_close_to_tray =
1712 gtk_toggle_button_get_active
1713 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_close_to_tray));
1715 notify_config.trayicon_hide_when_iconified =
1716 gtk_toggle_button_get_active
1717 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_when_iconified));
1719 #ifdef HAVE_LIBNOTIFY
1720 notify_config.trayicon_popup_enabled =
1721 gtk_toggle_button_get_active
1722 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1724 timeout =
1725 gtk_spin_button_get_value(GTK_SPIN_BUTTON
1726 (trayicon_page.trayicon_popup_timeout));
1727 notify_config.trayicon_popup_timeout = (gint)floor(timeout*1000+0.5);
1729 notify_config.trayicon_display_folder_name =
1730 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trayicon_page.trayicon_display_folder_name));
1731 #endif
1733 notify_config.trayicon_folder_specific =
1734 gtk_toggle_button_get_active
1735 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1737 if(notify_config.trayicon_enabled)
1738 notification_update_msg_counts(NULL);
1739 else
1740 notification_trayicon_destroy();
1743 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton *button,
1744 gpointer data)
1746 gboolean active;
1747 active = gtk_toggle_button_get_active
1748 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1749 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_enable, active);
1752 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton *bu,
1753 gpointer data)
1755 gboolean active;
1756 active = gtk_toggle_button_get_active
1757 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1758 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_folder_specific, active);
1761 #ifdef HAVE_LIBNOTIFY
1762 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton *bu,
1763 gpointer data)
1765 gboolean active;
1766 active = gtk_toggle_button_get_active
1767 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1768 gtk_widget_set_sensitive(trayicon_page.trayicon_popup_cont_enable, active);
1771 #endif /* HAVE_LIBNOTIFY */
1773 #endif /* NOTIFICATION_TRAYICON */
1775 #ifdef NOTIFICATION_INDICATOR
1777 static void notify_create_indicator_page(PrefsPage *page, GtkWindow *window,
1778 gpointer data)
1780 GtkWidget *pvbox;
1781 GtkWidget *vbox;
1782 GtkWidget *checkbox;
1783 GtkWidget *ind_reg;
1785 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1786 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1788 /* Enable indicator */
1789 checkbox = gtk_check_button_new_with_label(_("Add to Indicator Applet"));
1790 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1791 notify_config.indicator_enabled);
1792 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1793 g_signal_connect(G_OBJECT(checkbox), "toggled",
1794 G_CALLBACK(notify_indicator_enable_set_sensitivity), NULL);
1795 indicator_page.indicator_enabled = checkbox;
1797 /* Container vbox for greying out everything */
1798 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1799 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1800 indicator_page.indicator_cont_enable = vbox;
1802 /* hide when minimized */
1803 checkbox = gtk_check_button_new_with_label(_("Hide mainwindow when minimized"));
1804 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), checkbox, FALSE, FALSE, 0);
1805 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.indicator_hide_minimized);
1806 indicator_page.indicator_hide_minimized = checkbox;
1808 notify_indicator_enable_set_sensitivity(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled), NULL);
1809 gtk_widget_show_all(pvbox);
1810 indicator_page.page.widget = pvbox;
1813 static void notify_destroy_indicator_page(PrefsPage *page)
1817 static void notify_save_indicator(PrefsPage *page)
1819 notification_indicator_destroy();
1821 notify_config.indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1823 notify_config.indicator_hide_minimized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_hide_minimized));
1825 if(notify_config.indicator_enabled) {
1826 notification_indicator_setup();
1827 notification_update_indicator();
1831 static void notify_indicator_enable_set_sensitivity(GtkToggleButton *button,
1832 gpointer data)
1834 gboolean active;
1835 active = gtk_toggle_button_get_active
1836 (GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1837 gtk_widget_set_sensitive(indicator_page.indicator_cont_enable, active);
1839 #endif /* NOTIFICATION_INDICATOR */
1841 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
1842 static void notify_create_hotkeys_page(PrefsPage *page, GtkWindow *window, gpointer data)
1844 GtkWidget *pvbox;
1845 GtkWidget *vbox;
1846 GtkWidget *checkbox;
1847 GtkWidget *label;
1848 gchar *markup;
1849 GtkWidget *hbox;
1850 GtkWidget *entry;
1852 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1853 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1855 /* Enable hotkeys */
1856 checkbox = gtk_check_button_new_with_label(_("Enable global hotkeys"));
1857 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.hotkeys_enabled);
1858 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1859 g_signal_connect(G_OBJECT(checkbox), "toggled",
1860 G_CALLBACK(notify_hotkeys_enable_set_sensitivity), NULL);
1861 hotkeys_page.hotkeys_enabled = checkbox;
1863 /* Container vbox for greying out everything */
1864 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1865 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1866 hotkeys_page.hotkeys_cont_enable = vbox;
1868 /* description */
1869 label = gtk_label_new("");
1870 markup = g_markup_printf_escaped(_("Examples for hotkeys include <b>%s</b> and <b>%s</b>"), _("<control><shift>F11"), _("<alt>N"));
1871 gtk_label_set_markup(GTK_LABEL(label), markup);
1872 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
1873 gtk_label_set_yalign(GTK_LABEL(label), 0.0);
1874 g_free(markup);
1875 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), label, FALSE, FALSE, 0);
1877 /* hbox for entry fields */
1878 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
1879 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), hbox, FALSE, FALSE, 0);
1881 /* toggle mainwindow */
1882 label = gtk_label_new(_("Toggle minimize"));
1883 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1884 entry = gtk_entry_new();
1885 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1886 if(notify_config.hotkeys_toggle_mainwindow)
1887 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.hotkeys_toggle_mainwindow);
1888 hotkeys_page.hotkeys_toggle_mainwindow = entry;
1890 notify_hotkeys_enable_set_sensitivity(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled), NULL);
1891 gtk_widget_show_all(pvbox);
1892 hotkeys_page.page.widget = pvbox;
1895 static void notify_destroy_hotkeys_page(PrefsPage *page)
1899 static void notify_save_hotkeys(PrefsPage *page)
1901 const gchar *tmp_str;
1902 notify_config.hotkeys_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1904 tmp_str = gtk_entry_get_text(GTK_ENTRY(hotkeys_page.hotkeys_toggle_mainwindow));
1905 if(notify_config.hotkeys_toggle_mainwindow)
1906 g_free(notify_config.hotkeys_toggle_mainwindow);
1907 notify_config.hotkeys_toggle_mainwindow = g_strdup(tmp_str);
1909 notification_hotkeys_update_bindings();
1912 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton *button,
1913 gpointer data)
1915 gboolean active;
1916 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1917 gtk_widget_set_sensitive(hotkeys_page.hotkeys_cont_enable, active);
1919 #endif /* hotkeys */