Followed Jeromes suggestion and moved the desktop directory lookup to the

BackgroundImage::SetDesktopImage() method - if you need more control, you
can still easily make _SetImage() public.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16274 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-02-07 11:26:39 +00:00
parent a60adbf9b4
commit 5921f4e2f1
3 changed files with 20 additions and 14 deletions

View File

@ -38,6 +38,7 @@ All rights reserved.
#include <Background.h>
#include <Directory.h>
#include <Entry.h>
#include <FindDirectory.h>
#include <Message.h>
#include <Path.h>
#include <Window.h>
@ -248,9 +249,20 @@ BackgroundImage::SetImage(BDirectory& directory, const char* path, Mode mode,
/*static*/
status_t
BackgroundImage::SetDesktopImage(BDirectory& directory, uint32 workspaces, const char* path,
BackgroundImage::SetDesktopImage(uint32 workspaces, const char* image,
Mode mode, BPoint offset, bool eraseIconBackground)
{
return _SetImage(directory, true, workspaces, path, mode, offset, eraseIconBackground);
BPath path;
status_t status = find_directory(B_DESKTOP_DIRECTORY, &path);
if (status != B_OK)
return status;
BDirectory directory;
status = directory.SetTo(path.Path());
if (status != B_OK)
return status;
return _SetImage(directory, true, workspaces, image, mode, offset,
eraseIconBackground);
}

View File

@ -55,8 +55,8 @@ class BackgroundImage {
static status_t SetImage(BDirectory& directory, const char* path, Mode mode,
BPoint offset, bool eraseIconBackground = false);
static status_t SetDesktopImage(BDirectory& directory, uint32 workspaces,
const char* path, Mode mode, BPoint offset,
static status_t SetDesktopImage(uint32 workspaces, const char* path,
Mode mode, BPoint offset,
bool eraseIconBackground = false);
private:

View File

@ -24,7 +24,6 @@
#include <Clipboard.h>
#include <Entry.h>
#include <File.h>
#include <FindDirectory.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuItem.h>
@ -801,15 +800,10 @@ ShowImageWindow::MessageReceived(BMessage *message)
case MSG_DESKTOP_BACKGROUND:
{
BPath path;
if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) {
BDirectory directory(path.Path());
if (directory.InitCheck() == B_OK) {
if (path.SetTo(fImageView->Image()) == B_OK) {
BackgroundImage::SetDesktopImage(directory, B_CURRENT_WORKSPACE,
path.Path(), BackgroundImage::kScaledToFit, BPoint(0, 0),
false);
}
}
if (path.SetTo(fImageView->Image()) == B_OK) {
BackgroundImage::SetDesktopImage(B_CURRENT_WORKSPACE,
path.Path(), BackgroundImage::kScaledToFit,
BPoint(0, 0), false);
}
break;
}