2 * Copyright 2002-2009 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
7 * Jerome Duval, jerome.duval@free.fr
11 #include <Application.h>
13 #include <LayoutBuilder.h>
15 #include <TrackerAddOnAppLaunch.h>
18 #include "BackgroundsView.h"
21 #undef B_TRANSLATION_CONTEXT
22 #define B_TRANSLATION_CONTEXT "Main Window"
25 static const char* kSignature
= "application/x-vnd.Haiku-Backgrounds";
28 class BackgroundsWindow
: public BWindow
{
32 void RefsReceived(BMessage
* message
);
35 virtual bool QuitRequested();
36 virtual void WorkspaceActivated(int32 oldWorkspaces
,
39 BackgroundsView
* fBackgroundsView
;
43 class BackgroundsApplication
: public BApplication
{
45 BackgroundsApplication();
46 virtual void MessageReceived(BMessage
* message
);
47 virtual void RefsReceived(BMessage
* message
);
50 BackgroundsWindow
* fWindow
;
54 // #pragma mark - BackgroundsApplication
57 BackgroundsApplication::BackgroundsApplication()
59 BApplication(kSignature
),
62 fWindow
= new BackgroundsWindow();
68 BackgroundsApplication::MessageReceived(BMessage
* message
)
73 if (message
->WasDropped() && message
->FindData("RGBColor", B_RGB_COLOR_TYPE
,
74 &data
, &size
) == B_OK
) {
75 // This is the desktop telling us that it was changed by a color drop
76 BMessenger(fWindow
).SendMessage(message
);
79 switch (message
->what
) {
80 case B_SILENT_RELAUNCH
:
84 BApplication::MessageReceived(message
);
91 BackgroundsApplication::RefsReceived(BMessage
* message
)
93 fWindow
->RefsReceived(message
);
97 // #pragma mark - BackgroundsWindow
100 BackgroundsWindow::BackgroundsWindow()
102 BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_SYSTEM_NAME("Backgrounds"),
103 B_TITLED_WINDOW
, B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
104 | B_AUTO_UPDATE_SIZE_LIMITS
,
107 fBackgroundsView
= new BackgroundsView();
109 BLayoutBuilder::Group
<>(this)
110 .AddGroup(B_HORIZONTAL
, 0)
111 .Add(fBackgroundsView
)
115 if (!fBackgroundsView
->FoundPositionSetting())
121 BackgroundsWindow::RefsReceived(BMessage
* message
)
123 fBackgroundsView
->RefsReceived(message
);
129 BackgroundsWindow::QuitRequested()
131 fBackgroundsView
->SaveSettings();
132 be_app
->PostMessage(B_QUIT_REQUESTED
);
139 BackgroundsWindow::WorkspaceActivated(int32 oldWorkspaces
, bool active
)
141 fBackgroundsView
->WorkspaceActivated(oldWorkspaces
, active
);
145 // #pragma mark - main method
149 main(int argc
, char** argv
)
151 BackgroundsApplication app
;