From 5921f4e2f17e6321c51cb8c026ea78326cd4558c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 7 Feb 2006 11:26:39 +0000 Subject: [PATCH] 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 --- src/apps/showimage/BackgroundImage.cpp | 16 ++++++++++++++-- src/apps/showimage/BackgroundImage.h | 4 ++-- src/apps/showimage/ShowImageWindow.cpp | 14 ++++---------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/apps/showimage/BackgroundImage.cpp b/src/apps/showimage/BackgroundImage.cpp index 59e157a69e..ffe92428a0 100644 --- a/src/apps/showimage/BackgroundImage.cpp +++ b/src/apps/showimage/BackgroundImage.cpp @@ -38,6 +38,7 @@ All rights reserved. #include #include #include +#include #include #include #include @@ -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); } diff --git a/src/apps/showimage/BackgroundImage.h b/src/apps/showimage/BackgroundImage.h index b368ffe60e..d06f0203bd 100644 --- a/src/apps/showimage/BackgroundImage.h +++ b/src/apps/showimage/BackgroundImage.h @@ -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: diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index dff4f9d316..14f8a18852 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -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; }