~ubuntu-branches/debian/jessie/xfe/jessie

« back to all changes in this revision

Viewing changes to .pc/15_not-asking-for-quit.patch/src/Preferences.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Wiedorn
  • Date: 2011-10-18 14:17:15 UTC
  • Revision ID: james.westby@ubuntu.com-20111018141715-7oxdt8ifiuy9ruom
Tags: 1.32.4-3
* debian/control:
  - Update suggested packages: remove playmidi, change to xine-ui.
* debian/patches:
  - Update some patches.
  - Optimize no-mount-warning patch. By default do not warn while mounting.
  - Add not-asking-for-quit patch. By default do not ask for quit. (Closes:
    #642078)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Preferences dialog box
 
2
 
 
3
#include "config.h"
 
4
#include "i18n.h"
 
5
 
 
6
#include <fx.h>
 
7
#include <fxkeys.h>
 
8
 
 
9
#include "icons.h"
 
10
#include "xfedefs.h"
 
11
#include "xfeutils.h"
 
12
#include "FileDialog.h"
 
13
#include "FontDialog.h"
 
14
#include "XFileExplorer.h"
 
15
#include "MessageBox.h"
 
16
#include "Keybindings.h"
 
17
#include "Preferences.h"
 
18
 
 
19
 
 
20
FXbool Theme::operator != (const Theme& t)
 
21
{
 
22
    for(int i=0;i<NUM_COLORS;i++)
 
23
        if(color[i] != t.color[i])
 
24
            return TRUE;
 
25
    return FALSE;
 
26
}
 
27
 
 
28
 
 
29
// Main window
 
30
extern FXMainWindow *mainWindow;
 
31
 
 
32
// Single click navigation
 
33
extern FXbool single_click;
 
34
 
 
35
// File tooltips
 
36
extern FXbool file_tooltips;
 
37
 
 
38
// Relative resizing of the panels and columns in detailed mode
 
39
extern FXbool relative_resize;
 
40
 
 
41
// Save window position 
 
42
extern FXbool save_win_pos;
 
43
 
 
44
 
 
45
// Create hilite color from given color for gradient controls
 
46
FXColor makeHiliteColorGradient(FXColor color)
 
47
{
 
48
        FXuint r, g, b;
 
49
        
 
50
        r=FXREDVAL(color);
 
51
        g=FXGREENVAL(color);
 
52
        b=FXBLUEVAL(color);
 
53
 
 
54
        r=(FXuint)(FXMIN(1.2*r,255));
 
55
        g=(FXuint)(FXMIN(1.2*g,255));
 
56
        b=(FXuint)(FXMIN(1.2*b,255));
 
57
 
 
58
        return FXRGB(r,g,b);
 
59
}
 
60
 
 
61
 
 
62
// Create shadow color from given color for gradient controls
 
63
FXColor makeShadowColorGradient(FXColor color)
 
64
{
 
65
        FXuint r, g, b;
 
66
        
 
67
        r=FXREDVAL(color);
 
68
        g=FXGREENVAL(color);
 
69
        b=FXBLUEVAL(color);
 
70
 
 
71
        r=(FXuint)(0.7*r);
 
72
        g=(FXuint)(0.7*g);
 
73
        b=(FXuint)(0.7*b);
 
74
 
 
75
        return FXRGB(r,g,b);
 
76
}
 
77
 
 
78
 
 
79
// Map
 
80
FXDEFMAP(PreferencesBox) PreferencesMap[]=
 
81
{
 
82
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_ACCEPT,PreferencesBox::onCmdAccept),
 
83
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_CANCEL,PreferencesBox::onCmdCancel),
 
84
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_TXTEDIT,PreferencesBox::onCmdBrowse),
 
85
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_TXTVIEW,PreferencesBox::onCmdBrowse),
 
86
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_IMGVIEW,PreferencesBox::onCmdBrowse),
 
87
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_ARCHIVER,PreferencesBox::onCmdBrowse),
 
88
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_PDFVIEW,PreferencesBox::onCmdBrowse),
 
89
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_VIDEOVIEW,PreferencesBox::onCmdBrowse),
 
90
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_AUDIOVIEW,PreferencesBox::onCmdBrowse),
 
91
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_XTERM,PreferencesBox::onCmdBrowse),
 
92
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_COLOR,PreferencesBox::onCmdColor),
 
93
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_NORMALFONT,PreferencesBox::onCmdNormalFont),
 
94
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_TEXTFONT,PreferencesBox::onCmdTextFont),
 
95
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_THEME,PreferencesBox::onCmdTheme),
 
96
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_BROWSE_ICON_PATH,PreferencesBox::onCmdBrowsePath),
 
97
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_SU_CMD,PreferencesBox::onCmdSuMode),
 
98
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_SUDO_CMD,PreferencesBox::onCmdSuMode),
 
99
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_STANDARD_CONTROLS,PreferencesBox::onCmdControls),
 
100
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_CLEARLOOKS_CONTROLS,PreferencesBox::onCmdControls),
 
101
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_WHEELADJUST,PreferencesBox::onCmdWheelAdjust),
 
102
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_CHANGE_KEYBINDINGS,PreferencesBox::onCmdChangeKeyBindings),
 
103
        FXMAPFUNC(SEL_COMMAND,PreferencesBox::ID_RESTORE_KEYBINDINGS,PreferencesBox::onCmdRestoreKeyBindings),
 
104
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_STANDARD_CONTROLS,PreferencesBox::onUpdControls),
 
105
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_CLEARLOOKS_CONTROLS,PreferencesBox::onUpdControls),
 
106
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_COLOR,PreferencesBox::onUpdColor),
 
107
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_WHEELADJUST,PreferencesBox::onUpdWheelAdjust),
 
108
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_SINGLE_CLICK_FILEOPEN,PreferencesBox::onUpdSingleClickFileopen),
 
109
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_CONFIRM_TRASH,PreferencesBox::onUpdTrash),
 
110
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_TRASH_BYPASS,PreferencesBox::onUpdTrash),
 
111
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_CONFIRM_DEL_EMPTYDIR,PreferencesBox::onUpdConfirmDelEmptyDir),
 
112
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_SU_CMD,PreferencesBox::onUpdSuMode),
 
113
        FXMAPFUNC(SEL_UPDATE,PreferencesBox::ID_SUDO_CMD,PreferencesBox::onUpdSuMode),
 
114
};
 
115
 
 
116
// Object implementation
 
117
FXIMPLEMENT(PreferencesBox,DialogBox,PreferencesMap,ARRAYNUMBER(PreferencesMap))
 
118
 
 
119
// Construct window
 
120
PreferencesBox::PreferencesBox(FXWindow *win, FXColor listbackcolor, FXColor listforecolor, FXColor highlightcolor, FXColor pbarcolor, FXColor attentioncolor): DialogBox(win,_("Preferences"), DECOR_TITLE|DECOR_BORDER)
 
121
{
 
122
    currTheme.name = _("Current Theme");
 
123
    currTheme.color[0] = getApp()->getBaseColor();
 
124
    currTheme.color[1] = getApp()->getBorderColor();
 
125
    currTheme.color[2] = getApp()->getBackColor();
 
126
    currTheme.color[3] = getApp()->getForeColor();
 
127
    currTheme.color[4] = getApp()->getSelbackColor();
 
128
    currTheme.color[5] = getApp()->getSelforeColor();
 
129
    currTheme.color[6] = listbackcolor;
 
130
    currTheme.color[7] = listforecolor;
 
131
    currTheme.color[8] = highlightcolor;
 
132
    currTheme.color[9] = pbarcolor;
 
133
        currTheme.color[10] = attentioncolor;
 
134
 
 
135
    Themes[0] = currTheme;
 
136
    Themes[1] = Theme("FOX",FXRGB(212,208,200),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(10,36,106),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(10,36,106),FXRGB(255,0,0));
 
137
    Themes[2] = Theme("GNOME2",FXRGB(220,218,213),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(75,105,131),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(75,105,131),FXRGB(255,0,0));
 
138
    Themes[3] = Theme("KDE3",FXRGB(238,238,230),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(255,222,118),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(255,222,118),FXRGB(255,0,0));
 
139
    Themes[4] = Theme("XFCE4",FXRGB(238,238,238),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(0,0,0),FXRGB(99,119,146),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(99,119,146),FXRGB(255,0,0));
 
140
    Themes[5] = Theme("CDE",FXRGB(156,153,156),FXRGB(0,0,0),FXRGB(131,129,131),FXRGB(255,255,255),FXRGB(49,97,131),FXRGB(255,255,255),FXRGB(131,129,131),FXRGB(255,255,255),FXRGB(165,162,165),FXRGB(49,97,131),FXRGB(255,0,0));
 
141
    Themes[6] = Theme("Digital CDE",FXRGB(74,121,131),FXRGB(0,0,0),FXRGB(49,76,74),FXRGB(255,255,255),FXRGB(82,101,113),FXRGB(255,255,255),FXRGB(49,76,74),FXRGB(255,255,255),FXRGB(69,107,104),FXRGB(82,101,113),FXRGB(255,0,0));
 
142
    Themes[7] = Theme("Sea Sky",FXRGB(165,178,198),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(49,101,156),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(49,101,156),FXRGB(255,0,0));
 
143
    Themes[8] = Theme("Blue Slate",FXRGB(156,186,205),FXRGB(0,0,0),FXRGB(197,194,197),FXRGB(0,0,0),FXRGB(82,129,148),FXRGB(255,255,255),FXRGB(197,194,197),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(82,129,148),FXRGB(255,0,0));
 
144
    Themes[9] = Theme("Human",FXRGB(0xEF,0xEB,0xE7),FXRGB(0,0,0),FXRGB(0xEE,0xEE,0xEE),FXRGB(0,0,0),FXRGB(0xB3,0x91,0x69),FXRGB(0xFF,0xFF,0xFF),FXRGB(0xEE,0xEE,0xEE),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0xB3,0x91,0x69),FXRGB(255,0,0));
 
145
    Themes[10] = Theme("iMac",FXRGB(205,206,205),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(0,0,128),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(0,0,128),FXRGB(255,0,0));
 
146
    Themes[11] = Theme("BeOS",FXRGB(222,218,222),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(172,170,172),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(172,170,172),FXRGB(255,0,0));
 
147
        Themes[12] = Theme("Windows 95",FXRGB(192,192,192),FXRGB(0,0,0),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(0,0,128),FXRGB(255,255,255),FXRGB(255,255,255),FXRGB(0,0,0),FXRGB(238,238,238),FXRGB(0,0,128),FXRGB(255,0,0));
 
148
 
 
149
    // Buttons
 
150
    FXHorizontalFrame *buttons=new FXHorizontalFrame(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X,0,0,0,0,10,10,5,5);
 
151
 
 
152
    // Contents
 
153
    FXHorizontalFrame *contents=new FXHorizontalFrame(this,LAYOUT_SIDE_TOP|FRAME_NONE|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH);
 
154
 
 
155
        // Accept
 
156
    FXButton *ok = new FXButton(buttons,_("&Accept"),NULL,this,PreferencesBox::ID_ACCEPT,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
157
    ok->addHotKey(KEY_Return);
 
158
    
 
159
    // Cancel
 
160
    new FXButton(buttons,_("&Cancel"),NULL,this,PreferencesBox::ID_CANCEL,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
161
    
 
162
        // Switcher
 
163
    FXTabBook *tabbook = new FXTabBook(contents,NULL,0,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT);
 
164
 
 
165
 
 
166
    // First tab - General options
 
167
    new FXTabItem(tabbook,_("&General"),NULL);
 
168
    FXVerticalFrame *options=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
169
 
 
170
        FXGroupBox *group=new FXGroupBox(options,_("Options"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
171
    trashcan=new FXCheckButton(group,_("Use trash can for file deletion (safe delete)")); 
 
172
        trashbypass=new FXCheckButton(group,_("Include a command to bypass the trash can (permanent delete)"),this,ID_TRASH_BYPASS);
 
173
    autosave=new FXCheckButton(group,_("Auto save layout"));
 
174
        savewinpos=new FXCheckButton(group,_("Save window position"));
 
175
    diropen=new FXCheckButton(group,_("Single click directory open"));
 
176
    fileopen=new FXCheckButton(group,_("Single click file open"),this,ID_SINGLE_CLICK_FILEOPEN);
 
177
    filetooltips=new FXCheckButton(group,_("Display tooltips in file and directory lists"),this,ID_FILE_TOOLTIPS);
 
178
    relativeresize=new FXCheckButton(group,_("Relative resizing of file lists"),this,ID_RELATIVE_RESIZE);
 
179
    showpathlink=new FXCheckButton(group,_("Display a path linker above file lists"),this,ID_SHOW_PATHLINK);
 
180
#ifdef STARTUP_NOTIFICATION
 
181
        usesn=new FXCheckButton(group,_("Notify when applications start up"));
 
182
#endif
 
183
        group=new FXGroupBox(options,_("Mouse"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
184
    scroll=new FXCheckButton(group,_("Smooth scrolling in file lists and text windows"));
 
185
    FXMatrix *matrix = new FXMatrix(group,2,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_Y);
 
186
        new FXLabel(matrix,_("Mouse scrolling speed:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
187
    FXSpinner* spinner=new FXSpinner(matrix,3,this,PreferencesBox::ID_WHEELADJUST,JUSTIFY_RIGHT|LAYOUT_FILL_X|LAYOUT_FILL_ROW,0,0,0,0, 2,2,1,1);
 
188
    spinner->setRange(1,100);
 
189
        FXbool smoothscroll=getApp()->reg().readUnsignedEntry("SETTINGS","smooth_scroll",TRUE);
 
190
        scroll->setCheck(smoothscroll);
 
191
 
 
192
        group=new FXGroupBox(options,_("Root mode"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
193
        rootmode=new FXCheckButton(group,_("Allow root mode"));
 
194
        FXRadioButton* subutton=new FXRadioButton(group,_("Authentication using su (uses root password)"),this,ID_SU_CMD);
 
195
        FXRadioButton* sudobutton=new FXRadioButton(group,_("Authentication using sudo (uses user password)"),this,ID_SUDO_CMD);
 
196
 
 
197
    FXbool root_mode=getApp()->reg().readUnsignedEntry("OPTIONS","root_mode",TRUE);
 
198
    rootmode->setCheck(root_mode);
 
199
 
 
200
        if (getuid()==0) // Super user
 
201
        {
 
202
                rootmode->disable();
 
203
                subutton->disable();
 
204
                sudobutton->disable();
 
205
        }
 
206
        use_sudo=getApp()->reg().readUnsignedEntry("OPTIONS","use_sudo",FALSE);
 
207
 
 
208
    FXbool use_trash_can=getApp()->reg().readUnsignedEntry("OPTIONS","use_trash_can",TRUE);
 
209
        trashcan->setCheck(use_trash_can);
 
210
    
 
211
        if (trashcan->getCheck())
 
212
        {
 
213
            FXbool use_trash_bypass=getApp()->reg().readUnsignedEntry("OPTIONS","use_trash_bypass",FALSE);
 
214
                trashbypass->setCheck(use_trash_bypass);
 
215
        }
 
216
        else
 
217
                trashbypass->disable();
 
218
 
 
219
        FXbool auto_save_layout=getApp()->reg().readUnsignedEntry("OPTIONS","auto_save_layout",TRUE);
 
220
        autosave->setCheck(auto_save_layout);
 
221
 
 
222
    FXbool save_win_pos=getApp()->reg().readUnsignedEntry("SETTINGS","save_win_pos",FALSE);
 
223
        savewinpos->setCheck(save_win_pos);
 
224
    
 
225
        // Single click navigation
 
226
        single_click=getApp()->reg().readUnsignedEntry("SETTINGS","single_click",SINGLE_CLICK_NONE);
 
227
        single_click=getApp()->reg().readUnsignedEntry("SETTINGS","single_click",SINGLE_CLICK_NONE);
 
228
        if (single_click==SINGLE_CLICK_DIR)
 
229
        {
 
230
                diropen->setCheck(TRUE);
 
231
                fileopen->setCheck(FALSE);
 
232
        }
 
233
        else if (single_click==SINGLE_CLICK_DIR_FILE)
 
234
        {
 
235
                diropen->setCheck(TRUE);
 
236
                fileopen->setCheck(TRUE);
 
237
        }
 
238
        else
 
239
        {
 
240
                diropen->setCheck(FALSE);
 
241
                fileopen->setCheck(FALSE);
 
242
        }
 
243
        
 
244
        // File tooltips
 
245
        if (file_tooltips==FALSE)
 
246
                filetooltips->setCheck(FALSE);
 
247
        else
 
248
                filetooltips->setCheck(TRUE);
 
249
        
 
250
        // Relative resizing
 
251
        if (relative_resize==FALSE)
 
252
                relativeresize->setCheck(FALSE);
 
253
        else
 
254
                relativeresize->setCheck(TRUE);
 
255
                
 
256
        // Display path linker
 
257
        show_pathlink=getApp()->reg().readUnsignedEntry("SETTINGS","show_pathlinker",TRUE);
 
258
        if (show_pathlink==FALSE)
 
259
                showpathlink->setCheck(FALSE);
 
260
        else
 
261
                showpathlink->setCheck(TRUE);   
 
262
 
 
263
#ifdef STARTUP_NOTIFICATION
 
264
    FXbool use_sn=getApp()->reg().readUnsignedEntry("OPTIONS","use_startup_notification",TRUE);
 
265
        usesn->setCheck(use_sn);
 
266
#endif
 
267
                
 
268
    // Second tab - Dialogs
 
269
    new FXTabItem(tabbook,_("&Dialogs"),NULL);
 
270
    FXVerticalFrame *dialogs=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
271
        group=new FXGroupBox(dialogs,_("Confirmations"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
272
    ask=new FXCheckButton(group,_("Confirm copy/move/rename/symlink"));
 
273
    dnd=new FXCheckButton(group,_("Confirm drag and drop"));
 
274
        trashmv=new FXCheckButton(group,_("Confirm move to trash/restore from trash"),this,ID_CONFIRM_TRASH);
 
275
        del=new FXCheckButton(group,_("Confirm delete"));
 
276
        del_emptydir=new FXCheckButton(group,_("Confirm delete non empty directories"),this,ID_CONFIRM_DEL_EMPTYDIR);
 
277
    overwrite=new FXCheckButton(group,_("Confirm overwrite"));
 
278
        quit=new FXCheckButton(group,_("Confirm quit"));
 
279
 
 
280
        group=new FXGroupBox(dialogs,_("Warnings"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
281
#if defined(linux)
 
282
    mount=new FXCheckButton (group,_("Warn when mount points are not responding"));
 
283
        show_mount=new FXCheckButton(group, _("Display mount/umount success messages"));
 
284
#endif
 
285
    root_warning=new FXCheckButton (group,_("Warn if running as root"));
 
286
 
 
287
        FXbool confirm_quit=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_quit",TRUE);
 
288
        quit->setCheck(confirm_quit);
 
289
    FXbool confirm_trash=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_trash",TRUE);
 
290
        trashmv->setCheck(confirm_trash);
 
291
    FXbool confirm_del=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_delete",TRUE);
 
292
        del->setCheck(confirm_del);
 
293
    FXbool confirm_del_emptydir=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_delete_emptydir",TRUE);
 
294
        del_emptydir->setCheck(confirm_del_emptydir);
 
295
    FXbool confirm_overwrite=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_overwrite",TRUE);
 
296
        overwrite->setCheck(confirm_overwrite);
 
297
    FXbool ask_before_copy=getApp()->reg().readUnsignedEntry("OPTIONS","ask_before_copy",TRUE);
 
298
        ask->setCheck(ask_before_copy);
 
299
    FXbool confirm_dnd=getApp()->reg().readUnsignedEntry("OPTIONS","confirm_drag_and_drop",TRUE);
 
300
        dnd->setCheck(confirm_dnd);
 
301
 
 
302
#if defined(linux)
 
303
        FXbool mount_warn=getApp()->reg().readUnsignedEntry("OPTIONS","mount_warn",FALSE);
 
304
        FXbool mount_messages=getApp()->reg().readUnsignedEntry("OPTIONS","mount_messages",TRUE);
 
305
        mount->setCheck(mount_warn);
 
306
        show_mount->setCheck(mount_messages);
 
307
#endif
 
308
 
 
309
        FXbool root_warn=getApp()->reg().readUnsignedEntry("OPTIONS","root_warn",TRUE);
 
310
        if(getuid()) // Simple user
 
311
        root_warning->disable();
 
312
    else
 
313
        root_warning->setCheck(root_warn);
 
314
 
 
315
        // Third tab - Programs
 
316
    new FXTabItem(tabbook,_("&Programs"),NULL);
 
317
    FXVerticalFrame *programs=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
318
    group=new FXGroupBox(programs,_("Default programs"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
319
    matrix = new FXMatrix(group,3,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
320
 
 
321
    new FXLabel(matrix,_("Text editor:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
322
    txteditor = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
323
    new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_TXTEDIT,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
324
    oldtxteditor=getApp()->reg().readStringEntry("PROGS","txteditor",DEFAULT_TXTEDITOR);
 
325
    txteditor->setText(oldtxteditor);
 
326
 
 
327
        new FXLabel(matrix,_("Text viewer:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
328
    txtviewer = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
329
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_TXTVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
330
    oldtxtviewer=getApp()->reg().readStringEntry("PROGS","txtviewer",DEFAULT_TXTVIEWER);
 
331
    txtviewer->setText(oldtxtviewer);
 
332
 
 
333
        new FXLabel(matrix,_("Image editor:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
334
    imgeditor = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
335
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_IMGVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
336
    oldimgeditor=getApp()->reg().readStringEntry("PROGS","imgeditor",DEFAULT_IMGEDITOR);
 
337
    imgeditor->setText(oldimgeditor);
 
338
 
 
339
        new FXLabel(matrix,_("Image viewer:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
340
    imgviewer = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
341
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_IMGVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
342
    oldimgviewer=getApp()->reg().readStringEntry("PROGS","imgviewer",DEFAULT_IMGVIEWER);
 
343
    imgviewer->setText(oldimgviewer);
 
344
 
 
345
        new FXLabel(matrix,_("Archiver:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
346
    archiver = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
347
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_ARCHIVER,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
348
    oldarchiver=getApp()->reg().readStringEntry("PROGS","archiver",DEFAULT_ARCHIVER);
 
349
    archiver->setText(oldarchiver);
 
350
 
 
351
        new FXLabel(matrix,_("Pdf viewer:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
352
    pdfviewer = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
353
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_PDFVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
354
    oldpdfviewer=getApp()->reg().readStringEntry("PROGS","pdfviewer",DEFAULT_PDFVIEWER);
 
355
    pdfviewer->setText(oldpdfviewer);
 
356
 
 
357
        new FXLabel(matrix,_("Audio player:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
358
    audioviewer = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
359
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_AUDIOVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
360
    oldaudioviewer=getApp()->reg().readStringEntry("PROGS","audioviewer",DEFAULT_AUDIOVIEWER);
 
361
    audioviewer->setText(oldaudioviewer);
 
362
 
 
363
        new FXLabel(matrix,_("Video player:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
364
    videoviewer = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
365
        new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_VIDEOVIEW,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
366
    oldvideoviewer=getApp()->reg().readStringEntry("PROGS","videoviewer",DEFAULT_VIDEOVIEWER);
 
367
    videoviewer->setText(oldvideoviewer);
 
368
 
 
369
        new FXLabel(matrix,_("Terminal:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
370
    xterm = new FXTextField(matrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
371
    new FXButton(matrix,_("\tSelect file..."),filedialogicon,this,ID_BROWSE_XTERM,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
372
    oldxterm=getApp()->reg().readStringEntry("PROGS","xterm",DEFAULT_TERMINAL);
 
373
    xterm->setText(oldxterm);
 
374
 
 
375
        // Fourth tab - Visual
 
376
    new FXTabItem(tabbook,_("&Themes"),NULL);
 
377
    FXVerticalFrame *visual=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
378
    FXGroupBox *themes=new FXGroupBox(visual,_("Color theme"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
379
    FXPacker *pack = new FXPacker(themes,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_Y|LAYOUT_FILL_X,0,0,0,0, 0,0,0,0);
 
380
    themesList = new FXList(pack,this,ID_THEME,LIST_BROWSESELECT|FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
381
    themesList->setNumVisible(7);
 
382
        for(int i=0;i<NUM_THEMES;i++)
 
383
        themesList->appendItem(Themes[i].name);
 
384
    themesList->setCurrentItem(0);
 
385
 
 
386
    FXGroupBox *colors=new FXGroupBox(visual,_("Custom colors"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
 
387
        FXMatrix *matrix3 = new FXMatrix(colors,2,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
388
    colorsBox = new FXComboBox(matrix3,NUM_COLORS,NULL,0,COMBOBOX_STATIC|FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_SIDE_RIGHT|LAYOUT_CENTER_Y);
 
389
        colorsBox->setNumVisible(NUM_COLORS);
 
390
        cwell=new FXColorWell(matrix3,FXRGB(0,0,0),this,ID_COLOR,LAYOUT_FILL_X|LAYOUT_FILL_COLUMN|LAYOUT_FILL_Y,0,0,0,0, 10,10,0,0);
 
391
        cwell->setTipText(_("Double click to customize the color"));
 
392
 
 
393
    colorsBox->appendItem(_("Base color"));
 
394
    colorsBox->appendItem(_("Border color"));
 
395
    colorsBox->appendItem(_("Background color"));
 
396
    colorsBox->appendItem(_("Text color"));
 
397
    colorsBox->appendItem(_("Selection background color"));
 
398
    colorsBox->appendItem(_("Selection text color"));
 
399
    colorsBox->appendItem(_("File list background color"));
 
400
    colorsBox->appendItem(_("File list text color"));
 
401
        colorsBox->appendItem(_("File list highlight color"));
 
402
        colorsBox->appendItem(_("Progress bar color"));
 
403
        colorsBox->appendItem(_("Attention color"));
 
404
    colorsBox->setCurrentItem(0);
 
405
 
 
406
        // Controls theme
 
407
        FXGroupBox *button=new FXGroupBox(visual,_("Controls"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
408
        use_clearlooks=getApp()->reg().readUnsignedEntry("SETTINGS","use_clearlooks",TRUE);
 
409
        new FXRadioButton(button,_("Standard (classic controls)"),this,ID_STANDARD_CONTROLS);
 
410
        new FXRadioButton(button,_("Clearlooks (modern looking controls)"),this,ID_CLEARLOOKS_CONTROLS);
 
411
 
 
412
        // Find iconpath from the Xfe registry settings or set it to DEFAULTICONPATH
 
413
        FXGroupBox *group2=new FXGroupBox(visual,_("Icon theme path"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X);
 
414
        FXMatrix *matrix2 = new FXMatrix(group2,2,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
415
        iconpath = new FXTextField(matrix2,40,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
416
    new FXButton(matrix2,_("\tSelect path..."),filedialogicon,this,ID_BROWSE_ICON_PATH,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y,0,0,0,0,20,20);
 
417
        oldiconpath=getApp()->reg().readStringEntry("SETTINGS","iconpath",DEFAULTICONPATH);
 
418
    iconpath->setText(oldiconpath);
 
419
 
 
420
    // Fifth tab - Fonts
 
421
    new FXTabItem(tabbook,_("&Fonts"),NULL);
 
422
    FXVerticalFrame *fonts=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
423
    FXGroupBox *fgroup=new FXGroupBox(fonts,_("Fonts"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
424
 
 
425
    FXMatrix *fmatrix = new FXMatrix(fgroup,3,MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
426
    new FXLabel(fmatrix,_("Normal font:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
427
    normalfont = new FXTextField(fmatrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
428
    new FXButton(fmatrix,_(" Select..."),NULL,this,ID_NORMALFONT,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y);//,0,0,0,0,20,20);
 
429
    oldnormalfont=getApp()->reg().readStringEntry("SETTINGS","font","Helvetica,100,normal,regular");
 
430
    normalfont->setText(oldnormalfont);
 
431
 
 
432
    new FXLabel(fmatrix,_("Text font:"),NULL,JUSTIFY_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
 
433
    textfont = new FXTextField(fmatrix,30,NULL,0,FRAME_THICK|FRAME_SUNKEN|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW|LAYOUT_FILL_X);
 
434
        new FXButton(fmatrix,_(" Select..."),NULL,this,ID_TEXTFONT,FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y);//0,0,0,0,20,20);
 
435
    oldtextfont=getApp()->reg().readStringEntry("SETTINGS","textfont","Helvetica,100,normal,regular");
 
436
    textfont->setText(oldtextfont);
 
437
 
 
438
    // Sixth tab - Key bindings
 
439
    new FXTabItem(tabbook,_("&Key Bindings"),NULL);
 
440
    FXVerticalFrame *keybindings=new FXVerticalFrame(tabbook,FRAME_THICK|FRAME_RAISED);
 
441
    FXGroupBox *kbgroup=new FXGroupBox(keybindings,_("Key Bindings"),GROUPBOX_TITLE_LEFT|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y);
 
442
 
 
443
    FXPacker *kbpack = new FXPacker(kbgroup,LAYOUT_FILL_X);
 
444
    new FXButton(kbpack,_("Modify key bindings..."),minikeybindingsicon,this,ID_CHANGE_KEYBINDINGS,FRAME_RAISED|FRAME_THICK|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP|LAYOUT_FILL_X);//,0,0,0,0,20,20);
 
445
    new FXButton(kbpack,_("Restore default key bindings..."),reloadicon,this,ID_RESTORE_KEYBINDINGS,FRAME_RAISED|FRAME_THICK|ICON_BEFORE_TEXT|LAYOUT_SIDE_TOP|LAYOUT_FILL_X);//,0,0,0,0,20,20);
 
446
        
 
447
        // Initializations
 
448
        bindingsbox=NULL;
 
449
        glbBindingsDict=NULL;
 
450
        xfeBindingsDict=NULL;
 
451
        xfiBindingsDict=NULL;
 
452
        xfwBindingsDict=NULL;
 
453
}
 
454
 
 
455
 
 
456
long PreferencesBox::onUpdColor(FXObject* o,FXSelector s,void* p)
 
457
{
 
458
    FXColorWell *cwell = (FXColorWell*)o;
 
459
    int i = colorsBox->getCurrentItem();
 
460
    cwell->setRGBA(currTheme.color[i]);
 
461
 
 
462
    return 1;
 
463
}
 
464
 
 
465
 
 
466
long PreferencesBox::onCmdColor(FXObject* o,FXSelector s,void* p)
 
467
{
 
468
        FXColorWell *cwell = (FXColorWell*)o;
 
469
    int i = colorsBox->getCurrentItem();
 
470
    currTheme.color[i] = cwell->getRGBA();
 
471
    
 
472
    return 1;
 
473
}
 
474
 
 
475
 
 
476
long PreferencesBox::onCmdTheme(FXObject* o,FXSelector s,void* p)
 
477
{
 
478
    currTheme = Themes[themesList->getCurrentItem()];
 
479
    return 1;
 
480
}
 
481
 
 
482
 
 
483
long PreferencesBox::onCmdBrowsePath(FXObject* o,FXSelector s,void* p)
 
484
{
 
485
        FileDialog browse(this,_("Select an icon theme folder or an icon file"));
 
486
        browse.setSelectMode(SELECT_FILE_MIXED);
 
487
        browse.setDirectory(iconpath->getText());
 
488
        if(browse.execute())
 
489
        {
 
490
                FXString path=browse.getFilename();
 
491
                if (::isFile(path))
 
492
                        iconpath->setText(FXPath::directory(path).text());
 
493
                else
 
494
                        iconpath->setText(path);
 
495
        }
 
496
        return 1;
 
497
}
 
498
 
 
499
 
 
500
long PreferencesBox::onCmdBrowse(FXObject* o,FXSelector s,void* p)
 
501
{
 
502
    FileDialog browse(this,_("Select an executable file"));
 
503
    const FXchar *patterns[]=
 
504
        {
 
505
            _("All files"),     "*",NULL
 
506
        };
 
507
        browse.setFilename(ROOTDIR);
 
508
        browse.setPatternList(patterns);
 
509
        browse.setSelectMode(SELECT_FILE_EXISTING);
 
510
    if(browse.execute())
 
511
    {
 
512
                FXString path=browse.getFilename();
 
513
                
 
514
                switch(FXSELID(s))
 
515
        {
 
516
        case ID_BROWSE_TXTEDIT:
 
517
            txteditor->setText(FXPath::name(path));
 
518
            break;
 
519
        case ID_BROWSE_TXTVIEW:
 
520
            txtviewer->setText(FXPath::name(path));
 
521
            break;
 
522
        case ID_BROWSE_IMGVIEW:
 
523
            imgviewer->setText(FXPath::name(path));
 
524
            break;
 
525
        case ID_BROWSE_ARCHIVER:
 
526
            archiver->setText(FXPath::name(path));
 
527
            break;
 
528
        case ID_BROWSE_PDFVIEW:
 
529
            pdfviewer->setText(FXPath::name(path));
 
530
            break;
 
531
        case ID_BROWSE_AUDIOVIEW:
 
532
            audioviewer->setText(FXPath::name(path));
 
533
            break;
 
534
        case ID_BROWSE_VIDEOVIEW:
 
535
            videoviewer->setText(FXPath::name(path));
 
536
            break;
 
537
        case ID_BROWSE_XTERM:
 
538
            xterm->setText(FXPath::name(path));
 
539
            break;
 
540
        }
 
541
    }
 
542
    return 1;
 
543
}
 
544
 
 
545
// Change normal font
 
546
long PreferencesBox::onCmdNormalFont(FXObject*,FXSelector,void*)
 
547
{
 
548
    FontDialog fontdlg(this,_("Change Normal Font"),DECOR_BORDER|DECOR_TITLE);
 
549
    FXFontDesc fontdesc;
 
550
        FXString fontspec;
 
551
 
 
552
        fontspec=getApp()->reg().readStringEntry("SETTINGS","font","Helvetica,100,normal,regular");
 
553
        FXFont* nfont=new FXFont(getApp(),fontspec);
 
554
        nfont->create();
 
555
        nfont->getFontDesc(fontdesc);
 
556
    
 
557
        fontdlg.setFontSelection(fontdesc);
 
558
    if(fontdlg.execute())
 
559
    {
 
560
        fontdlg.getFontSelection(fontdesc);
 
561
                nfont->setFontDesc(fontdesc);
 
562
                fontspec=nfont->getFont();
 
563
        normalfont->setText(fontspec);  
 
564
    }
 
565
    return 1;
 
566
}
 
567
 
 
568
// Change text font
 
569
long PreferencesBox::onCmdTextFont(FXObject*,FXSelector,void*)
 
570
{
 
571
    FontDialog fontdlg(this,_("Change Text Font"),DECOR_BORDER|DECOR_TITLE);
 
572
    FXFontDesc fontdesc;
 
573
        FXString fontspec;
 
574
        fontspec=getApp()->reg().readStringEntry("SETTINGS","textfont","Helvetica,100,normal,regular");
 
575
        FXFont* tfont=new FXFont(getApp(),fontspec);
 
576
        tfont->create();
 
577
        tfont->getFontDesc(fontdesc);
 
578
    fontdlg.setFontSelection(fontdesc);
 
579
    if(fontdlg.execute())
 
580
    {
 
581
        fontdlg.getFontSelection(fontdesc);
 
582
                tfont->setFontDesc(fontdesc);
 
583
                fontspec=tfont->getFont();
 
584
        textfont->setText(fontspec);
 
585
    }
 
586
    return 1;
 
587
}
 
588
 
 
589
 
 
590
// Change key bindings
 
591
long PreferencesBox::onCmdChangeKeyBindings(FXObject*,FXSelector,void*)
 
592
{
 
593
        FXString key, str;
 
594
 
 
595
    // String dictionary used to store global key bindings 
 
596
        if (glbBindingsDict==NULL)
 
597
                glbBindingsDict=new FXStringDict();
 
598
 
 
599
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_back","Ctrl-Backspace");
 
600
        str=_("Go to previous directory")+TAB+key;
 
601
        glbBindingsDict->insert("go_back",str.text());
 
602
        
 
603
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_forward","Shift-Backspace");
 
604
        str=_("Go to next directory")+TAB+key;
 
605
        glbBindingsDict->insert("go_forward",str.text());
 
606
 
 
607
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_up","Backspace");
 
608
        str=_("Go to parent directory")+TAB+key;
 
609
        glbBindingsDict->insert("go_up",str.text());
 
610
        
 
611
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_home","Ctrl-H");
 
612
        str=_("Go to home directory")+TAB+key;
 
613
        glbBindingsDict->insert("go_home",str.text());
 
614
 
 
615
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new_file","F2");
 
616
        str=_("Create new file")+TAB+key;
 
617
        glbBindingsDict->insert("new_file",str.text());
 
618
 
 
619
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new_folder","F7");
 
620
        str=_("Create new folder")+TAB+key;
 
621
        glbBindingsDict->insert("new_folder",str.text());
 
622
 
 
623
        key=getApp()->reg().readStringEntry("KEYBINDINGS","copy","Ctrl-C");
 
624
        str=_("Copy to clipboard")+TAB+key;
 
625
        glbBindingsDict->insert("copy",str.text());
 
626
 
 
627
        key=getApp()->reg().readStringEntry("KEYBINDINGS","cut","Ctrl-X");
 
628
        str=_("Cut to clipboard")+TAB+key;
 
629
        glbBindingsDict->insert("cut",str.text());
 
630
 
 
631
        key=getApp()->reg().readStringEntry("KEYBINDINGS","paste","Ctrl-V");
 
632
        str=_("Paste from clipboard")+TAB+key;
 
633
        glbBindingsDict->insert("paste",str.text());
 
634
 
 
635
        key=getApp()->reg().readStringEntry("KEYBINDINGS","big_icons","F10");
 
636
        str=_("Big icon list")+TAB+key;
 
637
        glbBindingsDict->insert("big_icons",str.text());
 
638
 
 
639
        key=getApp()->reg().readStringEntry("KEYBINDINGS","small_icons","F11");
 
640
        str=_("Small icon list")+TAB+key;
 
641
        glbBindingsDict->insert("small_icons",str.text());
 
642
 
 
643
        key=getApp()->reg().readStringEntry("KEYBINDINGS","detailed_file_list","F12");
 
644
        str=_("Detailed file list")+TAB+key;
 
645
        glbBindingsDict->insert("detailed_file_list",str.text());
 
646
 
 
647
        key=getApp()->reg().readStringEntry("KEYBINDINGS","open","Ctrl-O");
 
648
        str=_("Open file")+TAB+key;
 
649
        glbBindingsDict->insert("open",str.text());
 
650
 
 
651
        key=getApp()->reg().readStringEntry("KEYBINDINGS","quit","Ctrl-Q");
 
652
        str=_("Quit application")+TAB+key;
 
653
        glbBindingsDict->insert("quit",str.text());
 
654
 
 
655
        key=getApp()->reg().readStringEntry("KEYBINDINGS","select_all","Ctrl-A");
 
656
        str=_("Select all")+TAB+key;
 
657
        glbBindingsDict->insert("select_all",str.text());
 
658
 
 
659
        key=getApp()->reg().readStringEntry("KEYBINDINGS","deselect_all","Ctrl-Z");
 
660
        str=_("Deselect all")+TAB+key;
 
661
        glbBindingsDict->insert("deselect_all",str.text());
 
662
 
 
663
        key=getApp()->reg().readStringEntry("KEYBINDINGS","invert_selection","Ctrl-I");
 
664
        str=_("Invert selection")+TAB+key;
 
665
        glbBindingsDict->insert("invert_selection",str.text());
 
666
 
 
667
        key=getApp()->reg().readStringEntry("KEYBINDINGS","help","F1");
 
668
        str=_("Display help")+TAB+key;
 
669
        glbBindingsDict->insert("help",str.text());
 
670
 
 
671
        key=getApp()->reg().readStringEntry("KEYBINDINGS","hidden_files","Ctrl-F6");
 
672
        str=_("Toggle display hidden files")+TAB+key;
 
673
        glbBindingsDict->insert("hidden_files",str.text());
 
674
 
 
675
        key=getApp()->reg().readStringEntry("KEYBINDINGS","thumbnails","Ctrl-F7");
 
676
        str=_("Toggle display thumbnails")+TAB+key;
 
677
        glbBindingsDict->insert("thumbnails",str.text());
 
678
 
 
679
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_work","Shift-F2");
 
680
        str=_("Go to working directory")+TAB+key;
 
681
        glbBindingsDict->insert("go_work",str.text());
 
682
 
 
683
        key=getApp()->reg().readStringEntry("KEYBINDINGS","close","Ctrl-W");
 
684
        str=_("Close window")+TAB+key;
 
685
        glbBindingsDict->insert("close",str.text());
 
686
 
 
687
        key=getApp()->reg().readStringEntry("KEYBINDINGS","print","Ctrl-P");
 
688
        str=_("Print file")+TAB+key;
 
689
        glbBindingsDict->insert("print",str.text());
 
690
 
 
691
        key=getApp()->reg().readStringEntry("KEYBINDINGS","search","Ctrl-F");
 
692
        str=_("Search")+TAB+key;
 
693
        glbBindingsDict->insert("search",str.text());
 
694
 
 
695
        key=getApp()->reg().readStringEntry("KEYBINDINGS","search_prev","Shift-Ctrl-G");
 
696
        str=_("Search previous")+TAB+key;
 
697
        glbBindingsDict->insert("search_prev",str.text());
 
698
 
 
699
        key=getApp()->reg().readStringEntry("KEYBINDINGS","search_next","Ctrl-G");
 
700
        str=_("Search next")+TAB+key;
 
701
        glbBindingsDict->insert("search_next",str.text());
 
702
 
 
703
 
 
704
    // Key bindings specific to X File Explorer (Xfe)
 
705
        if (xfeBindingsDict==NULL)
 
706
                xfeBindingsDict=new FXStringDict();
 
707
 
 
708
        key=getApp()->reg().readStringEntry("KEYBINDINGS","refresh","Ctrl-R");
 
709
        str=_("Refresh panels")+TAB+key;
 
710
        xfeBindingsDict->insert("refresh",str.text());
 
711
 
 
712
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new_symlink","Ctrl-J");
 
713
        str=_("Create new symbolic link")+TAB+key;
 
714
        xfeBindingsDict->insert("new_symlink",str.text());
 
715
 
 
716
        key=getApp()->reg().readStringEntry("KEYBINDINGS","properties","F9");
 
717
        str=_("File properties")+TAB+key;
 
718
        xfeBindingsDict->insert("properties",str.text());
 
719
 
 
720
        key=getApp()->reg().readStringEntry("KEYBINDINGS","move_to_trash","Del");
 
721
        str=_("Move files to trash")+TAB+key;
 
722
        xfeBindingsDict->insert("move_to_trash",str.text());
 
723
 
 
724
        key=getApp()->reg().readStringEntry("KEYBINDINGS","restore_from_trash","Alt-Del");
 
725
        str=_("Restore files from trash")+TAB+key;
 
726
        xfeBindingsDict->insert("restore_from_trash",str.text());
 
727
 
 
728
        key=getApp()->reg().readStringEntry("KEYBINDINGS","delete","Shift-Del");
 
729
        str=_("Delete files")+TAB+key;
 
730
        xfeBindingsDict->insert("delete",str.text());
 
731
 
 
732
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new_window","F3");
 
733
        str=_("Create new window")+TAB+key;
 
734
        xfeBindingsDict->insert("new_window",str.text());
 
735
 
 
736
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new_root_window","Shift-F3");
 
737
        str=_("Create new root window")+TAB+key;
 
738
        xfeBindingsDict->insert("new_root_window",str.text());
 
739
 
 
740
        key=getApp()->reg().readStringEntry("KEYBINDINGS","execute_command","Ctrl-E");
 
741
        str=_("Execute command")+TAB+key;
 
742
        xfeBindingsDict->insert("execute_command",str.text());
 
743
 
 
744
        key=getApp()->reg().readStringEntry("KEYBINDINGS","terminal","Ctrl-T");
 
745
        str=_("Launch terminal")+TAB+key;
 
746
        xfeBindingsDict->insert("terminal",str.text());
 
747
 
 
748
#if defined(linux)
 
749
        key=getApp()->reg().readStringEntry("KEYBINDINGS","mount","Ctrl-M");
 
750
        str=_("Mount file system (Linux only)")+TAB+key;
 
751
        xfeBindingsDict->insert("mount",str.text());
 
752
 
 
753
        key=getApp()->reg().readStringEntry("KEYBINDINGS","unmount","Ctrl-U");
 
754
        str=_("Unmount file system (Linux only)")+TAB+key;
 
755
        xfeBindingsDict->insert("unmount",str.text());
 
756
 
 
757
#endif
 
758
        key=getApp()->reg().readStringEntry("KEYBINDINGS","one_panel","Ctrl-F1");
 
759
        str=_("One panel mode")+TAB+key;
 
760
        xfeBindingsDict->insert("one_panel",str.text());
 
761
 
 
762
        key=getApp()->reg().readStringEntry("KEYBINDINGS","tree_panel","Ctrl-F2");
 
763
        str=_("Tree and panel mode")+TAB+key;
 
764
        xfeBindingsDict->insert("tree_panel",str.text());
 
765
 
 
766
        key=getApp()->reg().readStringEntry("KEYBINDINGS","two_panels","Ctrl-F3");
 
767
        str=_("Two panels mode")+TAB+key;
 
768
        xfeBindingsDict->insert("two_panels",str.text());
 
769
 
 
770
        key=getApp()->reg().readStringEntry("KEYBINDINGS","tree_two_panels","Ctrl-F4");
 
771
        str=_("Tree and two panels mode")+TAB+key;
 
772
        xfeBindingsDict->insert("tree_two_panels",str.text());
 
773
 
 
774
        key=getApp()->reg().readStringEntry("KEYBINDINGS","clear_location","Ctrl-L");
 
775
        str=_("Clear location bar")+TAB+key;
 
776
        xfeBindingsDict->insert("clear_location",str.text());
 
777
 
 
778
        key=getApp()->reg().readStringEntry("KEYBINDINGS","rename","Ctrl-N");
 
779
        str=_("Rename file")+TAB+key;
 
780
        xfeBindingsDict->insert("rename",str.text());
 
781
 
 
782
        key=getApp()->reg().readStringEntry("KEYBINDINGS","copy_to","F5");
 
783
        str=_("Copy files to location")+TAB+key;
 
784
        xfeBindingsDict->insert("copy_to",str.text());
 
785
 
 
786
        key=getApp()->reg().readStringEntry("KEYBINDINGS","move_to","F6");
 
787
        str=_("Move files to location")+TAB+key;
 
788
        xfeBindingsDict->insert("move_to",str.text());
 
789
 
 
790
        key=getApp()->reg().readStringEntry("KEYBINDINGS","symlink_to","Ctrl-S");
 
791
        str=_("Symlink files to location")+TAB+key;
 
792
        xfeBindingsDict->insert("symlink_to",str.text());
 
793
 
 
794
        key=getApp()->reg().readStringEntry("KEYBINDINGS","add_bookmark","Ctrl-B");
 
795
        str=_("Add bookmark")+TAB+key;
 
796
        xfeBindingsDict->insert("add_bookmark",str.text());
 
797
 
 
798
        key=getApp()->reg().readStringEntry("KEYBINDINGS","synchronize_panels","Ctrl-Y");
 
799
        str=_("Synchronize panels")+TAB+key;
 
800
        xfeBindingsDict->insert("synchronize_panels",str.text());
 
801
 
 
802
        key=getApp()->reg().readStringEntry("KEYBINDINGS","switch_panels","Ctrl-K");
 
803
        str=_("Switch panels")+TAB+key;
 
804
        xfeBindingsDict->insert("switch_panels",str.text());
 
805
 
 
806
        key=getApp()->reg().readStringEntry("KEYBINDINGS","go_to_trash","Ctrl-F8");
 
807
        str=_("Go to trash can")+TAB+key;
 
808
        xfeBindingsDict->insert("go_to_trash",str.text());
 
809
 
 
810
        key=getApp()->reg().readStringEntry("KEYBINDINGS","empty_trash_can","Ctrl-Del");
 
811
        str=_("Empty trash can")+TAB+key;
 
812
        xfeBindingsDict->insert("empty_trash_can",str.text());
 
813
 
 
814
        key=getApp()->reg().readStringEntry("KEYBINDINGS","view","Shift-F4");
 
815
        str=_("View")+TAB+key;
 
816
        xfeBindingsDict->insert("view",str.text());
 
817
 
 
818
        key=getApp()->reg().readStringEntry("KEYBINDINGS","edit","F4");
 
819
        str=_("Edit")+TAB+key;
 
820
        xfeBindingsDict->insert("edit",str.text());
 
821
 
 
822
        key=getApp()->reg().readStringEntry("KEYBINDINGS","hidden_dirs","Ctrl-F5");
 
823
        str=_("Toggle display hidden directories")+TAB+key;
 
824
        xfeBindingsDict->insert("hidden_dirs",str.text());
 
825
 
 
826
        key=getApp()->reg().readStringEntry("KEYBINDINGS","filter","Ctrl-D");
 
827
        str=_("Filter files")+TAB+key;
 
828
        xfeBindingsDict->insert("filter",str.text());
 
829
 
 
830
 
 
831
        // Key bindings specific to X File Image (Xfi)
 
832
        if (xfiBindingsDict==NULL)
 
833
                xfiBindingsDict=new FXStringDict();
 
834
 
 
835
        key=getApp()->reg().readStringEntry("KEYBINDINGS","zoom_100","Ctrl-I");
 
836
        str=_("Zoom image to 100%")+TAB+key;
 
837
        xfiBindingsDict->insert("zoom_100",str.text());
 
838
 
 
839
        key=getApp()->reg().readStringEntry("KEYBINDINGS","zoom_win","Ctrl-F");
 
840
        str=_("Zoom to fit window")+TAB+key;
 
841
        xfiBindingsDict->insert("zoom_win",str.text());
 
842
 
 
843
        key=getApp()->reg().readStringEntry("KEYBINDINGS","rotate_left","Ctrl-L");
 
844
        str=_("Rotate image to left")+TAB+key;
 
845
        xfiBindingsDict->insert("rotate_left",str.text());
 
846
 
 
847
        key=getApp()->reg().readStringEntry("KEYBINDINGS","rotate_right","Ctrl-R");
 
848
        str=_("Rotate image to right")+TAB+key;
 
849
        xfiBindingsDict->insert("rotate_right",str.text());
 
850
 
 
851
        key=getApp()->reg().readStringEntry("KEYBINDINGS","mirror_horizontally","Ctrl-H");
 
852
        str=_("Mirror image horizontally")+TAB+key;
 
853
        xfiBindingsDict->insert("mirror_horizontally",str.text());
 
854
 
 
855
        key=getApp()->reg().readStringEntry("KEYBINDINGS","mirror_vertically","Ctrl-V");
 
856
        str=_("Mirror image vertically")+TAB+key;
 
857
        xfiBindingsDict->insert("mirror_vertically",str.text());
 
858
 
 
859
 
 
860
        // Key bindings specific to X File Write (Xfw)
 
861
        if (xfwBindingsDict==NULL)
 
862
                xfwBindingsDict=new FXStringDict();
 
863
 
 
864
        key=getApp()->reg().readStringEntry("KEYBINDINGS","new","Ctrl-N");
 
865
        str=_("Create new document")+TAB+key;
 
866
        xfwBindingsDict->insert("new",str.text());
 
867
 
 
868
        key=getApp()->reg().readStringEntry("KEYBINDINGS","save","Ctrl-S");
 
869
        str=_("Save changes to file")+TAB+key;
 
870
        xfwBindingsDict->insert("save",str.text());
 
871
 
 
872
        key=getApp()->reg().readStringEntry("KEYBINDINGS","goto_line","Ctrl-L");
 
873
        str=_("Goto line")+TAB+key;
 
874
        xfwBindingsDict->insert("goto_line",str.text());
 
875
 
 
876
        key=getApp()->reg().readStringEntry("KEYBINDINGS","undo","Ctrl-Z");
 
877
        str=_("Undo last change")+TAB+key;
 
878
        xfwBindingsDict->insert("undo",str.text());
 
879
 
 
880
        key=getApp()->reg().readStringEntry("KEYBINDINGS","redo","Ctrl-Y");
 
881
        str=_("Redo last change")+TAB+key;
 
882
        xfwBindingsDict->insert("redo",str.text());
 
883
 
 
884
        key=getApp()->reg().readStringEntry("KEYBINDINGS","replace","Ctrl-R");
 
885
        str=_("Replace string")+TAB+key;
 
886
        xfwBindingsDict->insert("replace",str.text());
 
887
 
 
888
        key=getApp()->reg().readStringEntry("KEYBINDINGS","word_wrap","Ctrl-K");
 
889
        str=_("Toggle word wrap mode")+TAB+key;
 
890
        xfwBindingsDict->insert("word_wrap",str.text());
 
891
 
 
892
        key=getApp()->reg().readStringEntry("KEYBINDINGS","line_numbers","Ctrl-T");
 
893
        str=_("Toggle line numbers mode")+TAB+key;
 
894
        xfwBindingsDict->insert("line_numbers",str.text());
 
895
 
 
896
        key=getApp()->reg().readStringEntry("KEYBINDINGS","lower_case","Ctrl-U");
 
897
        str=_("Toggle lower case mode")+TAB+key;
 
898
        xfwBindingsDict->insert("lower_case",str.text());
 
899
 
 
900
        key=getApp()->reg().readStringEntry("KEYBINDINGS","upper_case","Shift-Ctrl-U");
 
901
        str=_("Toggle upper case mode")+TAB+key;
 
902
        xfwBindingsDict->insert("upper_case",str.text());
 
903
 
 
904
        // Display the key bindings dialog box
 
905
        if (bindingsbox==NULL)
 
906
                bindingsbox=new KeybindingsBox(this,glbBindingsDict,xfeBindingsDict,xfiBindingsDict,xfwBindingsDict);   
 
907
    
 
908
        bindingsbox->execute(PLACEMENT_SCREEN);
 
909
        
 
910
    return 1;
 
911
}
 
912
 
 
913
 
 
914
// Restore default key bindings
 
915
long PreferencesBox::onCmdRestoreKeyBindings(FXObject*,FXSelector,void*)
 
916
{
 
917
    // Confirmation message
 
918
        FXString message=_("Do you really want to restore the default key bindings?\n\nAll your customizations will be lost!");
 
919
    MessageBox box(this,_("Restore default key bindings"),message,keybindingsicon,BOX_OK_CANCEL|DECOR_TITLE|DECOR_BORDER);
 
920
        if(box.execute(PLACEMENT_CURSOR) != BOX_CLICKED_OK)
 
921
        return 0;
 
922
 
 
923
        // Write default key bindings to the registry
 
924
        
 
925
        // Global key bindings
 
926
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_back","Ctrl-Backspace");
 
927
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_forward","Shift-Backspace");
 
928
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_up","Backspace");
 
929
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_home","Ctrl-H");
 
930
        getApp()->reg().writeStringEntry("KEYBINDINGS","new_file","F2");
 
931
        getApp()->reg().writeStringEntry("KEYBINDINGS","new_folder","F7");
 
932
        getApp()->reg().writeStringEntry("KEYBINDINGS","copy","Ctrl-C");
 
933
        getApp()->reg().writeStringEntry("KEYBINDINGS","cut","Ctrl-X");
 
934
        getApp()->reg().writeStringEntry("KEYBINDINGS","paste","Ctrl-V");
 
935
        getApp()->reg().writeStringEntry("KEYBINDINGS","big_icons","F10");
 
936
        getApp()->reg().writeStringEntry("KEYBINDINGS","small_icons","F11");
 
937
        getApp()->reg().writeStringEntry("KEYBINDINGS","detailed_file_list","F12");
 
938
        getApp()->reg().writeStringEntry("KEYBINDINGS","open","Ctrl-O");
 
939
        getApp()->reg().writeStringEntry("KEYBINDINGS","quit","Ctrl-Q");
 
940
        getApp()->reg().writeStringEntry("KEYBINDINGS","select_all","Ctrl-A");
 
941
        getApp()->reg().writeStringEntry("KEYBINDINGS","deselect_all","Ctrl-Z");
 
942
        getApp()->reg().writeStringEntry("KEYBINDINGS","invert_selection","Ctrl-I");
 
943
        getApp()->reg().writeStringEntry("KEYBINDINGS","help","F1");
 
944
        getApp()->reg().writeStringEntry("KEYBINDINGS","hidden_files","Ctrl-F6");
 
945
        getApp()->reg().writeStringEntry("KEYBINDINGS","thumbnails","Ctrl-F7");
 
946
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_work","Shift-F2");
 
947
        getApp()->reg().writeStringEntry("KEYBINDINGS","close","Ctrl-W");
 
948
        getApp()->reg().writeStringEntry("KEYBINDINGS","print","Ctrl-P");
 
949
        getApp()->reg().writeStringEntry("KEYBINDINGS","search","Ctrl-F");
 
950
        getApp()->reg().writeStringEntry("KEYBINDINGS","search_prev","Shift-Ctrl-G");
 
951
        getApp()->reg().writeStringEntry("KEYBINDINGS","search_next","Ctrl-G");
 
952
        
 
953
        // Key bindings specific to X File Explorer (Xfe)
 
954
        getApp()->reg().writeStringEntry("KEYBINDINGS","refresh","Ctrl-R");
 
955
        getApp()->reg().writeStringEntry("KEYBINDINGS","new_symlink","Ctrl-J");
 
956
        getApp()->reg().writeStringEntry("KEYBINDINGS","properties","F9");
 
957
        getApp()->reg().writeStringEntry("KEYBINDINGS","move_to_trash","Del");
 
958
        getApp()->reg().writeStringEntry("KEYBINDINGS","restore_from_trash","Alt-Del");
 
959
        getApp()->reg().writeStringEntry("KEYBINDINGS","delete","Shift-Del");
 
960
        getApp()->reg().writeStringEntry("KEYBINDINGS","new_window","F3");
 
961
        getApp()->reg().writeStringEntry("KEYBINDINGS","new_root_window","Shift-F3");
 
962
        getApp()->reg().writeStringEntry("KEYBINDINGS","execute_command","Ctrl-E");
 
963
        getApp()->reg().writeStringEntry("KEYBINDINGS","terminal","Ctrl-T");
 
964
#if defined(linux)
 
965
        getApp()->reg().writeStringEntry("KEYBINDINGS","mount","Ctrl-M");
 
966
        getApp()->reg().writeStringEntry("KEYBINDINGS","unmount","Ctrl-U");
 
967
#endif
 
968
        getApp()->reg().writeStringEntry("KEYBINDINGS","one_panel","Ctrl-F1");
 
969
        getApp()->reg().writeStringEntry("KEYBINDINGS","tree_panel","Ctrl-F2");
 
970
        getApp()->reg().writeStringEntry("KEYBINDINGS","two_panels","Ctrl-F3");
 
971
        getApp()->reg().writeStringEntry("KEYBINDINGS","tree_two_panels","Ctrl-F4");
 
972
        getApp()->reg().writeStringEntry("KEYBINDINGS","clear_location","Ctrl-L");
 
973
        getApp()->reg().writeStringEntry("KEYBINDINGS","rename","Ctrl-N");
 
974
        getApp()->reg().writeStringEntry("KEYBINDINGS","copy_to","F5");
 
975
        getApp()->reg().writeStringEntry("KEYBINDINGS","move_to","F6");
 
976
        getApp()->reg().writeStringEntry("KEYBINDINGS","symlink_to","Ctrl-S");
 
977
        getApp()->reg().writeStringEntry("KEYBINDINGS","add_bookmark","Ctrl-B");
 
978
        getApp()->reg().writeStringEntry("KEYBINDINGS","synchronize_panels","Ctrl-Y");
 
979
        getApp()->reg().writeStringEntry("KEYBINDINGS","switch_panels","Ctrl-K");
 
980
        getApp()->reg().writeStringEntry("KEYBINDINGS","go_to_trash","Ctrl-F8");
 
981
        getApp()->reg().writeStringEntry("KEYBINDINGS","empty_trash_can","Ctrl-Del");
 
982
        getApp()->reg().writeStringEntry("KEYBINDINGS","view","Shift-F4");
 
983
        getApp()->reg().writeStringEntry("KEYBINDINGS","edit","F4");
 
984
        getApp()->reg().writeStringEntry("KEYBINDINGS","hidden_dirs","Ctrl-F5");
 
985
        getApp()->reg().writeStringEntry("KEYBINDINGS","filter","Ctrl-D");
 
986
 
 
987
        // Key bindings specific to X File Image (Xfi)
 
988
        getApp()->reg().writeStringEntry("KEYBINDINGS","zoom_100","Ctrl-I");
 
989
        getApp()->reg().writeStringEntry("KEYBINDINGS","zoom_win","Ctrl-F");
 
990
        getApp()->reg().writeStringEntry("KEYBINDINGS","rotate_left","Ctrl-L");
 
991
        getApp()->reg().writeStringEntry("KEYBINDINGS","rotate_right","Ctrl-R");
 
992
        getApp()->reg().writeStringEntry("KEYBINDINGS","mirror_horizontally","Ctrl-H");
 
993
        getApp()->reg().writeStringEntry("KEYBINDINGS","mirror_vertically","Ctrl-V");
 
994
 
 
995
        // Key bindings specific to X File Write (Xfw)
 
996
        getApp()->reg().writeStringEntry("KEYBINDINGS","new","Ctrl-N");
 
997
        getApp()->reg().writeStringEntry("KEYBINDINGS","save","Ctrl-S");
 
998
        getApp()->reg().writeStringEntry("KEYBINDINGS","goto_line","Ctrl-L");
 
999
        getApp()->reg().writeStringEntry("KEYBINDINGS","undo","Ctrl-Z");
 
1000
        getApp()->reg().writeStringEntry("KEYBINDINGS","redo","Ctrl-Y");
 
1001
        getApp()->reg().writeStringEntry("KEYBINDINGS","replace","Ctrl-R");
 
1002
        getApp()->reg().writeStringEntry("KEYBINDINGS","word_wrap","Ctrl-K");
 
1003
        getApp()->reg().writeStringEntry("KEYBINDINGS","line_numbers","Ctrl-T");
 
1004
        getApp()->reg().writeStringEntry("KEYBINDINGS","lower_case","Ctrl-U");
 
1005
        getApp()->reg().writeStringEntry("KEYBINDINGS","upper_case","Shift-Ctrl-U");
 
1006
 
 
1007
        // Finally, update the registry
 
1008
        getApp()->reg().write();
 
1009
 
 
1010
        // Ask the user if he wants to restart Xfe
 
1011
        if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Key bindings will be changed after restart.\nRestart X File Explorer now?")))
 
1012
                mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1013
 
 
1014
    return 1;
 
1015
}
 
1016
 
 
1017
 
 
1018
long PreferencesBox::onCmdAccept(FXObject* o,FXSelector s,void* p)
 
1019
{
 
1020
    FXbool restart_theme=FALSE;
 
1021
    FXbool restart_scroll=FALSE;
 
1022
    FXbool restart_pathlink=FALSE;
 
1023
    FXbool restart_controls=FALSE;
 
1024
    FXbool restart_normalfont=FALSE;
 
1025
    FXbool restart_textfont=FALSE;
 
1026
        
 
1027
        if (iconpath->getText()=="")
 
1028
                iconpath->setText(oldiconpath);
 
1029
 
 
1030
        // Icon path has changed
 
1031
        if(oldiconpath != iconpath->getText())
 
1032
        {
 
1033
                getApp()->reg().writeStringEntry("SETTINGS","iconpath",iconpath->getText().text());
 
1034
                getApp()->reg().write();
 
1035
                restart_theme=TRUE;
 
1036
        }
 
1037
        
 
1038
        // Normal font has changed
 
1039
        if (oldnormalfont != normalfont->getText())
 
1040
        {
 
1041
                getApp()->reg().writeStringEntry("SETTINGS","font",normalfont->getText().text());
 
1042
                getApp()->reg().write();
 
1043
                restart_normalfont=TRUE;
 
1044
        }
 
1045
 
 
1046
        // Text font has changed
 
1047
        if (oldtextfont != textfont->getText())
 
1048
        {
 
1049
                getApp()->reg().writeStringEntry("SETTINGS","textfont",textfont->getText().text());
 
1050
                getApp()->reg().write();
 
1051
                restart_textfont=TRUE;
 
1052
        }
 
1053
 
 
1054
    // Text editor has changed
 
1055
        if(oldtxteditor != txteditor->getText())
 
1056
        {
 
1057
        // Update the txteditor string
 
1058
                FXString newtxteditor=txteditor->getText().text();
 
1059
                getApp()->reg().writeStringEntry("PROGS","txteditor",newtxteditor.text());
 
1060
                
 
1061
                // Update each filetype where the old txteditor was used
 
1062
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1063
                FileDict *assoc=new FileDict(getApp());
 
1064
 
 
1065
                FXint i;
 
1066
                FXString key, value, newvalue;
 
1067
                FXString strtmp, open, view, edit, command;
 
1068
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1069
                {
 
1070
                        // Read key and value of each filetype
 
1071
                        key=strdict->key(i);
 
1072
                        value=strdict->data(i);
 
1073
                        
 
1074
                        // Replace the old txteditor string with the new one
 
1075
                        if (value.contains(oldtxteditor))
 
1076
                        {
 
1077
                                // Obtain the open, view, edit and command strings
 
1078
                                strtmp=value.before(';',1);
 
1079
                                command=value.after(';',1);
 
1080
                                open=strtmp.section(',',0);
 
1081
                                view=strtmp.section(',',1);
 
1082
                                edit=strtmp.section(',',2);
 
1083
                                
 
1084
                                // Replace only the open and edit strings, if needed
 
1085
                                if (open==oldtxteditor)
 
1086
                                        open=newtxteditor;
 
1087
                                if (edit==oldtxteditor)
 
1088
                                        edit=newtxteditor;
 
1089
                                
 
1090
                                // Replace with the new value
 
1091
                                value=open + "," + view + "," + edit + ";" + command;
 
1092
                                assoc->replace(key.text(),value.text());
 
1093
                        }
 
1094
                }
 
1095
        }
 
1096
 
 
1097
    // Text viewer has changed
 
1098
        if(oldtxtviewer != txtviewer->getText())
 
1099
        {
 
1100
        // Update the txtviewer string
 
1101
                FXString newtxtviewer=txtviewer->getText().text();
 
1102
                getApp()->reg().writeStringEntry("PROGS","txtviewer",newtxtviewer.text());
 
1103
                
 
1104
                // Update each filetype where the old txtviewer was used
 
1105
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1106
                FileDict *assoc=new FileDict(getApp());
 
1107
 
 
1108
                FXint i;
 
1109
                FXString key, value, newvalue;
 
1110
                FXString strtmp, open, view, edit, command;
 
1111
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1112
                {
 
1113
                        // Read key and value of each filetype
 
1114
                        key=strdict->key(i);
 
1115
                        value=strdict->data(i);
 
1116
                        
 
1117
                        // Replace the old txtviewer string with the new one
 
1118
                        if (value.contains(oldtxtviewer))
 
1119
                        {
 
1120
                                // Obtain the open, view, edit and command strings
 
1121
                                strtmp=value.before(';',1);
 
1122
                                command=value.after(';',1);
 
1123
                                open=strtmp.section(',',0);
 
1124
                                view=strtmp.section(',',1);
 
1125
                                edit=strtmp.section(',',2);
 
1126
                                
 
1127
                                // Replace only the view string, if needed
 
1128
                                if (view==oldtxtviewer)
 
1129
                                        view=newtxtviewer;
 
1130
                                
 
1131
                                // Replace with the new value
 
1132
                                value=open + "," + view + "," + edit + ";" + command;
 
1133
                                assoc->replace(key.text(),value.text());
 
1134
                        }
 
1135
                }
 
1136
        }
 
1137
 
 
1138
    // Image editor has changed
 
1139
        if(oldimgeditor != imgeditor->getText())
 
1140
        {
 
1141
        // Update the imgeditor string
 
1142
                FXString newimgeditor=imgeditor->getText().text();
 
1143
                getApp()->reg().writeStringEntry("PROGS","imgeditor",newimgeditor.text());
 
1144
                
 
1145
                // Update each filetype where the old imgeditor was used
 
1146
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1147
                FileDict *assoc=new FileDict(getApp());
 
1148
 
 
1149
                FXint i;
 
1150
                FXString key, value, newvalue;
 
1151
                FXString strtmp, open, view, edit, command;
 
1152
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1153
                {
 
1154
                        // Read key and value of each filetype
 
1155
                        key=strdict->key(i);
 
1156
                        value=strdict->data(i);
 
1157
                        
 
1158
                        // Replace the old imgeditor string with the new one
 
1159
                        if (value.contains(oldimgeditor))
 
1160
                        {
 
1161
                                // Obtain the open, view, edit and command strings
 
1162
                                strtmp=value.before(';',1);
 
1163
                                command=value.after(';',1);
 
1164
                                open=strtmp.section(',',0);
 
1165
                                view=strtmp.section(',',1);
 
1166
                                edit=strtmp.section(',',2);
 
1167
                                
 
1168
                                // Replace only the open and edit strings, if needed
 
1169
                                if (open==oldimgeditor)
 
1170
                                        open=newimgeditor;
 
1171
                                if (edit==oldimgeditor)
 
1172
                                        edit=newimgeditor;
 
1173
                                
 
1174
                                // Replace with the new value
 
1175
                                value=open + "," + view + "," + edit + ";" + command;
 
1176
                                assoc->replace(key.text(),value.text());
 
1177
                        }
 
1178
                }
 
1179
        }
 
1180
 
 
1181
    // Image viewer has changed
 
1182
        if(oldimgviewer != imgviewer->getText())
 
1183
        {
 
1184
        // Update the imgviewer string
 
1185
                FXString newimgviewer=imgviewer->getText().text();
 
1186
                getApp()->reg().writeStringEntry("PROGS","imgviewer",newimgviewer.text());
 
1187
                
 
1188
                // Update each filetype where the old imgviewer was used
 
1189
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1190
                FileDict *assoc=new FileDict(getApp());
 
1191
 
 
1192
                FXint i;
 
1193
                FXString key, value, newvalue;
 
1194
                FXString strtmp, open, view, edit, command;
 
1195
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1196
                {
 
1197
                        // Read key and value of each filetype
 
1198
                        key=strdict->key(i);
 
1199
                        value=strdict->data(i);
 
1200
                        
 
1201
                        // Replace the old imgviewer string with the new one
 
1202
                        if (value.contains(oldimgviewer))
 
1203
                        {
 
1204
                                // Obtain the open, view, edit and command strings
 
1205
                                strtmp=value.before(';',1);
 
1206
                                command=value.after(';',1);
 
1207
                                open=strtmp.section(',',0);
 
1208
                                view=strtmp.section(',',1);
 
1209
                                edit=strtmp.section(',',2);
 
1210
                                
 
1211
                                // Replace the open and view string, if needed
 
1212
                                if (open==oldimgviewer)
 
1213
                                        open=newimgviewer;
 
1214
                                if (view==oldimgviewer)
 
1215
                                        view=newimgviewer;
 
1216
                                
 
1217
                                // Replace with the new value
 
1218
                                value=open + "," + view + "," + edit + ";" + command;
 
1219
                                assoc->replace(key.text(),value.text());
 
1220
                        }
 
1221
                }
 
1222
        }
 
1223
 
 
1224
    // Archiver has changed
 
1225
        if(oldarchiver != archiver->getText())
 
1226
        {
 
1227
        // Update the archiver string
 
1228
                FXString newarchiver=archiver->getText().text();
 
1229
                getApp()->reg().writeStringEntry("PROGS","archiver",newarchiver.text());
 
1230
                
 
1231
                // Update each filetype where the old archiver was used
 
1232
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1233
                FileDict *assoc=new FileDict(getApp());
 
1234
 
 
1235
                FXint i;
 
1236
                FXString key, value, newvalue;
 
1237
                FXString strtmp, open, view, edit, command;
 
1238
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1239
                {
 
1240
                        // Read key and value of each filetype
 
1241
                        key=strdict->key(i);
 
1242
                        value=strdict->data(i);
 
1243
                        
 
1244
                        // Replace the old archiver string with the new one
 
1245
                        if (value.contains(oldarchiver))
 
1246
                        {
 
1247
                                // Obtain the open, view, edit and command strings
 
1248
                                strtmp=value.before(';',1);
 
1249
                                command=value.after(';',1);
 
1250
                                open=strtmp.section(',',0);
 
1251
                                view=strtmp.section(',',1);
 
1252
                                edit=strtmp.section(',',2);
 
1253
                                
 
1254
                                // Replace the open, view and edit strings, if needed
 
1255
                                if (open==oldarchiver)
 
1256
                                        open=newarchiver;
 
1257
                                if (view==oldarchiver)
 
1258
                                        view=newarchiver;
 
1259
                                if (edit==oldarchiver)
 
1260
                                        edit=newarchiver;
 
1261
                                
 
1262
                                // Replace with the new value
 
1263
                                value=open + "," + view + "," + edit + ";" + command;
 
1264
                                assoc->replace(key.text(),value.text());
 
1265
                        }
 
1266
                }
 
1267
        }
 
1268
 
 
1269
    // PDF viewer has changed
 
1270
        if(oldpdfviewer != pdfviewer->getText())
 
1271
        {
 
1272
        // Update the PDF viewer string
 
1273
                FXString newpdfviewer=pdfviewer->getText().text();
 
1274
                getApp()->reg().writeStringEntry("PROGS","pdfviewer",newpdfviewer.text());
 
1275
                
 
1276
                // Update each filetype where the old PDF viewer was used
 
1277
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1278
                FileDict *assoc=new FileDict(getApp());
 
1279
 
 
1280
                FXint i;
 
1281
                FXString key, value, newvalue;
 
1282
                FXString strtmp, open, view, edit, command;
 
1283
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1284
                {
 
1285
                        // Read key and value of each filetype
 
1286
                        key=strdict->key(i);
 
1287
                        value=strdict->data(i);
 
1288
                        
 
1289
                        // Replace the old PDF viewer string with the new one
 
1290
                        if (value.contains(oldpdfviewer))
 
1291
                        {
 
1292
                                // Obtain the open, view, edit and command strings
 
1293
                                strtmp=value.before(';',1);
 
1294
                                command=value.after(';',1);
 
1295
                                open=strtmp.section(',',0);
 
1296
                                view=strtmp.section(',',1);
 
1297
                                edit=strtmp.section(',',2);
 
1298
                                
 
1299
                                // Replace the open, view and edit strings, if needed
 
1300
                                if (open==oldpdfviewer)
 
1301
                                        open=newpdfviewer;
 
1302
                                if (view==oldpdfviewer)
 
1303
                                        view=newpdfviewer;
 
1304
                                if (edit==oldpdfviewer)
 
1305
                                        edit=newpdfviewer;
 
1306
                                
 
1307
                                // Replace with the new value
 
1308
                                value=open + "," + view + "," + edit + ";" + command;
 
1309
                                assoc->replace(key.text(),value.text());
 
1310
                        }
 
1311
                }
 
1312
        }
 
1313
 
 
1314
    // Audio viewer has changed
 
1315
        if(oldaudioviewer != audioviewer->getText())
 
1316
        {
 
1317
        // Update the audio viewer string
 
1318
                FXString newaudioviewer=audioviewer->getText().text();
 
1319
                getApp()->reg().writeStringEntry("PROGS","audioviewer",newaudioviewer.text());
 
1320
                
 
1321
                // Update each filetype where the old audio viewer was used
 
1322
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1323
                FileDict *assoc=new FileDict(getApp());
 
1324
 
 
1325
                FXint i;
 
1326
                FXString key, value, newvalue;
 
1327
                FXString strtmp, open, view, edit, command;
 
1328
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1329
                {
 
1330
                        // Read key and value of each filetype
 
1331
                        key=strdict->key(i);
 
1332
                        value=strdict->data(i);
 
1333
                        
 
1334
                        // Replace the old audio viewer string with the new one
 
1335
                        if (value.contains(oldaudioviewer))
 
1336
                        {
 
1337
                                // Obtain the open, view, edit and command strings
 
1338
                                strtmp=value.before(';',1);
 
1339
                                command=value.after(';',1);
 
1340
                                open=strtmp.section(',',0);
 
1341
                                view=strtmp.section(',',1);
 
1342
                                edit=strtmp.section(',',2);
 
1343
                                
 
1344
                                // Replace the open, view and edit strings, if needed
 
1345
                                if (open==oldaudioviewer)
 
1346
                                        open=newaudioviewer;
 
1347
                                if (view==oldaudioviewer)
 
1348
                                        view=newaudioviewer;
 
1349
                                if (edit==oldaudioviewer)
 
1350
                                        edit=newaudioviewer;
 
1351
                                
 
1352
                                // Replace with the new value
 
1353
                                value=open + "," + view + "," + edit + ";" + command;
 
1354
                                assoc->replace(key.text(),value.text());
 
1355
                        }
 
1356
                }
 
1357
        }
 
1358
 
 
1359
    // Video viewer has changed
 
1360
        if(oldvideoviewer != videoviewer->getText())
 
1361
        {
 
1362
        // Update the video viewer string
 
1363
                FXString newvideoviewer=videoviewer->getText().text();
 
1364
                getApp()->reg().writeStringEntry("PROGS","videoviewer",newvideoviewer.text());
 
1365
                
 
1366
                // Update each filetype where the old video viewer was used
 
1367
                FXStringDict *strdict = getApp()->reg().find("FILETYPES");
 
1368
                FileDict *assoc=new FileDict(getApp());
 
1369
 
 
1370
                FXint i;
 
1371
                FXString key, value, newvalue;
 
1372
                FXString strtmp, open, view, edit, command;
 
1373
                for (i=strdict->first(); i<strdict->size(); i=strdict->next(i))
 
1374
                {
 
1375
                        // Read key and value of each filetype
 
1376
                        key=strdict->key(i);
 
1377
                        value=strdict->data(i);
 
1378
                        
 
1379
                        // Replace the old video viewer string with the new one
 
1380
                        if (value.contains(oldvideoviewer))
 
1381
                        {
 
1382
                                // Obtain the open, view, edit and command strings
 
1383
                                strtmp=value.before(';',1);
 
1384
                                command=value.after(';',1);
 
1385
                                open=strtmp.section(',',0);
 
1386
                                view=strtmp.section(',',1);
 
1387
                                edit=strtmp.section(',',2);
 
1388
                                
 
1389
                                // Replace the open, view and edit strings, if needed
 
1390
                                if (open==oldvideoviewer)
 
1391
                                        open=newvideoviewer;
 
1392
                                if (view==oldvideoviewer)
 
1393
                                        view=newvideoviewer;
 
1394
                                if (edit==oldvideoviewer)
 
1395
                                        edit=newvideoviewer;
 
1396
                                
 
1397
                                // Replace with the new value
 
1398
                                value=open + "," + view + "," + edit + ";" + command;
 
1399
                                assoc->replace(key.text(),value.text());
 
1400
                        }
 
1401
                }
 
1402
        }
 
1403
 
 
1404
        // Terminal has changed
 
1405
        if(oldxterm != xterm->getText())
 
1406
        getApp()->reg().writeStringEntry("PROGS","xterm",xterm->getText().text());
 
1407
 
 
1408
        getApp()->reg().writeUnsignedEntry("OPTIONS","auto_save_layout",autosave->getCheck());
 
1409
        getApp()->reg().writeUnsignedEntry("SETTINGS","save_win_pos",savewinpos->getCheck());
 
1410
    getApp()->reg().writeUnsignedEntry("OPTIONS","use_trash_can",trashcan->getCheck());
 
1411
    getApp()->reg().writeUnsignedEntry("OPTIONS","use_trash_bypass",trashbypass->getCheck());
 
1412
    getApp()->reg().writeUnsignedEntry("OPTIONS","ask_before_copy",ask->getCheck());
 
1413
    getApp()->reg().writeUnsignedEntry("SETTINGS","single_click",single_click);
 
1414
    getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_trash",trashmv->getCheck());
 
1415
    getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_delete",del->getCheck());
 
1416
    getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_delete_emptydir",del_emptydir->getCheck());
 
1417
    getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_overwrite",overwrite->getCheck());
 
1418
        getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_quit",quit->getCheck());
 
1419
    getApp()->reg().writeUnsignedEntry("OPTIONS","confirm_drag_and_drop",dnd->getCheck());
 
1420
    getApp()->reg().writeUnsignedEntry("OPTIONS","root_warn",root_warning->getCheck());
 
1421
    getApp()->reg().writeUnsignedEntry("OPTIONS","root_mode",rootmode->getCheck());
 
1422
#ifdef STARTUP_NOTIFICATION
 
1423
    getApp()->reg().writeUnsignedEntry("OPTIONS","use_startup_notification",usesn->getCheck());
 
1424
#endif
 
1425
#if defined(linux)
 
1426
    getApp()->reg().writeUnsignedEntry("OPTIONS","mount_warn",mount->getCheck());
 
1427
        getApp()->reg().writeUnsignedEntry("OPTIONS","mount_messages",show_mount->getCheck());
 
1428
#endif
 
1429
 
 
1430
        // Smooth scrolling
 
1431
        getApp()->reg().writeUnsignedEntry("SETTINGS","smooth_scroll",scroll->getCheck());
 
1432
        if (scroll->getCheck()!=smoothscroll_prev)
 
1433
        {
 
1434
                getApp()->reg().write();
 
1435
                restart_scroll=TRUE;
 
1436
        }
 
1437
                
 
1438
    // Control themes
 
1439
    getApp()->reg().writeUnsignedEntry("SETTINGS","use_clearlooks",use_clearlooks);
 
1440
 
 
1441
        if (use_clearlooks!=use_clearlooks_prev)
 
1442
        {
 
1443
                FXColor hilitecolor, shadowcolor;
 
1444
 
 
1445
                // Change control hilite and shadow colors when the control theme has changed
 
1446
                if (use_clearlooks) // clearlooks
 
1447
                {
 
1448
                        hilitecolor=makeHiliteColorGradient(currTheme.color[0]);
 
1449
                        shadowcolor=makeShadowColorGradient(currTheme.color[0]);
 
1450
                }
 
1451
                else // standard
 
1452
                {
 
1453
                        hilitecolor=makeHiliteColor(currTheme.color[0]);
 
1454
                        shadowcolor=makeShadowColor(currTheme.color[0]);
 
1455
                }
 
1456
                getApp()->reg().writeColorEntry("SETTINGS","hilitecolor",hilitecolor);
 
1457
                getApp()->reg().writeColorEntry("SETTINGS","shadowcolor",shadowcolor);
 
1458
 
 
1459
                getApp()->reg().write();
 
1460
                restart_controls=TRUE;
 
1461
        }
 
1462
 
 
1463
        // Update some global options
 
1464
        if (diropen->getCheck() && fileopen->getCheck())
 
1465
                single_click=SINGLE_CLICK_DIR_FILE;
 
1466
        else if (diropen->getCheck() && !fileopen->getCheck())
 
1467
                single_click=SINGLE_CLICK_DIR;
 
1468
        else
 
1469
                single_click=SINGLE_CLICK_NONE;
 
1470
        
 
1471
        if (single_click==SINGLE_CLICK_DIR_FILE)
 
1472
                ((XFileExplorer*) mainWindow)->setDefaultCursor(getApp()->getDefaultCursor(DEF_HAND_CURSOR));
 
1473
        else
 
1474
                ((XFileExplorer*) mainWindow)->setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
 
1475
   
 
1476
        // Update the file tooltips flag
 
1477
        if (filetooltips->getCheck())
 
1478
                file_tooltips=TRUE;
 
1479
        else
 
1480
                file_tooltips=FALSE;
 
1481
        getApp()->reg().writeUnsignedEntry("SETTINGS","file_tooltips",(FXuint)file_tooltips);
 
1482
 
 
1483
        // Update the relative resize flag
 
1484
        if (relativeresize->getCheck())
 
1485
                relative_resize=TRUE;
 
1486
        else
 
1487
                relative_resize=FALSE;
 
1488
        getApp()->reg().writeUnsignedEntry("SETTINGS","relative_resize",(FXuint)relative_resize);
 
1489
 
 
1490
        // Update the display path linker flag
 
1491
        show_pathlink=showpathlink->getCheck();
 
1492
        getApp()->reg().writeUnsignedEntry("SETTINGS","show_pathlinker",show_pathlink);
 
1493
        if (show_pathlink!=show_pathlink_prev)
 
1494
        {
 
1495
                getApp()->reg().write();
 
1496
                restart_pathlink=TRUE;
 
1497
        }
 
1498
 
 
1499
        // Theme has changed
 
1500
        if(currTheme != Themes[0])
 
1501
    {
 
1502
                getApp()->reg().writeColorEntry("SETTINGS","basecolor",currTheme.color[0]);
 
1503
        getApp()->reg().writeColorEntry("SETTINGS","bordercolor",currTheme.color[1]);
 
1504
        getApp()->reg().writeColorEntry("SETTINGS","backcolor",currTheme.color[2]);
 
1505
        getApp()->reg().writeColorEntry("SETTINGS","forecolor",currTheme.color[3]);
 
1506
        getApp()->reg().writeColorEntry("SETTINGS","selbackcolor",currTheme.color[4]);
 
1507
        getApp()->reg().writeColorEntry("SETTINGS","selforecolor",currTheme.color[5]);
 
1508
                getApp()->reg().writeColorEntry("SETTINGS","listbackcolor",currTheme.color[6]);
 
1509
                getApp()->reg().writeColorEntry("SETTINGS","listforecolor",currTheme.color[7]);
 
1510
                getApp()->reg().writeColorEntry("SETTINGS","highlightcolor",currTheme.color[8]);
 
1511
                getApp()->reg().writeColorEntry("SETTINGS","pbarcolor",currTheme.color[9]);
 
1512
                getApp()->reg().writeColorEntry("SETTINGS","attentioncolor",currTheme.color[10]);
 
1513
 
 
1514
        // Control themes
 
1515
                FXColor hilitecolor, shadowcolor;
 
1516
 
 
1517
                // Change control hilite and shadow colors when the control theme has changed
 
1518
                if (use_clearlooks) // clearlooks
 
1519
                {
 
1520
                        hilitecolor=makeHiliteColorGradient(currTheme.color[0]);
 
1521
                        shadowcolor=makeShadowColorGradient(currTheme.color[0]);
 
1522
                }
 
1523
                else // standard
 
1524
                {
 
1525
                        hilitecolor=makeHiliteColor(currTheme.color[0]);
 
1526
                        shadowcolor=makeShadowColor(currTheme.color[0]);
 
1527
                }
 
1528
                getApp()->reg().writeColorEntry("SETTINGS","hilitecolor",hilitecolor);
 
1529
                getApp()->reg().writeColorEntry("SETTINGS","shadowcolor",shadowcolor);
 
1530
 
 
1531
                getApp()->reg().write();
 
1532
        restart_theme=TRUE;
 
1533
    }
 
1534
        
 
1535
        // Restart application if necessary
 
1536
        if (restart_scroll)
 
1537
        {
 
1538
                if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Scrolling mode will be changed after restart.\nRestart X File Explorer now?")))
 
1539
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1540
        }
 
1541
        if (restart_theme)
 
1542
        {
 
1543
                if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Theme will be changed after restart.\nRestart X File Explorer now?")))
 
1544
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1545
        }
 
1546
        
 
1547
        if (restart_pathlink)
 
1548
        {
 
1549
                if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Path linker will be changed after restart.\nRestart X File Explorer now?")))
 
1550
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1551
        }
 
1552
 
 
1553
        if (restart_controls)
 
1554
        {
 
1555
                if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Button style will be changed after restart.\nRestart X File Explorer now?")))
 
1556
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1557
        }
 
1558
 
 
1559
        if (restart_normalfont)
 
1560
        {
 
1561
        if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Normal font will be changed after restart.\nRestart X File Explorer now?")))
 
1562
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1563
        }
 
1564
 
 
1565
        if (restart_textfont)
 
1566
        {
 
1567
        if(BOX_CLICKED_CANCEL!=MessageBox::question(this,BOX_OK_CANCEL,_("Restart"),_("Text font will be changed after restart.\nRestart X File Explorer now?")))
 
1568
                        mainWindow->handle(this,FXSEL(SEL_COMMAND,XFileExplorer::ID_RESTART),NULL);
 
1569
        }
 
1570
 
 
1571
        // Finally, update the registry
 
1572
        getApp()->reg().write();
 
1573
                
 
1574
    DialogBox::onCmdAccept(o,s,p);
 
1575
    return 1;
 
1576
}
 
1577
 
 
1578
 
 
1579
long PreferencesBox::onCmdCancel(FXObject* o,FXSelector s,void* p)
 
1580
{
 
1581
        // Reset preferences to their previous values
 
1582
        
 
1583
        // First tab - Options
 
1584
        trashcan->setCheck(trashcan_prev);
 
1585
        trashbypass->setCheck(trashbypass_prev);
 
1586
        autosave->setCheck(autosave_prev);
 
1587
        savewinpos->setCheck(savewinpos_prev);
 
1588
        diropen->setCheck(diropen_prev);
 
1589
        fileopen->setCheck(fileopen_prev);
 
1590
        filetooltips->setCheck(filetooltips_prev);
 
1591
        relativeresize->setCheck(relativeresize_prev);
 
1592
        showpathlink->setCheck(show_pathlink_prev);
 
1593
        getApp()->setWheelLines(value_prev);    
 
1594
        use_sudo=use_sudo_prev;
 
1595
        getApp()->reg().writeUnsignedEntry("OPTIONS","use_sudo",use_sudo);
 
1596
        scroll->setCheck(smoothscroll_prev);
 
1597
        rootmode->setCheck(rootmode_prev);
 
1598
#ifdef STARTUP_NOTIFICATION
 
1599
        usesn->setCheck(usesn_prev);
 
1600
#endif
 
1601
        
 
1602
        // Second tab - Dialogs
 
1603
        ask->setCheck(ask_prev);
 
1604
        dnd->setCheck(dnd_prev);
 
1605
        trashmv->setCheck(trashmv_prev);
 
1606
        del->setCheck(del_prev);
 
1607
        del_emptydir->setCheck(del_emptydir_prev);
 
1608
        overwrite->setCheck(overwrite_prev);
 
1609
        quit->setCheck(quit_prev);
 
1610
#if defined(linux)
 
1611
        mount->setCheck(mount_prev);
 
1612
        show_mount->setCheck(show_mount_prev);
 
1613
#endif
 
1614
        root_warning->setCheck(root_warning_prev);
 
1615
        
 
1616
        // Third tab - Programs
 
1617
        txteditor->setText(oldtxteditor);       
 
1618
        txtviewer->setText(oldtxtviewer);       
 
1619
        imgeditor->setText(oldimgeditor);       
 
1620
        imgviewer->setText(oldimgviewer);       
 
1621
        archiver->setText(oldarchiver); 
 
1622
        pdfviewer->setText(oldpdfviewer);       
 
1623
        audioviewer->setText(oldaudioviewer);   
 
1624
        videoviewer->setText(oldvideoviewer);   
 
1625
        xterm->setText(oldxterm);
 
1626
 
 
1627
        // Fourth tab - Visual
 
1628
    themesList->setCurrentItem(themelist_prev);
 
1629
        currTheme=currTheme_prev;
 
1630
    iconpath->setText(oldiconpath);
 
1631
        use_clearlooks=use_clearlooks_prev;
 
1632
        getApp()->reg().writeUnsignedEntry("SETTINGS","use_clearlooks",use_clearlooks);
 
1633
 
 
1634
        // Fifth tab - Fonts
 
1635
        normalfont->setText(oldnormalfont);
 
1636
        textfont->setText(oldtextfont);
 
1637
 
 
1638
        // Finally, update the registry (really necessary?)
 
1639
        getApp()->reg().write();
 
1640
        
 
1641
    DialogBox::onCmdCancel(o,s,p);
 
1642
    return 1;
 
1643
}
 
1644
 
 
1645
 
 
1646
// Execute dialog box modally
 
1647
FXuint PreferencesBox::execute(FXuint placement)
 
1648
{
 
1649
        // Save current preferences to restore them if cancel is pressed
 
1650
        
 
1651
        // First tab - Options
 
1652
        trashcan_prev=trashcan->getCheck();
 
1653
        trashbypass_prev=trashbypass->getCheck();
 
1654
        autosave_prev=autosave->getCheck();
 
1655
        savewinpos_prev=savewinpos->getCheck();
 
1656
        diropen_prev=diropen->getCheck();
 
1657
        fileopen_prev=fileopen->getCheck();
 
1658
        filetooltips_prev=filetooltips->getCheck();
 
1659
        relativeresize_prev=relativeresize->getCheck();
 
1660
        show_pathlink_prev=showpathlink->getCheck();
 
1661
        value_prev=getApp()->getWheelLines();
 
1662
        use_sudo_prev=use_sudo;
 
1663
        smoothscroll_prev=scroll->getCheck();
 
1664
        rootmode_prev=rootmode->getCheck();
 
1665
#ifdef STARTUP_NOTIFICATION
 
1666
        usesn_prev=usesn->getCheck();
 
1667
#endif
 
1668
        
 
1669
        // Second tab - Dialogs
 
1670
        ask_prev=ask->getCheck();
 
1671
        dnd_prev=dnd->getCheck();
 
1672
        trashmv_prev=trashmv->getCheck();
 
1673
        del_prev=del->getCheck();
 
1674
        del_emptydir_prev=del_emptydir->getCheck();
 
1675
        overwrite_prev=overwrite->getCheck();
 
1676
        quit_prev=quit->getCheck();
 
1677
#if defined(linux)
 
1678
        mount_prev=mount->getCheck();
 
1679
        show_mount_prev=show_mount->getCheck();
 
1680
#endif
 
1681
        root_warning_prev=root_warning->getCheck();
 
1682
 
 
1683
    // Third tab - Programs
 
1684
        oldtxteditor=txteditor->getText();
 
1685
        oldtxtviewer=txtviewer->getText();
 
1686
        oldimgeditor=imgeditor->getText();
 
1687
        oldimgviewer=imgviewer->getText();
 
1688
        oldarchiver=archiver->getText();
 
1689
        oldpdfviewer=pdfviewer->getText();
 
1690
        oldaudioviewer=audioviewer->getText();
 
1691
        oldvideoviewer=videoviewer->getText();
 
1692
        oldxterm=xterm->getText();
 
1693
        
 
1694
        // Fourth tab - Visual
 
1695
        themelist_prev=themesList->getCurrentItem();
 
1696
    currTheme_prev = currTheme;
 
1697
    oldiconpath=iconpath->getText();
 
1698
        use_clearlooks_prev=use_clearlooks;
 
1699
        
 
1700
        // Fifth tab - Fonts
 
1701
        oldnormalfont=normalfont->getText();
 
1702
        oldtextfont=textfont->getText();
 
1703
 
 
1704
        create();
 
1705
    show(placement);
 
1706
        getApp()->refresh();
 
1707
    return getApp()->runModalFor(this);
 
1708
}
 
1709
 
 
1710
 
 
1711
// Update buttons related to the trash can option item
 
1712
long PreferencesBox::onUpdTrash(FXObject* o,FXSelector,void*)
 
1713
{
 
1714
        if (trashcan->getCheck())       
 
1715
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_ENABLE),NULL);
 
1716
        else
 
1717
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_DISABLE),NULL);
 
1718
    return 1;
 
1719
}
 
1720
 
 
1721
 
 
1722
// Update the confirm delete empty directories option item
 
1723
long PreferencesBox::onUpdConfirmDelEmptyDir(FXObject* o,FXSelector,void*)
 
1724
{
 
1725
        if (del->getCheck())    
 
1726
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_ENABLE),NULL);
 
1727
        else
 
1728
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_DISABLE),NULL);
 
1729
    return 1;
 
1730
}
 
1731
 
 
1732
 
 
1733
// Set root mode
 
1734
long PreferencesBox::onCmdSuMode(FXObject*,FXSelector sel,void*)
 
1735
{
 
1736
        if (FXSELID(sel)==ID_SU_CMD)
 
1737
                use_sudo=FALSE;
 
1738
                
 
1739
        else if (FXSELID(sel)==ID_SUDO_CMD)
 
1740
                use_sudo=TRUE;
 
1741
 
 
1742
        getApp()->reg().writeUnsignedEntry("OPTIONS","use_sudo",use_sudo);
 
1743
        getApp()->reg().write();
 
1744
 
 
1745
        return 1;
 
1746
}
 
1747
 
 
1748
 
 
1749
// Update root mode radio button
 
1750
long PreferencesBox::onUpdSuMode(FXObject* sender,FXSelector sel,void*)
 
1751
{
 
1752
        if (!rootmode->getCheck())
 
1753
                sender->handle(this,FXSEL(SEL_COMMAND,ID_DISABLE),NULL);
 
1754
        else
 
1755
        {
 
1756
                if (getuid()) // Simple user
 
1757
                        sender->handle(this,FXSEL(SEL_COMMAND,ID_ENABLE),NULL);
 
1758
                
 
1759
                FXSelector updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1760
                
 
1761
                if (FXSELID(sel)==ID_SU_CMD)
 
1762
                {
 
1763
                        if (use_sudo)
 
1764
                                updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1765
                        else
 
1766
                                updatemessage=FXSEL(SEL_COMMAND,ID_CHECK);
 
1767
                }
 
1768
                else if (FXSELID(sel)==ID_SUDO_CMD)
 
1769
                {
 
1770
                        if (use_sudo)
 
1771
                                updatemessage=FXSEL(SEL_COMMAND,ID_CHECK);
 
1772
                        else
 
1773
                                updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1774
 
 
1775
                }               
 
1776
                sender->handle(this,updatemessage,NULL);
 
1777
        }
 
1778
        return 1;
 
1779
}
 
1780
 
 
1781
 
 
1782
// Set root mode
 
1783
long PreferencesBox::onCmdControls(FXObject*,FXSelector sel,void*)
 
1784
{
 
1785
        if (FXSELID(sel)==ID_STANDARD_CONTROLS)
 
1786
                use_clearlooks=FALSE;
 
1787
                
 
1788
        else if (FXSELID(sel)==ID_CLEARLOOKS_CONTROLS)
 
1789
                use_clearlooks=TRUE;
 
1790
 
 
1791
        getApp()->reg().writeUnsignedEntry("SETTINGS","use_clearlooks",use_clearlooks);
 
1792
        getApp()->reg().write();
 
1793
 
 
1794
        return 1;
 
1795
}
 
1796
 
 
1797
 
 
1798
// Update root mode radio button
 
1799
long PreferencesBox::onUpdControls(FXObject* sender,FXSelector sel,void*)
 
1800
{
 
1801
        FXSelector updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1802
        
 
1803
        if (FXSELID(sel)==ID_STANDARD_CONTROLS)
 
1804
        {
 
1805
                if (use_clearlooks)
 
1806
                        updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1807
                else
 
1808
                        updatemessage=FXSEL(SEL_COMMAND,ID_CHECK);
 
1809
        }
 
1810
        else if (FXSELID(sel)==ID_CLEARLOOKS_CONTROLS)
 
1811
        {
 
1812
                if (use_clearlooks)
 
1813
                        updatemessage=FXSEL(SEL_COMMAND,ID_CHECK);
 
1814
                else
 
1815
                        updatemessage=FXSEL(SEL_COMMAND,ID_UNCHECK);
 
1816
 
 
1817
        }               
 
1818
        sender->handle(this,updatemessage,NULL);
 
1819
        return 1;
 
1820
}
 
1821
 
 
1822
 
 
1823
 
 
1824
// Set scroll wheel lines (Mathew Robertson <mathew@optushome.com.au>)
 
1825
long PreferencesBox::onCmdWheelAdjust(FXObject* sender,FXSelector,void*)
 
1826
{
 
1827
    FXuint value;
 
1828
    sender->handle(this,FXSEL(SEL_COMMAND,ID_GETINTVALUE),(void*)&value);
 
1829
    getApp()->setWheelLines(value);
 
1830
        getApp()->reg().write();
 
1831
    return 1;
 
1832
}
 
1833
 
 
1834
 
 
1835
// Update the wheel lines button
 
1836
long PreferencesBox::onUpdWheelAdjust(FXObject* sender,FXSelector,void*)
 
1837
{
 
1838
    FXuint value=getApp()->getWheelLines();
 
1839
        sender->handle(this,FXSEL(SEL_COMMAND,ID_SETINTVALUE),(void*)&value);
 
1840
    return 1;
 
1841
}
 
1842
 
 
1843
 
 
1844
// Update single click file open button
 
1845
long PreferencesBox::onUpdSingleClickFileopen(FXObject* o,FXSelector,void*)
 
1846
{
 
1847
        if (diropen->getCheck())        
 
1848
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_ENABLE),NULL);
 
1849
        else
 
1850
        {
 
1851
                fileopen->setCheck(FALSE);
 
1852
                o->handle(this,FXSEL(SEL_COMMAND,FXWindow::ID_DISABLE),NULL);
 
1853
        }
 
1854
    return 1;
 
1855
}
 
1856