Merge lp:~uriboni/unity-2d/unity-2d-panel-pluggable into lp:unity-2d/3.0
- unity-2d-panel-pluggable
- Merge into natty
Status: | Merged |
---|---|
Approved by: | Alberto Mardegan |
Approved revision: | 698 |
Merged at revision: | 673 |
Proposed branch: | lp:~uriboni/unity-2d/unity-2d-panel-pluggable |
Merge into: | lp:unity-2d/3.0 |
Diff against target: |
1739 lines (+1100/-250) 41 files modified
config.h.in (+8/-0) data/com.canonical.Unity2d.gschema.xml (+20/-0) debian/unity-2d-panel.install (+1/-0) libunity-2d-private/src/CMakeLists.txt (+1/-0) libunity-2d-private/src/panelapplet.cpp (+13/-0) libunity-2d-private/src/panelapplet.h (+44/-0) libunity-2d-private/src/panelappletproviderinterface.h (+42/-0) panel/app/CMakeLists.txt (+4/-3) panel/app/panelmanager.cpp (+116/-26) panel/applets/CMakeLists.txt (+6/-87) panel/applets/appindicator/CMakeLists.txt (+38/-0) panel/applets/appindicator/appindicatorapplet.h (+4/-4) panel/applets/appindicator/plugin.cpp (+39/-0) panel/applets/appindicator/plugin.h (+40/-0) panel/applets/appname/CMakeLists.txt (+51/-0) panel/applets/appname/appnameapplet.cpp (+0/-7) panel/applets/appname/appnameapplet.h (+5/-11) panel/applets/appname/plugin.cpp (+39/-0) panel/applets/appname/plugin.h (+40/-0) panel/applets/common/applet.cpp (+0/-46) panel/applets/common/applet.h (+0/-48) panel/applets/homebutton/CMakeLists.txt (+33/-0) panel/applets/homebutton/homebuttonapplet.cpp (+2/-2) panel/applets/homebutton/homebuttonapplet.h (+4/-2) panel/applets/homebutton/plugin.cpp (+39/-0) panel/applets/homebutton/plugin.h (+40/-0) panel/applets/indicator/CMakeLists.txt (+61/-0) panel/applets/indicator/indicatorapplet.h (+4/-4) panel/applets/indicator/plugin.cpp (+39/-0) panel/applets/indicator/plugin.h (+40/-0) panel/applets/legacytray/CMakeLists.txt (+43/-0) panel/applets/legacytray/legacytrayapplet.h (+3/-5) panel/applets/legacytray/plugin.cpp (+39/-0) panel/applets/legacytray/plugin.h (+40/-0) panel/applets/separator/CMakeLists.txt (+32/-0) panel/applets/separator/plugin.cpp (+39/-0) panel/applets/separator/plugin.h (+40/-0) panel/applets/separator/separatorapplet.cpp (+44/-0) panel/applets/separator/separatorapplet.h (+44/-0) panel/tests/CMakeLists.txt (+2/-3) panel/tests/homebuttonapplettest.cpp (+1/-2) |
To merge this branch: | bzr merge lp:~uriboni/unity-2d/unity-2d-panel-pluggable |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Mardegan (community) | Approve | ||
Review via email: mp+71369@code.launchpad.net |
Commit message
Load the panel applets from dynamically loaded plugins instead of having them hardcoded.
Description of the change
Load the panel applets from dynamically loaded plugins instead of having them hardcoded.
With the current architecture it's impossible to add new applets to the panel without branching the code and adding a new hardcoded applet.
With this modification each applet lives in a shared library in /usr/lib/
- 684. By Ugo Riboni
-
Remove a debug comment in the CMakeLists.txt
- 685. By Ugo Riboni
-
Add soversion to the plugin libraries
- 686. By Ugo Riboni
-
Install the versioned libraries too
Alberto Mardegan (mardy) wrote : | # |
Ugo Riboni (uriboni) wrote : | # |
> data/com.
>
> 24 + <schema path="/
> id="com.
> 25 + <key type="as" name="applets">
> 26 + <default>
> "indicator"
> 27 + <summary>Applets to display in the panel</summary>
>
> GSettings schema allows you to write this in a simpler way: you could use
> type="a(sb)" where "s" is the name and "b" is the boolean for "only on first
> screen". And if you need it, you can also add the expanding here, having the
> type as "a(sbb)". I see that there's also a "child" element for GSettings
> schema, but I don't know much about GSettings myself, so I'm not sure how
> suitable it is for our case.
I thought about it but then I read the documentation for QConf, which basically says that not all complex types are supported by the QT bindings. In fact the only non-basic types supported are "as" (QStringList) and "ay" (QByteArray).
For more details read https:/
> 34 + <key type="s" name="expanding">
> 35 + <default>
> 36 + <summary>Applet that should expand to fill all unused
> space</summary>
>
> Why does it need to be specified here? I'd rather let the applet itself set
> the desired policy on its widget; also, in that way you could have more than
> one applet expanding, and not just one.
I guess it's essentially a matter of choice if it's up to the applet or if it has to be a configuration policy.
The reason why I chose it to be a configuration policy is related to why I am proposing this change: I need to alter the panel layout (add new applets, remove stock applets) for an OEM project and want to modify the stock unity-2d as little as possible.
In this context, having the expanding widget configured in dconf allows me to change which one it is without having to patch the unity-2d widgets (or my own widgets for that matter).
Regarding the choice of having just one expanding applet, I did that to reproduce what was going on in unity-2d before this merge request: only one applet (appname) was expanding.
It's clearly possible to turn that property in an "as" property and have more than one expanding applet, but I think it's outside of the scope of this MR.
> libunity-
> 88 + virtual QString getAppletName() const = 0;
> 89 + virtual QWidget* getApplet() const = 0;
>
> Qt coding style is appletName() and applet(), with no "get".
> (it would also be "Type *variable", but I see that's never used in unity-2d so
> I won't interfere :-) )
I agree with you on appletName(). For applet() now that I think of it, it would actually be much more clear to call it createApplet() since it create a new one every time it's called. What do you think ?
> panel/CMakeList
> 104 -add_subdirecto
> 105 +#add_subdirect
>
> Looks suspicious. :-)
This should be fixed now.
> panel/app/
> 162 -#include <QLabel>
> 163 +#include <QProcessEnviro
> 164 +#include <QFil...
Alberto Mardegan (mardy) wrote : | # |
[...]
> I thought about it but then I read the documentation for QConf, which
> basically says that not all complex types are supported by the QT bindings. In
> fact the only non-basic types supported are "as" (QStringList) and "ay"
> (QByteArray).
Sad. But OK with the code in your MR, then!
[...]
> In this context, having the expanding widget configured in dconf allows me to
> change which one it is without having to patch the unity-2d widgets (or my own
> widgets for that matter).
Correct -- but note that I'm not advocating against using DConf: my doubt is whether this fits better in the Unity-2d schema or in the applet's. For example:
/com/canonical/
width = 200
expand = false
> Regarding the choice of having just one expanding applet, I did that to
> reproduce what was going on in unity-2d before this merge request: only one
> applet (appname) was expanding.
> It's clearly possible to turn that property in an "as" property and have more
> than one expanding applet, but I think it's outside of the scope of this MR.
This is also related to the previous point; I also think it can be changed later without too much effort, and later on we might have a better understanding on what measure this improved customizability is needed/helpful. For this MR, I agree that your approach is the most practical. :-)
[...]
> I agree with you on appletName(). For applet() now that I think of it, it
> would actually be much more clear to call it createApplet() since it create a
> new one every time it's called. What do you think ?
createApplet() is much better indeed.
> > BTW, I see the rest of the code is using UQ_WARNING and UQ_DEBUG instead of
> > qWarning and qDebug.
>
> I'm a bit unsure if they should be used so widely in unity-2d code because
> they are defined in a private header debug_p.h in libunity-
> makes me think they are internal utilities to the library.
> If this is not the case, why don't we get the file renamed to something else
> or even better merged with the public unity2ddebug.h ?
I don't know -- I just saw a merge request about changing all qDebug() and qWarnings() to use that macro, so I assumed it would make sense for this branch too. Indeed the name debug_p.h is suspicious...
> Our internal guidelines don't seem to prefer anything, and I personally find
> the explicit comparison with NULL to be clearer. Unity-2d code seems to use
> both.
> What about I change them to == 0 and we do something to put that rule into the
> coding conventions too ?
I'll see what other people think of it, too.
Now, continuing with the review.
I notice you changed the parent class of the applets from Unity2d::Applet to QWidget. While I don't see much code in the Applet class to make it useful right now, I think it's a good idea to keep it and actually have the applet interface's createApplet method return that, instead of QWidget.
The reason is that it gives us the possibility of implementing some common applet behaviour in the future, and we can use the Applet class to define an interface for panel applets: suppose for instance that one day we want to have a way to ask applets to reload their con...
- 687. By Ugo Riboni
-
Rename the AppletProviderI
nterface to PanelAppletProv iderInterface for clarity and consistency with following commits - 688. By Ugo Riboni
-
Add back the Applet class, now renamed PanelApplet. Fix interface to use it. Make all plugins inherit from it instead of just QWidget.
- 689. By Ugo Riboni
-
Add soversion to the appname plugin, it was missing it from previous changes.
- 690. By Ugo Riboni
-
Refactor the method names in the interface to be more in line with Qt naming guidelines
- 691. By Ugo Riboni
-
Sort Qt imports alphabetically
- 692. By Ugo Riboni
-
Make a few tests simpler or clearer
- 693. By Ugo Riboni
-
Use the new methods from the refactored interface
- 694. By Ugo Riboni
-
Remove the Unity2d namespace from the AppNameApplet. No other applet was using it.
- 695. By Ugo Riboni
-
Merge back changes from trunk
- 696. By Ugo Riboni
-
Fix an error message
Ugo Riboni (uriboni) wrote : | # |
I think I fixed all the remarks you made in your comments.
For the qDebug/qWarning thing, I think that until the header is made non-private (and thus installed with the libunity-2d-private headers) I will stick with the QT standard functions. It's easy to change them afterwards in another MR anyway.
I also made a few extra changes:
- Renamed the base class to PanelApplet (clearer than just Applet), and therefore the interface becomes PanelAppletProv
- Removed some explicit size policy code in the appname applet constructor. As we agree size policy for all applets is controlled by the panel manager now.
- Removed an Unity2d namespace from one of the applets. Nothing else uses it in the rest of the code.
Hope it's all good now. Thanks for the review :)
Alberto Mardegan (mardy) wrote : | # |
Thanks for the update!
I'd say this is good to go, but if you have time for a couple of changes, that would be even better (IMHO):
- Have the PanelApplet class and the PanelAppletProv
http://
- Since the rest of the code is using the "Type* variable" style, let's use it here too: check your panelapplet.{h,cpp}
- 697. By Ugo Riboni
-
Coding style change
- 698. By Ugo Riboni
-
Move the interface and the PanelApplet classes into the Unity2d namespace
Ugo Riboni (uriboni) wrote : | # |
All changes you requested should be there now
Alberto Mardegan (mardy) wrote : | # |
Looks hot! All fine by me! :-)
Preview Diff
1 | === modified file 'config.h.in' |
2 | --- config.h.in 2011-03-07 14:52:11 +0000 |
3 | +++ config.h.in 2011-08-16 14:11:07 +0000 |
4 | @@ -24,3 +24,11 @@ |
5 | return QString(QCoreApplication::applicationDirPath()+"/../"); |
6 | } |
7 | } |
8 | + |
9 | +inline QString unity2dPluginsPath() { |
10 | + if (isRunningInstalled()) { |
11 | + return QString(INSTALL_PREFIX "/lib/unity-2d/plugins"); |
12 | + } else { |
13 | + return unity2dDirectory(); |
14 | + } |
15 | +} |
16 | |
17 | === modified file 'data/com.canonical.Unity2d.gschema.xml' |
18 | --- data/com.canonical.Unity2d.gschema.xml 2011-07-25 10:18:45 +0000 |
19 | +++ data/com.canonical.Unity2d.gschema.xml 2011-08-16 14:11:07 +0000 |
20 | @@ -16,4 +16,24 @@ |
21 | <description>Use EWMH standard to reserve an area of the desktop (struts) so that no window can use the launcher's area</description> |
22 | </key> |
23 | </schema> |
24 | + <schema path="/com/canonical/unity-2d/panel/" id="com.canonical.Unity2d.Panel" gettext-domain="unity-2d"> |
25 | + <key type="as" name="applets"> |
26 | + <default>["!homebutton", "!separator", "appname", "!legacytray", "indicator"]</default> |
27 | + <summary>Applets to display in the panel</summary> |
28 | + <description> |
29 | + List of panel applets that should be displayed, in order, in the panel. |
30 | + Each applet name can be annotated with the prefix "!" to force that applet to be displayed |
31 | + only on the panel living in the leftmost screen. |
32 | + </description> |
33 | + </key> |
34 | + <key type="s" name="expanding"> |
35 | + <default>"appname"</default> |
36 | + <summary>Applet that should expand to fill all unused space</summary> |
37 | + <description> |
38 | + If this property names a valid applet from the list in the applets property, then this |
39 | + applet will be setup so that it tries to use all the panel space that remains empty after |
40 | + the other applets have resized themselves to display their content. |
41 | + </description> |
42 | + </key> |
43 | + </schema> |
44 | </schemalist> |
45 | |
46 | === modified file 'debian/unity-2d-panel.install' |
47 | --- debian/unity-2d-panel.install 2011-01-14 21:41:39 +0000 |
48 | +++ debian/unity-2d-panel.install 2011-08-16 14:11:07 +0000 |
49 | @@ -2,3 +2,4 @@ |
50 | usr/share/applications/unity-2d-panel.desktop |
51 | usr/share/unity-2d/panel/artwork/background.png |
52 | usr/share/unity-2d/panel/artwork/divider.png |
53 | +usr/lib/unity-2d/plugins/panel/libpanelplugin-*.so* |
54 | |
55 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
56 | --- libunity-2d-private/src/CMakeLists.txt 2011-07-29 13:49:34 +0000 |
57 | +++ libunity-2d-private/src/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
58 | @@ -53,6 +53,7 @@ |
59 | workspaces.cpp |
60 | launcherdropitem.cpp |
61 | iconutilities.cpp |
62 | + panelapplet.cpp |
63 | ) |
64 | |
65 | # Build |
66 | |
67 | === added file 'libunity-2d-private/src/panelapplet.cpp' |
68 | --- libunity-2d-private/src/panelapplet.cpp 1970-01-01 00:00:00 +0000 |
69 | +++ libunity-2d-private/src/panelapplet.cpp 2011-08-16 14:11:07 +0000 |
70 | @@ -0,0 +1,13 @@ |
71 | +#include "panelapplet.h" |
72 | + |
73 | +namespace Unity2d |
74 | +{ |
75 | + |
76 | +PanelApplet::PanelApplet(QWidget* parent) : |
77 | + QWidget(parent) |
78 | +{ |
79 | +} |
80 | + |
81 | +} // namespace Unity2d |
82 | + |
83 | +#include "panelapplet.moc" |
84 | |
85 | === added file 'libunity-2d-private/src/panelapplet.h' |
86 | --- libunity-2d-private/src/panelapplet.h 1970-01-01 00:00:00 +0000 |
87 | +++ libunity-2d-private/src/panelapplet.h 2011-08-16 14:11:07 +0000 |
88 | @@ -0,0 +1,44 @@ |
89 | +/* |
90 | + * This file is part of unity-2d |
91 | + * |
92 | + * Copyright 2010 Canonical Ltd. |
93 | + * |
94 | + * Authors: |
95 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
96 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
97 | + * |
98 | + * This program is free software; you can redistribute it and/or modify |
99 | + * it under the terms of the GNU General Public License as published |
100 | + * by the Free Software Foundation; version 3. |
101 | + * |
102 | + * This program is distributed in the hope that it will be useful, |
103 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
104 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
105 | + * GNU General Public License for more details. |
106 | + * |
107 | + * You should have received a copy of the GNU General Public License |
108 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
109 | + */ |
110 | + |
111 | +#ifndef PANELAPPLET_H |
112 | +#define PANELAPPLET_H |
113 | + |
114 | +// Qt |
115 | +#include <QWidget> |
116 | + |
117 | +namespace Unity2d |
118 | +{ |
119 | + |
120 | +class PanelApplet : public QWidget |
121 | +{ |
122 | + Q_OBJECT |
123 | +public: |
124 | + explicit PanelApplet(QWidget* parent = 0); |
125 | + |
126 | +private: |
127 | + Q_DISABLE_COPY(PanelApplet) |
128 | +}; |
129 | + |
130 | +} // namespace Unity2d |
131 | + |
132 | +#endif // PANELAPPLET_H |
133 | |
134 | === added file 'libunity-2d-private/src/panelappletproviderinterface.h' |
135 | --- libunity-2d-private/src/panelappletproviderinterface.h 1970-01-01 00:00:00 +0000 |
136 | +++ libunity-2d-private/src/panelappletproviderinterface.h 2011-08-16 14:11:07 +0000 |
137 | @@ -0,0 +1,42 @@ |
138 | +/* |
139 | + * This file is part of unity-2d |
140 | + * |
141 | + * Copyright 2011 Canonical Ltd. |
142 | + * |
143 | + * Authors: |
144 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
145 | + * |
146 | + * This program is free software; you can redistribute it and/or modify |
147 | + * it under the terms of the GNU General Public License as published by |
148 | + * the Free Software Foundation; version 3. |
149 | + * |
150 | + * This program is distributed in the hope that it will be useful, |
151 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
152 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
153 | + * GNU General Public License for more details. |
154 | + * |
155 | + * You should have received a copy of the GNU General Public License |
156 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
157 | + */ |
158 | + |
159 | +#ifndef PANELAPPLETPROVIDERINTERFACE_H |
160 | +#define PANELAPPLETPROVIDERINTERFACE_H |
161 | + |
162 | +#include "panelapplet.h" |
163 | + |
164 | +namespace Unity2d |
165 | +{ |
166 | + |
167 | +class PanelAppletProviderInterface |
168 | +{ |
169 | +public: |
170 | + virtual QString appletName() const = 0; |
171 | + virtual PanelApplet* createApplet() const = 0; |
172 | +}; |
173 | + |
174 | +} // namespace Unity2d |
175 | + |
176 | +Q_DECLARE_INTERFACE(Unity2d::PanelAppletProviderInterface, |
177 | + "com.canonical.Unity2d.PanelAppletProviderInterface/1.0") |
178 | + |
179 | +#endif // PANELAPPLETPROVIDERINTERFACE_H |
180 | |
181 | === modified file 'panel/app/CMakeLists.txt' |
182 | --- panel/app/CMakeLists.txt 2011-04-04 16:41:15 +0000 |
183 | +++ panel/app/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
184 | @@ -1,3 +1,5 @@ |
185 | +pkg_check_modules(DCONFQT REQUIRED dconf-qt) |
186 | + |
187 | set(panel_SRCS |
188 | main.cpp |
189 | panelmanager.cpp |
190 | @@ -10,15 +12,14 @@ |
191 | include_directories( |
192 | ${CMAKE_CURRENT_BINARY_DIR} |
193 | ${CMAKE_CURRENT_SOURCE_DIR} |
194 | - ${uqapplets_SOURCE_DIR} |
195 | - ${uqapplets_SOURCE_DIR}/common |
196 | + ${DCONFQT_INCLUDE_DIRS} |
197 | ${libunity-2d-private_SOURCE_DIR}/src |
198 | ) |
199 | |
200 | target_link_libraries(unity-2d-panel |
201 | ${QT_QTGUI_LIBRARIES} |
202 | ${QT_QTCORE_LIBRARIES} |
203 | - uqapplets |
204 | + ${DCONFQT_LIBRARIES} |
205 | unity-2d-private |
206 | ) |
207 | |
208 | |
209 | === modified file 'panel/app/panelmanager.cpp' |
210 | --- panel/app/panelmanager.cpp 2011-06-12 23:01:35 +0000 |
211 | +++ panel/app/panelmanager.cpp 2011-08-16 14:11:07 +0000 |
212 | @@ -25,23 +25,31 @@ |
213 | // Local |
214 | #include <config.h> |
215 | |
216 | -// Applets |
217 | -#include <appindicator/appindicatorapplet.h> |
218 | -#include <appname/appnameapplet.h> |
219 | -#include <homebutton/homebuttonapplet.h> |
220 | -#include <indicator/indicatorapplet.h> |
221 | -#include <legacytray/legacytrayapplet.h> |
222 | - |
223 | // Unity |
224 | #include <unity2dpanel.h> |
225 | +#include <panelappletproviderinterface.h> |
226 | + |
227 | +// QConf |
228 | +#include <qconf.h> |
229 | |
230 | // Qt |
231 | #include <QApplication> |
232 | +#include <QDebug> |
233 | #include <QDesktopWidget> |
234 | -#include <QLabel> |
235 | +#include <QDir> |
236 | +#include <QFileInfo> |
237 | +#include <QHash> |
238 | +#include <QPluginLoader> |
239 | +#include <QProcessEnvironment> |
240 | +#include <QVariant> |
241 | |
242 | using namespace Unity2d; |
243 | |
244 | +static const char* PANEL_DCONF_SCHEMA = "com.canonical.Unity2d.Panel"; |
245 | +static const char* PANEL_DCONF_PROPERTY_APPLETS = "applets"; |
246 | +static const char* PANEL_DCONF_PROPERTY_EXPAND = "expanding"; |
247 | +static const char* PANEL_PLUGINS_DEV_DIR_ENV = "DEV_PLUGIN_PATH"; |
248 | + |
249 | static QPalette getPalette() |
250 | { |
251 | QPalette palette; |
252 | @@ -57,13 +65,76 @@ |
253 | return palette; |
254 | } |
255 | |
256 | -static QLabel* createSeparator() |
257 | -{ |
258 | - QLabel* label = new QLabel; |
259 | - QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png"); |
260 | - label->setPixmap(pix); |
261 | - label->setFixedSize(pix.size()); |
262 | - return label; |
263 | +static QHash<QString, PanelAppletProviderInterface*> loadPlugins() |
264 | +{ |
265 | + QHash<QString, PanelAppletProviderInterface*> plugins; |
266 | + |
267 | + /* When running uninstalled the plugins will be loaded from the source tree |
268 | + under panel/applets. |
269 | + When running installed the plugins will be typically in /usr/lib/unity-2d/plugins/panel |
270 | + In both cases it's still possible to override these default locations by setting an |
271 | + environment variable with the path where the plugins are located. |
272 | + */ |
273 | + |
274 | + QString panelPluginsDefaultDir = unity2dPluginsPath() + "/panel"; |
275 | + if (!isRunningInstalled()) panelPluginsDefaultDir += "/applets"; |
276 | + QString pluginPath = QProcessEnvironment::systemEnvironment().value(PANEL_PLUGINS_DEV_DIR_ENV, |
277 | + panelPluginsDefaultDir); |
278 | + QFileInfo pluginFileInfo = QFileInfo(pluginPath); |
279 | + if (!pluginFileInfo.isDir()) { |
280 | + qWarning() << "Panel plugin directory does not exist:" << pluginPath; |
281 | + return plugins; |
282 | + } |
283 | + |
284 | + qDebug() << "Scanning panel plugin directory" << pluginFileInfo.absoluteFilePath(); |
285 | + |
286 | + QDir pluginDir = QDir(pluginFileInfo.absoluteFilePath()); |
287 | + QStringList filters; |
288 | + filters << "*.so"; |
289 | + pluginDir.setNameFilters(filters); |
290 | + |
291 | + Q_FOREACH(QString fileEntry, pluginDir.entryList()) { |
292 | + QString pluginFilePath = pluginDir.absoluteFilePath(fileEntry); |
293 | + qDebug() << "Loading panel plugin:" << pluginFilePath; |
294 | + |
295 | + QPluginLoader loader(pluginFilePath); |
296 | + if (loader.load()) { |
297 | + PanelAppletProviderInterface* provider; |
298 | + provider = qobject_cast<PanelAppletProviderInterface*>(loader.instance()); |
299 | + if (provider == 0) { |
300 | + qWarning() << "Plugin loaded from" << pluginFilePath |
301 | + << "does not implement the interface PanelAppletProviderInterface"; |
302 | + } else { |
303 | + plugins.insert(provider->appletName(), provider); |
304 | + } |
305 | + } else { |
306 | + qWarning() << "Failed to load panel plugin from" << pluginFilePath |
307 | + << "with error" << loader.errorString(); |
308 | + } |
309 | + } |
310 | + |
311 | + return plugins; |
312 | +} |
313 | + |
314 | +static bool loadPanelConfiguration(QStringList& applets, QString& expanding) |
315 | +{ |
316 | + QConf panelConfig(PANEL_DCONF_SCHEMA); |
317 | + |
318 | + QVariant appletsConfig = panelConfig.property(PANEL_DCONF_PROPERTY_APPLETS); |
319 | + if (!appletsConfig.isValid()) { |
320 | + qWarning() << "Missing or invalid panel applets configuration in dconf. Please check" |
321 | + << "the property" << PANEL_DCONF_PROPERTY_APPLETS |
322 | + << "in schema" << PANEL_DCONF_SCHEMA; |
323 | + return false; |
324 | + } |
325 | + |
326 | + applets.append(appletsConfig.toStringList()); |
327 | + qDebug() << "Configured plugins list is:" << applets; |
328 | + |
329 | + expanding = panelConfig.property(PANEL_DCONF_PROPERTY_EXPAND).toString(); |
330 | + qDebug() << "Expanding applet is:" << expanding; |
331 | + |
332 | + return true; |
333 | } |
334 | |
335 | static Unity2dPanel* instantiatePanel(int screen) |
336 | @@ -74,17 +145,36 @@ |
337 | panel->setFixedHeight(24); |
338 | |
339 | int leftmost = QApplication::desktop()->screenNumber(QPoint()); |
340 | - if (screen == leftmost) { |
341 | - panel->addWidget(new HomeButtonApplet); |
342 | - panel->addWidget(createSeparator()); |
343 | - } |
344 | - panel->addWidget(new AppNameApplet); |
345 | - if (screen == leftmost) { |
346 | - /* It doesn’t make sense to have more than one instance of the systray, |
347 | - XEmbed’ed windows can be displayed only once anyway. */ |
348 | - panel->addWidget(new LegacyTrayApplet); |
349 | - } |
350 | - panel->addWidget(new IndicatorApplet); |
351 | + |
352 | + QHash<QString, PanelAppletProviderInterface*> plugins = loadPlugins(); |
353 | + |
354 | + QString expandingApplet; |
355 | + QStringList panelConfiguration; |
356 | + loadPanelConfiguration(panelConfiguration, expandingApplet); |
357 | + |
358 | + Q_FOREACH(QString appletName, panelConfiguration) { |
359 | + bool onlyLeftmost = appletName.startsWith('!'); |
360 | + if (onlyLeftmost) { |
361 | + appletName = appletName.mid(1); |
362 | + } |
363 | + |
364 | + PanelAppletProviderInterface* provider = plugins.value(appletName, NULL); |
365 | + if (provider == 0) { |
366 | + qWarning() << "Panel applet" << appletName << "was requested but there's no" |
367 | + << "installed plugin providing it."; |
368 | + } else { |
369 | + if (screen == leftmost || !onlyLeftmost) { |
370 | + QWidget *applet = provider->createApplet(); |
371 | + if (appletName == expandingApplet) { |
372 | + applet->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); |
373 | + } else { |
374 | + applet->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
375 | + } |
376 | + panel->addWidget(applet); |
377 | + } |
378 | + } |
379 | + } |
380 | + |
381 | return panel; |
382 | } |
383 | |
384 | |
385 | === modified file 'panel/applets/CMakeLists.txt' |
386 | --- panel/applets/CMakeLists.txt 2011-07-18 10:33:35 +0000 |
387 | +++ panel/applets/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
388 | @@ -1,87 +1,6 @@ |
389 | -project(uqapplets) |
390 | - |
391 | -macro(read_pkg_variable cmake_var pkg pkg_var) |
392 | - execute_process( |
393 | - COMMAND pkg-config --variable=${pkg_var} ${pkg} |
394 | - OUTPUT_VARIABLE tmp |
395 | - ) |
396 | - # Remove trailing newline from ${tmp} |
397 | - string(STRIP "${tmp}" ${cmake_var}) |
398 | -endmacro(read_pkg_variable) |
399 | - |
400 | -# Dependencies |
401 | -include(FindPkgConfig) |
402 | - |
403 | -pkg_check_modules(QTBAMF REQUIRED libqtbamf) |
404 | -pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
405 | -pkg_check_modules(INDICATOR REQUIRED indicator) |
406 | - |
407 | -# Get indicator dirs from pkgconfig |
408 | -read_pkg_variable(INDICATOR_DIR indicator indicatordir) |
409 | -read_pkg_variable(INDICATOR_ICONS_DIR indicator iconsdir) |
410 | -configure_file(indicator-config.h.in indicator-config.h) |
411 | - |
412 | -# Sources |
413 | -set(uqapplets_SRCS |
414 | - appindicator/appindicatorapplet.cpp |
415 | - appindicator/sniitem.cpp |
416 | - appname/appnameapplet.cpp |
417 | - appname/menubarwidget.cpp |
418 | - appname/registrar.cpp |
419 | - appname/windowhelper.cpp |
420 | - common/applet.cpp |
421 | - homebutton/homebuttonapplet.cpp |
422 | - homebutton/homebutton.cpp |
423 | - indicator/abstractindicator.cpp |
424 | - indicator/datetimeindicator.cpp |
425 | - indicator/indicatorapplet.cpp |
426 | - indicator/indicatorservicemanager.cpp |
427 | - indicator/indicator.c |
428 | - legacytray/legacytrayapplet.cpp |
429 | - legacytray/fdoselectionmanager.cpp |
430 | - legacytray/fdotask.cpp |
431 | - legacytray/x11embedcontainer.cpp |
432 | - legacytray/x11embeddelegate.cpp |
433 | - legacytray/x11embedpainter.cpp |
434 | - ) |
435 | - |
436 | -qt4_add_dbus_adaptor(uqapplets_SRCS appname/com.canonical.AppMenu.Registrar.xml |
437 | - registrar.h Registrar |
438 | - ) |
439 | - |
440 | -qt4_automoc(${uqapplets_SRCS}) |
441 | - |
442 | -# Build |
443 | -include_directories( |
444 | - ${CMAKE_CURRENT_SOURCE_DIR}/appindicator |
445 | - ${CMAKE_CURRENT_SOURCE_DIR}/appname |
446 | - ${CMAKE_CURRENT_SOURCE_DIR}/common |
447 | - ${CMAKE_CURRENT_SOURCE_DIR}/homebutton |
448 | - ${CMAKE_CURRENT_SOURCE_DIR}/indicator |
449 | - ${QTBAMF_INCLUDE_DIRS} |
450 | - ${DBUSMENUQT_INCLUDE_DIRS} |
451 | - ${GTK_INCLUDE_DIRS} |
452 | - ${INDICATOR_INCLUDE_DIRS} |
453 | - ${WNCK_INCLUDE_DIRS} |
454 | - ${CMAKE_CURRENT_BINARY_DIR} |
455 | - ${X11_INCLUDE_DIR} |
456 | - ${libunity-2d-private_SOURCE_DIR}/src |
457 | - ) |
458 | - |
459 | -add_library(uqapplets ${uqapplets_SRCS}) |
460 | - |
461 | -target_link_libraries(uqapplets |
462 | - ${QT_QTGUI_LIBRARIES} |
463 | - ${QT_QTCORE_LIBRARIES} |
464 | - ${DBUSMENUQT_LDFLAGS} |
465 | - ${QTBAMF_LDFLAGS} |
466 | - ${GTK_LDFLAGS} |
467 | - ${INDICATOR_LDFLAGS} |
468 | - ${WNCK_LDFLAGS} |
469 | - ${X11_LIBRARIES} |
470 | - ${X11_Xrender_LIB} |
471 | - ${X11_Xcomposite_LIB} |
472 | - ${X11_Xdamage_LIB} |
473 | - ${X11_Xfixes_LIB} |
474 | - unity-2d-private |
475 | - ) |
476 | +add_subdirectory(separator) |
477 | +add_subdirectory(homebutton) |
478 | +add_subdirectory(appname) |
479 | +add_subdirectory(legacytray) |
480 | +add_subdirectory(indicator) |
481 | +add_subdirectory(appindicator) |
482 | |
483 | === added file 'panel/applets/appindicator/CMakeLists.txt' |
484 | --- panel/applets/appindicator/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
485 | +++ panel/applets/appindicator/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
486 | @@ -0,0 +1,38 @@ |
487 | +project(panelplugin-appindicator) |
488 | + |
489 | +# Dependencies |
490 | +pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
491 | + |
492 | +# Sources |
493 | +set(appindicator_SRCS |
494 | + appindicatorapplet.cpp |
495 | + sniitem.cpp |
496 | + plugin.cpp |
497 | + ) |
498 | + |
499 | +# Build |
500 | +include_directories( |
501 | + ${CMAKE_CURRENT_SOURCE_DIR} |
502 | + ${CMAKE_CURRENT_BINARY_DIR} |
503 | + ${DBUSMENUQT_INCLUDE_DIRS} |
504 | + ${libunity-2d-private_SOURCE_DIR}/src |
505 | + ) |
506 | + |
507 | +qt4_automoc(${appindicator_SRCS}) |
508 | +add_library(panelplugin-appindicator SHARED ${appindicator_SRCS}) |
509 | +set_target_properties(panelplugin-appindicator PROPERTIES |
510 | + LIBRARY_OUTPUT_DIRECTORY ".." |
511 | + VERSION 0 |
512 | + SOVERSION 0.0 |
513 | + ) |
514 | + |
515 | +target_link_libraries(panelplugin-appindicator |
516 | + ${QT_QTGUI_LIBRARIES} |
517 | + ${QT_QTCORE_LIBRARIES} |
518 | + ${DBUSMENUQT_LIBRARIES} |
519 | + unity-2d-private |
520 | + ) |
521 | + |
522 | +install(TARGETS panelplugin-appindicator |
523 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
524 | + ) |
525 | |
526 | === modified file 'panel/applets/appindicator/appindicatorapplet.h' |
527 | --- panel/applets/appindicator/appindicatorapplet.h 2011-01-15 01:41:03 +0000 |
528 | +++ panel/applets/appindicator/appindicatorapplet.h 2011-08-16 14:11:07 +0000 |
529 | @@ -22,14 +22,14 @@ |
530 | #ifndef APPINDICATORAPPLET_H |
531 | #define APPINDICATORAPPLET_H |
532 | |
533 | -// Local |
534 | -#include <applet.h> |
535 | - |
536 | // Qt |
537 | #include <QDBusInterface> |
538 | #include <QMenuBar> |
539 | |
540 | -class AppIndicatorApplet : public Unity2d::Applet |
541 | +// Unity-2d |
542 | +#include <panelapplet.h> |
543 | + |
544 | +class AppIndicatorApplet : public Unity2d::PanelApplet |
545 | { |
546 | Q_OBJECT |
547 | public: |
548 | |
549 | === added file 'panel/applets/appindicator/plugin.cpp' |
550 | --- panel/applets/appindicator/plugin.cpp 1970-01-01 00:00:00 +0000 |
551 | +++ panel/applets/appindicator/plugin.cpp 2011-08-16 14:11:07 +0000 |
552 | @@ -0,0 +1,39 @@ |
553 | +/* |
554 | + * This file is part of unity-2d |
555 | + * |
556 | + * Copyright 2011 Canonical Ltd. |
557 | + * |
558 | + * Authors: |
559 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
560 | + * |
561 | + * This program is free software; you can redistribute it and/or modify |
562 | + * it under the terms of the GNU General Public License as published by |
563 | + * the Free Software Foundation; version 3. |
564 | + * |
565 | + * This program is distributed in the hope that it will be useful, |
566 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
567 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
568 | + * GNU General Public License for more details. |
569 | + * |
570 | + * You should have received a copy of the GNU General Public License |
571 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
572 | + */ |
573 | + |
574 | +#include "plugin.h" |
575 | +#include "appindicatorapplet.h" |
576 | + |
577 | +#include <QtPlugin> |
578 | + |
579 | +QString AppIndicatorPlugin::appletName() const |
580 | +{ |
581 | + return QString("appindicator"); |
582 | +} |
583 | + |
584 | +PanelApplet* AppIndicatorPlugin::createApplet() const |
585 | +{ |
586 | + return new AppIndicatorApplet(); |
587 | +} |
588 | + |
589 | +Q_EXPORT_PLUGIN2(panelplugin-appindicator, AppIndicatorPlugin) |
590 | + |
591 | +#include "plugin.moc" |
592 | |
593 | === added file 'panel/applets/appindicator/plugin.h' |
594 | --- panel/applets/appindicator/plugin.h 1970-01-01 00:00:00 +0000 |
595 | +++ panel/applets/appindicator/plugin.h 2011-08-16 14:11:07 +0000 |
596 | @@ -0,0 +1,40 @@ |
597 | +/* |
598 | + * This file is part of unity-2d |
599 | + * |
600 | + * Copyright 2011 Canonical Ltd. |
601 | + * |
602 | + * Authors: |
603 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
604 | + * |
605 | + * This program is free software; you can redistribute it and/or modify |
606 | + * it under the terms of the GNU General Public License as published by |
607 | + * the Free Software Foundation; version 3. |
608 | + * |
609 | + * This program is distributed in the hope that it will be useful, |
610 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
611 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
612 | + * GNU General Public License for more details. |
613 | + * |
614 | + * You should have received a copy of the GNU General Public License |
615 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
616 | + */ |
617 | + |
618 | +#ifndef APPINDICATOR_PLUGIN_H |
619 | +#define APPINDICATOR_PLUGIN_H |
620 | + |
621 | +#include <QString> |
622 | +#include <panelappletproviderinterface.h> |
623 | + |
624 | +using namespace Unity2d; |
625 | + |
626 | +class AppIndicatorPlugin : public QObject, PanelAppletProviderInterface |
627 | +{ |
628 | + Q_OBJECT |
629 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
630 | + |
631 | +public: |
632 | + QString appletName() const; |
633 | + PanelApplet* createApplet() const; |
634 | +}; |
635 | + |
636 | +#endif // APPINDICATOR_PLUGIN_H |
637 | |
638 | === added file 'panel/applets/appname/CMakeLists.txt' |
639 | --- panel/applets/appname/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
640 | +++ panel/applets/appname/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
641 | @@ -0,0 +1,51 @@ |
642 | +project(panelplugin-appname) |
643 | + |
644 | +# Dependencies |
645 | +pkg_check_modules(QTBAMF REQUIRED libqtbamf) |
646 | +pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
647 | + |
648 | +# Sources |
649 | +set(appname_SRCS |
650 | + appnameapplet.cpp |
651 | + menubarwidget.cpp |
652 | + registrar.cpp |
653 | + windowhelper.cpp |
654 | + plugin.cpp |
655 | + ) |
656 | + |
657 | +qt4_add_dbus_adaptor(appname_SRCS com.canonical.AppMenu.Registrar.xml |
658 | + registrar.h Registrar |
659 | + ) |
660 | + |
661 | +# Build |
662 | +include_directories( |
663 | + ${CMAKE_CURRENT_SOURCE_DIR} |
664 | + ${CMAKE_CURRENT_BINARY_DIR} |
665 | + ${QTBAMF_INCLUDE_DIRS} |
666 | + ${DBUSMENUQT_INCLUDE_DIRS} |
667 | + ${GTK_INCLUDE_DIRS} |
668 | + ${WNCK_INCLUDE_DIRS} |
669 | + ${libunity-2d-private_SOURCE_DIR}/src |
670 | + ) |
671 | + |
672 | +qt4_automoc(${appname_SRCS}) |
673 | +add_library(panelplugin-appname SHARED ${appname_SRCS}) |
674 | + |
675 | +set_target_properties(panelplugin-appname PROPERTIES |
676 | + LIBRARY_OUTPUT_DIRECTORY ".." |
677 | + VERSION 0 |
678 | + SOVERSION 0.0 |
679 | + ) |
680 | + |
681 | +target_link_libraries(panelplugin-appname |
682 | + ${QT_QTGUI_LIBRARIES} |
683 | + ${QT_QTCORE_LIBRARIES} |
684 | + ${GTK_LIBRARIES} |
685 | + ${WNCK_LIBRARIES} |
686 | + ${DBUSMENUQT_LDFLAGS} |
687 | + unity-2d-private |
688 | + ) |
689 | + |
690 | +install(TARGETS panelplugin-appname |
691 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
692 | + ) |
693 | |
694 | === modified file 'panel/applets/appname/appnameapplet.cpp' |
695 | --- panel/applets/appname/appnameapplet.cpp 2011-07-26 09:36:41 +0000 |
696 | +++ panel/applets/appname/appnameapplet.cpp 2011-08-16 14:11:07 +0000 |
697 | @@ -36,7 +36,6 @@ |
698 | |
699 | // Qt |
700 | #include <QAbstractButton> |
701 | -#include <QEvent> |
702 | #include <QHBoxLayout> |
703 | #include <QLabel> |
704 | #include <QLinearGradient> |
705 | @@ -53,9 +52,6 @@ |
706 | |
707 | static const int FADEOUT_WIDTH = 16; |
708 | |
709 | -namespace Unity2d |
710 | -{ |
711 | - |
712 | class WindowButton : public QAbstractButton |
713 | { |
714 | public: |
715 | @@ -220,7 +216,6 @@ |
716 | : d(new AppNameAppletPrivate) |
717 | { |
718 | d->q = this; |
719 | - setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum); |
720 | |
721 | QPalette palette; |
722 | palette.setColor(QPalette::WindowText, Qt::white); |
723 | @@ -301,6 +296,4 @@ |
724 | updateWidgets(); |
725 | } |
726 | |
727 | -} // namespace |
728 | - |
729 | #include "appnameapplet.moc" |
730 | |
731 | === modified file 'panel/applets/appname/appnameapplet.h' |
732 | --- panel/applets/appname/appnameapplet.h 2011-06-06 09:06:55 +0000 |
733 | +++ panel/applets/appname/appnameapplet.h 2011-08-16 14:11:07 +0000 |
734 | @@ -22,18 +22,14 @@ |
735 | #ifndef APPNAMEAPPLET_H |
736 | #define APPNAMEAPPLET_H |
737 | |
738 | -// Local |
739 | -#include <applet.h> |
740 | - |
741 | // Qt |
742 | - |
743 | -class QEvent; |
744 | - |
745 | -namespace Unity2d |
746 | -{ |
747 | +#include <QEvent> |
748 | + |
749 | +// Unity-2d |
750 | +#include <panelapplet.h> |
751 | |
752 | struct AppNameAppletPrivate; |
753 | -class AppNameApplet : public Applet |
754 | +class AppNameApplet : public Unity2d::PanelApplet |
755 | { |
756 | Q_OBJECT |
757 | public: |
758 | @@ -52,7 +48,5 @@ |
759 | AppNameAppletPrivate* const d; |
760 | }; |
761 | |
762 | -} // namespace |
763 | - |
764 | #endif /* APPNAMEAPPLET_H */ |
765 | |
766 | |
767 | === added file 'panel/applets/appname/plugin.cpp' |
768 | --- panel/applets/appname/plugin.cpp 1970-01-01 00:00:00 +0000 |
769 | +++ panel/applets/appname/plugin.cpp 2011-08-16 14:11:07 +0000 |
770 | @@ -0,0 +1,39 @@ |
771 | +/* |
772 | + * This file is part of unity-2d |
773 | + * |
774 | + * Copyright 2011 Canonical Ltd. |
775 | + * |
776 | + * Authors: |
777 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
778 | + * |
779 | + * This program is free software; you can redistribute it and/or modify |
780 | + * it under the terms of the GNU General Public License as published by |
781 | + * the Free Software Foundation; version 3. |
782 | + * |
783 | + * This program is distributed in the hope that it will be useful, |
784 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
785 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
786 | + * GNU General Public License for more details. |
787 | + * |
788 | + * You should have received a copy of the GNU General Public License |
789 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
790 | + */ |
791 | + |
792 | +#include "plugin.h" |
793 | +#include "appnameapplet.h" |
794 | + |
795 | +#include <QtPlugin> |
796 | + |
797 | +QString AppNamePlugin::appletName() const |
798 | +{ |
799 | + return QString("appname"); |
800 | +} |
801 | + |
802 | +PanelApplet* AppNamePlugin::createApplet() const |
803 | +{ |
804 | + return new AppNameApplet(); |
805 | +} |
806 | + |
807 | +Q_EXPORT_PLUGIN2(panelplugin-appname, AppNamePlugin) |
808 | + |
809 | +#include "plugin.moc" |
810 | |
811 | === added file 'panel/applets/appname/plugin.h' |
812 | --- panel/applets/appname/plugin.h 1970-01-01 00:00:00 +0000 |
813 | +++ panel/applets/appname/plugin.h 2011-08-16 14:11:07 +0000 |
814 | @@ -0,0 +1,40 @@ |
815 | +/* |
816 | + * This file is part of unity-2d |
817 | + * |
818 | + * Copyright 2011 Canonical Ltd. |
819 | + * |
820 | + * Authors: |
821 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
822 | + * |
823 | + * This program is free software; you can redistribute it and/or modify |
824 | + * it under the terms of the GNU General Public License as published by |
825 | + * the Free Software Foundation; version 3. |
826 | + * |
827 | + * This program is distributed in the hope that it will be useful, |
828 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
829 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
830 | + * GNU General Public License for more details. |
831 | + * |
832 | + * You should have received a copy of the GNU General Public License |
833 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
834 | + */ |
835 | + |
836 | +#ifndef APPNAME_PLUGIN_H |
837 | +#define APPNAME_PLUGIN_H |
838 | + |
839 | +#include <QString> |
840 | +#include <panelappletproviderinterface.h> |
841 | + |
842 | +using namespace Unity2d; |
843 | + |
844 | +class AppNamePlugin : public QObject, PanelAppletProviderInterface |
845 | +{ |
846 | + Q_OBJECT |
847 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
848 | + |
849 | +public: |
850 | + QString appletName() const; |
851 | + PanelApplet* createApplet() const; |
852 | +}; |
853 | + |
854 | +#endif // APPNAME_PLUGIN_H |
855 | |
856 | === removed directory 'panel/applets/common' |
857 | === removed file 'panel/applets/common/applet.cpp' |
858 | --- panel/applets/common/applet.cpp 2011-02-10 00:48:58 +0000 |
859 | +++ panel/applets/common/applet.cpp 1970-01-01 00:00:00 +0000 |
860 | @@ -1,46 +0,0 @@ |
861 | -/* |
862 | - * This file is part of unity-2d |
863 | - * |
864 | - * Copyright 2010 Canonical Ltd. |
865 | - * |
866 | - * Authors: |
867 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
868 | - * |
869 | - * This program is free software; you can redistribute it and/or modify |
870 | - * it under the terms of the GNU General Public License as published |
871 | - * by the Free Software Foundation; version 3. |
872 | - * |
873 | - * This program is distributed in the hope that it will be useful, |
874 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
875 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
876 | - * GNU General Public License for more details. |
877 | - * |
878 | - * You should have received a copy of the GNU General Public License |
879 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
880 | - */ |
881 | - |
882 | -// Self |
883 | -#include "applet.h" |
884 | - |
885 | -namespace Unity2d |
886 | -{ |
887 | - |
888 | -struct AppletPrivate |
889 | -{ |
890 | -}; |
891 | - |
892 | -Applet::Applet() |
893 | -: QWidget() |
894 | -, d(new AppletPrivate) |
895 | -{ |
896 | - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
897 | -} |
898 | - |
899 | -Applet::~Applet() |
900 | -{ |
901 | - delete d; |
902 | -} |
903 | - |
904 | -} // namespace |
905 | - |
906 | -#include "applet.moc" |
907 | |
908 | === removed file 'panel/applets/common/applet.h' |
909 | --- panel/applets/common/applet.h 2011-02-10 00:48:58 +0000 |
910 | +++ panel/applets/common/applet.h 1970-01-01 00:00:00 +0000 |
911 | @@ -1,48 +0,0 @@ |
912 | -/* |
913 | - * This file is part of unity-2d |
914 | - * |
915 | - * Copyright 2010 Canonical Ltd. |
916 | - * |
917 | - * Authors: |
918 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
919 | - * |
920 | - * This program is free software; you can redistribute it and/or modify |
921 | - * it under the terms of the GNU General Public License as published |
922 | - * by the Free Software Foundation; version 3. |
923 | - * |
924 | - * This program is distributed in the hope that it will be useful, |
925 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
926 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
927 | - * GNU General Public License for more details. |
928 | - * |
929 | - * You should have received a copy of the GNU General Public License |
930 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
931 | - */ |
932 | - |
933 | -#ifndef APPLET_H |
934 | -#define APPLET_H |
935 | - |
936 | -// Local |
937 | - |
938 | -// Qt |
939 | -#include <QWidget> |
940 | - |
941 | -namespace Unity2d |
942 | -{ |
943 | - |
944 | -struct AppletPrivate; |
945 | -class Applet : public QWidget |
946 | -{ |
947 | -Q_OBJECT |
948 | -public: |
949 | - Applet(); |
950 | - ~Applet(); |
951 | - |
952 | -private: |
953 | - Q_DISABLE_COPY(Applet) |
954 | - AppletPrivate* const d; |
955 | -}; |
956 | - |
957 | -} // namespace |
958 | - |
959 | -#endif /* APPLET_H */ |
960 | |
961 | === added file 'panel/applets/homebutton/CMakeLists.txt' |
962 | --- panel/applets/homebutton/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
963 | +++ panel/applets/homebutton/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
964 | @@ -0,0 +1,33 @@ |
965 | +project(panelplugin-homebutton) |
966 | + |
967 | +# Sources |
968 | +set(homebutton_SRCS |
969 | + homebuttonapplet.cpp |
970 | + homebutton.cpp |
971 | + plugin.cpp |
972 | + ) |
973 | + |
974 | +# Build |
975 | +include_directories( |
976 | + ${CMAKE_CURRENT_SOURCE_DIR} |
977 | + ${CMAKE_CURRENT_BINARY_DIR} |
978 | + ${libunity-2d-private_SOURCE_DIR}/src |
979 | + ) |
980 | + |
981 | +qt4_automoc(${homebutton_SRCS}) |
982 | +add_library(panelplugin-homebutton SHARED ${homebutton_SRCS}) |
983 | +set_target_properties(panelplugin-homebutton PROPERTIES |
984 | + LIBRARY_OUTPUT_DIRECTORY ".." |
985 | + VERSION 0 |
986 | + SOVERSION 0.0 |
987 | + ) |
988 | + |
989 | +target_link_libraries(panelplugin-homebutton |
990 | + ${QT_QTGUI_LIBRARIES} |
991 | + ${QT_QTCORE_LIBRARIES} |
992 | + unity-2d-private |
993 | + ) |
994 | + |
995 | +install(TARGETS panelplugin-homebutton |
996 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
997 | + ) |
998 | |
999 | === modified file 'panel/applets/homebutton/homebuttonapplet.cpp' |
1000 | --- panel/applets/homebutton/homebuttonapplet.cpp 2011-05-26 16:41:04 +0000 |
1001 | +++ panel/applets/homebutton/homebuttonapplet.cpp 2011-08-16 14:11:07 +0000 |
1002 | @@ -98,13 +98,13 @@ |
1003 | |
1004 | void HomeButtonApplet::enterEvent(QEvent* event) |
1005 | { |
1006 | - Unity2d::Applet::enterEvent(event); |
1007 | + QWidget::enterEvent(event); |
1008 | m_launcherClient->beginForceVisible(); |
1009 | } |
1010 | |
1011 | void HomeButtonApplet::leaveEvent(QEvent* event) |
1012 | { |
1013 | - Unity2d::Applet::leaveEvent(event); |
1014 | + QWidget::leaveEvent(event); |
1015 | m_launcherClient->endForceVisible(); |
1016 | } |
1017 | |
1018 | |
1019 | === modified file 'panel/applets/homebutton/homebuttonapplet.h' |
1020 | --- panel/applets/homebutton/homebuttonapplet.h 2011-05-26 16:41:04 +0000 |
1021 | +++ panel/applets/homebutton/homebuttonapplet.h 2011-08-16 14:11:07 +0000 |
1022 | @@ -23,13 +23,15 @@ |
1023 | #define HOMEBUTTONAPPLET_H |
1024 | |
1025 | // Local |
1026 | -#include <applet.h> |
1027 | #include "homebutton.h" |
1028 | |
1029 | +// Unity-2d |
1030 | +#include <panelapplet.h> |
1031 | + |
1032 | class QDBusInterface; |
1033 | class LauncherClient; |
1034 | |
1035 | -class HomeButtonApplet : public Unity2d::Applet |
1036 | +class HomeButtonApplet : public Unity2d::PanelApplet |
1037 | { |
1038 | Q_OBJECT |
1039 | public: |
1040 | |
1041 | === added file 'panel/applets/homebutton/plugin.cpp' |
1042 | --- panel/applets/homebutton/plugin.cpp 1970-01-01 00:00:00 +0000 |
1043 | +++ panel/applets/homebutton/plugin.cpp 2011-08-16 14:11:07 +0000 |
1044 | @@ -0,0 +1,39 @@ |
1045 | +/* |
1046 | + * This file is part of unity-2d |
1047 | + * |
1048 | + * Copyright 2011 Canonical Ltd. |
1049 | + * |
1050 | + * Authors: |
1051 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1052 | + * |
1053 | + * This program is free software; you can redistribute it and/or modify |
1054 | + * it under the terms of the GNU General Public License as published by |
1055 | + * the Free Software Foundation; version 3. |
1056 | + * |
1057 | + * This program is distributed in the hope that it will be useful, |
1058 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1059 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1060 | + * GNU General Public License for more details. |
1061 | + * |
1062 | + * You should have received a copy of the GNU General Public License |
1063 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1064 | + */ |
1065 | + |
1066 | +#include "plugin.h" |
1067 | +#include "homebuttonapplet.h" |
1068 | + |
1069 | +#include <QtPlugin> |
1070 | + |
1071 | +QString HomeButtonPlugin::appletName() const |
1072 | +{ |
1073 | + return QString("homebutton"); |
1074 | +} |
1075 | + |
1076 | +PanelApplet* HomeButtonPlugin::createApplet() const |
1077 | +{ |
1078 | + return new HomeButtonApplet(); |
1079 | +} |
1080 | + |
1081 | +Q_EXPORT_PLUGIN2(panelplugin-homebutton, HomeButtonPlugin) |
1082 | + |
1083 | +#include "plugin.moc" |
1084 | |
1085 | === added file 'panel/applets/homebutton/plugin.h' |
1086 | --- panel/applets/homebutton/plugin.h 1970-01-01 00:00:00 +0000 |
1087 | +++ panel/applets/homebutton/plugin.h 2011-08-16 14:11:07 +0000 |
1088 | @@ -0,0 +1,40 @@ |
1089 | +/* |
1090 | + * This file is part of unity-2d |
1091 | + * |
1092 | + * Copyright 2011 Canonical Ltd. |
1093 | + * |
1094 | + * Authors: |
1095 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1096 | + * |
1097 | + * This program is free software; you can redistribute it and/or modify |
1098 | + * it under the terms of the GNU General Public License as published by |
1099 | + * the Free Software Foundation; version 3. |
1100 | + * |
1101 | + * This program is distributed in the hope that it will be useful, |
1102 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1103 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1104 | + * GNU General Public License for more details. |
1105 | + * |
1106 | + * You should have received a copy of the GNU General Public License |
1107 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1108 | + */ |
1109 | + |
1110 | +#ifndef HOMEBUTTON_PLUGIN_H |
1111 | +#define HOMEBUTTON_PLUGIN_H |
1112 | + |
1113 | +#include <QString> |
1114 | +#include <panelappletproviderinterface.h> |
1115 | + |
1116 | +using namespace Unity2d; |
1117 | + |
1118 | +class HomeButtonPlugin : public QObject, PanelAppletProviderInterface |
1119 | +{ |
1120 | + Q_OBJECT |
1121 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
1122 | + |
1123 | +public: |
1124 | + QString appletName() const; |
1125 | + PanelApplet* createApplet() const; |
1126 | +}; |
1127 | + |
1128 | +#endif // HOMEBUTTON_PLUGIN_H |
1129 | |
1130 | === added file 'panel/applets/indicator/CMakeLists.txt' |
1131 | --- panel/applets/indicator/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1132 | +++ panel/applets/indicator/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
1133 | @@ -0,0 +1,61 @@ |
1134 | +project(panelplugin-indicator) |
1135 | + |
1136 | +macro(read_pkg_variable cmake_var pkg pkg_var) |
1137 | + execute_process( |
1138 | + COMMAND pkg-config --variable=${pkg_var} ${pkg} |
1139 | + OUTPUT_VARIABLE tmp |
1140 | + ) |
1141 | + # Remove trailing newline from ${tmp} |
1142 | + string(STRIP "${tmp}" ${cmake_var}) |
1143 | +endmacro(read_pkg_variable) |
1144 | + |
1145 | +# Dependencies |
1146 | +pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
1147 | +pkg_check_modules(INDICATOR REQUIRED indicator) |
1148 | + |
1149 | +# Get indicator dirs from pkgconfig |
1150 | +read_pkg_variable(INDICATOR_DIR indicator indicatordir) |
1151 | +read_pkg_variable(INDICATOR_ICONS_DIR indicator iconsdir) |
1152 | +configure_file(indicator-config.h.in indicator-config.h) |
1153 | + |
1154 | +# Sources |
1155 | +set(indicator_SRCS |
1156 | + abstractindicator.cpp |
1157 | + datetimeindicator.cpp |
1158 | + indicatorapplet.cpp |
1159 | + indicatorservicemanager.cpp |
1160 | + indicator.c |
1161 | + plugin.cpp |
1162 | + ) |
1163 | + |
1164 | +# Build |
1165 | +include_directories( |
1166 | + ${CMAKE_CURRENT_SOURCE_DIR} |
1167 | + ${CMAKE_CURRENT_BINARY_DIR} |
1168 | + ${DBUSMENUQT_INCLUDE_DIRS} |
1169 | + ${GTK_INCLUDE_DIRS} |
1170 | + ${INDICATOR_INCLUDE_DIRS} |
1171 | + ${CMAKE_CURRENT_BINARY_DIR} |
1172 | + ${libunity-2d-private_SOURCE_DIR}/src |
1173 | + ) |
1174 | + |
1175 | +qt4_automoc(${indicator_SRCS}) |
1176 | +add_library(panelplugin-indicator SHARED ${indicator_SRCS}) |
1177 | +set_target_properties(panelplugin-indicator PROPERTIES |
1178 | + LIBRARY_OUTPUT_DIRECTORY ".." |
1179 | + VERSION 0 |
1180 | + SOVERSION 0.0 |
1181 | + ) |
1182 | + |
1183 | +target_link_libraries(panelplugin-indicator |
1184 | + ${QT_QTGUI_LIBRARIES} |
1185 | + ${QT_QTCORE_LIBRARIES} |
1186 | + ${DBUSMENUQT_LDFLAGS} |
1187 | + ${GTK_LDFLAGS} |
1188 | + ${INDICATOR_LDFLAGS} |
1189 | + unity-2d-private |
1190 | + ) |
1191 | + |
1192 | +install(TARGETS panelplugin-indicator |
1193 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
1194 | + ) |
1195 | |
1196 | === renamed file 'panel/applets/indicator-config.h.in' => 'panel/applets/indicator/indicator-config.h.in' |
1197 | === modified file 'panel/applets/indicator/indicatorapplet.h' |
1198 | --- panel/applets/indicator/indicatorapplet.h 2011-01-15 01:41:03 +0000 |
1199 | +++ panel/applets/indicator/indicatorapplet.h 2011-08-16 14:11:07 +0000 |
1200 | @@ -22,18 +22,18 @@ |
1201 | #ifndef INDICATORAPPLET_H |
1202 | #define INDICATORAPPLET_H |
1203 | |
1204 | -// Local |
1205 | -#include <applet.h> |
1206 | - |
1207 | // Qt |
1208 | #include <QDBusInterface> |
1209 | #include <QMenuBar> |
1210 | |
1211 | +// Unity-2d |
1212 | +#include <panelapplet.h> |
1213 | + |
1214 | class QX11EmbedContainer; |
1215 | |
1216 | struct _IndicatorPlugin; |
1217 | |
1218 | -class IndicatorApplet : public Unity2d::Applet |
1219 | +class IndicatorApplet : public Unity2d::PanelApplet |
1220 | { |
1221 | Q_OBJECT |
1222 | public: |
1223 | |
1224 | === added file 'panel/applets/indicator/plugin.cpp' |
1225 | --- panel/applets/indicator/plugin.cpp 1970-01-01 00:00:00 +0000 |
1226 | +++ panel/applets/indicator/plugin.cpp 2011-08-16 14:11:07 +0000 |
1227 | @@ -0,0 +1,39 @@ |
1228 | +/* |
1229 | + * This file is part of unity-2d |
1230 | + * |
1231 | + * Copyright 2011 Canonical Ltd. |
1232 | + * |
1233 | + * Authors: |
1234 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1235 | + * |
1236 | + * This program is free software; you can redistribute it and/or modify |
1237 | + * it under the terms of the GNU General Public License as published by |
1238 | + * the Free Software Foundation; version 3. |
1239 | + * |
1240 | + * This program is distributed in the hope that it will be useful, |
1241 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1242 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1243 | + * GNU General Public License for more details. |
1244 | + * |
1245 | + * You should have received a copy of the GNU General Public License |
1246 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1247 | + */ |
1248 | + |
1249 | +#include "plugin.h" |
1250 | +#include "indicatorapplet.h" |
1251 | + |
1252 | +#include <QtPlugin> |
1253 | + |
1254 | +QString IndicatorPlugin::appletName() const |
1255 | +{ |
1256 | + return QString("indicator"); |
1257 | +} |
1258 | + |
1259 | +PanelApplet* IndicatorPlugin::createApplet() const |
1260 | +{ |
1261 | + return new IndicatorApplet(); |
1262 | +} |
1263 | + |
1264 | +Q_EXPORT_PLUGIN2(panelplugin-indicator, IndicatorPlugin) |
1265 | + |
1266 | +#include "plugin.moc" |
1267 | |
1268 | === added file 'panel/applets/indicator/plugin.h' |
1269 | --- panel/applets/indicator/plugin.h 1970-01-01 00:00:00 +0000 |
1270 | +++ panel/applets/indicator/plugin.h 2011-08-16 14:11:07 +0000 |
1271 | @@ -0,0 +1,40 @@ |
1272 | +/* |
1273 | + * This file is part of unity-2d |
1274 | + * |
1275 | + * Copyright 2011 Canonical Ltd. |
1276 | + * |
1277 | + * Authors: |
1278 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1279 | + * |
1280 | + * This program is free software; you can redistribute it and/or modify |
1281 | + * it under the terms of the GNU General Public License as published by |
1282 | + * the Free Software Foundation; version 3. |
1283 | + * |
1284 | + * This program is distributed in the hope that it will be useful, |
1285 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1286 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1287 | + * GNU General Public License for more details. |
1288 | + * |
1289 | + * You should have received a copy of the GNU General Public License |
1290 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1291 | + */ |
1292 | + |
1293 | +#ifndef INDICATOR_PLUGIN_H |
1294 | +#define INDICATOR_PLUGIN_H |
1295 | + |
1296 | +#include <QString> |
1297 | +#include <panelappletproviderinterface.h> |
1298 | + |
1299 | +using namespace Unity2d; |
1300 | + |
1301 | +class IndicatorPlugin : public QObject, PanelAppletProviderInterface |
1302 | +{ |
1303 | + Q_OBJECT |
1304 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
1305 | + |
1306 | +public: |
1307 | + QString appletName() const; |
1308 | + PanelApplet* createApplet() const; |
1309 | +}; |
1310 | + |
1311 | +#endif // INDICATOR_PLUGIN_H |
1312 | |
1313 | === added file 'panel/applets/legacytray/CMakeLists.txt' |
1314 | --- panel/applets/legacytray/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1315 | +++ panel/applets/legacytray/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
1316 | @@ -0,0 +1,43 @@ |
1317 | +project(panelplugin-legacytray) |
1318 | + |
1319 | +# Sources |
1320 | +set(legacytray_SRCS |
1321 | + legacytrayapplet.cpp |
1322 | + fdoselectionmanager.cpp |
1323 | + fdotask.cpp |
1324 | + x11embedcontainer.cpp |
1325 | + x11embeddelegate.cpp |
1326 | + x11embedpainter.cpp |
1327 | + plugin.cpp |
1328 | + ) |
1329 | + |
1330 | +# Build |
1331 | +include_directories( |
1332 | + ${CMAKE_CURRENT_SOURCE_DIR} |
1333 | + ${CMAKE_CURRENT_BINARY_DIR} |
1334 | + ${X11_INCLUDE_DIR} |
1335 | + ${libunity-2d-private_SOURCE_DIR}/src |
1336 | + ) |
1337 | + |
1338 | +qt4_automoc(${legacytray_SRCS}) |
1339 | +add_library(panelplugin-legacytray SHARED ${legacytray_SRCS}) |
1340 | +set_target_properties(panelplugin-legacytray PROPERTIES |
1341 | + LIBRARY_OUTPUT_DIRECTORY ".." |
1342 | + VERSION 0 |
1343 | + SOVERSION 0.0 |
1344 | + ) |
1345 | + |
1346 | +target_link_libraries(panelplugin-legacytray |
1347 | + ${QT_QTGUI_LIBRARIES} |
1348 | + ${QT_QTCORE_LIBRARIES} |
1349 | + ${X11_LIBRARIES} |
1350 | + ${X11_Xrender_LIB} |
1351 | + ${X11_Xcomposite_LIB} |
1352 | + ${X11_Xdamage_LIB} |
1353 | + ${X11_Xfixes_LIB} |
1354 | + unity-2d-private |
1355 | + ) |
1356 | + |
1357 | +install(TARGETS panelplugin-legacytray |
1358 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
1359 | + ) |
1360 | |
1361 | === modified file 'panel/applets/legacytray/legacytrayapplet.h' |
1362 | --- panel/applets/legacytray/legacytrayapplet.h 2011-01-15 01:41:03 +0000 |
1363 | +++ panel/applets/legacytray/legacytrayapplet.h 2011-08-16 14:11:07 +0000 |
1364 | @@ -22,10 +22,8 @@ |
1365 | #ifndef LEGACYTRAYAPPLET_H |
1366 | #define LEGACYTRAYAPPLET_H |
1367 | |
1368 | -// Local |
1369 | -#include <applet.h> |
1370 | - |
1371 | -// Qt |
1372 | +// Unity-2d |
1373 | +#include <panelapplet.h> |
1374 | |
1375 | namespace SystemTray |
1376 | { |
1377 | @@ -33,7 +31,7 @@ |
1378 | class Task; |
1379 | } |
1380 | |
1381 | -class LegacyTrayApplet : public Unity2d::Applet |
1382 | +class LegacyTrayApplet : public Unity2d::PanelApplet |
1383 | { |
1384 | Q_OBJECT |
1385 | public: |
1386 | |
1387 | === added file 'panel/applets/legacytray/plugin.cpp' |
1388 | --- panel/applets/legacytray/plugin.cpp 1970-01-01 00:00:00 +0000 |
1389 | +++ panel/applets/legacytray/plugin.cpp 2011-08-16 14:11:07 +0000 |
1390 | @@ -0,0 +1,39 @@ |
1391 | +/* |
1392 | + * This file is part of unity-2d |
1393 | + * |
1394 | + * Copyright 2011 Canonical Ltd. |
1395 | + * |
1396 | + * Authors: |
1397 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1398 | + * |
1399 | + * This program is free software; you can redistribute it and/or modify |
1400 | + * it under the terms of the GNU General Public License as published by |
1401 | + * the Free Software Foundation; version 3. |
1402 | + * |
1403 | + * This program is distributed in the hope that it will be useful, |
1404 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1405 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1406 | + * GNU General Public License for more details. |
1407 | + * |
1408 | + * You should have received a copy of the GNU General Public License |
1409 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1410 | + */ |
1411 | + |
1412 | +#include "plugin.h" |
1413 | +#include "legacytrayapplet.h" |
1414 | + |
1415 | +#include <QtPlugin> |
1416 | + |
1417 | +QString LegacyTrayPlugin::appletName() const |
1418 | +{ |
1419 | + return QString("legacytray"); |
1420 | +} |
1421 | + |
1422 | +PanelApplet* LegacyTrayPlugin::createApplet() const |
1423 | +{ |
1424 | + return new LegacyTrayApplet(); |
1425 | +} |
1426 | + |
1427 | +Q_EXPORT_PLUGIN2(panelplugin-legacytray, LegacyTrayPlugin) |
1428 | + |
1429 | +#include "plugin.moc" |
1430 | |
1431 | === added file 'panel/applets/legacytray/plugin.h' |
1432 | --- panel/applets/legacytray/plugin.h 1970-01-01 00:00:00 +0000 |
1433 | +++ panel/applets/legacytray/plugin.h 2011-08-16 14:11:07 +0000 |
1434 | @@ -0,0 +1,40 @@ |
1435 | +/* |
1436 | + * This file is part of unity-2d |
1437 | + * |
1438 | + * Copyright 2011 Canonical Ltd. |
1439 | + * |
1440 | + * Authors: |
1441 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1442 | + * |
1443 | + * This program is free software; you can redistribute it and/or modify |
1444 | + * it under the terms of the GNU General Public License as published by |
1445 | + * the Free Software Foundation; version 3. |
1446 | + * |
1447 | + * This program is distributed in the hope that it will be useful, |
1448 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1449 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1450 | + * GNU General Public License for more details. |
1451 | + * |
1452 | + * You should have received a copy of the GNU General Public License |
1453 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1454 | + */ |
1455 | + |
1456 | +#ifndef LEGACYTRAY_PLUGIN_H |
1457 | +#define LEGACYTRAY_PLUGIN_H |
1458 | + |
1459 | +#include <QString> |
1460 | +#include <panelappletproviderinterface.h> |
1461 | + |
1462 | +using namespace Unity2d; |
1463 | + |
1464 | +class LegacyTrayPlugin : public QObject, PanelAppletProviderInterface |
1465 | +{ |
1466 | + Q_OBJECT |
1467 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
1468 | + |
1469 | +public: |
1470 | + QString appletName() const; |
1471 | + PanelApplet* createApplet() const; |
1472 | +}; |
1473 | + |
1474 | +#endif // LEGACYTRAY_PLUGIN_H |
1475 | |
1476 | === added directory 'panel/applets/separator' |
1477 | === added file 'panel/applets/separator/CMakeLists.txt' |
1478 | --- panel/applets/separator/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1479 | +++ panel/applets/separator/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
1480 | @@ -0,0 +1,32 @@ |
1481 | +project(panelplugin-separator) |
1482 | + |
1483 | +# Sources |
1484 | +set(separator_SRCS |
1485 | + separatorapplet.cpp |
1486 | + plugin.cpp |
1487 | + ) |
1488 | + |
1489 | +# Build |
1490 | +include_directories( |
1491 | + ${CMAKE_CURRENT_SOURCE_DIR} |
1492 | + ${CMAKE_CURRENT_BINARY_DIR} |
1493 | + ${libunity-2d-private_SOURCE_DIR}/src |
1494 | + ) |
1495 | + |
1496 | +qt4_automoc(${separator_SRCS}) |
1497 | +add_library(panelplugin-separator SHARED ${separator_SRCS}) |
1498 | +set_target_properties(panelplugin-separator PROPERTIES |
1499 | + LIBRARY_OUTPUT_DIRECTORY ".." |
1500 | + VERSION 0 |
1501 | + SOVERSION 0.0 |
1502 | + ) |
1503 | + |
1504 | +target_link_libraries(panelplugin-separator |
1505 | + ${QT_QTGUI_LIBRARIES} |
1506 | + ${QT_QTCORE_LIBRARIES} |
1507 | + unity-2d-private |
1508 | + ) |
1509 | + |
1510 | +install(TARGETS panelplugin-separator |
1511 | + LIBRARY DESTINATION lib/unity-2d/plugins/panel |
1512 | + ) |
1513 | |
1514 | === added file 'panel/applets/separator/plugin.cpp' |
1515 | --- panel/applets/separator/plugin.cpp 1970-01-01 00:00:00 +0000 |
1516 | +++ panel/applets/separator/plugin.cpp 2011-08-16 14:11:07 +0000 |
1517 | @@ -0,0 +1,39 @@ |
1518 | +/* |
1519 | + * This file is part of unity-2d |
1520 | + * |
1521 | + * Copyright 2011 Canonical Ltd. |
1522 | + * |
1523 | + * Authors: |
1524 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1525 | + * |
1526 | + * This program is free software; you can redistribute it and/or modify |
1527 | + * it under the terms of the GNU General Public License as published by |
1528 | + * the Free Software Foundation; version 3. |
1529 | + * |
1530 | + * This program is distributed in the hope that it will be useful, |
1531 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1532 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1533 | + * GNU General Public License for more details. |
1534 | + * |
1535 | + * You should have received a copy of the GNU General Public License |
1536 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1537 | + */ |
1538 | + |
1539 | +#include "plugin.h" |
1540 | +#include "separatorapplet.h" |
1541 | + |
1542 | +#include <QtPlugin> |
1543 | + |
1544 | +QString SeparatorPlugin::appletName() const |
1545 | +{ |
1546 | + return QString("separator"); |
1547 | +} |
1548 | + |
1549 | +PanelApplet* SeparatorPlugin::createApplet() const |
1550 | +{ |
1551 | + return new SeparatorApplet(); |
1552 | +} |
1553 | + |
1554 | +Q_EXPORT_PLUGIN2(panelplugin-separator, SeparatorPlugin) |
1555 | + |
1556 | +#include "plugin.moc" |
1557 | |
1558 | === added file 'panel/applets/separator/plugin.h' |
1559 | --- panel/applets/separator/plugin.h 1970-01-01 00:00:00 +0000 |
1560 | +++ panel/applets/separator/plugin.h 2011-08-16 14:11:07 +0000 |
1561 | @@ -0,0 +1,40 @@ |
1562 | +/* |
1563 | + * This file is part of unity-2d |
1564 | + * |
1565 | + * Copyright 2011 Canonical Ltd. |
1566 | + * |
1567 | + * Authors: |
1568 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1569 | + * |
1570 | + * This program is free software; you can redistribute it and/or modify |
1571 | + * it under the terms of the GNU General Public License as published by |
1572 | + * the Free Software Foundation; version 3. |
1573 | + * |
1574 | + * This program is distributed in the hope that it will be useful, |
1575 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1576 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1577 | + * GNU General Public License for more details. |
1578 | + * |
1579 | + * You should have received a copy of the GNU General Public License |
1580 | + * along with this program. If not, see <http://www.gnu.org/licenses/> |
1581 | + */ |
1582 | + |
1583 | +#ifndef SEPARATOR_PLUGIN_H |
1584 | +#define SEPARATOR_PLUGIN_H |
1585 | + |
1586 | +#include <QString> |
1587 | +#include <panelappletproviderinterface.h> |
1588 | + |
1589 | +using namespace Unity2d; |
1590 | + |
1591 | +class SeparatorPlugin : public QObject, PanelAppletProviderInterface |
1592 | +{ |
1593 | + Q_OBJECT |
1594 | + Q_INTERFACES(Unity2d::PanelAppletProviderInterface) |
1595 | + |
1596 | +public: |
1597 | + QString appletName() const; |
1598 | + PanelApplet* createApplet() const; |
1599 | +}; |
1600 | + |
1601 | +#endif // SEPARATOR_PLUGIN_H |
1602 | |
1603 | === added file 'panel/applets/separator/separatorapplet.cpp' |
1604 | --- panel/applets/separator/separatorapplet.cpp 1970-01-01 00:00:00 +0000 |
1605 | +++ panel/applets/separator/separatorapplet.cpp 2011-08-16 14:11:07 +0000 |
1606 | @@ -0,0 +1,44 @@ |
1607 | +/* |
1608 | + * This file is part of unity-2d |
1609 | + * |
1610 | + * Copyright 2011 Canonical Ltd. |
1611 | + * |
1612 | + * Authors: |
1613 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1614 | + * |
1615 | + * This program is free software; you can redistribute it and/or modify |
1616 | + * it under the terms of the GNU General Public License as published by |
1617 | + * the Free Software Foundation; version 3. |
1618 | + * |
1619 | + * This program is distributed in the hope that it will be useful, |
1620 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1621 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1622 | + * GNU General Public License for more details. |
1623 | + * |
1624 | + * You should have received a copy of the GNU General Public License |
1625 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1626 | + */ |
1627 | + |
1628 | +// Self |
1629 | +#include "separatorapplet.h" |
1630 | + |
1631 | +// Local |
1632 | +#include <config.h> |
1633 | + |
1634 | +// QT |
1635 | +#include <QPixmap> |
1636 | +#include <QHBoxLayout> |
1637 | + |
1638 | +SeparatorApplet::SeparatorApplet() |
1639 | + : m_separator(new QLabel()) |
1640 | +{ |
1641 | + QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png"); |
1642 | + m_separator->setPixmap(pix); |
1643 | + m_separator->setFixedSize(pix.size()); |
1644 | + |
1645 | + QHBoxLayout* layout = new QHBoxLayout(this); |
1646 | + layout->setMargin(0); |
1647 | + layout->addWidget(m_separator); |
1648 | +} |
1649 | + |
1650 | +#include "separatorapplet.moc" |
1651 | |
1652 | === added file 'panel/applets/separator/separatorapplet.h' |
1653 | --- panel/applets/separator/separatorapplet.h 1970-01-01 00:00:00 +0000 |
1654 | +++ panel/applets/separator/separatorapplet.h 2011-08-16 14:11:07 +0000 |
1655 | @@ -0,0 +1,44 @@ |
1656 | +/* |
1657 | + * This file is part of unity-2d |
1658 | + * |
1659 | + * Copyright 2011 Canonical Ltd. |
1660 | + * |
1661 | + * Authors: |
1662 | + * - Ugo Riboni <ugo.riboni@canonical.com> |
1663 | + * |
1664 | + * This program is free software; you can redistribute it and/or modify |
1665 | + * it under the terms of the GNU General Public License as published by |
1666 | + * the Free Software Foundation; version 3. |
1667 | + * |
1668 | + * This program is distributed in the hope that it will be useful, |
1669 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1670 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1671 | + * GNU General Public License for more details. |
1672 | + * |
1673 | + * You should have received a copy of the GNU General Public License |
1674 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1675 | + */ |
1676 | + |
1677 | +#ifndef SEPARATORAPPLET_H |
1678 | +#define SEPARATORAPPLET_H |
1679 | + |
1680 | +// Qt |
1681 | +#include <QLabel> |
1682 | + |
1683 | +// Unity-2d |
1684 | +#include <panelapplet.h> |
1685 | + |
1686 | +using namespace Unity2d; |
1687 | + |
1688 | +class SeparatorApplet : public Unity2d::PanelApplet |
1689 | +{ |
1690 | +Q_OBJECT |
1691 | +public: |
1692 | + SeparatorApplet(); |
1693 | + |
1694 | +private: |
1695 | + Q_DISABLE_COPY(SeparatorApplet) |
1696 | + QLabel* m_separator; |
1697 | +}; |
1698 | + |
1699 | +#endif /* SEPARATORAPPLET_H */ |
1700 | |
1701 | === modified file 'panel/tests/CMakeLists.txt' |
1702 | --- panel/tests/CMakeLists.txt 2011-01-27 16:23:33 +0000 |
1703 | +++ panel/tests/CMakeLists.txt 2011-08-16 14:11:07 +0000 |
1704 | @@ -6,7 +6,7 @@ |
1705 | qt4_generate_moc(${_test}.cpp ${_test}.moc) |
1706 | target_link_libraries(${_test} |
1707 | ${QT_QTTEST_LIBRARIES} |
1708 | - uqapplets |
1709 | + panelplugin-homebutton |
1710 | ) |
1711 | set(_test_list "${_test_list};${_test}") |
1712 | endforeach(_test) |
1713 | @@ -17,8 +17,7 @@ |
1714 | endmacro(panel_tests) |
1715 | |
1716 | include_directories( |
1717 | - ${uqapplets_SOURCE_DIR}/homebutton |
1718 | - ${uqapplets_SOURCE_DIR}/common |
1719 | + ${panelplugin-homebutton_SOURCE_DIR} |
1720 | ${CMAKE_CURRENT_BINARY_DIR} |
1721 | ${QT_QTTEST_INCLUDE_DIR} |
1722 | ) |
1723 | |
1724 | === modified file 'panel/tests/homebuttonapplettest.cpp' |
1725 | --- panel/tests/homebuttonapplettest.cpp 2011-01-15 01:41:03 +0000 |
1726 | +++ panel/tests/homebuttonapplettest.cpp 2011-08-16 14:11:07 +0000 |
1727 | @@ -25,11 +25,10 @@ |
1728 | // Qt |
1729 | #include <QtTestGui> |
1730 | |
1731 | -using namespace Unity2d; |
1732 | - |
1733 | class HomeButtonAppletTest : public QObject |
1734 | { |
1735 | Q_OBJECT |
1736 | + |
1737 | private Q_SLOTS: |
1738 | void testCreateButton() |
1739 | { |
data/com. canonical. Unity2d. gschema. xml:
24 + <schema path="/ com/canonical/ unity-2d/ panel/" id="com. canonical. Unity2d. Panel" gettext- domain= "unity- 2d"> ["!homebutton" , "!separator", "appname", "!legacytray", "indicator" ]</default>
25 + <key type="as" name="applets">
26 + <default>
27 + <summary>Applets to display in the panel</summary>
GSettings schema allows you to write this in a simpler way: you could use type="a(sb)" where "s" is the name and "b" is the boolean for "only on first screen". And if you need it, you can also add the expanding here, having the type as "a(sbb)". I see that there's also a "child" element for GSettings schema, but I don't know much about GSettings myself, so I'm not sure how suitable it is for our case.
34 + <key type="s" name="expanding"> "appname" </default>
35 + <default>
36 + <summary>Applet that should expand to fill all unused space</summary>
Why does it need to be specified here? I'd rather let the applet itself set the desired policy on its widget; also, in that way you could have more than one applet expanding, and not just one.
libunity- 2d-private/ src/appletprovi derinterface. h:
88 + virtual QString getAppletName() const = 0;
89 + virtual QWidget* getApplet() const = 0;
Qt coding style is appletName() and applet(), with no "get".
(it would also be "Type *variable", but I see that's never used in unity-2d so
I won't interfere :-) )
panel/CMakeList s.txt: ry(tests) ory(tests)
104 -add_subdirecto
105 +#add_subdirect
Looks suspicious. :-)
panel/app/ panelmanager. cpp: nment>
162 -#include <QLabel>
163 +#include <QProcessEnviro
164 +#include <QFileInfo>
165 +#include <QDir>
166 +#include <QHash>
167 +#include <QPluginLoader>
168 +#include <QDebug>
169 +#include <QVariant>
Please sort include files alphabetically (and generally, any list where order is not otherwise important).
206 + if (!pluginFileInf o.exists( ) || !pluginFileInfo .isDir( )) {
207 + qWarning() << "Panel plugin path does not exist or it is not a directory:" << pluginPath;
208 + return plugins;
209 + }
The "exists" test is unnecessary, and the error message can also simply be: "The plugin directory does not exist:".
BTW, I see the rest of the code is using UQ_WARNING and UQ_DEBUG instead of qWarning and qDebug.
226 + if (provider == NULL) {
Qt style prefers 0 to NULL.
296 + if (!(onlyLeftmost && screen != leftmost)) { >getApplet( );
297 + QWidget *applet = provider-
This condition's logic is a bit twisted. :-)
I suggest:
if (screen == leftmost || !onlyLeftmost)
Got to leave now. I'll continue the review on Monday. :-)