2 * Copyright 2009, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
14 static void Error(BView
*view
, status_t status
, bool unlock
=false)
19 BString
s(strerror(status
));
20 alert
= new BAlert("Error", s
.String(), "OK");
21 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
26 process_refs(entry_ref dir
, BMessage
* refs
, void* /*reserved*/)
31 BPoseView
*view
= NULL
;
32 BMessage poseViewBackup
;
33 BMessage poseViewColumnBackup
;
34 uint32 poseViewModeBackup
;
35 BString windowTitleBackup
;
37 refs
->PrintToStream();
39 status
= refs
->FindMessenger("TrackerViewToken", &msgr
);
46 if (!msgr
.LockTarget()) {
51 status
= B_BAD_HANDLER
;
52 view
= dynamic_cast<BPoseView
*>(msgr
.Target(NULL
));
57 if (dynamic_cast<BWindow
*>(view
->Looper()) == NULL
) {
58 Error(view
, status
, true);
62 windowTitleBackup
= view
->Window()->Title();
64 view
->SaveColumnState(poseViewColumnBackup
);
65 view
->SaveState(poseViewBackup
);
66 view
->SetDragEnabled(false);
67 view
->SetSelectionRectEnabled(false);
68 view
->SetPoseEditing(false);
69 poseViewModeBackup
= view
->ViewMode();
71 view
->SetViewMode(kIconMode
);
72 view
->ShowBarberPole();
76 alert
= new BAlert("Error", "IconVader:\nClick on the icons to get points."
77 "\nAvoid symlinks!", "OK");
78 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
85 if (!msgr
.LockTarget()) {
91 for (int32 i
= 0; (pose
= view
->PoseAtIndex(i
)); i
++) {
92 if (pose
->IsSelected()) {
93 if (pose
->TargetModel()->IsFile())
95 if (pose
->TargetModel()->IsDirectory())
97 if (pose
->TargetModel()->IsSymLink())
101 BPoint location
= pose
->Location(view
);
102 location
.x
+= ((rand() % 20) - 10);
103 location
.y
+= ((rand() % 20) - 10);
104 pose
->SetLocation(location
, view
);
107 view
->CheckPoseVisibility();
111 BString
str("Score: ");
113 view
->Window()->SetTitle(str
.String());
115 view
->UnlockLooper();
119 BString
scoreStr("You scored ");
120 scoreStr
<< score
<< " points!";
121 alert
= new BAlert("Error", scoreStr
.String(), "Cool!");
122 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
126 if (!msgr
.LockTarget()) {
132 status = B_BAD_HANDLER;
133 view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
138 view
->HideBarberPole();
139 view
->SetViewMode(poseViewModeBackup
);
140 view
->RestoreState(poseViewBackup
);
141 view
->RestoreColumnState(poseViewColumnBackup
);
143 view
->Window()->SetTitle(windowTitleBackup
.String());
147 TrackerViewToken = BMessenger(port=32004, team=591, target=direct:0x131)
151 view
->UnlockLooper();