This source file includes following definitions.
- Action_SwitchShowIcons
- NavGoParentDir
- NavGoPath
- LoadStyles
- BF_GUI_FilesPanel_LoadFiles_Thread
- Load_Files
- DrawListInfo
- PathHistory_Add
- PathHistory_GoBack
- Path
- PrepareHotKeys
- PrepareCmdLine
- PrepareKeysMenu
- PrepareTopMenuItem
- OnKeyDown
- OnClose
- NavEnter
- Pub_GoPath
- AttachedToWindow
- ActionDelete_Run
- Action_CopyMoveTo_Run
- ActionCopyTo_Run
- ActionMoveTo_Run
- MessageReceived
- NavChangeCursor
- SayFriend_About_CursorChanged_Ext
- ActionMakeDir_Run
- ActionRename_Run
- Nodes_Add
- Nodes_Remove
- Action_ChangeCase_0
- Action_ChangeCase_1
- Action_MakeLinks_StartDialog
- Action_MakeLinks_StartTask
- Action_TextViewer_Start
- Action_Run_File
- Action_Edit_File
- Action_CopyToBuffer
- Action_PasteFromBuffer
- Action_PasteFromBuffer_Step2
- Action_GoPath_StartDialog
- Action_GoPath_Run
1 #include <stdio.h>
2 #include <Locker.h>
3 #include "BF_GUI_FilesPanel.h"
4 #include "BF_Dict.h"
5 #include "BF_Roster.h"
6 #include "BF_GUI_CmdLine.h"
7 #include "BF_GUI_KeysMenu.h"
8 #include "BF_GUI_FilesPanel_Tasks.h"
9 #include "BF_GUI_WinMain.h"
10 #include "BF_GUI_ImagePanel.h"
11 #include "BF_GUI_FilesPanel_InfoPanel.h"
12 #include "BF_GUI_ArcPanel.h"
13 #include "BF_GUI_TextViewer.h"
14 #include "BF_GUI_AttrDialog.h"
15 #include <be/app/Clipboard.h>
16
17
18
19
20 BF_GUI_FilesPanel::BF_GUI_FilesPanel(const BRect & o_Rect,bool b_WinPos_OnLeft)
21 :BF_GUI_NodePanel(o_Rect,b_WinPos_OnLeft)
22 {
23 idThreadLoading = 0;
24 if(poSysSetup && poSysSetup->oVars.Loaded()){
25 BF_GUI_Setup_Vars_Panel *poVar = bWinPos_OnLeft?(&poSysSetup->oVars.oLPanel):(&poSysSetup->oVars.oRPanel);
26 ASSERT(poVar);
27 iModeFullStyles = poVar->iModeFullStyles;
28 iModeColsStyles = poVar->iModeColsStyles;
29 iMode = poVar->iMode;
30 }
31 }
32
33 void
34 BF_GUI_FilesPanel::Action_SwitchShowIcons()
35 {
36 if(!ModeShowSIcon()) Load_Files(true);
37 BF_GUI_NodePanel::Action_SwitchShowIcons();
38 }
39
40
41 void
42 BF_GUI_FilesPanel::NavGoParentDir()
43 {
44 BF_FilesPath oNewPath = oPath;
45 BString sDir;
46 bool bRet = poSysSetup->MainStyle() & BF_SETUP_MAIN_RETURN_REMEMBER;
47 if(bRet) oNewPath.LastDir(sDir);
48 while(TRUE){
49 if(!oNewPath.GoParent()) return;
50 NavGoPath(oNewPath,bRet?(&sDir):NULL);
51 break;
52 }
53 }
54
55 void
56 BF_GUI_FilesPanel::NavGoPath(
57 const BF_Path & o_NewPath,
58 BString *ps_FocusItem,
59 bool b_LoadNodes,
60 bool b_AddToHistory)
61 {
62
63 if(b_AddToHistory && !oPath.IsEmpty()) PathHistory_Add(&oPath);
64
65
66 if(!(poSysSetup->MainStyle() & BF_SETUP_DEB_NOMONITORING)){
67 BF_Roster_StopAllMonitors(this);
68 }
69
70
71 oPath = o_NewPath;
72 SetHeader(oPath.Path(),(poSysSetup->MainStyle() & BF_SETUP_MAIN_FP_HEADERICON)?oPath.LoadSIcon():NULL);
73
74 if(b_LoadNodes){
75 if(ps_FocusItem) sThreadLoading_FutureFocus = *ps_FocusItem;
76 Load_Files();
77 }
78
79 PrepareCmdLine();
80 }
81
82 int32
83 BF_GUI_FilesPanel::LoadStyles()
84 {
85 int32 iLoadStyles = BF_ROSTER_LOAD_NODE_ALL;
86 iLoadStyles = iLoadStyles | (((iMode==BF_NODEPANEL_MODE_FULL) && (iModeFullStyles & BF_NODEPANEL_FULL_TYPE))?BF_ROSTER_LOAD_TYPE:0);
87 iLoadStyles = iLoadStyles | ((ModeShowSIcon())?BF_ROSTER_LOAD_SICON:0);
88 return iLoadStyles;
89 }
90
91 int32
92 BF_GUI_FilesPanel_LoadFiles_Thread(void *data)
93 {
94 BF_GUI_FilesPanel *poPanel = (BF_GUI_FilesPanel*)data;
95 ASSERT(poPanel);
96 BF_Roster_LoadNodeList_Ext(poPanel->oPath,poPanel->LoadStyles(),poPanel,BF_MSG_FILEPANEL_LOADNODES_STEP,BF_MSG_FILEPANEL_LOADNODES_FINISHED);
97 return 0;
98 }
99
100 void
101 BF_GUI_FilesPanel::Load_Files(bool b_AlwaysLoadSIcons)
102 {
103 loNode.DeleteItems();
104 loNode.poPath = &oPath;
105 Invalidate(Bounds());
106
107 iThreadLoading_Count = 0;
108 iThreadLoading_Index = 0;
109
110
111 BF_GUI_Func_PanelsEnable(false);
112 if(poSysKeysMenu) poSysKeysMenu->Clear();
113
114 idThreadLoading = spawn_thread(BF_GUI_FilesPanel_LoadFiles_Thread,"BeFar:load_files",B_THREAD_SUSPENDED,(void*)this);
115 ASSERT(idThreadLoading>0,"can`t start thread load_files\n");
116 ASSERT(B_OK==resume_thread(idThreadLoading));
117 set_thread_priority(idThreadLoading,B_NORMAL_PRIORITY);
118 }
119
120
121 void
122 BF_GUI_FilesPanel::DrawListInfo(bool b_DrawBack)
123 {
124 if(idThreadLoading){
125 Draw_OpenTransaction();
126
127 BL_String s,s1;
128 s=BF_DictAt(BF_DICT_FILES_LOADING);
129 s<<" ";
130 s1 << iThreadLoading_Index;
131 s1.SetDigits();
132 s<<s1;
133 s << BF_DictAt(BF_DICT_FILES_FROM);
134 s1 = iThreadLoading_Count;
135 s1.SetDigits();
136 s<<s1;
137 DrawBottom(s.String(), b_DrawBack);
138
139 BRect oRect(BottomRect());
140 Draw_CloseTransaction(&oRect);
141
142 }else
143 BF_GUI_NodePanel::DrawListInfo(b_DrawBack);
144 }
145
146
147 void
148 BF_GUI_FilesPanel::PathHistory_Add(BF_Path * po_Path)
149 {
150 if(lsPathHistory.CountItems()==poSysSetup->iPathHistorySize) lsPathHistory.DeleteItemAt(0);
151 ASSERT(po_Path);
152 lsPathHistory.AddItem(new BL_String(po_Path->Path()));
153 }
154
155 void
156 BF_GUI_FilesPanel::PathHistory_GoBack()
157 {
158 BL_String * ps = (BL_String*)lsPathHistory.ItemAt(lsPathHistory.CountItems()-1);
159
160 if(!ps){
161 BF_Dialog_Alert_Sep(BF_DictAt(BF_DICT_WARNING),BF_DictAt(BF_DICT_FILES_PATHHIST_EMPTY),NULL,this);
162 return;
163 }
164 BF_Path oNewPath(ps->String());
165 lsPathHistory.DeleteItemAt(lsPathHistory.CountItems()-1);
166 NavGoPath(oNewPath,NULL,true,false);
167 }
168
169 const BL_String
170 BF_GUI_FilesPanel::Path() const
171 {
172 BL_String sResult;
173 sResult = oPath.Path();
174 return sResult;
175 }
176
177 void
178 BF_GUI_FilesPanel::PrepareHotKeys(bool b_Focused)
179 {
180 BF_GUI_NodePanel::PrepareHotKeys(b_Focused);
181
182 if(b_Focused){
183 poWin->AddShortcut('d',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_TRACKER_ADDONS_START),this);
184
185 poWin->AddShortcut('i',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_SHOW_INFOPANEL),this);
186 poWin->AddShortcut('u',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_SET_FRIENDPATH_TOEQUAL),this);
187 poWin->AddShortcut('r',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_REFRESH),this);
188 poWin->AddShortcut('a',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_SHOW_ATTRDIALOG),this);
189 poWin->AddShortcut('s',B_COMMAND_KEY,new BMessage(BF_MSG_FILEPANEL_MAKESH_DIALOG),this);
190 }else{
191 poWin->RemoveShortcut('d',B_COMMAND_KEY);
192
193 poWin->RemoveShortcut('i',B_COMMAND_KEY);
194 poWin->RemoveShortcut('u',B_COMMAND_KEY);
195 poWin->RemoveShortcut('r',B_COMMAND_KEY);
196 poWin->RemoveShortcut('a',B_COMMAND_KEY);
197 poWin->RemoveShortcut('s',B_COMMAND_KEY);
198 }
199 }
200
201 void
202 BF_GUI_FilesPanel::PrepareCmdLine()
203 {
204 if(!poCmdLine) return;
205
206 poCmdLine->SetValues(oPath.Path());
207 }
208
209 void
210 BF_GUI_FilesPanel::PrepareKeysMenu()
211 {
212 BF_GUI_NodePanel::PrepareKeysMenu();
213 uint32 iKeysModifiers = modifiers();
214
215 if(iKeysModifiers & B_RIGHT_OPTION_KEY){
216 BMessage *po;
217
218 poSysKeysMenu->SetText(5,BF_DictAt(BF_DICT_FILES_MKLINK));
219 po = new BMessage(BF_MSG_NODEPANEL_MAKELINK_STARTDIALOG);
220 poSysKeysMenu->SetMessage(5,po,this);
221
222 poSysKeysMenu->SetText(6,BF_DictAt(BF_DICT_RENAME));
223 po = new BMessage(BF_MSG_NODEPANEL_RENAME_START);
224 poSysKeysMenu->SetMessage(6,po,this);
225
226 poSysKeysMenu->SetText(7,BF_DictAt(BF_DICT_SEARCH));
227 po = new BMessage(BF_MSG_FILEPANEL_SEARCH_START);
228 poSysKeysMenu->SetMessage(7,po,this);
229
230 poSysKeysMenu->SetText(8,BF_DictAt(BF_DICT_FILES_TOVOID));
231 po = new BMessage(BF_MSG_FILEPANEL_DELETE_VOID);
232 poSysKeysMenu->SetMessage(8,po,this);
233
234 }else{
235 poSysKeysMenu->SetText(3,BF_DictAt(BF_DICT_VIEW));
236 poSysKeysMenu->SetMessage(3,new BMessage(BF_MSG_FILEPANEL_TEXTVIEWER_START),this);
237
238 poSysKeysMenu->SetText(4,BF_DictAt(BF_DICT_EDIT));
239 poSysKeysMenu->SetMessage(4,new BMessage(BF_MSG_FILEPANEL_EDIT),this);
240
241 poSysKeysMenu->SetText(5,BF_DictAt(BF_DICT_COPY));
242 poSysKeysMenu->SetMessage(5,new BMessage(BF_MSG_NODEPANEL_COPY_START),this);
243
244 poSysKeysMenu->SetText(6,BF_DictAt(BF_DICT_MOVE));
245 poSysKeysMenu->SetMessage(6,new BMessage(BF_MSG_NODEPANEL_MOVE_START),this);
246
247 poSysKeysMenu->SetText(7,BF_DictAt(BF_DICT_FILES_MKDIR));
248 poSysKeysMenu->SetMessage(7,new BMessage(BF_MSG_NODEPANEL_MAKEDIR_START),this);
249
250 poSysKeysMenu->SetText(8,BF_DictAt(BF_DICT_FILES_TOTRASH));
251 poSysKeysMenu->SetMessage(8,new BMessage(BF_MSG_FILEPANEL_DELETE_TRASH),this);
252 }
253 }
254
255 void
256 BF_GUI_FilesPanel::PrepareTopMenuItem(BF_GUI_TopMenu_HItem *po_HItem)
257 {
258 BF_GUI_NodePanel::PrepareTopMenuItem(po_HItem);
259 po_HItem->AddHItem("",NULL);
260 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_SEARCH),BF_MSG_FILEPANEL_SEARCH_START,this,"Ctrl+F7");
261 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_CHANGECASE),BF_MSG_FILEPANEL_CHANGE_CASE,this,"");
262 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_TRACKER_ADDONS),BF_MSG_FILEPANEL_TRACKER_ADDONS_START,this,"Alt+D");
263
264 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_SHOWINFO),BF_MSG_FILEPANEL_SHOW_INFOPANEL,this,"Alt+I");
265 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_SETOPPATH),BF_MSG_FILEPANEL_SET_FRIENDPATH_TOEQUAL,this,"Alt+U");
266 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_GOTO),BF_MSG_FILEPANEL_GOPATH_PREPARE,this,"");
267 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_REFRESH),BF_MSG_FILEPANEL_REFRESH,this,"Alt+R");
268 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_SHOWATTRS),BF_MSG_FILEPANEL_SHOW_ATTRDIALOG,this,"Alt+A");
269 po_HItem->AddHItem(BF_DictAt(BF_DICT_MENU_MAKESHLINK),BF_MSG_FILEPANEL_MAKESH_DIALOG,this,"Alt+S");
270 }
271
272 bool
273 BF_GUI_FilesPanel::OnKeyDown(const char *bytes, int32 numBytes)
274 {
275 if(numBytes==1 && bytes[0]==B_DELETE){
276 iTempDelType = BF_MSG_FILEPANEL_DELETE_TRASH;
277 ActionDelete_Start();
278 }else
279 return BF_GUI_NodePanel::OnKeyDown(bytes,numBytes);
280 return true;
281 }
282
283 bool
284 BF_GUI_FilesPanel::OnClose()
285 {
286 return false;
287 }
288
289 bool
290 BF_GUI_FilesPanel::NavEnter()
291 {
292 BF_Node* poNode = Nodes_Focus();
293 if(!poNode) return BF_GUI_NodePanel::NavEnter();
294
295
296
297 if(poNode->bLink && BF_NODE_TYPE_DIR==poNode->iType){
298 BL_String s,s1;
299 s<<oPath.Path();
300 s<<"/";
301 s<<poNode->sName;
302 status_t uRes = BF_Roster_TraverseLink(s.String(),s1);
303
304 if(uRes!=B_OK){
305 BF_Dialog_Alert_Sep_Error(uRes,this);
306 return false;
307 }else{
308
309 BF_Path oNewPath(s1.String());
310 NavGoPath(oNewPath);
311 return true;
312 }
313 }
314
315 switch(poNode->iType){
316 case BF_NODE_TYPE_PARENTDIR:{
317 NavGoParentDir();
318 break;}
319
320 case BF_NODE_TYPE_DIR:{
321 BF_Path oNewPath = oPath;
322 if(!oNewPath.GoLocalDir(poNode->sName)) return(true);
323 NavGoPath(oNewPath,NULL,true);
324 break;}
325 case BF_NODE_TYPE_FILE:{
326
327
328 if(false)
329 {
330
331 if(poNode->sType==""){
332
333 BF_Roster_ReloadNode(oPath.Path(),poNode,BF_ROSTER_LOAD_TYPE);
334 }
335
336 if(poNode->sType=="application/zip"){
337 BF_GUI_ArcPanel_OpenFile(oPath.Path(),poNode->Name(),bWinPos_OnLeft);
338 break;
339 }
340 }
341 Action_Run_File(poNode);
342 break;}
343 };
344
345 return true;
346 }
347
348 void
349 BF_GUI_FilesPanel::Pub_GoPath(const char *pc_Path)
350 {
351 ASSERT(pc_Path);
352 BF_Path o(strlen(pc_Path)>0?pc_Path:"/boot/home");
353 NavGoPath(o);
354 }
355
356 void
357 BF_GUI_FilesPanel::AttachedToWindow(void)
358 {
359 BF_GUI_NodePanel::AttachedToWindow();
360
361
362 }
363
364 void
365 BF_GUI_FilesPanel::ActionDelete_Run(BF_NodeCollection & lo_Node)
366 {
367 BF_GUI_NodePanel::ActionDelete_Run(lo_Node);
368 BF_GUI_OperRoster_AddTask( new BF_GUI_FilesPanel_DeleteTask(oPath,lo_Node,
369 BF_MSG_FILEPANEL_DELETE_TRASH==iTempDelType?BF_FILESPANEL_DELETE_TO_TRASH:BF_FILESPANEL_DELETE_TO_VOID));
370 }
371 void
372 BF_GUI_FilesPanel::Action_CopyMoveTo_Run(BL_String & s_Path,BF_NodeCollection & lo_Node,bool b_Move)
373 {
374 BF_GUI_NodePanel::ActionCopyTo_Run(s_Path,lo_Node);
375 BF_FilesPath oDestPath(s_Path.String());
376
377 if(oDestPath.IsStorageKit() || oDestPath.String().FindFirst("//")<0){
378 BF_GUI_OperRoster_AddTask( new BF_GUI_FilesPanel_CopyTask(oPath,oDestPath,lo_Node,b_Move));
379 }else{
380 BF_GUI_Panel *po = poWinView->PanelOnTop(!bWinPos_OnLeft);
381 if(!po) return;
382 BL_String sSelfPath(oPath.Path());
383 po->ActionCopyFrom_Run(sSelfPath,lo_Node,b_Move);
384
385 }
386 }
387
388
389 void
390 BF_GUI_FilesPanel::ActionCopyTo_Run(BL_String & s_Path,BF_NodeCollection & lo_Node)
391 {
392 BF_GUI_NodePanel::ActionCopyTo_Run(s_Path,lo_Node);
393 Action_CopyMoveTo_Run(s_Path,lo_Node,false);
394 }
395
396 void
397 BF_GUI_FilesPanel::ActionMoveTo_Run(BL_String & s_Path,BF_NodeCollection & lo_Node)
398 {
399 BF_GUI_NodePanel::ActionMoveTo_Run(s_Path,lo_Node);
400 Action_CopyMoveTo_Run(s_Path,lo_Node,true);
401 }
402
403 void
404 BF_GUI_FilesPanel::MessageReceived(BMessage* po_Message)
405 {
406 switch(po_Message->what){
407
408 case BF_MSG_FILEPANEL_MAKESH_DIALOG:
409 Action_MakeSH_Dialog();
410 break;
411 case BF_MSG_FILEPANEL_MAKESH_RUN:
412 Action_MakeSH_Run(po_Message);
413 break;
414
415 case BF_MSG_FILEPANEL_GOPATH_PREPARE:{
416 Action_GoPath_StartDialog();
417 break;}
418 case BF_MSG_FILEPANEL_GOPATH_RUN:{
419 BF_GUI_Func_PanelsEnable(true);
420 MakeFocus();
421 Action_GoPath_Run(po_Message);
422 break;}
423
424 case BF_MSG_FILEPANEL_TRACKER_ADDONS_START:
425 Action_Tracker_Addons_Start();
426 break;
427 case BF_MSG_FILEPANEL_TRACKER_ADDONS_SELECTED:{
428 BF_GUI_Func_PanelsEnable(true);
429 MakeFocus();
430 const char *pcItem = po_Message->FindString("menu_code");
431 if(!pcItem || pcItem[0]=='\0') return;
432 Action_Tracker_Addons_Run(pcItem);
433 break;}
434
435 case BF_MSG_FILEPANEL_SHOW_ATTRDIALOG:{
436 BF_Node *poNode = Nodes_Focus();
437 if(!poNode) break;
438 BF_GUI_AttrDialog_Run(oPath,*poNode,this);
439 break;}
440
441 case BF_MSG_FILEPANEL_EDIT:
442 Action_Edit_File();
443 break;
444
445 case BF_MSG_FILEPANEL_TEXTVIEWER_START:{
446 Action_TextViewer_Start();
447 break;}
448 case BF_MSG_TEXTVIEWER_CLOSED:
449 BF_GUI_Func_PanelsShow(true);
450 MakeFocus();
451 break;
452
453 case BF_MSG_FILEPANEL_GOPATH_NOW:{
454 Action_GoPath_Run(po_Message);
455 break;}
456
457 case BF_MSG_FILEPANEL_SET_FRIENDPATH_TOEQUAL:{
458 LOCK_WIN();
459 BF_GUI_Panel *poFriend = poWinView->PanelOnTop(!bWinPos_OnLeft);
460 if(poFriend){
461 BMessage oMessage(BF_MSG_FILEPANEL_GOPATH_NOW);
462 BMessenger oMessenger(poFriend);
463 oMessage.AddString("bf_cPath",oPath.Path());
464 oMessenger.SendMessage(&oMessage);
465 }
466 break;}
467
468 case BF_MSG_FILEPANEL_REFRESH:{
469 Pub_GoPath(oPath.Path());
470 break;}
471
472 case BF_MSG_FILEPANEL_SHOW_INFOPANEL:{
473 if(!Enabled()) return;
474 BF_GUI_Panel *poFriendPanel = poWinView->PanelOnTop(!bWinPos_OnLeft);
475 if(poFriendPanel && strstr(poFriendPanel->Name(),"info_panel_")!=NULL){
476
477 poWinView->RemovePanel(poFriendPanel);
478 }else{
479
480 BF_GUI_FilesPanel_InfoPanel *poPanel = new BF_GUI_FilesPanel_InfoPanel(poWinView->PanelRect(!bWinPos_OnLeft),!bWinPos_OnLeft);
481 poWinView->AddPanel(poPanel);
482 SayFriend_About_CursorChanged_Ext();
483 }
484 break;}
485
486 case BF_MSG_FILEPANEL_IMAGEVIEWER_START:{
487 if(!Enabled()) return;
488 BF_GUI_Panel *poFriendPanel = poWinView->PanelOnTop(!bWinPos_OnLeft);
489 if(poFriendPanel && strstr(poFriendPanel->Name(),"image_panel_")!=NULL){
490
491 poWinView->RemovePanel(poFriendPanel);
492 }else{
493 BF_GUI_ImagePanel *poPanel = new BF_GUI_ImagePanel(poWinView->PanelRect(!bWinPos_OnLeft),"image",!bWinPos_OnLeft);
494 poWinView->AddPanel(poPanel);
495 SayFriend_About_CursorChanged_Ext();
496 }
497 break;}
498
499 case BF_MSG_NODEPANEL_MAKELINK_STARTDIALOG:
500 Action_MakeLinks_StartDialog();
501 break;
502 case BF_MSG_NODEPANEL_MAKELINK_STARTTASK:
503 BF_GUI_Func_PanelsEnable(true);
504 MakeFocus();
505 Action_MakeLinks_StartTask(po_Message);
506 break;
507
508 case BF_MSG_FILEPANEL_CHANGE_CASE:
509 Action_ChangeCase_0();
510 break;
511 case BF_MSG_FILEPANEL_CHANGE_CASE_RUN:
512 BF_GUI_Func_PanelsEnable(true);
513 MakeFocus();
514 Action_ChangeCase_1(po_Message);
515 break;
516
517 case BF_MSG_TO_PANEL_SET_PATH:{
518 const char *pcPath=NULL;
519 ASSERT(B_OK==po_Message->FindString("bf_cPath",&pcPath) && pcPath);
520 BF_Path oNewPath(pcPath);
521 NavGoPath(oNewPath);
522 break;}
523
524 case BF_MSG_FILEPANEL_DELETE_TRASH:
525 case BF_MSG_FILEPANEL_DELETE_VOID:
526 iTempDelType = po_Message->what;
527 ActionDelete_Start();
528 break;
529
530 case BF_MSG_FILEPANEL_SEARCH_START:
531 Action_Search_0();
532 break;
533 case BF_MSG_FILEPANEL_SEARCH_SETUP_CLOSE:
534 Action_Search_1(po_Message);
535 break;
536 case BF_MSG_FILEPANEL_SEARCH_CLOSE:{
537 printf("BF_MSG_FILEPANEL_SEARCH_CLOSE received\n");
538
539 BF_GUI_Func_PanelsEnable(true);
540 MakeFocus();
541
542 const char *pcItem = po_Message->FindString("results_code");
543 if(pcItem){
544 BEntry oEntry(pcItem);
545 BF_Path oNewPath(pcItem);
546 BL_String s;
547 oNewPath.LastDir(s);
548 oNewPath.GoParent();
549 NavGoPath(oNewPath,&s);
550 }
551 break;}
552
553 case BF_MSG_FILEPANEL_LOADNODES_STEP:{
554 iThreadLoading_Count = po_Message->FindInt32("bf_Count");
555 iThreadLoading_Index = po_Message->FindInt32("bf_Index");
556 printf("BF_MSG_FILEPANEL_ADDNODE received \n");
557 DrawListInfo(true);
558 break;}
559 case BF_MSG_FILEPANEL_LOADNODES_FINISHED:{
560 BF_NodeList *ploNode=NULL;
561 ASSERT(B_OK==po_Message->FindPointer("bf_Nodes",(void**)&ploNode) && ploNode);
562
563 BF_GUI_Func_PanelsEnable(true);
564 if(poSysKeysMenu) PrepareKeysMenu();
565
566 idThreadLoading = 0;
567 loNode.DeleteItems();
568 loNode.AddList(ploNode);
569 ploNode->MakeEmpty();
570 DELETE(ploNode);
571
572 loNode.Sort(iSortType );
573
574
575 if(sThreadLoading_FutureFocus!=""){
576 iNavCursorIndex = loNode.IndexByName(sThreadLoading_FutureFocus.String());
577
578 iNavFirstIndex = 0;
579 Invalidate(Bounds());
580 NavChangeCursor(iNavCursorIndex);
581 }else{
582
583 iNavCursorIndex = 0;
584 iNavFirstIndex = 0;
585 Invalidate(Bounds());
586 }
587 sThreadLoading_FutureFocus = "";
588
589
590 if(!(poSysSetup->MainStyle() & BF_SETUP_DEB_NOMONITORING)){
591
592 BF_Roster_StopAllMonitors(this);
593
594 BF_Roster_StartMonitor_Dir(oPath,this);
595 BF_Roster_StartMonitor_Nodes(loNode,this);
596 }
597
598 break;}
599
600 case B_NODE_MONITOR:{
601 HandlingMonitor(*po_Message);
602 break;}
603 default:
604 BF_GUI_NodePanel::MessageReceived(po_Message);
605 };
606 }
607
608 bool
609 BF_GUI_FilesPanel::NavChangeCursor(int i_NewCursor,bool b_DrawNodes,bool b_ChangeVars)
610 {
611 bool bRes = BF_GUI_NodePanel::NavChangeCursor(i_NewCursor,b_DrawNodes,b_ChangeVars);
612 SayFriend_About_CursorChanged_Ext();
613 return bRes;
614 }
615
616 void
617 BF_GUI_FilesPanel::SayFriend_About_CursorChanged_Ext()
618 {
619 BF_Node* poNodeFocus = Nodes_Focus();
620 if(!poNodeFocus) return ;
621
622 SayFriend_About_CursorChanged(oPath.Path(),poNodeFocus->sName.String(),poNodeFocus->iType);
623 }
624
625
626 void
627 BF_GUI_FilesPanel::ActionMakeDir_Run(BL_String & s_Title)
628 {
629
630 if(s_Title==""){
631 BF_Dialog_Alert_Sep(BF_DictAt(BF_DICT_ERROR),BF_DictAt(BF_DICT_FILES_MKFOLDEMPTY),NULL,this);
632 return;
633 }
634
635 if(oPath.IsVolumeReadOnly()){
636 BF_Dialog_Alert_Sep(BF_DictAt(BF_DICT_WARNING),BF_DictAt(BF_DICT_FILES_VOLREAD),NULL,this);
637 return;
638 }
639
640 BL_String s(oPath.Path());
641 s<<"/";
642 s<<s_Title;
643
644 status_t uRes = BF_Roster_MakeDir(s.String());
645 if(B_OK!=uRes){
646 BL_System_TranslError(uRes,s);
647 BF_Dialog_Alert_Sep(BF_DictAt(BF_DICT_FILES_ERRMKDIR),s.String(),NULL,this);
648 }
649 }
650
651 void
652 BF_GUI_FilesPanel::ActionRename_Run(BF_NodeCollection & lo_OpNode,BL_String & s_NewName)
653 {
654 BF_GUI_NodePanel::ActionRename_Run(lo_OpNode,s_NewName);
655 BF_GUI_OperRoster_AddTask( new BF_GUI_FilesPanel_Rename(oPath,lo_OpNode,s_NewName));
656 }
657
658 void
659 BF_GUI_FilesPanel::Nodes_Add(BF_Node *po_Node,BF_NodeCollection *plo_Node)
660 {
661 BF_GUI_NodePanel::Nodes_Add(po_Node,plo_Node);
662
663 if(!(poSysSetup->MainStyle() & BF_SETUP_DEB_NOMONITORING)){
664 if(po_Node) BF_Roster_StartMonitor_Node(po_Node,this);
665 if(plo_Node) BF_Roster_StartMonitor_Nodes(*plo_Node,this);
666 }
667 }
668
669 void
670 BF_GUI_FilesPanel::Nodes_Remove(BF_Node *po_Node,BF_NodeCollection *plo_Node)
671 {
672 BF_GUI_NodePanel::Nodes_Remove(po_Node,plo_Node);
673
674 if(!(poSysSetup->MainStyle() & BF_SETUP_DEB_NOMONITORING)){
675 if(po_Node) BF_Roster_StopMonitor_Node(po_Node,this);
676 if(plo_Node) BF_Roster_StopMonitor_Nodes(*plo_Node,this);
677 }
678 }
679
680 void
681 BF_GUI_FilesPanel::Action_ChangeCase_0()
682 {
683 BL_List *ploMenu = new BL_List();
684 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_FILES_TOLOWER),"lower"));
685 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_FILES_TOUPPER),"upper"));
686 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_FILES_CAPITALISE),"cap"));
687 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_FILES_CAPITALISEEW),"cap_ew"));
688 ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_CANCEL),"cancel"));
689
690 BF_Dialog_Alert_Sep(BF_DictAt(BF_DICT_FILES_CHANGENAMES),"Method:",ploMenu,this,"",BF_MSG_FILEPANEL_CHANGE_CASE_RUN);
691 }
692
693 void
694 BF_GUI_FilesPanel::Action_ChangeCase_1(BMessage *po_Message)
695 {
696 ASSERT(po_Message);
697
698 int32 iIndex=-1;
699 if(B_OK != po_Message->FindInt32("menu",&iIndex) || iIndex>3) return;
700
701 BF_NodeCollection *ploNode = Nodes_GetSelecting();
702 BF_GUI_OperRoster_AddTask( new BF_GUI_FilesPanel_ChangeCaseTask(oPath,*ploNode,iIndex));
703 DELETE(ploNode);
704 }
705
706 void
707 BF_GUI_FilesPanel::Action_MakeLinks_StartDialog()
708 {
709
710 BL_String sDestPath;
711 BF_GUI_Panel *poDestPanel = poWinView->PanelOnTop(!bWinPos_OnLeft);
712 sDestPath = poDestPanel?poDestPanel->Path():Path();
713
714
715 {
716
717 BF_GUI_Func_PanelsEnable(false);
718
719 BMessage oMessage(BF_MSG_NODEPANEL_MAKELINK_STARTTASK);
720 oMessage.AddPointer("bf_focus",this);
721
722 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
723 BF_DictAt(BF_DICT_FILES_MKLINKS),"dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
724 BRect oRect;
725
726 poDialog->LocalBounds(oRect);
727 oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
728 BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_PATH),poDialog,"bf_cPath",
729 sDestPath.String(),
730 B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE);
731
732 poDialog->AddOkCancelMenu(oRect);
733
734 poDialog->SetHeightFromLastChild();
735 poDialog->MoveToCenter( poWinView );
736 BF_GUI_Func_AddChildToMainView ( poDialog );
737 }
738 }
739
740 void
741 BF_GUI_FilesPanel::Action_MakeLinks_StartTask(BMessage *po_Message)
742 {
743 ASSERT(po_Message);
744 const char *pcDestPath=NULL;
745 if(B_OK!=po_Message->FindString("bf_cPath",&pcDestPath) || !pcDestPath) return;
746
747 BF_FilesPath oDestPath(pcDestPath);
748
749 BF_NodeCollection *ploNode = Nodes_GetSelecting();
750 BF_GUI_OperRoster_AddTask( new BF_GUI_FilesPanel_MakeLinksTask(oPath,oDestPath,*ploNode));
751 DELETE(ploNode);
752
753 }
754
755
756
757 void
758 BF_GUI_FilesPanel::Action_TextViewer_Start()
759 {
760
761
762
763
764
765
766
767
768 if(!Enabled()) return;
769 BF_Node *poNode = Nodes_Focus();
770 if(!poNode) return;
771
772 switch(poNode->iType){
773 case BF_NODE_TYPE_FILE:{
774 BString s;
775 s<<oPath.Path();
776 s<<"/";
777 s<<poNode->sName;
778
779 BF_GUI_TextViewer_Run(s.String());
780
781
782
783
784
785
786
787
788
789
790
791 break;}
792 }
793 }
794
795 void
796 BF_GUI_FilesPanel::Action_Run_File(BF_Node *po_Node)
797 {
798 if(!po_Node) return;
799
800
801 {
802 BL_String s(oPath.Path());
803 s<<"/";
804 s<<po_Node->Name();
805 if(B_OK==BF_Roster_RunEntry(BEntry(s.String()))) return;
806 }
807
808 if(BF_Roster_RunFile(oPath.Path(),po_Node->Name())==0) return;
809
810
811
812
813
814 Action_Alert(BF_DictAt(BF_DICT_ERROR),BF_DictAt(BF_DICT_FILES_CANTRUN));
815 return;
816
817
818
819 }
820
821 void
822 BF_GUI_FilesPanel::Action_Edit_File(BF_Node *po_Node)
823 {
824 if(!po_Node) po_Node = Nodes_Focus();
825 if(!po_Node || po_Node->iType!=BF_NODE_TYPE_FILE) return;
826
827 Action_Run_File(po_Node);
828 }
829
830 void
831 BF_GUI_FilesPanel::Action_CopyToBuffer()
832 {
833 BF_NodeCollection loSelNode;
834 loNode.GetSelecting(loSelNode);
835 if(loSelNode.CountItems()==0){
836 BF_Node *poNode = Nodes_Focus();
837 if(!poNode) return;
838 loSelNode.AddItem(poNode);
839 }
840
841 BL_String s;
842 BF_Node *poNode=NULL;
843 for(int i=0;i<loSelNode.CountItems();i++){
844 poNode = loSelNode.NodeAt(i);
845 if(i>0) s<<"\n";
846 s<<oPath.Path();
847 s<<"/";
848 s<<poNode->Name();
849 }
850
851 if(be_clipboard->Lock()){
852 be_clipboard->Clear();
853 BMessage *po = be_clipboard->Data();
854 po->AddData("text/plain", B_MIME_TYPE, s.String(),s.Length());
855 be_clipboard->Commit();
856 be_clipboard->Unlock();
857 }
858 }
859
860 void
861 BF_GUI_FilesPanel::Action_PasteFromBuffer()
862 {
863 BL_String sData;
864
865 Debug_Info("Action_PasteFromBuffer()");
866
867 if(be_clipboard->Lock()){
868 be_clipboard->Clear();
869 BMessage *po = be_clipboard->Data();
870
871 const char *pcText;
872 int32 iTextLen=0;;
873 status_t uRes = po->FindData("text/plain", B_MIME_TYPE,(const void **)&pcText, &iTextLen);
874 be_clipboard->Commit();
875 be_clipboard->Unlock();
876
877 if(!pcText) sData = pcText;
878 }
879 if(sData=="") return;
880
881 Debug_Info(sData.String());
882 }
883
884 void
885 BF_GUI_FilesPanel::Action_PasteFromBuffer_Step2(BMessage *po_Message)
886 {
887
888 }
889
890 void
891 BF_GUI_FilesPanel::Action_GoPath_StartDialog()
892 {
893
894 {
895
896 BF_GUI_Func_PanelsEnable(false);
897
898 BMessage oMessage(BF_MSG_FILEPANEL_GOPATH_RUN);
899 oMessage.AddPointer("bf_focus",this);
900
901 BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
902 BF_DictAt(BF_DICT_GOTO),"dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
903 BRect oRect;
904
905 poDialog->LocalBounds(oRect);
906 oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
907 BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_PATH),poDialog,"bf_cPath",
908 "",
909 B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE);
910
911 poDialog->AddOkCancelMenu(oRect);
912
913 poDialog->SetHeightFromLastChild();
914 poDialog->MoveToCenter( poWinView );
915 BF_GUI_Func_AddChildToMainView( poDialog );
916 }
917 }
918
919 void
920 BF_GUI_FilesPanel::Action_GoPath_Run(BMessage *po_Message)
921 {
922 ASSERT(po_Message);
923 const char *pcDestPath=NULL;
924 if(B_OK!=po_Message->FindString("bf_cPath",&pcDestPath) || !pcDestPath) return;
925
926 if(oPath==pcDestPath) return;
927
928
929 status_t uRes = BF_Roster_MakeDir(pcDestPath);
930
931 if(uRes!=B_OK){
932 BF_Dialog_Alert_Sep_Error(uRes,this);
933 return;
934 }
935
936 Pub_GoPath(pcDestPath);
937 }
938