diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
index a504101..e1fc0b5 100644
a
|
b
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
26 | 26 | used in advertising or otherwise to promote the sale, use or other dealings in |
27 | 27 | this Software without prior written authorization from Be Incorporated. |
28 | 28 | |
29 | | Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks |
30 | | of Be Incorporated in the United States and other countries. Other brand product |
31 | | names are registered trademarks or trademarks of their respective holders. |
| 29 | Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered |
| 30 | trademarks of Be Incorporated in the United States and other countries. Other |
| 31 | brand product names are registered trademarks or trademarks of their respective |
| 32 | holders. |
32 | 33 | All rights reserved. |
33 | 34 | */ |
34 | 35 | |
… |
… |
All rights reserved.
|
74 | 75 | using std::max; |
75 | 76 | |
76 | 77 | #ifdef DB_ADDONS |
77 | | // Add-on support |
| 78 | // Add-on support |
78 | 79 | // |
79 | | // Item - internal item list (node, eref, etc) |
80 | | // Icon - physical replicant handed to the DeskbarClass class |
81 | | // AddOn - attribute based add-on |
| 80 | // Item - internal item list (node, eref, etc) |
| 81 | // Icon - physical replicant handed to the DeskbarClass class |
| 82 | // AddOn - attribute based add-on |
82 | 83 | |
83 | 84 | const char* const kInstantiateItemCFunctionName = "instantiate_deskbar_item"; |
84 | 85 | const char* const kInstantiateEntryCFunctionName = "instantiate_deskbar_entry"; |
85 | 86 | const char* const kDeskbarSecurityCodeFile = "Deskbar_security_code"; |
86 | 87 | const char* const kDeskbarSecurityCodeAttr = "be:deskbar_security_code"; |
87 | 88 | const char* const kStatusPredicate = "be:deskbar_item_status"; |
88 | | const char* const kEnabledPredicate = "be:deskbar_item_status=enabled"; |
89 | | const char* const kDisabledPredicate = "be:deskbar_item_status=disabled"; |
| 89 | const char* const kEnabledPredicate = "be:deskbar_item_status = enabled"; |
| 90 | const char* const kDisabledPredicate = "be:deskbar_item_status = disabled"; |
90 | 91 | |
91 | 92 | float sMinimumWindowWidth = kGutter + kMinimumTrayWidth + kDragRegionWidth; |
92 | 93 | |
… |
… |
TReplicantTray::DealWithClock(bool showClock)
|
240 | 241 | } |
241 | 242 | |
242 | 243 | |
243 | | /*! |
244 | | Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth |
| 244 | /*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth |
245 | 245 | if not in multirowmode and greater than kMinimumReplicantCount |
246 | 246 | the width should be calculated based on the actual |
247 | 247 | replicant widths |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
255 | 255 | if (fShelf->CountReplicants() > 0) |
256 | 256 | height = fRightBottomReplicant.bottom; |
257 | 257 | |
258 | | // the height will be uniform for the number of rows |
259 | | // necessary to show all the reps + any gutters |
260 | | // necessary for spacing |
| 258 | // the height will be uniform for the number of rows necessary to show |
| 259 | // all the reps + any gutters necessary for spacing |
261 | 260 | int32 rowCount = (int32)(height / kMaxReplicantHeight); |
262 | 261 | height = kGutter + (rowCount * kMaxReplicantHeight) |
263 | 262 | + ((rowCount - 1) * kIconGap) + kGutter; |
264 | 263 | height = max(kMinimumTrayHeight, height); |
265 | 264 | width = fMinimumTrayWidth; |
266 | 265 | } else { |
267 | | // if last replicant overruns clock then |
268 | | // resize to accomodate |
| 266 | // if last replicant overruns clock then resize to accomodate |
269 | 267 | if (fShelf->CountReplicants() > 0) { |
270 | 268 | if (fBarView->ShowingClock() |
271 | 269 | && fRightBottomReplicant.right + 6 >= fClock->Frame().left) { |
… |
… |
TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
|
274 | 272 | } else |
275 | 273 | width = fRightBottomReplicant.right + 3; |
276 | 274 | } |
| 275 | |
277 | 276 | // this view has a fixed minimum width |
278 | 277 | width = max(fMinimumTrayWidth, width); |
279 | 278 | } |
280 | 279 | |
281 | 280 | *preferredWidth = width; |
282 | | // add 2 for the border |
| 281 | // add 1 for the border |
283 | 282 | *preferredHeight = height + 1; |
284 | 283 | } |
285 | 284 | |
… |
… |
TReplicantTray::ShowReplicantMenu(BPoint point)
|
350 | 349 | BPopUpMenu* menu = new BPopUpMenu("", false, false); |
351 | 350 | menu->SetFont(be_plain_font); |
352 | 351 | |
353 | | // If the clock is visible, show the extended menu |
354 | | // otheriwse, show "Show Time". |
| 352 | // If clock is visible show the extended menu, otherwise show "Show Time" |
355 | 353 | |
356 | 354 | if (fBarView->ShowingClock()) |
357 | 355 | fClock->ShowClockOptions(ConvertToScreen(point)); |
… |
… |
TReplicantTray::MouseDown(BPoint where)
|
375 | 373 | DumpList(fItemList); |
376 | 374 | #endif |
377 | 375 | |
378 | | uint32 buttons; |
| 376 | uint32 buttons; |
379 | 377 | |
380 | 378 | Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); |
381 | 379 | if (buttons == B_SECONDARY_MOUSE_BUTTON) { |
… |
… |
TReplicantTray::InitAddOnSupport()
|
412 | 410 | { |
413 | 411 | // list to maintain refs to each rep added/deleted |
414 | 412 | fItemList = new BList(); |
415 | | |
416 | 413 | bool haveKey = false; |
417 | | BPath path; |
| 414 | BPath path; |
| 415 | |
418 | 416 | if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) == B_OK) { |
419 | 417 | path.Append(kDeskbarSecurityCodeFile); |
420 | 418 | |
421 | | BFile file(path.Path(),B_READ_ONLY); |
| 419 | BFile file(path.Path(), B_READ_ONLY); |
422 | 420 | if (file.InitCheck() == B_OK |
423 | | && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)) |
| 421 | && file.Read(&fDeskbarSecurityCode, sizeof(fDeskbarSecurityCode)) |
424 | 422 | == sizeof(fDeskbarSecurityCode)) |
425 | 423 | haveKey = true; |
426 | 424 | } |
… |
… |
TReplicantTray::InitAddOnSupport()
|
443 | 441 | } |
444 | 442 | } |
445 | 443 | |
446 | | // for each volume currently mounted |
447 | | // index the volume with our indices |
| 444 | // for each volume currently mounted index the volume with our indices |
448 | 445 | BVolumeRoster roster; |
449 | 446 | BVolume volume; |
450 | 447 | while (roster.GetNextVolume(&volume) == B_OK) { |
… |
… |
TReplicantTray::RunAddOnQuery(BVolume* volume, const char* predicate)
|
488 | 485 | || fs_stat_index(volume->Device(), kStatusPredicate, &info) != 0) |
489 | 486 | return; |
490 | 487 | |
491 | | // run a new query on a specific volume |
492 | | // make it live |
| 488 | // run a new query on a specific volume and make it live |
493 | 489 | BQuery query; |
494 | 490 | query.SetVolume(volume); |
495 | 491 | query.SetPredicate(predicate); |
… |
… |
TReplicantTray::NodeExists(node_ref& nodeRef)
|
557 | 553 | } |
558 | 554 | |
559 | 555 | |
560 | | /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received |
| 556 | /*! This handles B_NODE_MONITOR & B_QUERY_UPDATE messages received |
561 | 557 | for the registered add-ons. |
562 | 558 | */ |
563 | 559 | void |
… |
… |
TReplicantTray::HandleEntryUpdate(BMessage* message)
|
697 | 693 | } |
698 | 694 | |
699 | 695 | |
700 | | /*! |
701 | | The add-ons must support the exported C function API |
| 696 | /*! The add-ons must support the exported C function API |
702 | 697 | if they do, they will be loaded and added to deskbar |
703 | 698 | primary function is the Instantiate function |
704 | 699 | */ |
… |
… |
TReplicantTray::MoveItem(entry_ref* ref, ino_t toDirectory)
|
883 | 878 | } |
884 | 879 | } |
885 | 880 | |
886 | | #endif // add-on support |
| 881 | #endif // add-on support |
887 | 882 | |
888 | 883 | // external add-on API routines |
889 | 884 | // called using the new BDeskbar class |
… |
… |
TReplicantTray::IconCount() const
|
989 | 984 | } |
990 | 985 | |
991 | 986 | |
992 | | /*! Message must contain an archivable view for later rehydration. |
| 987 | /*! Message must contain an archivable view for later rehydration. |
993 | 988 | This function takes over ownership of the provided message on success |
994 | 989 | only. |
995 | 990 | Returns the current replicant ID. |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1008 | 1003 | ref = *addOn; |
1009 | 1004 | } else { |
1010 | 1005 | const char* signature; |
| 1006 | |
1011 | 1007 | status_t status = archive->FindString("add_on", &signature); |
1012 | 1008 | if (status == B_OK) { |
1013 | 1009 | BRoster roster; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1028 | 1024 | return status; |
1029 | 1025 | |
1030 | 1026 | BEntry entry(&ref, true); |
1031 | | // ToDo: this resolves an eventual link for the item |
1032 | | // being added - this is okay for now, but in multi-user |
1033 | | // environments, one might want to have links that |
1034 | | // carry the be:deskbar_item_status attribute |
| 1027 | // TODO: this resolves an eventual link for the item being added - this |
| 1028 | // is okay for now, but in multi-user environments, one might want to |
| 1029 | // have links that carry the be:deskbar_item_status attribute |
1035 | 1030 | status = entry.InitCheck(); |
1036 | 1031 | if (status != B_OK) |
1037 | 1032 | return status; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1041 | 1036 | archive->what = 0; |
1042 | 1037 | |
1043 | 1038 | BRect originalBounds = archive->FindRect("_frame"); |
1044 | | // this is a work-around for buggy replicants that change their |
1045 | | // size in AttachedToWindow() (such as "SVM") |
| 1039 | // this is a work-around for buggy replicants that change their size in |
| 1040 | // AttachedToWindow() (such as "SVM") |
1046 | 1041 | |
1047 | | // !! check for name collisions? |
| 1042 | // TODO: check for name collisions? |
1048 | 1043 | status = fShelf->AddReplicant(archive, BPoint(1, 1)); |
1049 | 1044 | if (status != B_OK) |
1050 | 1045 | return status; |
… |
… |
TReplicantTray::AddIcon(BMessage* archive, int32* id, const entry_ref* addOn)
|
1070 | 1065 | // add the item to the add-on list |
1071 | 1066 | |
1072 | 1067 | AddItem(*id, nodeRef, entry, addOn != NULL); |
1073 | | return B_OK; |
| 1068 | return B_OK; |
1074 | 1069 | } |
1075 | 1070 | |
1076 | 1071 | |
… |
… |
TReplicantTray::RealReplicantAdjustment(int32 startIndex)
|
1129 | 1124 | float width, height; |
1130 | 1125 | GetPreferredSize(&width, &height); |
1131 | 1126 | if (oldWidth != width || oldHeight != height) { |
1132 | | // resize view to accomodate the replicants |
1133 | | // redraw as necessary |
| 1127 | // resize view to accomodate the replicants, redraw as necessary |
1134 | 1128 | AdjustPlacement(); |
1135 | 1129 | } |
1136 | 1130 | } |
… |
… |
TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex)
|
1154 | 1148 | } |
1155 | 1149 | } |
1156 | 1150 | } else { |
1157 | | int32 count = fShelf->CountReplicants()-1; |
| 1151 | int32 count = fShelf->CountReplicants() - 1; |
1158 | 1152 | int32 localid; |
1159 | 1153 | for (int32 repIndex = count ; repIndex >= 0 ; repIndex--) { |
1160 | 1154 | fShelf->ReplicantAt(repIndex, &view, (uint32*)&localid); |
… |
… |
TReplicantTray::ViewAt(int32* index, int32* id, int32 target, bool byIndex)
|
1165 | 1159 | } |
1166 | 1160 | } |
1167 | 1161 | } |
1168 | | |
1169 | 1162 | return NULL; |
1170 | 1163 | } |
1171 | 1164 | |
… |
… |
TReplicantTray::ViewAt(int32* index, int32* id, const char* name)
|
1189 | 1182 | return view; |
1190 | 1183 | } |
1191 | 1184 | } |
1192 | | |
1193 | 1185 | return NULL; |
1194 | 1186 | } |
1195 | 1187 | |
… |
… |
TReplicantTray::SetMultiRow(bool state)
|
1353 | 1345 | // #pragma mark - |
1354 | 1346 | |
1355 | 1347 | |
1356 | | /*! Draggable region that is asynchronous so that dragging does not block |
| 1348 | /*! Draggable region that is asynchronous so that dragging does not block |
1357 | 1349 | other activities. |
1358 | 1350 | */ |
1359 | 1351 | TDragRegion::TDragRegion(TBarView* parent, BView* child) |
… |
… |
bool
|
1583 | 1575 | TDragRegion::SwitchModeForRect(BPoint mouse, BRect rect, |
1584 | 1576 | bool newVertical, bool newLeft, bool newTop, int32 newState) |
1585 | 1577 | { |
1586 | | if (!rect.Contains(mouse)) |
| 1578 | if (!rect.Contains(mouse)) { |
1587 | 1579 | // not our rect |
1588 | 1580 | return false; |
| 1581 | } |
1589 | 1582 | |
1590 | | if (newVertical == fBarView->Vertical() |
1591 | | && newLeft == fBarView->Left() |
1592 | | && newTop == fBarView->Top() |
1593 | | && newState == fBarView->State()) |
| 1583 | if (newVertical == fBarView->Vertical() && newLeft == fBarView->Left() |
| 1584 | && newTop == fBarView->Top() && newState == fBarView->State()) { |
1594 | 1585 | // already in the correct mode |
1595 | 1586 | return true; |
| 1587 | } |
1596 | 1588 | |
1597 | 1589 | fBarView->ChangeState(newState, newVertical, newLeft, newTop); |
1598 | 1590 | return true; |