forked from juddmon/jpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefs_gui.c
1048 lines (872 loc) · 37.5 KB
/
prefs_gui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* prefs_gui.c
* A module of J-Pilot http://jpilot.org
*
* Copyright (C) 1999-2014 by Judd Montgomery
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/
/********************************* Includes ***********************************/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "prefs_gui.h"
#include "prefs.h"
#include "i18n.h"
#include "utils.h"
#include "log.h"
#include "plugins.h"
/******************************* Global vars **********************************/
static GtkWidget *window;
static GtkWidget *main_window;
static GtkWidget *port_entry;
static GtkWidget *backups_entry;
static GtkWidget *ext_editor_entry;
static GtkWidget *alarm_command_entry;
static GtkWidget *mail_command_entry;
static GtkWidget *todo_days_due_entry;
extern int glob_app;
extern GtkTooltips *glob_tooltips;
#ifdef ENABLE_PLUGINS
extern unsigned char skip_plugins;
#endif
/* Sync Port Menu */
static GtkWidget *port_menu;
static GtkWidget *port_menu_item[10];
static const char *port_choices[]={
"other", "usb:",
"/dev/ttyUSB0", "/dev/ttyUSB1", "/dev/ttyUSB2", "/dev/ttyUSB3",
"/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3",
NULL
};
/* Serial Rate Menu */
static GtkWidget *rate_menu;
/****************************** Main Code *************************************/
#ifdef COLORS
/* This doesn't work quite right. There is supposedly no way to do it in GTK. */
static void r(GtkWidget *w, gpointer data)
{
GtkStyle *style;
style = gtk_rc_get_style(GTK_WIDGET(w));
if (style) gtk_rc_style_unref(style);
if (GTK_IS_CONTAINER(w)) {
gtk_container_foreach(GTK_CONTAINER(w), r, w);
}
}
static void set_colors()
{
GtkStyle* style;
int i;
r(main_window, NULL);
r(window, NULL);
gtk_rc_reparse_all();
read_gtkrc_file();
gtk_rc_reparse_all();
gtk_widget_reset_rc_styles(window);
gtk_widget_reset_rc_styles(main_window);
gtk_rc_reparse_all();
gtk_widget_queue_draw(window);
gtk_widget_queue_draw(main_window);
}
#endif /* #ifdef COLORS */
/* Sync Port menu code */
static void cb_serial_port_menu(GtkWidget *widget,
gpointer data)
{
if (!widget)
return;
if (!(GTK_CHECK_MENU_ITEM(widget))->active) {
return;
}
const char *port_str = port_choices[GPOINTER_TO_INT(data)];
gtk_entry_set_text(GTK_ENTRY(port_entry), port_str);
if (! strcmp(port_str, "usb:")) {
gtk_widget_set_sensitive(rate_menu, FALSE);
} else {
gtk_widget_set_sensitive(rate_menu, TRUE);
}
return;
}
static int make_serial_port_menu(GtkWidget **port_menu)
{
GtkWidget *menu;
GSList *group;
int i, selected;
const char *entry_text;
*port_menu = gtk_option_menu_new();
menu = gtk_menu_new();
group = NULL;
selected=0;
entry_text = gtk_entry_get_text(GTK_ENTRY(port_entry));
for (i=0; port_choices[i]; i++) {
port_menu_item[i] = gtk_radio_menu_item_new_with_label(group, port_choices[i]);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(port_menu_item[i]));
gtk_menu_append(GTK_MENU(menu), port_menu_item[i]);
if (!strcmp(entry_text, port_choices[i])) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(port_menu_item[i]), TRUE);
selected=i;
}
/* We don't want a callback if "other" is selected */
if (i) {
gtk_signal_connect(GTK_OBJECT(port_menu_item[i]), "activate",
GTK_SIGNAL_FUNC(cb_serial_port_menu),
GINT_TO_POINTER(i));
}
gtk_widget_show(port_menu_item[i]);
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(*port_menu), menu);
gtk_option_menu_set_history(GTK_OPTION_MENU(*port_menu), selected);
return EXIT_SUCCESS;
}
/* End Sync Port Menu code */
static void cb_pref_menu(GtkWidget *widget, gpointer data)
{
int pref;
int value;
if (!widget)
return;
if (!(GTK_CHECK_MENU_ITEM(widget))->active) {
return;
}
pref = GPOINTER_TO_INT(data);
value = pref & 0xFF;
pref = pref >> 8;
set_pref_possibility(pref, value, TRUE);
jp_logf(JP_LOG_DEBUG, "pref %d, value %d\n", pref, value);
#ifdef COLORS
if (pref==PREF_RCFILE) {
set_colors();
}
#endif
return;
}
int make_pref_menu(GtkWidget **pref_menu, int pref_num)
{
GtkWidget *menu_item;
GtkWidget *menu;
GSList *group;
int i, r;
long ivalue;
const char *svalue;
char format_text[MAX_PREF_LEN];
char human_text[MAX_PREF_LEN];
time_t ltime;
struct tm *now;
time(<ime);
now = localtime(<ime);
*pref_menu = gtk_option_menu_new();
menu = gtk_menu_new();
group = NULL;
get_pref(pref_num, &ivalue, &svalue);
for (i=0; i<MAX_NUM_PREFS; i++) {
r = get_pref_possibility(pref_num, i, format_text);
if (r) {
break;
}
switch (pref_num) {
case PREF_SHORTDATE:
case PREF_TIME:
jp_strftime(human_text, MAX_PREF_LEN, format_text, now);
break;
case PREF_LONGDATE:
jp_strftime(human_text, MAX_PREF_LEN, _(format_text), now);
break;
default:
strncpy(human_text, format_text, MAX_PREF_LEN);
break;
}
menu_item = gtk_radio_menu_item_new_with_label(
group, human_text);
group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item));
gtk_menu_append(GTK_MENU(menu), menu_item);
if (ivalue == i) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), ivalue);
}
gtk_signal_connect(GTK_OBJECT(menu_item), "activate", GTK_SIGNAL_FUNC(cb_pref_menu),
GINT_TO_POINTER(((pref_num*0x100) + (i & 0xFF))));
gtk_widget_show(menu_item);
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(*pref_menu), menu);
return EXIT_SUCCESS;
}
static void cb_backups_entry(GtkWidget *widget, gpointer data)
{
const char *entry_text;
int num_backups;
entry_text = gtk_entry_get_text(GTK_ENTRY(backups_entry));
sscanf(entry_text, "%d", &num_backups);
if (num_backups < 1) {
num_backups = 1;
}
if (num_backups > 99) {
num_backups = 99;
}
set_pref(PREF_NUM_BACKUPS, num_backups, NULL, FALSE);
}
static void cb_checkbox_todo_days_till_due(GtkWidget *widget, gpointer data)
{
int num_days;
const char *entry_text;
entry_text = gtk_entry_get_text(GTK_ENTRY(todo_days_due_entry));
sscanf(entry_text, "%d", &num_days);
set_pref(PREF_TODO_DAYS_TILL_DUE, num_days, NULL, TRUE);
}
static void cb_checkbox_show_tooltips(GtkWidget *widget, gpointer data)
{
set_pref(PREF_SHOW_TOOLTIPS, GTK_TOGGLE_BUTTON(widget)->active, NULL, TRUE);
}
static void cb_text_entry(GtkWidget *widget, gpointer data)
{
const char *entry_text;
int i, found;
entry_text = gtk_entry_get_text(GTK_ENTRY(widget));
set_pref(GPOINTER_TO_INT(data), 0, entry_text, FALSE);
if (GPOINTER_TO_INT(data) == PREF_PORT) {
if (GTK_IS_WIDGET(port_menu_item[0])) {
found=0;
for (i=0; port_choices[i]; i++) {
if (!strcmp(entry_text, port_choices[i])) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(port_menu_item[i]), TRUE);
gtk_option_menu_set_history(GTK_OPTION_MENU(port_menu), i);
found=1;
}
}
if (!found) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(port_menu_item[0]), TRUE);
gtk_option_menu_set_history(GTK_OPTION_MENU(port_menu), 0);
}
}
}
}
static void cb_checkbox_set_pref(GtkWidget *widget, gpointer data)
{
unsigned long pref, value;
pref = GPOINTER_TO_INT(data);
value = GTK_TOGGLE_BUTTON(widget)->active;
set_pref(pref, value, NULL, TRUE);
}
/*
* upper 16 bits of data is pref to set
* lower 16 bits of data is value to set it to
*/
static void cb_radio_set_pref(GtkWidget *widget, gpointer data)
{
unsigned long pref, value;
pref=GPOINTER_TO_INT(data);
value=pref & 0xFFFF;
pref >>= 16;
set_pref(pref, value, NULL, TRUE);
}
#ifdef ENABLE_PLUGINS
static void cb_sync_plugin(GtkWidget *widget, gpointer data)
{
GList *plugin_list, *temp_list;
struct plugin_s *Pplugin;
int number;
number = GPOINTER_TO_INT(data);
plugin_list=NULL;
plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
Pplugin = (struct plugin_s *)temp_list->data;
if (Pplugin) {
if (number == Pplugin->number) {
if (GTK_TOGGLE_BUTTON(widget)->active) {
Pplugin->sync_on = 1;
} else {
Pplugin->sync_on = 0;
}
}
}
}
write_plugin_sync_file();
}
#endif
static gboolean cb_destroy(GtkWidget *widget)
{
jp_logf(JP_LOG_DEBUG, "Pref GUI Cleanup\n");
pref_write_rc_file();
window = NULL;
/* Preference changes can affect visual elements of applications.
* Redraw the screen to incorporate any changes made. */
cb_app_button(NULL, GINT_TO_POINTER(REDRAW));
return FALSE;
}
static void cb_quit(GtkWidget *widget, gpointer data)
{
jp_logf(JP_LOG_DEBUG, "cb_quit\n");
if (GTK_IS_WIDGET(data)) {
gtk_widget_destroy(data);
}
}
/* This function adds a simple option checkbutton for the supplied text +
* option. */
static void add_checkbutton(const char *text,
int which,
GtkWidget *vbox,
void cb(GtkWidget *widget, gpointer data))
{
/* Create button */
GtkWidget *checkbutton = gtk_check_button_new_with_label(text);
gtk_box_pack_start(GTK_BOX(vbox), checkbutton, FALSE, FALSE, 0);
gtk_widget_show(checkbutton);
/* Set the button state based on option value */
if (get_pref_int_default(which, 0))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton), TRUE);
/* Set button callback */
gtk_signal_connect(GTK_OBJECT(checkbutton), "clicked", GTK_SIGNAL_FUNC(cb),
GINT_TO_POINTER(which));
}
void cb_prefs_gui(GtkWidget *widget, gpointer data)
{
GtkWidget *checkbutton;
GtkWidget *pref_menu;
GtkWidget *label;
GtkWidget *button;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *vbox_locale;
GtkWidget *vbox_settings;
GtkWidget *vbox_datebook;
GtkWidget *vbox_address;
GtkWidget *vbox_todo;
GtkWidget *vbox_memo;
GtkWidget *vbox_alarms;
GtkWidget *vbox_conduits;
GtkWidget *hbox_temp;
GtkWidget *hseparator;
GtkWidget *notebook;
/* FIXME: Uncomment when support for Task has been added */
#if 0
GtkWidget *radio_button_todo_version[2];
#endif
GtkWidget *radio_button_datebook_version[2];
GtkWidget *radio_button_address_version[2];
GtkWidget *radio_button_memo_version[3];
long ivalue;
const char *cstr;
char temp_str[10];
char temp[256];
GSList *group;
#ifdef ENABLE_PLUGINS
GList *plugin_list, *temp_list;
struct plugin_s *Pplugin;
#endif
jp_logf(JP_LOG_DEBUG, "cb_prefs_gui\n");
if (window) {
jp_logf(JP_LOG_DEBUG, "pref_window is already up\n");
/* Shift focus to existing window if called again
and window is still alive. */
gtk_window_present(GTK_WINDOW(window));
return;
}
main_window = data;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
g_snprintf(temp, sizeof(temp), "%s %s", PN, _("Preferences"));
gtk_window_set_title(GTK_WINDOW(window), temp);
gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(cb_destroy), window);
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(window), vbox);
/* Boxes for each preference tax */
vbox_locale = gtk_vbox_new(FALSE, 0);
vbox_settings = gtk_vbox_new(FALSE, 0);
vbox_datebook = gtk_vbox_new(FALSE, 0);
vbox_address = gtk_vbox_new(FALSE, 0);
vbox_todo = gtk_vbox_new(FALSE, 0);
vbox_memo = gtk_vbox_new(FALSE, 0);
vbox_alarms = gtk_vbox_new(FALSE, 0);
vbox_conduits = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(vbox_locale), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_settings), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_datebook), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_address), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_todo), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_memo), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_alarms), 5);
gtk_container_set_border_width(GTK_CONTAINER(vbox_conduits), 5);
/* Notebook for preference tabs */
notebook = gtk_notebook_new();
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);
label = gtk_label_new(_("Locale"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_locale, label);
label = gtk_label_new(_("Settings"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_settings, label);
label = gtk_label_new(_("Datebook"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_datebook, label);
label = gtk_label_new(C_("prefgui","Address"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_address, label);
label = gtk_label_new(_("ToDo"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_todo, label);
label = gtk_label_new(_("Memo"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_memo, label);
label = gtk_label_new(_("Alarms"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_alarms, label);
label = gtk_label_new(_("Conduits"));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox_conduits, label);
gtk_box_pack_start(GTK_BOX(vbox), notebook, FALSE, FALSE, 0);
/************************************************************/
/* Locale preference tab */
table = gtk_table_new(5, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table),0);
gtk_table_set_col_spacings(GTK_TABLE(table),5);
gtk_box_pack_start(GTK_BOX(vbox_locale), table, FALSE, FALSE, 0);
/* Character Set */
label = gtk_label_new(_("Character Set"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 1, 0, 1);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&pref_menu, PREF_CHAR_SET);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(pref_menu),
1, 2, 0, 1);
get_pref(PREF_CHAR_SET, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(pref_menu), ivalue);
/* Shortdate */
label = gtk_label_new(_("Short date format"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 1, 1, 2);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&pref_menu, PREF_SHORTDATE);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(pref_menu),
1, 2, 1, 2);
get_pref(PREF_SHORTDATE, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(pref_menu), ivalue);
/* Longdate */
label = gtk_label_new(_("Long date format"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 1, 2, 3);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&pref_menu, PREF_LONGDATE);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(pref_menu),
1, 2, 2, 3);
get_pref(PREF_LONGDATE, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(pref_menu), ivalue);
/* Time */
label = gtk_label_new(_("Time format"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 1, 3, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&pref_menu, PREF_TIME);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(pref_menu),
1, 2, 3, 4);
get_pref(PREF_TIME, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(pref_menu), ivalue);
/**********************************************************************/
/* Settings preference tab */
table = gtk_table_new(4, 3, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(table),0);
gtk_table_set_col_spacings(GTK_TABLE(table),5);
gtk_box_pack_start(GTK_BOX(vbox_settings), table, FALSE, FALSE, 0);
/* GTK colors file */
label = gtk_label_new(_("GTK color theme file"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 2, 0, 1);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&pref_menu, PREF_RCFILE);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(pref_menu),
2, 3, 0, 1);
get_pref(PREF_RCFILE, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(pref_menu), ivalue);
/* Port */
label = gtk_label_new(_("Sync Port"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 1, 1, 2);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
port_entry = gtk_entry_new_with_max_length(MAX_PREF_LEN - 2);
entry_set_multiline_truncate(GTK_ENTRY(port_entry), TRUE);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(port_entry),
2, 3, 1, 2);
get_pref(PREF_PORT, NULL, &cstr);
if (cstr) {
gtk_entry_set_text(GTK_ENTRY(port_entry), cstr);
}
gtk_signal_connect(GTK_OBJECT(port_entry),
"changed", GTK_SIGNAL_FUNC(cb_text_entry),
GINT_TO_POINTER(PREF_PORT));
/* Sync Port Menu */
/* Note that port_entry must exist before we call this function */
make_serial_port_menu(&port_menu);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(port_menu),
1, 2, 1, 2);
/* Serial Rate */
label = gtk_label_new(_("Serial Rate"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 2, 2, 3);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
make_pref_menu(&rate_menu, PREF_RATE);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(rate_menu),
2, 3, 2, 3);
get_pref(PREF_RATE, &ivalue, NULL);
gtk_option_menu_set_history(GTK_OPTION_MENU(rate_menu), ivalue);
/* Disable Serial Rate menu if sync port is USB */
if (! strcmp(cstr, "usb:")) {
gtk_widget_set_sensitive(rate_menu, FALSE);
} else {
gtk_widget_set_sensitive(rate_menu, TRUE);
}
/* Number of backups */
label = gtk_label_new(_("Number of backups to be archived"));
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label),
0, 2, 3, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
backups_entry = gtk_entry_new_with_max_length(2);
entry_set_multiline_truncate(GTK_ENTRY(backups_entry), TRUE);
gtk_widget_set_usize(backups_entry, 30, 0);
gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(backups_entry),
2, 3, 3, 4);
get_pref(PREF_NUM_BACKUPS, &ivalue, NULL);
sprintf(temp_str, "%ld", ivalue);
gtk_entry_set_text(GTK_ENTRY(backups_entry), temp_str);
gtk_signal_connect(GTK_OBJECT(backups_entry),
"changed", GTK_SIGNAL_FUNC(cb_backups_entry),
NULL);
/* Show deleted files check box */
add_checkbutton(_("Show deleted records (default NO)"),
PREF_SHOW_DELETED, vbox_settings, cb_checkbox_set_pref);
/* Show modified files check box */
add_checkbutton(_("Show modified deleted records (default NO)"),
PREF_SHOW_MODIFIED, vbox_settings, cb_checkbox_set_pref);
/* Confirm file installation */
add_checkbutton(
_("Ask confirmation for file installation (J-Pilot -> PDA) (default YES)"),
PREF_CONFIRM_FILE_INSTALL, vbox_settings, cb_checkbox_set_pref);
/* Show tooltips check box */
add_checkbutton(_("Show popup tooltips (default YES) (requires restart)"),
PREF_SHOW_TOOLTIPS, vbox_settings,
cb_checkbox_show_tooltips);
/**********************************************************************/
/* Datebook preference tab */
/* Radio box to choose which database to use: Datebook/Calendar */
group = NULL;
radio_button_datebook_version[0] =
gtk_radio_button_new_with_label(group, _("Use Datebook database (Palm OS < 5.2.1)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_datebook_version[0]));
radio_button_datebook_version[1] =
gtk_radio_button_new_with_label(group, _("Use Calendar database (Palm OS > 5.2)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_datebook_version[1]));
gtk_box_pack_start(GTK_BOX(vbox_datebook), radio_button_datebook_version[0],
FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_datebook), radio_button_datebook_version[1],
FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(radio_button_datebook_version[0]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_DATEBOOK_VERSION<<16)|0));
gtk_signal_connect(GTK_OBJECT(radio_button_datebook_version[1]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_DATEBOOK_VERSION<<16)|1));
get_pref(PREF_DATEBOOK_VERSION, &ivalue, NULL);
if (ivalue) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_datebook_version[1]), TRUE);
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_datebook_version[0]), TRUE);
}
/* Separate database selection from less important options */
hseparator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox_datebook), hseparator, FALSE, FALSE, 3);
/* Show highlight days check box */
add_checkbutton(_("Highlight calendar days with appointments"),
PREF_DATEBOOK_HIGHLIGHT_DAYS, vbox_datebook,
cb_checkbox_set_pref);
/* Highlight today on month and week view */
add_checkbutton(_("Annotate today in day, week, and month views"),
PREF_DATEBOOK_HI_TODAY, vbox_datebook, cb_checkbox_set_pref);
/* Show number of years on anniversaries in month and week view */
add_checkbutton(_("Append years on anniversaries in day, week, and month views"),
PREF_DATEBOOK_ANNI_YEARS, vbox_datebook,
cb_checkbox_set_pref);
#ifdef ENABLE_DATEBK
/* Show use DateBk check box */
add_checkbutton(_("Use DateBk note tags"),
PREF_USE_DB3, vbox_datebook, cb_checkbox_set_pref);
#else
checkbutton = gtk_check_button_new_with_label(_("DateBk support disabled in this build"));
gtk_widget_set_sensitive(checkbutton, FALSE);
gtk_box_pack_start(GTK_BOX(vbox_datebook), checkbutton, FALSE, FALSE, 0);
gtk_widget_show(checkbutton);
#endif
/**********************************************************************/
/* Address preference tab */
/* Radio box to choose which database to use: Address/Contacts */
group = NULL;
radio_button_address_version[0] =
gtk_radio_button_new_with_label(group, _("Use Address database (Palm OS < 5.2.1)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_address_version[0]));
radio_button_address_version[1] =
gtk_radio_button_new_with_label(group, _("Use Contacts database (Palm OS > 5.2)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_address_version[1]));
gtk_box_pack_start(GTK_BOX(vbox_address), radio_button_address_version[0],
FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_address), radio_button_address_version[1],
FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(radio_button_address_version[0]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_ADDRESS_VERSION<<16)|0));
gtk_signal_connect(GTK_OBJECT(radio_button_address_version[1]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_ADDRESS_VERSION<<16)|1));
get_pref(PREF_ADDRESS_VERSION, &ivalue, NULL);
if (ivalue) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_address_version[1]), TRUE);
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_address_version[0]), TRUE);
}
/* Separate database selection from less important options */
hseparator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox_address), hseparator, FALSE, FALSE, 3);
/* Command to use for e-mailing from address book */
hbox_temp = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_address), hbox_temp, FALSE, FALSE, 0);
label = gtk_label_new(_("Mail Command"));
gtk_box_pack_start(GTK_BOX(hbox_temp), label, FALSE, FALSE, 0);
mail_command_entry = gtk_entry_new_with_max_length(MAX_PREF_LEN - 2);
get_pref(PREF_MAIL_COMMAND, NULL, &cstr);
if (cstr) {
gtk_entry_set_text(GTK_ENTRY(mail_command_entry), cstr);
}
gtk_signal_connect(GTK_OBJECT(mail_command_entry),
"changed", GTK_SIGNAL_FUNC(cb_text_entry),
GINT_TO_POINTER(PREF_MAIL_COMMAND));
gtk_box_pack_start(GTK_BOX(hbox_temp), mail_command_entry, TRUE, TRUE, 1);
label = gtk_label_new(_("%s is replaced by the e-mail address"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_address), label, FALSE, FALSE, 0);
/**********************************************************************/
/* ToDo preference tab */
/* FIXME: undef when support for Task has been coded */
#if 0
/* Radio box to choose which database to use: Todo/Task */
group = NULL;
radio_button_task_version[0] =
gtk_radio_button_new_with_label(group, _("Use ToDo database (Palm OS < 5.2.1)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_todo_version[0]));
radio_button_todo_version[1] =
gtk_radio_button_new_with_label(group, _("Use Task database (Palm OS > 5.2)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_todo_version[1]));
gtk_box_pack_start(GTK_BOX(vbox_todo), radio_button_todo_version[0],
FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_todo), radio_button_todo_version[1],
FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(radio_button_todo_version[0]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_TODO_VERSION<<16)|0));
gtk_signal_connect(GTK_OBJECT(radio_button_todo_version[1]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_TODO_VERSION<<16)|1));
get_pref(PREF_TODO_VERSION, &ivalue, NULL);
if (ivalue) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_todo_version[1]), TRUE);
} else {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_todo_version[0]), TRUE);
}
/* Separate database selection from less important options */
hseparator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox_todo), hseparator, FALSE, FALSE, 3);
#endif
/* hide completed check box */
add_checkbutton(_("Hide Completed ToDos"),
PREF_TODO_HIDE_COMPLETED, vbox_todo, cb_checkbox_set_pref);
/* hide todos not yet due check box */
add_checkbutton(_("Hide ToDos not yet due"),
PREF_TODO_HIDE_NOT_DUE, vbox_todo, cb_checkbox_set_pref);
/* record todo completion date check box */
add_checkbutton(_("Record Completion Date"),
PREF_TODO_COMPLETION_DATE, vbox_todo, cb_checkbox_set_pref);
#ifdef ENABLE_MANANA
/* Use Manana check box */
add_checkbutton(_("Use Manana database"),
PREF_MANANA_MODE, vbox_todo, cb_checkbox_set_pref);
#endif
/* Default Number of Days Due for ToDos */
hbox_temp = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_todo), hbox_temp, FALSE, FALSE, 0);
add_checkbutton(_("Use default number of days due"),
PREF_TODO_DAYS_DUE, hbox_temp, cb_checkbox_set_pref);
todo_days_due_entry = gtk_entry_new_with_max_length(MAX_PREF_LEN - 2);
entry_set_multiline_truncate(GTK_ENTRY(todo_days_due_entry), TRUE);
get_pref(PREF_TODO_DAYS_TILL_DUE, &ivalue, NULL);
temp[0]='\0';
g_snprintf(temp, sizeof(temp), "%ld", ivalue);
gtk_entry_set_text(GTK_ENTRY(todo_days_due_entry), temp);
gtk_box_pack_start(GTK_BOX(hbox_temp), todo_days_due_entry, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(todo_days_due_entry),
"changed", GTK_SIGNAL_FUNC(cb_checkbox_todo_days_till_due),
NULL);
gtk_widget_show_all(hbox_temp);
/**********************************************************************/
/* Memo preference tab */
/* Radio box to choose which database to use: Memo/Memos/Memo32 */
group = NULL;
radio_button_memo_version[0] =
gtk_radio_button_new_with_label(group, _("Use Memo database (Palm OS < 5.2.1)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_memo_version[0]));
radio_button_memo_version[1] =
gtk_radio_button_new_with_label(group, _("Use Memos database (Palm OS > 5.2)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_memo_version[1]));
radio_button_memo_version[2] =
gtk_radio_button_new_with_label(group, _("Use Memo32 database (pedit32)"));
group = gtk_radio_button_group(GTK_RADIO_BUTTON(radio_button_memo_version[2]));
gtk_box_pack_start(GTK_BOX(vbox_memo), radio_button_memo_version[0],
FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_memo), radio_button_memo_version[1],
FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_memo), radio_button_memo_version[2],
FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(radio_button_memo_version[0]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_MEMO_VERSION<<16)|0));
gtk_signal_connect(GTK_OBJECT(radio_button_memo_version[1]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_MEMO_VERSION<<16)|1));
gtk_signal_connect(GTK_OBJECT(radio_button_memo_version[2]), "pressed",
GTK_SIGNAL_FUNC(cb_radio_set_pref),
GINT_TO_POINTER((PREF_MEMO_VERSION<<16)|2));
get_pref(PREF_MEMO_VERSION, &ivalue, NULL);
switch (ivalue) {
case 0:
default:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_memo_version[0]), TRUE);
break;
case 1:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_memo_version[1]), TRUE);
break;
case 2:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_memo_version[2]), TRUE);
break;
}
hseparator = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(vbox_memo), hseparator, FALSE, FALSE, 3);
/* External Editor Command to execute */
hbox_temp = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_memo), hbox_temp, FALSE, FALSE, 0);
label = gtk_label_new(_("External Editor"));
gtk_box_pack_start(GTK_BOX(hbox_temp), label, FALSE, FALSE, 0);
ext_editor_entry = gtk_entry_new_with_max_length(MAX_PREF_LEN - 2);
get_pref(PREF_EXTERNAL_EDITOR, NULL, &cstr);
if (cstr) {
gtk_entry_set_text(GTK_ENTRY(ext_editor_entry), cstr);
}
gtk_signal_connect(GTK_OBJECT(ext_editor_entry),
"changed", GTK_SIGNAL_FUNC(cb_text_entry),
GINT_TO_POINTER(PREF_EXTERNAL_EDITOR));
gtk_box_pack_start(GTK_BOX(hbox_temp), ext_editor_entry, TRUE, TRUE, 1);
label = gtk_label_new(_("Use Ctrl-E inside a memo to launch external editor for memo text"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_memo), label, FALSE, FALSE, 0);
/**********************************************************************/
/* Alarms preference tab */
/* Open alarm windows check box */
add_checkbutton(_("Open alarm windows for appointment reminders"),
PREF_OPEN_ALARM_WINDOWS, vbox_alarms, cb_checkbox_set_pref);
/* Execute alarm command check box */
add_checkbutton(_("Execute this command"),
PREF_DO_ALARM_COMMAND, vbox_alarms, cb_checkbox_set_pref);
/* Shell warning label */
label = gtk_label_new(_("WARNING: executing arbitrary shell commands can be dangerous!!!"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
/* Alarm Command to execute */
hbox_temp = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), hbox_temp, FALSE, FALSE, 0);
label = gtk_label_new(_("Alarm Command"));
gtk_box_pack_start(GTK_BOX(hbox_temp), label, FALSE, FALSE, 10);
alarm_command_entry = gtk_entry_new_with_max_length(MAX_PREF_LEN - 2);
get_pref(PREF_ALARM_COMMAND, NULL, &cstr);
if (cstr) {
gtk_entry_set_text(GTK_ENTRY(alarm_command_entry), cstr);
}
gtk_signal_connect(GTK_OBJECT(alarm_command_entry),
"changed", GTK_SIGNAL_FUNC(cb_text_entry),
GINT_TO_POINTER(PREF_ALARM_COMMAND));
gtk_box_pack_start(GTK_BOX(hbox_temp), alarm_command_entry, FALSE, FALSE, 0);
label = gtk_label_new(_("%t is replaced with the alarm time"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
label = gtk_label_new(_("%d is replaced with the alarm date"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
#ifdef ENABLE_ALARM_SHELL_DANGER
label = gtk_label_new(_("%D is replaced with the alarm description"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
label = gtk_label_new(_("%N is replaced with the alarm note"));
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
#else
label = gtk_label_new(_("%D (description substitution) is disabled in this build"));
gtk_widget_set_sensitive(label, FALSE);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
label = gtk_label_new(_("%N (note substitution) is disabled in this build"));
gtk_widget_set_sensitive(label, FALSE);
gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(vbox_alarms), label, FALSE, FALSE, 0);
#endif
/**********************************************************************/
/* Conduits preference tab */
/* Sync datebook check box */
add_checkbutton(_("Sync datebook"),
PREF_SYNC_DATEBOOK, vbox_conduits, cb_checkbox_set_pref);
/* Sync address check box */
add_checkbutton(_("Sync address"),
PREF_SYNC_ADDRESS, vbox_conduits, cb_checkbox_set_pref);
/* Sync todo check box */
add_checkbutton(_("Sync todo"),
PREF_SYNC_TODO, vbox_conduits, cb_checkbox_set_pref);
/* Sync memo check box */
add_checkbutton(_("Sync memo"),
PREF_SYNC_MEMO, vbox_conduits, cb_checkbox_set_pref);
#ifdef ENABLE_MANANA
/* Show sync Manana check box */