support image/x-eps format via pdf_viewer
[claws.git] / src / plugins / notification / notification_prefs.c
blob6133a4cf0e69c184b9f2dd0611aa2b6966fd5787
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_ayatana_indicator.h"
47 #include "notification_indicator.h"
49 #ifdef GDK_WINDOWING_X11
50 #include "notification_hotkeys.h"
51 #include <gdk/gdkx.h>
52 #endif
54 #include "notification_foldercheck.h"
56 #ifdef HAVE_LIBNOTIFY
57 /* allow infinite timeout with libnotify */
58 # define TIMEOUT_SPINNER_MIN 0.0
59 #else
60 /* don't allow infinite timeout with self-handled popups */
61 # define TIMEOUT_SPINNER_MIN 0.2
62 #endif
64 #define TIMEOUT_SPINNER_MAX 3600.0
65 #define TIMEOUT_SPINNER_STEP 0.5
67 typedef struct
69 PrefsPage page;
70 GtkWidget *include_mail;
71 GtkWidget *include_news;
72 GtkWidget *include_rss;
73 GtkWidget *include_calendar;
74 GtkWidget *urgency_hint_new;
75 GtkWidget *urgency_hint_unread;
76 #ifdef HAVE_LIBCANBERRA_GTK
77 GtkWidget *canberra_play_sounds;
78 #endif
79 } NotifyPage;
81 NotifyPrefs notify_config;
82 NotifyPage notify_page;
84 #ifdef NOTIFICATION_BANNER
85 typedef struct {
86 PrefsPage page;
87 GtkWidget *banner_show;
88 GtkWidget *banner_speed;
89 GtkWidget *banner_width;
90 GtkWidget *banner_include_unread;
91 GtkWidget *banner_max_msgs;
92 GtkWidget *banner_sticky;
93 GtkWidget *banner_folder_specific;
94 GtkWidget *banner_enable_colors;
95 GtkWidget *banner_color_bg;
96 GtkWidget *banner_color_fg;
97 GtkWidget *banner_cont_enable;
98 GtkWidget *banner_cont_folder_specific;
99 GtkWidget *banner_cont_color_sel;
100 }NotifyBannerPage;
101 NotifyBannerPage banner_page;
102 #endif /* NOTIFICATION_BANNER */
104 #ifdef NOTIFICATION_POPUP
105 typedef struct {
106 PrefsPage page;
107 GtkWidget *popup_show;
108 GtkWidget *popup_timeout;
109 GtkWidget *popup_folder_specific;
110 GtkWidget *popup_cont_enable;
111 GtkWidget *popup_cont_folder_specific;
112 #ifndef HAVE_LIBNOTIFY
113 GtkWidget *popup_sticky;
114 GtkWidget *popup_enable_colors;
115 GtkWidget *popup_color_bg;
116 GtkWidget *popup_color_fg;
117 GtkWidget *popup_cont_color_sel;
118 #else /* HAVE_LIBNOTIFY */
119 GtkWidget *popup_display_folder_name;
120 #endif /* HAVE_LIBNOTIFY */
121 }NotifyPopupPage;
122 NotifyPopupPage popup_page;
123 #endif /* NOTIFICATION_POPUP */
125 #ifdef NOTIFICATION_COMMAND
126 typedef struct {
127 PrefsPage page;
128 GtkWidget *command_enabled;
129 GtkWidget *command_timeout;
130 GtkWidget *command_folder_specific;
131 GtkWidget *command_line;
132 GtkWidget *command_cont_enable;
133 GtkWidget *command_cont_folder_specific;
134 }NotifyCommandPage;
135 NotifyCommandPage command_page;
136 #endif /* NOTIFICATION_COMMAND */
138 #ifdef NOTIFICATION_LCDPROC
139 typedef struct {
140 PrefsPage page;
141 GtkWidget *lcdproc_enabled;
142 GtkWidget *lcdproc_cont_enable;
143 GtkWidget *lcdproc_hostname;
144 GtkWidget *lcdproc_port;
145 }NotifyLCDProcPage;
146 NotifyLCDProcPage lcdproc_page;
147 #endif
149 #ifdef NOTIFICATION_TRAYICON
150 typedef struct {
151 PrefsPage page;
152 GtkWidget *trayicon_enabled;
153 GtkWidget *trayicon_cont_enable;
154 GtkWidget *trayicon_hide_at_startup;
155 GtkWidget *trayicon_close_to_tray;
156 GtkWidget *trayicon_hide_when_iconified;
157 GtkWidget *trayicon_folder_specific;
158 GtkWidget *trayicon_cont_folder_specific;
159 #ifdef HAVE_LIBNOTIFY
160 GtkWidget *trayicon_display_folder_name;
161 GtkWidget *trayicon_popup_enabled;
162 GtkWidget *trayicon_popup_cont_enable;
163 GtkWidget *trayicon_popup_timeout;
164 #endif
165 }NotifyTrayiconPage;
166 NotifyTrayiconPage trayicon_page;
167 #endif
169 #ifdef NOTIFICATION_AYATANA_INDICATOR
170 typedef struct {
171 PrefsPage page;
172 GtkWidget *ayatana_indicator_enabled;
173 }NotifyAtayanaIndicatorPage;
174 NotifyAtayanaIndicatorPage ayatana_indicator_page;
175 #endif
177 #ifdef NOTIFICATION_INDICATOR
178 typedef struct {
179 PrefsPage page;
180 GtkWidget *indicator_enabled;
181 GtkWidget *indicator_cont_enable;
182 GtkWidget *indicator_hide_minimized;
183 }NotifyIndicatorPage;
184 NotifyIndicatorPage indicator_page;
185 #endif
187 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
188 typedef struct {
189 PrefsPage page;
190 GtkWidget *hotkeys_enabled;
191 GtkWidget *hotkeys_cont_enable;
192 GtkWidget *hotkeys_toggle_mainwindow;
193 }NotifyHotkeysPage;
194 NotifyHotkeysPage hotkeys_page;
195 #endif
198 PrefParam
199 notify_param[] =
202 { "include_mail", "TRUE", &notify_config.include_mail, P_BOOL, NULL,
203 NULL, NULL },
204 { "include_news", "TRUE", &notify_config.include_news, P_BOOL, NULL,
205 NULL, NULL },
206 { "include_rss", "TRUE", &notify_config.include_rss, P_BOOL, NULL,
207 NULL, NULL },
208 { "include_calendar", "TRUE", &notify_config.include_calendar, P_BOOL,
209 NULL, NULL, NULL },
210 { "urgency_hint_new", "FALSE", &notify_config.urgency_hint_new, P_BOOL,
211 NULL, NULL, NULL },
212 { "urgency_hint_unread", "FALSE", &notify_config.urgency_hint_unread, P_BOOL,
213 NULL, NULL, NULL },
215 #ifdef HAVE_LIBCANBERRA_GTK
216 { "canberra_play_sounds", "TRUE", &notify_config.canberra_play_sounds, P_BOOL,
217 NULL, NULL, NULL },
218 #endif
220 #ifdef NOTIFICATION_BANNER
221 { "banner_show", "0", &notify_config.banner_show, P_INT, NULL, NULL, NULL},
222 { "banner_speed", "30", &notify_config.banner_speed, P_INT, NULL, NULL, NULL},
223 { "banner_width", "0", &notify_config.banner_width, P_INT, NULL, NULL, NULL},
224 { "banner_include_unread", "FALSE", &notify_config.banner_include_unread,
225 P_BOOL, NULL, NULL, NULL},
226 { "banner_max_msgs", "100", &notify_config.banner_max_msgs, P_INT,
227 NULL, NULL, NULL},
228 { "banner_sticky", "FALSE", &notify_config.banner_sticky,
229 P_BOOL, NULL, NULL, NULL},
230 { "banner_root_x", "0", &notify_config.banner_root_x, P_INT,
231 NULL, NULL, NULL},
232 { "banner_root_y", "10", &notify_config.banner_root_y, P_INT,
233 NULL, NULL, NULL},
234 { "banner_folder_specific", "FALSE", &notify_config.banner_folder_specific,
235 P_BOOL, NULL, NULL, NULL},
236 { "banner_enable_colors", "FALSE", &notify_config.banner_enable_colors,
237 P_BOOL, NULL, NULL, NULL},
238 { "banner_color_bg", "0", &notify_config.banner_color_bg, P_COLOR,
239 NULL, NULL, NULL},
240 { "banner_color_fg", "16776704", &notify_config.banner_color_fg, P_COLOR,
241 NULL, NULL, NULL},
242 #endif
244 #ifdef NOTIFICATION_POPUP
245 { "popup_show", "TRUE", &notify_config.popup_show, P_BOOL, NULL, NULL, NULL},
246 { "popup_timeout", "5000", &notify_config.popup_timeout,
247 P_INT, NULL, NULL, NULL},
248 { "popup_folder_specific", "FALSE", &notify_config.popup_folder_specific,
249 P_BOOL, NULL, NULL, NULL},
250 #ifndef HAVE_LIBNOTIFY
251 { "popup_sticky", "TRUE", &notify_config.popup_sticky, P_BOOL,
252 NULL, NULL, NULL},
253 { "popup_root_x", "10", &notify_config.popup_root_x,
254 P_INT, NULL, NULL, NULL},
255 { "popup_root_y", "10", &notify_config.popup_root_y,
256 P_INT, NULL, NULL, NULL},
257 { "popup_width", "100", &notify_config.popup_width,
258 P_INT, NULL, NULL, NULL},
259 { "popup_enable_colors", "FALSE", &notify_config.popup_enable_colors, P_BOOL,
260 NULL, NULL, NULL},
261 { "popup_color_bg", "0", &notify_config.popup_color_bg, P_COLOR,
262 NULL, NULL, NULL},
263 { "popup_color_fg", "16776704", &notify_config.popup_color_fg, P_COLOR,
264 NULL, NULL, NULL},
265 #else /* HAVE_LIBNOTIFY */
266 { "popup_display_folder_name", "FALSE", &notify_config.popup_display_folder_name,
267 P_BOOL, NULL, NULL, NULL},
268 #endif /* HAVE_LIBNOTIFY */
269 #endif
271 #ifdef NOTIFICATION_COMMAND
272 { "command_enabled", "FALSE", &notify_config.command_enabled, P_BOOL,
273 NULL, NULL, NULL},
274 { "command_timeout", "60000", &notify_config.command_timeout, P_INT,
275 NULL, NULL, NULL},
276 { "command_folder_specific", "FALSE", &notify_config.command_folder_specific,
277 P_BOOL, NULL, NULL, NULL},
278 { "command_line", "", &notify_config.command_line, P_STRING,
279 NULL, NULL, NULL},
280 #endif
282 #ifdef NOTIFICATION_LCDPROC
283 { "lcdproc_enabled", "FALSE", &notify_config.lcdproc_enabled, P_BOOL,
284 NULL, NULL, NULL},
285 { "lcdproc_hostname", "localhost", &notify_config.lcdproc_hostname, P_STRING,
286 NULL, NULL, NULL},
287 { "lcdproc_port", "13666", &notify_config.lcdproc_port, P_INT,
288 NULL, NULL, NULL},
289 #endif
291 #ifdef NOTIFICATION_TRAYICON
292 #ifndef G_OS_WIN32
293 { "trayicon_enabled", "FALSE", &notify_config.trayicon_enabled, P_BOOL,
294 NULL, NULL, NULL},
295 #else
296 { "trayicon_enabled", "TRUE", &notify_config.trayicon_enabled, P_BOOL,
297 NULL, NULL, NULL},
298 #endif
299 { "trayicon_hide_at_startup", "FALSE",
300 &notify_config.trayicon_hide_at_startup, P_BOOL, NULL, NULL, NULL},
301 { "trayicon_close_to_tray", "FALSE",
302 &notify_config.trayicon_close_to_tray, P_BOOL, NULL, NULL, NULL},
303 { "trayicon_hide_when_iconified", "FALSE",
304 &notify_config.trayicon_hide_when_iconified, P_BOOL, NULL, NULL, NULL},
305 { "trayicon_folder_specific", "FALSE",
306 &notify_config.trayicon_folder_specific,
307 P_BOOL, NULL, NULL, NULL},
308 #ifdef HAVE_LIBNOTIFY
309 { "trayicon_display_folder_name", "FALSE",
310 &notify_config.trayicon_display_folder_name,
311 P_BOOL, NULL, NULL, NULL},
312 { "trayicon_popup_enabled", "TRUE", &notify_config.trayicon_popup_enabled,
313 P_BOOL, NULL, NULL, NULL},
314 { "trayicon_popup_timeout", "5000", &notify_config.trayicon_popup_timeout,
315 P_INT, NULL, NULL, NULL},
316 #endif /* HAVE_LIBNOTIFY */
317 #endif
319 #ifdef NOTIFICATION_AYATANA_INDICATOR
320 { "ayatana_indicator_enabled", "FALSE", &notify_config.ayatana_indicator_enabled, P_BOOL,
321 NULL, NULL, NULL},
322 #endif /* NOTIFICATION_AYATANA_INDICATOR */
323 #ifdef NOTIFICATION_INDICATOR
324 { "indicator_enabled", "FALSE", &notify_config.indicator_enabled, P_BOOL,
325 NULL, NULL, NULL},
326 { "indicator_hide_minimized", "FALSE", &notify_config.indicator_hide_minimized, P_BOOL,
327 NULL, NULL, NULL},
328 #endif /* NOTIFICATION_INDICATOR */
329 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
330 { "hotkeys_enabled", "FALSE", &notify_config.hotkeys_enabled, P_BOOL,
331 NULL, NULL, NULL},
332 { "hotkeys_toggle_mainwindow", "", &notify_config.hotkeys_toggle_mainwindow,
333 P_STRING, NULL, NULL, NULL},
334 #endif /* NOTIFICATION_HOTKEYS */
335 { NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL } };
337 static void notify_create_prefs_page(PrefsPage*, GtkWindow*, gpointer);
338 static void notify_destroy_prefs_page(PrefsPage*);
339 static void notify_save_prefs(PrefsPage*);
341 #ifdef NOTIFICATION_BANNER
342 static void notify_create_banner_page(PrefsPage*, GtkWindow*, gpointer);
343 static void notify_destroy_banner_page(PrefsPage*);
344 static void notify_save_banner(PrefsPage*);
345 static void notify_banner_enable_set_sensitivity(GtkComboBox*, gpointer);
346 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
347 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton*,
348 gpointer);
349 #endif
351 #ifdef NOTIFICATION_POPUP
352 static void notify_create_popup_page(PrefsPage*, GtkWindow*, gpointer);
353 static void notify_destroy_popup_page(PrefsPage*);
354 static void notify_save_popup(PrefsPage*);
355 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton*,
356 gpointer);
357 static void notify_popup_enable_set_sensitivity(GtkToggleButton*, gpointer);
358 #ifndef HAVE_LIBNOTIFY
359 static void notify_popup_set_done_cb(GtkWidget*, gpointer);
360 static void notify_popup_set_cb(GtkWidget*, gpointer);
361 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
362 #endif /* !HAVE_LIBNOTIFY */
363 #endif
365 #ifdef NOTIFICATION_COMMAND
366 static void notify_command_browse_cb(GtkWidget* widget, gpointer data);
367 static void notify_create_command_page(PrefsPage*, GtkWindow*, gpointer);
368 static void notify_destroy_command_page(PrefsPage*);
369 static void notify_save_command(PrefsPage*);
370 static void notify_command_enable_set_sensitivity(GtkToggleButton*, gpointer);
371 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton*,
372 gpointer);
373 #endif
375 #ifdef NOTIFICATION_LCDPROC
376 static void notify_create_lcdproc_page(PrefsPage*, GtkWindow*, gpointer);
377 static void notify_destroy_lcdproc_page(PrefsPage*);
378 static void notify_save_lcdproc(PrefsPage*);
379 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton*, gpointer);
380 #endif
382 #ifdef NOTIFICATION_TRAYICON
383 static void notify_create_trayicon_page(PrefsPage*, GtkWindow*, gpointer);
384 static void notify_destroy_trayicon_page(PrefsPage*);
385 static void notify_save_trayicon(PrefsPage*);
386 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton*, gpointer);
387 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton*,
388 gpointer);
389 #ifdef HAVE_LIBNOTIFY
390 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton*,
391 gpointer);
392 #endif
393 #endif
395 #ifdef NOTIFICATION_AYATANA_INDICATOR
396 static void notify_create_ayatana_indicator_page(PrefsPage*, GtkWindow*, gpointer);
397 static void notify_destroy_ayatana_indicator_page(PrefsPage*);
398 static void notify_save_ayatana_indicator(PrefsPage*);
399 #endif /* NOTIFICATION_AYATANA_INDICATOR */
401 #ifdef NOTIFICATION_INDICATOR
402 static void notify_create_indicator_page(PrefsPage*, GtkWindow*, gpointer);
403 static void notify_destroy_indicator_page(PrefsPage*);
404 static void notify_save_indicator(PrefsPage*);
405 static void notify_indicator_enable_set_sensitivity(GtkToggleButton*, gpointer);
406 #endif /* NOTIFICATION_INDICATOR */
408 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
409 static void notify_create_hotkeys_page(PrefsPage*, GtkWindow*, gpointer);
410 static void notify_destroy_hotkeys_page(PrefsPage*);
411 static void notify_save_hotkeys(PrefsPage*);
412 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton*, gpointer);
413 #endif /* NOTIFICATION_HOTKEYS */
416 void notify_gtk_init(void)
418 static gchar *path[3];
420 path[0] = _("Plugins");
421 path[1] = _("Notification");
422 path[2] = NULL;
424 notify_page.page.path = path;
425 notify_page.page.create_widget = notify_create_prefs_page;
426 notify_page.page.destroy_widget = notify_destroy_prefs_page;
427 notify_page.page.save_page = notify_save_prefs;
428 notify_page.page.weight = 40.0;
429 prefs_gtk_register_page((PrefsPage*) &notify_page);
431 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
432 if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
434 static gchar *hotkeys_path[4];
436 hotkeys_path[0] = _("Plugins");
437 hotkeys_path[1] = _("Notification");
438 hotkeys_path[2] = _("Hotkeys");
439 hotkeys_path[3] = NULL;
441 hotkeys_page.page.path = hotkeys_path;
442 hotkeys_page.page.create_widget = notify_create_hotkeys_page;
443 hotkeys_page.page.destroy_widget = notify_destroy_hotkeys_page;
444 hotkeys_page.page.save_page = notify_save_hotkeys;
445 hotkeys_page.page.weight = 10.0;
446 prefs_gtk_register_page((PrefsPage*) &hotkeys_page);
448 #endif /* NOTIFICATION_HOTKEYS */
451 #ifdef NOTIFICATION_BANNER
453 static gchar *banner_path[4];
455 banner_path[0] = _("Plugins");
456 banner_path[1] = _("Notification");
457 banner_path[2] = _("Banner");
458 banner_path[3] = NULL;
460 banner_page.page.path = banner_path;
461 banner_page.page.create_widget = notify_create_banner_page;
462 banner_page.page.destroy_widget = notify_destroy_banner_page;
463 banner_page.page.save_page = notify_save_banner;
464 banner_page.page.weight = 20.0;
465 prefs_gtk_register_page((PrefsPage*) &banner_page);
467 #endif /* NOTIFICATION_BANNER */
469 #ifdef NOTIFICATION_POPUP
471 static gchar *popup_path[4];
473 popup_path[0] = _("Plugins");
474 popup_path[1] = _("Notification");
475 popup_path[2] = _("Popup");
476 popup_path[3] = NULL;
478 popup_page.page.path = popup_path;
479 popup_page.page.create_widget = notify_create_popup_page;
480 popup_page.page.destroy_widget = notify_destroy_popup_page;
481 popup_page.page.save_page = notify_save_popup;
482 popup_page.page.weight = 30.0;
483 prefs_gtk_register_page((PrefsPage*) &popup_page);
485 #endif /* NOTIFICATION_POPUP */
487 #ifdef NOTIFICATION_COMMAND
489 static gchar *command_path[4];
491 command_path[0] = _("Plugins");
492 command_path[1] = _("Notification");
493 command_path[2] = _("Command");
494 command_path[3] = NULL;
496 command_page.page.path = command_path;
497 command_page.page.create_widget = notify_create_command_page;
498 command_page.page.destroy_widget = notify_destroy_command_page;
499 command_page.page.save_page = notify_save_command;
500 command_page.page.weight = 40.0;
501 prefs_gtk_register_page((PrefsPage*) &command_page);
503 #endif /* NOTIFICATION_COMMAND */
505 #ifdef NOTIFICATION_LCDPROC
507 static gchar *lcdproc_path[4];
509 lcdproc_path[0] = _("Plugins");
510 lcdproc_path[1] = _("Notification");
511 lcdproc_path[2] = _("LCD");
512 lcdproc_path[3] = NULL;
514 lcdproc_page.page.path = lcdproc_path;
515 lcdproc_page.page.create_widget = notify_create_lcdproc_page;
516 lcdproc_page.page.destroy_widget = notify_destroy_lcdproc_page;
517 lcdproc_page.page.save_page = notify_save_lcdproc;
518 lcdproc_page.page.weight = 50.0;
519 prefs_gtk_register_page((PrefsPage*) &lcdproc_page);
521 #endif /* NOTIFICATION_LCDPROC */
523 #ifdef NOTIFICATION_TRAYICON
525 static gchar *trayicon_path[4];
527 trayicon_path[0] = _("Plugins");
528 trayicon_path[1] = _("Notification");
529 trayicon_path[2] = _("SysTrayicon");
530 trayicon_path[3] = NULL;
532 trayicon_page.page.path = trayicon_path;
533 trayicon_page.page.create_widget = notify_create_trayicon_page;
534 trayicon_page.page.destroy_widget = notify_destroy_trayicon_page;
535 trayicon_page.page.save_page = notify_save_trayicon;
536 trayicon_page.page.weight = 60.0;
537 prefs_gtk_register_page((PrefsPage*) &trayicon_page);
539 #endif /* NOTIFICATION_TRAYICON */
541 #ifdef NOTIFICATION_AYATANA_INDICATOR
543 static gchar *ayatana_indicator_path[4];
545 ayatana_indicator_path[0] = _("Plugins");
546 ayatana_indicator_path[1] = _("Notification");
547 ayatana_indicator_path[2] = _("Atayana App Indicator");
548 ayatana_indicator_path[3] = NULL;
550 ayatana_indicator_page.page.path = ayatana_indicator_path;
551 ayatana_indicator_page.page.create_widget = notify_create_ayatana_indicator_page;
552 ayatana_indicator_page.page.destroy_widget = notify_destroy_ayatana_indicator_page;
553 ayatana_indicator_page.page.save_page = notify_save_ayatana_indicator;
554 ayatana_indicator_page.page.weight = 70.0;
555 prefs_gtk_register_page((PrefsPage*) &ayatana_indicator_page);
557 #endif /* NOTIFICATION_AYATANA_INDICATOR */
559 #ifdef NOTIFICATION_INDICATOR
561 static gchar *indicator_path[4];
563 indicator_path[0] = _("Plugins");
564 indicator_path[1] = _("Notification");
565 indicator_path[2] = _("Indicator");
566 indicator_path[3] = NULL;
568 indicator_page.page.path = indicator_path;
569 indicator_page.page.create_widget = notify_create_indicator_page;
570 indicator_page.page.destroy_widget = notify_destroy_indicator_page;
571 indicator_page.page.save_page = notify_save_indicator;
572 indicator_page.page.weight = 70.0;
573 prefs_gtk_register_page((PrefsPage*) &indicator_page);
575 #endif /* NOTIFICATION_INDICATOR */
578 void notify_gtk_done(void)
580 if (claws_is_exiting())
581 return;
582 prefs_gtk_unregister_page((PrefsPage*) &notify_page);
583 #ifdef NOTIFICATION_BANNER
584 prefs_gtk_unregister_page((PrefsPage*) &banner_page);
585 #endif
586 #ifdef NOTIFICATION_POPUP
587 prefs_gtk_unregister_page((PrefsPage*) &popup_page);
588 #endif
589 #ifdef NOTIFICATION_COMMAND
590 prefs_gtk_unregister_page((PrefsPage*) &command_page);
591 #endif
592 #ifdef NOTIFICATION_LCDPROC
593 prefs_gtk_unregister_page((PrefsPage*) &lcdproc_page);
594 #endif
595 #ifdef NOTIFICATION_TRAYICON
596 prefs_gtk_unregister_page((PrefsPage*) &trayicon_page);
597 #endif
598 #ifdef NOTIFICATION_AYATANA_INDICATOR
599 prefs_gtk_unregister_page((PrefsPage*) &ayatana_indicator_page);
600 #endif
601 #ifdef NOTIFICATION_INDICATOR
602 prefs_gtk_unregister_page((PrefsPage*) &indicator_page);
603 #endif
604 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
605 prefs_gtk_unregister_page((PrefsPage*) &hotkeys_page);
606 #endif
609 void notify_save_config(void)
611 PrefFile *pfile;
612 gchar *rcpath;
614 debug_print("Saving Notification plugin configuration...\n");
616 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
617 pfile = prefs_write_open(rcpath);
618 g_free(rcpath);
619 if (!pfile || (prefs_set_block_label(pfile, "NotificationPlugin") < 0))
620 return;
622 if (prefs_write_param(notify_param, pfile->fp) < 0) {
623 debug_print("failed!\n");
624 g_warning("notification plugin: failed to write plugin configuration "
625 "to file");
626 prefs_file_close_revert(pfile);
627 return;
629 if (fprintf(pfile->fp, "\n") < 0) {
630 FILE_OP_ERROR(rcpath, "fprintf");
631 prefs_file_close_revert(pfile);
633 else
634 prefs_file_close(pfile);
635 debug_print("done.\n");
638 static void notify_create_prefs_page(PrefsPage *page, GtkWindow *window,
639 gpointer data)
641 GtkWidget *pvbox;
642 GtkWidget *vbox;
643 GtkWidget *checkbox;
644 GtkWidget *frame;
645 GtkWidget *label;
647 /* Page vbox */
648 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
650 /* Frame */
651 PACK_FRAME (pvbox, frame, _("Include folder types"))
652 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
654 /* Frame vbox */
655 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
656 gtk_container_add(GTK_CONTAINER(frame), vbox);
657 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
659 /* Include mail folders */
660 checkbox = gtk_check_button_new_with_label(_("Mail folders"));
661 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
662 notify_config.include_mail);
663 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
664 gtk_widget_show(checkbox);
665 notify_page.include_mail = checkbox;
667 /* Include news folders */
668 checkbox = gtk_check_button_new_with_label(_("News folders"));
669 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
670 notify_config.include_news);
671 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
672 gtk_widget_show(checkbox);
673 notify_page.include_news = checkbox;
675 /* Include RSSyl folders */
676 checkbox = gtk_check_button_new_with_label(_("RSSyl folders"));
677 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
678 notify_config.include_rss);
679 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
680 gtk_widget_show(checkbox);
681 notify_page.include_rss = checkbox;
683 /* Include calendar folders */
684 checkbox = gtk_check_button_new_with_label(_("vCalendar folders"));
685 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
686 notify_config.include_calendar);
687 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
688 gtk_widget_show(checkbox);
689 notify_page.include_calendar = checkbox;
691 /* Warning-Label */
692 label = gtk_label_new(_("These settings override folder-specific "
693 "selections."));
694 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
695 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
696 gtk_widget_show(label);
698 /* done with the frame */
699 gtk_widget_show(frame);
700 gtk_widget_show(vbox);
702 /* Frame */
703 PACK_FRAME (pvbox, frame, _("Global notification settings"));
704 gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
706 /* Frame vbox */
707 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
708 gtk_container_add(GTK_CONTAINER(frame), vbox);
709 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
711 /* urgency hint new */
712 checkbox = gtk_check_button_new_with_label(_("Set window manager "
713 "urgency hint when new messages exist"));
714 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
715 notify_config.urgency_hint_new);
716 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
717 gtk_widget_show(checkbox);
718 notify_page.urgency_hint_new = checkbox;
720 /* urgency hint new */
721 checkbox = gtk_check_button_new_with_label(_("Set window manager "
722 "urgency hint when unread messages exist"));
723 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
724 notify_config.urgency_hint_unread);
725 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
726 gtk_widget_show(checkbox);
727 notify_page.urgency_hint_unread = checkbox;
729 #ifdef HAVE_LIBCANBERRA_GTK
730 /* canberra */
731 checkbox = gtk_check_button_new_with_label(_("Use sound theme"));
732 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
733 notify_config.canberra_play_sounds);
734 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
735 gtk_widget_show(checkbox);
736 notify_page.canberra_play_sounds = checkbox;
737 #endif
739 /* done with the frame */
740 gtk_widget_show(frame);
741 gtk_widget_show(vbox);
743 /* done with the page */
744 gtk_widget_show(pvbox);
745 page->widget = pvbox;
748 static void notify_destroy_prefs_page(PrefsPage *page)
752 static void notify_save_prefs(PrefsPage *page)
754 notify_config.include_mail =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_mail));
755 notify_config.include_news =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_news));
756 notify_config.include_rss =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_rss));
757 notify_config.include_calendar
758 = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_calendar));
759 notify_config.urgency_hint_new = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_new));
760 notify_config.urgency_hint_unread = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_unread));
761 #ifdef HAVE_LIBCANBERRA_GTK
762 notify_config.canberra_play_sounds = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.canberra_play_sounds));
763 #endif
765 notification_core_global_includes_changed();
768 #ifdef NOTIFICATION_BANNER
769 static void notify_banner_slider_add_cb(GtkWidget *widget, gpointer data)
771 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
772 gtk_range_set_value(slider, gtk_range_get_value(slider) - 1.0);
775 static void notify_banner_slider_remove_cb(GtkWidget *widget, gpointer data)
777 GtkRange *slider = GTK_RANGE(data); /* inverted slider */
778 gtk_range_set_value(slider, gtk_range_get_value(slider) + 1.0);
781 static void notify_create_banner_page(PrefsPage *page, GtkWindow *window,
782 gpointer data)
784 GtkRequisition requisition;
785 GtkWidget *pvbox;
786 GtkWidget *vbox;
787 GtkWidget *hbox;
788 GtkWidget *chbox, *cvbox, *cframe;
789 GtkWidget *checkbox;
790 GtkWidget *button;
791 GtkWidget *combo;
792 GtkWidget *spinner;
793 GtkWidget *label;
794 GtkWidget *slider;
795 GtkWidget *color_sel;
797 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
798 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
800 /* Always / Never / Only when non-empty */
801 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
802 gtk_box_pack_start(GTK_BOX(pvbox), hbox, FALSE, FALSE, 0);
803 label = gtk_label_new(_("Show banner"));
804 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
805 gtk_widget_show(label);
806 combo = gtk_combo_box_text_new();
807 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_NEVER,
808 _("Never"));
809 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_ALWAYS,
810 _("Always"));
811 gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combo), NOTIFY_BANNER_SHOW_NONEMPTY,
812 _("Only when not empty"));
813 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), notify_config.banner_show);
814 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
815 g_signal_connect(G_OBJECT(combo), "changed",
816 G_CALLBACK(notify_banner_enable_set_sensitivity), NULL);
817 gtk_widget_show(combo);
818 gtk_widget_show(hbox);
819 banner_page.banner_show = combo;
821 /* Container vbox for greying out everything */
822 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
823 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
824 gtk_widget_show(vbox);
825 banner_page.banner_cont_enable = vbox;
827 /* Banner speed */
828 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
829 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
831 label = gtk_label_new(_("Banner speed"));
832 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
833 gtk_widget_show(label);
835 slider = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 10., 70., 10.);
836 gtk_scale_set_digits(GTK_SCALE(slider), 0);
837 gtk_widget_get_preferred_size(combo, &requisition, NULL);
838 gtk_widget_set_size_request(slider, requisition.width, -1);
839 gtk_range_set_increments(GTK_RANGE(slider), 10., 10.);
840 gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
841 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
842 gtk_range_set_value(GTK_RANGE(slider), notify_config.banner_speed);
844 button = gtk_button_new();
845 gtk_button_set_image(GTK_BUTTON(button),
846 gtk_image_new_from_icon_name("list-remove", GTK_ICON_SIZE_MENU));
847 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
848 g_signal_connect(G_OBJECT(button), "clicked",
849 G_CALLBACK(notify_banner_slider_remove_cb), slider);
850 gtk_widget_show(button);
852 gtk_box_pack_start(GTK_BOX(hbox), slider, TRUE, TRUE, 0);
853 gtk_widget_show(slider);
855 button = gtk_button_new();
856 gtk_button_set_image(GTK_BUTTON(button),
857 gtk_image_new_from_icon_name("list-add", GTK_ICON_SIZE_MENU));
858 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
859 g_signal_connect(G_OBJECT(button), "clicked",
860 G_CALLBACK(notify_banner_slider_add_cb), slider);
861 gtk_widget_show(button);
863 gtk_widget_show(hbox);
864 banner_page.banner_speed = slider;
866 /* Maximum number of messages in banner */
867 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
868 label = gtk_label_new(_("Maximum number of messages"));
869 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
870 gtk_widget_show(label);
871 spinner = gtk_spin_button_new_with_range(0., 1000., 1.);
872 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
873 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), notify_config.banner_max_msgs);
874 CLAWS_SET_TIP (spinner, _("Limit the number of messages shown, use 0 for unlimited"));
875 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
876 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
877 gtk_widget_show(spinner);
878 gtk_widget_show(hbox);
879 banner_page.banner_max_msgs = spinner;
881 /* banner width */
882 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
883 label = gtk_label_new(_("Banner width"));
884 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
885 gtk_widget_show(label);
886 spinner = gtk_spin_button_new_with_range(0.,5000., 50);
887 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner),0);
888 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),notify_config.banner_width);
889 CLAWS_SET_TIP (spinner, _("Limit the size of banner, use 0 for screen width"));
890 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
891 label = gtk_label_new(_("pixel(s)"));
892 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
893 gtk_widget_show(label);
894 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
895 gtk_widget_show(spinner);
896 gtk_widget_show(hbox);
897 banner_page.banner_width = spinner;
899 /* Include unread */
900 checkbox = gtk_check_button_new_with_label(_("Include unread mails in banner"));
901 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
902 notify_config.banner_include_unread);
903 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
904 gtk_widget_show(checkbox);
905 banner_page.banner_include_unread = checkbox;
907 /* Check button sticky */
908 checkbox = gtk_check_button_new_with_label(_("Make banner sticky"));
909 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
910 notify_config.banner_sticky);
911 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
912 gtk_widget_show(checkbox);
913 banner_page.banner_sticky = checkbox;
915 /* Check box for enabling folder specific selection */
916 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
917 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
918 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
919 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
920 notify_config.banner_folder_specific);
921 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
922 g_signal_connect(G_OBJECT(checkbox), "toggled",
923 G_CALLBACK(notify_banner_folder_specific_set_sensitivity),
924 NULL);
925 gtk_widget_show(checkbox);
926 banner_page.banner_folder_specific = checkbox;
927 button = gtk_button_new_with_label(_("Select folders..."));
928 g_signal_connect(G_OBJECT(button), "clicked",
929 G_CALLBACK(notification_foldercheck_sel_folders_cb),
930 BANNER_SPECIFIC_FOLDER_ID_STR);
931 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
932 banner_page.banner_cont_folder_specific = button;
933 gtk_widget_show(button);
934 gtk_widget_show(hbox);
936 /* Check box for enabling custom colors */
937 cvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
938 gtk_widget_show(cvbox);
939 PACK_FRAME (vbox, cframe, _("Banner colors"))
940 gtk_container_set_border_width(GTK_CONTAINER(cvbox), 5);
941 gtk_container_add(GTK_CONTAINER(cframe), cvbox);
943 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
944 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
945 notify_config.banner_enable_colors);
946 gtk_box_pack_start(GTK_BOX(cvbox), checkbox, FALSE, FALSE, 0);
947 g_signal_connect(G_OBJECT(checkbox), "toggled",
948 G_CALLBACK(notify_banner_color_sel_set_sensitivity), NULL);
949 gtk_widget_show(checkbox);
950 banner_page.banner_enable_colors = checkbox;
952 /* Color selection dialogs for foreground and background color */
953 /* foreground */
954 chbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
955 gtk_box_pack_start(GTK_BOX(cvbox), chbox, FALSE, FALSE, 0);
956 gtk_widget_show(chbox);
958 label = gtk_label_new(_("Foreground"));
959 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
960 gtk_widget_show(label);
961 color_sel = gtk_color_button_new_with_rgba(&notify_config.banner_color_fg);
962 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
963 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
964 gtk_widget_show(color_sel);
965 banner_page.banner_color_fg = color_sel;
966 /* background */
967 label = gtk_label_new(_("Background"));
968 gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
969 gtk_widget_show(label);
970 color_sel = gtk_color_button_new_with_rgba(&notify_config.banner_color_bg);
971 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel), _("Background color"));
972 gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
973 gtk_widget_show(color_sel);
974 banner_page.banner_color_bg = color_sel;
975 banner_page.banner_cont_color_sel = chbox;
977 notify_banner_color_sel_set_sensitivity
978 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors), NULL);
979 notify_banner_folder_specific_set_sensitivity
980 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific), NULL);
981 notify_banner_enable_set_sensitivity(GTK_COMBO_BOX(combo), NULL);
982 gtk_widget_show(pvbox);
983 banner_page.page.widget = pvbox;
986 static void notify_destroy_banner_page(PrefsPage *page)
990 static void notify_save_banner(PrefsPage *page)
992 gdouble range_val;
994 notify_config.banner_show =
995 gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
996 notify_config.banner_max_msgs =
997 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_max_msgs));
998 notify_config.banner_width =
999 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_width));
1000 notify_config.banner_include_unread =
1001 gtk_toggle_button_get_active
1002 (GTK_TOGGLE_BUTTON(banner_page.banner_include_unread));
1003 range_val= gtk_range_get_value(GTK_RANGE(banner_page.banner_speed));
1004 notify_config.banner_speed = (gint)ceil(range_val);
1006 notify_config.banner_sticky =
1007 gtk_toggle_button_get_active
1008 (GTK_TOGGLE_BUTTON(banner_page.banner_sticky));
1010 notify_config.banner_folder_specific =
1011 gtk_toggle_button_get_active
1012 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
1014 notify_config.banner_enable_colors =
1015 gtk_toggle_button_get_active
1016 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
1018 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(banner_page.banner_color_fg),
1019 &notify_config.banner_color_fg);
1020 gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(banner_page.banner_color_bg),
1021 &notify_config.banner_color_bg);
1023 notification_banner_destroy();
1024 notification_update_banner();
1027 static void notify_banner_enable_set_sensitivity(GtkComboBox *combo,
1028 gpointer data)
1030 NotifyBannerShow show;
1032 show = gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
1033 gtk_widget_set_sensitive(banner_page.banner_cont_enable,
1034 (show == NOTIFY_BANNER_SHOW_NEVER) ? FALSE : TRUE);
1037 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton *button,
1038 gpointer data)
1040 gboolean active;
1041 active = gtk_toggle_button_get_active
1042 (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
1043 gtk_widget_set_sensitive(banner_page.banner_cont_color_sel, active);
1046 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton *bu,
1047 gpointer data)
1049 gboolean active;
1050 active = gtk_toggle_button_get_active
1051 (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
1052 gtk_widget_set_sensitive(banner_page.banner_cont_folder_specific, active);
1054 #endif /* NOTIFICATION_BANNER */
1056 #ifdef NOTIFICATION_POPUP
1057 static void notify_create_popup_page(PrefsPage *page, GtkWindow *window,
1058 gpointer data)
1060 gdouble timeout;
1061 GtkWidget *pvbox;
1062 GtkWidget *vbox;
1063 GtkWidget *checkbox;
1064 GtkWidget *hbox;
1065 GtkWidget *spinner;
1066 GtkWidget *label;
1067 GtkWidget *button;
1068 #ifndef HAVE_LIBNOTIFY
1069 GtkWidget *table;
1070 GtkWidget *color_sel;
1071 #endif /* !HAVE_LIBNOTIFY */
1073 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1074 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1076 /* Enable popup */
1077 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1078 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1079 notify_config.popup_show);
1080 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1081 g_signal_connect(G_OBJECT(checkbox), "toggled",
1082 G_CALLBACK(notify_popup_enable_set_sensitivity), NULL);
1083 gtk_widget_show(checkbox);
1084 popup_page.popup_show = checkbox;
1086 /* Container vbox for greying out everything */
1087 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1088 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1089 gtk_widget_show(vbox);
1090 popup_page.popup_cont_enable = vbox;
1092 /* Popup timeout */
1093 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1094 label = gtk_label_new(_("Popup timeout"));
1095 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1096 gtk_widget_show(label);
1097 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1098 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1099 timeout = notify_config.popup_timeout/1000.;
1100 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1101 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1102 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1103 gtk_widget_show(spinner);
1104 label = gtk_label_new(_("seconds"));
1105 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1106 gtk_widget_show(label);
1107 gtk_widget_show(hbox);
1108 popup_page.popup_timeout = spinner;
1110 /* Check box for enabling folder specific selection */
1111 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1112 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1113 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1114 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1115 notify_config.popup_folder_specific);
1116 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1117 g_signal_connect(G_OBJECT(checkbox), "toggled",
1118 G_CALLBACK(notify_popup_folder_specific_set_sensitivity),
1119 NULL);
1120 gtk_widget_show(checkbox);
1121 popup_page.popup_folder_specific = checkbox;
1122 button = gtk_button_new_with_label(_("Select folders..."));
1123 g_signal_connect(G_OBJECT(button), "clicked",
1124 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1125 POPUP_SPECIFIC_FOLDER_ID_STR);
1126 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1127 popup_page.popup_cont_folder_specific = button;
1128 gtk_widget_show(button);
1129 gtk_widget_show(hbox);
1131 #ifndef HAVE_LIBNOTIFY
1132 /* Sticky check button */
1133 checkbox = gtk_check_button_new_with_label(_("Make popup sticky"));
1134 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1135 notify_config.popup_sticky);
1136 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1137 gtk_widget_show(checkbox);
1138 popup_page.popup_sticky = checkbox;
1140 /* Button to set size and position of popup window */
1141 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1142 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1143 button = gtk_button_new_with_label(_("Set popup window width and position"));
1144 g_signal_connect(G_OBJECT(button), "clicked",
1145 G_CALLBACK(notify_popup_set_cb), NULL);
1146 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1147 gtk_widget_show(button);
1148 label = gtk_label_new(_("(the window manager is free to ignore this)"));
1149 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1150 gtk_widget_show(label);
1151 gtk_widget_show(hbox);
1153 /* Check box for enabling custom colors */
1154 checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
1155 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1156 notify_config.popup_enable_colors);
1157 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1158 g_signal_connect(G_OBJECT(checkbox), "toggled",
1159 G_CALLBACK(notify_popup_color_sel_set_sensitivity), NULL);
1160 gtk_widget_show(checkbox);
1161 popup_page.popup_enable_colors = checkbox;
1163 /* Color selection dialogs for foreground and background color */
1164 table = gtk_grid_new();
1165 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
1167 /* foreground */
1168 label = gtk_label_new(_("Foreground"));
1169 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
1170 gtk_widget_show(label);
1171 color_sel = gtk_color_button_new();
1172 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(color_sel),
1173 &notify_config.popup_color_fg);
1174 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
1175 gtk_grid_attach(GTK_GRID(table), color_sel, 1, 0, 1, 1);
1176 gtk_widget_show(color_sel);
1177 popup_page.popup_color_fg = color_sel;
1179 /* background */
1180 label = gtk_label_new(_("Background"));
1181 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
1182 gtk_widget_show(label);
1183 color_sel = gtk_color_button_new();
1184 gtk_color_button_set_rgba(GTK_COLOR_BUTTON(color_sel),
1185 &notify_config.popup_color_bg);
1186 gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Background color"));
1187 gtk_grid_attach(GTK_GRID(table), color_sel, 1, 1, 1, 1);
1188 gtk_widget_show(color_sel);
1189 gtk_widget_show(table);
1190 popup_page.popup_color_bg = color_sel;
1191 popup_page.popup_cont_color_sel = table;
1193 notify_popup_color_sel_set_sensitivity
1194 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors), NULL);
1195 #else /* HAVE_LIBNOTIFY */
1196 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1197 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1198 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1199 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1200 notify_config.popup_display_folder_name);
1201 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1202 gtk_widget_show(checkbox);
1203 gtk_widget_show(hbox);
1204 popup_page.popup_display_folder_name = checkbox;
1205 #endif /* HAVE_LIBNOTIFY */
1207 notify_popup_enable_set_sensitivity
1208 (GTK_TOGGLE_BUTTON(popup_page.popup_show), NULL);
1209 notify_popup_folder_specific_set_sensitivity
1210 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific), NULL);
1211 gtk_widget_show(pvbox);
1212 popup_page.page.widget = pvbox;
1215 static void notify_destroy_popup_page(PrefsPage *page)
1219 static void notify_save_popup(PrefsPage *page)
1221 gdouble timeout;
1223 notify_config.popup_show =
1224 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_show));
1225 timeout =
1226 gtk_spin_button_get_value(GTK_SPIN_BUTTON(popup_page.popup_timeout));
1227 notify_config.popup_timeout = (gint)floor(timeout*1000+0.5);
1228 notify_config.popup_folder_specific =
1229 gtk_toggle_button_get_active
1230 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1232 #ifndef HAVE_LIBNOTIFY
1233 notify_config.popup_sticky =
1234 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_sticky));
1235 notify_config.popup_enable_colors =
1236 gtk_toggle_button_get_active
1237 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1239 /* Color dialogs are a bit more complicated */
1240 gtk_color_button_get_rgba(GTK_COLOR_BUTTON(popup_page.popup_color_fg),
1241 &notify_config.popup_color_fg);
1242 gtk_color_button_get_rgba(GTK_COLOR_BUTTON(popup_page.popup_color_bg),
1243 &notify_config.popup_color_bg);
1244 #else /* HAVE_LIBNOTIFY */
1245 notify_config.popup_display_folder_name =
1246 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_display_folder_name));
1247 #endif /* HAVE_LIBNOTIFY */
1250 #ifndef HAVE_LIBNOTIFY
1251 static void notify_popup_set_cb(GtkWidget *widget, gpointer data)
1253 GtkWidget *win;
1254 GtkWidget *button;
1256 win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "notification_prefs");
1257 gtk_window_set_title(GTK_WINDOW(win), _("Sample popup window"));
1258 gtk_window_set_modal(GTK_WINDOW(win), TRUE);
1259 gtk_window_set_keep_above(GTK_WINDOW(win), TRUE);
1260 gtk_window_set_resizable(GTK_WINDOW(win), TRUE);
1261 gtk_container_set_border_width(GTK_CONTAINER(win), 5);
1263 button = gtk_button_new_with_label(_("Done"));
1264 g_signal_connect(G_OBJECT(button), "clicked",
1265 G_CALLBACK(notify_popup_set_done_cb), win);
1266 gtk_container_add(GTK_CONTAINER(win), button);
1268 gtk_widget_show_all(win);
1271 static void notify_popup_set_done_cb(GtkWidget *widget, gpointer data)
1273 GtkWidget *win = data;
1274 gint dummy;
1276 gtk_window_get_position(GTK_WINDOW(win),
1277 &(notify_config.popup_root_x),
1278 &(notify_config.popup_root_y));
1279 gtk_window_get_size(GTK_WINDOW(win),
1280 &(notify_config.popup_width), &dummy);
1281 gtk_widget_destroy(win);
1284 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton *button,
1285 gpointer data)
1287 gboolean active;
1288 active = gtk_toggle_button_get_active
1289 (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1290 gtk_widget_set_sensitive(popup_page.popup_cont_color_sel, active);
1292 #endif /* !HAVE_LIBNOTIFY */
1294 static void notify_popup_enable_set_sensitivity(GtkToggleButton *button,
1295 gpointer data)
1297 gboolean active;
1298 active = gtk_toggle_button_get_active
1299 (GTK_TOGGLE_BUTTON(popup_page.popup_show));
1300 gtk_widget_set_sensitive(popup_page.popup_cont_enable, active);
1303 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton *bu,
1304 gpointer data)
1306 gboolean active;
1307 active = gtk_toggle_button_get_active
1308 (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1309 gtk_widget_set_sensitive(popup_page.popup_cont_folder_specific, active);
1312 #endif /* NOTIFICATION_POPUP */
1314 #ifdef NOTIFICATION_COMMAND
1315 static void notify_command_browse_cb(GtkWidget* widget, gpointer data)
1317 gchar *filename;
1318 gchar *utf8_filename;
1319 GtkEntry *dest = GTK_ENTRY(data);
1321 filename = filesel_select_file_open(_("Select command"), NULL);
1322 if (!filename) return;
1324 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1325 if (!utf8_filename) {
1326 g_warning("notify_command_browse_cb(): failed to convert character set");
1327 utf8_filename = g_strdup(filename);
1329 gtk_entry_set_text(GTK_ENTRY(dest), utf8_filename);
1330 g_free(utf8_filename);
1333 static void notify_create_command_page(PrefsPage *page, GtkWindow *window,
1334 gpointer data)
1336 GtkWidget *pvbox;
1337 GtkWidget *vbox;
1338 GtkWidget *checkbox;
1339 GtkWidget *hbox;
1340 GtkWidget *spinner;
1341 GtkWidget *entry;
1342 GtkWidget *label;
1343 GtkWidget *button, *buttonb;
1344 gdouble timeout;
1346 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1347 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1349 /* Enable command */
1350 checkbox = gtk_check_button_new_with_label(_("Enable command"));
1351 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1352 notify_config.command_enabled);
1353 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1354 g_signal_connect(G_OBJECT(checkbox), "toggled",
1355 G_CALLBACK(notify_command_enable_set_sensitivity), NULL);
1356 gtk_widget_show(checkbox);
1357 command_page.command_enabled = checkbox;
1359 /* Container vbox for greying out everything */
1360 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1361 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1362 gtk_widget_show(vbox);
1363 command_page.command_cont_enable = vbox;
1365 /* entry field for command to execute */
1366 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1367 label = gtk_label_new(_("Command to execute"));
1368 gtk_widget_show(label);
1369 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1370 entry = gtk_entry_new();
1371 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.command_line);
1372 gtk_widget_show(entry);
1373 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1374 buttonb = gtkut_get_browse_file_btn(_("Bro_wse"));
1375 gtk_box_pack_start(GTK_BOX(hbox), buttonb, FALSE, FALSE, 0);
1376 g_signal_connect(G_OBJECT(buttonb), "clicked",
1377 G_CALLBACK(notify_command_browse_cb), entry);
1378 gtk_widget_show(buttonb);
1379 gtk_widget_show(hbox);
1380 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1381 command_page.command_line = entry;
1383 /* Spin button for command timeout */
1384 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1385 label = gtk_label_new(_("Block command after execution for"));
1386 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1387 gtk_widget_show(label);
1388 spinner = gtk_spin_button_new_with_range(0., 600., 1.);
1389 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1390 timeout = notify_config.command_timeout/1000.;
1391 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1392 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1393 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1394 gtk_widget_show(spinner);
1395 label = gtk_label_new(_("seconds"));
1396 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1397 gtk_widget_show(label);
1398 gtk_widget_show(hbox);
1399 command_page.command_timeout = spinner;
1401 /* Check box for enabling folder specific selection */
1402 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1403 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1404 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1405 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1406 notify_config.command_folder_specific);
1407 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1408 g_signal_connect(G_OBJECT(checkbox), "toggled",
1409 G_CALLBACK(notify_command_folder_specific_set_sensitivity),
1410 NULL);
1411 gtk_widget_show(checkbox);
1412 command_page.command_folder_specific = checkbox;
1413 button = gtk_button_new_with_label(_("Select folders..."));
1414 g_signal_connect(G_OBJECT(button), "clicked",
1415 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1416 COMMAND_SPECIFIC_FOLDER_ID_STR);
1417 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1418 command_page.command_cont_folder_specific = button;
1419 gtk_widget_show(button);
1420 gtk_widget_show(hbox);
1422 notify_command_enable_set_sensitivity
1423 (GTK_TOGGLE_BUTTON(command_page.command_enabled), NULL);
1424 notify_command_folder_specific_set_sensitivity
1425 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific), NULL);
1426 gtk_widget_show(pvbox);
1427 command_page.page.widget = pvbox;
1430 static void notify_destroy_command_page(PrefsPage *page)
1434 static void notify_save_command(PrefsPage *page)
1436 gdouble timeout;
1437 const gchar *tmp_str;
1439 notify_config.command_enabled =
1440 gtk_toggle_button_get_active
1441 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1443 timeout =
1444 gtk_spin_button_get_value(GTK_SPIN_BUTTON(command_page.command_timeout));
1445 notify_config.command_timeout = (gint)floor(timeout*1000+0.5);
1446 notify_config.command_folder_specific =
1447 gtk_toggle_button_get_active
1448 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1450 tmp_str = gtk_entry_get_text(GTK_ENTRY(command_page.command_line));
1451 if(notify_config.command_line)
1452 g_free(notify_config.command_line);
1453 notify_config.command_line = g_strdup(tmp_str);
1456 static void notify_command_enable_set_sensitivity(GtkToggleButton *button,
1457 gpointer data)
1459 gboolean active;
1460 active = gtk_toggle_button_get_active
1461 (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1462 gtk_widget_set_sensitive(command_page.command_cont_enable, active);
1465 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton *bu,
1466 gpointer data)
1468 gboolean active;
1469 active = gtk_toggle_button_get_active
1470 (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1471 gtk_widget_set_sensitive(command_page.command_cont_folder_specific, active);
1474 #endif /* NOTIFICATION_COMMAND */
1476 #ifdef NOTIFICATION_LCDPROC
1477 static void notify_create_lcdproc_page(PrefsPage *page, GtkWindow *window,
1478 gpointer data)
1480 GtkWidget *pvbox;
1481 GtkWidget *vbox;
1482 GtkWidget *label;
1483 GtkWidget *entry;
1484 GtkWidget *spinner;
1485 GtkWidget *checkbox;
1486 GtkWidget *hbox;
1488 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1489 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1491 /* Enable lcdproc */
1492 checkbox = gtk_check_button_new_with_label(_("Enable LCD"));
1493 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1494 notify_config.lcdproc_enabled);
1495 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1496 g_signal_connect(G_OBJECT(checkbox), "toggled",
1497 G_CALLBACK(notify_lcdproc_enable_set_sensitivity), NULL);
1498 gtk_widget_show(checkbox);
1499 lcdproc_page.lcdproc_enabled = checkbox;
1501 /* Container vbox for greying out everything */
1502 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1503 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1504 gtk_widget_show(vbox);
1505 lcdproc_page.lcdproc_cont_enable = vbox;
1507 /* Hostname and port information */
1508 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1509 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1510 gtk_widget_show(hbox);
1511 label = gtk_label_new(_("Hostname:Port of LCDd server"));
1512 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1513 entry = gtk_entry_new();
1514 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.lcdproc_hostname);
1515 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1516 gtk_widget_show(entry);
1517 gtk_widget_show(label);
1518 label = gtk_label_new(":");
1519 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1520 gtk_widget_show(label);
1521 spinner = gtk_spin_button_new_with_range(1., 65535., 1.);
1522 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1523 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),
1524 notify_config.lcdproc_port);
1525 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1526 gtk_widget_show(spinner);
1527 lcdproc_page.lcdproc_hostname = entry;
1528 lcdproc_page.lcdproc_port = spinner;
1530 notify_lcdproc_enable_set_sensitivity
1531 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled), NULL);
1532 gtk_widget_show(pvbox);
1533 lcdproc_page.page.widget = pvbox;
1536 static void notify_destroy_lcdproc_page(PrefsPage *page)
1540 static void notify_save_lcdproc(PrefsPage *page)
1542 notify_config.lcdproc_enabled =
1543 gtk_toggle_button_get_active
1544 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1546 if(notify_config.lcdproc_hostname)
1547 g_free(notify_config.lcdproc_hostname);
1548 notify_config.lcdproc_hostname =
1549 g_strdup(gtk_entry_get_text(GTK_ENTRY(lcdproc_page.lcdproc_hostname)));
1551 notify_config.lcdproc_port =
1552 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lcdproc_page.lcdproc_port));
1554 if(notify_config.lcdproc_enabled)
1555 notification_lcdproc_connect();
1556 else
1557 notification_lcdproc_disconnect();
1560 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton *button,
1561 gpointer data)
1563 gboolean active;
1564 active = gtk_toggle_button_get_active
1565 (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1566 gtk_widget_set_sensitive(lcdproc_page.lcdproc_cont_enable, active);
1568 #endif /* NOTIFICATION_LCDPROC */
1570 #ifdef NOTIFICATION_TRAYICON
1571 static void notify_create_trayicon_page(PrefsPage *page, GtkWindow *window,
1572 gpointer data)
1574 GtkWidget *pvbox;
1575 GtkWidget *vbox;
1576 GtkWidget *checkbox;
1577 GtkWidget *hbox;
1578 GtkWidget *button;
1580 #if defined(HAVE_LIBNOTIFY)
1581 GtkWidget *frame;
1582 GtkWidget *svbox;
1583 GtkWidget *label;
1584 #endif
1586 #ifdef HAVE_LIBNOTIFY
1587 GtkWidget *ssvbox;
1588 GtkWidget *spinner;
1589 gdouble timeout;
1590 #endif
1592 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1593 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1595 /* Enable trayicon */
1596 checkbox = gtk_check_button_new_with_label(_("Enable Trayicon"));
1597 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1598 notify_config.trayicon_enabled);
1599 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1600 g_signal_connect(G_OBJECT(checkbox), "toggled",
1601 G_CALLBACK(notify_trayicon_enable_set_sensitivity), NULL);
1602 gtk_widget_show(checkbox);
1603 trayicon_page.trayicon_enabled = checkbox;
1605 /* Container vbox for greying out everything */
1606 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1607 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1608 gtk_widget_show(vbox);
1609 trayicon_page.trayicon_cont_enable = vbox;
1611 /* Hide at startup */
1612 checkbox = gtk_check_button_new_with_label(_("Hide at start-up"));
1613 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1614 notify_config.trayicon_hide_at_startup);
1615 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1616 gtk_widget_show(checkbox);
1617 trayicon_page.trayicon_hide_at_startup = checkbox;
1619 /* Close to tray */
1620 checkbox = gtk_check_button_new_with_label(_("Close to tray"));
1621 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1622 notify_config.trayicon_close_to_tray);
1623 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1624 gtk_widget_show(checkbox);
1625 trayicon_page.trayicon_close_to_tray = checkbox;
1627 /* Hide when iconified */
1628 checkbox = gtk_check_button_new_with_label(_("Hide when iconified"));
1629 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1630 notify_config.trayicon_hide_when_iconified);
1631 gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1632 gtk_widget_show(checkbox);
1633 trayicon_page.trayicon_hide_when_iconified = checkbox;
1635 /* folder specific */
1636 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1637 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1638 gtk_widget_show(hbox);
1639 checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1640 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1641 notify_config.trayicon_folder_specific);
1642 gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1643 g_signal_connect(G_OBJECT(checkbox), "toggled",
1644 G_CALLBACK(notify_trayicon_folder_specific_set_sensitivity),
1645 NULL);
1646 gtk_widget_show(checkbox);
1647 trayicon_page.trayicon_folder_specific = checkbox;
1648 button = gtk_button_new_with_label(_("Select folders..."));
1649 g_signal_connect(G_OBJECT(button), "clicked",
1650 G_CALLBACK(notification_foldercheck_sel_folders_cb),
1651 TRAYICON_SPECIFIC_FOLDER_ID_STR);
1652 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1653 trayicon_page.trayicon_cont_folder_specific = button;
1654 gtk_widget_show(button);
1656 #ifdef HAVE_LIBNOTIFY
1657 /* Frame for trayicon popup stuff */
1659 /* TRANSLATORS: "Toaster" does not refer to the kitchen appliance.
1660 A toast is a small passive (non-focus-stealing)
1661 notification bubble. If your language does not have a word
1662 for that, go for something along the lines of "passive popup"
1663 instead.See also
1664 http://en.wikipedia.org/wiki/Toast_(computing) */
1665 PACK_FRAME (vbox, frame, _("Passive toaster popup"))
1667 /* vbox for frame */
1668 svbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1669 gtk_container_set_border_width(GTK_CONTAINER(svbox), 5);
1670 gtk_container_add(GTK_CONTAINER(frame), svbox);
1671 gtk_widget_show(svbox);
1673 /* Enable popup for the tray icon */
1674 checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1675 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1676 notify_config.trayicon_popup_enabled);
1677 g_signal_connect(G_OBJECT(checkbox), "toggled",
1678 G_CALLBACK(notify_trayicon_popup_enable_set_sensitivity),
1679 NULL);
1680 gtk_box_pack_start(GTK_BOX(svbox), checkbox, FALSE, FALSE, 0);
1681 gtk_widget_show(checkbox);
1682 trayicon_page.trayicon_popup_enabled = checkbox;
1684 /* vbox for trayicon popup stuff enabled/disabled container */
1685 ssvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1686 gtk_box_pack_start(GTK_BOX(svbox), ssvbox, FALSE, FALSE, 0);
1687 gtk_widget_show(ssvbox);
1688 trayicon_page.trayicon_popup_cont_enable = ssvbox;
1690 /* timeout */
1691 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
1692 label = gtk_label_new(_("Popup timeout"));
1693 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1694 gtk_widget_show(label);
1695 spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1696 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1697 timeout = notify_config.trayicon_popup_timeout/1000.;
1698 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1699 gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1700 gtk_box_pack_start(GTK_BOX(ssvbox), hbox, FALSE, FALSE, 0);
1701 label = gtk_label_new(_("seconds"));
1702 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1704 checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1705 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1706 notify_config.trayicon_display_folder_name);
1707 gtk_box_pack_start(GTK_BOX(ssvbox), checkbox, FALSE, FALSE, 0);
1708 trayicon_page.trayicon_display_folder_name = checkbox;
1709 gtk_widget_show(checkbox);
1711 gtk_widget_show(spinner);
1712 gtk_widget_show(label);
1713 gtk_widget_show(hbox);
1714 trayicon_page.trayicon_popup_timeout = spinner;
1716 #endif
1718 notify_trayicon_enable_set_sensitivity
1719 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled), NULL);
1721 #ifdef HAVE_LIBNOTIFY
1722 notify_trayicon_popup_enable_set_sensitivity
1723 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled), NULL);
1724 #endif
1726 notify_trayicon_folder_specific_set_sensitivity
1727 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific), NULL);
1729 gtk_widget_show(pvbox);
1730 trayicon_page.page.widget = pvbox;
1733 static void notify_destroy_trayicon_page(PrefsPage *page)
1737 static void notify_save_trayicon(PrefsPage *page)
1739 #ifdef HAVE_LIBNOTIFY
1740 gdouble timeout;
1741 #endif
1743 notify_config.trayicon_enabled =
1744 gtk_toggle_button_get_active
1745 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1747 notify_config.trayicon_hide_at_startup =
1748 gtk_toggle_button_get_active
1749 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_at_startup));
1751 notify_config.trayicon_close_to_tray =
1752 gtk_toggle_button_get_active
1753 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_close_to_tray));
1755 notify_config.trayicon_hide_when_iconified =
1756 gtk_toggle_button_get_active
1757 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_when_iconified));
1759 #ifdef HAVE_LIBNOTIFY
1760 notify_config.trayicon_popup_enabled =
1761 gtk_toggle_button_get_active
1762 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1764 timeout =
1765 gtk_spin_button_get_value(GTK_SPIN_BUTTON
1766 (trayicon_page.trayicon_popup_timeout));
1767 notify_config.trayicon_popup_timeout = (gint)floor(timeout*1000+0.5);
1769 notify_config.trayicon_display_folder_name =
1770 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trayicon_page.trayicon_display_folder_name));
1771 #endif
1773 notify_config.trayicon_folder_specific =
1774 gtk_toggle_button_get_active
1775 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1777 if(notify_config.trayicon_enabled)
1778 notification_update_msg_counts(NULL);
1779 else
1780 notification_trayicon_destroy();
1783 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton *button,
1784 gpointer data)
1786 gboolean active;
1787 active = gtk_toggle_button_get_active
1788 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1789 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_enable, active);
1792 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton *bu,
1793 gpointer data)
1795 gboolean active;
1796 active = gtk_toggle_button_get_active
1797 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1798 gtk_widget_set_sensitive(trayicon_page.trayicon_cont_folder_specific, active);
1801 #ifdef HAVE_LIBNOTIFY
1802 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton *bu,
1803 gpointer data)
1805 gboolean active;
1806 active = gtk_toggle_button_get_active
1807 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1808 gtk_widget_set_sensitive(trayicon_page.trayicon_popup_cont_enable, active);
1811 #endif /* HAVE_LIBNOTIFY */
1813 #endif /* NOTIFICATION_TRAYICON */
1815 #ifdef NOTIFICATION_AYATANA_INDICATOR
1817 static void notify_create_ayatana_indicator_page(PrefsPage *page, GtkWindow *window,
1818 gpointer data)
1820 GtkWidget *pvbox;
1821 GtkWidget *vbox;
1822 GtkWidget *checkbox;
1824 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1825 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1827 /* Enable indicator */
1828 checkbox = gtk_check_button_new_with_label(_("Enable Ayatana App Indicator"));
1829 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1830 notify_config.ayatana_indicator_enabled);
1831 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1832 ayatana_indicator_page.ayatana_indicator_enabled = checkbox;
1834 /* Container vbox for greying out everything */
1835 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1836 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1838 gtk_widget_show_all(pvbox);
1839 ayatana_indicator_page.page.widget = pvbox;
1842 static void notify_destroy_ayatana_indicator_page(PrefsPage *page)
1846 static void notify_save_ayatana_indicator(PrefsPage *page)
1848 notification_ayatana_indicator_disable();
1850 notify_config.ayatana_indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ayatana_indicator_page.ayatana_indicator_enabled));
1852 if(notify_config.ayatana_indicator_enabled) {
1853 notification_ayatana_indicator_enable();
1854 notification_update_ayatana_indicator();
1857 #endif /* NOTIFICATION_AYATANA_INDICATOR */
1859 #ifdef NOTIFICATION_INDICATOR
1861 static void notify_create_indicator_page(PrefsPage *page, GtkWindow *window,
1862 gpointer data)
1864 GtkWidget *pvbox;
1865 GtkWidget *vbox;
1866 GtkWidget *checkbox;
1867 GtkWidget *ind_reg;
1869 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1870 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1872 /* Enable indicator */
1873 checkbox = gtk_check_button_new_with_label(_("Add to Indicator Applet"));
1874 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1875 notify_config.indicator_enabled);
1876 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1877 g_signal_connect(G_OBJECT(checkbox), "toggled",
1878 G_CALLBACK(notify_indicator_enable_set_sensitivity), NULL);
1879 indicator_page.indicator_enabled = checkbox;
1881 /* Container vbox for greying out everything */
1882 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1883 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1884 indicator_page.indicator_cont_enable = vbox;
1886 /* hide when minimized */
1887 checkbox = gtk_check_button_new_with_label(_("Hide mainwindow when minimized"));
1888 gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), checkbox, FALSE, FALSE, 0);
1889 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.indicator_hide_minimized);
1890 indicator_page.indicator_hide_minimized = checkbox;
1892 notify_indicator_enable_set_sensitivity(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled), NULL);
1893 gtk_widget_show_all(pvbox);
1894 indicator_page.page.widget = pvbox;
1897 static void notify_destroy_indicator_page(PrefsPage *page)
1901 static void notify_save_indicator(PrefsPage *page)
1903 notification_indicator_destroy();
1905 notify_config.indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1907 notify_config.indicator_hide_minimized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_hide_minimized));
1909 if(notify_config.indicator_enabled) {
1910 notification_indicator_setup();
1911 notification_update_indicator();
1915 static void notify_indicator_enable_set_sensitivity(GtkToggleButton *button,
1916 gpointer data)
1918 gboolean active;
1919 active = gtk_toggle_button_get_active
1920 (GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1921 gtk_widget_set_sensitive(indicator_page.indicator_cont_enable, active);
1923 #endif /* NOTIFICATION_INDICATOR */
1925 #if defined NOTIFICATION_HOTKEYS && defined GDK_WINDOWING_X11
1926 static void notify_create_hotkeys_page(PrefsPage *page, GtkWindow *window, gpointer data)
1928 GtkWidget *pvbox;
1929 GtkWidget *vbox;
1930 GtkWidget *checkbox;
1931 GtkWidget *label;
1932 gchar *markup;
1933 GtkWidget *hbox;
1934 GtkWidget *entry;
1936 pvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 20);
1937 gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1939 /* Enable hotkeys */
1940 checkbox = gtk_check_button_new_with_label(_("Enable global hotkeys"));
1941 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.hotkeys_enabled);
1942 gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1943 g_signal_connect(G_OBJECT(checkbox), "toggled",
1944 G_CALLBACK(notify_hotkeys_enable_set_sensitivity), NULL);
1945 hotkeys_page.hotkeys_enabled = checkbox;
1947 /* Container vbox for greying out everything */
1948 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
1949 gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1950 hotkeys_page.hotkeys_cont_enable = vbox;
1952 /* description */
1953 label = gtk_label_new("");
1954 markup = g_markup_printf_escaped(_("Examples for hotkeys include <b>%s</b> and <b>%s</b>"), _("<control><shift>F11"), _("<alt>N"));
1955 gtk_label_set_markup(GTK_LABEL(label), markup);
1956 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
1957 gtk_label_set_yalign(GTK_LABEL(label), 0.0);
1958 g_free(markup);
1959 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), label, FALSE, FALSE, 0);
1961 /* hbox for entry fields */
1962 hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
1963 gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), hbox, FALSE, FALSE, 0);
1965 /* toggle mainwindow */
1966 label = gtk_label_new(_("Toggle minimize"));
1967 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1968 entry = gtk_entry_new();
1969 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1970 if(notify_config.hotkeys_toggle_mainwindow)
1971 gtk_entry_set_text(GTK_ENTRY(entry), notify_config.hotkeys_toggle_mainwindow);
1972 hotkeys_page.hotkeys_toggle_mainwindow = entry;
1974 notify_hotkeys_enable_set_sensitivity(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled), NULL);
1975 gtk_widget_show_all(pvbox);
1976 hotkeys_page.page.widget = pvbox;
1979 static void notify_destroy_hotkeys_page(PrefsPage *page)
1983 static void notify_save_hotkeys(PrefsPage *page)
1985 const gchar *tmp_str;
1986 notify_config.hotkeys_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1988 tmp_str = gtk_entry_get_text(GTK_ENTRY(hotkeys_page.hotkeys_toggle_mainwindow));
1989 if(notify_config.hotkeys_toggle_mainwindow)
1990 g_free(notify_config.hotkeys_toggle_mainwindow);
1991 notify_config.hotkeys_toggle_mainwindow = g_strdup(tmp_str);
1993 notification_hotkeys_update_bindings();
1996 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton *button,
1997 gpointer data)
1999 gboolean active;
2000 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
2001 gtk_widget_set_sensitive(hotkeys_page.hotkeys_cont_enable, active);
2003 #endif /* hotkeys */