Merge lp:~fboucault/unity-2d/dash_collapsed_by_default into lp:unity-2d/3.0

Proposed by Florian Boucault
Status: Superseded
Proposed branch: lp:~fboucault/unity-2d/dash_collapsed_by_default
Merge into: lp:unity-2d/3.0
Diff against target: 10694 lines (+4169/-3110)
211 files modified
.bzrignore (+2/-0)
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 (+103/-17)
debian/control (+16/-12)
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 (+14/-12)
launcher/LauncherItem.qml (+2/-0)
launcher/LauncherList.qml (+11/-0)
launcher/app/launcher.cpp (+2/-0)
launcher/app/launcherview.cpp (+5/-7)
launcher/app/launcherview.h (+1/-1)
libunity-2d-private/CMakeLists.txt (+3/-1)
libunity-2d-private/Unity2d/CMakeLists.txt (+3/-0)
libunity-2d-private/Unity2d/GnomeBackground.qml (+12/-22)
libunity-2d-private/Unity2d/plugin.cpp (+10/-4)
libunity-2d-private/src/CMakeLists.txt (+18/-0)
libunity-2d-private/src/bfb.cpp (+119/-0)
libunity-2d-private/src/bfb.h (+75/-0)
libunity-2d-private/src/dashclient.cpp (+155/-0)
libunity-2d-private/src/dashclient.h (+68/-0)
libunity-2d-private/src/debug.cpp (+23/-0)
libunity-2d-private/src/debug_p.h (+6/-0)
libunity-2d-private/src/filter.cpp (+92/-0)
libunity-2d-private/src/filter.h (+74/-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/lens.cpp (+272/-0)
libunity-2d-private/src/lens.h (+130/-0)
libunity-2d-private/src/lenses.cpp (+123/-0)
libunity-2d-private/src/lenses.h (+73/-0)
libunity-2d-private/src/placeentry.cpp (+14/-80)
libunity-2d-private/src/placeentry.h (+2/-8)
libunity-2d-private/src/ratingsfilter.cpp (+46/-0)
libunity-2d-private/src/ratingsfilter.h (+56/-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 (+23/-48)
panel/app/panelmanager.h (+2/-0)
panel/app/unity2dstyle.cpp (+0/-98)
panel/app/unity2dstyle.h (+0/-44)
panel/applets/CMakeLists.txt (+15/-29)
panel/applets/appname/appnameapplet.cpp (+49/-84)
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 (+378/-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 (+0/-61)
panel/applets/homebutton/homebutton.h (+0/-43)
panel/applets/homebutton/homebuttonapplet.cpp (+0/-111)
panel/applets/homebutton/homebuttonapplet.h (+0/-53)
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)
panel/tests/CMakeLists.txt (+2/-4)
panel/tests/homebuttonapplettest.cpp (+0/-42)
places/AbstractButton.qml (+2/-0)
places/CategoryHeader.qml (+9/-7)
places/Home.qml (+26/-24)
places/HomeButton.qml (+2/-0)
places/HomeShortcuts.qml (+15/-11)
places/LensBar.qml (+117/-0)
places/LensButton.qml (+80/-0)
places/LensView.qml (+46/-46)
places/PageModel.qml (+1/-1)
places/Renderer.qml (+8/-8)
places/RendererGrid.qml (+5/-12)
places/SearchEntry.qml (+9/-1)
places/SearchRefine.qml (+4/-2)
places/SearchRefineOption.qml (+1/-1)
places/SearchRefineOptionType.qml (+7/-5)
places/TickBox.qml (+3/-0)
places/UnityDefaultRenderer.qml (+3/-1)
places/UnityEmptySearchRenderer.qml (+5/-3)
places/UnityFileInfoRenderer.qml (+3/-1)
places/UnityHorizontalTileRenderer.qml (+1/-1)
places/app/dash.xml (+10/-16)
places/app/dashdeclarativeview.cpp (+9/-11)
places/app/dashdeclarativeview.h (+6/-6)
places/app/places.cpp (+2/-0)
places/artwork/lens-nav-home.svg (+9/-0)
places/dash.qml (+55/-24)
places/tile-vertical.qml (+22/-0)
po/af.po (+2/-2)
po/am.po (+2/-2)
po/an.po (+2/-2)
po/ar.po (+2/-2)
po/ast.po (+2/-2)
po/az.po (+2/-2)
po/be.po (+2/-2)
po/bem.po (+2/-2)
po/bg.po (+2/-2)
po/bn.po (+2/-2)
po/bs.po (+3/-3)
po/ca.po (+2/-2)
po/ca@valencia.po (+3/-3)
po/crh.po (+2/-2)
po/cs.po (+2/-2)
po/cy.po (+2/-2)
po/da.po (+2/-2)
po/de.po (+2/-2)
po/el.po (+2/-2)
po/en_AU.po (+4/-4)
po/en_GB.po (+4/-4)
po/eo.po (+2/-2)
po/es.po (+2/-2)
po/et.po (+3/-3)
po/eu.po (+2/-2)
po/fa.po (+2/-2)
po/fi.po (+2/-2)
po/fil.po (+2/-2)
po/fr.po (+2/-2)
po/fy.po (+2/-2)
po/gd.po (+2/-2)
po/gl.po (+2/-2)
po/gv.po (+2/-2)
po/he.po (+2/-2)
po/hi.po (+2/-2)
po/hr.po (+2/-2)
po/hu.po (+2/-2)
po/hy.po (+2/-2)
po/id.po (+2/-2)
po/is.po (+2/-2)
po/it.po (+2/-2)
po/ja.po (+2/-2)
po/ka.po (+2/-2)
po/kk.po (+2/-2)
po/ko.po (+2/-2)
po/ku.po (+2/-2)
po/ky.po (+2/-2)
po/lb.po (+2/-2)
po/lt.po (+2/-2)
po/lv.po (+2/-2)
po/mg.po (+2/-2)
po/ml.po (+2/-2)
po/ms.po (+2/-2)
po/nb.po (+2/-2)
po/nl.po (+2/-2)
po/nn.po (+2/-2)
po/oc.po (+2/-2)
po/pa.po (+2/-2)
po/pl.po (+2/-2)
po/pt.po (+2/-2)
po/pt_BR.po (+2/-2)
po/ro.po (+2/-2)
po/ru.po (+2/-2)
po/si.po (+2/-2)
po/sk.po (+2/-2)
po/sl.po (+2/-2)
po/sq.po (+2/-2)
po/sr.po (+2/-2)
po/sv.po (+2/-2)
po/ta.po (+2/-2)
po/te.po (+2/-2)
po/th.po (+2/-2)
po/tr.po (+2/-2)
po/tt.po (+2/-2)
po/ug.po (+2/-2)
po/uk.po (+2/-2)
po/unity-2d.pot (+2/-2)
po/ur.po (+2/-2)
po/vi.po (+2/-2)
po/zh_CN.po (+2/-2)
po/zh_HK.po (+2/-2)
po/zh_TW.po (+2/-2)
spread/app/spread.cpp (+1/-0)
To merge this branch: bzr merge lp:~fboucault/unity-2d/dash_collapsed_by_default
Reviewer Review Type Date Requested Status
Gerry Boland Pending
Review via email: mp+71653@code.launchpad.net

Description of the change

[dash] Collapse categories by default.

To post a comment you must log in.

Unmerged revisions

653. By Florian Boucault

[dash] Collapse categories by default.

652. By Gerry Boland

[dash] Fix Lens bar icons so they scale correctly. Use correct Home lens icon.

651. By Florian Boucault

Readded dependency on libdee as a workaround until the proper fix is made in UnityCore.

650. By Florian Boucault

Removed mistakenly introduced dependency on libdee.

649. By Didier Roche-Tolomelli

releasing version 4.0.0-0ubuntu1

648. By Didier Roche-Tolomelli

* New upstream release:
  - [launcher] Impossible to keep KDE Apps in Launcher (LP: #741129)
  - [dash] Background should be blurred (LP: #823326)
  - No 'safely remove' option is present in the unity menu when a usb disk
    is inserted (LP: #660010)
  - Quicklist item "Keep In Launcher" should be "Keep in launcher" as design
    (LP: #795422)
  - [launcher] ESC doesn't dismiss launcher when activated with Alt+F1
    (LP: #812792)
  - [dash] Background wallpaper shifted when using a non compositing window
    manager (LP: #823295)
  - [launcher] Bottom gradient appears too early (LP: #823877)
  - mute/unmute sound when user clicks on sound applet using scroll button
    or middle mouse button (LP: #609860)
  - Secondary activate (i.e. middle click) support for indicators advanced
    usage (LP: #812933)
  - Unused GConfItemQmlWrapper dep found (LP: #821880)

647. By Didier Roche-Tolomelli

recommends lenses and not places anymore. Adding music lens

646. By Didier Roche-Tolomelli

* debian/control:
  - bump libunity-core-4.0-dev, libnux-1.0-dev

645. By Florian Boucault

[dash] Introduce bindings of shared backend for the dash and make use of them in the user interface.

Only search results have been integrated. The filters have been deactivated for now.
Also broken is the drag and drop from the dash to the launcher because lenses return garbled URIs.
All references to Place and PlaceEntry have been replaced by Lens.

644. By Aurélien Gâteau

[panel][launcher] Turn the HomeButtonApplet into a launcher item.

Preview Diff

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

Subscribers

People subscribed via source and target branches