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