Do not translate g_warning() strings
[claws.git] / src / plugins / notification / notification_prefs.c
1 /* Notification plugin for Claws-Mail
2  * Copyright (C) 2005-2015 Hiroyuki Yamamoto and the Claws Mail team
3  * Copyright (C) 2005-2015 Holger Berndt
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #ifdef HAVE_CONFIG_H
20 #  include "config.h"
21 #  include "claws-features.h"
22 #endif
23
24 #include <glib.h>
25 #include <glib/gi18n.h>
26
27 #include <math.h>
28
29 #include "prefs_gtk.h"
30 #include "common/prefs.h"
31 #include "common/utils.h"
32 #include "common/defs.h"
33 #include "gtk/gtkutils.h"
34 #include "gtk/filesel.h"
35 #include "main.h"
36
37 #include "notification_prefs.h"
38 #include "notification_plugin.h"
39 #include "notification_core.h"
40
41 #include "notification_popup.h"
42 #include "notification_command.h"
43 #include "notification_lcdproc.h"
44 #include "notification_trayicon.h"
45 #include "notification_indicator.h"
46 #include "notification_hotkeys.h"
47
48 #include "notification_foldercheck.h"
49
50 #ifdef HAVE_LIBNOTIFY
51 /* allow infinite timeout with libnotify */
52 # define TIMEOUT_SPINNER_MIN     0.0
53 #else
54 /* don't allow infinite timeout with self-handled popups */
55 # define TIMEOUT_SPINNER_MIN     0.2
56 #endif
57
58 #define TIMEOUT_SPINNER_MAX  3600.0
59 #define TIMEOUT_SPINNER_STEP    0.5
60
61 typedef struct
62 {
63         PrefsPage page;
64         GtkWidget *include_mail;
65         GtkWidget *include_news;
66         GtkWidget *include_rss;
67         GtkWidget *include_calendar;
68         GtkWidget *urgency_hint_new;
69         GtkWidget *urgency_hint_unread;
70 #ifdef HAVE_LIBCANBERRA_GTK
71         GtkWidget *canberra_play_sounds;
72 #endif
73 } NotifyPage;
74
75 NotifyPrefs notify_config;
76 NotifyPage notify_page;
77
78 #ifdef NOTIFICATION_BANNER
79 typedef struct {
80         PrefsPage page;
81         GtkWidget *banner_show;
82         GtkWidget *banner_speed;
83         GtkWidget *banner_width;
84         GtkWidget *banner_include_unread;
85         GtkWidget *banner_max_msgs;
86         GtkWidget *banner_sticky;
87         GtkWidget *banner_folder_specific;
88         GtkWidget *banner_enable_colors;
89         GtkWidget *banner_color_bg;
90         GtkWidget *banner_color_fg;
91         GtkWidget *banner_cont_enable;
92         GtkWidget *banner_cont_folder_specific;
93         GtkWidget *banner_cont_color_sel;
94 }NotifyBannerPage;
95 NotifyBannerPage banner_page;
96 #endif /* NOTIFICATION_BANNER */
97
98 #ifdef NOTIFICATION_POPUP
99 typedef struct {
100         PrefsPage page;
101         GtkWidget *popup_show;
102         GtkWidget *popup_timeout;
103         GtkWidget *popup_folder_specific;
104         GtkWidget *popup_cont_enable;
105         GtkWidget *popup_cont_folder_specific;
106 #ifndef HAVE_LIBNOTIFY
107         GtkWidget *popup_sticky;
108         GtkWidget *popup_enable_colors;
109         GtkWidget *popup_color_bg;
110         GtkWidget *popup_color_fg;
111         GtkWidget *popup_cont_color_sel;
112 #else /* HAVE_LIBNOTIFY */
113         GtkWidget *popup_display_folder_name;
114 #endif /* HAVE_LIBNOTIFY */
115 }NotifyPopupPage;
116 NotifyPopupPage popup_page;
117 #endif /* NOTIFICATION_POPUP */
118
119 #ifdef NOTIFICATION_COMMAND
120 typedef struct {
121         PrefsPage page;
122         GtkWidget *command_enabled;
123         GtkWidget *command_timeout;
124         GtkWidget *command_folder_specific;
125         GtkWidget *command_line;
126         GtkWidget *command_cont_enable;
127         GtkWidget *command_cont_folder_specific;
128 }NotifyCommandPage;
129 NotifyCommandPage command_page;
130 #endif /* NOTIFICATION_COMMAND */
131
132 #ifdef NOTIFICATION_LCDPROC
133 typedef struct {
134         PrefsPage page;
135         GtkWidget *lcdproc_enabled;
136         GtkWidget *lcdproc_cont_enable;
137         GtkWidget *lcdproc_hostname;
138         GtkWidget *lcdproc_port;
139 }NotifyLCDProcPage;
140 NotifyLCDProcPage lcdproc_page;
141 #endif
142
143 #ifdef NOTIFICATION_TRAYICON
144 typedef struct {
145         PrefsPage page;
146         GtkWidget *trayicon_enabled;
147         GtkWidget *trayicon_cont_enable;
148         GtkWidget *trayicon_hide_at_startup;
149         GtkWidget *trayicon_close_to_tray;
150         GtkWidget *trayicon_hide_when_iconified;
151         GtkWidget *trayicon_folder_specific;
152         GtkWidget *trayicon_cont_folder_specific;
153 #ifdef HAVE_LIBNOTIFY
154         GtkWidget *trayicon_display_folder_name;
155         GtkWidget *trayicon_popup_enabled;
156         GtkWidget *trayicon_popup_cont_enable;
157         GtkWidget *trayicon_popup_timeout;
158 #endif
159 }NotifyTrayiconPage;
160 NotifyTrayiconPage trayicon_page;
161 #endif
162
163 #ifdef NOTIFICATION_INDICATOR
164 typedef struct {
165         PrefsPage page;
166         GtkWidget *indicator_enabled;
167         GtkWidget *indicator_cont_enable;
168         GtkWidget *indicator_register;
169         GtkWidget *indicator_hide_minimized;
170 }NotifyIndicatorPage;
171 NotifyIndicatorPage indicator_page;
172 #endif
173
174 #ifdef NOTIFICATION_HOTKEYS
175 typedef struct {
176     PrefsPage page;
177     GtkWidget *hotkeys_enabled;
178     GtkWidget *hotkeys_cont_enable;
179     GtkWidget *hotkeys_toggle_mainwindow;
180 }NotifyHotkeysPage;
181 NotifyHotkeysPage hotkeys_page;
182 #endif
183
184
185 PrefParam
186                 notify_param[] =
187                 {
188
189                                 { "include_mail", "TRUE", &notify_config.include_mail, P_BOOL, NULL,
190                                                 NULL, NULL },
191                                 { "include_news", "TRUE", &notify_config.include_news, P_BOOL, NULL,
192                                                 NULL, NULL },
193                                 { "include_rss", "TRUE", &notify_config.include_rss, P_BOOL, NULL,
194                                                 NULL, NULL },
195                                 { "include_calendar", "TRUE", &notify_config.include_calendar, P_BOOL,
196                                                 NULL, NULL, NULL },
197                                 { "urgency_hint_new", "FALSE", &notify_config.urgency_hint_new, P_BOOL,
198                                                 NULL, NULL, NULL },
199                                 { "urgency_hint_unread", "FALSE", &notify_config.urgency_hint_unread, P_BOOL,
200                                                 NULL, NULL, NULL },
201
202 #ifdef HAVE_LIBCANBERRA_GTK
203                 { "canberra_play_sounds", "TRUE", &notify_config.canberra_play_sounds, P_BOOL,
204                         NULL, NULL, NULL },
205 #endif
206
207 #ifdef NOTIFICATION_BANNER
208                                 {       "banner_show", "0", &notify_config.banner_show, P_INT, NULL, NULL, NULL},
209                                 {       "banner_speed", "30", &notify_config.banner_speed, P_INT, NULL, NULL, NULL},
210                                 {       "banner_width", "0", &notify_config.banner_width, P_INT, NULL, NULL, NULL},
211                                 {       "banner_include_unread", "FALSE", &notify_config.banner_include_unread,
212                                         P_BOOL, NULL, NULL, NULL},
213                                 {       "banner_max_msgs", "100", &notify_config.banner_max_msgs, P_INT,
214                                         NULL, NULL, NULL},
215                                 {       "banner_sticky", "FALSE", &notify_config.banner_sticky,
216                                         P_BOOL, NULL, NULL, NULL},
217                                 {       "banner_root_x", "0", &notify_config.banner_root_x, P_INT,
218                                         NULL, NULL, NULL},
219                                 {       "banner_root_y", "10", &notify_config.banner_root_y, P_INT,
220                                         NULL, NULL, NULL},
221                                 {       "banner_folder_specific", "FALSE", &notify_config.banner_folder_specific,
222                                         P_BOOL, NULL, NULL, NULL},
223                                 {       "banner_enable_colors", "FALSE", &notify_config.banner_enable_colors,
224                                         P_BOOL, NULL, NULL, NULL},
225                                 {       "banner_color_bg", "0", &notify_config.banner_color_bg, P_COLOR,
226                                         NULL, NULL, NULL},
227                                 {       "banner_color_fg", "16776704", &notify_config.banner_color_fg, P_COLOR,
228                                         NULL, NULL, NULL},
229 #endif
230
231 #ifdef NOTIFICATION_POPUP
232                                 {       "popup_show", "TRUE", &notify_config.popup_show, P_BOOL, NULL, NULL, NULL},
233                                 {       "popup_timeout", "5000", &notify_config.popup_timeout,
234                                         P_INT, NULL, NULL, NULL},
235                                 {       "popup_folder_specific", "FALSE", &notify_config.popup_folder_specific,
236                                         P_BOOL, NULL, NULL, NULL},
237 #ifndef HAVE_LIBNOTIFY
238                                 {       "popup_sticky", "TRUE", &notify_config.popup_sticky, P_BOOL,
239                                         NULL, NULL, NULL},
240                                 {       "popup_root_x", "10", &notify_config.popup_root_x,
241                                         P_INT, NULL, NULL, NULL},
242                                 {       "popup_root_y", "10", &notify_config.popup_root_y,
243                                         P_INT, NULL, NULL, NULL},
244                                 {       "popup_width", "100", &notify_config.popup_width,
245                                         P_INT, NULL, NULL, NULL},
246                                 {       "popup_enable_colors", "FALSE", &notify_config.popup_enable_colors, P_BOOL,
247                                         NULL, NULL, NULL},
248                                 {       "popup_color_bg", "0", &notify_config.popup_color_bg, P_COLOR,
249                                         NULL, NULL, NULL},
250                                 {       "popup_color_fg", "16776704", &notify_config.popup_color_fg, P_COLOR,
251                                         NULL, NULL, NULL},
252 #else /* HAVE_LIBNOTIFY */
253                                 {       "popup_display_folder_name", "FALSE", &notify_config.popup_display_folder_name,
254                                         P_BOOL, NULL, NULL, NULL},
255 #endif /* HAVE_LIBNOTIFY */
256 #endif
257
258 #ifdef NOTIFICATION_COMMAND
259                                 {       "command_enabled", "FALSE", &notify_config.command_enabled, P_BOOL,
260                                         NULL, NULL, NULL},
261                                 {       "command_timeout", "60000", &notify_config.command_timeout, P_INT,
262                                         NULL, NULL, NULL},
263                                 {       "command_folder_specific", "FALSE", &notify_config.command_folder_specific,
264                                         P_BOOL, NULL, NULL, NULL},
265                                 {       "command_line", "", &notify_config.command_line, P_STRING,
266                                         NULL, NULL, NULL},
267 #endif
268
269 #ifdef NOTIFICATION_LCDPROC
270                                 {       "lcdproc_enabled", "FALSE", &notify_config.lcdproc_enabled, P_BOOL,
271                                         NULL, NULL, NULL},
272                                 {       "lcdproc_hostname", "localhost", &notify_config.lcdproc_hostname, P_STRING,
273                                         NULL, NULL, NULL},
274                                 {       "lcdproc_port", "13666", &notify_config.lcdproc_port, P_INT,
275                                         NULL, NULL, NULL},
276 #endif
277
278 #ifdef NOTIFICATION_TRAYICON
279 #ifndef G_OS_WIN32
280                                 {       "trayicon_enabled", "FALSE", &notify_config.trayicon_enabled, P_BOOL,
281                                         NULL, NULL, NULL},
282 #else
283                                 {       "trayicon_enabled", "TRUE", &notify_config.trayicon_enabled, P_BOOL,
284                                         NULL, NULL, NULL},
285 #endif
286                                 {       "trayicon_hide_at_startup", "FALSE",
287                                         &notify_config.trayicon_hide_at_startup, P_BOOL, NULL, NULL, NULL},
288                                 {       "trayicon_close_to_tray", "FALSE",
289                                         &notify_config.trayicon_close_to_tray, P_BOOL, NULL, NULL, NULL},
290                                 {       "trayicon_hide_when_iconified", "FALSE",
291                                         &notify_config.trayicon_hide_when_iconified, P_BOOL, NULL, NULL, NULL},
292                                 {       "trayicon_folder_specific", "FALSE",
293                                         &notify_config.trayicon_folder_specific,
294                                         P_BOOL, NULL, NULL, NULL},
295 #ifdef HAVE_LIBNOTIFY
296                                 {       "trayicon_display_folder_name", "FALSE",
297                                         &notify_config.trayicon_display_folder_name,
298                                         P_BOOL, NULL, NULL, NULL},
299                                 {       "trayicon_popup_enabled", "TRUE", &notify_config.trayicon_popup_enabled,
300                                         P_BOOL, NULL, NULL, NULL},
301                                 {       "trayicon_popup_timeout", "5000", &notify_config.trayicon_popup_timeout,
302                                         P_INT, NULL, NULL, NULL},
303 #endif /* HAVE_LIBNOTIFY */
304 #endif
305
306 #ifdef NOTIFICATION_INDICATOR
307                                 {       "indicator_enabled", "FALSE", &notify_config.indicator_enabled, P_BOOL,
308                                         NULL, NULL, NULL},
309                 {   "indicator_hide_minimized", "FALSE", &notify_config.indicator_hide_minimized, P_BOOL,
310                     NULL, NULL, NULL},
311 #endif /* NOTIFICATION_INDICATOR */
312 #ifdef NOTIFICATION_HOTKEYS
313                 {   "hotkeys_enabled", "FALSE", &notify_config.hotkeys_enabled, P_BOOL,
314                     NULL, NULL, NULL},
315                 {   "hotkeys_toggle_mainwindow", "", &notify_config.hotkeys_toggle_mainwindow,
316                     P_STRING, NULL, NULL, NULL},
317 #endif /* NOTIFICATION_HOTKEYS */
318                                 { NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL } };
319
320 static void notify_create_prefs_page(PrefsPage*, GtkWindow*, gpointer);
321 static void notify_destroy_prefs_page(PrefsPage*);
322 static void notify_save_prefs(PrefsPage*);
323
324 #ifdef NOTIFICATION_BANNER
325 static void notify_create_banner_page(PrefsPage*, GtkWindow*, gpointer);
326 static void notify_destroy_banner_page(PrefsPage*);
327 static void notify_save_banner(PrefsPage*);
328 static void notify_banner_enable_set_sensitivity(GtkComboBox*, gpointer);
329 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
330 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton*,
331                 gpointer);
332 #endif
333
334 #ifdef NOTIFICATION_POPUP
335 static void notify_create_popup_page(PrefsPage*, GtkWindow*, gpointer);
336 static void notify_destroy_popup_page(PrefsPage*);
337 static void notify_save_popup(PrefsPage*);
338 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton*,
339                 gpointer);
340 static void notify_popup_enable_set_sensitivity(GtkToggleButton*, gpointer);
341 #ifndef HAVE_LIBNOTIFY
342 static void notify_popup_set_done_cb(GtkWidget*, gpointer);
343 static void notify_popup_set_cb(GtkWidget*, gpointer);
344 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton*,gpointer);
345 #endif /* !HAVE_LIBNOTIFY */
346 #endif
347
348 #ifdef NOTIFICATION_COMMAND
349 static void notify_command_browse_cb(GtkWidget* widget, gpointer data);
350 static void notify_create_command_page(PrefsPage*, GtkWindow*, gpointer);
351 static void notify_destroy_command_page(PrefsPage*);
352 static void notify_save_command(PrefsPage*);
353 static void notify_command_enable_set_sensitivity(GtkToggleButton*, gpointer);
354 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton*,
355                 gpointer);
356 #endif
357
358 #ifdef NOTIFICATION_LCDPROC
359 static void notify_create_lcdproc_page(PrefsPage*, GtkWindow*, gpointer);
360 static void notify_destroy_lcdproc_page(PrefsPage*);
361 static void notify_save_lcdproc(PrefsPage*);
362 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton*, gpointer);
363 #endif
364
365 #ifdef NOTIFICATION_TRAYICON
366 static void notify_create_trayicon_page(PrefsPage*, GtkWindow*, gpointer);
367 static void notify_destroy_trayicon_page(PrefsPage*);
368 static void notify_save_trayicon(PrefsPage*);
369 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton*, gpointer);
370 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton*,
371                 gpointer);
372 #ifdef HAVE_LIBNOTIFY
373 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton*,
374                 gpointer);
375 #endif
376 #endif
377
378 #ifdef NOTIFICATION_INDICATOR
379 static void notify_create_indicator_page(PrefsPage*, GtkWindow*, gpointer);
380 static void notify_destroy_indicator_page(PrefsPage*);
381 static void notify_save_indicator(PrefsPage*);
382 static void notify_indicator_enable_set_sensitivity(GtkToggleButton*, gpointer);
383 #endif /* NOTIFICATION_INDICATOR */
384
385 #ifdef NOTIFICATION_HOTKEYS
386 static void notify_create_hotkeys_page(PrefsPage*, GtkWindow*, gpointer);
387 static void notify_destroy_hotkeys_page(PrefsPage*);
388 static void notify_save_hotkeys(PrefsPage*);
389 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton*, gpointer);
390 #endif /* NOTIFICATION_HOTKEYS */
391
392
393 static gint conv_color_to_int(GdkColor*);
394
395 void notify_gtk_init(void)
396 {
397         static gchar *path[3];
398
399         path[0] = _("Plugins");
400         path[1] = _("Notification");
401         path[2] = NULL;
402
403         notify_page.page.path = path;
404         notify_page.page.create_widget = notify_create_prefs_page;
405         notify_page.page.destroy_widget = notify_destroy_prefs_page;
406         notify_page.page.save_page = notify_save_prefs;
407         notify_page.page.weight = 40.0;
408         prefs_gtk_register_page((PrefsPage*) &notify_page);
409
410 #ifdef NOTIFICATION_HOTKEYS
411     {
412         static gchar *hotkeys_path[4];
413
414         hotkeys_path[0] = _("Plugins");
415         hotkeys_path[1] = _("Notification");
416         hotkeys_path[2] = _("Hotkeys");
417         hotkeys_path[3] = NULL;
418
419         hotkeys_page.page.path = hotkeys_path;
420         hotkeys_page.page.create_widget = notify_create_hotkeys_page;
421         hotkeys_page.page.destroy_widget = notify_destroy_hotkeys_page;
422         hotkeys_page.page.save_page = notify_save_hotkeys;
423         hotkeys_page.page.weight = 10.0;
424         prefs_gtk_register_page((PrefsPage*) &hotkeys_page);
425     }
426 #endif /* NOTIFICATION_HOTKEYS */
427
428
429 #ifdef NOTIFICATION_BANNER
430         {
431                 static gchar *banner_path[4];
432
433                 banner_path[0] = _("Plugins");
434                 banner_path[1] = _("Notification");
435                 banner_path[2] = _("Banner");
436                 banner_path[3] = NULL;
437
438                 banner_page.page.path = banner_path;
439                 banner_page.page.create_widget = notify_create_banner_page;
440                 banner_page.page.destroy_widget = notify_destroy_banner_page;
441                 banner_page.page.save_page = notify_save_banner;
442                 banner_page.page.weight = 20.0;
443                 prefs_gtk_register_page((PrefsPage*) &banner_page);
444         }
445 #endif /* NOTIFICATION_BANNER */
446
447 #ifdef NOTIFICATION_POPUP
448         {
449                 static gchar *popup_path[4];
450
451                 popup_path[0] = _("Plugins");
452                 popup_path[1] = _("Notification");
453                 popup_path[2] = _("Popup");
454                 popup_path[3] = NULL;
455
456                 popup_page.page.path = popup_path;
457                 popup_page.page.create_widget = notify_create_popup_page;
458                 popup_page.page.destroy_widget = notify_destroy_popup_page;
459                 popup_page.page.save_page = notify_save_popup;
460                 popup_page.page.weight = 30.0;
461                 prefs_gtk_register_page((PrefsPage*) &popup_page);
462         }
463 #endif /* NOTIFICATION_POPUP */
464
465 #ifdef NOTIFICATION_COMMAND
466         {
467                 static gchar *command_path[4];
468
469                 command_path[0] = _("Plugins");
470                 command_path[1] = _("Notification");
471                 command_path[2] = _("Command");
472                 command_path[3] = NULL;
473
474                 command_page.page.path = command_path;
475                 command_page.page.create_widget = notify_create_command_page;
476                 command_page.page.destroy_widget = notify_destroy_command_page;
477                 command_page.page.save_page = notify_save_command;
478                 command_page.page.weight = 40.0;
479                 prefs_gtk_register_page((PrefsPage*) &command_page);
480         }
481 #endif /* NOTIFICATION_COMMAND */
482
483 #ifdef NOTIFICATION_LCDPROC
484         {
485                 static gchar *lcdproc_path[4];
486
487                 lcdproc_path[0] = _("Plugins");
488                 lcdproc_path[1] = _("Notification");
489                 lcdproc_path[2] = _("LCD");
490                 lcdproc_path[3] = NULL;
491
492                 lcdproc_page.page.path = lcdproc_path;
493                 lcdproc_page.page.create_widget = notify_create_lcdproc_page;
494                 lcdproc_page.page.destroy_widget = notify_destroy_lcdproc_page;
495                 lcdproc_page.page.save_page = notify_save_lcdproc;
496                 lcdproc_page.page.weight = 50.0;
497                 prefs_gtk_register_page((PrefsPage*) &lcdproc_page);
498         }
499 #endif /* NOTIFICATION_LCDPROC */
500
501 #ifdef NOTIFICATION_TRAYICON
502         {
503                 static gchar *trayicon_path[4];
504
505                 trayicon_path[0] = _("Plugins");
506                 trayicon_path[1] = _("Notification");
507                 trayicon_path[2] = _("SysTrayicon");
508                 trayicon_path[3] = NULL;
509
510                 trayicon_page.page.path = trayicon_path;
511                 trayicon_page.page.create_widget = notify_create_trayicon_page;
512                 trayicon_page.page.destroy_widget = notify_destroy_trayicon_page;
513                 trayicon_page.page.save_page = notify_save_trayicon;
514                 trayicon_page.page.weight = 60.0;
515                 prefs_gtk_register_page((PrefsPage*) &trayicon_page);
516         }
517 #endif /* NOTIFICATION_TRAYICON */
518
519 #ifdef NOTIFICATION_INDICATOR
520         {
521                 static gchar *indicator_path[4];
522
523                 indicator_path[0] = _("Plugins");
524                 indicator_path[1] = _("Notification");
525                 indicator_path[2] = _("Indicator");
526                 indicator_path[3] = NULL;
527
528                 indicator_page.page.path = indicator_path;
529                 indicator_page.page.create_widget = notify_create_indicator_page;
530                 indicator_page.page.destroy_widget = notify_destroy_indicator_page;
531                 indicator_page.page.save_page = notify_save_indicator;
532                 indicator_page.page.weight = 70.0;
533                 prefs_gtk_register_page((PrefsPage*) &indicator_page);
534         }
535 #endif /* NOTIFICATION_INDICATOR */
536 }
537
538 void notify_gtk_done(void)
539 {
540         if (claws_is_exiting())
541                 return;
542         prefs_gtk_unregister_page((PrefsPage*) &notify_page);
543 #ifdef NOTIFICATION_BANNER
544         prefs_gtk_unregister_page((PrefsPage*) &banner_page);
545 #endif
546 #ifdef NOTIFICATION_POPUP
547         prefs_gtk_unregister_page((PrefsPage*) &popup_page);
548 #endif
549 #ifdef NOTIFICATION_COMMAND
550         prefs_gtk_unregister_page((PrefsPage*) &command_page);
551 #endif
552 #ifdef NOTIFICATION_LCDPROC
553         prefs_gtk_unregister_page((PrefsPage*) &lcdproc_page);
554 #endif
555 #ifdef NOTIFICATION_TRAYICON
556         prefs_gtk_unregister_page((PrefsPage*) &trayicon_page);
557 #endif
558 #ifdef NOTIFICATION_INDICATOR
559         prefs_gtk_unregister_page((PrefsPage*) &indicator_page);
560 #endif
561 #ifdef NOTIFICATION_HOTKEYS
562         prefs_gtk_unregister_page((PrefsPage*) &hotkeys_page);
563 #endif
564 }
565
566 void notify_save_config(void)
567 {
568         PrefFile *pfile;
569         gchar *rcpath;
570
571         debug_print("Saving Notification plugin configuration...\n");
572
573         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
574         pfile = prefs_write_open(rcpath);
575         g_free(rcpath);
576         if (!pfile || (prefs_set_block_label(pfile, "NotificationPlugin") < 0))
577                 return;
578
579         if (prefs_write_param(notify_param, pfile->fp) < 0) {
580                 debug_print("failed!\n");
581                 g_warning("Notification Plugin: Failed to write plugin configuration "
582                                                 "to file");
583                 prefs_file_close_revert(pfile);
584                 return;
585         }
586         if (fprintf(pfile->fp, "\n") < 0) {
587                 FILE_OP_ERROR(rcpath, "fprintf");
588                 prefs_file_close_revert(pfile);
589         }
590         else
591                 prefs_file_close(pfile);
592         debug_print("done.\n");
593 }
594
595 static void notify_create_prefs_page(PrefsPage *page, GtkWindow *window,
596                 gpointer data)
597 {
598         GtkWidget *pvbox;
599         GtkWidget *vbox;
600         GtkWidget *checkbox;
601         GtkWidget *frame;
602         GtkWidget *label;
603
604         /* Page vbox */
605         pvbox = gtk_vbox_new(FALSE, 0);
606
607         /* Frame */
608         PACK_FRAME (pvbox, frame, _("Include folder types"))
609         gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
610
611         /* Frame vbox */
612         vbox = gtk_vbox_new(FALSE, 4);
613         gtk_container_add(GTK_CONTAINER(frame), vbox);
614         gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
615
616         /* Include mail folders */
617         checkbox = gtk_check_button_new_with_label(_("Mail folders"));
618         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
619         notify_config.include_mail);
620         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
621         gtk_widget_show(checkbox);
622         notify_page.include_mail = checkbox;
623
624         /* Include news folders */
625         checkbox = gtk_check_button_new_with_label(_("News folders"));
626         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
627         notify_config.include_news);
628         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
629         gtk_widget_show(checkbox);
630         notify_page.include_news = checkbox;
631
632         /* Include RSSyl folders */
633         checkbox = gtk_check_button_new_with_label(_("RSSyl folders"));
634         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
635         notify_config.include_rss);
636         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
637         gtk_widget_show(checkbox);
638         notify_page.include_rss = checkbox;
639
640         /* Include calendar folders */
641         checkbox = gtk_check_button_new_with_label(_("vCalendar folders"));
642         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
643                         notify_config.include_calendar);
644         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
645         gtk_widget_show(checkbox);
646         notify_page.include_calendar = checkbox;
647
648         /* Warning-Label */
649         label = gtk_label_new(_("These settings override folder-specific "
650                         "selections."));
651         gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
652         gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
653         gtk_widget_show(label);
654
655         /* done with the frame */
656         gtk_widget_show(frame);
657         gtk_widget_show(vbox);
658
659         /* Frame */
660         PACK_FRAME (pvbox, frame, _("Global notification settings"));
661         gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
662
663         /* Frame vbox */
664         vbox = gtk_vbox_new(FALSE, 4);
665         gtk_container_add(GTK_CONTAINER(frame), vbox);
666         gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
667
668         /* urgency hint new */
669         checkbox = gtk_check_button_new_with_label(_("Set window manager "
670                         "urgency hint when new messages exist"));
671         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
672                         notify_config.urgency_hint_new);
673         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
674         gtk_widget_show(checkbox);
675         notify_page.urgency_hint_new = checkbox;
676
677         /* urgency hint new */
678         checkbox = gtk_check_button_new_with_label(_("Set window manager "
679                         "urgency hint when unread messages exist"));
680         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
681                         notify_config.urgency_hint_unread);
682         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
683         gtk_widget_show(checkbox);
684         notify_page.urgency_hint_unread = checkbox;
685
686 #ifdef HAVE_LIBCANBERRA_GTK
687         /* canberra */
688     checkbox = gtk_check_button_new_with_label(_("Use sound theme"));
689     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
690             notify_config.canberra_play_sounds);
691     gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
692     gtk_widget_show(checkbox);
693     notify_page.canberra_play_sounds = checkbox;
694 #endif
695
696         /* done with the frame */
697         gtk_widget_show(frame);
698         gtk_widget_show(vbox);
699
700         /* done with the page */
701         gtk_widget_show(pvbox);
702         page->widget = pvbox;
703 }
704
705 static void notify_destroy_prefs_page(PrefsPage *page)
706 {
707 }
708
709 static void notify_save_prefs(PrefsPage *page)
710 {
711         notify_config.include_mail =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_mail));
712         notify_config.include_news =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_news));
713         notify_config.include_rss =gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_rss));
714         notify_config.include_calendar
715                         = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.include_calendar));
716         notify_config.urgency_hint_new = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_new));
717         notify_config.urgency_hint_unread = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.urgency_hint_unread));
718 #ifdef HAVE_LIBCANBERRA_GTK
719    notify_config.canberra_play_sounds = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(notify_page.canberra_play_sounds));
720 #endif
721
722    notification_core_global_includes_changed();
723 }
724
725 #ifdef NOTIFICATION_BANNER
726 static void notify_banner_slider_add_cb(GtkWidget *widget, gpointer data)
727 {
728         GtkRange *slider = GTK_RANGE(data); /* inverted slider */
729         gtk_range_set_value(slider, gtk_range_get_value(slider) - 1.0);
730 }
731
732 static void notify_banner_slider_remove_cb(GtkWidget *widget, gpointer data)
733 {
734         GtkRange *slider = GTK_RANGE(data); /* inverted slider */
735         gtk_range_set_value(slider, gtk_range_get_value(slider) + 1.0);
736 }
737
738 static void notify_create_banner_page(PrefsPage *page, GtkWindow *window,
739                 gpointer data)
740 {
741         GtkRequisition requisition;
742         GtkWidget *pvbox;
743         GtkWidget *vbox;
744         GtkWidget *hbox;
745         GtkWidget *chbox, *cvbox, *cframe;
746         GtkWidget *checkbox;
747         GtkWidget *button;
748         GtkWidget *combo;
749         GtkWidget *spinner;
750         GtkWidget *label;
751         GtkWidget *slider;
752         GtkWidget *color_sel;
753         GdkColor bg;
754         GdkColor fg;
755
756         pvbox = gtk_vbox_new(FALSE, 20);
757         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
758
759         /* Always / Never / Only when non-empty */
760         hbox = gtk_hbox_new(FALSE, 20);
761         gtk_box_pack_start(GTK_BOX(pvbox), hbox, FALSE, FALSE, 0);
762         label = gtk_label_new(_("Show banner"));
763         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
764         gtk_widget_show(label);
765         combo = gtk_combo_box_new_text();
766         gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NEVER,
767                         _("Never"));
768         gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_ALWAYS,
769                         _("Always"));
770         gtk_combo_box_insert_text(GTK_COMBO_BOX(combo), NOTIFY_BANNER_SHOW_NONEMPTY,
771                         _("Only when not empty"));
772         gtk_combo_box_set_active(GTK_COMBO_BOX(combo), notify_config.banner_show);
773         gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
774         g_signal_connect(G_OBJECT(combo), "changed",
775                         G_CALLBACK(notify_banner_enable_set_sensitivity), NULL);
776         gtk_widget_show(combo);
777         gtk_widget_show(hbox);
778         banner_page.banner_show = combo;
779
780         /* Container vbox for greying out everything */
781         vbox = gtk_vbox_new(FALSE, 10);
782         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
783         gtk_widget_show(vbox);
784         banner_page.banner_cont_enable = vbox;
785
786         /* Banner speed */
787         hbox = gtk_hbox_new(FALSE, 10);
788         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
789
790         label = gtk_label_new(_("Banner speed"));
791         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
792         gtk_widget_show(label);
793
794         slider = gtk_hscale_new_with_range(10., 70., 10.);
795         gtk_scale_set_digits(GTK_SCALE(slider), 0);
796         gtk_widget_size_request(combo, &requisition);
797         gtk_widget_set_size_request(slider, requisition.width, -1);
798         gtk_range_set_increments(GTK_RANGE(slider), 10., 10.);
799         gtk_range_set_inverted(GTK_RANGE(slider), TRUE);
800         gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
801         gtk_range_set_value(GTK_RANGE(slider), notify_config.banner_speed);
802
803         button = gtk_button_new();
804         gtk_button_set_image(GTK_BUTTON(button),
805                 gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
806         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
807         g_signal_connect(G_OBJECT(button), "clicked",
808                           G_CALLBACK(notify_banner_slider_remove_cb), slider);
809         gtk_widget_show(button);
810
811         gtk_box_pack_start(GTK_BOX(hbox), slider, TRUE, TRUE, 0);
812         gtk_widget_show(slider);
813
814         button = gtk_button_new();
815         gtk_button_set_image(GTK_BUTTON(button),
816                 gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
817         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
818         g_signal_connect(G_OBJECT(button), "clicked",
819                           G_CALLBACK(notify_banner_slider_add_cb), slider);
820         gtk_widget_show(button);
821
822         gtk_widget_show(hbox);
823         banner_page.banner_speed = slider;
824
825         /* Maximum number of messages in banner */
826         hbox = gtk_hbox_new(FALSE, 10);
827         label = gtk_label_new(_("Maximum number of messages"));
828         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
829         gtk_widget_show(label);
830         spinner = gtk_spin_button_new_with_range(0., 1000., 1.);
831         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
832         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), notify_config.banner_max_msgs);
833         CLAWS_SET_TIP (spinner, _("Limit the number of messages shown, use 0 for unlimited"));
834         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
835         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
836         gtk_widget_show(spinner);
837         gtk_widget_show(hbox);
838         banner_page.banner_max_msgs = spinner;
839
840         /* banner width */
841         hbox = gtk_hbox_new(FALSE, 10);
842         label = gtk_label_new(_("Banner width"));
843         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
844         gtk_widget_show(label);
845         spinner = gtk_spin_button_new_with_range(0.,5000., 50);
846         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner),0);
847         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),notify_config.banner_width);
848         CLAWS_SET_TIP (spinner, _("Limit the size of banner, use 0 for screen width"));
849         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
850         label = gtk_label_new(_("pixel(s)"));
851         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
852         gtk_widget_show(label);
853         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
854         gtk_widget_show(spinner);
855         gtk_widget_show(hbox);
856         banner_page.banner_width = spinner;
857
858         /* Include unread */
859         checkbox = gtk_check_button_new_with_label(_("Include unread mails in banner"));
860         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
861                         notify_config.banner_include_unread);
862         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
863         gtk_widget_show(checkbox);
864         banner_page.banner_include_unread = checkbox;
865
866         /* Check button sticky */
867         checkbox = gtk_check_button_new_with_label(_("Make banner sticky"));
868         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
869                         notify_config.banner_sticky);
870         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
871         gtk_widget_show(checkbox);
872         banner_page.banner_sticky = checkbox;
873
874         /* Check box for enabling folder specific selection */
875         hbox = gtk_hbox_new(FALSE, 10);
876         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
877         checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
878         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
879                         notify_config.banner_folder_specific);
880         gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
881         g_signal_connect(G_OBJECT(checkbox), "toggled",
882                         G_CALLBACK(notify_banner_folder_specific_set_sensitivity),
883                         NULL);
884         gtk_widget_show(checkbox);
885         banner_page.banner_folder_specific = checkbox;
886         button = gtk_button_new_with_label(_("Select folders..."));
887         g_signal_connect(G_OBJECT(button), "clicked",
888                         G_CALLBACK(notification_foldercheck_sel_folders_cb),
889                         BANNER_SPECIFIC_FOLDER_ID_STR);
890         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
891         banner_page.banner_cont_folder_specific = button;
892         gtk_widget_show(button);
893         gtk_widget_show(hbox);
894
895         /* Check box for enabling custom colors */
896         cvbox = gtk_vbox_new(FALSE, 10);
897         gtk_widget_show(cvbox);
898         PACK_FRAME (vbox, cframe, _("Banner colors"))
899         gtk_container_set_border_width(GTK_CONTAINER(cvbox), 5);
900         gtk_container_add(GTK_CONTAINER(cframe), cvbox);
901
902         checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
903         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
904                         notify_config.banner_enable_colors);
905         gtk_box_pack_start(GTK_BOX(cvbox), checkbox, FALSE, FALSE, 0);
906         g_signal_connect(G_OBJECT(checkbox), "toggled",
907                         G_CALLBACK(notify_banner_color_sel_set_sensitivity), NULL);
908         gtk_widget_show(checkbox);
909         banner_page.banner_enable_colors = checkbox;
910
911         /* Color selection dialogs for foreground and background color */
912         /* foreground */
913         chbox = gtk_hbox_new(FALSE, 10);
914         gtk_box_pack_start(GTK_BOX(cvbox), chbox, FALSE, FALSE, 0);
915         gtk_widget_show(chbox);
916
917         label = gtk_label_new(_("Foreground"));
918         gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
919         gtk_widget_show(label);
920         color_sel = gtk_color_button_new();
921         gtkut_convert_int_to_gdk_color(notify_config.banner_color_fg,&fg);
922         gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
923         gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
924         gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
925         gtk_widget_show(color_sel);
926         banner_page.banner_color_fg = color_sel;
927         /* background */
928         label = gtk_label_new(_("Background"));
929         gtk_box_pack_start(GTK_BOX(chbox), label, FALSE, FALSE, 0);
930         gtk_widget_show(label);
931         color_sel = gtk_color_button_new();
932         gtkut_convert_int_to_gdk_color(notify_config.banner_color_bg,&bg);
933         gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
934         gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel), _("Background color"));
935         gtk_box_pack_start(GTK_BOX(chbox), color_sel, FALSE, FALSE, 0);
936         gtk_widget_show(color_sel);
937         banner_page.banner_color_bg = color_sel;
938         banner_page.banner_cont_color_sel = chbox;
939
940         notify_banner_color_sel_set_sensitivity
941         (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors), NULL);
942         notify_banner_folder_specific_set_sensitivity
943         (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific), NULL);
944         notify_banner_enable_set_sensitivity(GTK_COMBO_BOX(combo), NULL);
945         gtk_widget_show(pvbox);
946         banner_page.page.widget = pvbox;
947 }
948
949 static void notify_destroy_banner_page(PrefsPage *page)
950 {
951 }
952
953 static void notify_save_banner(PrefsPage *page)
954 {
955         gdouble range_val;
956         GdkColor color;
957
958         notify_config.banner_show =
959                 gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
960         notify_config.banner_max_msgs =
961                 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_max_msgs));
962         notify_config.banner_width =
963                 gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(banner_page.banner_width));
964         notify_config.banner_include_unread =
965         gtk_toggle_button_get_active
966         (GTK_TOGGLE_BUTTON(banner_page.banner_include_unread));
967         range_val= gtk_range_get_value(GTK_RANGE(banner_page.banner_speed));
968         notify_config.banner_speed = (gint)ceil(range_val);
969
970         notify_config.banner_sticky =
971         gtk_toggle_button_get_active
972         (GTK_TOGGLE_BUTTON(banner_page.banner_sticky));
973
974         notify_config.banner_folder_specific =
975         gtk_toggle_button_get_active
976         (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
977
978         notify_config.banner_enable_colors =
979         gtk_toggle_button_get_active
980         (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
981
982         /* Color dialogs are a bit more complicated */
983         gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_fg),
984                         &color);
985         notify_config.banner_color_fg = conv_color_to_int(&color);
986         gtk_color_button_get_color(GTK_COLOR_BUTTON(banner_page.banner_color_bg),
987                         &color);
988         notify_config.banner_color_bg = conv_color_to_int(&color);
989
990         notification_banner_destroy();
991         notification_update_banner();
992 }
993
994 static void notify_banner_enable_set_sensitivity(GtkComboBox *combo,
995                 gpointer data)
996 {
997         NotifyBannerShow show;
998
999         show = gtk_combo_box_get_active(GTK_COMBO_BOX(banner_page.banner_show));
1000         gtk_widget_set_sensitive(banner_page.banner_cont_enable,
1001                         (show == NOTIFY_BANNER_SHOW_NEVER) ? FALSE : TRUE);
1002 }
1003
1004 static void notify_banner_color_sel_set_sensitivity(GtkToggleButton *button,
1005                 gpointer data)
1006 {
1007         gboolean active;
1008         active = gtk_toggle_button_get_active
1009         (GTK_TOGGLE_BUTTON(banner_page.banner_enable_colors));
1010         gtk_widget_set_sensitive(banner_page.banner_cont_color_sel, active);
1011 }
1012
1013 static void notify_banner_folder_specific_set_sensitivity(GtkToggleButton *bu,
1014                 gpointer data)
1015 {
1016         gboolean active;
1017         active = gtk_toggle_button_get_active
1018         (GTK_TOGGLE_BUTTON(banner_page.banner_folder_specific));
1019         gtk_widget_set_sensitive(banner_page.banner_cont_folder_specific, active);
1020 }
1021 #endif /* NOTIFICATION_BANNER */
1022
1023 #ifdef NOTIFICATION_POPUP
1024 static void notify_create_popup_page(PrefsPage *page, GtkWindow *window,
1025                 gpointer data)
1026 {
1027         gdouble timeout;
1028         GtkWidget *pvbox;
1029         GtkWidget *vbox;
1030         GtkWidget *checkbox;
1031         GtkWidget *hbox;
1032         GtkWidget *spinner;
1033         GtkWidget *label;
1034         GtkWidget *button;
1035 #ifndef HAVE_LIBNOTIFY
1036         GdkColor bg;
1037         GdkColor fg;
1038         GtkWidget *table;
1039         GtkWidget *color_sel;
1040 #endif /* !HAVE_LIBNOTIFY */
1041
1042         pvbox = gtk_vbox_new(FALSE, 20);
1043         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1044
1045         /* Enable popup */
1046         checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1047         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1048                         notify_config.popup_show);
1049         gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1050         g_signal_connect(G_OBJECT(checkbox), "toggled",
1051                         G_CALLBACK(notify_popup_enable_set_sensitivity), NULL);
1052         gtk_widget_show(checkbox);
1053         popup_page.popup_show = checkbox;
1054
1055         /* Container vbox for greying out everything */
1056         vbox = gtk_vbox_new(FALSE, 10);
1057         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1058         gtk_widget_show(vbox);
1059         popup_page.popup_cont_enable = vbox;
1060
1061         /* Popup timeout */
1062         hbox = gtk_hbox_new(FALSE, 10);
1063         label = gtk_label_new(_("Popup timeout"));
1064         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1065         gtk_widget_show(label);
1066         spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1067         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1068         timeout = notify_config.popup_timeout/1000.;
1069         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1070         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1071         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1072         gtk_widget_show(spinner);
1073         label = gtk_label_new(_("second(s)"));
1074         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1075         gtk_widget_show(label);
1076         gtk_widget_show(hbox);
1077         popup_page.popup_timeout = spinner;
1078
1079         /* Check box for enabling folder specific selection */
1080         hbox = gtk_hbox_new(FALSE, 10);
1081         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1082         checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1083         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1084                         notify_config.popup_folder_specific);
1085         gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1086         g_signal_connect(G_OBJECT(checkbox), "toggled",
1087                         G_CALLBACK(notify_popup_folder_specific_set_sensitivity),
1088                         NULL);
1089         gtk_widget_show(checkbox);
1090         popup_page.popup_folder_specific = checkbox;
1091         button = gtk_button_new_with_label(_("Select folders..."));
1092         g_signal_connect(G_OBJECT(button), "clicked",
1093                         G_CALLBACK(notification_foldercheck_sel_folders_cb),
1094                         POPUP_SPECIFIC_FOLDER_ID_STR);
1095         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1096         popup_page.popup_cont_folder_specific = button;
1097         gtk_widget_show(button);
1098         gtk_widget_show(hbox);
1099
1100 #ifndef HAVE_LIBNOTIFY
1101         /* Sticky check button */
1102         checkbox = gtk_check_button_new_with_label(_("Make popup sticky"));
1103         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1104                         notify_config.popup_sticky);
1105         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1106         gtk_widget_show(checkbox);
1107         popup_page.popup_sticky = checkbox;
1108
1109         /* Button to set size and position of popup window */
1110         hbox = gtk_hbox_new(FALSE, 10);
1111         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1112         button = gtk_button_new_with_label(_("Set popup window width and position"));
1113         g_signal_connect(G_OBJECT(button), "clicked",
1114                         G_CALLBACK(notify_popup_set_cb), NULL);
1115         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1116         gtk_widget_show(button);
1117         label = gtk_label_new(_("(the window manager is free to ignore this)"));
1118         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1119         gtk_widget_show(label);
1120         gtk_widget_show(hbox);
1121
1122         /* Check box for enabling custom colors */
1123         checkbox = gtk_check_button_new_with_label(_("Use custom colors"));
1124         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1125                         notify_config.popup_enable_colors);
1126         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1127         g_signal_connect(G_OBJECT(checkbox), "toggled",
1128                         G_CALLBACK(notify_popup_color_sel_set_sensitivity), NULL);
1129         gtk_widget_show(checkbox);
1130         popup_page.popup_enable_colors = checkbox;
1131
1132         /* Color selection dialogs for foreground and background color */
1133         table = gtk_table_new(2,2,FALSE);
1134         gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
1135         /* foreground */
1136         label = gtk_label_new(_("Foreground"));
1137         gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
1138         gtk_widget_show(label);
1139         color_sel = gtk_color_button_new();
1140         gtkut_convert_int_to_gdk_color(notify_config.popup_color_fg,&fg);
1141         gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&fg);
1142         gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Foreground color"));
1143         gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,0,1);
1144         gtk_widget_show(color_sel);
1145         popup_page.popup_color_fg = color_sel;
1146         /* background */
1147         label = gtk_label_new(_("Background"));
1148         gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
1149         gtk_widget_show(label);
1150         color_sel = gtk_color_button_new();
1151         gtkut_convert_int_to_gdk_color(notify_config.popup_color_bg,&bg);
1152         gtk_color_button_set_color(GTK_COLOR_BUTTON(color_sel),&bg);
1153         gtk_color_button_set_title(GTK_COLOR_BUTTON(color_sel),_("Background color"));
1154         gtk_table_attach_defaults(GTK_TABLE(table),color_sel,1,2,1,2);
1155         gtk_widget_show(color_sel);
1156         gtk_widget_show(table);
1157         popup_page.popup_color_bg = color_sel;
1158         popup_page.popup_cont_color_sel = table;
1159
1160         notify_popup_color_sel_set_sensitivity
1161         (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors), NULL);
1162 #else /* HAVE_LIBNOTIFY */
1163         hbox = gtk_hbox_new(FALSE, 10);
1164         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1165         checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1166         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1167                         notify_config.popup_display_folder_name);
1168         gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1169         gtk_widget_show(checkbox);
1170         gtk_widget_show(hbox);
1171         popup_page.popup_display_folder_name = checkbox;
1172 #endif /* HAVE_LIBNOTIFY */
1173
1174         notify_popup_enable_set_sensitivity
1175         (GTK_TOGGLE_BUTTON(popup_page.popup_show), NULL);
1176         notify_popup_folder_specific_set_sensitivity
1177         (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific), NULL);
1178         gtk_widget_show(pvbox);
1179         popup_page.page.widget = pvbox;
1180 }
1181
1182 static void notify_destroy_popup_page(PrefsPage *page)
1183 {
1184 }
1185
1186 static void notify_save_popup(PrefsPage *page)
1187 {
1188         gdouble timeout;
1189
1190 #ifndef HAVE_LIBNOTIFY
1191         GdkColor color;
1192 #endif /* !HAVE_LIBNOTIFY */
1193
1194         notify_config.popup_show =
1195         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_show));
1196         timeout =
1197         gtk_spin_button_get_value(GTK_SPIN_BUTTON(popup_page.popup_timeout));
1198         notify_config.popup_timeout = (gint)floor(timeout*1000+0.5);
1199         notify_config.popup_folder_specific =
1200         gtk_toggle_button_get_active
1201         (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1202
1203 #ifndef HAVE_LIBNOTIFY
1204         notify_config.popup_sticky =
1205         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_sticky));
1206         notify_config.popup_enable_colors =
1207         gtk_toggle_button_get_active
1208         (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1209
1210         /* Color dialogs are a bit more complicated */
1211         gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_fg),
1212                         &color);
1213         notify_config.popup_color_fg = conv_color_to_int(&color);
1214         gtk_color_button_get_color(GTK_COLOR_BUTTON(popup_page.popup_color_bg),
1215                         &color);
1216         notify_config.popup_color_bg = conv_color_to_int(&color);
1217 #else /* HAVE_LIBNOTIFY */
1218         notify_config.popup_display_folder_name =
1219         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(popup_page.popup_display_folder_name));
1220 #endif /* HAVE_LIBNOTIFY */
1221 }
1222
1223 #ifndef HAVE_LIBNOTIFY
1224 static void notify_popup_set_cb(GtkWidget *widget, gpointer data)
1225 {
1226         GtkWidget *win;
1227         GtkWidget *button;
1228
1229         win = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "notification_prefs");
1230         gtk_window_set_title(GTK_WINDOW(win), _("Sample popup window"));
1231         gtk_window_set_modal(GTK_WINDOW(win), TRUE);
1232         gtk_window_set_keep_above(GTK_WINDOW(win), TRUE);
1233         gtk_window_set_resizable(GTK_WINDOW(win), TRUE);
1234         gtk_container_set_border_width(GTK_CONTAINER(win), 5);
1235
1236         button = gtk_button_new_with_label(_("Done"));
1237         g_signal_connect(G_OBJECT(button), "clicked",
1238                         G_CALLBACK(notify_popup_set_done_cb), win);
1239         gtk_container_add(GTK_CONTAINER(win), button);
1240
1241         gtk_widget_show_all(win);
1242 }
1243
1244 static void notify_popup_set_done_cb(GtkWidget *widget, gpointer data)
1245 {
1246         GtkWidget *win = data;
1247         gint dummy;
1248
1249         gtk_window_get_position(GTK_WINDOW(win),
1250                         &(notify_config.popup_root_x),
1251                         &(notify_config.popup_root_y));
1252         gtk_window_get_size(GTK_WINDOW(win),
1253                         &(notify_config.popup_width), &dummy);
1254         gtk_widget_destroy(win);
1255 }
1256
1257 static void notify_popup_color_sel_set_sensitivity(GtkToggleButton *button,
1258                 gpointer data)
1259 {
1260         gboolean active;
1261         active = gtk_toggle_button_get_active
1262         (GTK_TOGGLE_BUTTON(popup_page.popup_enable_colors));
1263         gtk_widget_set_sensitive(popup_page.popup_cont_color_sel, active);
1264 }
1265 #endif /* !HAVE_LIBNOTIFY */
1266
1267 static void notify_popup_enable_set_sensitivity(GtkToggleButton *button,
1268                 gpointer data)
1269 {
1270         gboolean active;
1271         active = gtk_toggle_button_get_active
1272         (GTK_TOGGLE_BUTTON(popup_page.popup_show));
1273         gtk_widget_set_sensitive(popup_page.popup_cont_enable, active);
1274 }
1275
1276 static void notify_popup_folder_specific_set_sensitivity(GtkToggleButton *bu,
1277                 gpointer data)
1278 {
1279         gboolean active;
1280         active = gtk_toggle_button_get_active
1281         (GTK_TOGGLE_BUTTON(popup_page.popup_folder_specific));
1282         gtk_widget_set_sensitive(popup_page.popup_cont_folder_specific, active);
1283 }
1284
1285 #endif /* NOTIFICATION_POPUP */
1286
1287 #ifdef NOTIFICATION_COMMAND
1288 static void notify_command_browse_cb(GtkWidget* widget, gpointer data)
1289 {
1290         gchar *filename;
1291         gchar *utf8_filename;
1292         GtkEntry *dest = GTK_ENTRY(data);
1293
1294         filename = filesel_select_file_open(_("Select command"), NULL);
1295         if (!filename) return;
1296
1297         utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1298         if (!utf8_filename) {
1299                 g_warning("notify_command_browse_cb(): failed to convert character set.");
1300                 utf8_filename = g_strdup(filename);
1301         }
1302         gtk_entry_set_text(GTK_ENTRY(dest), utf8_filename);
1303         g_free(utf8_filename);
1304 }
1305
1306 static void notify_create_command_page(PrefsPage *page, GtkWindow *window,
1307                 gpointer data)
1308 {
1309         GtkWidget *pvbox;
1310         GtkWidget *vbox;
1311         GtkWidget *checkbox;
1312         GtkWidget *hbox;
1313         GtkWidget *spinner;
1314         GtkWidget *entry;
1315         GtkWidget *label;
1316         GtkWidget *button, *buttonb;
1317         gdouble timeout;
1318
1319         pvbox = gtk_vbox_new(FALSE, 20);
1320         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1321
1322         /* Enable command */
1323         checkbox = gtk_check_button_new_with_label(_("Enable command"));
1324         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1325                         notify_config.command_enabled);
1326         gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1327         g_signal_connect(G_OBJECT(checkbox), "toggled",
1328                         G_CALLBACK(notify_command_enable_set_sensitivity), NULL);
1329         gtk_widget_show(checkbox);
1330         command_page.command_enabled = checkbox;
1331
1332         /* Container vbox for greying out everything */
1333         vbox = gtk_vbox_new(FALSE, 10);
1334         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1335         gtk_widget_show(vbox);
1336         command_page.command_cont_enable = vbox;
1337
1338         /* entry field for command to execute */
1339         hbox = gtk_hbox_new(FALSE, 10);
1340         label = gtk_label_new(_("Command to execute"));
1341         gtk_widget_show(label);
1342         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1343         entry = gtk_entry_new();
1344         gtk_entry_set_text(GTK_ENTRY(entry), notify_config.command_line);
1345         gtk_widget_show(entry);
1346         gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1347         buttonb = gtkut_get_browse_file_btn(_("Bro_wse"));
1348         gtk_box_pack_start(GTK_BOX(hbox), buttonb, FALSE, FALSE, 0);
1349         g_signal_connect(G_OBJECT(buttonb), "clicked",
1350                 G_CALLBACK(notify_command_browse_cb), entry);
1351         gtk_widget_show(buttonb);
1352         gtk_widget_show(hbox);
1353         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1354         command_page.command_line = entry;
1355
1356         /* Spin button for command timeout */
1357         hbox = gtk_hbox_new(FALSE, 10);
1358         label = gtk_label_new(_("Block command after execution for"));
1359         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1360         gtk_widget_show(label);
1361         spinner = gtk_spin_button_new_with_range(0., 600., 1.);
1362         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1363         timeout = notify_config.command_timeout/1000.;
1364         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1365         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1366         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1367         gtk_widget_show(spinner);
1368         label = gtk_label_new(_("second(s)"));
1369         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1370         gtk_widget_show(label);
1371         gtk_widget_show(hbox);
1372         command_page.command_timeout = spinner;
1373
1374         /* Check box for enabling folder specific selection */
1375         hbox = gtk_hbox_new(FALSE, 10);
1376         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1377         checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1378         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1379                         notify_config.command_folder_specific);
1380         gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1381         g_signal_connect(G_OBJECT(checkbox), "toggled",
1382                         G_CALLBACK(notify_command_folder_specific_set_sensitivity),
1383                         NULL);
1384         gtk_widget_show(checkbox);
1385         command_page.command_folder_specific = checkbox;
1386         button = gtk_button_new_with_label(_("Select folders..."));
1387         g_signal_connect(G_OBJECT(button), "clicked",
1388                         G_CALLBACK(notification_foldercheck_sel_folders_cb),
1389                         COMMAND_SPECIFIC_FOLDER_ID_STR);
1390         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1391         command_page.command_cont_folder_specific = button;
1392         gtk_widget_show(button);
1393         gtk_widget_show(hbox);
1394
1395         notify_command_enable_set_sensitivity
1396         (GTK_TOGGLE_BUTTON(command_page.command_enabled), NULL);
1397         notify_command_folder_specific_set_sensitivity
1398         (GTK_TOGGLE_BUTTON(command_page.command_folder_specific), NULL);
1399         gtk_widget_show(pvbox);
1400         command_page.page.widget = pvbox;
1401 }
1402
1403 static void notify_destroy_command_page(PrefsPage *page)
1404 {
1405 }
1406
1407 static void notify_save_command(PrefsPage *page)
1408 {
1409         gdouble timeout;
1410         const gchar *tmp_str;
1411
1412         notify_config.command_enabled =
1413         gtk_toggle_button_get_active
1414         (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1415
1416         timeout =
1417         gtk_spin_button_get_value(GTK_SPIN_BUTTON(command_page.command_timeout));
1418         notify_config.command_timeout = (gint)floor(timeout*1000+0.5);
1419         notify_config.command_folder_specific =
1420         gtk_toggle_button_get_active
1421         (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1422
1423         tmp_str = gtk_entry_get_text(GTK_ENTRY(command_page.command_line));
1424         if(notify_config.command_line)
1425       g_free(notify_config.command_line);
1426         notify_config.command_line = g_strdup(tmp_str);
1427 }
1428
1429 static void notify_command_enable_set_sensitivity(GtkToggleButton *button,
1430                 gpointer data)
1431 {
1432         gboolean active;
1433         active = gtk_toggle_button_get_active
1434         (GTK_TOGGLE_BUTTON(command_page.command_enabled));
1435         gtk_widget_set_sensitive(command_page.command_cont_enable, active);
1436 }
1437
1438 static void notify_command_folder_specific_set_sensitivity(GtkToggleButton *bu,
1439                 gpointer data)
1440 {
1441         gboolean active;
1442         active = gtk_toggle_button_get_active
1443         (GTK_TOGGLE_BUTTON(command_page.command_folder_specific));
1444         gtk_widget_set_sensitive(command_page.command_cont_folder_specific, active);
1445 }
1446
1447 #endif /* NOTIFICATION_COMMAND */
1448
1449 #ifdef NOTIFICATION_LCDPROC
1450 static void notify_create_lcdproc_page(PrefsPage *page, GtkWindow *window,
1451                 gpointer data)
1452 {
1453         GtkWidget *pvbox;
1454         GtkWidget *vbox;
1455         GtkWidget *label;
1456         GtkWidget *entry;
1457         GtkWidget *spinner;
1458         GtkWidget *checkbox;
1459         GtkWidget *hbox;
1460
1461         pvbox = gtk_vbox_new(FALSE, 20);
1462         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1463
1464         /* Enable lcdproc */
1465         checkbox = gtk_check_button_new_with_label(_("Enable LCD"));
1466         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1467                         notify_config.lcdproc_enabled);
1468         gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1469         g_signal_connect(G_OBJECT(checkbox), "toggled",
1470                         G_CALLBACK(notify_lcdproc_enable_set_sensitivity), NULL);
1471         gtk_widget_show(checkbox);
1472         lcdproc_page.lcdproc_enabled = checkbox;
1473
1474         /* Container vbox for greying out everything */
1475         vbox = gtk_vbox_new(FALSE, 10);
1476         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1477         gtk_widget_show(vbox);
1478         lcdproc_page.lcdproc_cont_enable = vbox;
1479
1480         /* Hostname and port information */
1481         hbox = gtk_hbox_new(FALSE, 10);
1482         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1483         gtk_widget_show(hbox);
1484         label = gtk_label_new(_("Hostname:Port of LCDd server"));
1485         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1486         entry = gtk_entry_new();
1487         gtk_entry_set_text(GTK_ENTRY(entry), notify_config.lcdproc_hostname);
1488         gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
1489         gtk_widget_show(entry);
1490         gtk_widget_show(label);
1491         label = gtk_label_new(":");
1492         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1493         gtk_widget_show(label);
1494         spinner = gtk_spin_button_new_with_range(1., 65535., 1.);
1495         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 0);
1496         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner),
1497                         notify_config.lcdproc_port);
1498         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1499         gtk_widget_show(spinner);
1500         lcdproc_page.lcdproc_hostname = entry;
1501         lcdproc_page.lcdproc_port = spinner;
1502
1503         notify_lcdproc_enable_set_sensitivity
1504         (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled), NULL);
1505         gtk_widget_show(pvbox);
1506         lcdproc_page.page.widget = pvbox;
1507 }
1508
1509 static void notify_destroy_lcdproc_page(PrefsPage *page)
1510 {
1511 }
1512
1513 static void notify_save_lcdproc(PrefsPage *page)
1514 {
1515         notify_config.lcdproc_enabled =
1516         gtk_toggle_button_get_active
1517         (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1518
1519         if(notify_config.lcdproc_hostname)
1520         g_free(notify_config.lcdproc_hostname);
1521         notify_config.lcdproc_hostname =
1522         g_strdup(gtk_entry_get_text(GTK_ENTRY(lcdproc_page.lcdproc_hostname)));
1523
1524         notify_config.lcdproc_port =
1525         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(lcdproc_page.lcdproc_port));
1526
1527         if(notify_config.lcdproc_enabled)
1528         notification_lcdproc_connect();
1529         else
1530         notification_lcdproc_disconnect();
1531 }
1532
1533 static void notify_lcdproc_enable_set_sensitivity(GtkToggleButton *button,
1534                 gpointer data)
1535 {
1536         gboolean active;
1537         active = gtk_toggle_button_get_active
1538         (GTK_TOGGLE_BUTTON(lcdproc_page.lcdproc_enabled));
1539         gtk_widget_set_sensitive(lcdproc_page.lcdproc_cont_enable, active);
1540 }
1541 #endif /* NOTIFICATION_LCDPROC */
1542
1543 #ifdef NOTIFICATION_TRAYICON
1544 static void notify_create_trayicon_page(PrefsPage *page, GtkWindow *window,
1545                 gpointer data)
1546 {
1547         GtkWidget *pvbox;
1548         GtkWidget *vbox;
1549         GtkWidget *checkbox;
1550         GtkWidget *hbox;
1551         GtkWidget *button;
1552
1553 #if defined(HAVE_LIBNOTIFY)
1554         GtkWidget *frame;
1555         GtkWidget *svbox;
1556         GtkWidget *label;
1557 #endif
1558
1559 #ifdef HAVE_LIBNOTIFY
1560         GtkWidget *ssvbox;
1561         GtkWidget *spinner;
1562         gdouble timeout;
1563 #endif
1564
1565         pvbox = gtk_vbox_new(FALSE, 20);
1566         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1567
1568         /* Enable trayicon */
1569         checkbox = gtk_check_button_new_with_label(_("Enable Trayicon"));
1570         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1571                         notify_config.trayicon_enabled);
1572         gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1573         g_signal_connect(G_OBJECT(checkbox), "toggled",
1574                         G_CALLBACK(notify_trayicon_enable_set_sensitivity), NULL);
1575         gtk_widget_show(checkbox);
1576         trayicon_page.trayicon_enabled = checkbox;
1577
1578         /* Container vbox for greying out everything */
1579         vbox = gtk_vbox_new(FALSE, 10);
1580         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1581         gtk_widget_show(vbox);
1582         trayicon_page.trayicon_cont_enable = vbox;
1583
1584         /* Hide at startup */
1585         checkbox = gtk_check_button_new_with_label(_("Hide at start-up"));
1586         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1587                         notify_config.trayicon_hide_at_startup);
1588         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1589         gtk_widget_show(checkbox);
1590         trayicon_page.trayicon_hide_at_startup = checkbox;
1591
1592         /* Close to tray */
1593         checkbox = gtk_check_button_new_with_label(_("Close to tray"));
1594         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1595                         notify_config.trayicon_close_to_tray);
1596         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1597         gtk_widget_show(checkbox);
1598         trayicon_page.trayicon_close_to_tray = checkbox;
1599
1600         /* Hide when iconified */
1601         checkbox = gtk_check_button_new_with_label(_("Hide when iconified"));
1602         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1603                         notify_config.trayicon_hide_when_iconified);
1604         gtk_box_pack_start(GTK_BOX(vbox), checkbox, FALSE, FALSE, 0);
1605         gtk_widget_show(checkbox);
1606         trayicon_page.trayicon_hide_when_iconified = checkbox;
1607
1608         /* folder specific */
1609         hbox = gtk_hbox_new(FALSE, 10);
1610         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1611         gtk_widget_show(hbox);
1612         checkbox = gtk_check_button_new_with_label(_("Only include selected folders"));
1613         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1614                         notify_config.trayicon_folder_specific);
1615         gtk_box_pack_start(GTK_BOX(hbox), checkbox, FALSE, FALSE, 0);
1616         g_signal_connect(G_OBJECT(checkbox), "toggled",
1617                         G_CALLBACK(notify_trayicon_folder_specific_set_sensitivity),
1618                         NULL);
1619         gtk_widget_show(checkbox);
1620         trayicon_page.trayicon_folder_specific = checkbox;
1621         button = gtk_button_new_with_label(_("Select folders..."));
1622         g_signal_connect(G_OBJECT(button), "clicked",
1623                         G_CALLBACK(notification_foldercheck_sel_folders_cb),
1624                         TRAYICON_SPECIFIC_FOLDER_ID_STR);
1625         gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1626         trayicon_page.trayicon_cont_folder_specific = button;
1627         gtk_widget_show(button);
1628
1629 #ifdef HAVE_LIBNOTIFY
1630         /* Frame for trayicon popup stuff */
1631
1632         /* TRANSLATORS: "Toaster" does not refer to the kitchen appliance.
1633                  A toast is a small passive (non-focus-stealing)
1634                  notification bubble. If your language does not have a word
1635                  for that, go for something along the lines of "passive popup"
1636                  instead.See also
1637                  http://en.wikipedia.org/wiki/Toast_(computing) */
1638         PACK_FRAME (vbox, frame, _("Passive toaster popup"))
1639
1640         /* vbox for frame */
1641         svbox = gtk_vbox_new(FALSE, 10);
1642         gtk_container_set_border_width(GTK_CONTAINER(svbox), 5);
1643         gtk_container_add(GTK_CONTAINER(frame), svbox);
1644         gtk_widget_show(svbox);
1645
1646         /* Enable popup for the tray icon */
1647         checkbox = gtk_check_button_new_with_label(_("Enable popup"));
1648         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1649                         notify_config.trayicon_popup_enabled);
1650         g_signal_connect(G_OBJECT(checkbox), "toggled",
1651                         G_CALLBACK(notify_trayicon_popup_enable_set_sensitivity),
1652                         NULL);
1653         gtk_box_pack_start(GTK_BOX(svbox), checkbox, FALSE, FALSE, 0);
1654         gtk_widget_show(checkbox);
1655         trayicon_page.trayicon_popup_enabled = checkbox;
1656
1657         /* vbox for trayicon popup stuff enabled/disabled container */
1658         ssvbox = gtk_vbox_new(FALSE, 10);
1659         gtk_box_pack_start(GTK_BOX(svbox), ssvbox, FALSE, FALSE, 0);
1660         gtk_widget_show(ssvbox);
1661         trayicon_page.trayicon_popup_cont_enable = ssvbox;
1662
1663         /* timeout */
1664         hbox = gtk_hbox_new(FALSE, 10);
1665         label = gtk_label_new(_("Popup timeout"));
1666         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1667         gtk_widget_show(label);
1668         spinner = gtk_spin_button_new_with_range(TIMEOUT_SPINNER_MIN, TIMEOUT_SPINNER_MAX, TIMEOUT_SPINNER_STEP);
1669         gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spinner), 1);
1670         timeout = notify_config.trayicon_popup_timeout/1000.;
1671         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), timeout);
1672         gtk_box_pack_start(GTK_BOX(hbox), spinner, FALSE, FALSE, 0);
1673         gtk_box_pack_start(GTK_BOX(ssvbox), hbox, FALSE, FALSE, 0);
1674         label = gtk_label_new(_("second(s)"));
1675         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1676
1677         checkbox = gtk_check_button_new_with_label(_("Display folder name"));
1678         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1679                         notify_config.trayicon_display_folder_name);
1680         gtk_box_pack_start(GTK_BOX(ssvbox), checkbox, FALSE, FALSE, 0);
1681         trayicon_page.trayicon_display_folder_name = checkbox;
1682         gtk_widget_show(checkbox);
1683
1684         gtk_widget_show(spinner);
1685         gtk_widget_show(label);
1686         gtk_widget_show(hbox);
1687         trayicon_page.trayicon_popup_timeout = spinner;
1688
1689 #endif
1690
1691         notify_trayicon_enable_set_sensitivity
1692         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled), NULL);
1693
1694 #ifdef HAVE_LIBNOTIFY
1695         notify_trayicon_popup_enable_set_sensitivity
1696         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled), NULL);
1697 #endif
1698
1699         notify_trayicon_folder_specific_set_sensitivity
1700         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific), NULL);
1701
1702         gtk_widget_show(pvbox);
1703         trayicon_page.page.widget = pvbox;
1704 }
1705
1706 static void notify_destroy_trayicon_page(PrefsPage *page)
1707 {
1708 }
1709
1710 static void notify_save_trayicon(PrefsPage *page)
1711 {
1712 #ifdef HAVE_LIBNOTIFY
1713         gdouble timeout;
1714 #endif
1715
1716         notify_config.trayicon_enabled =
1717         gtk_toggle_button_get_active
1718         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1719
1720         notify_config.trayicon_hide_at_startup =
1721         gtk_toggle_button_get_active
1722         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_at_startup));
1723
1724         notify_config.trayicon_close_to_tray =
1725         gtk_toggle_button_get_active
1726         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_close_to_tray));
1727
1728         notify_config.trayicon_hide_when_iconified =
1729         gtk_toggle_button_get_active
1730         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_hide_when_iconified));
1731
1732 #ifdef HAVE_LIBNOTIFY
1733         notify_config.trayicon_popup_enabled =
1734         gtk_toggle_button_get_active
1735         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1736
1737         timeout =
1738         gtk_spin_button_get_value(GTK_SPIN_BUTTON
1739                         (trayicon_page.trayicon_popup_timeout));
1740         notify_config.trayicon_popup_timeout = (gint)floor(timeout*1000+0.5);
1741
1742         notify_config.trayicon_display_folder_name =
1743                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(trayicon_page.trayicon_display_folder_name));
1744 #endif
1745
1746         notify_config.trayicon_folder_specific =
1747                 gtk_toggle_button_get_active
1748                 (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1749
1750         if(notify_config.trayicon_enabled)
1751         notification_update_msg_counts(NULL);
1752         else
1753         notification_trayicon_destroy();
1754 }
1755
1756 static void notify_trayicon_enable_set_sensitivity(GtkToggleButton *button,
1757                 gpointer data)
1758 {
1759         gboolean active;
1760         active = gtk_toggle_button_get_active
1761         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_enabled));
1762         gtk_widget_set_sensitive(trayicon_page.trayicon_cont_enable, active);
1763 }
1764
1765 static void notify_trayicon_folder_specific_set_sensitivity(GtkToggleButton *bu,
1766                 gpointer data)
1767 {
1768         gboolean active;
1769         active = gtk_toggle_button_get_active
1770         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_folder_specific));
1771         gtk_widget_set_sensitive(trayicon_page.trayicon_cont_folder_specific, active);
1772 }
1773
1774 #ifdef HAVE_LIBNOTIFY
1775 static void notify_trayicon_popup_enable_set_sensitivity(GtkToggleButton *bu,
1776                 gpointer data)
1777 {
1778         gboolean active;
1779         active = gtk_toggle_button_get_active
1780         (GTK_TOGGLE_BUTTON(trayicon_page.trayicon_popup_enabled));
1781         gtk_widget_set_sensitive(trayicon_page.trayicon_popup_cont_enable, active);
1782 }
1783
1784 #endif /* HAVE_LIBNOTIFY */
1785
1786 #endif /* NOTIFICATION_TRAYICON */
1787
1788 #ifdef NOTIFICATION_INDICATOR
1789
1790 #define NOTIFICATION_INDICATOR_REGISTER_PATH ".config/indicators/messages/applications"
1791
1792 static gboolean indicator_register_file_exists(void)
1793 {
1794   gboolean retval;
1795   gchar *filepath;
1796   filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1797   retval = is_file_exist(filepath);
1798   g_free(filepath);
1799   return retval;
1800 }
1801
1802 static gboolean indicator_register_file_create(void)
1803 {
1804   FILE *fp;
1805   gchar *path, *filepath;
1806   gboolean success;
1807
1808   /* make sure directory path exists */
1809   path = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH, NULL);
1810   if(!is_dir_exist(path)) {
1811     if(make_dir_hier(path) != -1)
1812       debug_print("Notification plugin: Created directory '%s'\n", path);
1813      else {
1814        debug_print("Notification plugin: Error creating directory '%s'\n", path);
1815        g_free(path);
1816        return FALSE;
1817      }
1818   }
1819
1820   /* create register file */
1821   filepath = g_strconcat(path, "/claws-mail", NULL);
1822   g_free(path);
1823   fp = fopen(filepath, "w");
1824   success = (fp != NULL);
1825   if(fp) {
1826     fprintf(fp, "%s\n", get_desktop_file());
1827     fclose(fp);
1828     debug_print("Notification plugin: Created desktop indicator file '%s'\n", filepath);
1829   }
1830   else
1831     debug_print("Notification plugin: Could not create desktop indicator file '%s'\n", filepath);
1832   g_free(filepath);
1833
1834   return success;
1835 }
1836
1837 static gboolean indicator_register_file_remove(void)
1838 {
1839   gchar *filepath;
1840   int retval;
1841
1842   filepath = g_strconcat(get_home_dir(), "/" NOTIFICATION_INDICATOR_REGISTER_PATH "/claws-mail", NULL);
1843   retval = claws_unlink(filepath);
1844   if(retval != -1)
1845     debug_print("Notification plugin: Deleted file '%s'\n", filepath);
1846   else
1847     debug_print("Notification plugin: Error deleting file '%s'\n", filepath);
1848   g_free(filepath);
1849
1850   return (retval != -1);
1851 }
1852
1853 static void notify_create_indicator_page(PrefsPage *page, GtkWindow *window,
1854                 gpointer data)
1855 {
1856         GtkWidget *pvbox;
1857         GtkWidget *vbox;
1858         GtkWidget *checkbox;
1859         GtkWidget *ind_reg;
1860
1861         pvbox = gtk_vbox_new(FALSE, 20);
1862         gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1863
1864         /* Enable indicator */
1865         checkbox = gtk_check_button_new_with_label(_("Add to Indicator Applet"));
1866         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),
1867                         notify_config.indicator_enabled);
1868         gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1869         g_signal_connect(G_OBJECT(checkbox), "toggled",
1870                         G_CALLBACK(notify_indicator_enable_set_sensitivity), NULL);
1871         indicator_page.indicator_enabled = checkbox;
1872
1873         /* Container vbox for greying out everything */
1874         vbox = gtk_vbox_new(FALSE, 10);
1875         gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1876         indicator_page.indicator_cont_enable = vbox;
1877
1878         /* hide when minimized */
1879         checkbox = gtk_check_button_new_with_label(_("Hide mainwindow when minimized"));
1880         gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), checkbox, FALSE, FALSE, 0);
1881         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox), notify_config.indicator_hide_minimized);
1882         indicator_page.indicator_hide_minimized = checkbox;
1883
1884         /* register */
1885         ind_reg = gtk_check_button_new_with_label(_("Register Claws Mail"));
1886         gtk_box_pack_start(GTK_BOX(indicator_page.indicator_cont_enable), ind_reg, FALSE, FALSE, 0);
1887         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ind_reg), indicator_register_file_exists());
1888         indicator_page.indicator_register = ind_reg;
1889
1890         notify_indicator_enable_set_sensitivity(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled), NULL);
1891         gtk_widget_show_all(pvbox);
1892         indicator_page.page.widget = pvbox;
1893 }
1894
1895 static void notify_destroy_indicator_page(PrefsPage *page)
1896 {
1897 }
1898
1899 static void notify_save_indicator(PrefsPage *page)
1900 {
1901     gboolean ind_reg;
1902
1903         notify_config.indicator_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1904
1905         notify_config.indicator_hide_minimized = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_hide_minimized));
1906
1907         ind_reg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(indicator_page.indicator_register));
1908         if(ind_reg) {
1909           if(!indicator_register_file_exists())
1910             indicator_register_file_create();
1911         }
1912         else {
1913           if(indicator_register_file_exists())
1914             indicator_register_file_remove();
1915         }
1916
1917         notification_indicator_destroy();
1918         notification_update_indicator();
1919 }
1920
1921 static void notify_indicator_enable_set_sensitivity(GtkToggleButton *button,
1922                 gpointer data)
1923 {
1924         gboolean active;
1925         active = gtk_toggle_button_get_active
1926         (GTK_TOGGLE_BUTTON(indicator_page.indicator_enabled));
1927         gtk_widget_set_sensitive(indicator_page.indicator_cont_enable, active);
1928 }
1929 #endif /* NOTIFICATION_INDICATOR */
1930
1931 #ifdef NOTIFICATION_HOTKEYS
1932 static void notify_create_hotkeys_page(PrefsPage *page, GtkWindow *window, gpointer data)
1933 {
1934     GtkWidget *pvbox;
1935     GtkWidget *vbox;
1936     GtkWidget *checkbox;
1937     GtkWidget *label;
1938     gchar *markup;
1939     GtkWidget *hbox;
1940     GtkWidget *entry;
1941
1942     pvbox = gtk_vbox_new(FALSE, 20);
1943     gtk_container_set_border_width(GTK_CONTAINER(pvbox), 10);
1944
1945     /* Enable hotkeys */
1946     checkbox = gtk_check_button_new_with_label(_("Enable global hotkeys"));
1947     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbox),  notify_config.hotkeys_enabled);
1948     gtk_box_pack_start(GTK_BOX(pvbox), checkbox, FALSE, FALSE, 0);
1949     g_signal_connect(G_OBJECT(checkbox), "toggled",
1950         G_CALLBACK(notify_hotkeys_enable_set_sensitivity), NULL);
1951     hotkeys_page.hotkeys_enabled = checkbox;
1952
1953     /* Container vbox for greying out everything */
1954     vbox = gtk_vbox_new(FALSE, 10);
1955     gtk_box_pack_start(GTK_BOX(pvbox), vbox, FALSE, FALSE, 0);
1956     hotkeys_page.hotkeys_cont_enable = vbox;
1957
1958     /* description */
1959     label = gtk_label_new("");
1960     markup = g_markup_printf_escaped(_("Examples for hotkeys include <b>%s</b> and <b>%s</b>"), _("<control><shift>F11"), _("<alt>N"));
1961     gtk_label_set_markup(GTK_LABEL(label), markup);
1962     gtk_misc_set_alignment(GTK_MISC(label), 0., 0.);
1963     g_free(markup);
1964     gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), label, FALSE, FALSE, 0);
1965
1966     /* hbox for entry fields */
1967     hbox = gtk_hbox_new(FALSE, 6);
1968     gtk_box_pack_start(GTK_BOX(hotkeys_page.hotkeys_cont_enable), hbox, FALSE, FALSE, 0);
1969
1970     /* toggle mainwindow */
1971     label = gtk_label_new(_("Toggle minimize"));
1972     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1973     entry = gtk_entry_new();
1974     gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
1975     if(notify_config.hotkeys_toggle_mainwindow)
1976       gtk_entry_set_text(GTK_ENTRY(entry), notify_config.hotkeys_toggle_mainwindow);
1977     hotkeys_page.hotkeys_toggle_mainwindow = entry;
1978
1979     notify_hotkeys_enable_set_sensitivity(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled), NULL);
1980     gtk_widget_show_all(pvbox);
1981     hotkeys_page.page.widget = pvbox;
1982 }
1983
1984 static void notify_destroy_hotkeys_page(PrefsPage *page)
1985 {
1986 }
1987
1988 static void notify_save_hotkeys(PrefsPage *page)
1989 {
1990     const gchar *tmp_str;
1991     notify_config.hotkeys_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
1992
1993     tmp_str = gtk_entry_get_text(GTK_ENTRY(hotkeys_page.hotkeys_toggle_mainwindow));
1994     if(notify_config.hotkeys_toggle_mainwindow)
1995       g_free(notify_config.hotkeys_toggle_mainwindow);
1996     notify_config.hotkeys_toggle_mainwindow = g_strdup(tmp_str);
1997
1998     notification_hotkeys_update_bindings();
1999 }
2000
2001 static void notify_hotkeys_enable_set_sensitivity(GtkToggleButton *button,
2002         gpointer data)
2003 {
2004     gboolean active;
2005     active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hotkeys_page.hotkeys_enabled));
2006     gtk_widget_set_sensitive(hotkeys_page.hotkeys_cont_enable, active);
2007 }
2008 #endif /* hotkeys */
2009
2010
2011 /* This feels so wrong... */
2012 static gint conv_color_to_int(GdkColor *color)
2013 {
2014         gint result;
2015         guint red, green, blue;
2016
2017         red = (guint) ((gdouble)(color->red) /65535.*255.);
2018         green = (guint) ((gdouble)(color->green) /65535.*255.);
2019         blue = (guint) ((gdouble)(color->blue) /65535.*255.);
2020
2021         result = (gint) (blue | (green<<8)| (red<<16));
2022
2023         return result;
2024 }