2 * Copyright 2008, François Revol, <revol@free.fr>. All rights reserved.
3 * Distributed under the terms of the MIT License.
11 #include <Directory.h>
13 #include <FindDirectory.h>
17 #include <WindowPrivate.h>
20 #include "DesktopWindow.h"
22 #undef B_TRANSLATION_CONTEXT
23 #define B_TRANSLATION_CONTEXT "Desktop Window"
26 DesktopWindow::DesktopWindow(BRect frame
, bool editMode
)
27 : BWindow(frame
, B_TRANSLATE("Desktop"),
30 B_NOT_MOVABLE
| B_NOT_CLOSABLE
| B_NOT_ZOOMABLE
31 | B_NOT_MINIMIZABLE
| B_NOT_RESIZABLE
32 | B_ASYNCHRONOUS_CONTROLS
,
33 editMode
?B_CURRENT_WORKSPACE
:B_ALL_WORKSPACES
),
34 fEditShelfMode(editMode
)
37 BView
*desktop
= new BView(Bounds(), "desktop", B_FOLLOW_NONE
, 0);
38 desktop
->SetViewColor(screen
.DesktopColor());
45 err
= find_directory(B_SYSTEM_SETTINGS_DIRECTORY
, &path
, true);
47 BDirectory
dir(path
.Path());
48 if (!dir
.Contains("x-vnd.Haiku-Login", B_DIRECTORY_NODE
))
49 dir
.CreateDirectory("x-vnd.Haiku-Login", NULL
);
50 path
.Append("x-vnd.Haiku-Login");
51 dir
.SetTo(path
.Path());
52 if (!dir
.Contains("Shelf", B_FILE_NODE
))
53 dir
.CreateFile("Shelf", NULL
);
55 get_ref_for_path(path
.Path(), &ref
);
58 fDesktopShelf
= new BShelf(&ref
, desktop
, fEditShelfMode
, "DesktopShelf");
60 fDesktopShelf
->SetDisplaysZombies(true);
64 DesktopWindow::~DesktopWindow()
71 DesktopWindow::QuitRequested()
74 err
= fDesktopShelf
->Save();
75 printf(B_TRANSLATE_COMMENT("error %s\n",
76 "A return message from fDesktopShelf->Save(). It can be \"B_OK\""),
78 return BWindow::QuitRequested();
83 DesktopWindow::DispatchMessage(BMessage
*message
, BHandler
*handler
)
85 switch (message
->what
) {
91 case B_UNMAPPED_KEY_DOWN
:
92 case B_UNMAPPED_KEY_UP
:
93 /* don't allow interacting with the replicants */
97 BWindow::DispatchMessage(message
, handler
);