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