702.3.1
by Michael Terry
add modelines and fix up some inconsistent tabbings |
1 |
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
|
572.1.11
by Neil Jagdish Patel
Import the work done so far with Compiz |
2 |
/*
|
3 |
* Copyright (C) 2010 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: Neil Jagdish Patel <neil.patel@canonical.com>
|
|
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
18 |
* Marco Trevisan (Treviño) <mail@3v1n0.net>
|
572.1.11
by Neil Jagdish Patel
Import the work done so far with Compiz |
19 |
*/
|
20 |
||
1185.6.2
by Tim Penhey
Remove old header and rename new. |
21 |
#include "IndicatorEntry.h" |
572.1.11
by Neil Jagdish Patel
Import the work done so far with Compiz |
22 |
|
1208.2.3
by Tim Penhey
Update tests. |
23 |
#include <iostream> |
572.1.11
by Neil Jagdish Patel
Import the work done so far with Compiz |
24 |
|
1307
by Neil Jagdish Patel
Update formatting to match style (as close as possible) |
25 |
namespace unity |
26 |
{
|
|
27 |
namespace indicator |
|
28 |
{
|
|
1185.6.2
by Tim Penhey
Remove old header and rename new. |
29 |
|
1185.6.4
by Tim Penhey
Tweaking the indicator. |
30 |
Entry::Entry(std::string const& id, |
1351.2.5
by Marco Trevisan (Treviño)
Including name_hint parameter in the IndicatorEntry. |
31 |
std::string const &name_hint, |
1185.6.4
by Tim Penhey
Tweaking the indicator. |
32 |
std::string const& label, |
33 |
bool label_sensitive, |
|
34 |
bool label_visible, |
|
35 |
int image_type, |
|
36 |
std::string const& image_data, |
|
37 |
bool image_sensitive, |
|
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
38 |
bool image_visible, |
39 |
int priority) |
|
1185.6.4
by Tim Penhey
Tweaking the indicator. |
40 |
: id_(id) |
1351.2.5
by Marco Trevisan (Treviño)
Including name_hint parameter in the IndicatorEntry. |
41 |
, name_hint_(name_hint) |
1185.6.4
by Tim Penhey
Tweaking the indicator. |
42 |
, label_(label) |
43 |
, label_visible_(label_visible) |
|
44 |
, label_sensitive_(label_sensitive) |
|
45 |
, image_type_(image_type) |
|
46 |
, image_data_(image_data) |
|
47 |
, image_visible_(image_visible) |
|
48 |
, image_sensitive_(image_sensitive) |
|
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
49 |
, priority_(priority) |
1185.6.4
by Tim Penhey
Tweaking the indicator. |
50 |
, show_now_(false) |
51 |
, active_(false) |
|
52 |
{
|
|
53 |
}
|
|
54 |
||
1351.2.5
by Marco Trevisan (Treviño)
Including name_hint parameter in the IndicatorEntry. |
55 |
std::string const& Entry::name_hint() const |
56 |
{
|
|
57 |
return name_hint_; |
|
58 |
}
|
|
59 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
60 |
std::string const& Entry::id() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
61 |
{
|
62 |
return id_; |
|
63 |
}
|
|
64 |
||
1185.6.16
by Tim Penhey
Well the existing tests pass. |
65 |
std::string const& Entry::label() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
66 |
{
|
67 |
return label_; |
|
68 |
}
|
|
69 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
70 |
bool Entry::image_visible() const |
1185.6.3
by Tim Penhey
Update usage. |
71 |
{
|
72 |
return image_visible_; |
|
73 |
}
|
|
74 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
75 |
bool Entry::image_sensitive() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
76 |
{
|
77 |
return image_sensitive_; |
|
78 |
}
|
|
79 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
80 |
bool Entry::label_visible() const |
1185.6.3
by Tim Penhey
Update usage. |
81 |
{
|
82 |
return label_visible_; |
|
83 |
}
|
|
84 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
85 |
bool Entry::label_sensitive() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
86 |
{
|
87 |
return label_sensitive_; |
|
88 |
}
|
|
89 |
||
1208.2.2
by Tim Penhey
Remove the GdkPixbuf bits from the entries themselves. |
90 |
int Entry::image_type() const |
91 |
{
|
|
92 |
return image_type_; |
|
93 |
}
|
|
94 |
||
95 |
std::string const& Entry::image_data() const |
|
96 |
{
|
|
97 |
return image_data_; |
|
572.1.11
by Neil Jagdish Patel
Import the work done so far with Compiz |
98 |
}
|
99 |
||
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
100 |
int Entry::priority() const |
101 |
{
|
|
102 |
return priority_; |
|
103 |
}
|
|
104 |
||
1858.9.38
by Marco Trevisan (Treviño)
IndicatorEntry: remove the UNUSED_ID support, and add the visible property |
105 |
bool Entry::visible() const |
106 |
{
|
|
1858.9.40
by Marco Trevisan (Treviño)
IndicatorEntry: the image_type should be valid as well to make an entry visible |
107 |
return ((label_visible_ && !label_.empty()) || |
108 |
(image_type_ != 0 && image_visible_ && !image_data_.empty())); |
|
1858.9.38
by Marco Trevisan (Treviño)
IndicatorEntry: remove the UNUSED_ID support, and add the visible property |
109 |
}
|
110 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
111 |
void Entry::set_active(bool active) |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
112 |
{
|
113 |
if (active_ == active) |
|
114 |
return; |
|
115 |
||
116 |
active_ = active; |
|
117 |
active_changed.emit(active); |
|
118 |
updated.emit(); |
|
119 |
}
|
|
120 |
||
1858.11.11
by Marco Trevisan (Treviño)
UnityCore, IndicatorEntry: add support for entry geometry. |
121 |
void Entry::set_geometry(nux::Rect const& geometry) |
122 |
{
|
|
123 |
if (geometry_ == geometry) |
|
124 |
return; |
|
125 |
||
126 |
geometry_ = geometry; |
|
127 |
geometry_changed.emit(geometry); |
|
128 |
updated.emit(); |
|
129 |
}
|
|
130 |
||
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
131 |
void Entry::setLabel(std::string const& label, bool sensitive, bool visible) |
132 |
{
|
|
133 |
if (label_ == label && sensitive == label_sensitive_ && visible == label_visible_) |
|
134 |
return; |
|
135 |
||
136 |
label_ = label; |
|
137 |
label_sensitive_ = sensitive; |
|
138 |
label_visible_ = visible; |
|
139 |
updated.emit(); |
|
140 |
}
|
|
141 |
||
142 |
void Entry::setImage(int type, std::string const& data, bool sensitive, bool visible) |
|
143 |
{
|
|
144 |
if (image_type_ == type && image_data_ == data && |
|
145 |
image_sensitive_ == sensitive && image_visible_ == visible) |
|
146 |
{
|
|
147 |
return; |
|
148 |
}
|
|
149 |
||
150 |
image_type_ = type; |
|
151 |
image_data_ = data; |
|
152 |
image_sensitive_ = sensitive; |
|
153 |
image_visible_ = visible; |
|
154 |
updated.emit(); |
|
155 |
}
|
|
156 |
||
157 |
void Entry::setPriority(int priority) |
|
158 |
{
|
|
159 |
if (priority_ == priority) |
|
160 |
return; |
|
161 |
||
162 |
priority_ = priority; |
|
163 |
updated.emit(); |
|
164 |
}
|
|
165 |
||
1185.6.16
by Tim Penhey
Well the existing tests pass. |
166 |
bool Entry::active() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
167 |
{
|
168 |
return active_; |
|
169 |
}
|
|
170 |
||
1858.11.11
by Marco Trevisan (Treviño)
UnityCore, IndicatorEntry: add support for entry geometry. |
171 |
nux::Rect const& Entry::geometry() const |
172 |
{
|
|
173 |
return geometry_; |
|
174 |
}
|
|
175 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
176 |
Entry& Entry::operator=(Entry const& rhs) |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
177 |
{
|
1185.6.4
by Tim Penhey
Tweaking the indicator. |
178 |
id_ = rhs.id_; |
1351.2.5
by Marco Trevisan (Treviño)
Including name_hint parameter in the IndicatorEntry. |
179 |
name_hint_ = rhs.name_hint_; |
1185.6.4
by Tim Penhey
Tweaking the indicator. |
180 |
label_ = rhs.label_; |
181 |
label_sensitive_ = rhs.label_sensitive_; |
|
182 |
label_visible_ = rhs.label_visible_; |
|
183 |
image_type_ = rhs.image_type_; |
|
184 |
image_data_ = rhs.image_data_; |
|
185 |
image_sensitive_ = rhs.image_sensitive_; |
|
186 |
image_visible_ = rhs.image_visible_; |
|
1351.2.3
by Marco Trevisan (Treviño)
UnityCore: Support for prioritized indicator entries |
187 |
priority_ = rhs.priority_; |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
188 |
|
1307
by Neil Jagdish Patel
Update formatting to match style (as close as possible) |
189 |
updated.emit(); |
1185.6.16
by Tim Penhey
Well the existing tests pass. |
190 |
return *this; |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
191 |
}
|
192 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
193 |
bool Entry::show_now() const |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
194 |
{
|
195 |
return show_now_; |
|
196 |
}
|
|
197 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
198 |
void Entry::set_show_now(bool show_now) |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
199 |
{
|
1185.6.29
by Tim Penhey
Seems that we don't need to emit on no change after all. |
200 |
if (show_now_ == show_now) |
201 |
return; |
|
202 |
||
1185.6.2
by Tim Penhey
Remove old header and rename new. |
203 |
show_now_ = show_now; |
204 |
show_now_changed.emit(show_now); |
|
205 |
updated.emit(); |
|
206 |
}
|
|
207 |
||
1858.9.174
by Marco Trevisan (Treviño)
IndicatorEntry: add also the ShowMenu method with no Xid parameter as fallback |
208 |
void Entry::ShowMenu(int x, int y, unsigned int button, unsigned int timestamp) |
209 |
{
|
|
210 |
ShowMenu(0, x, y, button, timestamp); |
|
211 |
}
|
|
212 |
||
1858.9.10
by Marco Trevisan (Treviño)
UnityCore: update Entry ShowMenu related methods against the services changes. |
213 |
void Entry::ShowMenu(unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp) |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
214 |
{
|
1858.9.10
by Marco Trevisan (Treviño)
UnityCore: update Entry ShowMenu related methods against the services changes. |
215 |
on_show_menu.emit(id_, xid, x, y, button, timestamp); |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
216 |
}
|
217 |
||
1265.2.9
by Marco Trevisan (Treviño)
Indicator: Don't use anymore the x,y position on secondary-activation |
218 |
void Entry::SecondaryActivate(unsigned int timestamp) |
1265.2.6
by Marco Trevisan (Treviño)
Support for seconday activate |
219 |
{
|
1265.2.9
by Marco Trevisan (Treviño)
Indicator: Don't use anymore the x,y position on secondary-activation |
220 |
on_secondary_activate.emit(id_, timestamp); |
1265.2.6
by Marco Trevisan (Treviño)
Support for seconday activate |
221 |
}
|
222 |
||
1185.6.4
by Tim Penhey
Tweaking the indicator. |
223 |
void Entry::Scroll(int delta) |
1185.6.2
by Tim Penhey
Remove old header and rename new. |
224 |
{
|
225 |
on_scroll.emit(id_, delta); |
|
226 |
}
|
|
227 |
||
1185.6.22
by Tim Penhey
Add and remove some logging, and change the way the Indicators base class gets Entries. Can't use a map as I was due to the changing keys (entry->id()). It now traverses the indicator objects themselves to get the entry objects. |
228 |
std::ostream& operator<<(std::ostream& out, Entry const& e) |
229 |
{
|
|
1351.2.5
by Marco Trevisan (Treviño)
Including name_hint parameter in the IndicatorEntry. |
230 |
out << "<indicator::Entry " << e.id() << " hint: '" << e.name_hint() << "' " |
1185.6.22
by Tim Penhey
Add and remove some logging, and change the way the Indicators base class gets Entries. Can't use a map as I was due to the changing keys (entry->id()). It now traverses the indicator objects themselves to get the entry objects. |
231 |
<< std::boolalpha |
232 |
<< " \"" << e.label() << "\" (" |
|
233 |
<< e.label_sensitive() << ", " << e.label_visible() << ") image (" |
|
234 |
<< e.image_sensitive() << ", " << e.image_visible() << ") " |
|
235 |
<< (e.active() ? "active" : "not-active") << " " |
|
1307
by Neil Jagdish Patel
Update formatting to match style (as close as possible) |
236 |
<< (e.show_now() ? "show" : "dont-show") << " >"; |
1185.6.22
by Tim Penhey
Add and remove some logging, and change the way the Indicators base class gets Entries. Can't use a map as I was due to the changing keys (entry->id()). It now traverses the indicator objects themselves to get the entry objects. |
237 |
return out; |
238 |
}
|
|
239 |
||
1185.6.2
by Tim Penhey
Remove old header and rename new. |
240 |
|
241 |
} // namespace indicator |
|
242 |
} // namespace unity |