4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
1 |
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
|
2 |
/*
|
|
3 |
* Copyright (C) 2015 Canonical Ltd
|
|
4 |
*
|
|
5 |
* This program is free software: you can redistribute it and/or modify
|
|
6 |
* it under the terms of the GNU General Public License version 3 as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
*
|
|
17 |
* Authored by: Marco Trevisan <marco.trevisan@canonical.com>
|
|
18 |
*/
|
|
19 |
||
20 |
#include "StorageLauncherIcon.h" |
|
21 |
||
22 |
namespace unity |
|
23 |
{
|
|
24 |
namespace launcher |
|
25 |
{
|
|
26 |
||
27 |
StorageLauncherIcon::StorageLauncherIcon(AbstractLauncherIcon::IconType icon_type, FileManager::Ptr const& fm) |
|
28 |
: WindowedLauncherIcon(icon_type) |
|
29 |
, file_manager_(fm) |
|
30 |
{
|
|
4036.11.28
by Marco Trevisan (Treviño)
StorageLauncherIcon: add protected UpdateStorageWindows |
31 |
file_manager_->locations_changed.connect(sigc::mem_fun(this, &StorageLauncherIcon::UpdateStorageWindows)); |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
32 |
}
|
33 |
||
4036.11.28
by Marco Trevisan (Treviño)
StorageLauncherIcon: add protected UpdateStorageWindows |
34 |
void StorageLauncherIcon::UpdateStorageWindows() |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
35 |
{
|
36 |
bool active = false; |
|
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
37 |
bool urgent = false; |
4036.11.65
by Marco Trevisan (Treviño)
StorageLauncherIcon: check visibility only for applications icons |
38 |
bool check_visibility = (GetIconType() == IconType::APPLICATION); |
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
39 |
bool visible = false; |
4036.11.44
by Marco Trevisan (Treviño)
StorageLauncherIcon: manage visibility for application icons |
40 |
|
4036.11.33
by Marco Trevisan (Treviño)
StorageLauncherIcon: reduce the calls to FM's WindowsForLocation caching results |
41 |
managed_windows_ = GetStorageWindows(); |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
42 |
windows_connections_.Clear(); |
43 |
||
4036.11.27
by Marco Trevisan (Treviño)
StorageLauncherIcon: keep track of the managed windows |
44 |
for (auto const& win : managed_windows_) |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
45 |
{
|
46 |
windows_connections_.Add(win->monitor.changed.connect([this] (int) { EnsureWindowsLocation(); })); |
|
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
47 |
windows_connections_.Add(win->urgent.changed.connect([this] (bool) { OnWindowStateChanged(); })); |
48 |
windows_connections_.Add(win->active.changed.connect([this] (bool) { OnWindowStateChanged(); })); |
|
4036.11.28
by Marco Trevisan (Treviño)
StorageLauncherIcon: add protected UpdateStorageWindows |
49 |
windows_connections_.Add(win->closed.connect([this] { UpdateStorageWindows(); })); |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
50 |
|
51 |
if (!active && win->active()) |
|
52 |
active = true; |
|
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
53 |
|
54 |
if (!urgent && win->urgent()) |
|
55 |
urgent = true; |
|
4036.11.44
by Marco Trevisan (Treviño)
StorageLauncherIcon: manage visibility for application icons |
56 |
|
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
57 |
if (check_visibility && !visible) |
58 |
visible = true; |
|
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
59 |
}
|
60 |
||
4036.11.27
by Marco Trevisan (Treviño)
StorageLauncherIcon: keep track of the managed windows |
61 |
SetQuirk(Quirk::RUNNING, !managed_windows_.empty()); |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
62 |
SetQuirk(Quirk::ACTIVE, active); |
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
63 |
SetQuirk(Quirk::URGENT, urgent); |
4036.11.65
by Marco Trevisan (Treviño)
StorageLauncherIcon: check visibility only for applications icons |
64 |
|
65 |
if (check_visibility) |
|
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
66 |
SetQuirk(Quirk::VISIBLE, visible || IsSticky()); |
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
67 |
|
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
68 |
EnsureWindowsLocation(); |
69 |
}
|
|
70 |
||
4036.11.33
by Marco Trevisan (Treviño)
StorageLauncherIcon: reduce the calls to FM's WindowsForLocation caching results |
71 |
WindowList StorageLauncherIcon::GetManagedWindows() const |
72 |
{
|
|
73 |
return managed_windows_; |
|
74 |
}
|
|
75 |
||
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
76 |
void StorageLauncherIcon::OnWindowStateChanged() |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
77 |
{
|
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
78 |
bool active = false; |
79 |
bool urgent = false; |
|
4036.11.65
by Marco Trevisan (Treviño)
StorageLauncherIcon: check visibility only for applications icons |
80 |
bool check_visibility = (GetIconType() == IconType::APPLICATION); |
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
81 |
bool visible = false; |
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
82 |
|
83 |
for (auto const& win : managed_windows_) |
|
84 |
{
|
|
85 |
if (!active && win->active()) |
|
86 |
active = true; |
|
87 |
||
88 |
if (!urgent && win->urgent()) |
|
89 |
urgent = true; |
|
4036.11.44
by Marco Trevisan (Treviño)
StorageLauncherIcon: manage visibility for application icons |
90 |
|
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
91 |
if (check_visibility && !visible) |
4036.11.44
by Marco Trevisan (Treviño)
StorageLauncherIcon: manage visibility for application icons |
92 |
visible = true; |
4036.11.39
by Marco Trevisan (Treviño)
StorageLauncherIcon: just use window's active/urgent properties changed signals for changing QUIRKs |
93 |
}
|
94 |
||
95 |
SetQuirk(Quirk::ACTIVE, active); |
|
96 |
SetQuirk(Quirk::URGENT, urgent); |
|
4036.11.65
by Marco Trevisan (Treviño)
StorageLauncherIcon: check visibility only for applications icons |
97 |
|
98 |
if (check_visibility) |
|
4146.5.2
by Andrea Azzarone
Don't hide a FileManagerLauncherIcon until all windows are closed. The copy dialog marks itself as "non-visible" so we must properly handle this exception. |
99 |
SetQuirk(Quirk::VISIBLE, visible || IsSticky()); |
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
100 |
}
|
101 |
||
4036.11.48
by Marco Trevisan (Treviño)
ApplicationLauncherIcon: move FileManager specific actions to FileManagerLauncherIcon |
102 |
bool StorageLauncherIcon::OnShouldHighlightOnDrag(DndData const& dnd_data) |
103 |
{
|
|
104 |
for (auto const& uri : dnd_data.Uris()) |
|
105 |
{
|
|
106 |
if (uri.find("file://") == 0) |
|
107 |
return true; |
|
108 |
}
|
|
109 |
||
110 |
return false; |
|
111 |
}
|
|
112 |
||
4036.11.14
by Marco Trevisan (Treviño)
StorageLauncherIcon: add new base-class for storage icons and use it for Trash |
113 |
} // namespace launcher |
114 |
} // namespace unity |