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