diff --git a/src/apps/workspaces/Workspaces.cpp b/src/apps/workspaces/Workspaces.cpp
index e3415d0..874e982 100644
a
|
b
|
|
14 | 14 | #include <Alert.h> |
15 | 15 | #include <Application.h> |
16 | 16 | #include <Catalog.h> |
| 17 | #include <Deskbar.h> |
17 | 18 | #include <Dragger.h> |
18 | 19 | #include <Entry.h> |
19 | 20 | #include <File.h> |
… |
… |
|
40 | 41 | #define B_TRANSLATE_CONTEXT "Workspaces" |
41 | 42 | |
42 | 43 | |
| 44 | static const char* kDeskbarItemName = "workspaces"; |
43 | 45 | static const char* kSignature = "application/x-vnd.Be-WORK"; |
| 46 | static const char* kDeskbarSignature = "application/x-vnd.Be-TSKB"; |
44 | 47 | static const char* kScreenPrefletSignature = "application/x-vnd.Haiku-Screen"; |
45 | 48 | static const char* kOldSettingFile = "Workspace_data"; |
46 | 49 | static const char* kSettingsFile = "Workspaces_settings"; |
… |
… |
static const uint32 kMsgToggleTitle = 'tgTt';
|
50 | 53 | static const uint32 kMsgToggleBorder = 'tgBd'; |
51 | 54 | static const uint32 kMsgToggleAutoRaise = 'tgAR'; |
52 | 55 | static const uint32 kMsgToggleAlwaysOnTop = 'tgAT'; |
| 56 | static const uint32 kMsgToggleLiveInDeskbar = 'tgDb'; |
53 | 57 | |
54 | 58 | static const float kScreenBorderOffset = 10.0; |
55 | 59 | |
| 60 | extern "C" _EXPORT BView* instantiate_deskbar_item(); |
56 | 61 | |
57 | 62 | class WorkspacesSettings { |
58 | 63 | public: |
… |
… |
class WorkspacesSettings {
|
89 | 94 | |
90 | 95 | class WorkspacesView : public BView { |
91 | 96 | public: |
92 | | WorkspacesView(BRect frame); |
| 97 | WorkspacesView(BRect frame, bool showDragger); |
93 | 98 | WorkspacesView(BMessage* archive); |
94 | 99 | ~WorkspacesView(); |
95 | 100 | |
… |
… |
class WorkspacesView : public BView {
|
106 | 111 | virtual void MouseDown(BPoint where); |
107 | 112 | |
108 | 113 | private: |
109 | | void _AboutRequested(); |
110 | | |
111 | 114 | void _UpdateParentClipping(); |
112 | 115 | void _ExcludeFromParentClipping(); |
113 | 116 | void _CleanupParentClipping(); |
… |
… |
class WorkspacesApp : public BApplication {
|
142 | 145 | WorkspacesApp(); |
143 | 146 | virtual ~WorkspacesApp(); |
144 | 147 | |
145 | | virtual void AboutRequested(); |
146 | 148 | virtual void ArgvReceived(int32 argc, char **argv); |
147 | 149 | virtual void ReadyToRun(); |
148 | 150 | |
… |
… |
WorkspacesSettings::SetWindowFrame(BRect frame)
|
331 | 333 | // #pragma mark - |
332 | 334 | |
333 | 335 | |
334 | | WorkspacesView::WorkspacesView(BRect frame) |
| 336 | WorkspacesView::WorkspacesView(BRect frame, bool showDragger=true) |
335 | 337 | : |
336 | | BView(frame, "workspaces", B_FOLLOW_ALL, |
| 338 | BView(frame, kDeskbarItemName, B_FOLLOW_ALL, |
337 | 339 | kWorkspacesViewFlag | B_FRAME_EVENTS), |
338 | 340 | fParentWhichDrawsOnChildren(NULL), |
339 | 341 | fCurrentFrame(frame) |
340 | 342 | { |
341 | | frame.OffsetTo(B_ORIGIN); |
342 | | frame.top = frame.bottom - 7; |
343 | | frame.left = frame.right - 7; |
344 | | BDragger* dragger = new BDragger(frame, this, |
345 | | B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); |
346 | | AddChild(dragger); |
| 343 | if(showDragger) { |
| 344 | frame.OffsetTo(B_ORIGIN); |
| 345 | frame.top = frame.bottom - 7; |
| 346 | frame.left = frame.right - 7; |
| 347 | BDragger* dragger = new BDragger(frame, this, |
| 348 | B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); |
| 349 | AddChild(dragger); |
| 350 | } |
347 | 351 | } |
348 | 352 | |
349 | 353 | |
… |
… |
WorkspacesView::Archive(BMessage* archive, bool deep) const
|
391 | 395 | |
392 | 396 | |
393 | 397 | void |
394 | | WorkspacesView::_AboutRequested() |
395 | | { |
396 | | BString text = B_TRANSLATE("Workspaces\n" |
397 | | "written by %1, and %2.\n\n" |
398 | | "Copyright %3, Haiku.\n\n" |
399 | | "Send windows behind using the Option key. " |
400 | | "Move windows to front using the Control key.\n"); |
401 | | text.ReplaceFirst("%1", "François Revol, Axel Dörfler"); |
402 | | text.ReplaceFirst("%2", "Matt Madia"); |
403 | | text.ReplaceFirst("%3", "2002-2008"); |
404 | | |
405 | | BAlert *alert = new BAlert("about", text.String(), B_TRANSLATE("OK")); |
406 | | BTextView *view = alert->TextView(); |
407 | | BFont font; |
408 | | |
409 | | view->SetStylable(true); |
410 | | |
411 | | view->GetFont(&font); |
412 | | font.SetSize(18); |
413 | | font.SetFace(B_BOLD_FACE); |
414 | | view->SetFontAndColor(0, 10, &font); |
415 | | |
416 | | alert->Go(); |
417 | | } |
418 | | |
419 | | |
420 | | void |
421 | 398 | WorkspacesView::AttachedToWindow() |
422 | 399 | { |
423 | 400 | BView* parent = Parent(); |
… |
… |
void
|
490 | 467 | WorkspacesView::MessageReceived(BMessage* message) |
491 | 468 | { |
492 | 469 | switch (message->what) { |
493 | | case B_ABOUT_REQUESTED: |
494 | | _AboutRequested(); |
495 | | break; |
496 | | |
497 | 470 | case kMsgChangeCount: |
498 | 471 | be_roster->Launch(kScreenPrefletSignature); |
499 | 472 | break; |
… |
… |
WorkspacesView::MouseDown(BPoint where)
|
576 | 549 | new BMessage(kMsgToggleAutoRaise))); |
577 | 550 | if (window->IsAutoRaising()) |
578 | 551 | item->SetMarked(true); |
| 552 | if (be_roster->IsRunning(kDeskbarSignature)) { |
| 553 | menu->AddItem(item = new BMenuItem(B_TRANSLATE("Live in the Deskbar"), |
| 554 | new BMessage(kMsgToggleLiveInDeskbar))); |
| 555 | BDeskbar deskbar; |
| 556 | item->SetMarked(deskbar.HasItem(kDeskbarItemName)); |
| 557 | } |
579 | 558 | |
580 | 559 | menu->AddSeparatorItem(); |
581 | | menu->AddItem(new BMenuItem(B_TRANSLATE("About Workspaces" |
582 | | B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); |
583 | 560 | menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), |
584 | 561 | new BMessage(B_QUIT_REQUESTED))); |
585 | 562 | menu->SetTargetForItems(window); |
… |
… |
WorkspacesWindow::MessageReceived(BMessage *message)
|
712 | 689 | break; |
713 | 690 | } |
714 | 691 | |
715 | | case B_ABOUT_REQUESTED: |
716 | | PostMessage(message, ChildAt(0)); |
717 | | break; |
718 | | |
719 | 692 | case kMsgToggleBorder: |
720 | 693 | { |
721 | 694 | bool enable = false; |
… |
… |
WorkspacesWindow::MessageReceived(BMessage *message)
|
772 | 745 | fSettings->SetAlwaysOnTop(enable); |
773 | 746 | break; |
774 | 747 | } |
| 748 | |
| 749 | case kMsgToggleLiveInDeskbar: |
| 750 | { |
| 751 | BDeskbar deskbar; |
| 752 | if (deskbar.HasItem (kDeskbarItemName)) |
| 753 | deskbar.RemoveItem (kDeskbarItemName); |
| 754 | else { |
| 755 | entry_ref ref; |
| 756 | be_roster->FindApp(kSignature, &ref); |
| 757 | deskbar.AddItem(&ref); |
| 758 | } |
| 759 | break; |
| 760 | } |
775 | 761 | |
776 | 762 | default: |
777 | 763 | BWindow::MessageReceived(message); |
… |
… |
WorkspacesApp::~WorkspacesApp()
|
820 | 806 | |
821 | 807 | |
822 | 808 | void |
823 | | WorkspacesApp::AboutRequested() |
824 | | { |
825 | | fWindow->PostMessage(B_ABOUT_REQUESTED); |
826 | | } |
827 | | |
828 | | |
829 | | void |
830 | 809 | WorkspacesApp::Usage(const char *programName) |
831 | 810 | { |
832 | 811 | printf(B_TRANSLATE("Usage: %s [options] [workspace]\n" |
… |
… |
WorkspacesApp::ArgvReceived(int32 argc, char **argv)
|
904 | 883 | } |
905 | 884 | |
906 | 885 | |
| 886 | BView* instantiate_deskbar_item() |
| 887 | { |
| 888 | return new WorkspacesView(BRect (0, 0, 75, 15), false); |
| 889 | } |
| 890 | |
| 891 | |
907 | 892 | void |
908 | 893 | WorkspacesApp::ReadyToRun() |
909 | 894 | { |