Ticket #1006: ticket_1006.diff
File ticket_1006.diff, 25.4 KB (added by , 14 years ago) |
---|
-
BackgroundsView.h
4 4 * 5 5 * Authors: 6 6 * Jerome Duval (jerome.duval@free.fr) 7 * Markku Hyppönen, make.hypponen@pp.inet.fi 7 8 */ 8 9 #ifndef BACKGROUNDS_VIEW_H 9 10 #define BACKGROUNDS_VIEW_H … … 40 41 41 42 class BGImageMenuItem : public BMenuItem { 42 43 public: 43 BGImageMenuItem(const char* label, int32 imageIndex, 44 BMessage* message, char shortcut = 0, 45 uint32 modifiers = 0); 44 BGImageMenuItem(const char* label, 45 int32 imageIndex, BMessage* message, 46 char shortcut = 0, uint32 modifiers = 0); 47 int32 ImageIndex() { return fImageIndex; } 46 48 47 int32 ImageIndex() { return fImageIndex; }48 49 49 private: 50 int32 fImageIndex;50 int32 fImageIndex; 51 51 }; 52 52 53 53 … … 65 65 66 66 class FramePart : public BView { 67 67 public: 68 FramePart(int32 part); 68 FramePart(int32 part); 69 virtual void Draw(BRect rect); 70 void SetDesktop(bool isDesktop); 69 71 70 void Draw(BRect rect);71 void SetDesktop(bool isDesktop);72 73 72 private: 74 void _SetSizeAndAlignment();73 void _SetSizeAndAlignment(); 75 74 76 int32 fFramePart;77 bool fIsDesktop;75 int32 fFramePart; 76 bool fIsDesktop; 78 77 }; 79 78 80 79 81 80 class PreView : public BControl { 82 81 public: 83 PreView();82 PreView(); 84 83 85 BPoint fPoint;86 BRect fImageBounds;84 BPoint fPoint; 85 BRect fImageBounds; 87 86 88 87 protected: 89 voidMouseDown(BPoint point);90 voidMouseUp(BPoint point);91 voidMouseMoved(BPoint point, uint32 transit,88 virtual void MouseDown(BPoint point); 89 virtual void MouseUp(BPoint point); 90 virtual void MouseMoved(BPoint point, uint32 transit, 92 91 const BMessage* message); 93 voidAttachedToWindow();92 virtual void AttachedToWindow(); 94 93 95 BPoint fOldPoint; 96 float fXRatio; 97 float fYRatio; 98 display_mode fMode; 99 100 BCursor fMoveHandCursor; 94 BPoint fOldPoint; 95 float fXRatio; 96 float fYRatio; 97 display_mode fMode; 98 BCursor fMoveHandCursor; 101 99 }; 102 100 103 101 104 class BackgroundsView : public BBox{102 class Settings { 105 103 public: 106 BackgroundsView(); 107 ~BackgroundsView(); 104 Settings(); 108 105 109 void AllAttached(); 110 void MessageReceived(BMessage* msg); 106 int32 fWorkspace; 107 BackgroundImage* fImage; 108 BackgroundImage::BackgroundImageInfo* fInfo; 109 rgb_color fColor; 110 bool fIsAllWorkspacesSelected; 111 111 112 void RefsReceived(BMessage* msg);112 }; 113 113 114 void SaveSettings(); 115 void WorkspaceActivated(uint32 oldWorkspaces, 116 bool active); 117 int32 AddImage(BPath path); 118 Image* GetImage(int32 imageIndex); 114 class Controls { 115 public: 116 Controls(); 119 117 120 bool FoundPositionSetting(); 118 int32 fWorkspace; 119 rgb_color fColor; 120 bool fTextWidgetLabelOutline; 121 int32 fImageIndex; 122 int32 fPlacementIndex; 123 float fOffsetX; 124 float fOffsetY; 125 }; 121 126 122 protected:123 void _Save();124 void _NotifyServer();125 void _LoadSettings();126 void _LoadDesktopFolder();127 void _LoadDefaultFolder();128 void _LoadFolder(bool isDesktop);129 void _LoadRecentFolder(BPath path);130 void _UpdateWithCurrent();131 void _UpdatePreview();132 void _UpdateButtons();133 void _SetDesktop(bool isDesktop);134 int32 _AddPath(BPath path);135 127 136 static int32 _NotifyThread(void* data); 128 class BackgroundsView : public BBox { 129 public: 130 BackgroundsView(); 131 ~BackgroundsView(); 132 virtual void AllAttached(); 133 virtual void MessageReceived(BMessage* msg); 134 void RefsReceived(BMessage* msg); 135 void SaveSettings(); 136 void WorkspaceActivated(uint32 workspace, 137 bool active); 138 int32 AddImage(BPath path); 139 Image* GetImage(int32 imageIndex); 140 bool FoundPositionSetting(); 137 141 142 protected: 143 void _Save(); 144 void _Revert(); 145 void _RevertTo(BackgroundImage*& image, 146 BackgroundImage::BackgroundImageInfo*& info, 147 rgb_color& color); 148 void _NotifyServer(); 149 void _LoadSettings(); 150 void _LoadDesktopFolder(); 151 void _LoadDefaultFolder(); 152 void _LoadFolder(bool isDesktop); 153 void _LoadRecentFolder(BPath path); 154 void _UpdateWithCurrent(); 155 void _UpdatePreview(); 156 void _UpdateButtons(); 157 void _SetDesktop(bool isDesktop); 158 int32 _AddPath(BPath path); 159 static int32 _NotifyThread(void* data); 138 160 BGImageMenuItem* _FindImageItem(const int32 imageIndex); 161 bool _AddItem(BGImageMenuItem* item); 162 BackgroundImage::Mode _FindPlacementMode(); 163 void _SetInitialSettings(); 164 void _SetControlSettings(int32 workspace); 165 Settings* _GetInitialSettings(int32 workspace); 166 Controls* _GetControlSettings(int32 workspace, 167 bool remove); 168 void _ResetControlSettings(); 139 169 140 bool _AddItem(BGImageMenuItem* item); 141 142 BackgroundImage::Mode _FindPlacementMode(); 143 144 BColorControl* fPicker; 145 BButton* fApply; 146 BButton* fRevert; 147 BCheckBox* fIconLabelOutline; 148 BMenu* fPlacementMenu; 149 BMenu* fImageMenu; 150 BMenu* fWorkspaceMenu; 151 BTextControl* fXPlacementText; 152 BTextControl* fYPlacementText; 153 PreView* fPreView; 154 BBox* fPreview; 155 BFilePanel* fFolderPanel; 156 ImageFilePanel* fPanel; 157 170 BColorControl* fPicker; 171 BButton* fApply; 172 BButton* fRevert; 173 BCheckBox* fIconLabelOutline; 174 BMenu* fPlacementMenu; 175 BMenu* fImageMenu; 176 BMenu* fWorkspaceMenu; 177 BTextControl* fXPlacementText; 178 BTextControl* fYPlacementText; 179 PreView* fPreView; 180 BBox* fPreview; 181 BFilePanel* fFolderPanel; 182 ImageFilePanel* fPanel; 158 183 BackgroundImage* fCurrent; 159 160 BackgroundImage::BackgroundImageInfo* fCurrentInfo; 161 162 entry_ref fCurrentRef; 163 int32 fLastImageIndex; 164 int32 fLastWorkspaceIndex; 165 BMessage fSettings; 166 184 BackgroundImage::BackgroundImageInfo* fCurrentInfo; 185 entry_ref fCurrentRef; 186 int32 fLastImageIndex; 187 int32 fLastWorkspaceIndex; 188 BMessage fSettings; 167 189 BObjectList<BPath> fPathList; 168 190 BObjectList<Image> fImageList; 169 170 FramePart* fTopLeft; 171 FramePart* fTop; 172 FramePart* fTopRight; 173 FramePart* fLeft; 174 FramePart* fRight; 175 FramePart* fBottomLeft; 176 FramePart* fBottom; 177 FramePart* fBottomRight; 178 179 bool fFoundPositionSetting; 191 FramePart* fTopLeft; 192 FramePart* fTop; 193 FramePart* fTopRight; 194 FramePart* fLeft; 195 FramePart* fRight; 196 FramePart* fBottomLeft; 197 FramePart* fBottom; 198 FramePart* fBottomRight; 199 bool fFoundPositionSetting; 200 rgb_color color; 201 BObjectList<Settings>* fInitialSettings; 202 BObjectList<Controls>* fControlSettings; 180 203 }; 181 204 182 205 #endif // BACKGROUNDS_VIEW_H -
BackgroundsView.cpp
6 6 * Jerome Duval (jerome.duval@free.fr) 7 7 * Axel Dörfler, axeld@pinc-software.de 8 8 * Jonas Sundström, jonas@kirilla.se 9 * Markku Hyppönen, make.hypponen@pp.inet.fi 9 10 */ 10 11 11 12 … … 179 180 B_TRANSLATE("Current workspace"), 180 181 new BMessage(kMsgCurrentWorkspace))); 181 182 menuItem->SetMarked(true); 182 fLastWorkspaceIndex = 183 fWorkspaceMenu->IndexOf(fWorkspaceMenu->FindMarked()); 183 fLastWorkspaceIndex = fWorkspaceMenu->IndexOf(fWorkspaceMenu->FindMarked()); 184 184 fWorkspaceMenu->AddSeparatorItem(); 185 185 fWorkspaceMenu->AddItem(new BMenuItem(B_TRANSLATE("Default folder"), 186 186 new BMessage(kMsgDefaultFolder))); … … 333 333 334 334 335 335 void 336 BackgroundsView::MessageReceived(BMessage* m sg)336 BackgroundsView::MessageReceived(BMessage* message) 337 337 { 338 switch (m sg->what) {338 switch (message->what) { 339 339 case B_SIMPLE_DATA: 340 340 case B_REFS_RECEIVED: 341 RefsReceived(m sg);341 RefsReceived(message); 342 342 break; 343 343 344 344 case kMsgUpdatePreviewPlacement: … … 354 354 } 355 355 356 356 case kMsgManualPlacement: 357 _UpdatePreview(); 358 _UpdateButtons(); 359 break; 360 357 case kMsgUpdateColor: 358 case kMsgImagePlacement: 361 359 case kMsgTilePlacement: 362 360 case kMsgScalePlacement: 363 361 case kMsgCenterPlacement: … … 369 367 _UpdateButtons(); 370 368 break; 371 369 372 case kMsgUpdateColor:373 case kMsgImagePlacement:374 _UpdatePreview();375 _UpdateButtons();376 break;377 378 370 case kMsgCurrentWorkspace: 379 371 case kMsgAllWorkspaces: 380 372 fImageMenu->FindItem(kMsgNoImage)->SetLabel(B_TRANSLATE("None")); … … 408 400 { 409 401 PRINT(("cancel received\n")); 410 402 void* pointer; 411 m sg->FindPointer("source", &pointer);403 message->FindPointer("source", &pointer); 412 404 if (pointer == fPanel) { 413 405 if (fLastImageIndex >= 0) 414 406 _FindImageItem(fLastImageIndex)->SetMarked(true); … … 445 437 _Save(); 446 438 447 439 //_NotifyServer(); 448 thread_id notify _thread;449 notify _thread = spawn_thread(BackgroundsView::_NotifyThread,440 thread_id notifyThread; 441 notifyThread = spawn_thread(BackgroundsView::_NotifyThread, 450 442 "notifyServer", B_NORMAL_PRIORITY, this); 451 resume_thread(notify _thread);443 resume_thread(notifyThread); 452 444 _UpdateButtons(); 453 445 break; 454 446 } 455 447 case kMsgRevertSettings: 456 _ UpdateWithCurrent();448 _Revert(); 457 449 break; 458 450 459 451 default: 460 BView::MessageReceived(m sg);452 BView::MessageReceived(message); 461 453 break; 462 454 } 463 455 } … … 468 460 { 469 461 BPath path; 470 462 if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) { 471 status_t err ;472 err = get_ref_for_path(path.Path(), &fCurrentRef);473 if (err != B_OK)463 status_t error; 464 error = get_ref_for_path(path.Path(), &fCurrentRef); 465 if (error != B_OK) 474 466 printf("error in LoadDesktopSettings\n"); 475 467 _LoadFolder(true); 476 468 } … … 484 476 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { 485 477 BString pathString = path.Path(); 486 478 pathString << "/Tracker/DefaultFolderTemplate"; 487 status_t err ;488 err = get_ref_for_path(pathString.String(), &fCurrentRef);489 if (err != B_OK)479 status_t error; 480 error = get_ref_for_path(pathString.String(), &fCurrentRef); 481 if (error != B_OK) 490 482 printf("error in LoadDefaultFolderSettings\n"); 491 483 _LoadFolder(false); 492 484 } … … 496 488 void 497 489 BackgroundsView::_LoadRecentFolder(BPath path) 498 490 { 499 status_t err ;500 err = get_ref_for_path(path.Path(), &fCurrentRef);501 if (err != B_OK)491 status_t error; 492 error = get_ref_for_path(path.Path(), &fCurrentRef); 493 if (error != B_OK) 502 494 printf("error in LoadRecentFolder\n"); 503 495 _LoadFolder(false); 504 496 } 505 497 506 498 499 Settings* 500 BackgroundsView::_GetInitialSettings(int32 workspace) 501 { 502 for (int32 i=0; i < fInitialSettings->CountItems(); i++) { 503 Settings* settings = (Settings*)fInitialSettings->ItemAt(i); 504 if (settings != NULL && settings->fWorkspace == workspace) 505 return settings; 506 } 507 return NULL; 508 } 509 510 511 Controls* 512 BackgroundsView::_GetControlSettings(int32 workspace, bool remove) 513 { 514 if (fControlSettings == NULL) 515 fControlSettings = new BObjectList<Controls>(); 516 517 int32 count = fControlSettings->CountItems(); 518 519 for (int32 i=0; i < count; i++) { 520 Controls* controls = (Controls*)fControlSettings->ItemAt(i); 521 if (controls != NULL && controls->fWorkspace == workspace) { 522 if (remove) 523 return fControlSettings->RemoveItemAt(i); 524 else 525 return controls; 526 } 527 } 528 return NULL; 529 } 530 531 507 532 void 533 BackgroundsView::_SetInitialSettings() 534 { 535 if (fInitialSettings == NULL) 536 fInitialSettings = new BObjectList<Settings>(); 537 538 if (_GetInitialSettings(current_workspace()) == NULL) { 539 BNode node(&fCurrentRef); 540 if (node.InitCheck() != B_OK) 541 return; 542 543 Settings* settings = new Settings(); 544 settings->fWorkspace = current_workspace(); 545 settings->fColor = BScreen().DesktopColor(); 546 settings->fImage = 547 BackgroundImage::GetBackgroundImage(&node, true, this); 548 settings->fInfo = settings->fImage 549 ->ImageInfoForWorkspace(current_workspace()); 550 551 fInitialSettings->AddItem(settings); 552 } 553 } 554 555 void 556 BackgroundsView::_SetControlSettings(int32 workspace) 557 { 558 if (fControlSettings == NULL) 559 fControlSettings = new BObjectList<Controls>(); 560 561 Controls* controls = _GetControlSettings(workspace, true); 562 563 if (controls != NULL) 564 delete controls; 565 566 controls = new Controls(); 567 rgb_color color = fPicker->ValueAsColor(); 568 569 controls->fWorkspace = workspace; 570 controls->fColor = color; 571 controls->fTextWidgetLabelOutline = 572 fIconLabelOutline->Value() == B_CONTROL_ON; 573 controls->fImageIndex = fImageMenu->IndexOf(fImageMenu->FindMarked()); 574 controls->fPlacementIndex = 575 fPlacementMenu->IndexOf(fPlacementMenu->FindMarked()); 576 controls->fOffsetX = atoi(fXPlacementText->Text()); 577 controls->fOffsetY = atoi(fYPlacementText->Text()); 578 579 fControlSettings->AddItem(controls); 580 581 582 } 583 584 void 585 BackgroundsView::_ResetControlSettings() 586 { 587 if (!fControlSettings) 588 return; 589 590 if (fWorkspaceMenu->IndexOf(fWorkspaceMenu->FindMarked()) == 0) { 591 while (fControlSettings->CountItems() > 0) { 592 delete fControlSettings->RemoveItemAt(0); 593 } 594 } 595 } 596 597 void 508 598 BackgroundsView::_LoadFolder(bool isDesktop) 509 599 { 510 600 if (fCurrent) { … … 513 603 } 514 604 515 605 BNode node(&fCurrentRef); 516 if (node.InitCheck() == B_OK) 606 if (node.InitCheck() == B_OK) { 517 607 fCurrent = BackgroundImage::GetBackgroundImage(&node, isDesktop, this); 518 608 _SetInitialSettings(); 609 } 519 610 _UpdateWithCurrent(); 520 611 } 521 612 … … 523 614 void 524 615 BackgroundsView::_UpdateWithCurrent(void) 525 616 { 526 if (fCurrent == NULL) 617 rgb_color color = BScreen().DesktopColor(); 618 _RevertTo(fCurrent,fCurrentInfo,color); 619 _UpdatePreview(); 620 _UpdateButtons(); 621 } 622 623 624 void 625 BackgroundsView::_Revert() 626 { 627 Settings* bgInfo = (Settings*)_GetInitialSettings(current_workspace()); 628 _RevertTo(bgInfo->fImage,bgInfo->fInfo,bgInfo->fColor); 629 _ResetControlSettings(); 630 _SetInitialSettings(); 631 _UpdatePreview(); 632 _UpdateButtons(); 633 634 fRevert->SetEnabled(false); 635 } 636 637 638 void 639 BackgroundsView::_RevertTo(BackgroundImage*& image, 640 BackgroundImage::BackgroundImageInfo*& info, rgb_color& color) 641 { 642 if (image == NULL) 527 643 return; 528 644 529 645 fPlacementMenu->FindItem(kMsgScalePlacement) 530 ->SetEnabled( fCurrent->IsDesktop());646 ->SetEnabled(image->IsDesktop()); 531 647 fPlacementMenu->FindItem(kMsgCenterPlacement) 532 ->SetEnabled( fCurrent->IsDesktop());648 ->SetEnabled(image->IsDesktop()); 533 649 534 650 if (fWorkspaceMenu->IndexOf(fWorkspaceMenu->FindMarked()) > 5) 535 651 fImageMenu->FindItem(kMsgNoImage)->SetLabel(B_TRANSLATE("Default")); … … 546 662 } 547 663 548 664 fImageMenu->SetTargetForItems(this); 665 666 info = image->ImageInfoForWorkspace(current_workspace()); 549 667 550 fCurrentInfo = fCurrent->ImageInfoForWorkspace(current_workspace()); 551 552 if (!fCurrentInfo) { 668 if (!info) { 553 669 fImageMenu->FindItem(kMsgNoImage)->SetMarked(true); 554 670 fPlacementMenu->FindItem(kMsgManualPlacement)->SetMarked(true); 555 671 fIconLabelOutline->SetValue(B_CONTROL_ON); 556 672 } else { 557 fIconLabelOutline->SetValue( fCurrentInfo->fTextWidgetLabelOutline673 fIconLabelOutline->SetValue(info->fTextWidgetLabelOutline 558 674 ? B_CONTROL_ON : B_CONTROL_OFF); 559 675 560 fLastImageIndex = fCurrentInfo->fImageIndex;676 fLastImageIndex = info->fImageIndex; 561 677 _FindImageItem(fLastImageIndex)->SetMarked(true); 562 678 563 679 if (fLastImageIndex > -1) { 564 565 680 BString xtext, ytext; 566 681 int32 cmd = 0; 567 switch ( fCurrentInfo->fMode) {682 switch (info->fMode) { 568 683 case BackgroundImage::kCentered: 569 684 cmd = kMsgCenterPlacement; 570 685 break; 686 571 687 case BackgroundImage::kScaledToFit: 572 688 cmd = kMsgScalePlacement; 573 689 break; 690 574 691 case BackgroundImage::kAtOffset: 575 692 cmd = kMsgManualPlacement; 576 xtext << (int) fCurrentInfo->fOffset.x;577 ytext << (int) fCurrentInfo->fOffset.y;693 xtext << (int)info->fOffset.x; 694 ytext << (int)info->fOffset.y; 578 695 break; 696 579 697 case BackgroundImage::kTiled: 580 698 cmd = kMsgTilePlacement; 581 699 break; … … 591 709 } 592 710 } 593 711 594 rgb_color color = {255, 255, 255, 255}; 595 if (fCurrent->IsDesktop()) { 596 color = BScreen().DesktopColor(); 597 fPicker->SetEnabled(true); 598 } else 599 fPicker->SetEnabled(false); 600 712 fPicker->SetEnabled(true); 601 713 fPicker->SetValue(color); 602 603 _UpdatePreview();604 _UpdateButtons();605 714 } 606 715 607 716 608 717 void 609 718 BackgroundsView::_Save() 610 719 { 611 bool textWidgetLabelOutline 612 = fIconLabelOutline->Value() == B_CONTROL_ON; 613 720 bool textWidgetLabelOutline = fIconLabelOutline->Value() == B_CONTROL_ON; 614 721 BackgroundImage::Mode mode = _FindPlacementMode(); 615 722 BPoint offset(atoi(fXPlacementText->Text()), atoi(fYPlacementText->Text())); 616 723 … … 637 744 if (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()) { 638 745 if (fCurrentInfo->fWorkspace & workspaceMask 639 746 && fCurrentInfo->fWorkspace != workspaceMask) { 640 fCurrentInfo->fWorkspace = fCurrentInfo->fWorkspace641 ^ workspaceMask;747 fCurrentInfo->fWorkspace = 748 fCurrentInfo->fWorkspace ^ workspaceMask; 642 749 fCurrentInfo = new BackgroundImage::BackgroundImageInfo( 643 750 workspaceMask, fLastImageIndex, mode, offset, 644 751 textWidgetLabelOutline, fCurrentInfo->fImageSet, … … 704 811 } else { 705 812 int32 i = -1; 706 813 BMessage reply; 707 int32 err ;814 int32 error; 708 815 BEntry currentEntry(&fCurrentRef); 709 816 BPath currentPath(¤tEntry); 710 817 bool isCustomFolder 711 818 = !fWorkspaceMenu->FindItem(kMsgDefaultFolder)->IsMarked(); 712 819 713 820 do { 714 BMessage m sg(B_GET_PROPERTY);821 BMessage message = B_GET_PROPERTY; 715 822 i++; 716 823 717 824 // look at the "Poses" in every Tracker window 718 m sg.AddSpecifier("Poses");719 m sg.AddSpecifier("Window", i);825 message.AddSpecifier("Poses"); 826 message.AddSpecifier("Window", i); 720 827 721 828 reply.MakeEmpty(); 722 tracker.SendMessage(&m sg, &reply);829 tracker.SendMessage(&message, &reply); 723 830 724 831 // break out of the loop when we're at the end of 725 832 // the windows 726 833 if (reply.what == B_MESSAGE_NOT_UNDERSTOOD 727 && reply.FindInt32("error", &err ) == B_OK728 && err == B_BAD_INDEX)834 && reply.FindInt32("error", &error) == B_OK 835 && error == B_BAD_INDEX) 729 836 break; 730 837 731 838 // don't stop for windows that don't understand 732 839 // a request for "Poses"; they're not displaying 733 840 // folders 734 841 if (reply.what == B_MESSAGE_NOT_UNDERSTOOD 735 && reply.FindInt32("error", &err ) == B_OK736 && err != B_BAD_SCRIPT_SYNTAX)842 && reply.FindInt32("error", &error) == B_OK 843 && error != B_BAD_SCRIPT_SYNTAX) 737 844 continue; 738 845 739 846 BMessenger trackerWindow; … … 742 849 743 850 if (isCustomFolder) { 744 851 // found a window with poses, ask for its path 745 m sg.MakeEmpty();746 m sg.what = B_GET_PROPERTY;747 m sg.AddSpecifier("Path");748 m sg.AddSpecifier("Poses");749 m sg.AddSpecifier("Window", i);852 message.MakeEmpty(); 853 message.what = B_GET_PROPERTY; 854 message.AddSpecifier("Path"); 855 message.AddSpecifier("Poses"); 856 message.AddSpecifier("Window", i); 750 857 751 858 reply.MakeEmpty(); 752 tracker.SendMessage(&m sg, &reply);859 tracker.SendMessage(&message, &reply); 753 860 754 861 // go on with the next if this din't have a path 755 862 if (reply.what == B_MESSAGE_NOT_UNDERSTOOD) … … 854 961 855 962 path.SetTo(string.String()); 856 963 int32 i = _AddPath(path); 857 BString s;858 s<< B_TRANSLATE("Folder: ") << path.Leaf();859 BMenuItem* item = new BMenuItem( s.String(),964 BString title; 965 title << B_TRANSLATE("Folder: ") << path.Leaf(); 966 BMenuItem* item = new BMenuItem(title.String(), 860 967 new BMessage(kMsgFolderSelected)); 861 968 fWorkspaceMenu->AddItem(item, -i - 1 + 6); 862 969 index++; … … 868 975 869 976 870 977 void 871 BackgroundsView::WorkspaceActivated(uint32 oldWorkspaces, bool active)978 BackgroundsView::WorkspaceActivated(uint32 workspace, bool active) 872 979 { 980 rgb_color color = fPicker->ValueAsColor(); 981 982 if ((int)workspace == current_workspace()) { 983 return; 984 } else { 985 _SetControlSettings(workspace); 986 } 987 988 _SetInitialSettings(); 873 989 _UpdateWithCurrent(); 990 _UpdatePreview(); 991 992 Controls* controls = 993 (Controls*)_GetControlSettings(current_workspace(),false); 994 995 if (controls != NULL) { 996 fPicker->SetValue(controls->fColor); 997 fIconLabelOutline->SetValue(controls->fTextWidgetLabelOutline ? 998 B_CONTROL_ON : B_CONTROL_OFF); 999 1000 fImageMenu->ItemAt(controls->fImageIndex)->SetMarked(true); 1001 fPlacementMenu->ItemAt(controls->fPlacementIndex)->SetMarked(true); 1002 1003 BString xtext, ytext; 1004 xtext << (int)controls->fOffsetX; 1005 ytext << (int)controls->fOffsetY; 1006 fXPlacementText->SetText(xtext); 1007 fYPlacementText->SetText(ytext); 1008 1009 _UpdateButtons(); 1010 _UpdatePreview(); 1011 } 874 1012 } 875 1013 876 1014 … … 886 1024 && imageEnabled; 887 1025 if (fXPlacementText->IsEnabled() ^ textEnabled) 888 1026 fXPlacementText->SetEnabled(textEnabled); 1027 889 1028 if (fYPlacementText->IsEnabled() ^ textEnabled) 890 1029 fYPlacementText->SetEnabled(textEnabled); 891 1030 … … 939 1078 940 1079 if (fPlacementMenu->FindItem(kMsgCenterPlacement)->IsMarked()) 941 1080 mode = BackgroundImage::kCentered; 1081 942 1082 if (fPlacementMenu->FindItem(kMsgScalePlacement)->IsMarked()) 943 1083 mode = BackgroundImage::kScaledToFit; 1084 944 1085 if (fPlacementMenu->FindItem(kMsgManualPlacement)->IsMarked()) 945 1086 mode = BackgroundImage::kAtOffset; 1087 946 1088 if (fPlacementMenu->FindItem(kMsgTilePlacement)->IsMarked()) 947 1089 mode = BackgroundImage::kTiled; 948 1090 … … 953 1095 void 954 1096 BackgroundsView::_UpdateButtons() 955 1097 { 956 bool hasChanged = false; 1098 Settings* initialSettings = 1099 (Settings*)_GetInitialSettings(current_workspace()); 1100 1101 if (initialSettings == NULL) { 1102 return; 1103 } 1104 1105 BackgroundImage* image = initialSettings->fImage; 1106 BackgroundImage::BackgroundImageInfo* info = initialSettings->fInfo; 1107 rgb_color color = initialSettings->fColor; 1108 bool differsFromInitial = false; 1109 bool differsFromControls = false; 1110 957 1111 if (fPicker->IsEnabled() 958 1112 && fPicker->ValueAsColor() != BScreen().DesktopColor()) { 959 hasChanged= true;1113 differsFromControls = true; 960 1114 } else if (fCurrentInfo) { 961 1115 if ((fIconLabelOutline->Value() == B_CONTROL_ON) 962 1116 ^ fCurrentInfo->fTextWidgetLabelOutline) { 963 hasChanged= true;1117 differsFromControls = true; 964 1118 } else if (_FindPlacementMode() != fCurrentInfo->fMode) { 965 hasChanged= true;1119 differsFromControls = true; 966 1120 } else if (fCurrentInfo->fImageIndex 967 1121 != ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) { 968 hasChanged= true;969 } else if ( fCurrent->IsDesktop()1122 differsFromControls = true; 1123 } else if (image->IsDesktop() 970 1124 && ((fCurrentInfo->fWorkspace != B_ALL_WORKSPACES) 971 1125 ^ (fWorkspaceMenu->FindItem(kMsgCurrentWorkspace)->IsMarked()))) 972 1126 { 973 hasChanged= true;1127 differsFromControls = true; 974 1128 } else if (fCurrentInfo->fImageIndex > -1 975 1129 && fCurrentInfo->fMode == BackgroundImage::kAtOffset) { 976 BString oldString , newString;1130 BString oldString; 977 1131 oldString << (int)fCurrentInfo->fOffset.x; 978 1132 if (oldString != BString(fXPlacementText->Text())) { 979 hasChanged= true;1133 differsFromControls = true; 980 1134 } 981 1135 oldString = ""; 982 1136 oldString << (int)fCurrentInfo->fOffset.y; 983 1137 if (oldString != BString(fYPlacementText->Text())) { 984 hasChanged= true;1138 differsFromControls = true; 985 1139 } 986 1140 } 987 } else if (fImageMenu->IndexOf(fImageMenu->FindMarked()) > 0) { 988 hasChanged = true; 1141 } 1142 1143 if (fPicker->IsEnabled() 1144 && fPicker->ValueAsColor() != color) { 1145 differsFromInitial = true; 1146 } else if (info) { 1147 if ((fIconLabelOutline->Value() == B_CONTROL_ON) 1148 ^ info->fTextWidgetLabelOutline) { 1149 differsFromInitial = true; 1150 } else if (_FindPlacementMode() != info->fMode) { 1151 differsFromInitial = true; 1152 } else if (info->fImageIndex 1153 != ((BGImageMenuItem*)fImageMenu->FindMarked())->ImageIndex()) { 1154 differsFromInitial = true; 1155 } else if (info->fImageIndex > -1 1156 && info->fMode == BackgroundImage::kAtOffset) { 1157 BString oldString; 1158 oldString << (int)info->fOffset.x; 1159 if (oldString != BString(fXPlacementText->Text())) { 1160 differsFromInitial = true; 1161 } 1162 oldString = ""; 1163 oldString << (int)info->fOffset.y; 1164 if (oldString != BString(fYPlacementText->Text())) { 1165 differsFromInitial = true; 1166 } 1167 } 1168 } else if (fImageMenu->IndexOf(fImageMenu->FindMarked()) 1169 != info->fImageIndex) { 1170 differsFromInitial = true; 989 1171 } else if (fIconLabelOutline->Value() == B_CONTROL_OFF) { 990 hasChanged= true;1172 differsFromInitial = true; 991 1173 } 992 1174 993 fApply->SetEnabled( hasChanged);994 fRevert->SetEnabled( hasChanged);1175 fApply->SetEnabled(differsFromControls); 1176 fRevert->SetEnabled(differsFromInitial); 995 1177 } 996 1178 997 1179 998 1180 void 999 BackgroundsView::RefsReceived(BMessage* m sg)1181 BackgroundsView::RefsReceived(BMessage* message) 1000 1182 { 1001 if (!m sg->HasRef("refs") && msg->HasRef("dir_ref")) {1183 if (!message->HasRef("refs") && message->HasRef("dir_ref")) { 1002 1184 entry_ref dirRef; 1003 if (m sg->FindRef("dir_ref", &dirRef) == B_OK)1004 m sg->AddRef("refs", &dirRef);1185 if (message->FindRef("dir_ref", &dirRef) == B_OK) 1186 message->AddRef("refs", &dirRef); 1005 1187 } 1006 1188 1007 1189 entry_ref ref; … … 1010 1192 BPath desktopPath; 1011 1193 find_directory(B_DESKTOP_DIRECTORY, &desktopPath); 1012 1194 1013 while (m sg->FindRef("refs", i++, &ref) == B_OK) {1195 while (message->FindRef("refs", i++, &ref) == B_OK) { 1014 1196 BPath path; 1015 1197 BEntry entry(&ref, true); 1016 1198 path.SetTo(&entry); … … 1038 1220 1039 1221 // An optional placement may have been sent 1040 1222 int32 placement = 0; 1041 if (m sg->FindInt32("placement", &placement) == B_OK) {1223 if (message->FindInt32("placement", &placement) == B_OK) { 1042 1224 BMenuItem* item = fPlacementMenu->FindItem(placement); 1043 1225 if (item) 1044 1226 item->SetMarked(true); … … 1059 1241 } else { 1060 1242 if (fWorkspaceMenu->CountItems() <= 5) 1061 1243 fWorkspaceMenu->AddSeparatorItem(); 1062 BString s;1063 s<< B_TRANSLATE("Folder: ") << path.Leaf();1064 item = new BMenuItem( s.String(),1244 BString title; 1245 title << B_TRANSLATE("Folder: ") << path.Leaf(); 1246 item = new BMenuItem(title.String(), 1065 1247 new BMessage(kMsgFolderSelected)); 1066 1248 fWorkspaceMenu->AddItem(item, -index - 1 + 6); 1067 1249 item->SetTarget(this); … … 1646 1828 } 1647 1829 } 1648 1830 1831 1832 Settings::Settings() 1833 : 1834 fImage(NULL), 1835 fInfo(NULL), 1836 fColor(rgb_color()) 1837 { 1838 } 1839 1840 1841 Controls::Controls() 1842 : 1843 fColor(rgb_color()) 1844 { 1845 }