Merge lp:~didrocks/unity-2d/subdatadir into lp:unity-2d/3.0
- subdatadir
- Merge into natty
Status: | Superseded |
---|---|
Proposed branch: | lp:~didrocks/unity-2d/subdatadir |
Merge into: | lp:unity-2d/3.0 |
Diff against target: |
6908 lines (+2010/-2400) 169 files modified
CMakeLists.txt (+6/-3) data/unity-2d.convert (+0/-2) debian/20_ubuntu-2d-gconf-default (+0/-8) debian/20_ubuntu-2d-gconf-mandatory (+0/-1) debian/changelog (+78/-17) debian/control (+13/-10) debian/gconf/ubuntu-2d.default.path (+2/-2) debian/gconf/ubuntu-2d.mandatory.path (+2/-2) debian/unity-2d-panel.install (+0/-2) debian/unity-2d.gconf-defaults (+4/-0) debian/unity-2d.install (+2/-4) debian/unity-2d.postinst (+12/-15) debian/unity-2d.postrm (+11/-14) debian/unity-2d.preinst (+16/-0) launcher/Launcher.qml (+11/-0) launcher/LauncherItem.qml (+2/-0) launcher/LauncherList.qml (+11/-0) launcher/app/launcher.cpp (+2/-0) libunity-2d-private/CMakeLists.txt (+1/-1) libunity-2d-private/Unity2d/GnomeBackground.qml (+12/-22) libunity-2d-private/Unity2d/plugin.cpp (+0/-4) libunity-2d-private/src/CMakeLists.txt (+5/-0) libunity-2d-private/src/debug.cpp (+23/-0) libunity-2d-private/src/debug_p.h (+6/-0) libunity-2d-private/src/launcherapplication.cpp (+4/-6) libunity-2d-private/src/launcherapplicationslist.cpp (+20/-1) libunity-2d-private/src/launcherapplicationslist.h (+2/-1) libunity-2d-private/src/launchermenu.cpp (+1/-0) libunity-2d-private/src/screeninfo.cpp (+1/-3) libunity-2d-private/src/unity2dapplication.cpp (+83/-1) libunity-2d-private/src/unity2dapplication.h (+3/-0) libunity-2d-private/src/windowinfo.cpp (+1/-3) libunity-2d-private/src/workspacesinfo.cpp (+1/-3) panel/CMakeLists.txt (+3/-5) panel/app/CMakeLists.txt (+3/-1) panel/app/main.cpp (+5/-2) panel/app/panelmanager.cpp (+34/-46) panel/app/panelmanager.h (+2/-0) panel/app/unity2dstyle.cpp (+0/-98) panel/app/unity2dstyle.h (+0/-44) panel/applets/CMakeLists.txt (+15/-26) panel/applets/appname/appnameapplet.cpp (+7/-57) panel/applets/appname/appnameapplet.h (+3/-1) panel/applets/appname/com.canonical.AppMenu.Registrar.xml (+0/-82) panel/applets/appname/croppedlabel.cpp (+140/-0) panel/applets/appname/croppedlabel.h (+45/-0) panel/applets/appname/menubarwidget.cpp (+78/-279) panel/applets/appname/menubarwidget.h (+25/-66) panel/applets/appname/registrar.cpp (+0/-138) panel/applets/appname/registrar.h (+0/-85) panel/applets/common/cairoutils.cpp (+42/-0) panel/applets/common/cairoutils.h (+47/-0) panel/applets/common/indicatorentrywidget.cpp (+366/-0) panel/applets/common/indicatorentrywidget.h (+90/-0) panel/applets/common/indicatorsmanager.cpp (+206/-0) panel/applets/common/indicatorsmanager.h (+72/-0) panel/applets/common/indicatorwidget.cpp (+53/-0) panel/applets/common/indicatorwidget.h (+52/-0) panel/applets/common/panelstyle.cpp (+114/-0) panel/applets/common/panelstyle.h (+56/-0) panel/applets/homebutton/homebutton.cpp (+4/-2) panel/applets/indicator-config.h.in (+0/-7) panel/applets/indicator/abstractindicator.cpp (+0/-43) panel/applets/indicator/abstractindicator.h (+0/-53) panel/applets/indicator/datetimeindicator.cpp (+0/-94) panel/applets/indicator/datetimeindicator.h (+0/-53) panel/applets/indicator/indicator.c (+0/-525) panel/applets/indicator/indicator.h (+0/-45) panel/applets/indicator/indicatorapplet.cpp (+0/-114) panel/applets/indicator/indicatorapplet.h (+0/-60) panel/applets/indicator/indicatorservicemanager.cpp (+0/-120) panel/applets/indicator/indicatorservicemanager.h (+0/-54) places/AbstractButton.qml (+2/-0) places/GroupHeader.qml (+2/-0) places/Home.qml (+2/-0) places/HomeButton.qml (+2/-0) places/HomeShortcuts.qml (+4/-4) places/SearchEntry.qml (+8/-0) places/SearchRefine.qml (+2/-0) places/SearchRefineOptionType.qml (+2/-0) places/TickBox.qml (+3/-0) places/UnityDefaultRenderer.qml (+2/-0) places/UnityEmptySearchRenderer.qml (+2/-0) places/UnityFileInfoRenderer.qml (+2/-0) places/app/places.cpp (+2/-0) places/dash.qml (+6/-0) po/af.po (+2/-2) po/am.po (+2/-2) po/an.po (+2/-2) po/ar.po (+2/-2) po/ast.po (+2/-2) po/az.po (+2/-2) po/be.po (+2/-2) po/bem.po (+2/-2) po/bg.po (+2/-2) po/bn.po (+2/-2) po/bs.po (+3/-3) po/ca.po (+2/-2) po/ca@valencia.po (+3/-3) po/crh.po (+2/-2) po/cs.po (+2/-2) po/cy.po (+2/-2) po/da.po (+2/-2) po/de.po (+2/-2) po/el.po (+2/-2) po/en_AU.po (+4/-4) po/en_GB.po (+4/-4) po/eo.po (+2/-2) po/es.po (+2/-2) po/et.po (+3/-3) po/eu.po (+2/-2) po/fa.po (+2/-2) po/fi.po (+2/-2) po/fil.po (+2/-2) po/fr.po (+2/-2) po/fy.po (+2/-2) po/gd.po (+2/-2) po/gl.po (+2/-2) po/gv.po (+2/-2) po/he.po (+2/-2) po/hi.po (+2/-2) po/hr.po (+2/-2) po/hu.po (+2/-2) po/hy.po (+2/-2) po/id.po (+2/-2) po/is.po (+2/-2) po/it.po (+2/-2) po/ja.po (+2/-2) po/ka.po (+2/-2) po/kk.po (+2/-2) po/ko.po (+2/-2) po/ku.po (+2/-2) po/ky.po (+2/-2) po/lb.po (+2/-2) po/lt.po (+2/-2) po/lv.po (+2/-2) po/mg.po (+2/-2) po/ml.po (+2/-2) po/ms.po (+2/-2) po/nb.po (+2/-2) po/nl.po (+2/-2) po/nn.po (+2/-2) po/oc.po (+2/-2) po/pa.po (+2/-2) po/pl.po (+2/-2) po/pt.po (+2/-2) po/pt_BR.po (+2/-2) po/ro.po (+2/-2) po/ru.po (+2/-2) po/si.po (+2/-2) po/sk.po (+2/-2) po/sl.po (+2/-2) po/sq.po (+2/-2) po/sr.po (+2/-2) po/sv.po (+2/-2) po/ta.po (+2/-2) po/te.po (+2/-2) po/th.po (+2/-2) po/tr.po (+2/-2) po/tt.po (+2/-2) po/ug.po (+2/-2) po/uk.po (+2/-2) po/unity-2d.pot (+2/-2) po/ur.po (+2/-2) po/vi.po (+2/-2) po/zh_CN.po (+2/-2) po/zh_HK.po (+2/-2) po/zh_TW.po (+2/-2) spread/app/spread.cpp (+1/-0) |
To merge this branch: | bzr merge lp:~didrocks/unity-2d/subdatadir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-2d-team | Pending | ||
Review via email: mp+70461@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-08-04.
Commit message
Description of the change
Enable storing subdir (like kde4/) in the gsettings schema.
For instance /usr/share/
as kde4-konversati
This is valid for all .desktop file in XDG_DATA_
Note that full path and relative path are still supported
- 637. By Didier Roche-Tolomelli
-
fix typo
- 638. By Didier Roche-Tolomelli
-
make it more elegant, follow unity-2d guidelines and send a reference for favoriteFromDes
ktopFilePath (LP: #741129) - 639. By Didier Roche-Tolomelli
-
fixing coding guidelines
Unmerged revisions
- 639. By Didier Roche-Tolomelli
-
fixing coding guidelines
- 638. By Didier Roche-Tolomelli
-
make it more elegant, follow unity-2d guidelines and send a reference for favoriteFromDes
ktopFilePath (LP: #741129) - 637. By Didier Roche-Tolomelli
-
fix typo
- 636. By Didier Roche-Tolomelli
-
enable subdir in data_dir to be stored in dconf. The format is subdir-
filename. desktop - 635. By Felix H. Dahlke
-
[launcher] Changed quicklist item "Keep In Launcher" to "Keep in launcher" as well as "Remove From Launcher" to "Remove from launcher" per design
- 634. By Aurélien Gâteau
-
[panel] Fix build with Unity trunk -r1325
Indicators:
:on_menu_ pointer_ moved() signal has been removed. The code now
implements mouse polling to implement mouse scrubbing. This is more efficient
than waiting for unity-panel-service to ask for menus to show. - 633. By Didier Roche-Tolomelli
-
releasing version 3.8.14.1-0ubuntu1
- 632. By Didier Roche-Tolomelli
-
* Few upstream fixes:
- unity-2d-places crashed with SIGSEGV in
QDeclarativePropertyPrivat e::initProperty () (LP: #817896)
- update resets unity launcher favorites (LP: #817954) - 631. By Florian Boucault
-
Merged lp:unity-2d
- 630. By Didier Roche-Tolomelli
-
Remove the launcher favorite convert as it makes the launcher to be resetted to default values for people only using unity-3d. (LP: #817954)
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2011-07-27 09:42:32 +0000 |
3 | +++ CMakeLists.txt 2011-08-04 16:31:58 +0000 |
4 | @@ -25,10 +25,13 @@ |
5 | find_package(X11 REQUIRED) |
6 | find_package(Gettext REQUIRED) |
7 | pkg_check_modules(GLIB REQUIRED glib-2.0) |
8 | -pkg_check_modules(GDK REQUIRED gdk-2.0) |
9 | -pkg_check_modules(GTK REQUIRED gtk+-2.0) |
10 | +pkg_check_modules(GDK REQUIRED gdk-3.0) |
11 | +pkg_check_modules(GTK REQUIRED gtk+-3.0) |
12 | pkg_check_modules(GIO REQUIRED gio-2.0) |
13 | -pkg_check_modules(WNCK REQUIRED libwnck-1.0) |
14 | +pkg_check_modules(WNCK REQUIRED libwnck-3.0) |
15 | +pkg_check_modules(QTGCONF REQUIRED libqtgconf) |
16 | +pkg_check_modules(NUXCORE REQUIRED nux-core-1.0) |
17 | +pkg_check_modules(PANGO REQUIRED pango) |
18 | |
19 | |
20 | # GSettings schemas |
21 | |
22 | === modified file 'data/unity-2d.convert' |
23 | --- data/unity-2d.convert 2011-07-25 11:56:59 +0000 |
24 | +++ data/unity-2d.convert 2011-08-04 16:31:58 +0000 |
25 | @@ -3,5 +3,3 @@ |
26 | hide-mode = /desktop/unity-2d/launcher/hide_mode |
27 | use-strut = /desktop/unity-2d/launcher/use_strut |
28 | |
29 | -[com.canonical.Unity.Launcher] |
30 | -favorites = /desktop/unity-2d/launcher/favorites |
31 | |
32 | === renamed file 'debian/20_unity-2d-gconf-default' => 'debian/20_ubuntu-2d-gconf-default' |
33 | --- debian/20_unity-2d-gconf-default 2011-07-25 11:56:59 +0000 |
34 | +++ debian/20_ubuntu-2d-gconf-default 2011-08-04 16:31:58 +0000 |
35 | @@ -1,13 +1,5 @@ |
36 | -/apps/gnome-power-manager/lock/use_screensaver_settings true |
37 | -/apps/gnome-power-manager/general/use_time_for_policy false |
38 | -/desktop/gnome/applications/window_manager/default /usr/bin/metacity |
39 | -/desktop/gnome/applications/window_manager/current /usr/bin/metacity |
40 | /apps/metacity/general/show_maximized_titlebars false |
41 | /apps/metacity/general/auto_maximize_windows true |
42 | /apps/metacity/general/capture_before_unmap true |
43 | /apps/metacity/general/compositing_manager true |
44 | /apps/metacity/general/compositor_effects false |
45 | -/apps/metacity/general/theme Ambiance |
46 | -/desktop/gnome/interface/gtk_theme Ambiance |
47 | -/desktop/gnome/interface/icon_theme ubuntu-mono-dark |
48 | -/desktop/gnome/peripherals/mouse/cursor_theme DMZ-White |
49 | |
50 | === renamed file 'debian/20_unity-2d-gconf-mandatory' => 'debian/20_ubuntu-2d-gconf-mandatory' |
51 | --- debian/20_unity-2d-gconf-mandatory 2011-06-15 13:05:38 +0000 |
52 | +++ debian/20_ubuntu-2d-gconf-mandatory 2011-08-04 16:31:58 +0000 |
53 | @@ -1,3 +1,2 @@ |
54 | -/apps/nautilus/preferences/exit_with_last_window false |
55 | /apps/metacity/global_keybindings/panel_main_menu disabled |
56 | /apps/metacity/global_keybindings/panel_run_dialog disabled |
57 | |
58 | === modified file 'debian/changelog' |
59 | --- debian/changelog 2011-07-29 14:05:54 +0000 |
60 | +++ debian/changelog 2011-08-04 16:31:58 +0000 |
61 | @@ -1,20 +1,33 @@ |
62 | -unity-2d (3.8.14-0ubuntu1) UNRELEASED; urgency=low |
63 | - |
64 | - * |
65 | - |
66 | - -- Florian Boucault <florian.boucault@canonical.com> Fri, 29 Jul 2011 16:05:25 +0200 |
67 | - |
68 | -unity-2d (3.8.12-0ubuntu2) natty; urgency=low |
69 | +unity-2d (3.8.14.1-0ubuntu1) oneiric; urgency=low |
70 | + |
71 | + * Few upstream fixes: |
72 | + - unity-2d-places crashed with SIGSEGV in |
73 | + QDeclarativePropertyPrivate::initProperty() (LP: #817896) |
74 | + - update resets unity launcher favorites (LP: #817954) |
75 | + |
76 | + -- Didier Roche <didrocks@ubuntu.com> Tue, 02 Aug 2011 16:08:27 +0200 |
77 | + |
78 | +unity-2d (3.8.14-0ubuntu1) oneiric; urgency=low |
79 | + |
80 | + * New upstream release: |
81 | + - [launcher] Need to press Alt+F1 twice to show launcher (LP: #812787) |
82 | + * debian/control: |
83 | + - build on latest libunity-core-4.0-dev and latest libnux-1.0-dev |
84 | + |
85 | + -- Didier Roche <didrocks@ubuntu.com> Mon, 01 Aug 2011 19:53:40 +0200 |
86 | + |
87 | +unity-2d (3.8.12-0ubuntu2) oneiric; urgency=low |
88 | |
89 | * debian/control: |
90 | - enforcing latest libunity-private0 to be installed for each local |
91 | consumer |
92 | + - don't recommends indicator-me, it's deprecated |
93 | * debian/libunity-2d-private0.lintian-overrides: |
94 | - remove a qml-related exported symbol warning wrongly detected |
95 | |
96 | - -- Didier Roche <didrocks@ubuntu.com> Fri, 29 Jul 2011 08:01:51 +0200 |
97 | + -- Didier Roche <didrocks@ubuntu.com> Fri, 29 Jul 2011 15:19:11 +0200 |
98 | |
99 | -unity-2d (3.8.12-0ubuntu1) natty; urgency=low |
100 | +unity-2d (3.8.12-0ubuntu1) oneiric; urgency=low |
101 | |
102 | [ Florian Boucault ] |
103 | * Upstreamed patch 01_build_with_new_indicator.patch |
104 | @@ -32,6 +45,7 @@ |
105 | - remove default value for /desktop/unity-2d/launcher/favorites |
106 | * debian/control: |
107 | - add dependency on libdconf-qt-dev |
108 | + - add dependency on libnux-1.0-dev |
109 | |
110 | [ Didier Roche ] |
111 | * New upstream release: |
112 | @@ -73,13 +87,27 @@ |
113 | * Fix typo in trigger (debian/unity-2d.triggers): (LP: #807358) |
114 | * Install the apport hook in the right directory so that it's not launched |
115 | unconditionally (LP: #712343) |
116 | + * debian/control: |
117 | + - dep on latest libqtdee-dev |
118 | + - dep now on gtk3 indicator version |
119 | + - dep on versionned libnux-1.0-dev |
120 | + - dep on versionned libunity-core-4.0-dev |
121 | * debian/control, debian/rules, debian/libunity-2d-private-dev: |
122 | - add new -dev project (LP: #814709) |
123 | - add an upstream pc file |
124 | |
125 | - -- Florian Boucault <florian.boucault@canonical.com> Thu, 28 Jul 2011 12:05:05 +0200 |
126 | - |
127 | -unity-2d (3.8.10-0ubuntu1) natty; urgency=low |
128 | + -- Didier Roche <didrocks@ubuntu.com> Thu, 28 Jul 2011 12:05:38 +0200 |
129 | + |
130 | +unity-2d (3.8.10-0ubuntu2) oneiric; urgency=low |
131 | + |
132 | + * debian/control: |
133 | + - rebuild with new indicator 0.4 |
134 | + * 01_build_with_new_indicator.patch: |
135 | + - patch to build with the new indicator 0.4 stack |
136 | + |
137 | + -- Didier Roche <didrocks@ubuntu.com> Sun, 10 Jul 2011 23:48:01 +0200 |
138 | + |
139 | +unity-2d (3.8.10-0ubuntu1) oneiric; urgency=low |
140 | |
141 | [ Florian Boucault ] |
142 | * debian/unity-2d-launcher.install: |
143 | @@ -102,10 +130,17 @@ |
144 | - Missing a GConf schema file for the /desktop/unity-2d/… keys |
145 | (LP: #750303) |
146 | - [dash] home screen search hint should be 'Search' (LP: #797825) |
147 | - |
148 | - -- Florian Boucault <florian.boucault@canonical.com> Wed, 13 Jul 2011 11:59:29 +0200 |
149 | - |
150 | -unity-2d (3.8.8-0ubuntu1) natty; urgency=low |
151 | + * debian/unity-2d.gconf-defaults, |
152 | + debian/20_ubuntu-2d-gconf-default: |
153 | + - transition some gconf keys from session-wide to system-wide |
154 | + (LP: #797672, #797676) |
155 | + * debian/control: |
156 | + - ensure we are still using gtk2 indicator for alpha2 (LP: #804938) |
157 | + - bump standards-version |
158 | + |
159 | + -- Didier Roche <didrocks@ubuntu.com> Mon, 04 Jul 2011 11:05:54 +0200 |
160 | + |
161 | +unity-2d (3.8.8-0ubuntu1) oneiric; urgency=low |
162 | |
163 | [ Didier Roche ] |
164 | * new upstream release: |
165 | @@ -152,7 +187,21 @@ |
166 | |
167 | -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200 |
168 | |
169 | -unity-2d (3.8.6-0ubuntu1) natty; urgency=low |
170 | +unity-2d (3.8.6-0ubuntu3~ppa1) oneiric; urgency=low |
171 | + |
172 | + * Rebuild with new gcc |
173 | + |
174 | + -- Didier Roche <didrocks@ubuntu.com> Tue, 07 Jun 2011 15:00:32 +0200 |
175 | + |
176 | +unity-2d (3.8.6-0ubuntu2) oneiric; urgency=low |
177 | + |
178 | + * debian/unity-2d.postinst, debian/unity-2d.postrm: |
179 | + - remove the magic to set unity-2d in oneiric as the default session in gdm |
180 | + as it's now installed on the ubuntu CD. |
181 | + |
182 | + -- Didier Roche <didrocks@ubuntu.com> Wed, 01 Jun 2011 09:42:21 +0200 |
183 | + |
184 | +unity-2d (3.8.6-0ubuntu1) oneiric; urgency=low |
185 | |
186 | * New upstream release: |
187 | - [launcher] Support static shortcuts in the quicklists. (LP: #669923) |
188 | @@ -196,6 +245,18 @@ |
189 | * debian/libunity-2d-private0.post* |
190 | - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass |
191 | -n anymore |
192 | + * don't install unity-2d session as it's in gnome-session now |
193 | + * debian/unity-2d.install |
194 | + debian/20_ubuntu-2d-gconf-default |
195 | + debian/20_ubuntu-2d-gconf-mandatory |
196 | + debian/gconf/ubuntu-2d.default.path |
197 | + debian/gconf/ubuntu-2d.mandatory.path: |
198 | + - remove uneeded defaults and mandatory |
199 | + - remove some deprecated keys |
200 | + - the session is now called ubuntu-2d and not unity-2d anymore |
201 | + * debian/unity-2d.preinst, debian/unity-2d.postinst |
202 | + debian/unity-2d.postrm: |
203 | + - take into account the natty -> oneiric migration with session name change |
204 | |
205 | -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200 |
206 | |
207 | |
208 | === modified file 'debian/control' |
209 | --- debian/control 2011-07-29 11:55:03 +0000 |
210 | +++ debian/control 2011-08-04 16:31:58 +0000 |
211 | @@ -10,19 +10,22 @@ |
212 | libqt4-dev, |
213 | libqt4-opengl-dev, |
214 | libglib2.0-dev, |
215 | - libwnck-dev, |
216 | + libwnck-3-dev, |
217 | + libpango1.0-dev, |
218 | libqtgconf-dev, |
219 | libdconf-qt-dev, |
220 | libqtbamf-dev, |
221 | - libqtdee-dev, |
222 | + libqtdee-dev (>= 0.2.3), |
223 | libdbusmenu-qt-dev, |
224 | libx11-dev, |
225 | - libindicator-dev, |
226 | - libgtk2.0-dev, |
227 | + libindicator3-dev, |
228 | + libgtk-3-dev, |
229 | libutouch-geis-dev, |
230 | - libstartup-notification0-dev |
231 | -Standards-Version: 3.9.1 |
232 | -Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/trunk |
233 | + libstartup-notification0-dev, |
234 | + libunity-core-4.0-dev (>= 4.6.0), |
235 | + libnux-1.0-dev (>= 1.0.8), |
236 | +Standards-Version: 3.9.2 |
237 | +Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/oneiric |
238 | |
239 | Package: unity-2d |
240 | Architecture: all |
241 | @@ -56,9 +59,10 @@ |
242 | Depends: ${shlibs:Depends}, |
243 | ${misc:Depends}, |
244 | libunity-2d-private0 (= ${binary:Version}), |
245 | - libgtk2.0-dev, |
246 | - libwnck-dev, |
247 | + libgtk-3-dev, |
248 | + libwnck-3-dev, |
249 | libglib2.0-dev, |
250 | + libpango1.0-dev, |
251 | Description: Unity 2D shared library - development files |
252 | This library is used to host common code used by several Unity 2D components |
253 | It is only used internally, there is no use case for it outside of the unity-2d |
254 | @@ -90,7 +94,6 @@ |
255 | Recommends: indicator-application, |
256 | indicator-appmenu, |
257 | indicator-datetime, |
258 | - indicator-me, |
259 | indicator-messages, |
260 | indicator-session, |
261 | indicator-sound, |
262 | |
263 | === renamed file 'debian/gconf/unity-2d.default.path' => 'debian/gconf/ubuntu-2d.default.path' |
264 | --- debian/gconf/unity-2d.default.path 2011-06-15 13:05:38 +0000 |
265 | +++ debian/gconf/ubuntu-2d.default.path 2011-08-04 16:31:58 +0000 |
266 | @@ -1,3 +1,3 @@ |
267 | -# Additional mandatory path for unity-2d experience |
268 | -xml:readonly:/var/lib/gconf/unity-2d.default |
269 | +# Additional mandatory path for ubuntu-2d experience |
270 | +xml:readonly:/var/lib/gconf/ubuntu-2d.default |
271 | |
272 | |
273 | === renamed file 'debian/gconf/unity-2d.mandatory.path' => 'debian/gconf/ubuntu-2d.mandatory.path' |
274 | --- debian/gconf/unity-2d.mandatory.path 2011-06-15 13:05:38 +0000 |
275 | +++ debian/gconf/ubuntu-2d.mandatory.path 2011-08-04 16:31:58 +0000 |
276 | @@ -1,3 +1,3 @@ |
277 | -# Additional mandatory path for unity-2d experience |
278 | -xml:readonly:/var/lib/gconf/unity-2d.mandatory |
279 | +# Additional mandatory path for ubuntu-2d experience |
280 | +xml:readonly:/var/lib/gconf/ubuntu-2d.mandatory |
281 | |
282 | |
283 | === modified file 'debian/unity-2d-panel.install' |
284 | --- debian/unity-2d-panel.install 2011-01-14 21:41:39 +0000 |
285 | +++ debian/unity-2d-panel.install 2011-08-04 16:31:58 +0000 |
286 | @@ -1,4 +1,2 @@ |
287 | usr/bin/unity-2d-panel |
288 | usr/share/applications/unity-2d-panel.desktop |
289 | -usr/share/unity-2d/panel/artwork/background.png |
290 | -usr/share/unity-2d/panel/artwork/divider.png |
291 | |
292 | === added file 'debian/unity-2d.gconf-defaults' |
293 | --- debian/unity-2d.gconf-defaults 1970-01-01 00:00:00 +0000 |
294 | +++ debian/unity-2d.gconf-defaults 2011-08-04 16:31:58 +0000 |
295 | @@ -0,0 +1,4 @@ |
296 | +/desktop/unity-2d/launcher/favorites [ubiquity-gtkui.desktop,nautilus-home.desktop,firefox.desktop,libreoffice-writer.desktop,libreoffice-calc.desktop,libreoffice-impress.desktop,ubuntu-software-center.desktop,ubuntuone-control-panel-gtk.desktop] |
297 | +/desktop/unity-2d/launcher/hide_mode 2 |
298 | +/desktop/unity-2d/launcher/use_strut false |
299 | +/desktop/unity-2d/launcher/super_key_enable true |
300 | |
301 | === modified file 'debian/unity-2d.install' |
302 | --- debian/unity-2d.install 2011-07-22 14:44:57 +0000 |
303 | +++ debian/unity-2d.install 2011-08-04 16:31:58 +0000 |
304 | @@ -1,9 +1,7 @@ |
305 | debian/unity-2d.py /usr/share/apport/package-hooks |
306 | debian/gconf/* /usr/share/gconf |
307 | -session/unity-2d.desktop /usr/share/xsessions |
308 | -session/2d-ubuntu.session /usr/share/gnome-session/sessions |
309 | -debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory |
310 | -debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default |
311 | +debian/20_ubuntu-2d-gconf-mandatory /usr/share/gconf/ubuntu-2d/mandatory |
312 | +debian/20_ubuntu-2d-gconf-default /usr/share/gconf/ubuntu-2d/default |
313 | usr/share/locale/*/LC_MESSAGES/unity-2d.mo |
314 | usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml |
315 | usr/share/GConf/gsettings |
316 | |
317 | === modified file 'debian/unity-2d.postinst' |
318 | --- debian/unity-2d.postinst 2011-06-15 13:05:38 +0000 |
319 | +++ debian/unity-2d.postinst 2011-08-04 16:31:58 +0000 |
320 | @@ -9,24 +9,21 @@ |
321 | |
322 | case "$1" in |
323 | configure|upgrade) |
324 | - if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then |
325 | - /usr/lib/gdm/gdm-set-default-session --keep-old unity-2d || true |
326 | - fi |
327 | if which update-gconf-defaults >/dev/null 2>&1 ; then |
328 | - mkdir -p /var/lib/gconf/unity-2d.mandatory |
329 | - mkdir -p /var/lib/gconf/unity-2d.default |
330 | + mkdir -p /var/lib/gconf/ubuntu-2d.mandatory |
331 | + mkdir -p /var/lib/gconf/ubuntu-2d.default |
332 | fi |
333 | ;; |
334 | triggered) |
335 | for trigger in $2; do |
336 | case $trigger in |
337 | - /usr/share/gconf/unity-2d/mandatory) |
338 | - update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \ |
339 | - --destination /var/lib/gconf/unity-2d.mandatory --no-signal |
340 | + /usr/share/gconf/ubuntu-2d/mandatory) |
341 | + update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \ |
342 | + --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal |
343 | ;; |
344 | - /usr/share/gconf/unity-2d/default) |
345 | - update-gconf-defaults --source /usr/share/gconf/unity-2d/default \ |
346 | - --destination /var/lib/gconf/unity-2d.default --no-signal |
347 | + /usr/share/gconf/ubuntu-2d/default) |
348 | + update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \ |
349 | + --destination /var/lib/gconf/ubuntu-2d.default --no-signal |
350 | ;; |
351 | esac |
352 | done |
353 | @@ -39,9 +36,9 @@ |
354 | |
355 | # Upon installation/upgrade, regenerate all databases, because in this case |
356 | # there will be no trigger run |
357 | -update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \ |
358 | - --destination /var/lib/gconf/unity-2d.mandatory --no-signal |
359 | -update-gconf-defaults --source /usr/share/gconf/unity-2d/default \ |
360 | - --destination /var/lib/gconf/unity-2d.default --no-signal |
361 | +update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \ |
362 | + --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal |
363 | +update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \ |
364 | + --destination /var/lib/gconf/ubuntu-2d.default --no-signal |
365 | signal_daemons |
366 | |
367 | |
368 | === modified file 'debian/unity-2d.postrm' |
369 | --- debian/unity-2d.postrm 2011-06-15 13:05:38 +0000 |
370 | +++ debian/unity-2d.postrm 2011-08-04 16:31:58 +0000 |
371 | @@ -3,20 +3,17 @@ |
372 | |
373 | case "$1" in |
374 | remove|purge) |
375 | - if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/unity-2d ]; then |
376 | - update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \ |
377 | - --destination /var/lib/gconf/unity-2d.mandatory |
378 | - update-gconf-defaults --source /usr/share/gconf/unity-2d/default \ |
379 | - --destination /var/lib/gconf/unity-2d.default |
380 | - fi |
381 | - if [ -d /var/lib/gconf/unity-2d.mandatory ]; then |
382 | - rm -rf /var/lib/gconf/unity-2d.mandatory |
383 | - fi |
384 | - if [ -d /var/lib/gconf/unity-2d.default ]; then |
385 | - rm -rf /var/lib/gconf/unity-2d.default |
386 | - fi |
387 | - if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then |
388 | - /usr/lib/gdm/gdm-set-default-session --remove unity-2d || true |
389 | + if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/ubuntu-2d ]; then |
390 | + update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \ |
391 | + --destination /var/lib/gconf/ubuntu-2d.mandatory |
392 | + update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \ |
393 | + --destination /var/lib/gconf/ubuntu-2d.default |
394 | + fi |
395 | + if [ -d /var/lib/gconf/ubuntu-2d.mandatory ]; then |
396 | + rm -rf /var/lib/gconf/ubuntu-2d.mandatory |
397 | + fi |
398 | + if [ -d /var/lib/gconf/ubuntu-2d.default ]; then |
399 | + rm -rf /var/lib/gconf/ubuntu-2d.default |
400 | fi |
401 | ;; |
402 | esac |
403 | |
404 | === added file 'debian/unity-2d.preinst' |
405 | --- debian/unity-2d.preinst 1970-01-01 00:00:00 +0000 |
406 | +++ debian/unity-2d.preinst 2011-08-04 16:31:58 +0000 |
407 | @@ -0,0 +1,16 @@ |
408 | +#!/bin/sh |
409 | +set -e |
410 | + |
411 | +case "$1" in |
412 | + install|upgrade) |
413 | + if dpkg --compare-versions "$2" le "3.8.6-0ubuntu1"; then |
414 | + if [ -d /var/lib/gconf/unity-2d.mandatory ]; then |
415 | + mv /var/lib/gconf/unity-2d.mandatory /var/lib/gconf/ubuntu-2d.mandatory || true |
416 | + mv /var/lib/gconf/unity-2d.default /var/lib/gconf/ubuntu-2d.default || true |
417 | + fi |
418 | + fi |
419 | + ;; |
420 | +esac |
421 | + |
422 | +#DEBHELPER# |
423 | + |
424 | |
425 | === modified file 'launcher/Launcher.qml' |
426 | --- launcher/Launcher.qml 2011-07-11 12:16:31 +0000 |
427 | +++ launcher/Launcher.qml 2011-08-04 16:31:58 +0000 |
428 | @@ -22,7 +22,10 @@ |
429 | LauncherDropItem { |
430 | id: launcher |
431 | |
432 | + Accessible.name: "root" |
433 | + |
434 | GnomeBackground { |
435 | + Accessible.name: "background" |
436 | anchors.fill: parent |
437 | overlay_color: "black" |
438 | overlay_alpha: 0.66 |
439 | @@ -30,6 +33,7 @@ |
440 | } |
441 | |
442 | Rectangle { |
443 | + Accessible.name: "background" |
444 | anchors.fill: parent |
445 | color: "black" |
446 | opacity: 0.66 |
447 | @@ -37,6 +41,7 @@ |
448 | } |
449 | |
450 | Image { |
451 | + Accessible.name: "border" |
452 | id: border |
453 | |
454 | width: 1 |
455 | @@ -50,12 +55,16 @@ |
456 | onWebpageUrlDropped: applications.insertWebFavorite(url) |
457 | |
458 | FocusScope { |
459 | + Accessible.name: "content" |
460 | + |
461 | focus: true |
462 | anchors.fill: parent |
463 | z: 1 /* ensure the lists are always strictly on top of the background */ |
464 | |
465 | LauncherList { |
466 | id: main |
467 | + Accessible.name: "main" |
468 | + |
469 | anchors.top: parent.top |
470 | anchors.bottom: shelf.top |
471 | anchors.bottomMargin: itemPadding |
472 | @@ -75,6 +84,8 @@ |
473 | |
474 | LauncherList { |
475 | id: shelf |
476 | + Accessible.name: "shelf" |
477 | + |
478 | anchors.bottom: parent.bottom |
479 | anchors.bottomMargin: main.anchors.bottomMargin |
480 | height: (tileSize + itemPadding) * count |
481 | |
482 | === modified file 'launcher/LauncherItem.qml' |
483 | --- launcher/LauncherItem.qml 2011-07-14 11:17:30 +0000 |
484 | +++ launcher/LauncherItem.qml 2011-08-04 16:31:58 +0000 |
485 | @@ -48,6 +48,8 @@ |
486 | DropItem { |
487 | id: item |
488 | |
489 | + Accessible.role: Accessible.PushButton |
490 | + |
491 | anchors.horizontalCenter: parent.horizontalCenter |
492 | |
493 | property int padding |
494 | |
495 | === modified file 'launcher/LauncherList.qml' |
496 | --- launcher/LauncherList.qml 2011-07-28 12:27:39 +0000 |
497 | +++ launcher/LauncherList.qml 2011-08-04 16:31:58 +0000 |
498 | @@ -77,6 +77,17 @@ |
499 | delegate: LauncherItem { |
500 | id: launcherItem |
501 | |
502 | + function accessibleDescription() { |
503 | + if (running) { |
504 | + var windows = u2d.tr("%1 window opened", "%1 windows opened", item.windowCount).arg(item.windowCount) |
505 | + return "%1 %2".arg(item.name).arg(windows) |
506 | + } else { |
507 | + return "%1 %2".arg(item.name).arg(u2d.tr("not running")) |
508 | + } |
509 | + } |
510 | + |
511 | + Accessible.name: accessibleDescription() |
512 | + |
513 | width: list.width |
514 | tileSize: list.tileSize |
515 | padding: list.itemPadding |
516 | |
517 | === modified file 'launcher/app/launcher.cpp' |
518 | --- launcher/app/launcher.cpp 2011-07-27 09:42:32 +0000 |
519 | +++ launcher/app/launcher.cpp 2011-08-04 16:31:58 +0000 |
520 | @@ -78,6 +78,7 @@ |
521 | { |
522 | Unity2dApplication::earlySetup(argc, argv); |
523 | Unity2dApplication application(argc, argv); |
524 | + application.setApplicationName("Unity 2D Launcher"); |
525 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); |
526 | |
527 | GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop"); |
528 | @@ -91,6 +92,7 @@ |
529 | Unity2dPanel panel(true); |
530 | panel.setEdge(Unity2dPanel::LeftEdge); |
531 | panel.setFixedWidth(LauncherClient::MaximumWidth); |
532 | + panel.setAccessibleName("Launcher"); |
533 | |
534 | VisibilityController* visibilityController = new VisibilityController(&panel); |
535 | |
536 | |
537 | === modified file 'libunity-2d-private/CMakeLists.txt' |
538 | --- libunity-2d-private/CMakeLists.txt 2011-07-29 13:49:34 +0000 |
539 | +++ libunity-2d-private/CMakeLists.txt 2011-08-04 16:31:58 +0000 |
540 | @@ -6,7 +6,7 @@ |
541 | pkg_check_modules(QTDEE REQUIRED libqtdee) |
542 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
543 | pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0) |
544 | -pkg_check_modules(INDICATOR REQUIRED indicator) |
545 | +pkg_check_modules(INDICATOR REQUIRED indicator3-0.4) |
546 | pkg_check_modules(DCONFQT REQUIRED dconf-qt) |
547 | |
548 | set(libunity-2d-private_SOVERSION 0) |
549 | |
550 | === modified file 'libunity-2d-private/Unity2d/GnomeBackground.qml' |
551 | --- libunity-2d-private/Unity2d/GnomeBackground.qml 2011-07-11 10:26:02 +0000 |
552 | +++ libunity-2d-private/Unity2d/GnomeBackground.qml 2011-08-04 16:31:58 +0000 |
553 | @@ -17,7 +17,7 @@ |
554 | */ |
555 | |
556 | import QtQuick 1.0 |
557 | -import gconf 1.0 |
558 | +import QConf 1.0 |
559 | /* Necessary to access the blended image provider and CacheEffect */ |
560 | import Unity2d 1.0 |
561 | |
562 | @@ -32,19 +32,9 @@ |
563 | property bool cached: true |
564 | effect: (cached) ? cacheEffect : null |
565 | |
566 | - GConfItem { |
567 | - id: primary_color |
568 | - key: "/desktop/gnome/background/primary_color" |
569 | - } |
570 | - |
571 | - GConfItem { |
572 | - id: picture_filename |
573 | - key: "/desktop/gnome/background/picture_filename" |
574 | - } |
575 | - |
576 | - GConfItem { |
577 | - id: picture_options |
578 | - key: "/desktop/gnome/background/picture_options" |
579 | + QConf { |
580 | + id: desktopBackground |
581 | + schema: "org.gnome.desktop.background" |
582 | } |
583 | |
584 | Rectangle { |
585 | @@ -55,13 +45,13 @@ |
586 | } |
587 | |
588 | anchors.fill: parent |
589 | - color: primary_color.value |
590 | + color: desktopBackground.primaryColor |
591 | } |
592 | |
593 | Image { |
594 | id: picture |
595 | |
596 | - visible: picture_filename.value |
597 | + visible: desktopBackground.pictureUri |
598 | source: { |
599 | if (!visible) return "" |
600 | |
601 | @@ -74,8 +64,8 @@ |
602 | https://bugs.launchpad.net/ubuntu/+source/ubuntu-wallpapers/+bug/296538 |
603 | http://bugreports.qt.nokia.com/browse/QTBUG-7276 |
604 | */ |
605 | - var filename = picture_filename.value |
606 | - if(filename == "/usr/share/backgrounds/warty-final-ubuntu.png") |
607 | + var filename = desktopBackground.pictureUri |
608 | + if(filename == "file:///usr/share/backgrounds/warty-final-ubuntu.png") |
609 | filename = "/usr/share/unity-2d/warty-final-ubuntu.jpg" |
610 | |
611 | if(overlay_alpha > 0.0) |
612 | @@ -99,13 +89,13 @@ |
613 | - "spanned" (NOT IMPLEMENTED) |
614 | */ |
615 | fillMode: { |
616 | - if(picture_options.value == "wallpaper") |
617 | + if(desktopBackground.pictureOptions== "wallpaper") |
618 | return Image.Tile |
619 | - else if(picture_options.value == "scaled") |
620 | + else if(desktopBackground.pictureOptions == "scaled") |
621 | return Image.PreserveAspectFit |
622 | - else if(picture_options.value == "stretched") |
623 | + else if(desktopBackground.pictureOptions == "stretched") |
624 | return Image.Stretch |
625 | - else if(picture_options.value == "zoom") |
626 | + else if(desktopBackground.pictureOptions == "zoom") |
627 | return Image.PreserveAspectCrop |
628 | else return Image.PreserveAspectFit |
629 | } |
630 | |
631 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' |
632 | --- libunity-2d-private/Unity2d/plugin.cpp 2011-07-26 16:05:51 +0000 |
633 | +++ libunity-2d-private/Unity2d/plugin.cpp 2011-08-04 16:31:58 +0000 |
634 | @@ -20,10 +20,6 @@ |
635 | /* Required otherwise using wnck_set_client_type breaks linking with error: |
636 | undefined reference to `wnck_set_client_type(WnckClientType)' |
637 | */ |
638 | -extern "C" { |
639 | -#include <libwnck/util.h> |
640 | -} |
641 | - |
642 | #include "plugin.h" |
643 | |
644 | #include "launcherapplication.h" |
645 | |
646 | === modified file 'libunity-2d-private/src/CMakeLists.txt' |
647 | --- libunity-2d-private/src/CMakeLists.txt 2011-07-29 13:49:34 +0000 |
648 | +++ libunity-2d-private/src/CMakeLists.txt 2011-08-04 16:31:58 +0000 |
649 | @@ -2,6 +2,7 @@ |
650 | |
651 | # Sources |
652 | set(lib${LIB_NAME}_SRCS |
653 | + debug.cpp |
654 | gconnector.cpp |
655 | gnomesessionclient.cpp |
656 | keyboardmodifiersmonitor.cpp |
657 | @@ -64,6 +65,8 @@ |
658 | ${CMAKE_CURRENT_BINARY_DIR} |
659 | ${CMAKE_CURRENT_SOURCE_DIR} |
660 | ${GLIB_INCLUDE_DIRS} |
661 | + ${GTK_INCLUDE_DIRS} |
662 | + ${PANGO_INCLUDE_DIRS} |
663 | ${WNCK_INCLUDE_DIRS} |
664 | ${QTBAMF_INCLUDE_DIRS} |
665 | ${QTGCONF_INCLUDE_DIRS} |
666 | @@ -93,6 +96,8 @@ |
667 | ${QT_QTNETWORK_LIBRARIES} |
668 | ${X11_LIBRARIES} |
669 | ${GLIB_LDFLAGS} |
670 | + ${GTK_LDFLAGS} |
671 | + ${PANGO_LDFLAGS} |
672 | ${WNCK_LDFLAGS} |
673 | ${GDK_LDFLAGS} |
674 | ${GIO_LDFLAGS} |
675 | |
676 | === added file 'libunity-2d-private/src/debug.cpp' |
677 | --- libunity-2d-private/src/debug.cpp 1970-01-01 00:00:00 +0000 |
678 | +++ libunity-2d-private/src/debug.cpp 2011-08-04 16:31:58 +0000 |
679 | @@ -0,0 +1,23 @@ |
680 | +/* This file is part of unity-2d |
681 | + Copyright 2011 Canonical |
682 | + Author: Aurelien Gateau <aurelien.gateau@canonical.com> |
683 | + |
684 | + This program is free software; you can redistribute it and/or modify |
685 | + it under the terms of the GNU General Public License as published |
686 | + by the Free Software Foundation; version 3. |
687 | + |
688 | + This program is distributed in the hope that it will be useful, |
689 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
690 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
691 | + GNU General Public License for more details. |
692 | + |
693 | + You should have received a copy of the GNU General Public License |
694 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
695 | + */ |
696 | +// Self |
697 | +#include <debug_p.h> |
698 | + |
699 | +QDebug operator<<(QDebug& dbg, const std::string& str) |
700 | +{ |
701 | + return dbg << QString::fromUtf8(str.c_str()); |
702 | +} |
703 | |
704 | === modified file 'libunity-2d-private/src/debug_p.h' |
705 | --- libunity-2d-private/src/debug_p.h 2011-03-28 14:06:14 +0000 |
706 | +++ libunity-2d-private/src/debug_p.h 2011-08-04 16:31:58 +0000 |
707 | @@ -17,8 +17,12 @@ |
708 | #ifndef DEBUG_P_H |
709 | #define DEBUG_P_H |
710 | |
711 | +// Qt |
712 | #include <QDebug> |
713 | |
714 | +// STL |
715 | +#include <string> |
716 | + |
717 | #define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space() |
718 | |
719 | // Simple macros to get KDebug like support |
720 | @@ -62,5 +66,7 @@ |
721 | |
722 | #define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__) |
723 | |
724 | +// Support for outputing std::string with qDebug |
725 | +QDebug operator<<(QDebug& dbg, const std::string& str); |
726 | |
727 | #endif /* DEBUG_P_H */ |
728 | |
729 | === modified file 'libunity-2d-private/src/launcherapplication.cpp' |
730 | --- libunity-2d-private/src/launcherapplication.cpp 2011-07-29 13:49:34 +0000 |
731 | +++ libunity-2d-private/src/launcherapplication.cpp 2011-08-04 16:31:58 +0000 |
732 | @@ -14,10 +14,6 @@ |
733 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
734 | */ |
735 | |
736 | -/* Those have to be included before any QObject-style header to avoid |
737 | - compilation errors. */ |
738 | -#include <gdk/gdk.h> |
739 | - |
740 | /* Note regarding the use of wnck: it is critically important that the client |
741 | type be set to pager because wnck will pass that type over to the window |
742 | manager through XEvents. |
743 | @@ -59,6 +55,7 @@ |
744 | #include <QX11Info> |
745 | |
746 | extern "C" { |
747 | +#include <gdk/gdk.h> |
748 | #include <libsn/sn.h> |
749 | } |
750 | |
751 | @@ -649,7 +646,8 @@ |
752 | GTimeVal timeval; |
753 | |
754 | g_get_current_time (&timeval); |
755 | - GObjectScopedPointer<GdkAppLaunchContext> context(gdk_app_launch_context_new()); |
756 | + GdkDisplay* display = gdk_display_get_default(); |
757 | + GObjectScopedPointer<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display)); |
758 | /* Using GDK_CURRENT_TIME doesn’t seem to work, launched windows |
759 | sometimes don’t get focus (see https://launchpad.net/bugs/643616). */ |
760 | gdk_app_launch_context_set_timestamp(context.data(), timeval.tv_sec); |
761 | @@ -880,7 +878,7 @@ |
762 | QAction* keep = new QAction(m_menu); |
763 | keep->setCheckable(is_running); |
764 | keep->setChecked(sticky()); |
765 | - keep->setText(is_running ? u2dTr("Keep In Launcher") : u2dTr("Remove From Launcher")); |
766 | + keep->setText(is_running ? u2dTr("Keep in launcher") : u2dTr("Remove from launcher")); |
767 | actions.append(keep); |
768 | QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered())); |
769 | } |
770 | |
771 | === modified file 'libunity-2d-private/src/launcherapplicationslist.cpp' |
772 | --- libunity-2d-private/src/launcherapplicationslist.cpp 2011-07-29 13:49:34 +0000 |
773 | +++ libunity-2d-private/src/launcherapplicationslist.cpp 2011-08-04 16:31:58 +0000 |
774 | @@ -101,6 +101,17 @@ |
775 | application->installX11EventFilter(this); |
776 | } |
777 | |
778 | + /* Get the system applications data dirs and be flexible if / or not at the |
779 | + end of each path. */ |
780 | + QString xdg_string = QFile::decodeName(getenv("XDG_DATA_DIRS")); |
781 | + if (xdg_string.isEmpty()) |
782 | + xdg_string = "/usr/local/share/:/usr/share/"; |
783 | + xdg_string= xdg_string.replace(":", "/applications/:"); |
784 | + if (!xdg_string.endsWith(':')) |
785 | + xdg_string = xdg_string.append("/applications/"); |
786 | + xdg_string = xdg_string.replace("//", "/"); |
787 | + m_xdg_data_dirs = xdg_string.split(':'); |
788 | + |
789 | load(); |
790 | } |
791 | |
792 | @@ -180,7 +191,15 @@ |
793 | QString |
794 | LauncherApplicationsList::favoriteFromDesktopFilePath(QString desktop_file) |
795 | { |
796 | - return QDir(desktop_file).dirName(); |
797 | + Q_FOREACH(QString data_dir, m_xdg_data_dirs) { |
798 | + if (desktop_file.startsWith(data_dir)) |
799 | + { |
800 | + desktop_file = desktop_file.remove(data_dir); |
801 | + desktop_file = desktop_file.replace("/", "-"); |
802 | + break; |
803 | + } |
804 | + } |
805 | + return desktop_file; |
806 | } |
807 | |
808 | void |
809 | |
810 | === modified file 'libunity-2d-private/src/launcherapplicationslist.h' |
811 | --- libunity-2d-private/src/launcherapplicationslist.h 2011-07-29 13:49:34 +0000 |
812 | +++ libunity-2d-private/src/launcherapplicationslist.h 2011-08-04 16:31:58 +0000 |
813 | @@ -71,7 +71,7 @@ |
814 | void insertApplication(LauncherApplication* application); |
815 | void removeApplication(LauncherApplication* application); |
816 | |
817 | - static QString favoriteFromDesktopFilePath(QString desktop_file); |
818 | + QString favoriteFromDesktopFilePath(QString desktop_file); |
819 | |
820 | void writeFavoritesToGConf(); |
821 | |
822 | @@ -90,6 +90,7 @@ |
823 | */ |
824 | QHash<QString, LauncherApplication*> m_applicationForExecutable; |
825 | QConf* m_dconf_launcher; |
826 | + QStringList m_xdg_data_dirs; |
827 | |
828 | /* Startup notification support */ |
829 | SnDisplay *m_snDisplay; |
830 | |
831 | === modified file 'libunity-2d-private/src/launchermenu.cpp' |
832 | --- libunity-2d-private/src/launchermenu.cpp 2011-07-29 13:49:34 +0000 |
833 | +++ libunity-2d-private/src/launchermenu.cpp 2011-08-04 16:31:58 +0000 |
834 | @@ -96,6 +96,7 @@ |
835 | void |
836 | LauncherContextualMenu::setTitle(const QString& title) |
837 | { |
838 | + setAccessibleName(title); |
839 | m_title = title; |
840 | /* Escaping ampersands so that they are not considered as keyboard |
841 | accelerators. */ |
842 | |
843 | === modified file 'libunity-2d-private/src/screeninfo.cpp' |
844 | --- libunity-2d-private/src/screeninfo.cpp 2011-07-29 13:49:34 +0000 |
845 | +++ libunity-2d-private/src/screeninfo.cpp 2011-08-04 16:31:58 +0000 |
846 | @@ -1,7 +1,5 @@ |
847 | extern "C" { |
848 | -#include <libwnck/screen.h> |
849 | -#include <libwnck/window.h> |
850 | -#include <libwnck/workspace.h> |
851 | +#include <libwnck/libwnck.h> |
852 | } |
853 | |
854 | #include "bamf-matcher.h" |
855 | |
856 | === modified file 'libunity-2d-private/src/unity2dapplication.cpp' |
857 | --- libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 11:42:46 +0000 |
858 | +++ libunity-2d-private/src/unity2dapplication.cpp 2011-08-04 16:31:58 +0000 |
859 | @@ -25,14 +25,62 @@ |
860 | |
861 | // libunity-2d |
862 | #include <debug_p.h> |
863 | +#include <gconnector.h> |
864 | +#include <gscopedpointer.h> |
865 | #include <unity2ddebug.h> |
866 | |
867 | // Qt |
868 | +#include <QFont> |
869 | #include <QWindowsStyle> |
870 | +#include <QAccessible> |
871 | +#include <QAccessibleWidget> |
872 | +#include <QWidget> |
873 | |
874 | // GTK |
875 | #include <gtk/gtk.h> |
876 | - |
877 | +#include <pango/pango.h> |
878 | + |
879 | +/////////////////////////////// |
880 | +class PlatformFontTracker |
881 | +{ |
882 | +public: |
883 | + PlatformFontTracker() |
884 | + { |
885 | + m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-font-name", |
886 | + G_CALLBACK(PlatformFontTracker::onFontChanged), this); |
887 | + |
888 | + updateFont(); |
889 | + } |
890 | + |
891 | +private: |
892 | + void updateFont() |
893 | + { |
894 | + gchar* fontName = 0; |
895 | + g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontName, NULL); |
896 | + GScopedPointer<PangoFontDescription, pango_font_description_free> fontDescription( |
897 | + pango_font_description_from_string(fontName) |
898 | + ); |
899 | + g_free(fontName); |
900 | + |
901 | + int size = pango_font_description_get_size(fontDescription.data()); |
902 | + |
903 | + QFont font = QFont( |
904 | + pango_font_description_get_family(fontDescription.data()), |
905 | + size / PANGO_SCALE |
906 | + ); |
907 | + |
908 | + QApplication::setFont(font); |
909 | + } |
910 | + |
911 | + static void onFontChanged(GObject*, GParamSpec*, PlatformFontTracker* obj) |
912 | + { |
913 | + obj->updateFont(); |
914 | + } |
915 | + |
916 | + GConnector m_gConnector; |
917 | +}; |
918 | + |
919 | +/////////////////////////////// |
920 | AbstractX11EventFilter::~AbstractX11EventFilter() |
921 | { |
922 | Unity2dApplication* application = Unity2dApplication::instance(); |
923 | @@ -41,6 +89,28 @@ |
924 | } |
925 | } |
926 | |
927 | +/////////////////////////////// |
928 | +static bool arrayContains(char** begin, char** end, const char* string) |
929 | +{ |
930 | + for (char** ptr = begin; ptr != end; ++ptr) { |
931 | + if (strcmp(*ptr, string) == 0) { |
932 | + return true; |
933 | + } |
934 | + } |
935 | + return false; |
936 | +} |
937 | + |
938 | +QAccessibleInterface *panelFactory(const QString &classname, QObject *object) |
939 | +{ |
940 | + QAccessibleInterface *interface = 0; |
941 | + |
942 | + if (classname == "Unity2dPanel" && object && object->isWidgetType()) { |
943 | + interface = new QAccessibleWidget(static_cast<QWidget *>(object), QAccessible::ToolBar); |
944 | + } |
945 | + |
946 | + return interface; |
947 | +} |
948 | + |
949 | void Unity2dApplication::earlySetup(int& argc, char** argv) |
950 | { |
951 | // Parts of unity-2d uses GTK so it needs to be initialized |
952 | @@ -61,10 +131,19 @@ |
953 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { |
954 | QApplication::setGraphicsSystem("raster"); |
955 | } |
956 | + |
957 | + /* Unless style has been specified in args, set default Qt style to |
958 | + * QWindowStyle to avoid loading QGtkStyle. We don't want to load QGtkStyle |
959 | + * because it uses libgtk2, which causes conflicts with our gtk3 code. |
960 | + */ |
961 | + if (!arrayContains(argv, argv + argc, "-style")) { |
962 | + QApplication::setStyle(new QWindowsStyle); |
963 | + } |
964 | } |
965 | |
966 | Unity2dApplication::Unity2dApplication(int& argc, char** argv) |
967 | : QApplication(argc, argv) |
968 | +, m_platformFontTracker(new PlatformFontTracker) |
969 | { |
970 | /* Allow developers to run Unity 2D uninstalled by telling dconf-qt |
971 | where to look for Unity 2D's schemas. |
972 | @@ -73,11 +152,14 @@ |
973 | if (!isRunningInstalled()) { |
974 | qputenv("GSETTINGS_SCHEMA_DIR", unity2dDirectory().toLocal8Bit() + "/data"); |
975 | } |
976 | + |
977 | + QAccessible::installFactory(panelFactory); |
978 | } |
979 | |
980 | Unity2dApplication::~Unity2dApplication() |
981 | { |
982 | qDeleteAll(m_x11EventFilters); |
983 | + delete m_platformFontTracker; |
984 | } |
985 | |
986 | Unity2dApplication* Unity2dApplication::instance() |
987 | |
988 | === modified file 'libunity-2d-private/src/unity2dapplication.h' |
989 | --- libunity-2d-private/src/unity2dapplication.h 2011-07-18 13:47:29 +0000 |
990 | +++ libunity-2d-private/src/unity2dapplication.h 2011-08-04 16:31:58 +0000 |
991 | @@ -27,6 +27,8 @@ |
992 | |
993 | class Unity2dApplication; |
994 | |
995 | +class PlatformFontTracker; |
996 | + |
997 | class AbstractX11EventFilter |
998 | { |
999 | public: |
1000 | @@ -65,6 +67,7 @@ |
1001 | |
1002 | private: |
1003 | QList<AbstractX11EventFilter*> m_x11EventFilters; |
1004 | + PlatformFontTracker* m_platformFontTracker; |
1005 | }; |
1006 | |
1007 | #endif // UNITY2DAPPLICATION_H |
1008 | |
1009 | === modified file 'libunity-2d-private/src/windowinfo.cpp' |
1010 | --- libunity-2d-private/src/windowinfo.cpp 2011-07-29 13:49:34 +0000 |
1011 | +++ libunity-2d-private/src/windowinfo.cpp 2011-08-04 16:31:58 +0000 |
1012 | @@ -14,9 +14,7 @@ |
1013 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1014 | */ |
1015 | |
1016 | -#include <libwnck/screen.h> |
1017 | -#include <libwnck/window.h> |
1018 | -#include <libwnck/workspace.h> |
1019 | +#include <libwnck/libwnck.h> |
1020 | |
1021 | #include <glib-2.0/glib.h> |
1022 | |
1023 | |
1024 | === modified file 'libunity-2d-private/src/workspacesinfo.cpp' |
1025 | --- libunity-2d-private/src/workspacesinfo.cpp 2011-07-29 13:49:34 +0000 |
1026 | +++ libunity-2d-private/src/workspacesinfo.cpp 2011-08-04 16:31:58 +0000 |
1027 | @@ -4,9 +4,7 @@ |
1028 | #include <debug_p.h> |
1029 | |
1030 | extern "C" { |
1031 | -#include <libwnck/screen.h> |
1032 | -#include <libwnck/window.h> |
1033 | -#include <libwnck/workspace.h> |
1034 | +#include <libwnck/libwnck.h> |
1035 | } |
1036 | |
1037 | #include <QAbstractEventDispatcher> |
1038 | |
1039 | === modified file 'panel/CMakeLists.txt' |
1040 | --- panel/CMakeLists.txt 2011-06-27 13:40:51 +0000 |
1041 | +++ panel/CMakeLists.txt 2011-08-04 16:31:58 +0000 |
1042 | @@ -1,5 +1,8 @@ |
1043 | project(unity-2d-panel) |
1044 | |
1045 | +# Dependencies |
1046 | +pkg_check_modules(UNITYCORE REQUIRED unity-core-4.0) |
1047 | + |
1048 | # Source |
1049 | include_directories( |
1050 | ${libunity-2d-private_SOURCE_DIR}/src |
1051 | @@ -8,8 +11,3 @@ |
1052 | add_subdirectory(applets) |
1053 | add_subdirectory(app) |
1054 | add_subdirectory(tests) |
1055 | - |
1056 | -# Install |
1057 | -install(DIRECTORY artwork |
1058 | - DESTINATION ${UNITY_2D_DIR}/panel |
1059 | - ) |
1060 | |
1061 | === modified file 'panel/app/CMakeLists.txt' |
1062 | --- panel/app/CMakeLists.txt 2011-04-04 16:41:15 +0000 |
1063 | +++ panel/app/CMakeLists.txt 2011-08-04 16:31:58 +0000 |
1064 | @@ -1,7 +1,6 @@ |
1065 | set(panel_SRCS |
1066 | main.cpp |
1067 | panelmanager.cpp |
1068 | - unity2dstyle.cpp |
1069 | ) |
1070 | |
1071 | qt4_automoc(${panel_SRCS}) |
1072 | @@ -10,14 +9,17 @@ |
1073 | include_directories( |
1074 | ${CMAKE_CURRENT_BINARY_DIR} |
1075 | ${CMAKE_CURRENT_SOURCE_DIR} |
1076 | + ${GTK_INCLUDE_DIRS} |
1077 | ${uqapplets_SOURCE_DIR} |
1078 | ${uqapplets_SOURCE_DIR}/common |
1079 | + ${UNITYCORE_INCLUDE_DIRS} |
1080 | ${libunity-2d-private_SOURCE_DIR}/src |
1081 | ) |
1082 | |
1083 | target_link_libraries(unity-2d-panel |
1084 | ${QT_QTGUI_LIBRARIES} |
1085 | ${QT_QTCORE_LIBRARIES} |
1086 | + ${GTK_LDFLAGS} |
1087 | uqapplets |
1088 | unity-2d-private |
1089 | ) |
1090 | |
1091 | === modified file 'panel/app/main.cpp' |
1092 | --- panel/app/main.cpp 2011-07-18 13:47:29 +0000 |
1093 | +++ panel/app/main.cpp 2011-08-04 16:31:58 +0000 |
1094 | @@ -22,12 +22,12 @@ |
1095 | // Local |
1096 | #include <config.h> |
1097 | #include <panelmanager.h> |
1098 | +#include <panelstyle.h> |
1099 | |
1100 | // Unity |
1101 | #include <gnomesessionclient.h> |
1102 | #include <unity2ddebug.h> |
1103 | #include <unity2dapplication.h> |
1104 | -#include <unity2dstyle.h> |
1105 | #include <unity2dtr.h> |
1106 | |
1107 | // Qt |
1108 | @@ -54,7 +54,10 @@ |
1109 | ThemeEngineHandler handler; |
1110 | Unity2dApplication::earlySetup(argc, argv); |
1111 | Unity2dApplication app(argc, argv); |
1112 | - QApplication::setStyle(new Unity2dStyle); |
1113 | + app.setApplicationName("Unity 2D Panel"); |
1114 | + |
1115 | + // Instantiate a PanelStyle so that it configures QApplication |
1116 | + PanelStyle::instance(); |
1117 | |
1118 | GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop"); |
1119 | client.connectToSessionManager(); |
1120 | |
1121 | === modified file 'panel/app/panelmanager.cpp' |
1122 | --- panel/app/panelmanager.cpp 2011-06-12 23:01:35 +0000 |
1123 | +++ panel/app/panelmanager.cpp 2011-08-04 16:31:58 +0000 |
1124 | @@ -24,6 +24,8 @@ |
1125 | |
1126 | // Local |
1127 | #include <config.h> |
1128 | +#include <panelstyle.h> |
1129 | +#include <indicatorsmanager.h> |
1130 | |
1131 | // Applets |
1132 | #include <appindicator/appindicatorapplet.h> |
1133 | @@ -42,70 +44,56 @@ |
1134 | |
1135 | using namespace Unity2d; |
1136 | |
1137 | -static QPalette getPalette() |
1138 | -{ |
1139 | - QPalette palette; |
1140 | - |
1141 | - /* Should use the panel's background provided by Unity but it turns |
1142 | - out not to be good. It would look like: |
1143 | - |
1144 | - QBrush bg(QPixmap("theme:/panel_background.png")); |
1145 | - */ |
1146 | - QBrush bg(QPixmap(unity2dDirectory() + "/panel/artwork/background.png")); |
1147 | - palette.setBrush(QPalette::Window, bg); |
1148 | - palette.setBrush(QPalette::Button, bg); |
1149 | - return palette; |
1150 | -} |
1151 | - |
1152 | -static QLabel* createSeparator() |
1153 | -{ |
1154 | - QLabel* label = new QLabel; |
1155 | - QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png"); |
1156 | - label->setPixmap(pix); |
1157 | - label->setFixedSize(pix.size()); |
1158 | - return label; |
1159 | -} |
1160 | - |
1161 | -static Unity2dPanel* instantiatePanel(int screen) |
1162 | +static QWidget* createSeparator() |
1163 | +{ |
1164 | + // Just a quick-hack: homebutton is going away anyway |
1165 | + QWidget* widget = new QWidget; |
1166 | + widget->setFixedWidth(6); |
1167 | + return widget; |
1168 | +} |
1169 | + |
1170 | +PanelManager::PanelManager(QObject* parent) |
1171 | +: QObject(parent) |
1172 | +{ |
1173 | + QDesktopWidget* desktop = QApplication::desktop(); |
1174 | + for(int i = 0; i < desktop->screenCount(); ++i) { |
1175 | + Unity2dPanel* panel = instantiatePanel(i); |
1176 | + m_panels.append(panel); |
1177 | + panel->show(); |
1178 | + panel->move(desktop->screenGeometry(i).topLeft()); |
1179 | + } |
1180 | + connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int))); |
1181 | +} |
1182 | + |
1183 | +PanelManager::~PanelManager() |
1184 | +{ |
1185 | + qDeleteAll(m_panels); |
1186 | +} |
1187 | + |
1188 | +Unity2dPanel* PanelManager::instantiatePanel(int screen) |
1189 | { |
1190 | Unity2dPanel* panel = new Unity2dPanel; |
1191 | + panel->setAccessibleName("Top Panel"); |
1192 | panel->setEdge(Unity2dPanel::TopEdge); |
1193 | - panel->setPalette(getPalette()); |
1194 | panel->setFixedHeight(24); |
1195 | |
1196 | + IndicatorsManager* indicatorsManager = new IndicatorsManager(panel); |
1197 | + |
1198 | int leftmost = QApplication::desktop()->screenNumber(QPoint()); |
1199 | if (screen == leftmost) { |
1200 | panel->addWidget(new HomeButtonApplet); |
1201 | panel->addWidget(createSeparator()); |
1202 | } |
1203 | - panel->addWidget(new AppNameApplet); |
1204 | + panel->addWidget(new AppNameApplet(indicatorsManager)); |
1205 | if (screen == leftmost) { |
1206 | /* It doesn’t make sense to have more than one instance of the systray, |
1207 | XEmbed’ed windows can be displayed only once anyway. */ |
1208 | panel->addWidget(new LegacyTrayApplet); |
1209 | } |
1210 | - panel->addWidget(new IndicatorApplet); |
1211 | + panel->addWidget(new IndicatorApplet(indicatorsManager)); |
1212 | return panel; |
1213 | } |
1214 | |
1215 | -PanelManager::PanelManager(QObject* parent) |
1216 | - : QObject(parent) |
1217 | -{ |
1218 | - QDesktopWidget* desktop = QApplication::desktop(); |
1219 | - for(int i = 0; i < desktop->screenCount(); ++i) { |
1220 | - Unity2dPanel* panel = instantiatePanel(i); |
1221 | - m_panels.append(panel); |
1222 | - panel->show(); |
1223 | - panel->move(desktop->screenGeometry(i).topLeft()); |
1224 | - } |
1225 | - connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int))); |
1226 | -} |
1227 | - |
1228 | -PanelManager::~PanelManager() |
1229 | -{ |
1230 | - qDeleteAll(m_panels); |
1231 | -} |
1232 | - |
1233 | void |
1234 | PanelManager::onScreenCountChanged(int newCount) |
1235 | { |
1236 | |
1237 | === modified file 'panel/app/panelmanager.h' |
1238 | --- panel/app/panelmanager.h 2011-04-04 16:41:15 +0000 |
1239 | +++ panel/app/panelmanager.h 2011-08-04 16:31:58 +0000 |
1240 | @@ -40,6 +40,8 @@ |
1241 | Q_DISABLE_COPY(PanelManager) |
1242 | QList<Unity2dPanel*> m_panels; |
1243 | |
1244 | + Unity2dPanel* instantiatePanel(int screen); |
1245 | + |
1246 | private Q_SLOTS: |
1247 | void onScreenCountChanged(int newCount); |
1248 | }; |
1249 | |
1250 | === removed file 'panel/app/unity2dstyle.cpp' |
1251 | --- panel/app/unity2dstyle.cpp 2011-03-28 12:16:02 +0000 |
1252 | +++ panel/app/unity2dstyle.cpp 1970-01-01 00:00:00 +0000 |
1253 | @@ -1,98 +0,0 @@ |
1254 | -/* |
1255 | - * Plasma applet to display DBus global menu |
1256 | - * |
1257 | - * Copyright 2009 Canonical Ltd. |
1258 | - * |
1259 | - * Authors: |
1260 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
1261 | - * |
1262 | - * This program is free software; you can redistribute it and/or modify |
1263 | - * it under the terms of the GNU General Public License as published by |
1264 | - * the Free Software Foundation; version 3. |
1265 | - * |
1266 | - * This program is distributed in the hope that it will be useful, |
1267 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1268 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1269 | - * GNU General Public License for more details. |
1270 | - * |
1271 | - * You should have received a copy of the GNU General Public License |
1272 | - * along with this program. If not, see <http://www.gnu.org/licenses/> |
1273 | - */ |
1274 | - |
1275 | -// Self |
1276 | -#include "unity2dstyle.h" |
1277 | - |
1278 | -// Local |
1279 | - |
1280 | -// libunity-2d-private |
1281 | -#include <debug_p.h> |
1282 | -#include <keyboardmodifiersmonitor.h> |
1283 | - |
1284 | -// Qt |
1285 | -#include <QGtkStyle> |
1286 | -#include <QMenu> |
1287 | -#include <QPainter> |
1288 | -#include <QStyleOptionFrame> |
1289 | -#include <QWidget> |
1290 | - |
1291 | -Unity2dStyle::Unity2dStyle() |
1292 | -: QProxyStyle(new QGtkStyle) |
1293 | -{ |
1294 | -} |
1295 | - |
1296 | -void Unity2dStyle::drawControl(QStyle::ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const |
1297 | -{ |
1298 | - if (element == QStyle::CE_MenuBarItem && widget) { |
1299 | - QStyleOptionMenuItem opt = *qstyleoption_cast<const QStyleOptionMenuItem*>(option); |
1300 | - if (!(opt.state & QStyle::State_Enabled) && (opt.state & QStyle::State_Sunken)) { |
1301 | - // Reset State_Sunken flag to avoid drawing a frame on a disabled menu item |
1302 | - // See https://bugs.launchpad.net/unity-2d/+bug/717744 |
1303 | - opt.state ^= QStyle::State_Sunken; |
1304 | - } |
1305 | - // Skip "widget" parameter to avoid solid gray background behind the menubar items |
1306 | - QProxyStyle::drawControl(element, &opt, painter, 0); |
1307 | - } else if (element == QStyle::CE_MenuBarEmptyArea) { |
1308 | - // Avoid gray borders around the menubar items |
1309 | - } else { |
1310 | - QProxyStyle::drawControl(element, option, painter, widget); |
1311 | - } |
1312 | -} |
1313 | - |
1314 | -int Unity2dStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option, const QWidget* widget) const |
1315 | -{ |
1316 | - if (metric == QStyle::PM_MenuBarVMargin) { |
1317 | - // Avoid one-pixel gap above menuitem |
1318 | - return 0; |
1319 | - } else { |
1320 | - return QProxyStyle::pixelMetric(metric, option, widget); |
1321 | - } |
1322 | -} |
1323 | - |
1324 | -QSize Unity2dStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const |
1325 | -{ |
1326 | - QSize size = QProxyStyle::sizeFromContents(type, option, contentsSize, widget); |
1327 | - if (type == QStyle::CT_MenuBarItem && widget) { |
1328 | - // Avoid three-pixel gap below menuitem |
1329 | - size.setHeight(widget->height()); |
1330 | - } |
1331 | - return size; |
1332 | -} |
1333 | - |
1334 | -int Unity2dStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const |
1335 | -{ |
1336 | - if (hint == QStyle::SH_UnderlineShortcut) { |
1337 | - // The shortcut of an opened menu can be triggered without holding Alt |
1338 | - // down, so we always show the underline. For all other widgets we only |
1339 | - // show the underlines if alt is down. |
1340 | - // Note that this is a bit hackish: it only works reliably if the |
1341 | - // widget repaints itself when alt is pressed or released. For now only |
1342 | - // the MenuBarWidget from the AppNameApplets does this. |
1343 | - if (qobject_cast<const QMenu*>(widget)) { |
1344 | - return true; |
1345 | - } else { |
1346 | - return KeyboardModifiersMonitor::instance()->keyboardModifiers() == Qt::AltModifier; |
1347 | - } |
1348 | - } else { |
1349 | - return QProxyStyle::styleHint(hint, option, widget, returnData); |
1350 | - } |
1351 | -} |
1352 | |
1353 | === removed file 'panel/app/unity2dstyle.h' |
1354 | --- panel/app/unity2dstyle.h 2011-01-26 15:50:26 +0000 |
1355 | +++ panel/app/unity2dstyle.h 1970-01-01 00:00:00 +0000 |
1356 | @@ -1,44 +0,0 @@ |
1357 | -/* |
1358 | - * This file is part of unity-2d |
1359 | - * |
1360 | - * Copyright 2010 Canonical Ltd. |
1361 | - * |
1362 | - * Authors: |
1363 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
1364 | - * |
1365 | - * This program is free software; you can redistribute it and/or modify |
1366 | - * it under the terms of the GNU General Public License as published by |
1367 | - * the Free Software Foundation; version 3. |
1368 | - * |
1369 | - * This program is distributed in the hope that it will be useful, |
1370 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1371 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1372 | - * GNU General Public License for more details. |
1373 | - * |
1374 | - * You should have received a copy of the GNU General Public License |
1375 | - * along with this program. If not, see <http://www.gnu.org/licenses/> |
1376 | - */ |
1377 | - |
1378 | -#ifndef UNITY2DSTYLE_H |
1379 | -#define UNITY2DSTYLE_H |
1380 | - |
1381 | -// Local |
1382 | - |
1383 | -// Qt |
1384 | -#include <QProxyStyle> |
1385 | - |
1386 | -class Unity2dStyle : public QProxyStyle |
1387 | -{ |
1388 | -public: |
1389 | - Unity2dStyle(); |
1390 | - |
1391 | - virtual void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const; |
1392 | - |
1393 | - virtual int pixelMetric(PixelMetric metric, const QStyleOption* option = 0, const QWidget* widget = 0) const; |
1394 | - |
1395 | - virtual QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget = 0) const; |
1396 | - |
1397 | - virtual int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const; |
1398 | -}; |
1399 | - |
1400 | -#endif /* UNITY2DSTYLE_H */ |
1401 | |
1402 | === modified file 'panel/applets/CMakeLists.txt' |
1403 | --- panel/applets/CMakeLists.txt 2011-07-18 10:33:35 +0000 |
1404 | +++ panel/applets/CMakeLists.txt 2011-08-04 16:31:58 +0000 |
1405 | @@ -1,42 +1,28 @@ |
1406 | project(uqapplets) |
1407 | |
1408 | -macro(read_pkg_variable cmake_var pkg pkg_var) |
1409 | - execute_process( |
1410 | - COMMAND pkg-config --variable=${pkg_var} ${pkg} |
1411 | - OUTPUT_VARIABLE tmp |
1412 | - ) |
1413 | - # Remove trailing newline from ${tmp} |
1414 | - string(STRIP "${tmp}" ${cmake_var}) |
1415 | -endmacro(read_pkg_variable) |
1416 | - |
1417 | # Dependencies |
1418 | include(FindPkgConfig) |
1419 | |
1420 | pkg_check_modules(QTBAMF REQUIRED libqtbamf) |
1421 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
1422 | -pkg_check_modules(INDICATOR REQUIRED indicator) |
1423 | - |
1424 | -# Get indicator dirs from pkgconfig |
1425 | -read_pkg_variable(INDICATOR_DIR indicator indicatordir) |
1426 | -read_pkg_variable(INDICATOR_ICONS_DIR indicator iconsdir) |
1427 | -configure_file(indicator-config.h.in indicator-config.h) |
1428 | |
1429 | # Sources |
1430 | set(uqapplets_SRCS |
1431 | appindicator/appindicatorapplet.cpp |
1432 | appindicator/sniitem.cpp |
1433 | appname/appnameapplet.cpp |
1434 | + appname/croppedlabel.cpp |
1435 | appname/menubarwidget.cpp |
1436 | - appname/registrar.cpp |
1437 | appname/windowhelper.cpp |
1438 | common/applet.cpp |
1439 | + common/indicatorentrywidget.cpp |
1440 | + common/indicatorsmanager.cpp |
1441 | + common/indicatorwidget.cpp |
1442 | + common/cairoutils.cpp |
1443 | + common/panelstyle.cpp |
1444 | homebutton/homebuttonapplet.cpp |
1445 | homebutton/homebutton.cpp |
1446 | - indicator/abstractindicator.cpp |
1447 | - indicator/datetimeindicator.cpp |
1448 | indicator/indicatorapplet.cpp |
1449 | - indicator/indicatorservicemanager.cpp |
1450 | - indicator/indicator.c |
1451 | legacytray/legacytrayapplet.cpp |
1452 | legacytray/fdoselectionmanager.cpp |
1453 | legacytray/fdotask.cpp |
1454 | @@ -45,10 +31,6 @@ |
1455 | legacytray/x11embedpainter.cpp |
1456 | ) |
1457 | |
1458 | -qt4_add_dbus_adaptor(uqapplets_SRCS appname/com.canonical.AppMenu.Registrar.xml |
1459 | - registrar.h Registrar |
1460 | - ) |
1461 | - |
1462 | qt4_automoc(${uqapplets_SRCS}) |
1463 | |
1464 | # Build |
1465 | @@ -58,13 +40,17 @@ |
1466 | ${CMAKE_CURRENT_SOURCE_DIR}/common |
1467 | ${CMAKE_CURRENT_SOURCE_DIR}/homebutton |
1468 | ${CMAKE_CURRENT_SOURCE_DIR}/indicator |
1469 | + ${CMAKE_CURRENT_SOURCE_DIR}/unitycore |
1470 | ${QTBAMF_INCLUDE_DIRS} |
1471 | + ${QTGCONF_INCLUDE_DIRS} |
1472 | ${DBUSMENUQT_INCLUDE_DIRS} |
1473 | ${GTK_INCLUDE_DIRS} |
1474 | - ${INDICATOR_INCLUDE_DIRS} |
1475 | ${WNCK_INCLUDE_DIRS} |
1476 | ${CMAKE_CURRENT_BINARY_DIR} |
1477 | ${X11_INCLUDE_DIR} |
1478 | + ${UNITYCORE_INCLUDE_DIRS} |
1479 | + ${NUXCORE_INCLUDE_DIRS} |
1480 | + ${PANGO_INCLUDE_DIRS} |
1481 | ${libunity-2d-private_SOURCE_DIR}/src |
1482 | ) |
1483 | |
1484 | @@ -75,13 +61,16 @@ |
1485 | ${QT_QTCORE_LIBRARIES} |
1486 | ${DBUSMENUQT_LDFLAGS} |
1487 | ${QTBAMF_LDFLAGS} |
1488 | + ${QTGCONF_LDFLAGS} |
1489 | ${GTK_LDFLAGS} |
1490 | - ${INDICATOR_LDFLAGS} |
1491 | ${WNCK_LDFLAGS} |
1492 | ${X11_LIBRARIES} |
1493 | ${X11_Xrender_LIB} |
1494 | ${X11_Xcomposite_LIB} |
1495 | ${X11_Xdamage_LIB} |
1496 | ${X11_Xfixes_LIB} |
1497 | + ${UNITYCORE_LDFLAGS} |
1498 | + ${NUXCORE_LDFLAGS} |
1499 | + ${PANGO_LDFLAGS} |
1500 | unity-2d-private |
1501 | ) |
1502 | |
1503 | === modified file 'panel/applets/appname/appnameapplet.cpp' |
1504 | --- panel/applets/appname/appnameapplet.cpp 2011-07-26 09:36:41 +0000 |
1505 | +++ panel/applets/appname/appnameapplet.cpp 2011-08-04 16:31:58 +0000 |
1506 | @@ -23,6 +23,7 @@ |
1507 | #include "appnameapplet.h" |
1508 | |
1509 | // Local |
1510 | +#include "croppedlabel.h" |
1511 | #include "menubarwidget.h" |
1512 | #include "windowhelper.h" |
1513 | |
1514 | @@ -49,9 +50,7 @@ |
1515 | |
1516 | static const int WINDOW_BUTTONS_RIGHT_MARGIN = 4; |
1517 | |
1518 | -static const int APPNAME_LABEL_LEFT_MARGIN = 12; |
1519 | - |
1520 | -static const int FADEOUT_WIDTH = 16; |
1521 | +static const int APPNAME_LABEL_LEFT_MARGIN = 6; |
1522 | |
1523 | namespace Unity2d |
1524 | { |
1525 | @@ -106,50 +105,6 @@ |
1526 | } |
1527 | }; |
1528 | |
1529 | -/** |
1530 | - * This label makes sure minimumSizeHint() is not set. This ensures the applet |
1531 | - * does not get wider if a window title is very long |
1532 | - */ |
1533 | -class CroppedLabel : public QLabel |
1534 | -{ |
1535 | -public: |
1536 | - CroppedLabel(QWidget* parent = 0) |
1537 | - : QLabel(parent) |
1538 | - {} |
1539 | - |
1540 | - QSize minimumSizeHint() const |
1541 | - { |
1542 | - return QWidget::minimumSizeHint(); |
1543 | - } |
1544 | - |
1545 | -protected: |
1546 | - void paintEvent(QPaintEvent* event) |
1547 | - { |
1548 | - QImage image(width(), height(), QImage::Format_ARGB32_Premultiplied); |
1549 | - { |
1550 | - QPainter painter(&image); |
1551 | - painter.initFrom(this); |
1552 | - painter.setCompositionMode(QPainter::CompositionMode_Source); |
1553 | - painter.fillRect(rect(), Qt::transparent); |
1554 | - |
1555 | - painter.setCompositionMode(QPainter::CompositionMode_SourceOver); |
1556 | - painter.drawText(contentsRect(), Qt::AlignLeft | Qt::AlignVCenter, text()); |
1557 | - |
1558 | - if (QLabel::minimumSizeHint().width() > contentsRect().width()) { |
1559 | - // Text does not fit, fade the end |
1560 | - painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); |
1561 | - QRect gradientRect(width() - FADEOUT_WIDTH, 0, FADEOUT_WIDTH, height()); |
1562 | - QLinearGradient gradient(gradientRect.topLeft(), gradientRect.topRight()); |
1563 | - gradient.setColorAt(0, Qt::white); |
1564 | - gradient.setColorAt(1, Qt::transparent); |
1565 | - painter.fillRect(gradientRect, gradient); |
1566 | - } |
1567 | - } |
1568 | - QPainter painter(this); |
1569 | - painter.drawImage(0, 0, image); |
1570 | - } |
1571 | -}; |
1572 | - |
1573 | struct AppNameAppletPrivate |
1574 | { |
1575 | AppNameApplet* q; |
1576 | @@ -200,10 +155,10 @@ |
1577 | q, SLOT(updateWidgets())); |
1578 | } |
1579 | |
1580 | - void setupMenuBarWidget() |
1581 | + void setupMenuBarWidget(IndicatorsManager* manager) |
1582 | { |
1583 | - m_menuBarWidget = new MenuBarWidget(0 /* Window menu */); |
1584 | - QObject::connect(m_menuBarWidget, SIGNAL(menuBarClosed()), |
1585 | + m_menuBarWidget = new MenuBarWidget(manager); |
1586 | + QObject::connect(m_menuBarWidget, SIGNAL(isOpenedChanged()), |
1587 | q, SLOT(updateWidgets())); |
1588 | QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()), |
1589 | q, SLOT(updateWidgets())); |
1590 | @@ -216,21 +171,16 @@ |
1591 | } |
1592 | }; |
1593 | |
1594 | -AppNameApplet::AppNameApplet() |
1595 | +AppNameApplet::AppNameApplet(IndicatorsManager* indicatorsManager) |
1596 | : d(new AppNameAppletPrivate) |
1597 | { |
1598 | d->q = this; |
1599 | setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum); |
1600 | |
1601 | - QPalette palette; |
1602 | - palette.setColor(QPalette::WindowText, Qt::white); |
1603 | - palette.setColor(QPalette::ButtonText, Qt::white); |
1604 | - setPalette(palette); |
1605 | - |
1606 | d->setupWindowHelper(); |
1607 | d->setupLabel(); |
1608 | d->setupWindowButtonWidget(); |
1609 | - d->setupMenuBarWidget(); |
1610 | + d->setupMenuBarWidget(indicatorsManager); |
1611 | d->setupKeyboardModifiersMonitor(); |
1612 | |
1613 | QHBoxLayout* layout = new QHBoxLayout(this); |
1614 | |
1615 | === modified file 'panel/applets/appname/appnameapplet.h' |
1616 | --- panel/applets/appname/appnameapplet.h 2011-06-06 09:06:55 +0000 |
1617 | +++ panel/applets/appname/appnameapplet.h 2011-08-04 16:31:58 +0000 |
1618 | @@ -29,6 +29,8 @@ |
1619 | |
1620 | class QEvent; |
1621 | |
1622 | +class IndicatorsManager; |
1623 | + |
1624 | namespace Unity2d |
1625 | { |
1626 | |
1627 | @@ -37,7 +39,7 @@ |
1628 | { |
1629 | Q_OBJECT |
1630 | public: |
1631 | - AppNameApplet(); |
1632 | + AppNameApplet(IndicatorsManager*); |
1633 | ~AppNameApplet(); |
1634 | |
1635 | protected: |
1636 | |
1637 | === removed file 'panel/applets/appname/com.canonical.AppMenu.Registrar.xml' |
1638 | --- panel/applets/appname/com.canonical.AppMenu.Registrar.xml 2011-02-10 01:10:19 +0000 |
1639 | +++ panel/applets/appname/com.canonical.AppMenu.Registrar.xml 1970-01-01 00:00:00 +0000 |
1640 | @@ -1,82 +0,0 @@ |
1641 | -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
1642 | -<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd"> |
1643 | - <dox:d><![CDATA[ |
1644 | - @mainpage |
1645 | - |
1646 | - An interface to register menus that are associated with a window in an application. The |
1647 | - main interface is docuemented here: @ref com::canonical::AppMenu::Registrar. |
1648 | - |
1649 | - The actual menus are transported using the dbusmenu protocol which is available |
1650 | - here: @ref com::canonical::dbusmenu. |
1651 | - ]]></dox:d> |
1652 | - <interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd"> |
1653 | - <dox:d> |
1654 | - An interface to register a menu from an application's window to be displayed in another |
1655 | - window. This manages that association between XWindow Window IDs and the dbus |
1656 | - address and object that provides the menu using the dbusmenu dbus interface. |
1657 | - </dox:d> |
1658 | - <method name="RegisterWindow"> |
1659 | - <dox:d><![CDATA[ |
1660 | - Associates a dbusmenu with a window |
1661 | - |
1662 | - /note this method assumes that the connection from the caller is the DBus connection |
1663 | - to use for the object. Applications that use multiple DBus connections will need to |
1664 | - ensure this method is called with the same connection that implmenets the object. |
1665 | - ]]></dox:d> |
1666 | - <arg name="windowId" type="u" direction="in"> |
1667 | - <dox:d>The XWindow ID of the window</dox:d> |
1668 | - </arg> |
1669 | - <arg name="menuObjectPath" type="o" direction="in"> |
1670 | - <dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d> |
1671 | - </arg> |
1672 | - </method> |
1673 | - <method name="UnregisterWindow"> |
1674 | - <dox:d> |
1675 | - A method to allow removing a window from the database. Windows will also be removed |
1676 | - when the client drops off DBus so this is not required. It is polite though. And |
1677 | - important for testing. |
1678 | - </dox:d> |
1679 | - <arg name="windowId" type="u" direction="in"> |
1680 | - <dox:d>The XWindow ID of the window</dox:d> |
1681 | - </arg> |
1682 | - </method> |
1683 | - <method name="GetMenuForWindow"> |
1684 | - <dox:d>Gets the registered menu for a given window ID.</dox:d> |
1685 | - <arg name="windowId" type="u" direction="in"> |
1686 | - <dox:d>The XWindow ID of the window to get</dox:d> |
1687 | - </arg> |
1688 | - <arg name="service" type="s" direction="out"> |
1689 | - <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d> |
1690 | - </arg> |
1691 | - <arg name="menuObjectPath" type="o" direction="out"> |
1692 | - <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d> |
1693 | - </arg> |
1694 | - </method> |
1695 | - <method name="GetMenus"> |
1696 | - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MenuInfoList"/> |
1697 | - <dox:d>Gets the information on all menus that the registrar knows about. This |
1698 | - is useful for debugging or bringing up a new renderer.</dox:d> |
1699 | - <arg name="menus" type="a(uso)" direction="out"> |
1700 | - <dox:d>An array of structures containing the same parameters as @GetMenuForWindow. Window ID, Service and ObjectPath.</dox:d> |
1701 | - </arg> |
1702 | - </method> |
1703 | - <signal name="WindowRegistered"> |
1704 | - <dox:d>Signals when the registrar gets a new menu registered</dox:d> |
1705 | - <arg name="windowId" type="u" direction="out"> |
1706 | - <dox:d>The XWindow ID of the window</dox:d> |
1707 | - </arg> |
1708 | - <arg name="service" type="s" direction="out"> |
1709 | - <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d> |
1710 | - </arg> |
1711 | - <arg name="menuObjectPath" type="o" direction="out"> |
1712 | - <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d> |
1713 | - </arg> |
1714 | - </signal> |
1715 | - <signal name="WindowUnregistered"> |
1716 | - <dox:d>Signals when the registrar removes a menu registration</dox:d> |
1717 | - <arg name="windowId" type="u" direction="out"> |
1718 | - <dox:d>The XWindow ID of the window</dox:d> |
1719 | - </arg> |
1720 | - </signal> |
1721 | - </interface> |
1722 | -</node> |
1723 | |
1724 | === added file 'panel/applets/appname/croppedlabel.cpp' |
1725 | --- panel/applets/appname/croppedlabel.cpp 1970-01-01 00:00:00 +0000 |
1726 | +++ panel/applets/appname/croppedlabel.cpp 2011-08-04 16:31:58 +0000 |
1727 | @@ -0,0 +1,140 @@ |
1728 | +/* |
1729 | + * This file is part of unity-2d |
1730 | + * |
1731 | + * Copyright 2011 Canonical Ltd. |
1732 | + * |
1733 | + * Authors: |
1734 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
1735 | + * |
1736 | + * This program is free software; you can redistribute it and/or modify |
1737 | + * it under the terms of the GNU General Public License as published by |
1738 | + * the Free Software Foundation; version 3. |
1739 | + * |
1740 | + * This program is distributed in the hope that it will be useful, |
1741 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1742 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1743 | + * GNU General Public License for more details. |
1744 | + * |
1745 | + * You should have received a copy of the GNU General Public License |
1746 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1747 | + */ |
1748 | +// Self |
1749 | +#include "croppedlabel.h" |
1750 | + |
1751 | +// Local |
1752 | +#include <cairoutils.h> |
1753 | +#include <panelstyle.h> |
1754 | + |
1755 | +// unity-2d |
1756 | +#include <debug_p.h> |
1757 | + |
1758 | +// libqtgconf |
1759 | +#include <gconfitem-qml-wrapper.h> |
1760 | + |
1761 | +// Qt |
1762 | +#include <QImage> |
1763 | +#include <QPainter> |
1764 | + |
1765 | +// GTK |
1766 | +#include <gtk/gtk.h> |
1767 | + |
1768 | +static const int FADEOUT_WIDTH = 30; |
1769 | + |
1770 | +static const char* WINDOW_TITLE_FONT_KEY = "/apps/metacity/general/titlebar_font"; |
1771 | + |
1772 | +CroppedLabel::CroppedLabel(QWidget* parent) |
1773 | +: QLabel(parent) |
1774 | +{ |
1775 | +} |
1776 | + |
1777 | +QSize CroppedLabel::minimumSizeHint() const |
1778 | +{ |
1779 | + return QWidget::minimumSizeHint(); |
1780 | +} |
1781 | + |
1782 | +static void paintFadeoutGradient(QImage* image) |
1783 | +{ |
1784 | + QPainter painter(image); |
1785 | + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); |
1786 | + QRect gradientRect(image->width() - FADEOUT_WIDTH, 0, FADEOUT_WIDTH, image->height()); |
1787 | + QLinearGradient gradient(gradientRect.topLeft(), gradientRect.topRight()); |
1788 | + gradient.setColorAt(0, Qt::white); |
1789 | + gradient.setColorAt(1, Qt::transparent); |
1790 | + painter.fillRect(gradientRect, gradient); |
1791 | +} |
1792 | + |
1793 | +static QString getWindowTitleFontName() |
1794 | +{ |
1795 | + GConfItemQmlWrapper client; |
1796 | + client.setKey(WINDOW_TITLE_FONT_KEY); |
1797 | + return client.getValue().toString(); |
1798 | +} |
1799 | + |
1800 | +void CroppedLabel::paintEvent(QPaintEvent* event) |
1801 | +{ |
1802 | + // Create an image filled with background brush (to avoid subpixel hinting |
1803 | + // artefacts around text) |
1804 | + QImage image(width(), height(), QImage::Format_ARGB32_Premultiplied); |
1805 | + { |
1806 | + QPainter painter(&image); |
1807 | + painter.initFrom(this); |
1808 | + painter.eraseRect(rect()); |
1809 | + } |
1810 | + |
1811 | + // Create a pango layout |
1812 | + GObjectScopedPointer<PangoContext> pangoContext(gdk_pango_context_get()); |
1813 | + GObjectScopedPointer<PangoLayout> layout(pango_layout_new(pangoContext.data())); |
1814 | + |
1815 | + // Set font |
1816 | + QByteArray fontName = getWindowTitleFontName().toUtf8(); |
1817 | + PangoFontDescription* desc = pango_font_description_from_string(fontName.data()); |
1818 | + pango_layout_set_font_description(layout.data(), desc); |
1819 | + pango_font_description_free(desc); |
1820 | + |
1821 | + // Set text |
1822 | + QByteArray utf8Text = text().toUtf8(); |
1823 | + pango_layout_set_text (layout.data(), utf8Text.data(), -1); |
1824 | + |
1825 | + // Get text size |
1826 | + int textWidth = 0; |
1827 | + int textHeight = 0; |
1828 | + pango_layout_get_pixel_size(layout.data(), &textWidth, &textHeight); |
1829 | + |
1830 | + // Draw text |
1831 | + CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(&image)); |
1832 | + CairoUtils::Pointer cr(cairo_create(surface.data())); |
1833 | + |
1834 | + PanelStyle* style = PanelStyle::instance(); |
1835 | + GtkStyleContext* style_context = style->styleContext(); |
1836 | + |
1837 | + gtk_style_context_save(style_context); |
1838 | + |
1839 | + GtkWidgetPath* widget_path = gtk_widget_path_new(); |
1840 | + gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR); |
1841 | + gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM); |
1842 | + gtk_widget_path_iter_set_name(widget_path, -1 , "UnityPanelWidget"); |
1843 | + |
1844 | + gtk_style_context_set_path(style_context, widget_path); |
1845 | + gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR); |
1846 | + gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM); |
1847 | + |
1848 | + gtk_render_layout(style_context, cr.data(), |
1849 | + contentsRect().left(), |
1850 | + contentsRect().top() + (height() - textHeight) / 2, |
1851 | + layout.data()); |
1852 | + |
1853 | + gtk_widget_path_free(widget_path); |
1854 | + |
1855 | + gtk_style_context_restore(style_context); |
1856 | + |
1857 | + // Fade if necessary |
1858 | + if (textWidth > contentsRect().width()) { |
1859 | + paintFadeoutGradient(&image); |
1860 | + } |
1861 | + |
1862 | + // Paint on our widget |
1863 | + QPainter painter(this); |
1864 | + painter.drawImage(0, 0, image); |
1865 | +} |
1866 | + |
1867 | +#include "croppedlabel.moc" |
1868 | |
1869 | === added file 'panel/applets/appname/croppedlabel.h' |
1870 | --- panel/applets/appname/croppedlabel.h 1970-01-01 00:00:00 +0000 |
1871 | +++ panel/applets/appname/croppedlabel.h 2011-08-04 16:31:58 +0000 |
1872 | @@ -0,0 +1,45 @@ |
1873 | +/* |
1874 | + * This file is part of unity-2d |
1875 | + * |
1876 | + * Copyright 2011 Canonical Ltd. |
1877 | + * |
1878 | + * Authors: |
1879 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
1880 | + * |
1881 | + * This program is free software; you can redistribute it and/or modify |
1882 | + * it under the terms of the GNU General Public License as published by |
1883 | + * the Free Software Foundation; version 3. |
1884 | + * |
1885 | + * This program is distributed in the hope that it will be useful, |
1886 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1887 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1888 | + * GNU General Public License for more details. |
1889 | + * |
1890 | + * You should have received a copy of the GNU General Public License |
1891 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1892 | + */ |
1893 | +#ifndef CROPPEDLABEL_H |
1894 | +#define CROPPEDLABEL_H |
1895 | + |
1896 | +// Local |
1897 | + |
1898 | +// Qt |
1899 | +#include <QLabel> |
1900 | + |
1901 | +/** |
1902 | + * This label makes sure minimumSizeHint() is not set. This ensures the applet |
1903 | + * does not get wider if a window title is very long |
1904 | + */ |
1905 | +class CroppedLabel : public QLabel |
1906 | +{ |
1907 | + Q_OBJECT |
1908 | +public: |
1909 | + CroppedLabel(QWidget* parent = 0); |
1910 | + |
1911 | + QSize minimumSizeHint() const; |
1912 | + |
1913 | +protected: |
1914 | + void paintEvent(QPaintEvent*); |
1915 | +}; |
1916 | + |
1917 | +#endif /* CROPPEDLABEL_H */ |
1918 | |
1919 | === modified file 'panel/applets/appname/menubarwidget.cpp' |
1920 | --- panel/applets/appname/menubarwidget.cpp 2011-07-26 09:36:41 +0000 |
1921 | +++ panel/applets/appname/menubarwidget.cpp 2011-08-04 16:31:58 +0000 |
1922 | @@ -20,299 +20,98 @@ |
1923 | */ |
1924 | |
1925 | // Self |
1926 | -#include "menubarwidget.h" |
1927 | +#include <menubarwidget.h> |
1928 | |
1929 | // Local |
1930 | -#include "config.h" |
1931 | -#include "debug_p.h" |
1932 | -#include "keyboardmodifiersmonitor.h" |
1933 | -#include "registrar.h" |
1934 | - |
1935 | -// dbusmenu-qt |
1936 | -#include <dbusmenuimporter.h> |
1937 | - |
1938 | -// bamf |
1939 | -#include <bamf-matcher.h> |
1940 | -#include <bamf-window.h> |
1941 | +#include <debug_p.h> |
1942 | +#include <indicatorentrywidget.h> |
1943 | +#include <indicatorsmanager.h> |
1944 | |
1945 | // Qt |
1946 | -#include <QActionEvent> |
1947 | #include <QHBoxLayout> |
1948 | -#include <QLabel> |
1949 | -#include <QMenuBar> |
1950 | -#include <QTimer> |
1951 | - |
1952 | -class MyDBusMenuImporter : public DBusMenuImporter |
1953 | -{ |
1954 | -public: |
1955 | - MyDBusMenuImporter(const QString &service, const QString &path, QObject *parent) |
1956 | - : DBusMenuImporter(service, path, parent) |
1957 | - , m_service(service) |
1958 | - , m_path(path) |
1959 | - {} |
1960 | - |
1961 | - QString service() const { return m_service; } |
1962 | - QString path() const { return m_path; } |
1963 | - |
1964 | -private: |
1965 | - QString m_service; |
1966 | - QString m_path; |
1967 | -}; |
1968 | - |
1969 | -MenuBarWidget::MenuBarWidget(QMenu* windowMenu, QWidget* parent) |
1970 | + |
1971 | +static const int MENU_ITEM_PADDING = 6; |
1972 | + |
1973 | +MenuBarWidget::MenuBarWidget(IndicatorsManager* indicatorsManager, QWidget* parent) |
1974 | : QWidget(parent) |
1975 | -, m_windowMenu(windowMenu) |
1976 | -{ |
1977 | - m_activeWinId = 0; |
1978 | - setupRegistrar(); |
1979 | - setupMenuBar(); |
1980 | - |
1981 | - connect(&BamfMatcher::get_default(), SIGNAL(ActiveWindowChanged(BamfWindow*, BamfWindow*)), |
1982 | - SLOT(slotActiveWindowChanged(BamfWindow*, BamfWindow*))); |
1983 | - /* Work around a bug in BAMF: the ActiveWindowChanged signal is not emitted |
1984 | - for some windows that open maximized. This is for example the case of the |
1985 | - LibreOffice startcenter. */ |
1986 | - connect(&BamfMatcher::get_default(), SIGNAL(ViewOpened(BamfView*)), |
1987 | - SLOT(slotViewOpened())); |
1988 | - updateActiveWinId(BamfMatcher::get_default().active_window()); |
1989 | -} |
1990 | - |
1991 | -void MenuBarWidget::setupRegistrar() |
1992 | -{ |
1993 | - m_registrar = Registrar::instance(); |
1994 | - if (!m_registrar->connectToBus()) { |
1995 | - UQ_WARNING << "could not connect registrar to DBus"; |
1996 | - } |
1997 | - |
1998 | - connect(m_registrar, SIGNAL(WindowRegistered(WId, const QString&, const QDBusObjectPath&)), |
1999 | - SLOT(slotWindowRegistered(WId, const QString&, const QDBusObjectPath&))); |
2000 | - connect(m_registrar, SIGNAL(WindowUnregistered(WId)), |
2001 | - SLOT(slotWindowUnregistered(WId))); |
2002 | -} |
2003 | - |
2004 | -void MenuBarWidget::setupMenuBar() |
2005 | -{ |
2006 | - m_menuBar = new QMenuBar; |
2007 | - new MenuBarClosedHelper(this); |
2008 | - |
2009 | - QHBoxLayout* layout = new QHBoxLayout(this); |
2010 | - layout->setMargin(0); |
2011 | - layout->setSpacing(0); |
2012 | - layout->addWidget(m_menuBar); |
2013 | - m_menuBar->setNativeMenuBar(false); |
2014 | - |
2015 | - m_updateMenuBarTimer = new QTimer(this); |
2016 | - m_updateMenuBarTimer->setSingleShot(true); |
2017 | - m_updateMenuBarTimer->setInterval(0); |
2018 | - connect(m_updateMenuBarTimer, SIGNAL(timeout()), |
2019 | - SLOT(updateMenuBar())); |
2020 | - |
2021 | - // Repaint the menubar when modifiers change so that the shortcut underline |
2022 | - // is drawn or not |
2023 | - connect(KeyboardModifiersMonitor::instance(), SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), |
2024 | - m_menuBar, SLOT(update())); |
2025 | -} |
2026 | - |
2027 | -void MenuBarWidget::slotActiveWindowChanged(BamfWindow* /*former*/, BamfWindow* current) |
2028 | -{ |
2029 | - if (current) { |
2030 | - updateActiveWinId(current); |
2031 | - } |
2032 | -} |
2033 | - |
2034 | -void MenuBarWidget::slotViewOpened() |
2035 | -{ |
2036 | - BamfWindow* active = BamfMatcher::get_default().active_window(); |
2037 | - if (active != NULL) { |
2038 | - if (active->xid() != m_activeWinId) { |
2039 | - /* This shouldn’t be needed as BAMF should have emitted the |
2040 | - ActiveWindowChanged signal, but it sometimes doesn’t (e.g. when |
2041 | - LibreOffice startcenter starts automatically maximized). */ |
2042 | - updateActiveWinId(active); |
2043 | - } |
2044 | - } |
2045 | -} |
2046 | - |
2047 | -void MenuBarWidget::slotWindowRegistered(WId wid, const QString& service, const QDBusObjectPath& menuObjectPath) |
2048 | -{ |
2049 | - MyDBusMenuImporter* importer = new MyDBusMenuImporter(service, menuObjectPath.path(), this); |
2050 | - delete m_importers.take(wid); |
2051 | - m_importers.insert(wid, importer); |
2052 | - connect(importer, SIGNAL(menuUpdated()), SLOT(slotMenuUpdated())); |
2053 | - connect(importer, SIGNAL(actionActivationRequested(QAction*)), SLOT(slotActionActivationRequested(QAction*))); |
2054 | - QMetaObject::invokeMethod(importer, "updateMenu", Qt::QueuedConnection); |
2055 | -} |
2056 | - |
2057 | -void MenuBarWidget::slotWindowUnregistered(WId wid) |
2058 | -{ |
2059 | - MyDBusMenuImporter* importer = m_importers.take(wid); |
2060 | - if (importer) { |
2061 | - importer->deleteLater(); |
2062 | - } |
2063 | - if (wid == m_activeWinId) { |
2064 | - m_activeWinId = 0; |
2065 | - updateMenuBar(); |
2066 | - } |
2067 | -} |
2068 | - |
2069 | -void MenuBarWidget::slotMenuUpdated() |
2070 | -{ |
2071 | - DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender()); |
2072 | - |
2073 | - if (m_importers.value(m_activeWinId) == importer) { |
2074 | - updateMenuBar(); |
2075 | - } |
2076 | -} |
2077 | - |
2078 | -void MenuBarWidget::slotActionActivationRequested(QAction* action) |
2079 | -{ |
2080 | - DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender()); |
2081 | - |
2082 | - if (m_importers.value(m_activeWinId) == importer) { |
2083 | - m_menuBar->setActiveAction(action); |
2084 | - } |
2085 | -} |
2086 | - |
2087 | -QMenu* MenuBarWidget::menuForWinId(WId wid) const |
2088 | -{ |
2089 | - MyDBusMenuImporter* importer = m_importers.value(wid); |
2090 | - return importer ? importer->menu() : 0; |
2091 | -} |
2092 | - |
2093 | -void MenuBarWidget::updateActiveWinId(BamfWindow* bamfWindow) |
2094 | -{ |
2095 | - WId id = bamfWindow ? bamfWindow->xid() : 0; |
2096 | - if (id == m_activeWinId) { |
2097 | - return; |
2098 | - } |
2099 | - if (id == window()->winId()) { |
2100 | - // Do not update id if the active window is the one hosting this applet |
2101 | - return; |
2102 | - } |
2103 | - m_activeWinId = id; |
2104 | - updateMenuBar(); |
2105 | -} |
2106 | - |
2107 | -void MenuBarWidget::updateMenuBar() |
2108 | -{ |
2109 | - WId winId = m_activeWinId; |
2110 | - QMenu* menu = menuForWinId(winId); |
2111 | - |
2112 | - if (!menu) { |
2113 | - if (winId) { |
2114 | - menu = m_windowMenu; |
2115 | - } else { |
2116 | - // No active window, show a desktop menubar |
2117 | - // FIXME: Empty menu |
2118 | - /* |
2119 | - menu = mEmptyMenu; |
2120 | - */ |
2121 | - } |
2122 | - } |
2123 | - |
2124 | - m_menuBar->clear(); |
2125 | - // FIXME: Empty menu |
2126 | - if (!menu) { |
2127 | - return; |
2128 | - } |
2129 | - menu->installEventFilter(this); |
2130 | - Q_FOREACH(QAction* action, menu->actions()) { |
2131 | - if (action->isSeparator()) { |
2132 | - continue; |
2133 | - } |
2134 | - m_menuBar->addAction(action); |
2135 | - } |
2136 | -} |
2137 | - |
2138 | -bool MenuBarWidget::eventFilter(QObject* object, QEvent* event) |
2139 | -{ |
2140 | - switch (event->type()) { |
2141 | - case QEvent::ActionAdded: |
2142 | - case QEvent::ActionRemoved: |
2143 | - case QEvent::ActionChanged: |
2144 | - m_updateMenuBarTimer->start(); |
2145 | - break; |
2146 | - default: |
2147 | - break; |
2148 | - } |
2149 | - return false; |
2150 | +, m_indicatorsManager(indicatorsManager) |
2151 | +, m_layout(new QHBoxLayout(this)) |
2152 | +, m_isEmpty(true) |
2153 | +, m_isOpened(false) |
2154 | +{ |
2155 | + m_layout->setMargin(0); |
2156 | + m_layout->setSpacing(0); |
2157 | + indicatorsManager->indicators()->on_object_added.connect( |
2158 | + sigc::mem_fun(this, &MenuBarWidget::onObjectAdded) |
2159 | + ); |
2160 | + indicatorsManager->indicators()->on_entry_activated.connect( |
2161 | + sigc::mem_fun(this, &MenuBarWidget::onEntryActivated) |
2162 | + ); |
2163 | + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); |
2164 | + m_layout->addStretch(); |
2165 | } |
2166 | |
2167 | bool MenuBarWidget::isEmpty() const |
2168 | { |
2169 | - return m_menuBar->actions().isEmpty(); |
2170 | + return m_isEmpty; |
2171 | } |
2172 | |
2173 | bool MenuBarWidget::isOpened() const |
2174 | { |
2175 | - return m_menuBar->activeAction(); |
2176 | -} |
2177 | - |
2178 | -// MenuBarClosedHelper ---------------------------------------- |
2179 | -MenuBarClosedHelper::MenuBarClosedHelper(MenuBarWidget* widget) |
2180 | -: QObject(widget) |
2181 | -, m_widget(widget) |
2182 | -{ |
2183 | - widget->m_menuBar->installEventFilter(this); |
2184 | -} |
2185 | - |
2186 | -bool MenuBarClosedHelper::eventFilter(QObject* object, QEvent* event) |
2187 | -{ |
2188 | - if (object == m_widget->m_menuBar) { |
2189 | - switch (event->type()) { |
2190 | - case QEvent::ActionAdded: |
2191 | - case QEvent::ActionRemoved: |
2192 | - case QEvent::ActionChanged: |
2193 | - menuBarActionEvent(static_cast<QActionEvent*>(event)); |
2194 | - break; |
2195 | - default: |
2196 | - break; |
2197 | - } |
2198 | - } else { |
2199 | - // Top-level menus |
2200 | - if (event->type() == QEvent::Hide) { |
2201 | - // menu hide themselves when the menubar is closed but also when |
2202 | - // one goes from one menu to another. The way to know this is to |
2203 | - // check the value of QMenuBar::activeAction(), but at this point |
2204 | - // it has not been updated yet, so we check in a delayed method. |
2205 | - QMetaObject::invokeMethod(this, "emitMenuBarClosed", Qt::QueuedConnection); |
2206 | - } |
2207 | - } |
2208 | - return false; |
2209 | -} |
2210 | - |
2211 | -void MenuBarClosedHelper::emitMenuBarClosed() |
2212 | -{ |
2213 | - if (!m_widget->m_menuBar->activeAction()) { |
2214 | - QMetaObject::invokeMethod(m_widget, "menuBarClosed"); |
2215 | - } |
2216 | -} |
2217 | - |
2218 | -void MenuBarClosedHelper::menuBarActionEvent(QActionEvent* event) |
2219 | -{ |
2220 | - QMenu* menu = event->action()->menu(); |
2221 | - if (menu) { |
2222 | - // Install/remove event filters on top level menus so that know when |
2223 | - // they hide themselves and can emit menuBarClosed() |
2224 | - switch (event->type()) { |
2225 | - case QEvent::ActionAdded: |
2226 | - case QEvent::ActionChanged: |
2227 | - menu->installEventFilter(this); |
2228 | - break; |
2229 | - case QEvent::ActionRemoved: |
2230 | - menu->removeEventFilter(this); |
2231 | - break; |
2232 | - default: |
2233 | - break; |
2234 | - } |
2235 | - } |
2236 | - |
2237 | - // Emit isEmptyChanged() if necessary |
2238 | - QList<QAction*> actions = m_widget->m_menuBar->actions(); |
2239 | - if (event->type() == QEvent::ActionAdded && actions.count() == 1) { |
2240 | - QMetaObject::invokeMethod(m_widget, "isEmptyChanged"); |
2241 | - } else if (event->type() == QEvent::ActionRemoved && actions.isEmpty()) { |
2242 | - QMetaObject::invokeMethod(m_widget, "isEmptyChanged"); |
2243 | + return m_isOpened; |
2244 | +} |
2245 | + |
2246 | +void MenuBarWidget::onObjectAdded(const unity::indicator::Indicator::Ptr& indicator) |
2247 | +{ |
2248 | + QString name = QString::fromStdString(indicator->name()); |
2249 | + if (name == "libappmenu.so") { |
2250 | + indicator->on_entry_added.connect(sigc::mem_fun(this, &MenuBarWidget::onEntryAdded)); |
2251 | + } |
2252 | +} |
2253 | + |
2254 | +void MenuBarWidget::onEntryAdded(const unity::indicator::Entry::Ptr& entry) |
2255 | +{ |
2256 | + IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry); |
2257 | + widget->setPadding(MENU_ITEM_PADDING); |
2258 | + connect(widget, SIGNAL(isEmptyChanged()), SLOT(updateIsEmpty())); |
2259 | + |
2260 | + m_widgetList.append(widget); |
2261 | + m_indicatorsManager->addIndicatorEntryWidget(widget); |
2262 | + |
2263 | + // Insert *before* stretch |
2264 | + m_layout->insertWidget(m_layout->count() - 1, widget); |
2265 | +} |
2266 | + |
2267 | +void MenuBarWidget::updateIsEmpty() |
2268 | +{ |
2269 | + bool empty = true; |
2270 | + Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) { |
2271 | + if (!widget->isEmpty()) { |
2272 | + empty = false; |
2273 | + break; |
2274 | + } |
2275 | + } |
2276 | + if (m_isEmpty != empty) { |
2277 | + m_isEmpty = empty; |
2278 | + isEmptyChanged(); |
2279 | + } |
2280 | +} |
2281 | + |
2282 | +void MenuBarWidget::onEntryActivated(const std::string& id) |
2283 | +{ |
2284 | + bool isOpened = false; |
2285 | + if (!id.empty()) { |
2286 | + // We only cares about menubar entries |
2287 | + Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) { |
2288 | + if (widget->entry()->id() == id) { |
2289 | + isOpened = true; |
2290 | + break; |
2291 | + } |
2292 | + } |
2293 | + } |
2294 | + if (m_isOpened != isOpened) { |
2295 | + m_isOpened = isOpened; |
2296 | + isOpenedChanged(); |
2297 | } |
2298 | } |
2299 | |
2300 | |
2301 | === modified file 'panel/applets/appname/menubarwidget.h' |
2302 | --- panel/applets/appname/menubarwidget.h 2011-07-26 09:36:41 +0000 |
2303 | +++ panel/applets/appname/menubarwidget.h 2011-08-04 16:31:58 +0000 |
2304 | @@ -23,86 +23,45 @@ |
2305 | #define MENUBARWIDGET_H |
2306 | |
2307 | // Qt |
2308 | -#include <QHash> |
2309 | #include <QWidget> |
2310 | |
2311 | -class BamfWindow; |
2312 | - |
2313 | -class QActionEvent; |
2314 | -class QDBusObjectPath; |
2315 | -class QMenu; |
2316 | -class QMenuBar; |
2317 | -class QTimer; |
2318 | - |
2319 | -class MyDBusMenuImporter; |
2320 | -class Registrar; |
2321 | - |
2322 | -typedef QHash<WId, MyDBusMenuImporter*> ImporterForWId; |
2323 | - |
2324 | -class MenuBarWidget; |
2325 | - |
2326 | -/** |
2327 | - * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed() |
2328 | - * when necessary |
2329 | - */ |
2330 | -class MenuBarClosedHelper : public QObject |
2331 | -{ |
2332 | -Q_OBJECT |
2333 | -public: |
2334 | - MenuBarClosedHelper(MenuBarWidget*); |
2335 | - |
2336 | -protected: |
2337 | - bool eventFilter(QObject*, QEvent*); //reimp |
2338 | - |
2339 | -private Q_SLOTS: |
2340 | - void emitMenuBarClosed(); |
2341 | - |
2342 | -private: |
2343 | - MenuBarWidget* m_widget; |
2344 | - void menuBarActionEvent(QActionEvent*); |
2345 | -}; |
2346 | - |
2347 | -class MenuBarWidget : public QWidget |
2348 | -{ |
2349 | -Q_OBJECT |
2350 | -public: |
2351 | - MenuBarWidget(QMenu* windowMenu, QWidget* parent = 0); |
2352 | +// libunity-core |
2353 | +#include <UnityCore/Indicator.h> |
2354 | +#include <UnityCore/IndicatorEntry.h> |
2355 | + |
2356 | +class QHBoxLayout; |
2357 | + |
2358 | +class IndicatorEntryWidget; |
2359 | +class IndicatorsManager; |
2360 | + |
2361 | +class MenuBarWidget : public QWidget, public sigc::trackable |
2362 | +{ |
2363 | +Q_OBJECT |
2364 | +public: |
2365 | + MenuBarWidget(IndicatorsManager*, QWidget* parent = 0); |
2366 | |
2367 | bool isEmpty() const; |
2368 | bool isOpened() const; |
2369 | |
2370 | Q_SIGNALS: |
2371 | - void menuBarClosed(); |
2372 | + void isOpenedChanged(); |
2373 | void isEmptyChanged(); |
2374 | |
2375 | -protected: |
2376 | - bool eventFilter(QObject*, QEvent*); // reimp |
2377 | - |
2378 | private Q_SLOTS: |
2379 | - void slotActiveWindowChanged(BamfWindow*, BamfWindow*); |
2380 | - void slotViewOpened(); |
2381 | - void slotWindowRegistered(WId, const QString& service, const QDBusObjectPath& menuObjectPath); |
2382 | - void slotWindowUnregistered(WId); |
2383 | - void slotMenuUpdated(); |
2384 | - void slotActionActivationRequested(QAction* action); |
2385 | - void updateMenuBar(); |
2386 | + void updateIsEmpty(); |
2387 | |
2388 | private: |
2389 | Q_DISABLE_COPY(MenuBarWidget) |
2390 | |
2391 | - QMenuBar* m_menuBar; |
2392 | - Registrar* m_registrar; |
2393 | - ImporterForWId m_importers; |
2394 | - WId m_activeWinId; |
2395 | - QMenu* m_windowMenu; |
2396 | - QTimer* m_updateMenuBarTimer; |
2397 | - |
2398 | - void setupRegistrar(); |
2399 | - void setupMenuBar(); |
2400 | - QMenu* menuForWinId(WId) const; |
2401 | - void updateActiveWinId(BamfWindow*); |
2402 | - |
2403 | - friend class MenuBarClosedHelper; |
2404 | + IndicatorsManager* m_indicatorsManager; |
2405 | + QHBoxLayout* m_layout; |
2406 | + bool m_isEmpty; |
2407 | + bool m_isOpened; |
2408 | + QList<IndicatorEntryWidget*> m_widgetList; |
2409 | + |
2410 | + void onObjectAdded(const unity::indicator::Indicator::Ptr&); |
2411 | + void onEntryAdded(const unity::indicator::Entry::Ptr&); |
2412 | + void onEntryActivated(const std::string&); |
2413 | }; |
2414 | |
2415 | #endif /* MENUBARWIDGET_H */ |
2416 | |
2417 | === removed file 'panel/applets/appname/registrar.cpp' |
2418 | --- panel/applets/appname/registrar.cpp 2011-04-04 16:46:14 +0000 |
2419 | +++ panel/applets/appname/registrar.cpp 1970-01-01 00:00:00 +0000 |
2420 | @@ -1,138 +0,0 @@ |
2421 | -/* |
2422 | - * Plasma applet to display application window menus |
2423 | - * |
2424 | - * Copyright 2010 Canonical Ltd. |
2425 | - * |
2426 | - * Authors: |
2427 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
2428 | - * |
2429 | - * This program is free software; you can redistribute it and/or modify |
2430 | - * it under the terms of the GNU General Public License as published by |
2431 | - * the Free Software Foundation; version 3. |
2432 | - * |
2433 | - * This program is distributed in the hope that it will be useful, |
2434 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2435 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2436 | - * GNU General Public License for more details. |
2437 | - * |
2438 | - * You should have received a copy of the GNU General Public License |
2439 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2440 | - */ |
2441 | - |
2442 | -// Self |
2443 | -#include "registrar.h" |
2444 | - |
2445 | -// Qt |
2446 | -#include <QApplication> |
2447 | -#include <QDBusMessage> |
2448 | -#include <QDBusObjectPath> |
2449 | -#include <QDBusServiceWatcher> |
2450 | - |
2451 | -// Local |
2452 | -#include "registraradaptor.h" |
2453 | - |
2454 | -static const char* DBUS_SERVICE = "com.canonical.AppMenu.Registrar"; |
2455 | -static const char* DBUS_OBJECT_PATH = "/com/canonical/AppMenu/Registrar"; |
2456 | - |
2457 | -// Marshalling code for MenuInfo |
2458 | -QDBusArgument& operator<<(QDBusArgument& argument, const MenuInfo& info) |
2459 | -{ |
2460 | - argument.beginStructure(); |
2461 | - argument << info.winId << info.service << info.path; |
2462 | - argument.endStructure(); |
2463 | - return argument; |
2464 | -} |
2465 | - |
2466 | -const QDBusArgument& operator>>(const QDBusArgument& argument, MenuInfo& info) |
2467 | -{ |
2468 | - argument.beginStructure(); |
2469 | - argument >> info.winId >> info.service >> info.path; |
2470 | - argument.endStructure(); |
2471 | - return argument; |
2472 | -} |
2473 | - |
2474 | -Registrar::Registrar() |
2475 | -: QObject() |
2476 | -, mServiceWatcher(new QDBusServiceWatcher(this)) |
2477 | -{ |
2478 | - qDBusRegisterMetaType<MenuInfo>(); |
2479 | - qDBusRegisterMetaType<MenuInfoList>(); |
2480 | - mServiceWatcher->setConnection(QDBusConnection::sessionBus()); |
2481 | - mServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); |
2482 | - connect(mServiceWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&))); |
2483 | -} |
2484 | - |
2485 | -Registrar::~Registrar() |
2486 | -{ |
2487 | - QDBusConnection::sessionBus().unregisterService(mService); |
2488 | -} |
2489 | - |
2490 | -Registrar* Registrar::instance() |
2491 | -{ |
2492 | - static Registrar singleton; |
2493 | - return &singleton; |
2494 | -} |
2495 | - |
2496 | -bool Registrar::connectToBus(const QString& _service, const QString& _path) |
2497 | -{ |
2498 | - mService = _service.isEmpty() ? DBUS_SERVICE : _service; |
2499 | - QString path = _path.isEmpty() ? DBUS_OBJECT_PATH : _path; |
2500 | - |
2501 | - bool ok = QDBusConnection::sessionBus().registerService(mService); |
2502 | - if (!ok) { |
2503 | - return false; |
2504 | - } |
2505 | - new RegistrarAdaptor(this); |
2506 | - QDBusConnection::sessionBus().registerObject(path, this); |
2507 | - |
2508 | - return true; |
2509 | -} |
2510 | - |
2511 | -void Registrar::RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath) |
2512 | -{ |
2513 | - MenuInfo info; |
2514 | - info.winId = wid; |
2515 | - info.service = message().service(); |
2516 | - info.path = menuObjectPath; |
2517 | - mDb.insert(wid, info); |
2518 | - mServiceWatcher->addWatchedService(info.service); |
2519 | - WindowRegistered(wid, info.service, info.path); |
2520 | -} |
2521 | - |
2522 | -void Registrar::UnregisterWindow(WId wid) |
2523 | -{ |
2524 | - mDb.remove(wid); |
2525 | - WindowUnregistered(wid); |
2526 | -} |
2527 | - |
2528 | -QString Registrar::GetMenuForWindow(WId winId, QDBusObjectPath& menuObjectPath) |
2529 | -{ |
2530 | - MenuInfo info = mDb.value(winId); |
2531 | - QString service = info.service; |
2532 | - menuObjectPath = info.path; |
2533 | - return service; |
2534 | -} |
2535 | - |
2536 | -MenuInfoList Registrar::GetMenus() |
2537 | -{ |
2538 | - return mDb.values(); |
2539 | -} |
2540 | - |
2541 | -void Registrar::slotServiceUnregistered(const QString& service) |
2542 | -{ |
2543 | - MenuInfoDb::Iterator |
2544 | - it = mDb.begin(), |
2545 | - end = mDb.end(); |
2546 | - for (;it != end;) { |
2547 | - if (it.value().service == service) { |
2548 | - WId id = it.key(); |
2549 | - it = mDb.erase(it); |
2550 | - WindowUnregistered(id); |
2551 | - } else { |
2552 | - ++it; |
2553 | - } |
2554 | - } |
2555 | - mServiceWatcher->removeWatchedService(service); |
2556 | -} |
2557 | - |
2558 | -#include "registrar.moc" |
2559 | |
2560 | === removed file 'panel/applets/appname/registrar.h' |
2561 | --- panel/applets/appname/registrar.h 2011-04-04 16:47:28 +0000 |
2562 | +++ panel/applets/appname/registrar.h 1970-01-01 00:00:00 +0000 |
2563 | @@ -1,85 +0,0 @@ |
2564 | -/* |
2565 | - * Plasma applet to display application window menus |
2566 | - * |
2567 | - * Copyright 2010 Canonical Ltd. |
2568 | - * |
2569 | - * Authors: |
2570 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
2571 | - * |
2572 | - * This program is free software; you can redistribute it and/or modify |
2573 | - * it under the terms of the GNU General Public License as published by |
2574 | - * the Free Software Foundation; version 3. |
2575 | - * |
2576 | - * This program is distributed in the hope that it will be useful, |
2577 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2578 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2579 | - * GNU General Public License for more details. |
2580 | - * |
2581 | - * You should have received a copy of the GNU General Public License |
2582 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2583 | - */ |
2584 | - |
2585 | -#ifndef REGISTRAR_H |
2586 | -#define REGISTRAR_H |
2587 | - |
2588 | -// Qt |
2589 | -#include <QDBusContext> |
2590 | -#include <QDBusObjectPath> |
2591 | -#include <QObject> |
2592 | -#include <QWidget> // For WId |
2593 | - |
2594 | -class QDBusObjectPath; |
2595 | -class QDBusServiceWatcher; |
2596 | -class QMenu; |
2597 | - |
2598 | -struct MenuInfo |
2599 | -{ |
2600 | - MenuInfo() |
2601 | - : winId(0) |
2602 | - , path("/") |
2603 | - {} |
2604 | - |
2605 | - uint winId; |
2606 | - QString service; |
2607 | - QDBusObjectPath path; |
2608 | -}; |
2609 | -Q_DECLARE_METATYPE(MenuInfo) |
2610 | - |
2611 | -typedef QList<MenuInfo> MenuInfoList; |
2612 | -Q_DECLARE_METATYPE(MenuInfoList) |
2613 | - |
2614 | -class Registrar : public QObject, protected QDBusContext |
2615 | -{ |
2616 | - Q_OBJECT |
2617 | - |
2618 | -public: |
2619 | - /* The registrar is a singleton shared between all instances of MenuBarWidget. */ |
2620 | - static Registrar* instance(); |
2621 | - |
2622 | - bool connectToBus(const QString& service = QString(), const QString& objectPath = QString()); |
2623 | - |
2624 | -Q_SIGNALS: |
2625 | - void WindowRegistered(WId wid, const QString& service, const QDBusObjectPath&); |
2626 | - void WindowUnregistered(WId wid); |
2627 | - |
2628 | -public Q_SLOTS: |
2629 | - Q_NOREPLY void RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath); |
2630 | - Q_NOREPLY void UnregisterWindow(WId wid); |
2631 | - QString GetMenuForWindow(WId wid, QDBusObjectPath& menuObjectPath); |
2632 | - MenuInfoList GetMenus(); |
2633 | - |
2634 | -private Q_SLOTS: |
2635 | - void slotServiceUnregistered(const QString& service); |
2636 | - |
2637 | -private: |
2638 | - Registrar(); |
2639 | - Q_DISABLE_COPY(Registrar) |
2640 | - ~Registrar(); |
2641 | - |
2642 | - QDBusServiceWatcher* mServiceWatcher; |
2643 | - typedef QHash<WId, MenuInfo> MenuInfoDb; |
2644 | - MenuInfoDb mDb; |
2645 | - QString mService; |
2646 | -}; |
2647 | - |
2648 | -#endif /* REGISTRAR_H */ |
2649 | |
2650 | === added file 'panel/applets/common/cairoutils.cpp' |
2651 | --- panel/applets/common/cairoutils.cpp 1970-01-01 00:00:00 +0000 |
2652 | +++ panel/applets/common/cairoutils.cpp 2011-08-04 16:31:58 +0000 |
2653 | @@ -0,0 +1,42 @@ |
2654 | +/* |
2655 | + * This file is part of unity-2d |
2656 | + * |
2657 | + * Copyright 2011 Canonical Ltd. |
2658 | + * |
2659 | + * Authors: |
2660 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
2661 | + * |
2662 | + * This program is free software; you can redistribute it and/or modify |
2663 | + * it under the terms of the GNU General Public License as published by |
2664 | + * the Free Software Foundation; version 3. |
2665 | + * |
2666 | + * This program is distributed in the hope that it will be useful, |
2667 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2668 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2669 | + * GNU General Public License for more details. |
2670 | + * |
2671 | + * You should have received a copy of the GNU General Public License |
2672 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2673 | + */ |
2674 | +// Self |
2675 | +#include "cairoutils.h" |
2676 | + |
2677 | +// Local |
2678 | + |
2679 | +// Qt |
2680 | +#include <QImage> |
2681 | + |
2682 | +namespace CairoUtils { |
2683 | + |
2684 | +cairo_surface_t* createSurfaceForQImage(QImage* image) |
2685 | +{ |
2686 | + return cairo_image_surface_create_for_data( |
2687 | + image->bits(), |
2688 | + CAIRO_FORMAT_ARGB32, |
2689 | + image->width(), |
2690 | + image->height(), |
2691 | + image->bytesPerLine() |
2692 | + ); |
2693 | +} |
2694 | + |
2695 | +} // namespace |
2696 | |
2697 | === added file 'panel/applets/common/cairoutils.h' |
2698 | --- panel/applets/common/cairoutils.h 1970-01-01 00:00:00 +0000 |
2699 | +++ panel/applets/common/cairoutils.h 2011-08-04 16:31:58 +0000 |
2700 | @@ -0,0 +1,47 @@ |
2701 | +/* |
2702 | + * This file is part of unity-2d |
2703 | + * |
2704 | + * Copyright 2011 Canonical Ltd. |
2705 | + * |
2706 | + * Authors: |
2707 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
2708 | + * |
2709 | + * This program is free software; you can redistribute it and/or modify |
2710 | + * it under the terms of the GNU General Public License as published by |
2711 | + * the Free Software Foundation; version 3. |
2712 | + * |
2713 | + * This program is distributed in the hope that it will be useful, |
2714 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2715 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2716 | + * GNU General Public License for more details. |
2717 | + * |
2718 | + * You should have received a copy of the GNU General Public License |
2719 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2720 | + */ |
2721 | +#ifndef CAIROUTILS_H |
2722 | +#define CAIROUTILS_H |
2723 | + |
2724 | +// Local |
2725 | +#include <gscopedpointer.h> |
2726 | + |
2727 | +// Qt |
2728 | + |
2729 | +// Cairo |
2730 | +#include <cairo.h> |
2731 | + |
2732 | +class QImage; |
2733 | + |
2734 | +namespace CairoUtils { |
2735 | + |
2736 | +typedef GScopedPointer<cairo_surface_t, cairo_surface_destroy> SurfacePointer; |
2737 | +typedef GScopedPointer<cairo_t, cairo_destroy> Pointer; |
2738 | + |
2739 | +/** |
2740 | + * Creates a Cairo surface for a QImage. |
2741 | + * QImage format must be Format_ARGB32_Premultiplied. |
2742 | + */ |
2743 | +cairo_surface_t* createSurfaceForQImage(QImage*); |
2744 | + |
2745 | +} // namespace |
2746 | + |
2747 | +#endif /* CAIROUTILS_H */ |
2748 | |
2749 | === added file 'panel/applets/common/indicatorentrywidget.cpp' |
2750 | --- panel/applets/common/indicatorentrywidget.cpp 1970-01-01 00:00:00 +0000 |
2751 | +++ panel/applets/common/indicatorentrywidget.cpp 2011-08-04 16:31:58 +0000 |
2752 | @@ -0,0 +1,366 @@ |
2753 | +/* |
2754 | + * This file is part of unity-2d |
2755 | + * |
2756 | + * Copyright 2011 Canonical Ltd. |
2757 | + * |
2758 | + * Authors: |
2759 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
2760 | + * |
2761 | + * This program is free software; you can redistribute it and/or modify |
2762 | + * it under the terms of the GNU General Public License as published by |
2763 | + * the Free Software Foundation; version 3. |
2764 | + * |
2765 | + * This program is distributed in the hope that it will be useful, |
2766 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2767 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2768 | + * GNU General Public License for more details. |
2769 | + * |
2770 | + * You should have received a copy of the GNU General Public License |
2771 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2772 | + */ |
2773 | +// Self |
2774 | +#include "indicatorentrywidget.h" |
2775 | + |
2776 | +// Local |
2777 | +#include <cairoutils.h> |
2778 | +#include <debug_p.h> |
2779 | +#include <gscopedpointer.h> |
2780 | +#include <panelstyle.h> |
2781 | + |
2782 | +// Qt |
2783 | +#include <QIcon> |
2784 | +#include <QPainter> |
2785 | +#include <QWheelEvent> |
2786 | + |
2787 | +// GTK |
2788 | +#include <gtk/gtk.h> |
2789 | + |
2790 | +// libc |
2791 | +#include <time.h> |
2792 | + |
2793 | +static const int SPACING = 3; |
2794 | +static const int PADDING = 3; |
2795 | + |
2796 | +using namespace unity::indicator; |
2797 | + |
2798 | +IndicatorEntryWidget::IndicatorEntryWidget(const Entry::Ptr& entry) |
2799 | +: m_entry(entry) |
2800 | +, m_padding(PADDING) |
2801 | +, m_hasIcon(false) |
2802 | +, m_hasLabel(false) |
2803 | +, m_gtkWidgetPath(gtk_widget_path_new()) |
2804 | +{ |
2805 | + gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_WINDOW); |
2806 | + gtk_widget_path_iter_set_name(m_gtkWidgetPath, -1 , "UnityPanelWidget"); |
2807 | + gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_MENU_BAR); |
2808 | + gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_MENU_ITEM); |
2809 | + |
2810 | + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
2811 | + m_entry->updated.connect(sigc::mem_fun(this, &IndicatorEntryWidget::updatePix)); |
2812 | +} |
2813 | + |
2814 | +IndicatorEntryWidget::~IndicatorEntryWidget() |
2815 | +{ |
2816 | + gtk_widget_path_free(m_gtkWidgetPath); |
2817 | +} |
2818 | + |
2819 | +QSize IndicatorEntryWidget::minimumSizeHint() const |
2820 | +{ |
2821 | + return sizeHint(); |
2822 | +} |
2823 | + |
2824 | +QSize IndicatorEntryWidget::sizeHint() const |
2825 | +{ |
2826 | + return m_pix.size(); |
2827 | +} |
2828 | + |
2829 | +void IndicatorEntryWidget::resizeEvent(QResizeEvent* event) |
2830 | +{ |
2831 | + QWidget::resizeEvent(event); |
2832 | + updatePix(); |
2833 | +} |
2834 | + |
2835 | +void IndicatorEntryWidget::paintEvent(QPaintEvent*) |
2836 | +{ |
2837 | + if (!m_pix.isNull()) { |
2838 | + QPainter painter(this); |
2839 | + painter.drawPixmap(0, 0, m_pix); |
2840 | + } |
2841 | +} |
2842 | + |
2843 | + |
2844 | +void IndicatorEntryWidget::paintActiveBackground(QImage* image) |
2845 | +{ |
2846 | + // This code should be kept in sync with corresponding unityshell code from |
2847 | + // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp |
2848 | + |
2849 | + // Get a surface and a context |
2850 | + CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(image)); |
2851 | + CairoUtils::Pointer cr(cairo_create(surface.data())); |
2852 | + |
2853 | + // Init style |
2854 | + GtkStyleContext* styleContext = PanelStyle::instance()->styleContext(); |
2855 | + |
2856 | + gtk_style_context_save(styleContext); |
2857 | + |
2858 | + gtk_style_context_set_path(styleContext, m_gtkWidgetPath); |
2859 | + gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUBAR); |
2860 | + gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUITEM); |
2861 | + gtk_style_context_set_state(styleContext, GTK_STATE_FLAG_PRELIGHT); |
2862 | + |
2863 | + // Draw |
2864 | + // FIXME(Cimi) probably some padding is needed here. |
2865 | + gtk_render_background(styleContext, cr.data(), 0, 0, width(), height()); |
2866 | + gtk_render_frame(styleContext, cr.data(), 0, 0, width(), height()); |
2867 | + |
2868 | + // Clean up |
2869 | + gtk_style_context_restore(styleContext); |
2870 | +} |
2871 | + |
2872 | +void IndicatorEntryWidget::updatePix() |
2873 | +{ |
2874 | + bool oldIsEmpty = isEmpty(); |
2875 | + |
2876 | + int width = m_padding; |
2877 | + int iconX = m_padding; |
2878 | + int labelX = 0; |
2879 | + |
2880 | + GObjectScopedPointer<PangoLayout> pangoLayout; |
2881 | + |
2882 | + // Compute width, labelX and update m_has{Icon,Label} |
2883 | + QPixmap iconPix; |
2884 | + if (m_entry->image_visible()) { |
2885 | + iconPix = decodeIcon(); |
2886 | + m_hasIcon = !iconPix.isNull(); |
2887 | + } else { |
2888 | + m_hasIcon = false; |
2889 | + } |
2890 | + if (m_hasIcon) { |
2891 | + width += iconPix.width(); |
2892 | + } |
2893 | + |
2894 | + m_hasLabel = !m_entry->label().empty() && m_entry->label_visible(); |
2895 | + if (m_hasLabel) { |
2896 | + if (m_hasIcon) { |
2897 | + width += SPACING; |
2898 | + } |
2899 | + labelX = width; |
2900 | + pangoLayout.reset(createPangoLayout()); |
2901 | + int labelWidth; |
2902 | + int labelHeight; |
2903 | + pango_layout_get_pixel_size(pangoLayout.data(), &labelWidth, &labelHeight); |
2904 | + |
2905 | + width += labelWidth; |
2906 | + } |
2907 | + |
2908 | + width += m_padding; |
2909 | + |
2910 | + // Paint |
2911 | + QPixmap oldPix = m_pix; |
2912 | + if (!m_hasIcon && !m_hasLabel) { |
2913 | + m_pix = QPixmap(); |
2914 | + } else { |
2915 | + QImage img(width, height(), QImage::Format_ARGB32_Premultiplied); |
2916 | + QPainter painter(&img); |
2917 | + painter.initFrom(this); |
2918 | + painter.eraseRect(img.rect()); |
2919 | + if (m_entry->active()) { |
2920 | + paintActiveBackground(&img); |
2921 | + } |
2922 | + if (m_hasIcon) { |
2923 | + bool disabled = !m_entry->image_sensitive(); |
2924 | + if (disabled) { |
2925 | + painter.setOpacity(0.5); |
2926 | + } |
2927 | + painter.drawPixmap(iconX, (height() - iconPix.height()) / 2, iconPix); |
2928 | + if (disabled) { |
2929 | + painter.setOpacity(1); |
2930 | + } |
2931 | + } |
2932 | + if (m_hasLabel) { |
2933 | + paintLabel(&img, pangoLayout.data(), labelX); |
2934 | + } |
2935 | + m_pix = QPixmap::fromImage(img); |
2936 | + } |
2937 | + |
2938 | + // Notify others we changed, but only trigger a layout update if necessary |
2939 | + if (m_pix.size() == oldPix.size()) { |
2940 | + update(); |
2941 | + } else { |
2942 | + updateGeometry(); |
2943 | + } |
2944 | + bool newIsEmpty = isEmpty(); |
2945 | + if (newIsEmpty != oldIsEmpty) { |
2946 | + // If we emit isEmptyChanged() directly it won't reach any connected |
2947 | + // slot. I assume this is because this method is called as a response |
2948 | + // to a sigc++ signal. |
2949 | + QMetaObject::invokeMethod(this, "isEmptyChanged", Qt::QueuedConnection); |
2950 | + } |
2951 | +} |
2952 | + |
2953 | +PangoLayout* IndicatorEntryWidget::createPangoLayout() |
2954 | +{ |
2955 | + // Parse |
2956 | + PangoAttrList* attrs = NULL; |
2957 | + if (m_entry->show_now()) { |
2958 | + if (!pango_parse_markup(m_entry->label().c_str(), |
2959 | + -1, |
2960 | + '_', |
2961 | + &attrs, |
2962 | + NULL, |
2963 | + NULL, |
2964 | + NULL)) |
2965 | + { |
2966 | + UQ_WARNING << "pango_parse_markup failed"; |
2967 | + } |
2968 | + } |
2969 | + |
2970 | + // Create layout |
2971 | + GObjectScopedPointer<PangoContext> pangoContext(gdk_pango_context_get()); |
2972 | + PangoLayout* layout = pango_layout_new(pangoContext.data()); |
2973 | + |
2974 | + if (attrs) { |
2975 | + pango_layout_set_attributes(layout, attrs); |
2976 | + pango_attr_list_unref(attrs); |
2977 | + } |
2978 | + |
2979 | + // Set font |
2980 | + char* font_description = NULL; |
2981 | + GtkSettings *settings = gtk_settings_get_default(); |
2982 | + g_object_get(settings, |
2983 | + "gtk-font-name", &font_description, |
2984 | + NULL); |
2985 | + PangoFontDescription* desc = pango_font_description_from_string(font_description); |
2986 | + pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL); |
2987 | + pango_layout_set_font_description(layout, desc); |
2988 | + pango_font_description_free(desc); |
2989 | + g_free(font_description); |
2990 | + |
2991 | + // Set text |
2992 | + QString label = QString::fromUtf8(m_entry->label().c_str()); |
2993 | + label.replace('_', QString()); |
2994 | + QByteArray utf8Label = label.toUtf8(); |
2995 | + pango_layout_set_text(layout, utf8Label.data(), -1); |
2996 | + |
2997 | + return layout; |
2998 | +} |
2999 | + |
3000 | +void IndicatorEntryWidget::paintLabel(QImage* image, PangoLayout* layout, int labelX) |
3001 | +{ |
3002 | + // This code should be kept in sync with corresponding unityshell code from |
3003 | + // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp |
3004 | + int labelWidth, labelHeight; |
3005 | + pango_layout_get_pixel_size(layout, &labelWidth, &labelHeight); |
3006 | + CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(image)); |
3007 | + CairoUtils::Pointer cr(cairo_create(surface.data())); |
3008 | + pango_cairo_update_layout(cr.data(), layout); |
3009 | + |
3010 | + PanelStyle* style = PanelStyle::instance(); |
3011 | + GtkStyleContext* styleContext = style->styleContext(); |
3012 | + |
3013 | + gtk_style_context_save(styleContext); |
3014 | + |
3015 | + gtk_style_context_set_path(styleContext, m_gtkWidgetPath); |
3016 | + gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUBAR); |
3017 | + gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUITEM); |
3018 | + |
3019 | + if (m_entry->active()) { |
3020 | + gtk_style_context_set_state(styleContext, GTK_STATE_FLAG_PRELIGHT); |
3021 | + } |
3022 | + |
3023 | + gtk_render_layout(styleContext, cr.data(), labelX, (image->height() - labelHeight) / 2, layout); |
3024 | + gtk_style_context_restore(styleContext); |
3025 | +} |
3026 | + |
3027 | +QPixmap IndicatorEntryWidget::decodeIcon() |
3028 | +{ |
3029 | + QPixmap pix; |
3030 | + |
3031 | + int type = m_entry->image_type(); |
3032 | + |
3033 | + if (type == 0) { |
3034 | + // No icon |
3035 | + } else if (type == GTK_IMAGE_PIXBUF) { |
3036 | + QByteArray data = QByteArray::fromBase64(m_entry->image_data().c_str()); |
3037 | + QImage image; |
3038 | + bool ok = image.loadFromData(data); |
3039 | + if (ok) { |
3040 | + pix = QPixmap::fromImage(image); |
3041 | + } else { |
3042 | + UQ_WARNING << "Failed to decode image"; |
3043 | + } |
3044 | + } else if (type == GTK_IMAGE_ICON_NAME) { |
3045 | + QString name = QString::fromStdString(m_entry->image_data()); |
3046 | + QIcon icon = QIcon::fromTheme(name); |
3047 | + pix = icon.pixmap(24, 24); |
3048 | + } else if (type == GTK_IMAGE_GICON) { |
3049 | + UQ_WARNING << "FIXME: Implement support for GTK_IMAGE_GICON image type"; |
3050 | + } else { |
3051 | + UQ_WARNING << "Unknown image type" << m_entry->image_type(); |
3052 | + } |
3053 | + return pix; |
3054 | +} |
3055 | + |
3056 | +void IndicatorEntryWidget::mousePressEvent(QMouseEvent*) |
3057 | +{ |
3058 | + UQ_RETURN_IF_FAIL(m_hasIcon || m_hasLabel); |
3059 | + showMenu(Qt::LeftButton); |
3060 | +} |
3061 | + |
3062 | +void IndicatorEntryWidget::mouseReleaseEvent(QMouseEvent*) |
3063 | +{ |
3064 | + UQ_VAR(this); |
3065 | + update(); |
3066 | +} |
3067 | + |
3068 | +void IndicatorEntryWidget::wheelEvent(QWheelEvent* event) |
3069 | +{ |
3070 | + m_entry->Scroll(event->delta()); |
3071 | +} |
3072 | + |
3073 | +void IndicatorEntryWidget::showMenu(Qt::MouseButton qtButton) |
3074 | +{ |
3075 | + if (m_entry->active()) { |
3076 | + return; |
3077 | + } |
3078 | + int nuxButton = qtButton == Qt::NoButton ? 0 : 1; |
3079 | + QPoint pos = mapToGlobal(rect().bottomLeft()); |
3080 | + m_entry->ShowMenu(pos.x(), pos.y(), |
3081 | + time(NULL), |
3082 | + nuxButton |
3083 | + ); |
3084 | +} |
3085 | + |
3086 | +void IndicatorEntryWidget::setPadding(int padding) |
3087 | +{ |
3088 | + if (m_padding != padding) { |
3089 | + m_padding = padding; |
3090 | + updatePix(); |
3091 | + } |
3092 | +} |
3093 | + |
3094 | +bool IndicatorEntryWidget::event(QEvent* ev) |
3095 | +{ |
3096 | + bool ret = QWidget::event(ev); |
3097 | + switch (ev->type()) { |
3098 | + case QEvent::FontChange: |
3099 | + case QEvent::PaletteChange: |
3100 | + updatePix(); |
3101 | + break; |
3102 | + default: |
3103 | + break; |
3104 | + } |
3105 | + return ret; |
3106 | +} |
3107 | + |
3108 | +bool IndicatorEntryWidget::isEmpty() const |
3109 | +{ |
3110 | + return !m_hasIcon && !m_hasLabel; |
3111 | +} |
3112 | + |
3113 | +unity::indicator::Entry::Ptr IndicatorEntryWidget::entry() const |
3114 | +{ |
3115 | + return m_entry; |
3116 | +} |
3117 | + |
3118 | +#include "indicatorentrywidget.moc" |
3119 | |
3120 | === added file 'panel/applets/common/indicatorentrywidget.h' |
3121 | --- panel/applets/common/indicatorentrywidget.h 1970-01-01 00:00:00 +0000 |
3122 | +++ panel/applets/common/indicatorentrywidget.h 2011-08-04 16:31:58 +0000 |
3123 | @@ -0,0 +1,90 @@ |
3124 | +/* |
3125 | + * This file is part of unity-2d |
3126 | + * |
3127 | + * Copyright 2011 Canonical Ltd. |
3128 | + * |
3129 | + * Authors: |
3130 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3131 | + * |
3132 | + * This program is free software; you can redistribute it and/or modify |
3133 | + * it under the terms of the GNU General Public License as published by |
3134 | + * the Free Software Foundation; version 3. |
3135 | + * |
3136 | + * This program is distributed in the hope that it will be useful, |
3137 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3138 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3139 | + * GNU General Public License for more details. |
3140 | + * |
3141 | + * You should have received a copy of the GNU General Public License |
3142 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3143 | + */ |
3144 | +#ifndef INDICATORENTRYWIDGET_H |
3145 | +#define INDICATORENTRYWIDGET_H |
3146 | + |
3147 | +// Local |
3148 | + |
3149 | +// libunity-core |
3150 | +#include <UnityCore/IndicatorEntry.h> |
3151 | + |
3152 | +// Qt |
3153 | +#include <QWidget> |
3154 | + |
3155 | +struct _GtkWidgetPath; |
3156 | +struct _PangoLayout; |
3157 | + |
3158 | +class QPainter; |
3159 | + |
3160 | +class IndicatorEntryWidget : public QWidget, public sigc::trackable |
3161 | +{ |
3162 | +Q_OBJECT |
3163 | +public: |
3164 | + IndicatorEntryWidget(const unity::indicator::Entry::Ptr& entry); |
3165 | + ~IndicatorEntryWidget(); |
3166 | + |
3167 | + QSize minimumSizeHint() const; |
3168 | + QSize sizeHint() const; |
3169 | + |
3170 | + void setPadding(int); |
3171 | + |
3172 | + bool isEmpty() const; |
3173 | + |
3174 | + unity::indicator::Entry::Ptr entry() const; |
3175 | + |
3176 | + /** |
3177 | + * Shows the menu. |
3178 | + * |
3179 | + * When this method is called because of a click, button |
3180 | + * must be set to Qt::LeftButton. |
3181 | + * |
3182 | + * When it is called because user previously clicked an indicator and moved the |
3183 | + * mouse to another indicator, button must be set to Qt::NoButton. |
3184 | + */ |
3185 | + void showMenu(Qt::MouseButton button); |
3186 | + |
3187 | +Q_SIGNALS: |
3188 | + void isEmptyChanged(); |
3189 | + |
3190 | +protected: |
3191 | + void resizeEvent(QResizeEvent*); |
3192 | + void paintEvent(QPaintEvent*); |
3193 | + void mousePressEvent(QMouseEvent*); |
3194 | + void mouseReleaseEvent(QMouseEvent*); |
3195 | + void wheelEvent(QWheelEvent*); |
3196 | + bool event(QEvent*); |
3197 | + |
3198 | +private: |
3199 | + unity::indicator::Entry::Ptr m_entry; |
3200 | + QPixmap m_pix; |
3201 | + int m_padding; |
3202 | + bool m_hasIcon; |
3203 | + bool m_hasLabel; |
3204 | + struct _GtkWidgetPath* m_gtkWidgetPath; |
3205 | + void updatePix(); |
3206 | + QPixmap decodeIcon(); |
3207 | + void paintActiveBackground(QImage*); |
3208 | + |
3209 | + struct _PangoLayout* createPangoLayout(); |
3210 | + void paintLabel(QImage*, struct _PangoLayout*, int labelX); |
3211 | +}; |
3212 | + |
3213 | +#endif /* INDICATORENTRYWIDGET_H */ |
3214 | |
3215 | === added file 'panel/applets/common/indicatorsmanager.cpp' |
3216 | --- panel/applets/common/indicatorsmanager.cpp 1970-01-01 00:00:00 +0000 |
3217 | +++ panel/applets/common/indicatorsmanager.cpp 2011-08-04 16:31:58 +0000 |
3218 | @@ -0,0 +1,206 @@ |
3219 | +/* |
3220 | + * This file is part of unity-2d |
3221 | + * |
3222 | + * Copyright 2011 Canonical Ltd. |
3223 | + * |
3224 | + * Authors: |
3225 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3226 | + * |
3227 | + * This program is free software; you can redistribute it and/or modify |
3228 | + * it under the terms of the GNU General Public License as published by |
3229 | + * the Free Software Foundation; version 3. |
3230 | + * |
3231 | + * This program is distributed in the hope that it will be useful, |
3232 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3233 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3234 | + * GNU General Public License for more details. |
3235 | + * |
3236 | + * You should have received a copy of the GNU General Public License |
3237 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3238 | + */ |
3239 | +// Self |
3240 | +#include "indicatorsmanager.h" |
3241 | + |
3242 | +// Local |
3243 | +#include <debug_p.h> |
3244 | +#include <indicatorentrywidget.h> |
3245 | + |
3246 | +// Qt |
3247 | +#include <QApplication> |
3248 | +#include <QTimer> |
3249 | +#include <QX11Info> |
3250 | + |
3251 | +// X11 |
3252 | +#include <X11/Xlib.h> |
3253 | + |
3254 | +using namespace unity::indicator; |
3255 | + |
3256 | +IndicatorsManager::IndicatorsManager(QObject* parent) |
3257 | +: QObject(parent) |
3258 | +, m_indicators(new DBusIndicators) |
3259 | +, m_geometrySyncTimer(new QTimer(this)) |
3260 | +, m_mouseTrackerTimer(new QTimer(this)) |
3261 | +{ |
3262 | + m_geometrySyncTimer->setInterval(0); |
3263 | + m_geometrySyncTimer->setSingleShot(true); |
3264 | + connect(m_geometrySyncTimer, SIGNAL(timeout()), SLOT(syncGeometries())); |
3265 | + |
3266 | + // m_mouseTrackerTimer is inspired from |
3267 | + // plugins/unityshell/src/PanelView.cpp in OnEntryActivated() |
3268 | + // |
3269 | + // Rationale copied from Unity source code: |
3270 | + // """ |
3271 | + // Track menus being scrubbed at 60Hz (about every 16 millisec) |
3272 | + // It might sound ugly, but it's far nicer (and more responsive) than the |
3273 | + // code it replaces which used to capture motion events in another process |
3274 | + // (unity-panel-service) and send them to us over dbus. |
3275 | + // NOTE: The reason why we have to use a timer instead of tracking motion |
3276 | + // events is because the motion events will never be delivered to this |
3277 | + // process. All the motion events will go to unity-panel-service while |
3278 | + // scrubbing because the active panel menu has (needs) the pointer grab. |
3279 | + // """ |
3280 | + m_mouseTrackerTimer->setInterval(16); |
3281 | + m_mouseTrackerTimer->setSingleShot(false); |
3282 | + connect(m_mouseTrackerTimer, SIGNAL(timeout()), SLOT(checkMousePosition())); |
3283 | + |
3284 | + m_indicators->on_entry_show_menu.connect( |
3285 | + sigc::mem_fun(this, &IndicatorsManager::onEntryShowMenu) |
3286 | + ); |
3287 | + |
3288 | + m_indicators->on_entry_activate_request.connect( |
3289 | + sigc::mem_fun(this, &IndicatorsManager::onEntryActivateRequest) |
3290 | + ); |
3291 | + |
3292 | + m_indicators->on_entry_activated.connect( |
3293 | + sigc::mem_fun(this, &IndicatorsManager::onEntryActivated) |
3294 | + ); |
3295 | + |
3296 | + m_indicators->on_synced.connect( |
3297 | + sigc::mem_fun(this, &IndicatorsManager::onSynced) |
3298 | + ); |
3299 | +} |
3300 | + |
3301 | +unity::indicator::DBusIndicators::Ptr IndicatorsManager::indicators() const |
3302 | +{ |
3303 | + return m_indicators; |
3304 | +} |
3305 | + |
3306 | +void IndicatorsManager::onEntryShowMenu(const std::string& /*entryId*/, int posX, int posY, int /*timestamp*/, int /*button*/) |
3307 | +{ |
3308 | + // Copied from plugins/unityshell/src/PanelView.cpp, in OnEntryShowMenu() |
3309 | + // Without this code, menus cannot be shown from mousePressEvent() (but can |
3310 | + // be shown from mouseReleaseEvent()) |
3311 | + /* |
3312 | + Neil explanation: |
3313 | + On button down, X automatically gives Qt a passive grab on the mouse this |
3314 | + means that, if the panel service tries to grab the pointer to show the menu |
3315 | + (gtk does this automatically), it fails and the menu can't show. |
3316 | + We connect to the on_entry_show_menu signal, which is emitted before |
3317 | + DBusIndicators does anything else, and just break the grab. |
3318 | + */ |
3319 | + Display* display = QX11Info::display(); |
3320 | + XUngrabPointer(display, CurrentTime); |
3321 | + XFlush(display); |
3322 | + |
3323 | + XButtonEvent event = { |
3324 | + ButtonRelease, |
3325 | + 0, |
3326 | + False, |
3327 | + display, |
3328 | + 0, |
3329 | + 0, |
3330 | + 0, |
3331 | + CurrentTime, |
3332 | + posX, posY, |
3333 | + posX, posY, |
3334 | + 0, |
3335 | + Button1, |
3336 | + True |
3337 | + }; |
3338 | + qApp->x11ProcessEvent(reinterpret_cast<XEvent*>(&event)); |
3339 | +} |
3340 | + |
3341 | +void IndicatorsManager::checkMousePosition() |
3342 | +{ |
3343 | + // Called by m_mouseTrackerTimer to implement mouse scrubbing |
3344 | + // (Assuming item A menu is opened, move mouse over item B => item B menu opens) |
3345 | + QWidget* widget = QApplication::widgetAt(QCursor::pos()); |
3346 | + IndicatorEntryWidget* entryWidget = qobject_cast<IndicatorEntryWidget*>(widget); |
3347 | + if (!entryWidget) { |
3348 | + return; |
3349 | + } |
3350 | + entryWidget->showMenu(Qt::NoButton); |
3351 | +} |
3352 | + |
3353 | +void IndicatorsManager::onEntryActivateRequest(const std::string& entryId) |
3354 | +{ |
3355 | + if (entryId.empty()) { |
3356 | + return; |
3357 | + } |
3358 | + IndicatorEntryWidget* widget = 0; |
3359 | + Q_FOREACH(widget, m_widgetList) { |
3360 | + if (widget->entry()->id() == entryId) { |
3361 | + break; |
3362 | + } |
3363 | + } |
3364 | + if (!widget) { |
3365 | + UQ_WARNING << "Could not find a widget for IndicatorEntry with id" << QString::fromStdString(entryId); |
3366 | + return; |
3367 | + } |
3368 | + widget->showMenu(Qt::NoButton); |
3369 | +} |
3370 | + |
3371 | +void IndicatorsManager::onEntryActivated(const std::string& entryId) |
3372 | +{ |
3373 | + if (entryId.empty()) { |
3374 | + m_mouseTrackerTimer->stop(); |
3375 | + } else { |
3376 | + m_mouseTrackerTimer->start(); |
3377 | + } |
3378 | +} |
3379 | + |
3380 | +void IndicatorsManager::onSynced() |
3381 | +{ |
3382 | + QMetaObject::invokeMethod(m_geometrySyncTimer, "start", Qt::QueuedConnection); |
3383 | +} |
3384 | + |
3385 | +void IndicatorsManager::addIndicatorEntryWidget(IndicatorEntryWidget* widget) |
3386 | +{ |
3387 | + m_widgetList.append(widget); |
3388 | + widget->installEventFilter(this); |
3389 | +} |
3390 | + |
3391 | +bool IndicatorsManager::eventFilter(QObject*, QEvent* event) |
3392 | +{ |
3393 | + switch (event->type()) { |
3394 | + case QEvent::Show: |
3395 | + case QEvent::Hide: |
3396 | + case QEvent::Move: |
3397 | + case QEvent::Resize: |
3398 | + m_geometrySyncTimer->start(); |
3399 | + break; |
3400 | + default: |
3401 | + break; |
3402 | + } |
3403 | + return false; |
3404 | +} |
3405 | + |
3406 | +void IndicatorsManager::syncGeometries() |
3407 | +{ |
3408 | + EntryLocationMap locations; |
3409 | + Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) { |
3410 | + if (!widget->isVisible()) { |
3411 | + continue; |
3412 | + } |
3413 | + Entry::Ptr entry = widget->entry(); |
3414 | + if (entry->IsUnused()) { |
3415 | + continue; |
3416 | + } |
3417 | + QPoint topLeft = widget->mapToGlobal(QPoint(0, 0)); |
3418 | + nux::Rect rect(topLeft.x(), topLeft.y(), widget->width(), widget->height()); |
3419 | + locations[widget->entry()->id()] = rect; |
3420 | + } |
3421 | + m_indicators->SyncGeometries("Panel", locations); |
3422 | +} |
3423 | + |
3424 | +#include "indicatorsmanager.moc" |
3425 | |
3426 | === added file 'panel/applets/common/indicatorsmanager.h' |
3427 | --- panel/applets/common/indicatorsmanager.h 1970-01-01 00:00:00 +0000 |
3428 | +++ panel/applets/common/indicatorsmanager.h 2011-08-04 16:31:58 +0000 |
3429 | @@ -0,0 +1,72 @@ |
3430 | +/* |
3431 | + * This file is part of unity-2d |
3432 | + * |
3433 | + * Copyright 2011 Canonical Ltd. |
3434 | + * |
3435 | + * Authors: |
3436 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3437 | + * |
3438 | + * This program is free software; you can redistribute it and/or modify |
3439 | + * it under the terms of the GNU General Public License as published by |
3440 | + * the Free Software Foundation; version 3. |
3441 | + * |
3442 | + * This program is distributed in the hope that it will be useful, |
3443 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3444 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3445 | + * GNU General Public License for more details. |
3446 | + * |
3447 | + * You should have received a copy of the GNU General Public License |
3448 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3449 | + */ |
3450 | +#ifndef INDICATORSMANAGER_H |
3451 | +#define INDICATORSMANAGER_H |
3452 | + |
3453 | +// Local |
3454 | + |
3455 | +// Qt |
3456 | +#include <QMap> |
3457 | +#include <QObject> |
3458 | + |
3459 | +// libunity-core |
3460 | +#include <UnityCore/DBusIndicators.h> |
3461 | + |
3462 | +class QTimer; |
3463 | + |
3464 | +class IndicatorEntryWidget; |
3465 | + |
3466 | +/** |
3467 | + * Instantiates DBusIndicators and implement common behavior |
3468 | + */ |
3469 | +class IndicatorsManager : public QObject, public sigc::trackable |
3470 | +{ |
3471 | + Q_OBJECT |
3472 | +public: |
3473 | + IndicatorsManager(QObject* parent); |
3474 | + |
3475 | + unity::indicator::DBusIndicators::Ptr indicators() const; |
3476 | + |
3477 | + void addIndicatorEntryWidget(IndicatorEntryWidget* widget); |
3478 | + |
3479 | +protected: |
3480 | + bool eventFilter(QObject*, QEvent*); |
3481 | + |
3482 | +private Q_SLOTS: |
3483 | + void syncGeometries(); |
3484 | + void checkMousePosition(); |
3485 | + |
3486 | +private: |
3487 | + Q_DISABLE_COPY(IndicatorsManager) |
3488 | + unity::indicator::DBusIndicators::Ptr m_indicators; |
3489 | + QTimer* m_geometrySyncTimer; |
3490 | + QTimer* m_mouseTrackerTimer; |
3491 | + |
3492 | + typedef QList<IndicatorEntryWidget*> IndicatorEntryWidgetList; |
3493 | + IndicatorEntryWidgetList m_widgetList; |
3494 | + |
3495 | + void onSynced(); |
3496 | + void onEntryShowMenu(const std::string&, int x, int y, int timestamp, int button); |
3497 | + void onEntryActivateRequest(const std::string& entryId); |
3498 | + void onEntryActivated(const std::string& entryId); |
3499 | +}; |
3500 | + |
3501 | +#endif /* INDICATORSMANAGER_H */ |
3502 | |
3503 | === added file 'panel/applets/common/indicatorwidget.cpp' |
3504 | --- panel/applets/common/indicatorwidget.cpp 1970-01-01 00:00:00 +0000 |
3505 | +++ panel/applets/common/indicatorwidget.cpp 2011-08-04 16:31:58 +0000 |
3506 | @@ -0,0 +1,53 @@ |
3507 | +/* |
3508 | + * This file is part of unity-2d |
3509 | + * |
3510 | + * Copyright 2011 Canonical Ltd. |
3511 | + * |
3512 | + * Authors: |
3513 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3514 | + * |
3515 | + * This program is free software; you can redistribute it and/or modify |
3516 | + * it under the terms of the GNU General Public License as published by |
3517 | + * the Free Software Foundation; version 3. |
3518 | + * |
3519 | + * This program is distributed in the hope that it will be useful, |
3520 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3521 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3522 | + * GNU General Public License for more details. |
3523 | + * |
3524 | + * You should have received a copy of the GNU General Public License |
3525 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3526 | + */ |
3527 | +// Self |
3528 | +#include "indicatorwidget.h" |
3529 | + |
3530 | +// Local |
3531 | +#include <debug_p.h> |
3532 | +#include <indicatorentrywidget.h> |
3533 | +#include <indicatorsmanager.h> |
3534 | + |
3535 | +// Qt |
3536 | +#include <QHBoxLayout> |
3537 | + |
3538 | +using namespace unity::indicator; |
3539 | + |
3540 | +IndicatorWidget::IndicatorWidget(const Indicator::Ptr& indicator, IndicatorsManager* manager) |
3541 | +: m_layout(new QHBoxLayout(this)) |
3542 | +, m_indicatorsManager(manager) |
3543 | +, m_indicator(indicator) |
3544 | +{ |
3545 | + m_layout->setMargin(0); |
3546 | + m_layout->setSpacing(0); |
3547 | + |
3548 | + m_indicator->on_entry_added.connect(sigc::mem_fun(this, &IndicatorWidget::onEntryAdded)); |
3549 | +} |
3550 | + |
3551 | +void IndicatorWidget::onEntryAdded(const Entry::Ptr& entry) |
3552 | +{ |
3553 | + IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry); |
3554 | + m_indicatorsManager->addIndicatorEntryWidget(widget); |
3555 | + m_layout->addWidget(widget); |
3556 | +} |
3557 | + |
3558 | + |
3559 | +#include "indicatorwidget.moc" |
3560 | |
3561 | === added file 'panel/applets/common/indicatorwidget.h' |
3562 | --- panel/applets/common/indicatorwidget.h 1970-01-01 00:00:00 +0000 |
3563 | +++ panel/applets/common/indicatorwidget.h 2011-08-04 16:31:58 +0000 |
3564 | @@ -0,0 +1,52 @@ |
3565 | +/* |
3566 | + * This file is part of unity-2d |
3567 | + * |
3568 | + * Copyright 2011 Canonical Ltd. |
3569 | + * |
3570 | + * Authors: |
3571 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3572 | + * |
3573 | + * This program is free software; you can redistribute it and/or modify |
3574 | + * it under the terms of the GNU General Public License as published by |
3575 | + * the Free Software Foundation; version 3. |
3576 | + * |
3577 | + * This program is distributed in the hope that it will be useful, |
3578 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3579 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3580 | + * GNU General Public License for more details. |
3581 | + * |
3582 | + * You should have received a copy of the GNU General Public License |
3583 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3584 | + */ |
3585 | +#ifndef INDICATORWIDGET_H |
3586 | +#define INDICATORWIDGET_H |
3587 | + |
3588 | +// Local |
3589 | + |
3590 | +// libunity-core |
3591 | +#include <UnityCore/Indicator.h> |
3592 | +#include <UnityCore/IndicatorEntry.h> |
3593 | + |
3594 | +// Qt |
3595 | +#include <QWidget> |
3596 | + |
3597 | +class QHBoxLayout; |
3598 | + |
3599 | +class IndicatorEntryWidget; |
3600 | +class IndicatorsManager; |
3601 | + |
3602 | +class IndicatorWidget : public QWidget, public sigc::trackable |
3603 | +{ |
3604 | +Q_OBJECT |
3605 | +public: |
3606 | + IndicatorWidget(const unity::indicator::Indicator::Ptr& indicator, IndicatorsManager* manager); |
3607 | + |
3608 | +private: |
3609 | + QHBoxLayout* m_layout; |
3610 | + IndicatorsManager* m_indicatorsManager; |
3611 | + unity::indicator::Indicator::Ptr m_indicator; |
3612 | + |
3613 | + void onEntryAdded(const unity::indicator::Entry::Ptr& entry); |
3614 | +}; |
3615 | + |
3616 | +#endif /* INDICATORWIDGET_H */ |
3617 | |
3618 | === added file 'panel/applets/common/panelstyle.cpp' |
3619 | --- panel/applets/common/panelstyle.cpp 1970-01-01 00:00:00 +0000 |
3620 | +++ panel/applets/common/panelstyle.cpp 2011-08-04 16:31:58 +0000 |
3621 | @@ -0,0 +1,114 @@ |
3622 | +/* |
3623 | + * This file is part of unity-2d |
3624 | + * |
3625 | + * Copyright 2011 Canonical Ltd. |
3626 | + * |
3627 | + * Authors: |
3628 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3629 | + * |
3630 | + * This program is free software; you can redistribute it and/or modify |
3631 | + * it under the terms of the GNU General Public License as published by |
3632 | + * the Free Software Foundation; version 3. |
3633 | + * |
3634 | + * This program is distributed in the hope that it will be useful, |
3635 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3636 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3637 | + * GNU General Public License for more details. |
3638 | + * |
3639 | + * You should have received a copy of the GNU General Public License |
3640 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3641 | + */ |
3642 | +// Self |
3643 | +#include "panelstyle.h" |
3644 | + |
3645 | +// libunity-2d |
3646 | +#include <cairoutils.h> |
3647 | +#include <debug_p.h> |
3648 | +#include <gconnector.h> |
3649 | +#include <gscopedpointer.h> |
3650 | + |
3651 | +// Qt |
3652 | +#include <QApplication> |
3653 | +#include <QPalette> |
3654 | + |
3655 | +// GTK |
3656 | +#include <gtk/gtk.h> |
3657 | + |
3658 | +class PanelStylePrivate |
3659 | +{ |
3660 | +public: |
3661 | + PanelStyle* q; |
3662 | + GObjectScopedPointer<GtkStyleContext> m_styleContext; |
3663 | + GConnector m_gConnector; |
3664 | + |
3665 | + static void onThemeChanged(GObject*, GParamSpec*, gpointer data) |
3666 | + { |
3667 | + PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data); |
3668 | + priv->updatePalette(); |
3669 | + } |
3670 | + |
3671 | + void updatePalette() |
3672 | + { |
3673 | + GtkStyleContext* context = m_styleContext.data(); |
3674 | + gtk_style_context_invalidate(context); |
3675 | + |
3676 | + // Without this line, it seems the GtkStyleContext is not correctly |
3677 | + // initialized and we get some uninitialized pixels in the background |
3678 | + // brush. |
3679 | + gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, NULL); |
3680 | + |
3681 | + QPalette pal; |
3682 | + pal.setBrush(QPalette::Window, generateBackgroundBrush()); |
3683 | + QApplication::setPalette(pal); |
3684 | + } |
3685 | + |
3686 | + QBrush generateBackgroundBrush() |
3687 | + { |
3688 | + QImage image(100, 24, QImage::Format_ARGB32_Premultiplied); // FIXME: Hardcoded |
3689 | + image.fill(Qt::transparent); |
3690 | + CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(&image)); |
3691 | + CairoUtils::Pointer cr(cairo_create(surface.data())); |
3692 | + gtk_render_background(m_styleContext.data(), cr.data(), 0, 0, image.width(), image.height()); |
3693 | + return QBrush(image); |
3694 | + } |
3695 | +}; |
3696 | + |
3697 | +PanelStyle::PanelStyle(QObject* parent) |
3698 | +: d(new PanelStylePrivate) |
3699 | +{ |
3700 | + d->q = this; |
3701 | + d->m_styleContext.reset(gtk_style_context_new()); |
3702 | + |
3703 | + GtkWidgetPath* widgetPath = gtk_widget_path_new (); |
3704 | + gtk_widget_path_append_type(widgetPath, GTK_TYPE_WINDOW); |
3705 | + gtk_widget_path_iter_set_name(widgetPath, -1 , "UnityPanelWidget"); |
3706 | + |
3707 | + gtk_style_context_set_path(d->m_styleContext.data(), widgetPath); |
3708 | + gtk_style_context_add_class(d->m_styleContext.data(), "gnome-panel-menu-bar"); |
3709 | + gtk_style_context_add_class(d->m_styleContext.data(), "unity-panel"); |
3710 | + |
3711 | + gtk_widget_path_free (widgetPath); |
3712 | + |
3713 | + d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name", |
3714 | + G_CALLBACK(PanelStylePrivate::onThemeChanged), d); |
3715 | + |
3716 | + d->updatePalette(); |
3717 | +} |
3718 | + |
3719 | +PanelStyle::~PanelStyle() |
3720 | +{ |
3721 | + delete d; |
3722 | +} |
3723 | + |
3724 | +PanelStyle* PanelStyle::instance() |
3725 | +{ |
3726 | + static PanelStyle style; |
3727 | + return &style; |
3728 | +} |
3729 | + |
3730 | +GtkStyleContext* PanelStyle::styleContext() const |
3731 | +{ |
3732 | + return d->m_styleContext.data(); |
3733 | +} |
3734 | + |
3735 | +#include "panelstyle.moc" |
3736 | |
3737 | === added file 'panel/applets/common/panelstyle.h' |
3738 | --- panel/applets/common/panelstyle.h 1970-01-01 00:00:00 +0000 |
3739 | +++ panel/applets/common/panelstyle.h 2011-08-04 16:31:58 +0000 |
3740 | @@ -0,0 +1,56 @@ |
3741 | +/* |
3742 | + * This file is part of unity-2d |
3743 | + * |
3744 | + * Copyright 2011 Canonical Ltd. |
3745 | + * |
3746 | + * Authors: |
3747 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3748 | + * |
3749 | + * This program is free software; you can redistribute it and/or modify |
3750 | + * it under the terms of the GNU General Public License as published by |
3751 | + * the Free Software Foundation; version 3. |
3752 | + * |
3753 | + * This program is distributed in the hope that it will be useful, |
3754 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3755 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3756 | + * GNU General Public License for more details. |
3757 | + * |
3758 | + * You should have received a copy of the GNU General Public License |
3759 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3760 | + */ |
3761 | +#ifndef PANELSTYLE_H |
3762 | +#define PANELSTYLE_H |
3763 | + |
3764 | +// Local |
3765 | + |
3766 | +// Qt |
3767 | +#include <QObject> |
3768 | + |
3769 | +struct _GtkStyleContext; |
3770 | + |
3771 | +class PanelStylePrivate; |
3772 | +/** |
3773 | + * Provides easy access to panel style context and track platform theme to |
3774 | + * ensure we have the correct background brush. |
3775 | + * |
3776 | + * FIXME: This class does not have a very clear focus and has side-effects |
3777 | + * (background brush handling). It should be refactored. |
3778 | + */ |
3779 | +class PanelStyle : public QObject |
3780 | +{ |
3781 | + Q_OBJECT |
3782 | +public: |
3783 | + PanelStyle(QObject* parent = 0); |
3784 | + ~PanelStyle(); |
3785 | + |
3786 | + static PanelStyle* instance(); |
3787 | + |
3788 | + struct _GtkStyleContext* styleContext() const; |
3789 | + |
3790 | +private: |
3791 | + friend class PanelStylePrivate; |
3792 | + // Use a pimpl to avoid the need for gtk includes here |
3793 | + PanelStylePrivate* const d; |
3794 | +}; |
3795 | + |
3796 | +#endif /* PANELSTYLE_H */ |
3797 | |
3798 | === modified file 'panel/applets/homebutton/homebutton.cpp' |
3799 | --- panel/applets/homebutton/homebutton.cpp 2011-05-26 16:41:04 +0000 |
3800 | +++ panel/applets/homebutton/homebutton.cpp 2011-08-04 16:31:58 +0000 |
3801 | @@ -40,8 +40,10 @@ |
3802 | setStyleSheet( |
3803 | "QToolButton { border: none; margin: 0; padding: 0; width: 61 }" |
3804 | "QToolButton:checked, QToolButton:pressed {" |
3805 | - // Use border-image here, not background-image, because bfb_bg_active.png is 56px wide |
3806 | - " border-image: url(theme:/bfb_bg_active.png);" |
3807 | + " padding-top: 1px;" |
3808 | + " padding-left: 1px;" |
3809 | + " padding-right: -1px;" |
3810 | + " padding-bottom: -1px;" |
3811 | "}" |
3812 | ); |
3813 | } |
3814 | |
3815 | === added directory 'panel/applets/indicator' |
3816 | === removed directory 'panel/applets/indicator' |
3817 | === removed file 'panel/applets/indicator-config.h.in' |
3818 | --- panel/applets/indicator-config.h.in 2011-03-01 09:04:13 +0000 |
3819 | +++ panel/applets/indicator-config.h.in 1970-01-01 00:00:00 +0000 |
3820 | @@ -1,7 +0,0 @@ |
3821 | -#ifndef INDICATOR_CONFIG_H |
3822 | -#define INDICATOR_CONFIG_H |
3823 | - |
3824 | -#define INDICATOR_ICONS_DIR "${INDICATOR_ICONS_DIR}" |
3825 | -#define INDICATOR_DIR "${INDICATOR_DIR}" |
3826 | - |
3827 | -#endif /* INDICATOR_CONFIG_H */ |
3828 | |
3829 | === removed file 'panel/applets/indicator/abstractindicator.cpp' |
3830 | --- panel/applets/indicator/abstractindicator.cpp 2011-01-15 01:41:03 +0000 |
3831 | +++ panel/applets/indicator/abstractindicator.cpp 1970-01-01 00:00:00 +0000 |
3832 | @@ -1,43 +0,0 @@ |
3833 | -/* |
3834 | - * This file is part of unity-2d |
3835 | - * |
3836 | - * Copyright 2010 Canonical Ltd. |
3837 | - * |
3838 | - * Authors: |
3839 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3840 | - * |
3841 | - * This program is free software; you can redistribute it and/or modify |
3842 | - * it under the terms of the GNU General Public License as published by |
3843 | - * the Free Software Foundation; version 3. |
3844 | - * |
3845 | - * This program is distributed in the hope that it will be useful, |
3846 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3847 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3848 | - * GNU General Public License for more details. |
3849 | - * |
3850 | - * You should have received a copy of the GNU General Public License |
3851 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3852 | - */ |
3853 | - |
3854 | -// Self |
3855 | -#include "abstractindicator.h" |
3856 | - |
3857 | -// Local |
3858 | - |
3859 | -// Qt |
3860 | -#include <QAction> |
3861 | - |
3862 | -AbstractIndicator::AbstractIndicator(QObject* parent) |
3863 | -: QObject(parent) |
3864 | -{ |
3865 | -} |
3866 | - |
3867 | -AbstractIndicator::~AbstractIndicator() |
3868 | -{ |
3869 | -} |
3870 | - |
3871 | -void AbstractIndicator::init() |
3872 | -{ |
3873 | -} |
3874 | - |
3875 | -#include "abstractindicator.moc" |
3876 | |
3877 | === removed file 'panel/applets/indicator/abstractindicator.h' |
3878 | --- panel/applets/indicator/abstractindicator.h 2011-01-15 01:41:03 +0000 |
3879 | +++ panel/applets/indicator/abstractindicator.h 1970-01-01 00:00:00 +0000 |
3880 | @@ -1,53 +0,0 @@ |
3881 | -/* |
3882 | - * This file is part of unity-2d |
3883 | - * |
3884 | - * Copyright 2010 Canonical Ltd. |
3885 | - * |
3886 | - * Authors: |
3887 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3888 | - * |
3889 | - * This program is free software; you can redistribute it and/or modify |
3890 | - * it under the terms of the GNU General Public License as published by |
3891 | - * the Free Software Foundation; version 3. |
3892 | - * |
3893 | - * This program is distributed in the hope that it will be useful, |
3894 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3895 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3896 | - * GNU General Public License for more details. |
3897 | - * |
3898 | - * You should have received a copy of the GNU General Public License |
3899 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3900 | - */ |
3901 | - |
3902 | -#ifndef ABSTRACTINDICATOR_H |
3903 | -#define ABSTRACTINDICATOR_H |
3904 | - |
3905 | -// Local |
3906 | - |
3907 | -// Qt |
3908 | -#include <QObject> |
3909 | - |
3910 | -class QAction; |
3911 | - |
3912 | -class AbstractIndicator : public QObject |
3913 | -{ |
3914 | - Q_OBJECT |
3915 | -public: |
3916 | - AbstractIndicator(QObject* parent=0); |
3917 | - ~AbstractIndicator(); |
3918 | - |
3919 | - /** |
3920 | - * Called when the indicator has been constructed and its owner is connected to signals. |
3921 | - * It's the right place to emit actionAdded() |
3922 | - */ |
3923 | - virtual void init(); |
3924 | - |
3925 | -Q_SIGNALS: |
3926 | - void actionAdded(QAction*); |
3927 | - void actionRemoved(QAction*); |
3928 | - |
3929 | -private: |
3930 | - Q_DISABLE_COPY(AbstractIndicator) |
3931 | -}; |
3932 | - |
3933 | -#endif /* ABSTRACTINDICATOR_H */ |
3934 | |
3935 | === removed file 'panel/applets/indicator/datetimeindicator.cpp' |
3936 | --- panel/applets/indicator/datetimeindicator.cpp 2011-02-10 01:10:19 +0000 |
3937 | +++ panel/applets/indicator/datetimeindicator.cpp 1970-01-01 00:00:00 +0000 |
3938 | @@ -1,94 +0,0 @@ |
3939 | -/* |
3940 | - * This file is part of unity-2d |
3941 | - * |
3942 | - * Copyright 2010 Canonical Ltd. |
3943 | - * |
3944 | - * Authors: |
3945 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
3946 | - * |
3947 | - * This program is free software; you can redistribute it and/or modify |
3948 | - * it under the terms of the GNU General Public License as published by |
3949 | - * the Free Software Foundation; version 3. |
3950 | - * |
3951 | - * This program is distributed in the hope that it will be useful, |
3952 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3953 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3954 | - * GNU General Public License for more details. |
3955 | - * |
3956 | - * You should have received a copy of the GNU General Public License |
3957 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3958 | - */ |
3959 | - |
3960 | -// Self |
3961 | -#include "datetimeindicator.h" |
3962 | - |
3963 | -// Local |
3964 | -#include "indicatorservicemanager.h" |
3965 | - |
3966 | -// dbusmenu-qt |
3967 | -#include "dbusmenuimporter.h" |
3968 | - |
3969 | -// Qt |
3970 | -#include <QAction> |
3971 | -#include <QDateTime> |
3972 | - |
3973 | -// From dbus-shared.h |
3974 | -#define SERVICE_NAME "com.canonical.indicator.datetime" |
3975 | -#define SERVICE_IFACE "com.canonical.indicator.datetime.service" |
3976 | -#define SERVICE_OBJ "/com.canonical/indicator/datetime/service" |
3977 | -#define SERVICE_VERSION 1 |
3978 | - |
3979 | -#define MENU_OBJ "/com.canonical/indicator/datetime/menu" |
3980 | - |
3981 | -#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item" |
3982 | -//// |
3983 | - |
3984 | -DateTimeIndicator::DateTimeIndicator(QObject* parent) |
3985 | -: AbstractIndicator(parent) |
3986 | -, m_action(new QAction(this)) |
3987 | -, m_timer(new QTimer(this)) |
3988 | -{ |
3989 | - new IndicatorServiceManager(SERVICE_NAME, SERVICE_VERSION, this); |
3990 | - |
3991 | - readConfig(); |
3992 | - setupMenu(); |
3993 | - setupTimer(); |
3994 | - updateText(); |
3995 | -} |
3996 | - |
3997 | -void DateTimeIndicator::init() |
3998 | -{ |
3999 | - actionAdded(m_action); |
4000 | -} |
4001 | - |
4002 | -void DateTimeIndicator::setupMenu() |
4003 | -{ |
4004 | - DBusMenuImporter* importer = new DBusMenuImporter(SERVICE_NAME, MENU_OBJ, this); |
4005 | - m_action->setMenu(importer->menu()); |
4006 | -} |
4007 | - |
4008 | -void DateTimeIndicator::setupTimer() |
4009 | -{ |
4010 | - m_timer->setSingleShot(false); |
4011 | - connect(m_timer, SIGNAL(timeout()), SLOT(updateText())); |
4012 | - updateTimer(); |
4013 | - m_timer->start(); |
4014 | -} |
4015 | - |
4016 | -void DateTimeIndicator::updateTimer() |
4017 | -{ |
4018 | - m_timer->setInterval(1000); |
4019 | -} |
4020 | - |
4021 | -void DateTimeIndicator::updateText() |
4022 | -{ |
4023 | - QString text = QDateTime::currentDateTime().toString(m_format); |
4024 | - m_action->setText(text); |
4025 | -} |
4026 | - |
4027 | -void DateTimeIndicator::readConfig() |
4028 | -{ |
4029 | - m_format = "hh:mm:ss"; |
4030 | -} |
4031 | - |
4032 | -#include "datetimeindicator.moc" |
4033 | |
4034 | === removed file 'panel/applets/indicator/datetimeindicator.h' |
4035 | --- panel/applets/indicator/datetimeindicator.h 2011-01-15 01:41:03 +0000 |
4036 | +++ panel/applets/indicator/datetimeindicator.h 1970-01-01 00:00:00 +0000 |
4037 | @@ -1,53 +0,0 @@ |
4038 | -/* |
4039 | - * This file is part of unity-2d |
4040 | - * |
4041 | - * Copyright 2010 Canonical Ltd. |
4042 | - * |
4043 | - * Authors: |
4044 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4045 | - * |
4046 | - * This program is free software; you can redistribute it and/or modify |
4047 | - * it under the terms of the GNU General Public License as published by |
4048 | - * the Free Software Foundation; version 3. |
4049 | - * |
4050 | - * This program is distributed in the hope that it will be useful, |
4051 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4052 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4053 | - * GNU General Public License for more details. |
4054 | - * |
4055 | - * You should have received a copy of the GNU General Public License |
4056 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4057 | - */ |
4058 | - |
4059 | -#ifndef DATETIMEINDICATOR_H |
4060 | -#define DATETIMEINDICATOR_H |
4061 | - |
4062 | -// Local |
4063 | -#include "abstractindicator.h" |
4064 | - |
4065 | -// Qt |
4066 | -#include <QTimer> |
4067 | - |
4068 | -class DateTimeIndicator : public AbstractIndicator |
4069 | -{ |
4070 | - Q_OBJECT |
4071 | -public: |
4072 | - DateTimeIndicator(QObject* parent=0); |
4073 | - |
4074 | - virtual void init(); |
4075 | - |
4076 | -private Q_SLOTS: |
4077 | - void updateText(); |
4078 | -private: |
4079 | - Q_DISABLE_COPY(DateTimeIndicator) |
4080 | - QAction* m_action; |
4081 | - QTimer* m_timer; |
4082 | - QString m_format; |
4083 | - |
4084 | - void setupTimer(); |
4085 | - void setupMenu(); |
4086 | - void readConfig(); |
4087 | - void updateTimer(); |
4088 | -}; |
4089 | - |
4090 | -#endif /* DATETIMEINDICATOR_H */ |
4091 | |
4092 | === removed file 'panel/applets/indicator/indicator.c' |
4093 | --- panel/applets/indicator/indicator.c 2011-07-01 03:58:28 +0000 |
4094 | +++ panel/applets/indicator/indicator.c 1970-01-01 00:00:00 +0000 |
4095 | @@ -1,525 +0,0 @@ |
4096 | -/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org> |
4097 | - * |
4098 | - * This program is free software; you can redistribute it and/or modify |
4099 | - * it under the terms of the GNU General Public License as published by |
4100 | - * the Free Software Foundation; either version 2 of the License, or |
4101 | - * (at your option) any later version. |
4102 | - * |
4103 | - * This program is distributed in the hope that it will be useful, |
4104 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4105 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4106 | - * GNU Library General Public License for more details. |
4107 | - * |
4108 | - * You should have received a copy of the GNU General Public License |
4109 | - * along with this program; if not, write to the Free Software |
4110 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
4111 | - */ |
4112 | - |
4113 | -#include <string.h> |
4114 | - |
4115 | -#include <gtk/gtk.h> |
4116 | -#include <libindicator/indicator-object.h> |
4117 | - |
4118 | -#include "indicator.h" |
4119 | - |
4120 | -#include "indicator-config.h" |
4121 | - |
4122 | -/* default settings */ |
4123 | -#define DEFAULT_SETTING1 NULL |
4124 | -#define DEFAULT_SETTING2 1 |
4125 | -#define DEFAULT_SETTING3 FALSE |
4126 | - |
4127 | -typedef enum { |
4128 | - PANEL_APPLET_ORIENT_LEFT, |
4129 | - PANEL_APPLET_ORIENT_RIGHT, |
4130 | - PANEL_APPLET_ORIENT_TOP, |
4131 | - PANEL_APPLET_ORIENT_BOTTOM |
4132 | -} PanelAppletOrient; |
4133 | - |
4134 | -// <indicator-applet-copy> |
4135 | -static gchar * indicator_order[] = { |
4136 | - "libappmenu.so", |
4137 | - "libapplication.so", |
4138 | - "libsoundmenu.so", |
4139 | - "libnetworkmenu.so", |
4140 | - "libmessaging.so", |
4141 | - "libdatetime.so", |
4142 | - "libme.so", |
4143 | - "libsession.so", |
4144 | - NULL |
4145 | -}; |
4146 | - |
4147 | -static GtkPackDirection packdirection; |
4148 | -static PanelAppletOrient orient; |
4149 | - |
4150 | -#define MENU_DATA_INDICATOR_OBJECT "indicator-object" |
4151 | -#define MENU_DATA_INDICATOR_ENTRY "indicator-entry" |
4152 | - |
4153 | -#define IO_DATA_ORDER_NUMBER "indicator-order-number" |
4154 | - |
4155 | -static gint |
4156 | -name2order (const gchar * name) { |
4157 | - int i; |
4158 | - |
4159 | - for (i = 0; indicator_order[i] != NULL; i++) { |
4160 | - if (g_strcmp0(name, indicator_order[i]) == 0) { |
4161 | - return i; |
4162 | - } |
4163 | - } |
4164 | - |
4165 | - return -1; |
4166 | -} |
4167 | - |
4168 | -typedef struct _incoming_position_t incoming_position_t; |
4169 | -struct _incoming_position_t { |
4170 | - gint objposition; |
4171 | - gint entryposition; |
4172 | - gint menupos; |
4173 | - gboolean found; |
4174 | -}; |
4175 | - |
4176 | -/* This function helps by determining where in the menu list |
4177 | - this new entry should be placed. It compares the objects |
4178 | - that they're on, and then the individual entries. Each |
4179 | - is progressively more expensive. */ |
4180 | -static void |
4181 | -place_in_menu (GtkWidget * widget, gpointer user_data) |
4182 | -{ |
4183 | - incoming_position_t * position = (incoming_position_t *)user_data; |
4184 | - if (position->found) { |
4185 | - /* We've already been placed, just finish the foreach */ |
4186 | - return; |
4187 | - } |
4188 | - |
4189 | - IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT)); |
4190 | - g_assert(io != NULL); |
4191 | - |
4192 | - gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); |
4193 | - /* We've already passed it, well, then this is where |
4194 | - we should be be. Stop! */ |
4195 | - if (objposition > position->objposition) { |
4196 | - position->found = TRUE; |
4197 | - return; |
4198 | - } |
4199 | - |
4200 | - /* The objects don't match yet, keep looking */ |
4201 | - if (objposition < position->objposition) { |
4202 | - position->menupos++; |
4203 | - return; |
4204 | - } |
4205 | - |
4206 | - /* The objects are the same, let's start looking at entries. */ |
4207 | - IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
4208 | - gint entryposition = indicator_object_get_location(io, entry); |
4209 | - |
4210 | - if (entryposition > position->entryposition) { |
4211 | - position->found = TRUE; |
4212 | - return; |
4213 | - } |
4214 | - |
4215 | - if (entryposition < position->entryposition) { |
4216 | - position->menupos++; |
4217 | - return; |
4218 | - } |
4219 | - |
4220 | - /* We've got the same object and the same entry. Well, |
4221 | - let's just put it right here then. */ |
4222 | - position->found = TRUE; |
4223 | - return; |
4224 | -} |
4225 | - |
4226 | -static void |
4227 | -something_shown (GtkWidget * widget, gpointer user_data) |
4228 | -{ |
4229 | - GtkWidget * menuitem = GTK_WIDGET(user_data); |
4230 | - gtk_widget_show(menuitem); |
4231 | -} |
4232 | - |
4233 | -static void |
4234 | -something_hidden (GtkWidget * widget, gpointer user_data) |
4235 | -{ |
4236 | - GtkWidget * menuitem = GTK_WIDGET(user_data); |
4237 | - gtk_widget_hide(menuitem); |
4238 | -} |
4239 | - |
4240 | -static void |
4241 | -sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data) |
4242 | -{ |
4243 | - g_return_if_fail(GTK_IS_WIDGET(obj)); |
4244 | - g_return_if_fail(GTK_IS_WIDGET(user_data)); |
4245 | - |
4246 | - gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj))); |
4247 | - return; |
4248 | -} |
4249 | - |
4250 | -static gboolean |
4251 | -entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data) |
4252 | -{ |
4253 | - IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT); |
4254 | - IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY); |
4255 | - |
4256 | - g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); |
4257 | - |
4258 | - g_signal_emit_by_name (io, "scroll", 1, event->direction); |
4259 | - g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction); |
4260 | - |
4261 | - return FALSE; |
4262 | -} |
4263 | - |
4264 | -static void |
4265 | -entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) |
4266 | -{ |
4267 | - g_debug("Signal: Entry Added"); |
4268 | - gboolean something_visible = FALSE; |
4269 | - gboolean something_sensitive = FALSE; |
4270 | - |
4271 | - GtkWidget * menuitem = gtk_menu_item_new(); |
4272 | - GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ? |
4273 | - gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3); |
4274 | - |
4275 | - g_object_set_data (G_OBJECT (menuitem), "indicator", io); |
4276 | - g_object_set_data (G_OBJECT (menuitem), "box", box); |
4277 | - |
4278 | - if (entry->image != NULL) { |
4279 | - gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 0); |
4280 | - if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) { |
4281 | - something_visible = TRUE; |
4282 | - } |
4283 | - |
4284 | - if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) { |
4285 | - something_sensitive = TRUE; |
4286 | - } |
4287 | - |
4288 | - g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem); |
4289 | - g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem); |
4290 | - |
4291 | - g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); |
4292 | - } |
4293 | - if (entry->label != NULL) { |
4294 | - switch(packdirection) { |
4295 | - case GTK_PACK_DIRECTION_LTR: |
4296 | - gtk_label_set_angle(GTK_LABEL(entry->label), 0.0); |
4297 | - break; |
4298 | - case GTK_PACK_DIRECTION_TTB: |
4299 | - gtk_label_set_angle(GTK_LABEL(entry->label), |
4300 | - (orient == PANEL_APPLET_ORIENT_LEFT) ? |
4301 | - 270.0 : 90.0); |
4302 | - break; |
4303 | - default: |
4304 | - break; |
4305 | - } |
4306 | - gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 0); |
4307 | - |
4308 | - if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) { |
4309 | - something_visible = TRUE; |
4310 | - } |
4311 | - |
4312 | - if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) { |
4313 | - something_sensitive = TRUE; |
4314 | - } |
4315 | - |
4316 | - g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem); |
4317 | - g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem); |
4318 | - |
4319 | - g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem); |
4320 | - } |
4321 | - gtk_container_add(GTK_CONTAINER(menuitem), box); |
4322 | - gtk_widget_show(box); |
4323 | - |
4324 | - if (entry->menu != NULL) { |
4325 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu)); |
4326 | - } |
4327 | - |
4328 | - incoming_position_t position; |
4329 | - position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); |
4330 | - position.entryposition = indicator_object_get_location(io, entry); |
4331 | - position.menupos = 0; |
4332 | - position.found = FALSE; |
4333 | - |
4334 | - gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position); |
4335 | - |
4336 | - gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos); |
4337 | - |
4338 | - if (something_visible) { |
4339 | - gtk_widget_show(menuitem); |
4340 | - } |
4341 | - gtk_widget_set_sensitive(menuitem, something_sensitive); |
4342 | - |
4343 | - g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry); |
4344 | - g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io); |
4345 | - g_signal_connect(G_OBJECT (menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL); |
4346 | - |
4347 | - return; |
4348 | -} |
4349 | - |
4350 | -static void |
4351 | -entry_removed_cb (GtkWidget * widget, gpointer userdata) |
4352 | -{ |
4353 | - gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
4354 | - |
4355 | - if (data != userdata) { |
4356 | - return; |
4357 | - } |
4358 | - |
4359 | - IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data; |
4360 | - if (entry->label != NULL) { |
4361 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget); |
4362 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget); |
4363 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget); |
4364 | - } |
4365 | - if (entry->image != NULL) { |
4366 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget); |
4367 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget); |
4368 | - g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget); |
4369 | - } |
4370 | - |
4371 | - gtk_widget_destroy(widget); |
4372 | - return; |
4373 | -} |
4374 | - |
4375 | -static void |
4376 | -entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry, |
4377 | - gpointer user_data) |
4378 | -{ |
4379 | - g_debug("Signal: Entry Removed"); |
4380 | - |
4381 | - gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry); |
4382 | - |
4383 | - return; |
4384 | -} |
4385 | - |
4386 | -static void |
4387 | -entry_moved_find_cb (GtkWidget * widget, gpointer userdata) |
4388 | -{ |
4389 | - gpointer * array = (gpointer *)userdata; |
4390 | - if (array[1] != NULL) { |
4391 | - return; |
4392 | - } |
4393 | - |
4394 | - gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY); |
4395 | - |
4396 | - if (data != array[0]) { |
4397 | - return; |
4398 | - } |
4399 | - |
4400 | - array[1] = widget; |
4401 | - return; |
4402 | -} |
4403 | - |
4404 | -/* Gets called when an entry for an object was moved. */ |
4405 | -static void |
4406 | -entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry, |
4407 | - gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data) |
4408 | -{ |
4409 | - GtkWidget * menubar = GTK_WIDGET(user_data); |
4410 | - |
4411 | - gpointer array[2]; |
4412 | - array[0] = entry; |
4413 | - array[1] = NULL; |
4414 | - |
4415 | - gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array); |
4416 | - if (array[1] == NULL) { |
4417 | - g_warning("Moving an entry that isn't in our menus."); |
4418 | - return; |
4419 | - } |
4420 | - |
4421 | - GtkWidget * mi = GTK_WIDGET(array[1]); |
4422 | - g_object_ref(G_OBJECT(mi)); |
4423 | - gtk_container_remove(GTK_CONTAINER(menubar), mi); |
4424 | - |
4425 | - incoming_position_t position; |
4426 | - position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER)); |
4427 | - position.entryposition = indicator_object_get_location(io, entry); |
4428 | - position.menupos = 0; |
4429 | - position.found = FALSE; |
4430 | - |
4431 | - gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position); |
4432 | - |
4433 | - gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos); |
4434 | - |
4435 | - g_object_unref(G_OBJECT(mi)); |
4436 | - |
4437 | - return; |
4438 | -} |
4439 | - |
4440 | -static gboolean |
4441 | -load_module (const gchar * name, GtkWidget * menubar) |
4442 | -{ |
4443 | - g_debug("Looking at Module: %s", name); |
4444 | - g_return_val_if_fail(name != NULL, FALSE); |
4445 | - |
4446 | - if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) { |
4447 | - return FALSE; |
4448 | - } |
4449 | - |
4450 | - g_debug("Loading Module: %s", name); |
4451 | - |
4452 | - /* Build the object for the module */ |
4453 | - gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL); |
4454 | - IndicatorObject * io = indicator_object_new_from_file(fullpath); |
4455 | - g_free(fullpath); |
4456 | - g_return_val_if_fail(io != NULL, FALSE); |
4457 | - |
4458 | - /* Attach the 'name' to the object */ |
4459 | - g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name))); |
4460 | - |
4461 | - /* Connect to its signals */ |
4462 | - g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar); |
4463 | - g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar); |
4464 | - g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar); |
4465 | - |
4466 | - /* Work on the entries */ |
4467 | - GList * entries = indicator_object_get_entries(io); |
4468 | - GList * entry = NULL; |
4469 | - |
4470 | - for (entry = entries; entry != NULL; entry = g_list_next(entry)) { |
4471 | - IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data; |
4472 | - entry_added(io, entrydata, menubar); |
4473 | - } |
4474 | - |
4475 | - g_list_free(entries); |
4476 | - |
4477 | - return TRUE; |
4478 | -} |
4479 | -// </indicator-applet-copy> |
4480 | - |
4481 | - |
4482 | -/* prototypes */ |
4483 | -static gboolean |
4484 | -on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator); |
4485 | - |
4486 | -IndicatorPlugin * |
4487 | -indicator_new () |
4488 | -{ |
4489 | - IndicatorPlugin *indicator; |
4490 | - GtkOrientation orientation; |
4491 | - gint indicators_loaded = 0; |
4492 | - |
4493 | - /* Hack! prevent the appmenu indicator from swallowing our own menubar */ |
4494 | - setenv("APPMENU_DISPLAY_BOTH", "1"); |
4495 | - |
4496 | - /* allocate memory for the plugin structure */ |
4497 | - indicator = g_new (IndicatorPlugin, 1); |
4498 | - |
4499 | - indicator->container = gtk_plug_new(0); |
4500 | - |
4501 | - /* Init some theme/icon stuff */ |
4502 | - g_object_set (gtk_settings_get_default(), "gtk-theme-name", "Ambiance", NULL); |
4503 | - g_object_set (gtk_settings_get_default(), "gtk-icon-theme-name", "ubuntu-mono-dark", NULL); |
4504 | - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), |
4505 | - INDICATOR_ICONS_DIR); |
4506 | - gtk_rc_parse_string ( |
4507 | - "widget \"indicator-applet*\" style \"panel\"\n" |
4508 | - "style \"indicator-applet-style\"\n" |
4509 | - "{\n" |
4510 | - " GtkMenuBar::shadow-type = none\n" |
4511 | - " GtkMenuBar::internal-padding = 0\n" |
4512 | - " GtkWidget::focus-line-width = 0\n" |
4513 | - " GtkWidget::focus-padding = 0\n" |
4514 | - "}\n" |
4515 | - "style \"indicator-applet-menubar-style\"\n" |
4516 | - "{\n" |
4517 | - " GtkMenuBar::shadow-type = none\n" |
4518 | - " GtkMenuBar::internal-padding = 0\n" |
4519 | - " GtkWidget::focus-line-width = 0\n" |
4520 | - " GtkWidget::focus-padding = 0\n" |
4521 | - " GtkMenuItem::horizontal-padding = 0\n" |
4522 | - "}\n" |
4523 | - "style \"indicator-applet-menuitem-style\"\n" |
4524 | - "{\n" |
4525 | - " GtkWidget::focus-line-width = 0\n" |
4526 | - " GtkWidget::focus-padding = 0\n" |
4527 | - " GtkMenuItem::horizontal-padding = 0\n" |
4528 | - "}\n" |
4529 | - "widget \"*.indicator-applet\" style \"indicator-applet-style\"" |
4530 | - "widget \"*.indicator-applet-menuitem\" style \"indicator-applet-menuitem-style\"" |
4531 | - "widget \"*.indicator-applet-menubar\" style \"indicator-applet-menubar-style\""); |
4532 | - gtk_widget_set_name(GTK_WIDGET (indicator->container), "indicator-applet"); |
4533 | - /* create some panel widgets */ |
4534 | - |
4535 | - /* Build menu */ |
4536 | - indicator->menu = gtk_menu_bar_new(); |
4537 | - GTK_WIDGET_SET_FLAGS (indicator->menu, GTK_WIDGET_FLAGS(indicator->menu) | GTK_CAN_FOCUS); |
4538 | - gtk_widget_set_name(GTK_WIDGET (indicator->menu), "indicator-applet-menubar"); |
4539 | - g_signal_connect(indicator->menu, "button-press-event", G_CALLBACK(on_menu_press), NULL); |
4540 | - //g_signal_connect_after(indicator->menu, "expose-event", G_CALLBACK(menu_on_expose), menu); |
4541 | - gtk_container_set_border_width(GTK_CONTAINER(indicator->menu), 0); |
4542 | - |
4543 | - /* load 'em */ |
4544 | - if (!g_file_test(INDICATOR_DIR, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { |
4545 | - g_warning ("%s does not exist, cannot read any indicators", INDICATOR_DIR); |
4546 | - } else { |
4547 | - GDir *dir; |
4548 | - const gchar *name; |
4549 | - |
4550 | - dir = g_dir_open(INDICATOR_DIR, 0, NULL); |
4551 | - while ((name = g_dir_read_name (dir)) != NULL) { |
4552 | - if (g_strcmp0(name, "libappmenu.so") == 0) { |
4553 | - continue; |
4554 | - } |
4555 | - |
4556 | - if (load_module(name, indicator->menu)) { |
4557 | - indicators_loaded++; |
4558 | - } else { |
4559 | - g_warning("Failed to load module %s", name); |
4560 | - } |
4561 | - } |
4562 | - g_dir_close(dir); |
4563 | - } |
4564 | - |
4565 | - if (indicators_loaded == 0) { |
4566 | - /* A label to allow for click through */ |
4567 | - indicator->item = gtk_button_new(); |
4568 | - gtk_button_set_label(GTK_BUTTON(indicator->item), "No Indicators"); |
4569 | - gtk_widget_show(indicator->item); |
4570 | - gtk_container_add (GTK_CONTAINER (indicator->container), indicator->item); |
4571 | - } else { |
4572 | - gtk_widget_show(indicator->menu); |
4573 | - gtk_container_add (GTK_CONTAINER (indicator->container), indicator->menu); |
4574 | - } |
4575 | - return indicator; |
4576 | -} |
4577 | - |
4578 | - |
4579 | - |
4580 | -void |
4581 | -indicator_free (IndicatorPlugin *indicator) |
4582 | -{ |
4583 | - g_free(indicator); |
4584 | -} |
4585 | - |
4586 | - |
4587 | -#if 0 |
4588 | -static gboolean |
4589 | -indicator_size_changed (XfcePanelPlugin *plugin, |
4590 | - gint size, |
4591 | - IndicatorPlugin *indicator) |
4592 | -{ |
4593 | - GtkOrientation orientation; |
4594 | - |
4595 | - /* get the orientation of the plugin */ |
4596 | - orientation = xfce_panel_plugin_get_orientation (plugin); |
4597 | - |
4598 | - /* set the widget size */ |
4599 | - if (orientation == GTK_ORIENTATION_HORIZONTAL) |
4600 | - gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size); |
4601 | - else |
4602 | - gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1); |
4603 | - |
4604 | - /* we handled the orientation */ |
4605 | - return TRUE; |
4606 | -} |
4607 | -#endif |
4608 | - |
4609 | - |
4610 | -static gboolean |
4611 | -on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator) |
4612 | -{ |
4613 | - if (indicator != NULL && event->button == 1) /* left click only */ |
4614 | - { |
4615 | - /* gtk_menu_popup (GTK_MENU(indicator->menu), NULL, NULL, NULL, NULL, 0, |
4616 | - event->time);*/ |
4617 | - return TRUE; |
4618 | - } |
4619 | - return FALSE ; |
4620 | -} |
4621 | |
4622 | === removed file 'panel/applets/indicator/indicator.h' |
4623 | --- panel/applets/indicator/indicator.h 2011-06-22 14:49:34 +0000 |
4624 | +++ panel/applets/indicator/indicator.h 1970-01-01 00:00:00 +0000 |
4625 | @@ -1,45 +0,0 @@ |
4626 | -/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org> |
4627 | - * |
4628 | - * This program is free software; you can redistribute it and/or modify |
4629 | - * it under the terms of the GNU General Public License as published by |
4630 | - * the Free Software Foundation; either version 2 of the License, or |
4631 | - * (at your option) any later version. |
4632 | - * |
4633 | - * This program is distributed in the hope that it will be useful, |
4634 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4635 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4636 | - * GNU Library General Public License for more details. |
4637 | - * |
4638 | - * You should have received a copy of the GNU General Public License |
4639 | - * along with this program; if not, write to the Free Software |
4640 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
4641 | - */ |
4642 | - |
4643 | -#ifndef __INDICATOR_H__ |
4644 | -#define __INDICATOR_H__ |
4645 | - |
4646 | -#include <gtk/gtk.h> |
4647 | - |
4648 | -G_BEGIN_DECLS |
4649 | - |
4650 | -/* plugin structure */ |
4651 | -typedef struct _IndicatorPlugin |
4652 | -{ |
4653 | - GtkWidget *container; |
4654 | - /* panel widgets */ |
4655 | - GtkWidget *menu; |
4656 | - GtkWidget *item; |
4657 | - |
4658 | - /* indicator settings */ |
4659 | -} |
4660 | -IndicatorPlugin; |
4661 | - |
4662 | -IndicatorPlugin * |
4663 | -indicator_new (); |
4664 | - |
4665 | -void |
4666 | -indicator_free(IndicatorPlugin*); |
4667 | - |
4668 | -G_END_DECLS |
4669 | - |
4670 | -#endif /* !__INDICATOR_H__ */ |
4671 | |
4672 | === added file 'panel/applets/indicator/indicatorapplet.cpp' |
4673 | --- panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000 |
4674 | +++ panel/applets/indicator/indicatorapplet.cpp 2011-08-04 16:31:58 +0000 |
4675 | @@ -0,0 +1,58 @@ |
4676 | +/* |
4677 | + * This file is part of unity-2d |
4678 | + * |
4679 | + * Copyright 2011 Canonical Ltd. |
4680 | + * |
4681 | + * Authors: |
4682 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4683 | + * |
4684 | + * This program is free software; you can redistribute it and/or modify |
4685 | + * it under the terms of the GNU General Public License as published by |
4686 | + * the Free Software Foundation; version 3. |
4687 | + * |
4688 | + * This program is distributed in the hope that it will be useful, |
4689 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4690 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4691 | + * GNU General Public License for more details. |
4692 | + * |
4693 | + * You should have received a copy of the GNU General Public License |
4694 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4695 | + */ |
4696 | +// Self |
4697 | +#include "indicatorapplet.h" |
4698 | + |
4699 | +// Local |
4700 | +#include <debug_p.h> |
4701 | +#include <indicatorsmanager.h> |
4702 | +#include <indicatorwidget.h> |
4703 | + |
4704 | +// Qt |
4705 | +#include <QHBoxLayout> |
4706 | + |
4707 | +using namespace unity::indicator; |
4708 | + |
4709 | +IndicatorApplet::IndicatorApplet(IndicatorsManager* manager) |
4710 | +: m_indicatorsManager(manager) |
4711 | +{ |
4712 | + QHBoxLayout* layout = new QHBoxLayout(this); |
4713 | + layout->setMargin(0); |
4714 | + layout->setSpacing(0); |
4715 | + setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
4716 | + |
4717 | + m_indicatorsManager->indicators()->on_object_added.connect( |
4718 | + sigc::mem_fun(this, &IndicatorApplet::onObjectAdded) |
4719 | + ); |
4720 | +} |
4721 | + |
4722 | +void IndicatorApplet::onObjectAdded(Indicator::Ptr const& indicator) |
4723 | +{ |
4724 | + QString name = QString::fromStdString(indicator->name()); |
4725 | + if (name == "libappmenu.so") { |
4726 | + // appmenu indicator is handled by AppNameApplet |
4727 | + return; |
4728 | + } |
4729 | + IndicatorWidget* widget = new IndicatorWidget(indicator, m_indicatorsManager); |
4730 | + layout()->addWidget(widget); |
4731 | +} |
4732 | + |
4733 | +#include "indicatorapplet.moc" |
4734 | |
4735 | === removed file 'panel/applets/indicator/indicatorapplet.cpp' |
4736 | --- panel/applets/indicator/indicatorapplet.cpp 2011-06-22 14:49:34 +0000 |
4737 | +++ panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000 |
4738 | @@ -1,114 +0,0 @@ |
4739 | -/* |
4740 | - * This file is part of unity-2d |
4741 | - * |
4742 | - * Copyright 2010 Canonical Ltd. |
4743 | - * |
4744 | - * Authors: |
4745 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4746 | - * |
4747 | - * This program is free software; you can redistribute it and/or modify |
4748 | - * it under the terms of the GNU General Public License as published by |
4749 | - * the Free Software Foundation; version 3. |
4750 | - * |
4751 | - * This program is distributed in the hope that it will be useful, |
4752 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4753 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4754 | - * GNU General Public License for more details. |
4755 | - * |
4756 | - * You should have received a copy of the GNU General Public License |
4757 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4758 | - */ |
4759 | - |
4760 | -// Self |
4761 | -#include "indicatorapplet.h" |
4762 | - |
4763 | -// Local |
4764 | -#include "abstractindicator.h" |
4765 | -#include "datetimeindicator.h" |
4766 | -#include "debug_p.h" |
4767 | -#include "indicator.h" |
4768 | - |
4769 | -// Qt |
4770 | -#include <QAction> |
4771 | -#include <QDBusConnection> |
4772 | -#include <QHBoxLayout> |
4773 | -#include <QMenu> |
4774 | -#include <QX11EmbedContainer> |
4775 | - |
4776 | -// Gtk |
4777 | -#include <gdk/gdk.h> |
4778 | -#include <gtk/gtk.h> |
4779 | - |
4780 | -IndicatorApplet::IndicatorApplet() |
4781 | -{ |
4782 | - setupUi(); |
4783 | - loadIndicators(); |
4784 | -} |
4785 | - |
4786 | -void IndicatorApplet::setupUi() |
4787 | -{ |
4788 | - m_menuBar = new QMenuBar; |
4789 | - m_menuBar->setNativeMenuBar(false); |
4790 | - QHBoxLayout* layout = new QHBoxLayout(this); |
4791 | - layout->setMargin(0); |
4792 | - layout->addWidget(m_menuBar); |
4793 | - |
4794 | - QMetaObject::invokeMethod(this, "createGtkIndicator", Qt::QueuedConnection); |
4795 | -} |
4796 | - |
4797 | -void IndicatorApplet::createGtkIndicator() |
4798 | -{ |
4799 | - int* argc = 0; |
4800 | - char*** argv = 0; |
4801 | - gtk_init(argc, argv); |
4802 | - |
4803 | - m_container = new QX11EmbedContainer; |
4804 | - layout()->addWidget(m_container); |
4805 | - |
4806 | - m_gtkIndicator = indicator_new(); |
4807 | - m_container->embedClient(gtk_plug_get_id(GTK_PLUG(m_gtkIndicator->container))); |
4808 | - gtk_widget_show(m_gtkIndicator->container); |
4809 | - |
4810 | - QTimer* timer = new QTimer(this); |
4811 | - timer->setInterval(1000); |
4812 | - timer->setSingleShot(false); |
4813 | - connect(timer, SIGNAL(timeout()), SLOT(adjustGtkIndicatorSize())); |
4814 | - timer->start(); |
4815 | -} |
4816 | - |
4817 | -void IndicatorApplet::adjustGtkIndicatorSize() |
4818 | -{ |
4819 | - GtkRequisition requisition; |
4820 | - gtk_widget_size_request(m_gtkIndicator->menu, &requisition); |
4821 | - m_container->setFixedWidth(requisition.width); |
4822 | -} |
4823 | - |
4824 | -void IndicatorApplet::loadIndicators() |
4825 | -{ |
4826 | -#if 0 |
4827 | - // FIXME: Using Qt plugins |
4828 | - QList<AbstractIndicator*> indicators = QList<AbstractIndicator*>() |
4829 | - << new DateTimeIndicator(this) |
4830 | - ; |
4831 | - |
4832 | - Q_FOREACH(AbstractIndicator* indicator, indicators) { |
4833 | - connect(indicator, SIGNAL(actionAdded(QAction*)), SLOT(slotActionAdded(QAction*))); |
4834 | - connect(indicator, SIGNAL(actionRemoved(QAction*)), SLOT(slotActionRemoved(QAction*))); |
4835 | - indicator->init(); |
4836 | - } |
4837 | -#endif |
4838 | -} |
4839 | - |
4840 | -void IndicatorApplet::slotActionAdded(QAction* action) |
4841 | -{ |
4842 | - UQ_VAR(action->text()); |
4843 | - m_menuBar->addAction(action); |
4844 | -} |
4845 | - |
4846 | -void IndicatorApplet::slotActionRemoved(QAction* action) |
4847 | -{ |
4848 | - m_menuBar->removeAction(action); |
4849 | -} |
4850 | - |
4851 | - |
4852 | -#include "indicatorapplet.moc" |
4853 | |
4854 | === added file 'panel/applets/indicator/indicatorapplet.h' |
4855 | --- panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000 |
4856 | +++ panel/applets/indicator/indicatorapplet.h 2011-08-04 16:31:58 +0000 |
4857 | @@ -0,0 +1,45 @@ |
4858 | +/* |
4859 | + * This file is part of unity-2d |
4860 | + * |
4861 | + * Copyright 2011 Canonical Ltd. |
4862 | + * |
4863 | + * Authors: |
4864 | + * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4865 | + * |
4866 | + * This program is free software; you can redistribute it and/or modify |
4867 | + * it under the terms of the GNU General Public License as published by |
4868 | + * the Free Software Foundation; version 3. |
4869 | + * |
4870 | + * This program is distributed in the hope that it will be useful, |
4871 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4872 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4873 | + * GNU General Public License for more details. |
4874 | + * |
4875 | + * You should have received a copy of the GNU General Public License |
4876 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4877 | + */ |
4878 | + |
4879 | +#ifndef INDICATORAPPLET_H |
4880 | +#define INDICATORAPPLET_H |
4881 | + |
4882 | +// Local |
4883 | +#include <applet.h> |
4884 | + |
4885 | +// libunity-core |
4886 | +#include <UnityCore/Indicator.h> |
4887 | + |
4888 | +class IndicatorsManager; |
4889 | + |
4890 | +class IndicatorApplet : public Unity2d::Applet, public sigc::trackable |
4891 | +{ |
4892 | +Q_OBJECT |
4893 | +public: |
4894 | + IndicatorApplet(IndicatorsManager* manager); |
4895 | + |
4896 | +private: |
4897 | + Q_DISABLE_COPY(IndicatorApplet) |
4898 | + IndicatorsManager* m_indicatorsManager; |
4899 | + void onObjectAdded(unity::indicator::Indicator::Ptr const&); |
4900 | +}; |
4901 | + |
4902 | +#endif /* INDICATORAPPLET_H */ |
4903 | |
4904 | === removed file 'panel/applets/indicator/indicatorapplet.h' |
4905 | --- panel/applets/indicator/indicatorapplet.h 2011-01-15 01:41:03 +0000 |
4906 | +++ panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000 |
4907 | @@ -1,60 +0,0 @@ |
4908 | -/* |
4909 | - * This file is part of unity-2d |
4910 | - * |
4911 | - * Copyright 2010 Canonical Ltd. |
4912 | - * |
4913 | - * Authors: |
4914 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4915 | - * |
4916 | - * This program is free software; you can redistribute it and/or modify |
4917 | - * it under the terms of the GNU General Public License as published by |
4918 | - * the Free Software Foundation; version 3. |
4919 | - * |
4920 | - * This program is distributed in the hope that it will be useful, |
4921 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4922 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4923 | - * GNU General Public License for more details. |
4924 | - * |
4925 | - * You should have received a copy of the GNU General Public License |
4926 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4927 | - */ |
4928 | - |
4929 | -#ifndef INDICATORAPPLET_H |
4930 | -#define INDICATORAPPLET_H |
4931 | - |
4932 | -// Local |
4933 | -#include <applet.h> |
4934 | - |
4935 | -// Qt |
4936 | -#include <QDBusInterface> |
4937 | -#include <QMenuBar> |
4938 | - |
4939 | -class QX11EmbedContainer; |
4940 | - |
4941 | -struct _IndicatorPlugin; |
4942 | - |
4943 | -class IndicatorApplet : public Unity2d::Applet |
4944 | -{ |
4945 | -Q_OBJECT |
4946 | -public: |
4947 | - IndicatorApplet(); |
4948 | - |
4949 | -private Q_SLOTS: |
4950 | - void loadIndicators(); |
4951 | - void slotActionAdded(QAction*); |
4952 | - void slotActionRemoved(QAction*); |
4953 | - void createGtkIndicator(); |
4954 | - void adjustGtkIndicatorSize(); |
4955 | - |
4956 | -private: |
4957 | - Q_DISABLE_COPY(IndicatorApplet) |
4958 | - |
4959 | - QDBusInterface* m_watcher; |
4960 | - QMenuBar* m_menuBar; |
4961 | - QX11EmbedContainer* m_container; |
4962 | - struct _IndicatorPlugin* m_gtkIndicator; |
4963 | - |
4964 | - void setupUi(); |
4965 | -}; |
4966 | - |
4967 | -#endif /* INDICATORAPPLET_H */ |
4968 | |
4969 | === removed file 'panel/applets/indicator/indicatorservicemanager.cpp' |
4970 | --- panel/applets/indicator/indicatorservicemanager.cpp 2011-02-10 01:10:19 +0000 |
4971 | +++ panel/applets/indicator/indicatorservicemanager.cpp 1970-01-01 00:00:00 +0000 |
4972 | @@ -1,120 +0,0 @@ |
4973 | -/* |
4974 | - * This file is part of unity-2d |
4975 | - * |
4976 | - * Copyright 2010 Canonical Ltd. |
4977 | - * |
4978 | - * Authors: |
4979 | - * - Aurélien Gâteau <aurelien.gateau@canonical.com> |
4980 | - * |
4981 | - * This program is free software; you can redistribute it and/or modify |
4982 | - * it under the terms of the GNU General Public License as published by |
4983 | - * the Free Software Foundation; version 3. |
4984 | - * |
4985 | - * This program is distributed in the hope that it will be useful, |
4986 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4987 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4988 | - * GNU General Public License for more details. |
4989 | - * |
4990 | - * You should have received a copy of the GNU General Public License |
4991 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4992 | - */ |
4993 | - |
4994 | -// Self |
4995 | -#include "indicatorservicemanager.h" |
4996 | - |
4997 | -// Local |
4998 | -#include "debug_p.h" |
4999 | - |
5000 | -// Qt |