Merge lp:~didrocks/unity-2d/subdatadir into lp:unity-2d/3.0

Proposed by Didier Roche-Tolomelli
Status: Superseded
Proposed branch: lp:~didrocks/unity-2d/subdatadir
Merge into: lp:unity-2d/3.0
Diff against target: 6908 lines (+2010/-2400)
169 files modified
CMakeLists.txt (+6/-3)
data/unity-2d.convert (+0/-2)
debian/20_ubuntu-2d-gconf-default (+0/-8)
debian/20_ubuntu-2d-gconf-mandatory (+0/-1)
debian/changelog (+78/-17)
debian/control (+13/-10)
debian/gconf/ubuntu-2d.default.path (+2/-2)
debian/gconf/ubuntu-2d.mandatory.path (+2/-2)
debian/unity-2d-panel.install (+0/-2)
debian/unity-2d.gconf-defaults (+4/-0)
debian/unity-2d.install (+2/-4)
debian/unity-2d.postinst (+12/-15)
debian/unity-2d.postrm (+11/-14)
debian/unity-2d.preinst (+16/-0)
launcher/Launcher.qml (+11/-0)
launcher/LauncherItem.qml (+2/-0)
launcher/LauncherList.qml (+11/-0)
launcher/app/launcher.cpp (+2/-0)
libunity-2d-private/CMakeLists.txt (+1/-1)
libunity-2d-private/Unity2d/GnomeBackground.qml (+12/-22)
libunity-2d-private/Unity2d/plugin.cpp (+0/-4)
libunity-2d-private/src/CMakeLists.txt (+5/-0)
libunity-2d-private/src/debug.cpp (+23/-0)
libunity-2d-private/src/debug_p.h (+6/-0)
libunity-2d-private/src/launcherapplication.cpp (+4/-6)
libunity-2d-private/src/launcherapplicationslist.cpp (+20/-1)
libunity-2d-private/src/launcherapplicationslist.h (+2/-1)
libunity-2d-private/src/launchermenu.cpp (+1/-0)
libunity-2d-private/src/screeninfo.cpp (+1/-3)
libunity-2d-private/src/unity2dapplication.cpp (+83/-1)
libunity-2d-private/src/unity2dapplication.h (+3/-0)
libunity-2d-private/src/windowinfo.cpp (+1/-3)
libunity-2d-private/src/workspacesinfo.cpp (+1/-3)
panel/CMakeLists.txt (+3/-5)
panel/app/CMakeLists.txt (+3/-1)
panel/app/main.cpp (+5/-2)
panel/app/panelmanager.cpp (+34/-46)
panel/app/panelmanager.h (+2/-0)
panel/app/unity2dstyle.cpp (+0/-98)
panel/app/unity2dstyle.h (+0/-44)
panel/applets/CMakeLists.txt (+15/-26)
panel/applets/appname/appnameapplet.cpp (+7/-57)
panel/applets/appname/appnameapplet.h (+3/-1)
panel/applets/appname/com.canonical.AppMenu.Registrar.xml (+0/-82)
panel/applets/appname/croppedlabel.cpp (+140/-0)
panel/applets/appname/croppedlabel.h (+45/-0)
panel/applets/appname/menubarwidget.cpp (+78/-279)
panel/applets/appname/menubarwidget.h (+25/-66)
panel/applets/appname/registrar.cpp (+0/-138)
panel/applets/appname/registrar.h (+0/-85)
panel/applets/common/cairoutils.cpp (+42/-0)
panel/applets/common/cairoutils.h (+47/-0)
panel/applets/common/indicatorentrywidget.cpp (+366/-0)
panel/applets/common/indicatorentrywidget.h (+90/-0)
panel/applets/common/indicatorsmanager.cpp (+206/-0)
panel/applets/common/indicatorsmanager.h (+72/-0)
panel/applets/common/indicatorwidget.cpp (+53/-0)
panel/applets/common/indicatorwidget.h (+52/-0)
panel/applets/common/panelstyle.cpp (+114/-0)
panel/applets/common/panelstyle.h (+56/-0)
panel/applets/homebutton/homebutton.cpp (+4/-2)
panel/applets/indicator-config.h.in (+0/-7)
panel/applets/indicator/abstractindicator.cpp (+0/-43)
panel/applets/indicator/abstractindicator.h (+0/-53)
panel/applets/indicator/datetimeindicator.cpp (+0/-94)
panel/applets/indicator/datetimeindicator.h (+0/-53)
panel/applets/indicator/indicator.c (+0/-525)
panel/applets/indicator/indicator.h (+0/-45)
panel/applets/indicator/indicatorapplet.cpp (+0/-114)
panel/applets/indicator/indicatorapplet.h (+0/-60)
panel/applets/indicator/indicatorservicemanager.cpp (+0/-120)
panel/applets/indicator/indicatorservicemanager.h (+0/-54)
places/AbstractButton.qml (+2/-0)
places/GroupHeader.qml (+2/-0)
places/Home.qml (+2/-0)
places/HomeButton.qml (+2/-0)
places/HomeShortcuts.qml (+4/-4)
places/SearchEntry.qml (+8/-0)
places/SearchRefine.qml (+2/-0)
places/SearchRefineOptionType.qml (+2/-0)
places/TickBox.qml (+3/-0)
places/UnityDefaultRenderer.qml (+2/-0)
places/UnityEmptySearchRenderer.qml (+2/-0)
places/UnityFileInfoRenderer.qml (+2/-0)
places/app/places.cpp (+2/-0)
places/dash.qml (+6/-0)
po/af.po (+2/-2)
po/am.po (+2/-2)
po/an.po (+2/-2)
po/ar.po (+2/-2)
po/ast.po (+2/-2)
po/az.po (+2/-2)
po/be.po (+2/-2)
po/bem.po (+2/-2)
po/bg.po (+2/-2)
po/bn.po (+2/-2)
po/bs.po (+3/-3)
po/ca.po (+2/-2)
po/ca@valencia.po (+3/-3)
po/crh.po (+2/-2)
po/cs.po (+2/-2)
po/cy.po (+2/-2)
po/da.po (+2/-2)
po/de.po (+2/-2)
po/el.po (+2/-2)
po/en_AU.po (+4/-4)
po/en_GB.po (+4/-4)
po/eo.po (+2/-2)
po/es.po (+2/-2)
po/et.po (+3/-3)
po/eu.po (+2/-2)
po/fa.po (+2/-2)
po/fi.po (+2/-2)
po/fil.po (+2/-2)
po/fr.po (+2/-2)
po/fy.po (+2/-2)
po/gd.po (+2/-2)
po/gl.po (+2/-2)
po/gv.po (+2/-2)
po/he.po (+2/-2)
po/hi.po (+2/-2)
po/hr.po (+2/-2)
po/hu.po (+2/-2)
po/hy.po (+2/-2)
po/id.po (+2/-2)
po/is.po (+2/-2)
po/it.po (+2/-2)
po/ja.po (+2/-2)
po/ka.po (+2/-2)
po/kk.po (+2/-2)
po/ko.po (+2/-2)
po/ku.po (+2/-2)
po/ky.po (+2/-2)
po/lb.po (+2/-2)
po/lt.po (+2/-2)
po/lv.po (+2/-2)
po/mg.po (+2/-2)
po/ml.po (+2/-2)
po/ms.po (+2/-2)
po/nb.po (+2/-2)
po/nl.po (+2/-2)
po/nn.po (+2/-2)
po/oc.po (+2/-2)
po/pa.po (+2/-2)
po/pl.po (+2/-2)
po/pt.po (+2/-2)
po/pt_BR.po (+2/-2)
po/ro.po (+2/-2)
po/ru.po (+2/-2)
po/si.po (+2/-2)
po/sk.po (+2/-2)
po/sl.po (+2/-2)
po/sq.po (+2/-2)
po/sr.po (+2/-2)
po/sv.po (+2/-2)
po/ta.po (+2/-2)
po/te.po (+2/-2)
po/th.po (+2/-2)
po/tr.po (+2/-2)
po/tt.po (+2/-2)
po/ug.po (+2/-2)
po/uk.po (+2/-2)
po/unity-2d.pot (+2/-2)
po/ur.po (+2/-2)
po/vi.po (+2/-2)
po/zh_CN.po (+2/-2)
po/zh_HK.po (+2/-2)
po/zh_TW.po (+2/-2)
spread/app/spread.cpp (+1/-0)
To merge this branch: bzr merge lp:~didrocks/unity-2d/subdatadir
Reviewer Review Type Date Requested Status
unity-2d-team Pending
Review via email: mp+70461@code.launchpad.net

This proposal has been superseded by a proposal from 2011-08-04.

Description of the change

Enable storing subdir (like kde4/) in the gsettings schema.
For instance /usr/share/applications/kde4/konversation.desktop should be stored
as kde4-konversation.desktop.

This is valid for all .desktop file in XDG_DATA_DIR/applications.
Note that full path and relative path are still supported

To post a comment you must log in.
lp:~didrocks/unity-2d/subdatadir updated
637. By Didier Roche-Tolomelli

fix typo

638. By Didier Roche-Tolomelli

make it more elegant, follow unity-2d guidelines and send a reference for favoriteFromDesktopFilePath (LP: #741129)

639. By Didier Roche-Tolomelli

fixing coding guidelines

Unmerged revisions

639. By Didier Roche-Tolomelli

fixing coding guidelines

638. By Didier Roche-Tolomelli

make it more elegant, follow unity-2d guidelines and send a reference for favoriteFromDesktopFilePath (LP: #741129)

637. By Didier Roche-Tolomelli

fix typo

636. By Didier Roche-Tolomelli

enable subdir in data_dir to be stored in dconf. The format is subdir-filename.desktop

635. By Felix H. Dahlke

[launcher] Changed quicklist item "Keep In Launcher" to "Keep in launcher" as well as "Remove From Launcher" to "Remove from launcher" per design

634. By Aurélien Gâteau

[panel] Fix build with Unity trunk -r1325

Indicators::on_menu_pointer_moved() signal has been removed. The code now
implements mouse polling to implement mouse scrubbing. This is more efficient
than waiting for unity-panel-service to ask for menus to show.

633. By Didier Roche-Tolomelli

releasing version 3.8.14.1-0ubuntu1

632. By Didier Roche-Tolomelli

* Few upstream fixes:
  - unity-2d-places crashed with SIGSEGV in
    QDeclarativePropertyPrivate::initProperty() (LP: #817896)
  - update resets unity launcher favorites (LP: #817954)

631. By Florian Boucault

Merged lp:unity-2d

630. By Didier Roche-Tolomelli

Remove the launcher favorite convert as it makes the launcher to be resetted to default values for people only using unity-3d. (LP: #817954)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-07-27 09:42:32 +0000
+++ CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -25,10 +25,13 @@
25find_package(X11 REQUIRED)25find_package(X11 REQUIRED)
26find_package(Gettext REQUIRED)26find_package(Gettext REQUIRED)
27pkg_check_modules(GLIB REQUIRED glib-2.0)27pkg_check_modules(GLIB REQUIRED glib-2.0)
28pkg_check_modules(GDK REQUIRED gdk-2.0)28pkg_check_modules(GDK REQUIRED gdk-3.0)
29pkg_check_modules(GTK REQUIRED gtk+-2.0)29pkg_check_modules(GTK REQUIRED gtk+-3.0)
30pkg_check_modules(GIO REQUIRED gio-2.0)30pkg_check_modules(GIO REQUIRED gio-2.0)
31pkg_check_modules(WNCK REQUIRED libwnck-1.0)31pkg_check_modules(WNCK REQUIRED libwnck-3.0)
32pkg_check_modules(QTGCONF REQUIRED libqtgconf)
33pkg_check_modules(NUXCORE REQUIRED nux-core-1.0)
34pkg_check_modules(PANGO REQUIRED pango)
3235
3336
34# GSettings schemas37# GSettings schemas
3538
=== modified file 'data/unity-2d.convert'
--- data/unity-2d.convert 2011-07-25 11:56:59 +0000
+++ data/unity-2d.convert 2011-08-04 16:31:58 +0000
@@ -3,5 +3,3 @@
3hide-mode = /desktop/unity-2d/launcher/hide_mode3hide-mode = /desktop/unity-2d/launcher/hide_mode
4use-strut = /desktop/unity-2d/launcher/use_strut4use-strut = /desktop/unity-2d/launcher/use_strut
55
6[com.canonical.Unity.Launcher]
7favorites = /desktop/unity-2d/launcher/favorites
86
=== renamed file 'debian/20_unity-2d-gconf-default' => 'debian/20_ubuntu-2d-gconf-default'
--- debian/20_unity-2d-gconf-default 2011-07-25 11:56:59 +0000
+++ debian/20_ubuntu-2d-gconf-default 2011-08-04 16:31:58 +0000
@@ -1,13 +1,5 @@
1/apps/gnome-power-manager/lock/use_screensaver_settings true
2/apps/gnome-power-manager/general/use_time_for_policy false
3/desktop/gnome/applications/window_manager/default /usr/bin/metacity
4/desktop/gnome/applications/window_manager/current /usr/bin/metacity
5/apps/metacity/general/show_maximized_titlebars false1/apps/metacity/general/show_maximized_titlebars false
6/apps/metacity/general/auto_maximize_windows true2/apps/metacity/general/auto_maximize_windows true
7/apps/metacity/general/capture_before_unmap true3/apps/metacity/general/capture_before_unmap true
8/apps/metacity/general/compositing_manager true4/apps/metacity/general/compositing_manager true
9/apps/metacity/general/compositor_effects false5/apps/metacity/general/compositor_effects false
10/apps/metacity/general/theme Ambiance
11/desktop/gnome/interface/gtk_theme Ambiance
12/desktop/gnome/interface/icon_theme ubuntu-mono-dark
13/desktop/gnome/peripherals/mouse/cursor_theme DMZ-White
146
=== renamed file 'debian/20_unity-2d-gconf-mandatory' => 'debian/20_ubuntu-2d-gconf-mandatory'
--- debian/20_unity-2d-gconf-mandatory 2011-06-15 13:05:38 +0000
+++ debian/20_ubuntu-2d-gconf-mandatory 2011-08-04 16:31:58 +0000
@@ -1,3 +1,2 @@
1/apps/nautilus/preferences/exit_with_last_window false
2/apps/metacity/global_keybindings/panel_main_menu disabled1/apps/metacity/global_keybindings/panel_main_menu disabled
3/apps/metacity/global_keybindings/panel_run_dialog disabled2/apps/metacity/global_keybindings/panel_run_dialog disabled
43
=== modified file 'debian/changelog'
--- debian/changelog 2011-07-29 14:05:54 +0000
+++ debian/changelog 2011-08-04 16:31:58 +0000
@@ -1,20 +1,33 @@
1unity-2d (3.8.14-0ubuntu1) UNRELEASED; urgency=low1unity-2d (3.8.14.1-0ubuntu1) oneiric; urgency=low
22
3 * 3 * Few upstream fixes:
44 - unity-2d-places crashed with SIGSEGV in
5 -- Florian Boucault <florian.boucault@canonical.com> Fri, 29 Jul 2011 16:05:25 +02005 QDeclarativePropertyPrivate::initProperty() (LP: #817896)
66 - update resets unity launcher favorites (LP: #817954)
7unity-2d (3.8.12-0ubuntu2) natty; urgency=low7
8 -- Didier Roche <didrocks@ubuntu.com> Tue, 02 Aug 2011 16:08:27 +0200
9
10unity-2d (3.8.14-0ubuntu1) oneiric; urgency=low
11
12 * New upstream release:
13 - [launcher] Need to press Alt+F1 twice to show launcher (LP: #812787)
14 * debian/control:
15 - build on latest libunity-core-4.0-dev and latest libnux-1.0-dev
16
17 -- Didier Roche <didrocks@ubuntu.com> Mon, 01 Aug 2011 19:53:40 +0200
18
19unity-2d (3.8.12-0ubuntu2) oneiric; urgency=low
820
9 * debian/control:21 * debian/control:
10 - enforcing latest libunity-private0 to be installed for each local22 - enforcing latest libunity-private0 to be installed for each local
11 consumer23 consumer
24 - don't recommends indicator-me, it's deprecated
12 * debian/libunity-2d-private0.lintian-overrides:25 * debian/libunity-2d-private0.lintian-overrides:
13 - remove a qml-related exported symbol warning wrongly detected26 - remove a qml-related exported symbol warning wrongly detected
1427
15 -- Didier Roche <didrocks@ubuntu.com> Fri, 29 Jul 2011 08:01:51 +020028 -- Didier Roche <didrocks@ubuntu.com> Fri, 29 Jul 2011 15:19:11 +0200
1629
17unity-2d (3.8.12-0ubuntu1) natty; urgency=low30unity-2d (3.8.12-0ubuntu1) oneiric; urgency=low
1831
19 [ Florian Boucault ]32 [ Florian Boucault ]
20 * Upstreamed patch 01_build_with_new_indicator.patch33 * Upstreamed patch 01_build_with_new_indicator.patch
@@ -32,6 +45,7 @@
32 - remove default value for /desktop/unity-2d/launcher/favorites45 - remove default value for /desktop/unity-2d/launcher/favorites
33 * debian/control:46 * debian/control:
34 - add dependency on libdconf-qt-dev47 - add dependency on libdconf-qt-dev
48 - add dependency on libnux-1.0-dev
3549
36 [ Didier Roche ]50 [ Didier Roche ]
37 * New upstream release:51 * New upstream release:
@@ -73,13 +87,27 @@
73 * Fix typo in trigger (debian/unity-2d.triggers): (LP: #807358)87 * Fix typo in trigger (debian/unity-2d.triggers): (LP: #807358)
74 * Install the apport hook in the right directory so that it's not launched88 * Install the apport hook in the right directory so that it's not launched
75 unconditionally (LP: #712343)89 unconditionally (LP: #712343)
90 * debian/control:
91 - dep on latest libqtdee-dev
92 - dep now on gtk3 indicator version
93 - dep on versionned libnux-1.0-dev
94 - dep on versionned libunity-core-4.0-dev
76 * debian/control, debian/rules, debian/libunity-2d-private-dev:95 * debian/control, debian/rules, debian/libunity-2d-private-dev:
77 - add new -dev project (LP: #814709)96 - add new -dev project (LP: #814709)
78 - add an upstream pc file97 - add an upstream pc file
7998
80 -- Florian Boucault <florian.boucault@canonical.com> Thu, 28 Jul 2011 12:05:05 +020099 -- Didier Roche <didrocks@ubuntu.com> Thu, 28 Jul 2011 12:05:38 +0200
81100
82unity-2d (3.8.10-0ubuntu1) natty; urgency=low101unity-2d (3.8.10-0ubuntu2) oneiric; urgency=low
102
103 * debian/control:
104 - rebuild with new indicator 0.4
105 * 01_build_with_new_indicator.patch:
106 - patch to build with the new indicator 0.4 stack
107
108 -- Didier Roche <didrocks@ubuntu.com> Sun, 10 Jul 2011 23:48:01 +0200
109
110unity-2d (3.8.10-0ubuntu1) oneiric; urgency=low
83111
84 [ Florian Boucault ]112 [ Florian Boucault ]
85 * debian/unity-2d-launcher.install:113 * debian/unity-2d-launcher.install:
@@ -102,10 +130,17 @@
102 - Missing a GConf schema file for the /desktop/unity-2d/… keys130 - Missing a GConf schema file for the /desktop/unity-2d/… keys
103 (LP: #750303)131 (LP: #750303)
104 - [dash] home screen search hint should be 'Search' (LP: #797825)132 - [dash] home screen search hint should be 'Search' (LP: #797825)
105133 * debian/unity-2d.gconf-defaults,
106 -- Florian Boucault <florian.boucault@canonical.com> Wed, 13 Jul 2011 11:59:29 +0200134 debian/20_ubuntu-2d-gconf-default:
107135 - transition some gconf keys from session-wide to system-wide
108unity-2d (3.8.8-0ubuntu1) natty; urgency=low136 (LP: #797672, #797676)
137 * debian/control:
138 - ensure we are still using gtk2 indicator for alpha2 (LP: #804938)
139 - bump standards-version
140
141 -- Didier Roche <didrocks@ubuntu.com> Mon, 04 Jul 2011 11:05:54 +0200
142
143unity-2d (3.8.8-0ubuntu1) oneiric; urgency=low
109144
110 [ Didier Roche ]145 [ Didier Roche ]
111 * new upstream release:146 * new upstream release:
@@ -152,7 +187,21 @@
152187
153 -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200188 -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200
154189
155unity-2d (3.8.6-0ubuntu1) natty; urgency=low190unity-2d (3.8.6-0ubuntu3~ppa1) oneiric; urgency=low
191
192 * Rebuild with new gcc
193
194 -- Didier Roche <didrocks@ubuntu.com> Tue, 07 Jun 2011 15:00:32 +0200
195
196unity-2d (3.8.6-0ubuntu2) oneiric; urgency=low
197
198 * debian/unity-2d.postinst, debian/unity-2d.postrm:
199 - remove the magic to set unity-2d in oneiric as the default session in gdm
200 as it's now installed on the ubuntu CD.
201
202 -- Didier Roche <didrocks@ubuntu.com> Wed, 01 Jun 2011 09:42:21 +0200
203
204unity-2d (3.8.6-0ubuntu1) oneiric; urgency=low
156205
157 * New upstream release:206 * New upstream release:
158 - [launcher] Support static shortcuts in the quicklists. (LP: #669923)207 - [launcher] Support static shortcuts in the quicklists. (LP: #669923)
@@ -196,6 +245,18 @@
196 * debian/libunity-2d-private0.post*245 * debian/libunity-2d-private0.post*
197 - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass246 - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass
198 -n anymore247 -n anymore
248 * don't install unity-2d session as it's in gnome-session now
249 * debian/unity-2d.install
250 debian/20_ubuntu-2d-gconf-default
251 debian/20_ubuntu-2d-gconf-mandatory
252 debian/gconf/ubuntu-2d.default.path
253 debian/gconf/ubuntu-2d.mandatory.path:
254 - remove uneeded defaults and mandatory
255 - remove some deprecated keys
256 - the session is now called ubuntu-2d and not unity-2d anymore
257 * debian/unity-2d.preinst, debian/unity-2d.postinst
258 debian/unity-2d.postrm:
259 - take into account the natty -> oneiric migration with session name change
199260
200 -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200261 -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200
201262
202263
=== modified file 'debian/control'
--- debian/control 2011-07-29 11:55:03 +0000
+++ debian/control 2011-08-04 16:31:58 +0000
@@ -10,19 +10,22 @@
10 libqt4-dev,10 libqt4-dev,
11 libqt4-opengl-dev,11 libqt4-opengl-dev,
12 libglib2.0-dev,12 libglib2.0-dev,
13 libwnck-dev,13 libwnck-3-dev,
14 libpango1.0-dev,
14 libqtgconf-dev,15 libqtgconf-dev,
15 libdconf-qt-dev,16 libdconf-qt-dev,
16 libqtbamf-dev,17 libqtbamf-dev,
17 libqtdee-dev,18 libqtdee-dev (>= 0.2.3),
18 libdbusmenu-qt-dev,19 libdbusmenu-qt-dev,
19 libx11-dev,20 libx11-dev,
20 libindicator-dev,21 libindicator3-dev,
21 libgtk2.0-dev,22 libgtk-3-dev,
22 libutouch-geis-dev,23 libutouch-geis-dev,
23 libstartup-notification0-dev24 libstartup-notification0-dev,
24Standards-Version: 3.9.125 libunity-core-4.0-dev (>= 4.6.0),
25Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/trunk26 libnux-1.0-dev (>= 1.0.8),
27Standards-Version: 3.9.2
28Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/oneiric
2629
27Package: unity-2d30Package: unity-2d
28Architecture: all31Architecture: all
@@ -56,9 +59,10 @@
56Depends: ${shlibs:Depends},59Depends: ${shlibs:Depends},
57 ${misc:Depends},60 ${misc:Depends},
58 libunity-2d-private0 (= ${binary:Version}),61 libunity-2d-private0 (= ${binary:Version}),
59 libgtk2.0-dev,62 libgtk-3-dev,
60 libwnck-dev,63 libwnck-3-dev,
61 libglib2.0-dev,64 libglib2.0-dev,
65 libpango1.0-dev,
62Description: Unity 2D shared library - development files66Description: Unity 2D shared library - development files
63 This library is used to host common code used by several Unity 2D components67 This library is used to host common code used by several Unity 2D components
64 It is only used internally, there is no use case for it outside of the unity-2d68 It is only used internally, there is no use case for it outside of the unity-2d
@@ -90,7 +94,6 @@
90Recommends: indicator-application,94Recommends: indicator-application,
91 indicator-appmenu,95 indicator-appmenu,
92 indicator-datetime,96 indicator-datetime,
93 indicator-me,
94 indicator-messages,97 indicator-messages,
95 indicator-session,98 indicator-session,
96 indicator-sound,99 indicator-sound,
97100
=== renamed file 'debian/gconf/unity-2d.default.path' => 'debian/gconf/ubuntu-2d.default.path'
--- debian/gconf/unity-2d.default.path 2011-06-15 13:05:38 +0000
+++ debian/gconf/ubuntu-2d.default.path 2011-08-04 16:31:58 +0000
@@ -1,3 +1,3 @@
1# Additional mandatory path for unity-2d experience1# Additional mandatory path for ubuntu-2d experience
2xml:readonly:/var/lib/gconf/unity-2d.default2xml:readonly:/var/lib/gconf/ubuntu-2d.default
33
44
=== renamed file 'debian/gconf/unity-2d.mandatory.path' => 'debian/gconf/ubuntu-2d.mandatory.path'
--- debian/gconf/unity-2d.mandatory.path 2011-06-15 13:05:38 +0000
+++ debian/gconf/ubuntu-2d.mandatory.path 2011-08-04 16:31:58 +0000
@@ -1,3 +1,3 @@
1# Additional mandatory path for unity-2d experience1# Additional mandatory path for ubuntu-2d experience
2xml:readonly:/var/lib/gconf/unity-2d.mandatory2xml:readonly:/var/lib/gconf/ubuntu-2d.mandatory
33
44
=== modified file 'debian/unity-2d-panel.install'
--- debian/unity-2d-panel.install 2011-01-14 21:41:39 +0000
+++ debian/unity-2d-panel.install 2011-08-04 16:31:58 +0000
@@ -1,4 +1,2 @@
1usr/bin/unity-2d-panel1usr/bin/unity-2d-panel
2usr/share/applications/unity-2d-panel.desktop2usr/share/applications/unity-2d-panel.desktop
3usr/share/unity-2d/panel/artwork/background.png
4usr/share/unity-2d/panel/artwork/divider.png
53
=== added file 'debian/unity-2d.gconf-defaults'
--- debian/unity-2d.gconf-defaults 1970-01-01 00:00:00 +0000
+++ debian/unity-2d.gconf-defaults 2011-08-04 16:31:58 +0000
@@ -0,0 +1,4 @@
1/desktop/unity-2d/launcher/favorites [ubiquity-gtkui.desktop,nautilus-home.desktop,firefox.desktop,libreoffice-writer.desktop,libreoffice-calc.desktop,libreoffice-impress.desktop,ubuntu-software-center.desktop,ubuntuone-control-panel-gtk.desktop]
2/desktop/unity-2d/launcher/hide_mode 2
3/desktop/unity-2d/launcher/use_strut false
4/desktop/unity-2d/launcher/super_key_enable true
05
=== modified file 'debian/unity-2d.install'
--- debian/unity-2d.install 2011-07-22 14:44:57 +0000
+++ debian/unity-2d.install 2011-08-04 16:31:58 +0000
@@ -1,9 +1,7 @@
1debian/unity-2d.py /usr/share/apport/package-hooks1debian/unity-2d.py /usr/share/apport/package-hooks
2debian/gconf/* /usr/share/gconf2debian/gconf/* /usr/share/gconf
3session/unity-2d.desktop /usr/share/xsessions3debian/20_ubuntu-2d-gconf-mandatory /usr/share/gconf/ubuntu-2d/mandatory
4session/2d-ubuntu.session /usr/share/gnome-session/sessions4debian/20_ubuntu-2d-gconf-default /usr/share/gconf/ubuntu-2d/default
5debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory
6debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default
7usr/share/locale/*/LC_MESSAGES/unity-2d.mo5usr/share/locale/*/LC_MESSAGES/unity-2d.mo
8usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml6usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml
9usr/share/GConf/gsettings7usr/share/GConf/gsettings
108
=== modified file 'debian/unity-2d.postinst'
--- debian/unity-2d.postinst 2011-06-15 13:05:38 +0000
+++ debian/unity-2d.postinst 2011-08-04 16:31:58 +0000
@@ -9,24 +9,21 @@
99
10case "$1" in10case "$1" in
11 configure|upgrade)11 configure|upgrade)
12 if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
13 /usr/lib/gdm/gdm-set-default-session --keep-old unity-2d || true
14 fi
15 if which update-gconf-defaults >/dev/null 2>&1 ; then12 if which update-gconf-defaults >/dev/null 2>&1 ; then
16 mkdir -p /var/lib/gconf/unity-2d.mandatory13 mkdir -p /var/lib/gconf/ubuntu-2d.mandatory
17 mkdir -p /var/lib/gconf/unity-2d.default14 mkdir -p /var/lib/gconf/ubuntu-2d.default
18 fi15 fi
19 ;;16 ;;
20 triggered)17 triggered)
21 for trigger in $2; do18 for trigger in $2; do
22 case $trigger in19 case $trigger in
23 /usr/share/gconf/unity-2d/mandatory)20 /usr/share/gconf/ubuntu-2d/mandatory)
24 update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \21 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
25 --destination /var/lib/gconf/unity-2d.mandatory --no-signal22 --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
26 ;;23 ;;
27 /usr/share/gconf/unity-2d/default)24 /usr/share/gconf/ubuntu-2d/default)
28 update-gconf-defaults --source /usr/share/gconf/unity-2d/default \25 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
29 --destination /var/lib/gconf/unity-2d.default --no-signal26 --destination /var/lib/gconf/ubuntu-2d.default --no-signal
30 ;;27 ;;
31 esac28 esac
32 done29 done
@@ -39,9 +36,9 @@
3936
40# Upon installation/upgrade, regenerate all databases, because in this case 37# Upon installation/upgrade, regenerate all databases, because in this case
41# there will be no trigger run38# there will be no trigger run
42update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \39update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
43 --destination /var/lib/gconf/unity-2d.mandatory --no-signal40 --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
44update-gconf-defaults --source /usr/share/gconf/unity-2d/default \41update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
45 --destination /var/lib/gconf/unity-2d.default --no-signal42 --destination /var/lib/gconf/ubuntu-2d.default --no-signal
46signal_daemons43signal_daemons
4744
4845
=== modified file 'debian/unity-2d.postrm'
--- debian/unity-2d.postrm 2011-06-15 13:05:38 +0000
+++ debian/unity-2d.postrm 2011-08-04 16:31:58 +0000
@@ -3,20 +3,17 @@
33
4case "$1" in4case "$1" in
5 remove|purge)5 remove|purge)
6 if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/unity-2d ]; then6 if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/ubuntu-2d ]; then
7 update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \7 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
8 --destination /var/lib/gconf/unity-2d.mandatory8 --destination /var/lib/gconf/ubuntu-2d.mandatory
9 update-gconf-defaults --source /usr/share/gconf/unity-2d/default \9 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
10 --destination /var/lib/gconf/unity-2d.default10 --destination /var/lib/gconf/ubuntu-2d.default
11 fi11 fi
12 if [ -d /var/lib/gconf/unity-2d.mandatory ]; then12 if [ -d /var/lib/gconf/ubuntu-2d.mandatory ]; then
13 rm -rf /var/lib/gconf/unity-2d.mandatory13 rm -rf /var/lib/gconf/ubuntu-2d.mandatory
14 fi14 fi
15 if [ -d /var/lib/gconf/unity-2d.default ]; then15 if [ -d /var/lib/gconf/ubuntu-2d.default ]; then
16 rm -rf /var/lib/gconf/unity-2d.default16 rm -rf /var/lib/gconf/ubuntu-2d.default
17 fi
18 if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
19 /usr/lib/gdm/gdm-set-default-session --remove unity-2d || true
20 fi17 fi
21 ;;18 ;;
22esac19esac
2320
=== added file 'debian/unity-2d.preinst'
--- debian/unity-2d.preinst 1970-01-01 00:00:00 +0000
+++ debian/unity-2d.preinst 2011-08-04 16:31:58 +0000
@@ -0,0 +1,16 @@
1#!/bin/sh
2set -e
3
4case "$1" in
5 install|upgrade)
6 if dpkg --compare-versions "$2" le "3.8.6-0ubuntu1"; then
7 if [ -d /var/lib/gconf/unity-2d.mandatory ]; then
8 mv /var/lib/gconf/unity-2d.mandatory /var/lib/gconf/ubuntu-2d.mandatory || true
9 mv /var/lib/gconf/unity-2d.default /var/lib/gconf/ubuntu-2d.default || true
10 fi
11 fi
12 ;;
13esac
14
15#DEBHELPER#
16
017
=== modified file 'launcher/Launcher.qml'
--- launcher/Launcher.qml 2011-07-11 12:16:31 +0000
+++ launcher/Launcher.qml 2011-08-04 16:31:58 +0000
@@ -22,7 +22,10 @@
22LauncherDropItem {22LauncherDropItem {
23 id: launcher23 id: launcher
2424
25 Accessible.name: "root"
26
25 GnomeBackground {27 GnomeBackground {
28 Accessible.name: "background"
26 anchors.fill: parent29 anchors.fill: parent
27 overlay_color: "black"30 overlay_color: "black"
28 overlay_alpha: 0.6631 overlay_alpha: 0.66
@@ -30,6 +33,7 @@
30 }33 }
3134
32 Rectangle {35 Rectangle {
36 Accessible.name: "background"
33 anchors.fill: parent37 anchors.fill: parent
34 color: "black"38 color: "black"
35 opacity: 0.6639 opacity: 0.66
@@ -37,6 +41,7 @@
37 }41 }
38 42
39 Image {43 Image {
44 Accessible.name: "border"
40 id: border45 id: border
4146
42 width: 147 width: 1
@@ -50,12 +55,16 @@
50 onWebpageUrlDropped: applications.insertWebFavorite(url)55 onWebpageUrlDropped: applications.insertWebFavorite(url)
5156
52 FocusScope {57 FocusScope {
58 Accessible.name: "content"
59
53 focus: true60 focus: true
54 anchors.fill: parent61 anchors.fill: parent
55 z: 1 /* ensure the lists are always strictly on top of the background */62 z: 1 /* ensure the lists are always strictly on top of the background */
5663
57 LauncherList {64 LauncherList {
58 id: main65 id: main
66 Accessible.name: "main"
67
59 anchors.top: parent.top68 anchors.top: parent.top
60 anchors.bottom: shelf.top69 anchors.bottom: shelf.top
61 anchors.bottomMargin: itemPadding70 anchors.bottomMargin: itemPadding
@@ -75,6 +84,8 @@
7584
76 LauncherList {85 LauncherList {
77 id: shelf86 id: shelf
87 Accessible.name: "shelf"
88
78 anchors.bottom: parent.bottom89 anchors.bottom: parent.bottom
79 anchors.bottomMargin: main.anchors.bottomMargin90 anchors.bottomMargin: main.anchors.bottomMargin
80 height: (tileSize + itemPadding) * count91 height: (tileSize + itemPadding) * count
8192
=== modified file 'launcher/LauncherItem.qml'
--- launcher/LauncherItem.qml 2011-07-14 11:17:30 +0000
+++ launcher/LauncherItem.qml 2011-08-04 16:31:58 +0000
@@ -48,6 +48,8 @@
48DropItem {48DropItem {
49 id: item49 id: item
5050
51 Accessible.role: Accessible.PushButton
52
51 anchors.horizontalCenter: parent.horizontalCenter53 anchors.horizontalCenter: parent.horizontalCenter
5254
53 property int padding55 property int padding
5456
=== modified file 'launcher/LauncherList.qml'
--- launcher/LauncherList.qml 2011-07-28 12:27:39 +0000
+++ launcher/LauncherList.qml 2011-08-04 16:31:58 +0000
@@ -77,6 +77,17 @@
77 delegate: LauncherItem {77 delegate: LauncherItem {
78 id: launcherItem78 id: launcherItem
7979
80 function accessibleDescription() {
81 if (running) {
82 var windows = u2d.tr("%1 window opened", "%1 windows opened", item.windowCount).arg(item.windowCount)
83 return "%1 %2".arg(item.name).arg(windows)
84 } else {
85 return "%1 %2".arg(item.name).arg(u2d.tr("not running"))
86 }
87 }
88
89 Accessible.name: accessibleDescription()
90
80 width: list.width91 width: list.width
81 tileSize: list.tileSize92 tileSize: list.tileSize
82 padding: list.itemPadding93 padding: list.itemPadding
8394
=== modified file 'launcher/app/launcher.cpp'
--- launcher/app/launcher.cpp 2011-07-27 09:42:32 +0000
+++ launcher/app/launcher.cpp 2011-08-04 16:31:58 +0000
@@ -78,6 +78,7 @@
78{78{
79 Unity2dApplication::earlySetup(argc, argv);79 Unity2dApplication::earlySetup(argc, argv);
80 Unity2dApplication application(argc, argv);80 Unity2dApplication application(argc, argv);
81 application.setApplicationName("Unity 2D Launcher");
81 QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());82 QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments());
8283
83 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop");84 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-launcher.desktop");
@@ -91,6 +92,7 @@
91 Unity2dPanel panel(true);92 Unity2dPanel panel(true);
92 panel.setEdge(Unity2dPanel::LeftEdge);93 panel.setEdge(Unity2dPanel::LeftEdge);
93 panel.setFixedWidth(LauncherClient::MaximumWidth);94 panel.setFixedWidth(LauncherClient::MaximumWidth);
95 panel.setAccessibleName("Launcher");
9496
95 VisibilityController* visibilityController = new VisibilityController(&panel);97 VisibilityController* visibilityController = new VisibilityController(&panel);
9698
9799
=== modified file 'libunity-2d-private/CMakeLists.txt'
--- libunity-2d-private/CMakeLists.txt 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -6,7 +6,7 @@
6pkg_check_modules(QTDEE REQUIRED libqtdee)6pkg_check_modules(QTDEE REQUIRED libqtdee)
7pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)7pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
8pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0)8pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0)
9pkg_check_modules(INDICATOR REQUIRED indicator)9pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)
10pkg_check_modules(DCONFQT REQUIRED dconf-qt)10pkg_check_modules(DCONFQT REQUIRED dconf-qt)
1111
12set(libunity-2d-private_SOVERSION 0)12set(libunity-2d-private_SOVERSION 0)
1313
=== modified file 'libunity-2d-private/Unity2d/GnomeBackground.qml'
--- libunity-2d-private/Unity2d/GnomeBackground.qml 2011-07-11 10:26:02 +0000
+++ libunity-2d-private/Unity2d/GnomeBackground.qml 2011-08-04 16:31:58 +0000
@@ -17,7 +17,7 @@
17 */17 */
1818
19import QtQuick 1.019import QtQuick 1.0
20import gconf 1.020import QConf 1.0
21/* Necessary to access the blended image provider and CacheEffect */21/* Necessary to access the blended image provider and CacheEffect */
22import Unity2d 1.022import Unity2d 1.0
2323
@@ -32,19 +32,9 @@
32 property bool cached: true32 property bool cached: true
33 effect: (cached) ? cacheEffect : null33 effect: (cached) ? cacheEffect : null
3434
35 GConfItem {35 QConf {
36 id: primary_color36 id: desktopBackground
37 key: "/desktop/gnome/background/primary_color"37 schema: "org.gnome.desktop.background"
38 }
39
40 GConfItem {
41 id: picture_filename
42 key: "/desktop/gnome/background/picture_filename"
43 }
44
45 GConfItem {
46 id: picture_options
47 key: "/desktop/gnome/background/picture_options"
48 }38 }
4939
50 Rectangle {40 Rectangle {
@@ -55,13 +45,13 @@
55 }45 }
5646
57 anchors.fill: parent47 anchors.fill: parent
58 color: primary_color.value48 color: desktopBackground.primaryColor
59 }49 }
6050
61 Image {51 Image {
62 id: picture52 id: picture
6353
64 visible: picture_filename.value54 visible: desktopBackground.pictureUri
65 source: {55 source: {
66 if (!visible) return ""56 if (!visible) return ""
67 57
@@ -74,8 +64,8 @@
74 https://bugs.launchpad.net/ubuntu/+source/ubuntu-wallpapers/+bug/29653864 https://bugs.launchpad.net/ubuntu/+source/ubuntu-wallpapers/+bug/296538
75 http://bugreports.qt.nokia.com/browse/QTBUG-727665 http://bugreports.qt.nokia.com/browse/QTBUG-7276
76 */66 */
77 var filename = picture_filename.value67 var filename = desktopBackground.pictureUri
78 if(filename == "/usr/share/backgrounds/warty-final-ubuntu.png")68 if(filename == "file:///usr/share/backgrounds/warty-final-ubuntu.png")
79 filename = "/usr/share/unity-2d/warty-final-ubuntu.jpg"69 filename = "/usr/share/unity-2d/warty-final-ubuntu.jpg"
8070
81 if(overlay_alpha > 0.0)71 if(overlay_alpha > 0.0)
@@ -99,13 +89,13 @@
99 - "spanned" (NOT IMPLEMENTED)89 - "spanned" (NOT IMPLEMENTED)
100 */90 */
101 fillMode: {91 fillMode: {
102 if(picture_options.value == "wallpaper")92 if(desktopBackground.pictureOptions== "wallpaper")
103 return Image.Tile93 return Image.Tile
104 else if(picture_options.value == "scaled")94 else if(desktopBackground.pictureOptions == "scaled")
105 return Image.PreserveAspectFit95 return Image.PreserveAspectFit
106 else if(picture_options.value == "stretched")96 else if(desktopBackground.pictureOptions == "stretched")
107 return Image.Stretch97 return Image.Stretch
108 else if(picture_options.value == "zoom")98 else if(desktopBackground.pictureOptions == "zoom")
109 return Image.PreserveAspectCrop99 return Image.PreserveAspectCrop
110 else return Image.PreserveAspectFit100 else return Image.PreserveAspectFit
111 }101 }
112102
=== modified file 'libunity-2d-private/Unity2d/plugin.cpp'
--- libunity-2d-private/Unity2d/plugin.cpp 2011-07-26 16:05:51 +0000
+++ libunity-2d-private/Unity2d/plugin.cpp 2011-08-04 16:31:58 +0000
@@ -20,10 +20,6 @@
20/* Required otherwise using wnck_set_client_type breaks linking with error:20/* Required otherwise using wnck_set_client_type breaks linking with error:
21 undefined reference to `wnck_set_client_type(WnckClientType)'21 undefined reference to `wnck_set_client_type(WnckClientType)'
22*/22*/
23extern "C" {
24#include <libwnck/util.h>
25}
26
27#include "plugin.h"23#include "plugin.h"
2824
29#include "launcherapplication.h"25#include "launcherapplication.h"
3026
=== modified file 'libunity-2d-private/src/CMakeLists.txt'
--- libunity-2d-private/src/CMakeLists.txt 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -2,6 +2,7 @@
22
3# Sources3# Sources
4set(lib${LIB_NAME}_SRCS4set(lib${LIB_NAME}_SRCS
5 debug.cpp
5 gconnector.cpp6 gconnector.cpp
6 gnomesessionclient.cpp7 gnomesessionclient.cpp
7 keyboardmodifiersmonitor.cpp8 keyboardmodifiersmonitor.cpp
@@ -64,6 +65,8 @@
64 ${CMAKE_CURRENT_BINARY_DIR}65 ${CMAKE_CURRENT_BINARY_DIR}
65 ${CMAKE_CURRENT_SOURCE_DIR}66 ${CMAKE_CURRENT_SOURCE_DIR}
66 ${GLIB_INCLUDE_DIRS}67 ${GLIB_INCLUDE_DIRS}
68 ${GTK_INCLUDE_DIRS}
69 ${PANGO_INCLUDE_DIRS}
67 ${WNCK_INCLUDE_DIRS}70 ${WNCK_INCLUDE_DIRS}
68 ${QTBAMF_INCLUDE_DIRS}71 ${QTBAMF_INCLUDE_DIRS}
69 ${QTGCONF_INCLUDE_DIRS}72 ${QTGCONF_INCLUDE_DIRS}
@@ -93,6 +96,8 @@
93 ${QT_QTNETWORK_LIBRARIES}96 ${QT_QTNETWORK_LIBRARIES}
94 ${X11_LIBRARIES}97 ${X11_LIBRARIES}
95 ${GLIB_LDFLAGS}98 ${GLIB_LDFLAGS}
99 ${GTK_LDFLAGS}
100 ${PANGO_LDFLAGS}
96 ${WNCK_LDFLAGS}101 ${WNCK_LDFLAGS}
97 ${GDK_LDFLAGS}102 ${GDK_LDFLAGS}
98 ${GIO_LDFLAGS}103 ${GIO_LDFLAGS}
99104
=== added file 'libunity-2d-private/src/debug.cpp'
--- libunity-2d-private/src/debug.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/debug.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,23 @@
1/* This file is part of unity-2d
2 Copyright 2011 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; version 3.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17// Self
18#include <debug_p.h>
19
20QDebug operator<<(QDebug& dbg, const std::string& str)
21{
22 return dbg << QString::fromUtf8(str.c_str());
23}
024
=== modified file 'libunity-2d-private/src/debug_p.h'
--- libunity-2d-private/src/debug_p.h 2011-03-28 14:06:14 +0000
+++ libunity-2d-private/src/debug_p.h 2011-08-04 16:31:58 +0000
@@ -17,8 +17,12 @@
17#ifndef DEBUG_P_H17#ifndef DEBUG_P_H
18#define DEBUG_P_H18#define DEBUG_P_H
1919
20// Qt
20#include <QDebug>21#include <QDebug>
2122
23// STL
24#include <string>
25
22#define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space()26#define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space()
2327
24// Simple macros to get KDebug like support28// Simple macros to get KDebug like support
@@ -62,5 +66,7 @@
6266
63#define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__)67#define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__)
6468
69// Support for outputing std::string with qDebug
70QDebug operator<<(QDebug& dbg, const std::string& str);
6571
66#endif /* DEBUG_P_H */72#endif /* DEBUG_P_H */
6773
=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
--- libunity-2d-private/src/launcherapplication.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/launcherapplication.cpp 2011-08-04 16:31:58 +0000
@@ -14,10 +14,6 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17/* Those have to be included before any QObject-style header to avoid
18 compilation errors. */
19#include <gdk/gdk.h>
20
21/* Note regarding the use of wnck: it is critically important that the client17/* Note regarding the use of wnck: it is critically important that the client
22 type be set to pager because wnck will pass that type over to the window18 type be set to pager because wnck will pass that type over to the window
23 manager through XEvents.19 manager through XEvents.
@@ -59,6 +55,7 @@
59#include <QX11Info>55#include <QX11Info>
6056
61extern "C" {57extern "C" {
58#include <gdk/gdk.h>
62#include <libsn/sn.h>59#include <libsn/sn.h>
63}60}
6461
@@ -649,7 +646,8 @@
649 GTimeVal timeval;646 GTimeVal timeval;
650647
651 g_get_current_time (&timeval);648 g_get_current_time (&timeval);
652 GObjectScopedPointer<GdkAppLaunchContext> context(gdk_app_launch_context_new());649 GdkDisplay* display = gdk_display_get_default();
650 GObjectScopedPointer<GdkAppLaunchContext> context(gdk_display_get_app_launch_context(display));
653 /* Using GDK_CURRENT_TIME doesn’t seem to work, launched windows651 /* Using GDK_CURRENT_TIME doesn’t seem to work, launched windows
654 sometimes don’t get focus (see https://launchpad.net/bugs/643616). */652 sometimes don’t get focus (see https://launchpad.net/bugs/643616). */
655 gdk_app_launch_context_set_timestamp(context.data(), timeval.tv_sec);653 gdk_app_launch_context_set_timestamp(context.data(), timeval.tv_sec);
@@ -880,7 +878,7 @@
880 QAction* keep = new QAction(m_menu);878 QAction* keep = new QAction(m_menu);
881 keep->setCheckable(is_running);879 keep->setCheckable(is_running);
882 keep->setChecked(sticky());880 keep->setChecked(sticky());
883 keep->setText(is_running ? u2dTr("Keep In Launcher") : u2dTr("Remove From Launcher"));881 keep->setText(is_running ? u2dTr("Keep in launcher") : u2dTr("Remove from launcher"));
884 actions.append(keep);882 actions.append(keep);
885 QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered()));883 QObject::connect(keep, SIGNAL(triggered()), this, SLOT(onKeepTriggered()));
886 }884 }
887885
=== modified file 'libunity-2d-private/src/launcherapplicationslist.cpp'
--- libunity-2d-private/src/launcherapplicationslist.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/launcherapplicationslist.cpp 2011-08-04 16:31:58 +0000
@@ -101,6 +101,17 @@
101 application->installX11EventFilter(this);101 application->installX11EventFilter(this);
102 }102 }
103103
104 /* Get the system applications data dirs and be flexible if / or not at the
105 end of each path. */
106 QString xdg_string = QFile::decodeName(getenv("XDG_DATA_DIRS"));
107 if (xdg_string.isEmpty())
108 xdg_string = "/usr/local/share/:/usr/share/";
109 xdg_string= xdg_string.replace(":", "/applications/:");
110 if (!xdg_string.endsWith(':'))
111 xdg_string = xdg_string.append("/applications/");
112 xdg_string = xdg_string.replace("//", "/");
113 m_xdg_data_dirs = xdg_string.split(':');
114
104 load();115 load();
105}116}
106117
@@ -180,7 +191,15 @@
180QString191QString
181LauncherApplicationsList::favoriteFromDesktopFilePath(QString desktop_file)192LauncherApplicationsList::favoriteFromDesktopFilePath(QString desktop_file)
182{193{
183 return QDir(desktop_file).dirName();194 Q_FOREACH(QString data_dir, m_xdg_data_dirs) {
195 if (desktop_file.startsWith(data_dir))
196 {
197 desktop_file = desktop_file.remove(data_dir);
198 desktop_file = desktop_file.replace("/", "-");
199 break;
200 }
201 }
202 return desktop_file;
184}203}
185204
186void205void
187206
=== modified file 'libunity-2d-private/src/launcherapplicationslist.h'
--- libunity-2d-private/src/launcherapplicationslist.h 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/launcherapplicationslist.h 2011-08-04 16:31:58 +0000
@@ -71,7 +71,7 @@
71 void insertApplication(LauncherApplication* application);71 void insertApplication(LauncherApplication* application);
72 void removeApplication(LauncherApplication* application);72 void removeApplication(LauncherApplication* application);
7373
74 static QString favoriteFromDesktopFilePath(QString desktop_file);74 QString favoriteFromDesktopFilePath(QString desktop_file);
7575
76 void writeFavoritesToGConf();76 void writeFavoritesToGConf();
7777
@@ -90,6 +90,7 @@
90 */90 */
91 QHash<QString, LauncherApplication*> m_applicationForExecutable;91 QHash<QString, LauncherApplication*> m_applicationForExecutable;
92 QConf* m_dconf_launcher;92 QConf* m_dconf_launcher;
93 QStringList m_xdg_data_dirs;
9394
94 /* Startup notification support */95 /* Startup notification support */
95 SnDisplay *m_snDisplay;96 SnDisplay *m_snDisplay;
9697
=== modified file 'libunity-2d-private/src/launchermenu.cpp'
--- libunity-2d-private/src/launchermenu.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/launchermenu.cpp 2011-08-04 16:31:58 +0000
@@ -96,6 +96,7 @@
96void96void
97LauncherContextualMenu::setTitle(const QString& title)97LauncherContextualMenu::setTitle(const QString& title)
98{98{
99 setAccessibleName(title);
99 m_title = title;100 m_title = title;
100 /* Escaping ampersands so that they are not considered as keyboard101 /* Escaping ampersands so that they are not considered as keyboard
101 accelerators. */102 accelerators. */
102103
=== modified file 'libunity-2d-private/src/screeninfo.cpp'
--- libunity-2d-private/src/screeninfo.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/screeninfo.cpp 2011-08-04 16:31:58 +0000
@@ -1,7 +1,5 @@
1extern "C" {1extern "C" {
2#include <libwnck/screen.h>2#include <libwnck/libwnck.h>
3#include <libwnck/window.h>
4#include <libwnck/workspace.h>
5}3}
64
7#include "bamf-matcher.h"5#include "bamf-matcher.h"
86
=== modified file 'libunity-2d-private/src/unity2dapplication.cpp'
--- libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 11:42:46 +0000
+++ libunity-2d-private/src/unity2dapplication.cpp 2011-08-04 16:31:58 +0000
@@ -25,14 +25,62 @@
2525
26// libunity-2d26// libunity-2d
27#include <debug_p.h>27#include <debug_p.h>
28#include <gconnector.h>
29#include <gscopedpointer.h>
28#include <unity2ddebug.h>30#include <unity2ddebug.h>
2931
30// Qt32// Qt
33#include <QFont>
31#include <QWindowsStyle>34#include <QWindowsStyle>
35#include <QAccessible>
36#include <QAccessibleWidget>
37#include <QWidget>
3238
33// GTK39// GTK
34#include <gtk/gtk.h>40#include <gtk/gtk.h>
3541#include <pango/pango.h>
42
43///////////////////////////////
44class PlatformFontTracker
45{
46public:
47 PlatformFontTracker()
48 {
49 m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-font-name",
50 G_CALLBACK(PlatformFontTracker::onFontChanged), this);
51
52 updateFont();
53 }
54
55private:
56 void updateFont()
57 {
58 gchar* fontName = 0;
59 g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontName, NULL);
60 GScopedPointer<PangoFontDescription, pango_font_description_free> fontDescription(
61 pango_font_description_from_string(fontName)
62 );
63 g_free(fontName);
64
65 int size = pango_font_description_get_size(fontDescription.data());
66
67 QFont font = QFont(
68 pango_font_description_get_family(fontDescription.data()),
69 size / PANGO_SCALE
70 );
71
72 QApplication::setFont(font);
73 }
74
75 static void onFontChanged(GObject*, GParamSpec*, PlatformFontTracker* obj)
76 {
77 obj->updateFont();
78 }
79
80 GConnector m_gConnector;
81};
82
83///////////////////////////////
36AbstractX11EventFilter::~AbstractX11EventFilter()84AbstractX11EventFilter::~AbstractX11EventFilter()
37{85{
38 Unity2dApplication* application = Unity2dApplication::instance();86 Unity2dApplication* application = Unity2dApplication::instance();
@@ -41,6 +89,28 @@
41 }89 }
42}90}
4391
92///////////////////////////////
93static bool arrayContains(char** begin, char** end, const char* string)
94{
95 for (char** ptr = begin; ptr != end; ++ptr) {
96 if (strcmp(*ptr, string) == 0) {
97 return true;
98 }
99 }
100 return false;
101}
102
103QAccessibleInterface *panelFactory(const QString &classname, QObject *object)
104{
105 QAccessibleInterface *interface = 0;
106
107 if (classname == "Unity2dPanel" && object && object->isWidgetType()) {
108 interface = new QAccessibleWidget(static_cast<QWidget *>(object), QAccessible::ToolBar);
109 }
110
111 return interface;
112}
113
44void Unity2dApplication::earlySetup(int& argc, char** argv)114void Unity2dApplication::earlySetup(int& argc, char** argv)
45{115{
46 // Parts of unity-2d uses GTK so it needs to be initialized116 // Parts of unity-2d uses GTK so it needs to be initialized
@@ -61,10 +131,19 @@
61 if(getenv("QT_GRAPHICSSYSTEM") == 0) {131 if(getenv("QT_GRAPHICSSYSTEM") == 0) {
62 QApplication::setGraphicsSystem("raster");132 QApplication::setGraphicsSystem("raster");
63 }133 }
134
135 /* Unless style has been specified in args, set default Qt style to
136 * QWindowStyle to avoid loading QGtkStyle. We don't want to load QGtkStyle
137 * because it uses libgtk2, which causes conflicts with our gtk3 code.
138 */
139 if (!arrayContains(argv, argv + argc, "-style")) {
140 QApplication::setStyle(new QWindowsStyle);
141 }
64}142}
65143
66Unity2dApplication::Unity2dApplication(int& argc, char** argv)144Unity2dApplication::Unity2dApplication(int& argc, char** argv)
67: QApplication(argc, argv)145: QApplication(argc, argv)
146, m_platformFontTracker(new PlatformFontTracker)
68{147{
69 /* Allow developers to run Unity 2D uninstalled by telling dconf-qt148 /* Allow developers to run Unity 2D uninstalled by telling dconf-qt
70 where to look for Unity 2D's schemas.149 where to look for Unity 2D's schemas.
@@ -73,11 +152,14 @@
73 if (!isRunningInstalled()) {152 if (!isRunningInstalled()) {
74 qputenv("GSETTINGS_SCHEMA_DIR", unity2dDirectory().toLocal8Bit() + "/data");153 qputenv("GSETTINGS_SCHEMA_DIR", unity2dDirectory().toLocal8Bit() + "/data");
75 }154 }
155
156 QAccessible::installFactory(panelFactory);
76}157}
77158
78Unity2dApplication::~Unity2dApplication()159Unity2dApplication::~Unity2dApplication()
79{160{
80 qDeleteAll(m_x11EventFilters);161 qDeleteAll(m_x11EventFilters);
162 delete m_platformFontTracker;
81}163}
82164
83Unity2dApplication* Unity2dApplication::instance()165Unity2dApplication* Unity2dApplication::instance()
84166
=== modified file 'libunity-2d-private/src/unity2dapplication.h'
--- libunity-2d-private/src/unity2dapplication.h 2011-07-18 13:47:29 +0000
+++ libunity-2d-private/src/unity2dapplication.h 2011-08-04 16:31:58 +0000
@@ -27,6 +27,8 @@
2727
28class Unity2dApplication;28class Unity2dApplication;
2929
30class PlatformFontTracker;
31
30class AbstractX11EventFilter32class AbstractX11EventFilter
31{33{
32public:34public:
@@ -65,6 +67,7 @@
6567
66private:68private:
67 QList<AbstractX11EventFilter*> m_x11EventFilters;69 QList<AbstractX11EventFilter*> m_x11EventFilters;
70 PlatformFontTracker* m_platformFontTracker;
68};71};
6972
70#endif // UNITY2DAPPLICATION_H73#endif // UNITY2DAPPLICATION_H
7174
=== modified file 'libunity-2d-private/src/windowinfo.cpp'
--- libunity-2d-private/src/windowinfo.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/windowinfo.cpp 2011-08-04 16:31:58 +0000
@@ -14,9 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include <libwnck/screen.h>17#include <libwnck/libwnck.h>
18#include <libwnck/window.h>
19#include <libwnck/workspace.h>
2018
21#include <glib-2.0/glib.h>19#include <glib-2.0/glib.h>
2220
2321
=== modified file 'libunity-2d-private/src/workspacesinfo.cpp'
--- libunity-2d-private/src/workspacesinfo.cpp 2011-07-29 13:49:34 +0000
+++ libunity-2d-private/src/workspacesinfo.cpp 2011-08-04 16:31:58 +0000
@@ -4,9 +4,7 @@
4#include <debug_p.h>4#include <debug_p.h>
55
6extern "C" {6extern "C" {
7#include <libwnck/screen.h>7#include <libwnck/libwnck.h>
8#include <libwnck/window.h>
9#include <libwnck/workspace.h>
10}8}
119
12#include <QAbstractEventDispatcher>10#include <QAbstractEventDispatcher>
1311
=== modified file 'panel/CMakeLists.txt'
--- panel/CMakeLists.txt 2011-06-27 13:40:51 +0000
+++ panel/CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -1,5 +1,8 @@
1project(unity-2d-panel)1project(unity-2d-panel)
22
3# Dependencies
4pkg_check_modules(UNITYCORE REQUIRED unity-core-4.0)
5
3# Source6# Source
4include_directories(7include_directories(
5 ${libunity-2d-private_SOURCE_DIR}/src8 ${libunity-2d-private_SOURCE_DIR}/src
@@ -8,8 +11,3 @@
8add_subdirectory(applets)11add_subdirectory(applets)
9add_subdirectory(app)12add_subdirectory(app)
10add_subdirectory(tests)13add_subdirectory(tests)
11
12# Install
13install(DIRECTORY artwork
14 DESTINATION ${UNITY_2D_DIR}/panel
15 )
1614
=== modified file 'panel/app/CMakeLists.txt'
--- panel/app/CMakeLists.txt 2011-04-04 16:41:15 +0000
+++ panel/app/CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -1,7 +1,6 @@
1set(panel_SRCS1set(panel_SRCS
2 main.cpp2 main.cpp
3 panelmanager.cpp3 panelmanager.cpp
4 unity2dstyle.cpp
5 )4 )
65
7qt4_automoc(${panel_SRCS})6qt4_automoc(${panel_SRCS})
@@ -10,14 +9,17 @@
10include_directories(9include_directories(
11 ${CMAKE_CURRENT_BINARY_DIR}10 ${CMAKE_CURRENT_BINARY_DIR}
12 ${CMAKE_CURRENT_SOURCE_DIR}11 ${CMAKE_CURRENT_SOURCE_DIR}
12 ${GTK_INCLUDE_DIRS}
13 ${uqapplets_SOURCE_DIR}13 ${uqapplets_SOURCE_DIR}
14 ${uqapplets_SOURCE_DIR}/common14 ${uqapplets_SOURCE_DIR}/common
15 ${UNITYCORE_INCLUDE_DIRS}
15 ${libunity-2d-private_SOURCE_DIR}/src16 ${libunity-2d-private_SOURCE_DIR}/src
16 )17 )
1718
18target_link_libraries(unity-2d-panel19target_link_libraries(unity-2d-panel
19 ${QT_QTGUI_LIBRARIES}20 ${QT_QTGUI_LIBRARIES}
20 ${QT_QTCORE_LIBRARIES}21 ${QT_QTCORE_LIBRARIES}
22 ${GTK_LDFLAGS}
21 uqapplets23 uqapplets
22 unity-2d-private24 unity-2d-private
23 )25 )
2426
=== modified file 'panel/app/main.cpp'
--- panel/app/main.cpp 2011-07-18 13:47:29 +0000
+++ panel/app/main.cpp 2011-08-04 16:31:58 +0000
@@ -22,12 +22,12 @@
22// Local22// Local
23#include <config.h>23#include <config.h>
24#include <panelmanager.h>24#include <panelmanager.h>
25#include <panelstyle.h>
2526
26// Unity27// Unity
27#include <gnomesessionclient.h>28#include <gnomesessionclient.h>
28#include <unity2ddebug.h>29#include <unity2ddebug.h>
29#include <unity2dapplication.h>30#include <unity2dapplication.h>
30#include <unity2dstyle.h>
31#include <unity2dtr.h>31#include <unity2dtr.h>
3232
33// Qt33// Qt
@@ -54,7 +54,10 @@
54 ThemeEngineHandler handler;54 ThemeEngineHandler handler;
55 Unity2dApplication::earlySetup(argc, argv);55 Unity2dApplication::earlySetup(argc, argv);
56 Unity2dApplication app(argc, argv);56 Unity2dApplication app(argc, argv);
57 QApplication::setStyle(new Unity2dStyle);57 app.setApplicationName("Unity 2D Panel");
58
59 // Instantiate a PanelStyle so that it configures QApplication
60 PanelStyle::instance();
5861
59 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop");62 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop");
60 client.connectToSessionManager();63 client.connectToSessionManager();
6164
=== modified file 'panel/app/panelmanager.cpp'
--- panel/app/panelmanager.cpp 2011-06-12 23:01:35 +0000
+++ panel/app/panelmanager.cpp 2011-08-04 16:31:58 +0000
@@ -24,6 +24,8 @@
2424
25// Local25// Local
26#include <config.h>26#include <config.h>
27#include <panelstyle.h>
28#include <indicatorsmanager.h>
2729
28// Applets30// Applets
29#include <appindicator/appindicatorapplet.h>31#include <appindicator/appindicatorapplet.h>
@@ -42,70 +44,56 @@
4244
43using namespace Unity2d;45using namespace Unity2d;
4446
45static QPalette getPalette()47static QWidget* createSeparator()
46{48{
47 QPalette palette;49 // Just a quick-hack: homebutton is going away anyway
4850 QWidget* widget = new QWidget;
49 /* Should use the panel's background provided by Unity but it turns51 widget->setFixedWidth(6);
50 out not to be good. It would look like:52 return widget;
5153}
52 QBrush bg(QPixmap("theme:/panel_background.png"));54
53 */55PanelManager::PanelManager(QObject* parent)
54 QBrush bg(QPixmap(unity2dDirectory() + "/panel/artwork/background.png"));56: QObject(parent)
55 palette.setBrush(QPalette::Window, bg);57{
56 palette.setBrush(QPalette::Button, bg);58 QDesktopWidget* desktop = QApplication::desktop();
57 return palette;59 for(int i = 0; i < desktop->screenCount(); ++i) {
58}60 Unity2dPanel* panel = instantiatePanel(i);
5961 m_panels.append(panel);
60static QLabel* createSeparator()62 panel->show();
61{63 panel->move(desktop->screenGeometry(i).topLeft());
62 QLabel* label = new QLabel;64 }
63 QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png");65 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
64 label->setPixmap(pix);66}
65 label->setFixedSize(pix.size());67
66 return label;68PanelManager::~PanelManager()
67}69{
6870 qDeleteAll(m_panels);
69static Unity2dPanel* instantiatePanel(int screen)71}
72
73Unity2dPanel* PanelManager::instantiatePanel(int screen)
70{74{
71 Unity2dPanel* panel = new Unity2dPanel;75 Unity2dPanel* panel = new Unity2dPanel;
76 panel->setAccessibleName("Top Panel");
72 panel->setEdge(Unity2dPanel::TopEdge);77 panel->setEdge(Unity2dPanel::TopEdge);
73 panel->setPalette(getPalette());
74 panel->setFixedHeight(24);78 panel->setFixedHeight(24);
7579
80 IndicatorsManager* indicatorsManager = new IndicatorsManager(panel);
81
76 int leftmost = QApplication::desktop()->screenNumber(QPoint());82 int leftmost = QApplication::desktop()->screenNumber(QPoint());
77 if (screen == leftmost) {83 if (screen == leftmost) {
78 panel->addWidget(new HomeButtonApplet);84 panel->addWidget(new HomeButtonApplet);
79 panel->addWidget(createSeparator());85 panel->addWidget(createSeparator());
80 }86 }
81 panel->addWidget(new AppNameApplet);87 panel->addWidget(new AppNameApplet(indicatorsManager));
82 if (screen == leftmost) {88 if (screen == leftmost) {
83 /* It doesn’t make sense to have more than one instance of the systray,89 /* It doesn’t make sense to have more than one instance of the systray,
84 XEmbed’ed windows can be displayed only once anyway. */90 XEmbed’ed windows can be displayed only once anyway. */
85 panel->addWidget(new LegacyTrayApplet);91 panel->addWidget(new LegacyTrayApplet);
86 }92 }
87 panel->addWidget(new IndicatorApplet);93 panel->addWidget(new IndicatorApplet(indicatorsManager));
88 return panel;94 return panel;
89}95}
9096
91PanelManager::PanelManager(QObject* parent)
92 : QObject(parent)
93{
94 QDesktopWidget* desktop = QApplication::desktop();
95 for(int i = 0; i < desktop->screenCount(); ++i) {
96 Unity2dPanel* panel = instantiatePanel(i);
97 m_panels.append(panel);
98 panel->show();
99 panel->move(desktop->screenGeometry(i).topLeft());
100 }
101 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
102}
103
104PanelManager::~PanelManager()
105{
106 qDeleteAll(m_panels);
107}
108
109void97void
110PanelManager::onScreenCountChanged(int newCount)98PanelManager::onScreenCountChanged(int newCount)
111{99{
112100
=== modified file 'panel/app/panelmanager.h'
--- panel/app/panelmanager.h 2011-04-04 16:41:15 +0000
+++ panel/app/panelmanager.h 2011-08-04 16:31:58 +0000
@@ -40,6 +40,8 @@
40 Q_DISABLE_COPY(PanelManager)40 Q_DISABLE_COPY(PanelManager)
41 QList<Unity2dPanel*> m_panels;41 QList<Unity2dPanel*> m_panels;
4242
43 Unity2dPanel* instantiatePanel(int screen);
44
43private Q_SLOTS:45private Q_SLOTS:
44 void onScreenCountChanged(int newCount);46 void onScreenCountChanged(int newCount);
45};47};
4648
=== removed file 'panel/app/unity2dstyle.cpp'
--- panel/app/unity2dstyle.cpp 2011-03-28 12:16:02 +0000
+++ panel/app/unity2dstyle.cpp 1970-01-01 00:00:00 +0000
@@ -1,98 +0,0 @@
1/*
2 * Plasma applet to display DBus global menu
3 *
4 * Copyright 2009 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
20 */
21
22// Self
23#include "unity2dstyle.h"
24
25// Local
26
27// libunity-2d-private
28#include <debug_p.h>
29#include <keyboardmodifiersmonitor.h>
30
31// Qt
32#include <QGtkStyle>
33#include <QMenu>
34#include <QPainter>
35#include <QStyleOptionFrame>
36#include <QWidget>
37
38Unity2dStyle::Unity2dStyle()
39: QProxyStyle(new QGtkStyle)
40{
41}
42
43void Unity2dStyle::drawControl(QStyle::ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
44{
45 if (element == QStyle::CE_MenuBarItem && widget) {
46 QStyleOptionMenuItem opt = *qstyleoption_cast<const QStyleOptionMenuItem*>(option);
47 if (!(opt.state & QStyle::State_Enabled) && (opt.state & QStyle::State_Sunken)) {
48 // Reset State_Sunken flag to avoid drawing a frame on a disabled menu item
49 // See https://bugs.launchpad.net/unity-2d/+bug/717744
50 opt.state ^= QStyle::State_Sunken;
51 }
52 // Skip "widget" parameter to avoid solid gray background behind the menubar items
53 QProxyStyle::drawControl(element, &opt, painter, 0);
54 } else if (element == QStyle::CE_MenuBarEmptyArea) {
55 // Avoid gray borders around the menubar items
56 } else {
57 QProxyStyle::drawControl(element, option, painter, widget);
58 }
59}
60
61int Unity2dStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option, const QWidget* widget) const
62{
63 if (metric == QStyle::PM_MenuBarVMargin) {
64 // Avoid one-pixel gap above menuitem
65 return 0;
66 } else {
67 return QProxyStyle::pixelMetric(metric, option, widget);
68 }
69}
70
71QSize Unity2dStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const
72{
73 QSize size = QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
74 if (type == QStyle::CT_MenuBarItem && widget) {
75 // Avoid three-pixel gap below menuitem
76 size.setHeight(widget->height());
77 }
78 return size;
79}
80
81int Unity2dStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const
82{
83 if (hint == QStyle::SH_UnderlineShortcut) {
84 // The shortcut of an opened menu can be triggered without holding Alt
85 // down, so we always show the underline. For all other widgets we only
86 // show the underlines if alt is down.
87 // Note that this is a bit hackish: it only works reliably if the
88 // widget repaints itself when alt is pressed or released. For now only
89 // the MenuBarWidget from the AppNameApplets does this.
90 if (qobject_cast<const QMenu*>(widget)) {
91 return true;
92 } else {
93 return KeyboardModifiersMonitor::instance()->keyboardModifiers() == Qt::AltModifier;
94 }
95 } else {
96 return QProxyStyle::styleHint(hint, option, widget, returnData);
97 }
98}
990
=== removed file 'panel/app/unity2dstyle.h'
--- panel/app/unity2dstyle.h 2011-01-26 15:50:26 +0000
+++ panel/app/unity2dstyle.h 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
20 */
21
22#ifndef UNITY2DSTYLE_H
23#define UNITY2DSTYLE_H
24
25// Local
26
27// Qt
28#include <QProxyStyle>
29
30class Unity2dStyle : public QProxyStyle
31{
32public:
33 Unity2dStyle();
34
35 virtual void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const;
36
37 virtual int pixelMetric(PixelMetric metric, const QStyleOption* option = 0, const QWidget* widget = 0) const;
38
39 virtual QSize sizeFromContents(ContentsType type, const QStyleOption* option, const QSize& contentsSize, const QWidget* widget = 0) const;
40
41 virtual int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const;
42};
43
44#endif /* UNITY2DSTYLE_H */
450
=== modified file 'panel/applets/CMakeLists.txt'
--- panel/applets/CMakeLists.txt 2011-07-18 10:33:35 +0000
+++ panel/applets/CMakeLists.txt 2011-08-04 16:31:58 +0000
@@ -1,42 +1,28 @@
1project(uqapplets)1project(uqapplets)
22
3macro(read_pkg_variable cmake_var pkg pkg_var)
4 execute_process(
5 COMMAND pkg-config --variable=${pkg_var} ${pkg}
6 OUTPUT_VARIABLE tmp
7 )
8 # Remove trailing newline from ${tmp}
9 string(STRIP "${tmp}" ${cmake_var})
10endmacro(read_pkg_variable)
11
12# Dependencies3# Dependencies
13include(FindPkgConfig)4include(FindPkgConfig)
145
15pkg_check_modules(QTBAMF REQUIRED libqtbamf)6pkg_check_modules(QTBAMF REQUIRED libqtbamf)
16pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)7pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
17pkg_check_modules(INDICATOR REQUIRED indicator)
18
19# Get indicator dirs from pkgconfig
20read_pkg_variable(INDICATOR_DIR indicator indicatordir)
21read_pkg_variable(INDICATOR_ICONS_DIR indicator iconsdir)
22configure_file(indicator-config.h.in indicator-config.h)
238
24# Sources9# Sources
25set(uqapplets_SRCS10set(uqapplets_SRCS
26 appindicator/appindicatorapplet.cpp11 appindicator/appindicatorapplet.cpp
27 appindicator/sniitem.cpp12 appindicator/sniitem.cpp
28 appname/appnameapplet.cpp13 appname/appnameapplet.cpp
14 appname/croppedlabel.cpp
29 appname/menubarwidget.cpp15 appname/menubarwidget.cpp
30 appname/registrar.cpp
31 appname/windowhelper.cpp16 appname/windowhelper.cpp
32 common/applet.cpp17 common/applet.cpp
18 common/indicatorentrywidget.cpp
19 common/indicatorsmanager.cpp
20 common/indicatorwidget.cpp
21 common/cairoutils.cpp
22 common/panelstyle.cpp
33 homebutton/homebuttonapplet.cpp23 homebutton/homebuttonapplet.cpp
34 homebutton/homebutton.cpp24 homebutton/homebutton.cpp
35 indicator/abstractindicator.cpp
36 indicator/datetimeindicator.cpp
37 indicator/indicatorapplet.cpp25 indicator/indicatorapplet.cpp
38 indicator/indicatorservicemanager.cpp
39 indicator/indicator.c
40 legacytray/legacytrayapplet.cpp26 legacytray/legacytrayapplet.cpp
41 legacytray/fdoselectionmanager.cpp27 legacytray/fdoselectionmanager.cpp
42 legacytray/fdotask.cpp28 legacytray/fdotask.cpp
@@ -45,10 +31,6 @@
45 legacytray/x11embedpainter.cpp31 legacytray/x11embedpainter.cpp
46 )32 )
4733
48qt4_add_dbus_adaptor(uqapplets_SRCS appname/com.canonical.AppMenu.Registrar.xml
49 registrar.h Registrar
50 )
51
52qt4_automoc(${uqapplets_SRCS})34qt4_automoc(${uqapplets_SRCS})
5335
54# Build36# Build
@@ -58,13 +40,17 @@
58 ${CMAKE_CURRENT_SOURCE_DIR}/common40 ${CMAKE_CURRENT_SOURCE_DIR}/common
59 ${CMAKE_CURRENT_SOURCE_DIR}/homebutton41 ${CMAKE_CURRENT_SOURCE_DIR}/homebutton
60 ${CMAKE_CURRENT_SOURCE_DIR}/indicator42 ${CMAKE_CURRENT_SOURCE_DIR}/indicator
43 ${CMAKE_CURRENT_SOURCE_DIR}/unitycore
61 ${QTBAMF_INCLUDE_DIRS}44 ${QTBAMF_INCLUDE_DIRS}
45 ${QTGCONF_INCLUDE_DIRS}
62 ${DBUSMENUQT_INCLUDE_DIRS}46 ${DBUSMENUQT_INCLUDE_DIRS}
63 ${GTK_INCLUDE_DIRS}47 ${GTK_INCLUDE_DIRS}
64 ${INDICATOR_INCLUDE_DIRS}
65 ${WNCK_INCLUDE_DIRS}48 ${WNCK_INCLUDE_DIRS}
66 ${CMAKE_CURRENT_BINARY_DIR}49 ${CMAKE_CURRENT_BINARY_DIR}
67 ${X11_INCLUDE_DIR}50 ${X11_INCLUDE_DIR}
51 ${UNITYCORE_INCLUDE_DIRS}
52 ${NUXCORE_INCLUDE_DIRS}
53 ${PANGO_INCLUDE_DIRS}
68 ${libunity-2d-private_SOURCE_DIR}/src54 ${libunity-2d-private_SOURCE_DIR}/src
69 )55 )
7056
@@ -75,13 +61,16 @@
75 ${QT_QTCORE_LIBRARIES}61 ${QT_QTCORE_LIBRARIES}
76 ${DBUSMENUQT_LDFLAGS}62 ${DBUSMENUQT_LDFLAGS}
77 ${QTBAMF_LDFLAGS}63 ${QTBAMF_LDFLAGS}
64 ${QTGCONF_LDFLAGS}
78 ${GTK_LDFLAGS}65 ${GTK_LDFLAGS}
79 ${INDICATOR_LDFLAGS}
80 ${WNCK_LDFLAGS}66 ${WNCK_LDFLAGS}
81 ${X11_LIBRARIES}67 ${X11_LIBRARIES}
82 ${X11_Xrender_LIB}68 ${X11_Xrender_LIB}
83 ${X11_Xcomposite_LIB}69 ${X11_Xcomposite_LIB}
84 ${X11_Xdamage_LIB}70 ${X11_Xdamage_LIB}
85 ${X11_Xfixes_LIB}71 ${X11_Xfixes_LIB}
72 ${UNITYCORE_LDFLAGS}
73 ${NUXCORE_LDFLAGS}
74 ${PANGO_LDFLAGS}
86 unity-2d-private75 unity-2d-private
87 )76 )
8877
=== modified file 'panel/applets/appname/appnameapplet.cpp'
--- panel/applets/appname/appnameapplet.cpp 2011-07-26 09:36:41 +0000
+++ panel/applets/appname/appnameapplet.cpp 2011-08-04 16:31:58 +0000
@@ -23,6 +23,7 @@
23#include "appnameapplet.h"23#include "appnameapplet.h"
2424
25// Local25// Local
26#include "croppedlabel.h"
26#include "menubarwidget.h"27#include "menubarwidget.h"
27#include "windowhelper.h"28#include "windowhelper.h"
2829
@@ -49,9 +50,7 @@
4950
50static const int WINDOW_BUTTONS_RIGHT_MARGIN = 4;51static const int WINDOW_BUTTONS_RIGHT_MARGIN = 4;
5152
52static const int APPNAME_LABEL_LEFT_MARGIN = 12;53static const int APPNAME_LABEL_LEFT_MARGIN = 6;
53
54static const int FADEOUT_WIDTH = 16;
5554
56namespace Unity2d55namespace Unity2d
57{56{
@@ -106,50 +105,6 @@
106 }105 }
107};106};
108107
109/**
110 * This label makes sure minimumSizeHint() is not set. This ensures the applet
111 * does not get wider if a window title is very long
112 */
113class CroppedLabel : public QLabel
114{
115public:
116 CroppedLabel(QWidget* parent = 0)
117 : QLabel(parent)
118 {}
119
120 QSize minimumSizeHint() const
121 {
122 return QWidget::minimumSizeHint();
123 }
124
125protected:
126 void paintEvent(QPaintEvent* event)
127 {
128 QImage image(width(), height(), QImage::Format_ARGB32_Premultiplied);
129 {
130 QPainter painter(&image);
131 painter.initFrom(this);
132 painter.setCompositionMode(QPainter::CompositionMode_Source);
133 painter.fillRect(rect(), Qt::transparent);
134
135 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
136 painter.drawText(contentsRect(), Qt::AlignLeft | Qt::AlignVCenter, text());
137
138 if (QLabel::minimumSizeHint().width() > contentsRect().width()) {
139 // Text does not fit, fade the end
140 painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
141 QRect gradientRect(width() - FADEOUT_WIDTH, 0, FADEOUT_WIDTH, height());
142 QLinearGradient gradient(gradientRect.topLeft(), gradientRect.topRight());
143 gradient.setColorAt(0, Qt::white);
144 gradient.setColorAt(1, Qt::transparent);
145 painter.fillRect(gradientRect, gradient);
146 }
147 }
148 QPainter painter(this);
149 painter.drawImage(0, 0, image);
150 }
151};
152
153struct AppNameAppletPrivate108struct AppNameAppletPrivate
154{109{
155 AppNameApplet* q;110 AppNameApplet* q;
@@ -200,10 +155,10 @@
200 q, SLOT(updateWidgets()));155 q, SLOT(updateWidgets()));
201 }156 }
202157
203 void setupMenuBarWidget()158 void setupMenuBarWidget(IndicatorsManager* manager)
204 {159 {
205 m_menuBarWidget = new MenuBarWidget(0 /* Window menu */);160 m_menuBarWidget = new MenuBarWidget(manager);
206 QObject::connect(m_menuBarWidget, SIGNAL(menuBarClosed()),161 QObject::connect(m_menuBarWidget, SIGNAL(isOpenedChanged()),
207 q, SLOT(updateWidgets()));162 q, SLOT(updateWidgets()));
208 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),163 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),
209 q, SLOT(updateWidgets()));164 q, SLOT(updateWidgets()));
@@ -216,21 +171,16 @@
216 }171 }
217};172};
218173
219AppNameApplet::AppNameApplet()174AppNameApplet::AppNameApplet(IndicatorsManager* indicatorsManager)
220: d(new AppNameAppletPrivate)175: d(new AppNameAppletPrivate)
221{176{
222 d->q = this;177 d->q = this;
223 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);178 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
224179
225 QPalette palette;
226 palette.setColor(QPalette::WindowText, Qt::white);
227 palette.setColor(QPalette::ButtonText, Qt::white);
228 setPalette(palette);
229
230 d->setupWindowHelper();180 d->setupWindowHelper();
231 d->setupLabel();181 d->setupLabel();
232 d->setupWindowButtonWidget();182 d->setupWindowButtonWidget();
233 d->setupMenuBarWidget();183 d->setupMenuBarWidget(indicatorsManager);
234 d->setupKeyboardModifiersMonitor();184 d->setupKeyboardModifiersMonitor();
235185
236 QHBoxLayout* layout = new QHBoxLayout(this);186 QHBoxLayout* layout = new QHBoxLayout(this);
237187
=== modified file 'panel/applets/appname/appnameapplet.h'
--- panel/applets/appname/appnameapplet.h 2011-06-06 09:06:55 +0000
+++ panel/applets/appname/appnameapplet.h 2011-08-04 16:31:58 +0000
@@ -29,6 +29,8 @@
2929
30class QEvent;30class QEvent;
3131
32class IndicatorsManager;
33
32namespace Unity2d34namespace Unity2d
33{35{
3436
@@ -37,7 +39,7 @@
37{39{
38Q_OBJECT40Q_OBJECT
39public:41public:
40 AppNameApplet();42 AppNameApplet(IndicatorsManager*);
41 ~AppNameApplet();43 ~AppNameApplet();
4244
43protected:45protected:
4446
=== removed file 'panel/applets/appname/com.canonical.AppMenu.Registrar.xml'
--- panel/applets/appname/com.canonical.AppMenu.Registrar.xml 2011-02-10 01:10:19 +0000
+++ panel/applets/appname/com.canonical.AppMenu.Registrar.xml 1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
3 <dox:d><![CDATA[
4 @mainpage
5  
6 An interface to register menus that are associated with a window in an application.  The
7 main interface is docuemented here: @ref com::canonical::AppMenu::Registrar.
8     
9 The actual menus are transported using the dbusmenu protocol which is available
10 here: @ref com::canonical::dbusmenu.
11 ]]></dox:d>
12 <interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
13 <dox:d>
14 An interface to register a menu from an application's window to be displayed in another
15 window.  This manages that association between XWindow Window IDs and the dbus
16 address and object that provides the menu using the dbusmenu dbus interface.
17 </dox:d>
18 <method name="RegisterWindow">
19 <dox:d><![CDATA[
20 Associates a dbusmenu with a window
21      
22 /note this method assumes that the connection from the caller is the DBus connection
23 to use for the object.  Applications that use multiple DBus connections will need to
24 ensure this method is called with the same connection that implmenets the object.
25 ]]></dox:d>
26 <arg name="windowId" type="u" direction="in">
27 <dox:d>The XWindow ID of the window</dox:d>
28 </arg>
29 <arg name="menuObjectPath" type="o" direction="in">
30 <dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d>
31 </arg>
32 </method>
33 <method name="UnregisterWindow">
34 <dox:d>
35 A method to allow removing a window from the database. Windows will also be removed
36 when the client drops off DBus so this is not required. It is polite though. And
37 important for testing.
38 </dox:d>
39 <arg name="windowId" type="u" direction="in">
40 <dox:d>The XWindow ID of the window</dox:d>
41 </arg>
42 </method>
43 <method name="GetMenuForWindow">
44 <dox:d>Gets the registered menu for a given window ID.</dox:d>
45 <arg name="windowId" type="u" direction="in">
46 <dox:d>The XWindow ID of the window to get</dox:d>
47 </arg>
48 <arg name="service" type="s" direction="out">
49 <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
50 </arg>
51 <arg name="menuObjectPath" type="o" direction="out">
52 <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
53 </arg>
54 </method>
55 <method name="GetMenus">
56 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MenuInfoList"/>
57 <dox:d>Gets the information on all menus that the registrar knows about. This
58 is useful for debugging or bringing up a new renderer.</dox:d>
59 <arg name="menus" type="a(uso)" direction="out">
60 <dox:d>An array of structures containing the same parameters as @GetMenuForWindow. Window ID, Service and ObjectPath.</dox:d>
61 </arg>
62 </method>
63 <signal name="WindowRegistered">
64 <dox:d>Signals when the registrar gets a new menu registered</dox:d>
65 <arg name="windowId" type="u" direction="out">
66 <dox:d>The XWindow ID of the window</dox:d>
67 </arg>
68 <arg name="service" type="s" direction="out">
69 <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
70 </arg>
71 <arg name="menuObjectPath" type="o" direction="out">
72 <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
73 </arg>
74 </signal>
75 <signal name="WindowUnregistered">
76 <dox:d>Signals when the registrar removes a menu registration</dox:d>
77 <arg name="windowId" type="u" direction="out">
78 <dox:d>The XWindow ID of the window</dox:d>
79 </arg>
80 </signal>
81 </interface>
82</node>
830
=== added file 'panel/applets/appname/croppedlabel.cpp'
--- panel/applets/appname/croppedlabel.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/appname/croppedlabel.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,140 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "croppedlabel.h"
23
24// Local
25#include <cairoutils.h>
26#include <panelstyle.h>
27
28// unity-2d
29#include <debug_p.h>
30
31// libqtgconf
32#include <gconfitem-qml-wrapper.h>
33
34// Qt
35#include <QImage>
36#include <QPainter>
37
38// GTK
39#include <gtk/gtk.h>
40
41static const int FADEOUT_WIDTH = 30;
42
43static const char* WINDOW_TITLE_FONT_KEY = "/apps/metacity/general/titlebar_font";
44
45CroppedLabel::CroppedLabel(QWidget* parent)
46: QLabel(parent)
47{
48}
49
50QSize CroppedLabel::minimumSizeHint() const
51{
52 return QWidget::minimumSizeHint();
53}
54
55static void paintFadeoutGradient(QImage* image)
56{
57 QPainter painter(image);
58 painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
59 QRect gradientRect(image->width() - FADEOUT_WIDTH, 0, FADEOUT_WIDTH, image->height());
60 QLinearGradient gradient(gradientRect.topLeft(), gradientRect.topRight());
61 gradient.setColorAt(0, Qt::white);
62 gradient.setColorAt(1, Qt::transparent);
63 painter.fillRect(gradientRect, gradient);
64}
65
66static QString getWindowTitleFontName()
67{
68 GConfItemQmlWrapper client;
69 client.setKey(WINDOW_TITLE_FONT_KEY);
70 return client.getValue().toString();
71}
72
73void CroppedLabel::paintEvent(QPaintEvent* event)
74{
75 // Create an image filled with background brush (to avoid subpixel hinting
76 // artefacts around text)
77 QImage image(width(), height(), QImage::Format_ARGB32_Premultiplied);
78 {
79 QPainter painter(&image);
80 painter.initFrom(this);
81 painter.eraseRect(rect());
82 }
83
84 // Create a pango layout
85 GObjectScopedPointer<PangoContext> pangoContext(gdk_pango_context_get());
86 GObjectScopedPointer<PangoLayout> layout(pango_layout_new(pangoContext.data()));
87
88 // Set font
89 QByteArray fontName = getWindowTitleFontName().toUtf8();
90 PangoFontDescription* desc = pango_font_description_from_string(fontName.data());
91 pango_layout_set_font_description(layout.data(), desc);
92 pango_font_description_free(desc);
93
94 // Set text
95 QByteArray utf8Text = text().toUtf8();
96 pango_layout_set_text (layout.data(), utf8Text.data(), -1);
97
98 // Get text size
99 int textWidth = 0;
100 int textHeight = 0;
101 pango_layout_get_pixel_size(layout.data(), &textWidth, &textHeight);
102
103 // Draw text
104 CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(&image));
105 CairoUtils::Pointer cr(cairo_create(surface.data()));
106
107 PanelStyle* style = PanelStyle::instance();
108 GtkStyleContext* style_context = style->styleContext();
109
110 gtk_style_context_save(style_context);
111
112 GtkWidgetPath* widget_path = gtk_widget_path_new();
113 gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR);
114 gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM);
115 gtk_widget_path_iter_set_name(widget_path, -1 , "UnityPanelWidget");
116
117 gtk_style_context_set_path(style_context, widget_path);
118 gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR);
119 gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM);
120
121 gtk_render_layout(style_context, cr.data(),
122 contentsRect().left(),
123 contentsRect().top() + (height() - textHeight) / 2,
124 layout.data());
125
126 gtk_widget_path_free(widget_path);
127
128 gtk_style_context_restore(style_context);
129
130 // Fade if necessary
131 if (textWidth > contentsRect().width()) {
132 paintFadeoutGradient(&image);
133 }
134
135 // Paint on our widget
136 QPainter painter(this);
137 painter.drawImage(0, 0, image);
138}
139
140#include "croppedlabel.moc"
0141
=== added file 'panel/applets/appname/croppedlabel.h'
--- panel/applets/appname/croppedlabel.h 1970-01-01 00:00:00 +0000
+++ panel/applets/appname/croppedlabel.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,45 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef CROPPEDLABEL_H
22#define CROPPEDLABEL_H
23
24// Local
25
26// Qt
27#include <QLabel>
28
29/**
30 * This label makes sure minimumSizeHint() is not set. This ensures the applet
31 * does not get wider if a window title is very long
32 */
33class CroppedLabel : public QLabel
34{
35 Q_OBJECT
36public:
37 CroppedLabel(QWidget* parent = 0);
38
39 QSize minimumSizeHint() const;
40
41protected:
42 void paintEvent(QPaintEvent*);
43};
44
45#endif /* CROPPEDLABEL_H */
046
=== modified file 'panel/applets/appname/menubarwidget.cpp'
--- panel/applets/appname/menubarwidget.cpp 2011-07-26 09:36:41 +0000
+++ panel/applets/appname/menubarwidget.cpp 2011-08-04 16:31:58 +0000
@@ -20,299 +20,98 @@
20 */20 */
2121
22// Self22// Self
23#include "menubarwidget.h"23#include <menubarwidget.h>
2424
25// Local25// Local
26#include "config.h"26#include <debug_p.h>
27#include "debug_p.h"27#include <indicatorentrywidget.h>
28#include "keyboardmodifiersmonitor.h"28#include <indicatorsmanager.h>
29#include "registrar.h"
30
31// dbusmenu-qt
32#include <dbusmenuimporter.h>
33
34// bamf
35#include <bamf-matcher.h>
36#include <bamf-window.h>
3729
38// Qt30// Qt
39#include <QActionEvent>
40#include <QHBoxLayout>31#include <QHBoxLayout>
41#include <QLabel>32
42#include <QMenuBar>33static const int MENU_ITEM_PADDING = 6;
43#include <QTimer>34
4435MenuBarWidget::MenuBarWidget(IndicatorsManager* indicatorsManager, QWidget* parent)
45class MyDBusMenuImporter : public DBusMenuImporter
46{
47public:
48 MyDBusMenuImporter(const QString &service, const QString &path, QObject *parent)
49 : DBusMenuImporter(service, path, parent)
50 , m_service(service)
51 , m_path(path)
52 {}
53
54 QString service() const { return m_service; }
55 QString path() const { return m_path; }
56
57private:
58 QString m_service;
59 QString m_path;
60};
61
62MenuBarWidget::MenuBarWidget(QMenu* windowMenu, QWidget* parent)
63: QWidget(parent)36: QWidget(parent)
64, m_windowMenu(windowMenu)37, m_indicatorsManager(indicatorsManager)
65{38, m_layout(new QHBoxLayout(this))
66 m_activeWinId = 0;39, m_isEmpty(true)
67 setupRegistrar();40, m_isOpened(false)
68 setupMenuBar();41{
6942 m_layout->setMargin(0);
70 connect(&BamfMatcher::get_default(), SIGNAL(ActiveWindowChanged(BamfWindow*, BamfWindow*)),43 m_layout->setSpacing(0);
71 SLOT(slotActiveWindowChanged(BamfWindow*, BamfWindow*)));44 indicatorsManager->indicators()->on_object_added.connect(
72 /* Work around a bug in BAMF: the ActiveWindowChanged signal is not emitted45 sigc::mem_fun(this, &MenuBarWidget::onObjectAdded)
73 for some windows that open maximized. This is for example the case of the46 );
74 LibreOffice startcenter. */47 indicatorsManager->indicators()->on_entry_activated.connect(
75 connect(&BamfMatcher::get_default(), SIGNAL(ViewOpened(BamfView*)),48 sigc::mem_fun(this, &MenuBarWidget::onEntryActivated)
76 SLOT(slotViewOpened()));49 );
77 updateActiveWinId(BamfMatcher::get_default().active_window());50 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
78}51 m_layout->addStretch();
79
80void MenuBarWidget::setupRegistrar()
81{
82 m_registrar = Registrar::instance();
83 if (!m_registrar->connectToBus()) {
84 UQ_WARNING << "could not connect registrar to DBus";
85 }
86
87 connect(m_registrar, SIGNAL(WindowRegistered(WId, const QString&, const QDBusObjectPath&)),
88 SLOT(slotWindowRegistered(WId, const QString&, const QDBusObjectPath&)));
89 connect(m_registrar, SIGNAL(WindowUnregistered(WId)),
90 SLOT(slotWindowUnregistered(WId)));
91}
92
93void MenuBarWidget::setupMenuBar()
94{
95 m_menuBar = new QMenuBar;
96 new MenuBarClosedHelper(this);
97
98 QHBoxLayout* layout = new QHBoxLayout(this);
99 layout->setMargin(0);
100 layout->setSpacing(0);
101 layout->addWidget(m_menuBar);
102 m_menuBar->setNativeMenuBar(false);
103
104 m_updateMenuBarTimer = new QTimer(this);
105 m_updateMenuBarTimer->setSingleShot(true);
106 m_updateMenuBarTimer->setInterval(0);
107 connect(m_updateMenuBarTimer, SIGNAL(timeout()),
108 SLOT(updateMenuBar()));
109
110 // Repaint the menubar when modifiers change so that the shortcut underline
111 // is drawn or not
112 connect(KeyboardModifiersMonitor::instance(), SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
113 m_menuBar, SLOT(update()));
114}
115
116void MenuBarWidget::slotActiveWindowChanged(BamfWindow* /*former*/, BamfWindow* current)
117{
118 if (current) {
119 updateActiveWinId(current);
120 }
121}
122
123void MenuBarWidget::slotViewOpened()
124{
125 BamfWindow* active = BamfMatcher::get_default().active_window();
126 if (active != NULL) {
127 if (active->xid() != m_activeWinId) {
128 /* This shouldn’t be needed as BAMF should have emitted the
129 ActiveWindowChanged signal, but it sometimes doesn’t (e.g. when
130 LibreOffice startcenter starts automatically maximized). */
131 updateActiveWinId(active);
132 }
133 }
134}
135
136void MenuBarWidget::slotWindowRegistered(WId wid, const QString& service, const QDBusObjectPath& menuObjectPath)
137{
138 MyDBusMenuImporter* importer = new MyDBusMenuImporter(service, menuObjectPath.path(), this);
139 delete m_importers.take(wid);
140 m_importers.insert(wid, importer);
141 connect(importer, SIGNAL(menuUpdated()), SLOT(slotMenuUpdated()));
142 connect(importer, SIGNAL(actionActivationRequested(QAction*)), SLOT(slotActionActivationRequested(QAction*)));
143 QMetaObject::invokeMethod(importer, "updateMenu", Qt::QueuedConnection);
144}
145
146void MenuBarWidget::slotWindowUnregistered(WId wid)
147{
148 MyDBusMenuImporter* importer = m_importers.take(wid);
149 if (importer) {
150 importer->deleteLater();
151 }
152 if (wid == m_activeWinId) {
153 m_activeWinId = 0;
154 updateMenuBar();
155 }
156}
157
158void MenuBarWidget::slotMenuUpdated()
159{
160 DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
161
162 if (m_importers.value(m_activeWinId) == importer) {
163 updateMenuBar();
164 }
165}
166
167void MenuBarWidget::slotActionActivationRequested(QAction* action)
168{
169 DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
170
171 if (m_importers.value(m_activeWinId) == importer) {
172 m_menuBar->setActiveAction(action);
173 }
174}
175
176QMenu* MenuBarWidget::menuForWinId(WId wid) const
177{
178 MyDBusMenuImporter* importer = m_importers.value(wid);
179 return importer ? importer->menu() : 0;
180}
181
182void MenuBarWidget::updateActiveWinId(BamfWindow* bamfWindow)
183{
184 WId id = bamfWindow ? bamfWindow->xid() : 0;
185 if (id == m_activeWinId) {
186 return;
187 }
188 if (id == window()->winId()) {
189 // Do not update id if the active window is the one hosting this applet
190 return;
191 }
192 m_activeWinId = id;
193 updateMenuBar();
194}
195
196void MenuBarWidget::updateMenuBar()
197{
198 WId winId = m_activeWinId;
199 QMenu* menu = menuForWinId(winId);
200
201 if (!menu) {
202 if (winId) {
203 menu = m_windowMenu;
204 } else {
205 // No active window, show a desktop menubar
206 // FIXME: Empty menu
207 /*
208 menu = mEmptyMenu;
209 */
210 }
211 }
212
213 m_menuBar->clear();
214 // FIXME: Empty menu
215 if (!menu) {
216 return;
217 }
218 menu->installEventFilter(this);
219 Q_FOREACH(QAction* action, menu->actions()) {
220 if (action->isSeparator()) {
221 continue;
222 }
223 m_menuBar->addAction(action);
224 }
225}
226
227bool MenuBarWidget::eventFilter(QObject* object, QEvent* event)
228{
229 switch (event->type()) {
230 case QEvent::ActionAdded:
231 case QEvent::ActionRemoved:
232 case QEvent::ActionChanged:
233 m_updateMenuBarTimer->start();
234 break;
235 default:
236 break;
237 }
238 return false;
239}52}
24053
241bool MenuBarWidget::isEmpty() const54bool MenuBarWidget::isEmpty() const
242{55{
243 return m_menuBar->actions().isEmpty();56 return m_isEmpty;
244}57}
24558
246bool MenuBarWidget::isOpened() const59bool MenuBarWidget::isOpened() const
247{60{
248 return m_menuBar->activeAction();61 return m_isOpened;
249}62}
25063
251// MenuBarClosedHelper ----------------------------------------64void MenuBarWidget::onObjectAdded(const unity::indicator::Indicator::Ptr& indicator)
252MenuBarClosedHelper::MenuBarClosedHelper(MenuBarWidget* widget)65{
253: QObject(widget)66 QString name = QString::fromStdString(indicator->name());
254, m_widget(widget)67 if (name == "libappmenu.so") {
255{68 indicator->on_entry_added.connect(sigc::mem_fun(this, &MenuBarWidget::onEntryAdded));
256 widget->m_menuBar->installEventFilter(this);69 }
257}70}
25871
259bool MenuBarClosedHelper::eventFilter(QObject* object, QEvent* event)72void MenuBarWidget::onEntryAdded(const unity::indicator::Entry::Ptr& entry)
260{73{
261 if (object == m_widget->m_menuBar) {74 IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
262 switch (event->type()) {75 widget->setPadding(MENU_ITEM_PADDING);
263 case QEvent::ActionAdded:76 connect(widget, SIGNAL(isEmptyChanged()), SLOT(updateIsEmpty()));
264 case QEvent::ActionRemoved:77
265 case QEvent::ActionChanged:78 m_widgetList.append(widget);
266 menuBarActionEvent(static_cast<QActionEvent*>(event));79 m_indicatorsManager->addIndicatorEntryWidget(widget);
267 break;80
268 default:81 // Insert *before* stretch
269 break;82 m_layout->insertWidget(m_layout->count() - 1, widget);
270 }83}
271 } else {84
272 // Top-level menus85void MenuBarWidget::updateIsEmpty()
273 if (event->type() == QEvent::Hide) {86{
274 // menu hide themselves when the menubar is closed but also when87 bool empty = true;
275 // one goes from one menu to another. The way to know this is to88 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
276 // check the value of QMenuBar::activeAction(), but at this point89 if (!widget->isEmpty()) {
277 // it has not been updated yet, so we check in a delayed method.90 empty = false;
278 QMetaObject::invokeMethod(this, "emitMenuBarClosed", Qt::QueuedConnection);91 break;
279 }92 }
280 }93 }
281 return false;94 if (m_isEmpty != empty) {
282}95 m_isEmpty = empty;
28396 isEmptyChanged();
284void MenuBarClosedHelper::emitMenuBarClosed()97 }
285{98}
286 if (!m_widget->m_menuBar->activeAction()) {99
287 QMetaObject::invokeMethod(m_widget, "menuBarClosed");100void MenuBarWidget::onEntryActivated(const std::string& id)
288 }101{
289}102 bool isOpened = false;
290103 if (!id.empty()) {
291void MenuBarClosedHelper::menuBarActionEvent(QActionEvent* event)104 // We only cares about menubar entries
292{105 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
293 QMenu* menu = event->action()->menu();106 if (widget->entry()->id() == id) {
294 if (menu) {107 isOpened = true;
295 // Install/remove event filters on top level menus so that know when108 break;
296 // they hide themselves and can emit menuBarClosed()109 }
297 switch (event->type()) {110 }
298 case QEvent::ActionAdded:111 }
299 case QEvent::ActionChanged:112 if (m_isOpened != isOpened) {
300 menu->installEventFilter(this);113 m_isOpened = isOpened;
301 break;114 isOpenedChanged();
302 case QEvent::ActionRemoved:
303 menu->removeEventFilter(this);
304 break;
305 default:
306 break;
307 }
308 }
309
310 // Emit isEmptyChanged() if necessary
311 QList<QAction*> actions = m_widget->m_menuBar->actions();
312 if (event->type() == QEvent::ActionAdded && actions.count() == 1) {
313 QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
314 } else if (event->type() == QEvent::ActionRemoved && actions.isEmpty()) {
315 QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
316 }115 }
317}116}
318117
319118
=== modified file 'panel/applets/appname/menubarwidget.h'
--- panel/applets/appname/menubarwidget.h 2011-07-26 09:36:41 +0000
+++ panel/applets/appname/menubarwidget.h 2011-08-04 16:31:58 +0000
@@ -23,86 +23,45 @@
23#define MENUBARWIDGET_H23#define MENUBARWIDGET_H
2424
25// Qt25// Qt
26#include <QHash>
27#include <QWidget>26#include <QWidget>
2827
29class BamfWindow;28// libunity-core
3029#include <UnityCore/Indicator.h>
31class QActionEvent;30#include <UnityCore/IndicatorEntry.h>
32class QDBusObjectPath;31
33class QMenu;32class QHBoxLayout;
34class QMenuBar;33
35class QTimer;34class IndicatorEntryWidget;
3635class IndicatorsManager;
37class MyDBusMenuImporter;36
38class Registrar;37class MenuBarWidget : public QWidget, public sigc::trackable
3938{
40typedef QHash<WId, MyDBusMenuImporter*> ImporterForWId;39Q_OBJECT
4140public:
42class MenuBarWidget;41 MenuBarWidget(IndicatorsManager*, QWidget* parent = 0);
43
44/**
45 * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed()
46 * when necessary
47 */
48class MenuBarClosedHelper : public QObject
49{
50Q_OBJECT
51public:
52 MenuBarClosedHelper(MenuBarWidget*);
53
54protected:
55 bool eventFilter(QObject*, QEvent*); //reimp
56
57private Q_SLOTS:
58 void emitMenuBarClosed();
59
60private:
61 MenuBarWidget* m_widget;
62 void menuBarActionEvent(QActionEvent*);
63};
64
65class MenuBarWidget : public QWidget
66{
67Q_OBJECT
68public:
69 MenuBarWidget(QMenu* windowMenu, QWidget* parent = 0);
7042
71 bool isEmpty() const;43 bool isEmpty() const;
72 bool isOpened() const;44 bool isOpened() const;
7345
74Q_SIGNALS:46Q_SIGNALS:
75 void menuBarClosed();47 void isOpenedChanged();
76 void isEmptyChanged();48 void isEmptyChanged();
7749
78protected:
79 bool eventFilter(QObject*, QEvent*); // reimp
80
81private Q_SLOTS:50private Q_SLOTS:
82 void slotActiveWindowChanged(BamfWindow*, BamfWindow*);51 void updateIsEmpty();
83 void slotViewOpened();
84 void slotWindowRegistered(WId, const QString& service, const QDBusObjectPath& menuObjectPath);
85 void slotWindowUnregistered(WId);
86 void slotMenuUpdated();
87 void slotActionActivationRequested(QAction* action);
88 void updateMenuBar();
8952
90private:53private:
91 Q_DISABLE_COPY(MenuBarWidget)54 Q_DISABLE_COPY(MenuBarWidget)
9255
93 QMenuBar* m_menuBar;56 IndicatorsManager* m_indicatorsManager;
94 Registrar* m_registrar;57 QHBoxLayout* m_layout;
95 ImporterForWId m_importers;58 bool m_isEmpty;
96 WId m_activeWinId;59 bool m_isOpened;
97 QMenu* m_windowMenu;60 QList<IndicatorEntryWidget*> m_widgetList;
98 QTimer* m_updateMenuBarTimer;61
9962 void onObjectAdded(const unity::indicator::Indicator::Ptr&);
100 void setupRegistrar();63 void onEntryAdded(const unity::indicator::Entry::Ptr&);
101 void setupMenuBar();64 void onEntryActivated(const std::string&);
102 QMenu* menuForWinId(WId) const;
103 void updateActiveWinId(BamfWindow*);
104
105 friend class MenuBarClosedHelper;
106};65};
10766
108#endif /* MENUBARWIDGET_H */67#endif /* MENUBARWIDGET_H */
10968
=== removed file 'panel/applets/appname/registrar.cpp'
--- panel/applets/appname/registrar.cpp 2011-04-04 16:46:14 +0000
+++ panel/applets/appname/registrar.cpp 1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@
1/*
2 * Plasma applet to display application window menus
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "registrar.h"
24
25// Qt
26#include <QApplication>
27#include <QDBusMessage>
28#include <QDBusObjectPath>
29#include <QDBusServiceWatcher>
30
31// Local
32#include "registraradaptor.h"
33
34static const char* DBUS_SERVICE = "com.canonical.AppMenu.Registrar";
35static const char* DBUS_OBJECT_PATH = "/com/canonical/AppMenu/Registrar";
36
37// Marshalling code for MenuInfo
38QDBusArgument& operator<<(QDBusArgument& argument, const MenuInfo& info)
39{
40 argument.beginStructure();
41 argument << info.winId << info.service << info.path;
42 argument.endStructure();
43 return argument;
44}
45
46const QDBusArgument& operator>>(const QDBusArgument& argument, MenuInfo& info)
47{
48 argument.beginStructure();
49 argument >> info.winId >> info.service >> info.path;
50 argument.endStructure();
51 return argument;
52}
53
54Registrar::Registrar()
55: QObject()
56, mServiceWatcher(new QDBusServiceWatcher(this))
57{
58 qDBusRegisterMetaType<MenuInfo>();
59 qDBusRegisterMetaType<MenuInfoList>();
60 mServiceWatcher->setConnection(QDBusConnection::sessionBus());
61 mServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
62 connect(mServiceWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
63}
64
65Registrar::~Registrar()
66{
67 QDBusConnection::sessionBus().unregisterService(mService);
68}
69
70Registrar* Registrar::instance()
71{
72 static Registrar singleton;
73 return &singleton;
74}
75
76bool Registrar::connectToBus(const QString& _service, const QString& _path)
77{
78 mService = _service.isEmpty() ? DBUS_SERVICE : _service;
79 QString path = _path.isEmpty() ? DBUS_OBJECT_PATH : _path;
80
81 bool ok = QDBusConnection::sessionBus().registerService(mService);
82 if (!ok) {
83 return false;
84 }
85 new RegistrarAdaptor(this);
86 QDBusConnection::sessionBus().registerObject(path, this);
87
88 return true;
89}
90
91void Registrar::RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath)
92{
93 MenuInfo info;
94 info.winId = wid;
95 info.service = message().service();
96 info.path = menuObjectPath;
97 mDb.insert(wid, info);
98 mServiceWatcher->addWatchedService(info.service);
99 WindowRegistered(wid, info.service, info.path);
100}
101
102void Registrar::UnregisterWindow(WId wid)
103{
104 mDb.remove(wid);
105 WindowUnregistered(wid);
106}
107
108QString Registrar::GetMenuForWindow(WId winId, QDBusObjectPath& menuObjectPath)
109{
110 MenuInfo info = mDb.value(winId);
111 QString service = info.service;
112 menuObjectPath = info.path;
113 return service;
114}
115
116MenuInfoList Registrar::GetMenus()
117{
118 return mDb.values();
119}
120
121void Registrar::slotServiceUnregistered(const QString& service)
122{
123 MenuInfoDb::Iterator
124 it = mDb.begin(),
125 end = mDb.end();
126 for (;it != end;) {
127 if (it.value().service == service) {
128 WId id = it.key();
129 it = mDb.erase(it);
130 WindowUnregistered(id);
131 } else {
132 ++it;
133 }
134 }
135 mServiceWatcher->removeWatchedService(service);
136}
137
138#include "registrar.moc"
1390
=== removed file 'panel/applets/appname/registrar.h'
--- panel/applets/appname/registrar.h 2011-04-04 16:47:28 +0000
+++ panel/applets/appname/registrar.h 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
1/*
2 * Plasma applet to display application window menus
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef REGISTRAR_H
23#define REGISTRAR_H
24
25// Qt
26#include <QDBusContext>
27#include <QDBusObjectPath>
28#include <QObject>
29#include <QWidget> // For WId
30
31class QDBusObjectPath;
32class QDBusServiceWatcher;
33class QMenu;
34
35struct MenuInfo
36{
37 MenuInfo()
38 : winId(0)
39 , path("/")
40 {}
41
42 uint winId;
43 QString service;
44 QDBusObjectPath path;
45};
46Q_DECLARE_METATYPE(MenuInfo)
47
48typedef QList<MenuInfo> MenuInfoList;
49Q_DECLARE_METATYPE(MenuInfoList)
50
51class Registrar : public QObject, protected QDBusContext
52{
53 Q_OBJECT
54
55public:
56 /* The registrar is a singleton shared between all instances of MenuBarWidget. */
57 static Registrar* instance();
58
59 bool connectToBus(const QString& service = QString(), const QString& objectPath = QString());
60
61Q_SIGNALS:
62 void WindowRegistered(WId wid, const QString& service, const QDBusObjectPath&);
63 void WindowUnregistered(WId wid);
64
65public Q_SLOTS:
66 Q_NOREPLY void RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath);
67 Q_NOREPLY void UnregisterWindow(WId wid);
68 QString GetMenuForWindow(WId wid, QDBusObjectPath& menuObjectPath);
69 MenuInfoList GetMenus();
70
71private Q_SLOTS:
72 void slotServiceUnregistered(const QString& service);
73
74private:
75 Registrar();
76 Q_DISABLE_COPY(Registrar)
77 ~Registrar();
78
79 QDBusServiceWatcher* mServiceWatcher;
80 typedef QHash<WId, MenuInfo> MenuInfoDb;
81 MenuInfoDb mDb;
82 QString mService;
83};
84
85#endif /* REGISTRAR_H */
860
=== added file 'panel/applets/common/cairoutils.cpp'
--- panel/applets/common/cairoutils.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/cairoutils.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,42 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "cairoutils.h"
23
24// Local
25
26// Qt
27#include <QImage>
28
29namespace CairoUtils {
30
31cairo_surface_t* createSurfaceForQImage(QImage* image)
32{
33 return cairo_image_surface_create_for_data(
34 image->bits(),
35 CAIRO_FORMAT_ARGB32,
36 image->width(),
37 image->height(),
38 image->bytesPerLine()
39 );
40}
41
42} // namespace
043
=== added file 'panel/applets/common/cairoutils.h'
--- panel/applets/common/cairoutils.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/cairoutils.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,47 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef CAIROUTILS_H
22#define CAIROUTILS_H
23
24// Local
25#include <gscopedpointer.h>
26
27// Qt
28
29// Cairo
30#include <cairo.h>
31
32class QImage;
33
34namespace CairoUtils {
35
36typedef GScopedPointer<cairo_surface_t, cairo_surface_destroy> SurfacePointer;
37typedef GScopedPointer<cairo_t, cairo_destroy> Pointer;
38
39/**
40 * Creates a Cairo surface for a QImage.
41 * QImage format must be Format_ARGB32_Premultiplied.
42 */
43cairo_surface_t* createSurfaceForQImage(QImage*);
44
45} // namespace
46
47#endif /* CAIROUTILS_H */
048
=== added file 'panel/applets/common/indicatorentrywidget.cpp'
--- panel/applets/common/indicatorentrywidget.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorentrywidget.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,366 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorentrywidget.h"
23
24// Local
25#include <cairoutils.h>
26#include <debug_p.h>
27#include <gscopedpointer.h>
28#include <panelstyle.h>
29
30// Qt
31#include <QIcon>
32#include <QPainter>
33#include <QWheelEvent>
34
35// GTK
36#include <gtk/gtk.h>
37
38// libc
39#include <time.h>
40
41static const int SPACING = 3;
42static const int PADDING = 3;
43
44using namespace unity::indicator;
45
46IndicatorEntryWidget::IndicatorEntryWidget(const Entry::Ptr& entry)
47: m_entry(entry)
48, m_padding(PADDING)
49, m_hasIcon(false)
50, m_hasLabel(false)
51, m_gtkWidgetPath(gtk_widget_path_new())
52{
53 gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_WINDOW);
54 gtk_widget_path_iter_set_name(m_gtkWidgetPath, -1 , "UnityPanelWidget");
55 gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_MENU_BAR);
56 gtk_widget_path_append_type(m_gtkWidgetPath, GTK_TYPE_MENU_ITEM);
57
58 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
59 m_entry->updated.connect(sigc::mem_fun(this, &IndicatorEntryWidget::updatePix));
60}
61
62IndicatorEntryWidget::~IndicatorEntryWidget()
63{
64 gtk_widget_path_free(m_gtkWidgetPath);
65}
66
67QSize IndicatorEntryWidget::minimumSizeHint() const
68{
69 return sizeHint();
70}
71
72QSize IndicatorEntryWidget::sizeHint() const
73{
74 return m_pix.size();
75}
76
77void IndicatorEntryWidget::resizeEvent(QResizeEvent* event)
78{
79 QWidget::resizeEvent(event);
80 updatePix();
81}
82
83void IndicatorEntryWidget::paintEvent(QPaintEvent*)
84{
85 if (!m_pix.isNull()) {
86 QPainter painter(this);
87 painter.drawPixmap(0, 0, m_pix);
88 }
89}
90
91
92void IndicatorEntryWidget::paintActiveBackground(QImage* image)
93{
94 // This code should be kept in sync with corresponding unityshell code from
95 // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp
96
97 // Get a surface and a context
98 CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(image));
99 CairoUtils::Pointer cr(cairo_create(surface.data()));
100
101 // Init style
102 GtkStyleContext* styleContext = PanelStyle::instance()->styleContext();
103
104 gtk_style_context_save(styleContext);
105
106 gtk_style_context_set_path(styleContext, m_gtkWidgetPath);
107 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUBAR);
108 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUITEM);
109 gtk_style_context_set_state(styleContext, GTK_STATE_FLAG_PRELIGHT);
110
111 // Draw
112 // FIXME(Cimi) probably some padding is needed here.
113 gtk_render_background(styleContext, cr.data(), 0, 0, width(), height());
114 gtk_render_frame(styleContext, cr.data(), 0, 0, width(), height());
115
116 // Clean up
117 gtk_style_context_restore(styleContext);
118}
119
120void IndicatorEntryWidget::updatePix()
121{
122 bool oldIsEmpty = isEmpty();
123
124 int width = m_padding;
125 int iconX = m_padding;
126 int labelX = 0;
127
128 GObjectScopedPointer<PangoLayout> pangoLayout;
129
130 // Compute width, labelX and update m_has{Icon,Label}
131 QPixmap iconPix;
132 if (m_entry->image_visible()) {
133 iconPix = decodeIcon();
134 m_hasIcon = !iconPix.isNull();
135 } else {
136 m_hasIcon = false;
137 }
138 if (m_hasIcon) {
139 width += iconPix.width();
140 }
141
142 m_hasLabel = !m_entry->label().empty() && m_entry->label_visible();
143 if (m_hasLabel) {
144 if (m_hasIcon) {
145 width += SPACING;
146 }
147 labelX = width;
148 pangoLayout.reset(createPangoLayout());
149 int labelWidth;
150 int labelHeight;
151 pango_layout_get_pixel_size(pangoLayout.data(), &labelWidth, &labelHeight);
152
153 width += labelWidth;
154 }
155
156 width += m_padding;
157
158 // Paint
159 QPixmap oldPix = m_pix;
160 if (!m_hasIcon && !m_hasLabel) {
161 m_pix = QPixmap();
162 } else {
163 QImage img(width, height(), QImage::Format_ARGB32_Premultiplied);
164 QPainter painter(&img);
165 painter.initFrom(this);
166 painter.eraseRect(img.rect());
167 if (m_entry->active()) {
168 paintActiveBackground(&img);
169 }
170 if (m_hasIcon) {
171 bool disabled = !m_entry->image_sensitive();
172 if (disabled) {
173 painter.setOpacity(0.5);
174 }
175 painter.drawPixmap(iconX, (height() - iconPix.height()) / 2, iconPix);
176 if (disabled) {
177 painter.setOpacity(1);
178 }
179 }
180 if (m_hasLabel) {
181 paintLabel(&img, pangoLayout.data(), labelX);
182 }
183 m_pix = QPixmap::fromImage(img);
184 }
185
186 // Notify others we changed, but only trigger a layout update if necessary
187 if (m_pix.size() == oldPix.size()) {
188 update();
189 } else {
190 updateGeometry();
191 }
192 bool newIsEmpty = isEmpty();
193 if (newIsEmpty != oldIsEmpty) {
194 // If we emit isEmptyChanged() directly it won't reach any connected
195 // slot. I assume this is because this method is called as a response
196 // to a sigc++ signal.
197 QMetaObject::invokeMethod(this, "isEmptyChanged", Qt::QueuedConnection);
198 }
199}
200
201PangoLayout* IndicatorEntryWidget::createPangoLayout()
202{
203 // Parse
204 PangoAttrList* attrs = NULL;
205 if (m_entry->show_now()) {
206 if (!pango_parse_markup(m_entry->label().c_str(),
207 -1,
208 '_',
209 &attrs,
210 NULL,
211 NULL,
212 NULL))
213 {
214 UQ_WARNING << "pango_parse_markup failed";
215 }
216 }
217
218 // Create layout
219 GObjectScopedPointer<PangoContext> pangoContext(gdk_pango_context_get());
220 PangoLayout* layout = pango_layout_new(pangoContext.data());
221
222 if (attrs) {
223 pango_layout_set_attributes(layout, attrs);
224 pango_attr_list_unref(attrs);
225 }
226
227 // Set font
228 char* font_description = NULL;
229 GtkSettings *settings = gtk_settings_get_default();
230 g_object_get(settings,
231 "gtk-font-name", &font_description,
232 NULL);
233 PangoFontDescription* desc = pango_font_description_from_string(font_description);
234 pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
235 pango_layout_set_font_description(layout, desc);
236 pango_font_description_free(desc);
237 g_free(font_description);
238
239 // Set text
240 QString label = QString::fromUtf8(m_entry->label().c_str());
241 label.replace('_', QString());
242 QByteArray utf8Label = label.toUtf8();
243 pango_layout_set_text(layout, utf8Label.data(), -1);
244
245 return layout;
246}
247
248void IndicatorEntryWidget::paintLabel(QImage* image, PangoLayout* layout, int labelX)
249{
250 // This code should be kept in sync with corresponding unityshell code from
251 // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp
252 int labelWidth, labelHeight;
253 pango_layout_get_pixel_size(layout, &labelWidth, &labelHeight);
254 CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(image));
255 CairoUtils::Pointer cr(cairo_create(surface.data()));
256 pango_cairo_update_layout(cr.data(), layout);
257
258 PanelStyle* style = PanelStyle::instance();
259 GtkStyleContext* styleContext = style->styleContext();
260
261 gtk_style_context_save(styleContext);
262
263 gtk_style_context_set_path(styleContext, m_gtkWidgetPath);
264 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUBAR);
265 gtk_style_context_add_class(styleContext, GTK_STYLE_CLASS_MENUITEM);
266
267 if (m_entry->active()) {
268 gtk_style_context_set_state(styleContext, GTK_STATE_FLAG_PRELIGHT);
269 }
270
271 gtk_render_layout(styleContext, cr.data(), labelX, (image->height() - labelHeight) / 2, layout);
272 gtk_style_context_restore(styleContext);
273}
274
275QPixmap IndicatorEntryWidget::decodeIcon()
276{
277 QPixmap pix;
278
279 int type = m_entry->image_type();
280
281 if (type == 0) {
282 // No icon
283 } else if (type == GTK_IMAGE_PIXBUF) {
284 QByteArray data = QByteArray::fromBase64(m_entry->image_data().c_str());
285 QImage image;
286 bool ok = image.loadFromData(data);
287 if (ok) {
288 pix = QPixmap::fromImage(image);
289 } else {
290 UQ_WARNING << "Failed to decode image";
291 }
292 } else if (type == GTK_IMAGE_ICON_NAME) {
293 QString name = QString::fromStdString(m_entry->image_data());
294 QIcon icon = QIcon::fromTheme(name);
295 pix = icon.pixmap(24, 24);
296 } else if (type == GTK_IMAGE_GICON) {
297 UQ_WARNING << "FIXME: Implement support for GTK_IMAGE_GICON image type";
298 } else {
299 UQ_WARNING << "Unknown image type" << m_entry->image_type();
300 }
301 return pix;
302}
303
304void IndicatorEntryWidget::mousePressEvent(QMouseEvent*)
305{
306 UQ_RETURN_IF_FAIL(m_hasIcon || m_hasLabel);
307 showMenu(Qt::LeftButton);
308}
309
310void IndicatorEntryWidget::mouseReleaseEvent(QMouseEvent*)
311{
312 UQ_VAR(this);
313 update();
314}
315
316void IndicatorEntryWidget::wheelEvent(QWheelEvent* event)
317{
318 m_entry->Scroll(event->delta());
319}
320
321void IndicatorEntryWidget::showMenu(Qt::MouseButton qtButton)
322{
323 if (m_entry->active()) {
324 return;
325 }
326 int nuxButton = qtButton == Qt::NoButton ? 0 : 1;
327 QPoint pos = mapToGlobal(rect().bottomLeft());
328 m_entry->ShowMenu(pos.x(), pos.y(),
329 time(NULL),
330 nuxButton
331 );
332}
333
334void IndicatorEntryWidget::setPadding(int padding)
335{
336 if (m_padding != padding) {
337 m_padding = padding;
338 updatePix();
339 }
340}
341
342bool IndicatorEntryWidget::event(QEvent* ev)
343{
344 bool ret = QWidget::event(ev);
345 switch (ev->type()) {
346 case QEvent::FontChange:
347 case QEvent::PaletteChange:
348 updatePix();
349 break;
350 default:
351 break;
352 }
353 return ret;
354}
355
356bool IndicatorEntryWidget::isEmpty() const
357{
358 return !m_hasIcon && !m_hasLabel;
359}
360
361unity::indicator::Entry::Ptr IndicatorEntryWidget::entry() const
362{
363 return m_entry;
364}
365
366#include "indicatorentrywidget.moc"
0367
=== added file 'panel/applets/common/indicatorentrywidget.h'
--- panel/applets/common/indicatorentrywidget.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorentrywidget.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,90 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORENTRYWIDGET_H
22#define INDICATORENTRYWIDGET_H
23
24// Local
25
26// libunity-core
27#include <UnityCore/IndicatorEntry.h>
28
29// Qt
30#include <QWidget>
31
32struct _GtkWidgetPath;
33struct _PangoLayout;
34
35class QPainter;
36
37class IndicatorEntryWidget : public QWidget, public sigc::trackable
38{
39Q_OBJECT
40public:
41 IndicatorEntryWidget(const unity::indicator::Entry::Ptr& entry);
42 ~IndicatorEntryWidget();
43
44 QSize minimumSizeHint() const;
45 QSize sizeHint() const;
46
47 void setPadding(int);
48
49 bool isEmpty() const;
50
51 unity::indicator::Entry::Ptr entry() const;
52
53 /**
54 * Shows the menu.
55 *
56 * When this method is called because of a click, button
57 * must be set to Qt::LeftButton.
58 *
59 * When it is called because user previously clicked an indicator and moved the
60 * mouse to another indicator, button must be set to Qt::NoButton.
61 */
62 void showMenu(Qt::MouseButton button);
63
64Q_SIGNALS:
65 void isEmptyChanged();
66
67protected:
68 void resizeEvent(QResizeEvent*);
69 void paintEvent(QPaintEvent*);
70 void mousePressEvent(QMouseEvent*);
71 void mouseReleaseEvent(QMouseEvent*);
72 void wheelEvent(QWheelEvent*);
73 bool event(QEvent*);
74
75private:
76 unity::indicator::Entry::Ptr m_entry;
77 QPixmap m_pix;
78 int m_padding;
79 bool m_hasIcon;
80 bool m_hasLabel;
81 struct _GtkWidgetPath* m_gtkWidgetPath;
82 void updatePix();
83 QPixmap decodeIcon();
84 void paintActiveBackground(QImage*);
85
86 struct _PangoLayout* createPangoLayout();
87 void paintLabel(QImage*, struct _PangoLayout*, int labelX);
88};
89
90#endif /* INDICATORENTRYWIDGET_H */
091
=== added file 'panel/applets/common/indicatorsmanager.cpp'
--- panel/applets/common/indicatorsmanager.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorsmanager.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,206 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorsmanager.h"
23
24// Local
25#include <debug_p.h>
26#include <indicatorentrywidget.h>
27
28// Qt
29#include <QApplication>
30#include <QTimer>
31#include <QX11Info>
32
33// X11
34#include <X11/Xlib.h>
35
36using namespace unity::indicator;
37
38IndicatorsManager::IndicatorsManager(QObject* parent)
39: QObject(parent)
40, m_indicators(new DBusIndicators)
41, m_geometrySyncTimer(new QTimer(this))
42, m_mouseTrackerTimer(new QTimer(this))
43{
44 m_geometrySyncTimer->setInterval(0);
45 m_geometrySyncTimer->setSingleShot(true);
46 connect(m_geometrySyncTimer, SIGNAL(timeout()), SLOT(syncGeometries()));
47
48 // m_mouseTrackerTimer is inspired from
49 // plugins/unityshell/src/PanelView.cpp in OnEntryActivated()
50 //
51 // Rationale copied from Unity source code:
52 // """
53 // Track menus being scrubbed at 60Hz (about every 16 millisec)
54 // It might sound ugly, but it's far nicer (and more responsive) than the
55 // code it replaces which used to capture motion events in another process
56 // (unity-panel-service) and send them to us over dbus.
57 // NOTE: The reason why we have to use a timer instead of tracking motion
58 // events is because the motion events will never be delivered to this
59 // process. All the motion events will go to unity-panel-service while
60 // scrubbing because the active panel menu has (needs) the pointer grab.
61 // """
62 m_mouseTrackerTimer->setInterval(16);
63 m_mouseTrackerTimer->setSingleShot(false);
64 connect(m_mouseTrackerTimer, SIGNAL(timeout()), SLOT(checkMousePosition()));
65
66 m_indicators->on_entry_show_menu.connect(
67 sigc::mem_fun(this, &IndicatorsManager::onEntryShowMenu)
68 );
69
70 m_indicators->on_entry_activate_request.connect(
71 sigc::mem_fun(this, &IndicatorsManager::onEntryActivateRequest)
72 );
73
74 m_indicators->on_entry_activated.connect(
75 sigc::mem_fun(this, &IndicatorsManager::onEntryActivated)
76 );
77
78 m_indicators->on_synced.connect(
79 sigc::mem_fun(this, &IndicatorsManager::onSynced)
80 );
81}
82
83unity::indicator::DBusIndicators::Ptr IndicatorsManager::indicators() const
84{
85 return m_indicators;
86}
87
88void IndicatorsManager::onEntryShowMenu(const std::string& /*entryId*/, int posX, int posY, int /*timestamp*/, int /*button*/)
89{
90 // Copied from plugins/unityshell/src/PanelView.cpp, in OnEntryShowMenu()
91 // Without this code, menus cannot be shown from mousePressEvent() (but can
92 // be shown from mouseReleaseEvent())
93 /*
94 Neil explanation:
95 On button down, X automatically gives Qt a passive grab on the mouse this
96 means that, if the panel service tries to grab the pointer to show the menu
97 (gtk does this automatically), it fails and the menu can't show.
98 We connect to the on_entry_show_menu signal, which is emitted before
99 DBusIndicators does anything else, and just break the grab.
100 */
101 Display* display = QX11Info::display();
102 XUngrabPointer(display, CurrentTime);
103 XFlush(display);
104
105 XButtonEvent event = {
106 ButtonRelease,
107 0,
108 False,
109 display,
110 0,
111 0,
112 0,
113 CurrentTime,
114 posX, posY,
115 posX, posY,
116 0,
117 Button1,
118 True
119 };
120 qApp->x11ProcessEvent(reinterpret_cast<XEvent*>(&event));
121}
122
123void IndicatorsManager::checkMousePosition()
124{
125 // Called by m_mouseTrackerTimer to implement mouse scrubbing
126 // (Assuming item A menu is opened, move mouse over item B => item B menu opens)
127 QWidget* widget = QApplication::widgetAt(QCursor::pos());
128 IndicatorEntryWidget* entryWidget = qobject_cast<IndicatorEntryWidget*>(widget);
129 if (!entryWidget) {
130 return;
131 }
132 entryWidget->showMenu(Qt::NoButton);
133}
134
135void IndicatorsManager::onEntryActivateRequest(const std::string& entryId)
136{
137 if (entryId.empty()) {
138 return;
139 }
140 IndicatorEntryWidget* widget = 0;
141 Q_FOREACH(widget, m_widgetList) {
142 if (widget->entry()->id() == entryId) {
143 break;
144 }
145 }
146 if (!widget) {
147 UQ_WARNING << "Could not find a widget for IndicatorEntry with id" << QString::fromStdString(entryId);
148 return;
149 }
150 widget->showMenu(Qt::NoButton);
151}
152
153void IndicatorsManager::onEntryActivated(const std::string& entryId)
154{
155 if (entryId.empty()) {
156 m_mouseTrackerTimer->stop();
157 } else {
158 m_mouseTrackerTimer->start();
159 }
160}
161
162void IndicatorsManager::onSynced()
163{
164 QMetaObject::invokeMethod(m_geometrySyncTimer, "start", Qt::QueuedConnection);
165}
166
167void IndicatorsManager::addIndicatorEntryWidget(IndicatorEntryWidget* widget)
168{
169 m_widgetList.append(widget);
170 widget->installEventFilter(this);
171}
172
173bool IndicatorsManager::eventFilter(QObject*, QEvent* event)
174{
175 switch (event->type()) {
176 case QEvent::Show:
177 case QEvent::Hide:
178 case QEvent::Move:
179 case QEvent::Resize:
180 m_geometrySyncTimer->start();
181 break;
182 default:
183 break;
184 }
185 return false;
186}
187
188void IndicatorsManager::syncGeometries()
189{
190 EntryLocationMap locations;
191 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
192 if (!widget->isVisible()) {
193 continue;
194 }
195 Entry::Ptr entry = widget->entry();
196 if (entry->IsUnused()) {
197 continue;
198 }
199 QPoint topLeft = widget->mapToGlobal(QPoint(0, 0));
200 nux::Rect rect(topLeft.x(), topLeft.y(), widget->width(), widget->height());
201 locations[widget->entry()->id()] = rect;
202 }
203 m_indicators->SyncGeometries("Panel", locations);
204}
205
206#include "indicatorsmanager.moc"
0207
=== added file 'panel/applets/common/indicatorsmanager.h'
--- panel/applets/common/indicatorsmanager.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorsmanager.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,72 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORSMANAGER_H
22#define INDICATORSMANAGER_H
23
24// Local
25
26// Qt
27#include <QMap>
28#include <QObject>
29
30// libunity-core
31#include <UnityCore/DBusIndicators.h>
32
33class QTimer;
34
35class IndicatorEntryWidget;
36
37/**
38 * Instantiates DBusIndicators and implement common behavior
39 */
40class IndicatorsManager : public QObject, public sigc::trackable
41{
42 Q_OBJECT
43public:
44 IndicatorsManager(QObject* parent);
45
46 unity::indicator::DBusIndicators::Ptr indicators() const;
47
48 void addIndicatorEntryWidget(IndicatorEntryWidget* widget);
49
50protected:
51 bool eventFilter(QObject*, QEvent*);
52
53private Q_SLOTS:
54 void syncGeometries();
55 void checkMousePosition();
56
57private:
58 Q_DISABLE_COPY(IndicatorsManager)
59 unity::indicator::DBusIndicators::Ptr m_indicators;
60 QTimer* m_geometrySyncTimer;
61 QTimer* m_mouseTrackerTimer;
62
63 typedef QList<IndicatorEntryWidget*> IndicatorEntryWidgetList;
64 IndicatorEntryWidgetList m_widgetList;
65
66 void onSynced();
67 void onEntryShowMenu(const std::string&, int x, int y, int timestamp, int button);
68 void onEntryActivateRequest(const std::string& entryId);
69 void onEntryActivated(const std::string& entryId);
70};
71
72#endif /* INDICATORSMANAGER_H */
073
=== added file 'panel/applets/common/indicatorwidget.cpp'
--- panel/applets/common/indicatorwidget.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorwidget.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,53 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorwidget.h"
23
24// Local
25#include <debug_p.h>
26#include <indicatorentrywidget.h>
27#include <indicatorsmanager.h>
28
29// Qt
30#include <QHBoxLayout>
31
32using namespace unity::indicator;
33
34IndicatorWidget::IndicatorWidget(const Indicator::Ptr& indicator, IndicatorsManager* manager)
35: m_layout(new QHBoxLayout(this))
36, m_indicatorsManager(manager)
37, m_indicator(indicator)
38{
39 m_layout->setMargin(0);
40 m_layout->setSpacing(0);
41
42 m_indicator->on_entry_added.connect(sigc::mem_fun(this, &IndicatorWidget::onEntryAdded));
43}
44
45void IndicatorWidget::onEntryAdded(const Entry::Ptr& entry)
46{
47 IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
48 m_indicatorsManager->addIndicatorEntryWidget(widget);
49 m_layout->addWidget(widget);
50}
51
52
53#include "indicatorwidget.moc"
054
=== added file 'panel/applets/common/indicatorwidget.h'
--- panel/applets/common/indicatorwidget.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorwidget.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,52 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORWIDGET_H
22#define INDICATORWIDGET_H
23
24// Local
25
26// libunity-core
27#include <UnityCore/Indicator.h>
28#include <UnityCore/IndicatorEntry.h>
29
30// Qt
31#include <QWidget>
32
33class QHBoxLayout;
34
35class IndicatorEntryWidget;
36class IndicatorsManager;
37
38class IndicatorWidget : public QWidget, public sigc::trackable
39{
40Q_OBJECT
41public:
42 IndicatorWidget(const unity::indicator::Indicator::Ptr& indicator, IndicatorsManager* manager);
43
44private:
45 QHBoxLayout* m_layout;
46 IndicatorsManager* m_indicatorsManager;
47 unity::indicator::Indicator::Ptr m_indicator;
48
49 void onEntryAdded(const unity::indicator::Entry::Ptr& entry);
50};
51
52#endif /* INDICATORWIDGET_H */
053
=== added file 'panel/applets/common/panelstyle.cpp'
--- panel/applets/common/panelstyle.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/panelstyle.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,114 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "panelstyle.h"
23
24// libunity-2d
25#include <cairoutils.h>
26#include <debug_p.h>
27#include <gconnector.h>
28#include <gscopedpointer.h>
29
30// Qt
31#include <QApplication>
32#include <QPalette>
33
34// GTK
35#include <gtk/gtk.h>
36
37class PanelStylePrivate
38{
39public:
40 PanelStyle* q;
41 GObjectScopedPointer<GtkStyleContext> m_styleContext;
42 GConnector m_gConnector;
43
44 static void onThemeChanged(GObject*, GParamSpec*, gpointer data)
45 {
46 PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data);
47 priv->updatePalette();
48 }
49
50 void updatePalette()
51 {
52 GtkStyleContext* context = m_styleContext.data();
53 gtk_style_context_invalidate(context);
54
55 // Without this line, it seems the GtkStyleContext is not correctly
56 // initialized and we get some uninitialized pixels in the background
57 // brush.
58 gtk_style_context_get(context, GTK_STATE_FLAG_NORMAL, NULL);
59
60 QPalette pal;
61 pal.setBrush(QPalette::Window, generateBackgroundBrush());
62 QApplication::setPalette(pal);
63 }
64
65 QBrush generateBackgroundBrush()
66 {
67 QImage image(100, 24, QImage::Format_ARGB32_Premultiplied); // FIXME: Hardcoded
68 image.fill(Qt::transparent);
69 CairoUtils::SurfacePointer surface(CairoUtils::createSurfaceForQImage(&image));
70 CairoUtils::Pointer cr(cairo_create(surface.data()));
71 gtk_render_background(m_styleContext.data(), cr.data(), 0, 0, image.width(), image.height());
72 return QBrush(image);
73 }
74};
75
76PanelStyle::PanelStyle(QObject* parent)
77: d(new PanelStylePrivate)
78{
79 d->q = this;
80 d->m_styleContext.reset(gtk_style_context_new());
81
82 GtkWidgetPath* widgetPath = gtk_widget_path_new ();
83 gtk_widget_path_append_type(widgetPath, GTK_TYPE_WINDOW);
84 gtk_widget_path_iter_set_name(widgetPath, -1 , "UnityPanelWidget");
85
86 gtk_style_context_set_path(d->m_styleContext.data(), widgetPath);
87 gtk_style_context_add_class(d->m_styleContext.data(), "gnome-panel-menu-bar");
88 gtk_style_context_add_class(d->m_styleContext.data(), "unity-panel");
89
90 gtk_widget_path_free (widgetPath);
91
92 d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name",
93 G_CALLBACK(PanelStylePrivate::onThemeChanged), d);
94
95 d->updatePalette();
96}
97
98PanelStyle::~PanelStyle()
99{
100 delete d;
101}
102
103PanelStyle* PanelStyle::instance()
104{
105 static PanelStyle style;
106 return &style;
107}
108
109GtkStyleContext* PanelStyle::styleContext() const
110{
111 return d->m_styleContext.data();
112}
113
114#include "panelstyle.moc"
0115
=== added file 'panel/applets/common/panelstyle.h'
--- panel/applets/common/panelstyle.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/panelstyle.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,56 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef PANELSTYLE_H
22#define PANELSTYLE_H
23
24// Local
25
26// Qt
27#include <QObject>
28
29struct _GtkStyleContext;
30
31class PanelStylePrivate;
32/**
33 * Provides easy access to panel style context and track platform theme to
34 * ensure we have the correct background brush.
35 *
36 * FIXME: This class does not have a very clear focus and has side-effects
37 * (background brush handling). It should be refactored.
38 */
39class PanelStyle : public QObject
40{
41 Q_OBJECT
42public:
43 PanelStyle(QObject* parent = 0);
44 ~PanelStyle();
45
46 static PanelStyle* instance();
47
48 struct _GtkStyleContext* styleContext() const;
49
50private:
51 friend class PanelStylePrivate;
52 // Use a pimpl to avoid the need for gtk includes here
53 PanelStylePrivate* const d;
54};
55
56#endif /* PANELSTYLE_H */
057
=== modified file 'panel/applets/homebutton/homebutton.cpp'
--- panel/applets/homebutton/homebutton.cpp 2011-05-26 16:41:04 +0000
+++ panel/applets/homebutton/homebutton.cpp 2011-08-04 16:31:58 +0000
@@ -40,8 +40,10 @@
40 setStyleSheet(40 setStyleSheet(
41 "QToolButton { border: none; margin: 0; padding: 0; width: 61 }"41 "QToolButton { border: none; margin: 0; padding: 0; width: 61 }"
42 "QToolButton:checked, QToolButton:pressed {"42 "QToolButton:checked, QToolButton:pressed {"
43 // Use border-image here, not background-image, because bfb_bg_active.png is 56px wide43 " padding-top: 1px;"
44 " border-image: url(theme:/bfb_bg_active.png);"44 " padding-left: 1px;"
45 " padding-right: -1px;"
46 " padding-bottom: -1px;"
45 "}"47 "}"
46 );48 );
47}49}
4850
=== added directory 'panel/applets/indicator'
=== removed directory 'panel/applets/indicator'
=== removed file 'panel/applets/indicator-config.h.in'
--- panel/applets/indicator-config.h.in 2011-03-01 09:04:13 +0000
+++ panel/applets/indicator-config.h.in 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1#ifndef INDICATOR_CONFIG_H
2#define INDICATOR_CONFIG_H
3
4#define INDICATOR_ICONS_DIR "${INDICATOR_ICONS_DIR}"
5#define INDICATOR_DIR "${INDICATOR_DIR}"
6
7#endif /* INDICATOR_CONFIG_H */
80
=== removed file 'panel/applets/indicator/abstractindicator.cpp'
--- panel/applets/indicator/abstractindicator.cpp 2011-01-15 01:41:03 +0000
+++ panel/applets/indicator/abstractindicator.cpp 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "abstractindicator.h"
24
25// Local
26
27// Qt
28#include <QAction>
29
30AbstractIndicator::AbstractIndicator(QObject* parent)
31: QObject(parent)
32{
33}
34
35AbstractIndicator::~AbstractIndicator()
36{
37}
38
39void AbstractIndicator::init()
40{
41}
42
43#include "abstractindicator.moc"
440
=== removed file 'panel/applets/indicator/abstractindicator.h'
--- panel/applets/indicator/abstractindicator.h 2011-01-15 01:41:03 +0000
+++ panel/applets/indicator/abstractindicator.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef ABSTRACTINDICATOR_H
23#define ABSTRACTINDICATOR_H
24
25// Local
26
27// Qt
28#include <QObject>
29
30class QAction;
31
32class AbstractIndicator : public QObject
33{
34 Q_OBJECT
35public:
36 AbstractIndicator(QObject* parent=0);
37 ~AbstractIndicator();
38
39 /**
40 * Called when the indicator has been constructed and its owner is connected to signals.
41 * It's the right place to emit actionAdded()
42 */
43 virtual void init();
44
45Q_SIGNALS:
46 void actionAdded(QAction*);
47 void actionRemoved(QAction*);
48
49private:
50 Q_DISABLE_COPY(AbstractIndicator)
51};
52
53#endif /* ABSTRACTINDICATOR_H */
540
=== removed file 'panel/applets/indicator/datetimeindicator.cpp'
--- panel/applets/indicator/datetimeindicator.cpp 2011-02-10 01:10:19 +0000
+++ panel/applets/indicator/datetimeindicator.cpp 1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "datetimeindicator.h"
24
25// Local
26#include "indicatorservicemanager.h"
27
28// dbusmenu-qt
29#include "dbusmenuimporter.h"
30
31// Qt
32#include <QAction>
33#include <QDateTime>
34
35// From dbus-shared.h
36#define SERVICE_NAME "com.canonical.indicator.datetime"
37#define SERVICE_IFACE "com.canonical.indicator.datetime.service"
38#define SERVICE_OBJ "/com.canonical/indicator/datetime/service"
39#define SERVICE_VERSION 1
40
41#define MENU_OBJ "/com.canonical/indicator/datetime/menu"
42
43#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"
44////
45
46DateTimeIndicator::DateTimeIndicator(QObject* parent)
47: AbstractIndicator(parent)
48, m_action(new QAction(this))
49, m_timer(new QTimer(this))
50{
51 new IndicatorServiceManager(SERVICE_NAME, SERVICE_VERSION, this);
52
53 readConfig();
54 setupMenu();
55 setupTimer();
56 updateText();
57}
58
59void DateTimeIndicator::init()
60{
61 actionAdded(m_action);
62}
63
64void DateTimeIndicator::setupMenu()
65{
66 DBusMenuImporter* importer = new DBusMenuImporter(SERVICE_NAME, MENU_OBJ, this);
67 m_action->setMenu(importer->menu());
68}
69
70void DateTimeIndicator::setupTimer()
71{
72 m_timer->setSingleShot(false);
73 connect(m_timer, SIGNAL(timeout()), SLOT(updateText()));
74 updateTimer();
75 m_timer->start();
76}
77
78void DateTimeIndicator::updateTimer()
79{
80 m_timer->setInterval(1000);
81}
82
83void DateTimeIndicator::updateText()
84{
85 QString text = QDateTime::currentDateTime().toString(m_format);
86 m_action->setText(text);
87}
88
89void DateTimeIndicator::readConfig()
90{
91 m_format = "hh:mm:ss";
92}
93
94#include "datetimeindicator.moc"
950
=== removed file 'panel/applets/indicator/datetimeindicator.h'
--- panel/applets/indicator/datetimeindicator.h 2011-01-15 01:41:03 +0000
+++ panel/applets/indicator/datetimeindicator.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef DATETIMEINDICATOR_H
23#define DATETIMEINDICATOR_H
24
25// Local
26#include "abstractindicator.h"
27
28// Qt
29#include <QTimer>
30
31class DateTimeIndicator : public AbstractIndicator
32{
33 Q_OBJECT
34public:
35 DateTimeIndicator(QObject* parent=0);
36
37 virtual void init();
38
39private Q_SLOTS:
40 void updateText();
41private:
42 Q_DISABLE_COPY(DateTimeIndicator)
43 QAction* m_action;
44 QTimer* m_timer;
45 QString m_format;
46
47 void setupTimer();
48 void setupMenu();
49 void readConfig();
50 void updateTimer();
51};
52
53#endif /* DATETIMEINDICATOR_H */
540
=== removed file 'panel/applets/indicator/indicator.c'
--- panel/applets/indicator/indicator.c 2011-07-01 03:58:28 +0000
+++ panel/applets/indicator/indicator.c 1970-01-01 00:00:00 +0000
@@ -1,525 +0,0 @@
1/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17
18#include <string.h>
19
20#include <gtk/gtk.h>
21#include <libindicator/indicator-object.h>
22
23#include "indicator.h"
24
25#include "indicator-config.h"
26
27/* default settings */
28#define DEFAULT_SETTING1 NULL
29#define DEFAULT_SETTING2 1
30#define DEFAULT_SETTING3 FALSE
31
32typedef enum {
33 PANEL_APPLET_ORIENT_LEFT,
34 PANEL_APPLET_ORIENT_RIGHT,
35 PANEL_APPLET_ORIENT_TOP,
36 PANEL_APPLET_ORIENT_BOTTOM
37} PanelAppletOrient;
38
39// <indicator-applet-copy>
40static gchar * indicator_order[] = {
41 "libappmenu.so",
42 "libapplication.so",
43 "libsoundmenu.so",
44 "libnetworkmenu.so",
45 "libmessaging.so",
46 "libdatetime.so",
47 "libme.so",
48 "libsession.so",
49 NULL
50};
51
52static GtkPackDirection packdirection;
53static PanelAppletOrient orient;
54
55#define MENU_DATA_INDICATOR_OBJECT "indicator-object"
56#define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
57
58#define IO_DATA_ORDER_NUMBER "indicator-order-number"
59
60static gint
61name2order (const gchar * name) {
62 int i;
63
64 for (i = 0; indicator_order[i] != NULL; i++) {
65 if (g_strcmp0(name, indicator_order[i]) == 0) {
66 return i;
67 }
68 }
69
70 return -1;
71}
72
73typedef struct _incoming_position_t incoming_position_t;
74struct _incoming_position_t {
75 gint objposition;
76 gint entryposition;
77 gint menupos;
78 gboolean found;
79};
80
81/* This function helps by determining where in the menu list
82 this new entry should be placed. It compares the objects
83 that they're on, and then the individual entries. Each
84 is progressively more expensive. */
85static void
86place_in_menu (GtkWidget * widget, gpointer user_data)
87{
88 incoming_position_t * position = (incoming_position_t *)user_data;
89 if (position->found) {
90 /* We've already been placed, just finish the foreach */
91 return;
92 }
93
94 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
95 g_assert(io != NULL);
96
97 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
98 /* We've already passed it, well, then this is where
99 we should be be. Stop! */
100 if (objposition > position->objposition) {
101 position->found = TRUE;
102 return;
103 }
104
105 /* The objects don't match yet, keep looking */
106 if (objposition < position->objposition) {
107 position->menupos++;
108 return;
109 }
110
111 /* The objects are the same, let's start looking at entries. */
112 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
113 gint entryposition = indicator_object_get_location(io, entry);
114
115 if (entryposition > position->entryposition) {
116 position->found = TRUE;
117 return;
118 }
119
120 if (entryposition < position->entryposition) {
121 position->menupos++;
122 return;
123 }
124
125 /* We've got the same object and the same entry. Well,
126 let's just put it right here then. */
127 position->found = TRUE;
128 return;
129}
130
131static void
132something_shown (GtkWidget * widget, gpointer user_data)
133{
134 GtkWidget * menuitem = GTK_WIDGET(user_data);
135 gtk_widget_show(menuitem);
136}
137
138static void
139something_hidden (GtkWidget * widget, gpointer user_data)
140{
141 GtkWidget * menuitem = GTK_WIDGET(user_data);
142 gtk_widget_hide(menuitem);
143}
144
145static void
146sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
147{
148 g_return_if_fail(GTK_IS_WIDGET(obj));
149 g_return_if_fail(GTK_IS_WIDGET(user_data));
150
151 gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
152 return;
153}
154
155static gboolean
156entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
157{
158 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
159 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
160
161 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
162
163 g_signal_emit_by_name (io, "scroll", 1, event->direction);
164 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
165
166 return FALSE;
167}
168
169static void
170entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
171{
172 g_debug("Signal: Entry Added");
173 gboolean something_visible = FALSE;
174 gboolean something_sensitive = FALSE;
175
176 GtkWidget * menuitem = gtk_menu_item_new();
177 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
178 gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3);
179
180 g_object_set_data (G_OBJECT (menuitem), "indicator", io);
181 g_object_set_data (G_OBJECT (menuitem), "box", box);
182
183 if (entry->image != NULL) {
184 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
185 if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
186 something_visible = TRUE;
187 }
188
189 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
190 something_sensitive = TRUE;
191 }
192
193 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
194 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
195
196 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
197 }
198 if (entry->label != NULL) {
199 switch(packdirection) {
200 case GTK_PACK_DIRECTION_LTR:
201 gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
202 break;
203 case GTK_PACK_DIRECTION_TTB:
204 gtk_label_set_angle(GTK_LABEL(entry->label),
205 (orient == PANEL_APPLET_ORIENT_LEFT) ?
206 270.0 : 90.0);
207 break;
208 default:
209 break;
210 }
211 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
212
213 if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
214 something_visible = TRUE;
215 }
216
217 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
218 something_sensitive = TRUE;
219 }
220
221 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
222 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
223
224 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
225 }
226 gtk_container_add(GTK_CONTAINER(menuitem), box);
227 gtk_widget_show(box);
228
229 if (entry->menu != NULL) {
230 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
231 }
232
233 incoming_position_t position;
234 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
235 position.entryposition = indicator_object_get_location(io, entry);
236 position.menupos = 0;
237 position.found = FALSE;
238
239 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
240
241 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
242
243 if (something_visible) {
244 gtk_widget_show(menuitem);
245 }
246 gtk_widget_set_sensitive(menuitem, something_sensitive);
247
248 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
249 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
250 g_signal_connect(G_OBJECT (menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
251
252 return;
253}
254
255static void
256entry_removed_cb (GtkWidget * widget, gpointer userdata)
257{
258 gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
259
260 if (data != userdata) {
261 return;
262 }
263
264 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
265 if (entry->label != NULL) {
266 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
267 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
268 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
269 }
270 if (entry->image != NULL) {
271 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
272 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
273 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
274 }
275
276 gtk_widget_destroy(widget);
277 return;
278}
279
280static void
281entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
282 gpointer user_data)
283{
284 g_debug("Signal: Entry Removed");
285
286 gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
287
288 return;
289}
290
291static void
292entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
293{
294 gpointer * array = (gpointer *)userdata;
295 if (array[1] != NULL) {
296 return;
297 }
298
299 gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
300
301 if (data != array[0]) {
302 return;
303 }
304
305 array[1] = widget;
306 return;
307}
308
309/* Gets called when an entry for an object was moved. */
310static void
311entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
312 gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
313{
314 GtkWidget * menubar = GTK_WIDGET(user_data);
315
316 gpointer array[2];
317 array[0] = entry;
318 array[1] = NULL;
319
320 gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
321 if (array[1] == NULL) {
322 g_warning("Moving an entry that isn't in our menus.");
323 return;
324 }
325
326 GtkWidget * mi = GTK_WIDGET(array[1]);
327 g_object_ref(G_OBJECT(mi));
328 gtk_container_remove(GTK_CONTAINER(menubar), mi);
329
330 incoming_position_t position;
331 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
332 position.entryposition = indicator_object_get_location(io, entry);
333 position.menupos = 0;
334 position.found = FALSE;
335
336 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
337
338 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
339
340 g_object_unref(G_OBJECT(mi));
341
342 return;
343}
344
345static gboolean
346load_module (const gchar * name, GtkWidget * menubar)
347{
348 g_debug("Looking at Module: %s", name);
349 g_return_val_if_fail(name != NULL, FALSE);
350
351 if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
352 return FALSE;
353 }
354
355 g_debug("Loading Module: %s", name);
356
357 /* Build the object for the module */
358 gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
359 IndicatorObject * io = indicator_object_new_from_file(fullpath);
360 g_free(fullpath);
361 g_return_val_if_fail(io != NULL, FALSE);
362
363 /* Attach the 'name' to the object */
364 g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name)));
365
366 /* Connect to its signals */
367 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
368 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
369 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
370
371 /* Work on the entries */
372 GList * entries = indicator_object_get_entries(io);
373 GList * entry = NULL;
374
375 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
376 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
377 entry_added(io, entrydata, menubar);
378 }
379
380 g_list_free(entries);
381
382 return TRUE;
383}
384// </indicator-applet-copy>
385
386
387/* prototypes */
388static gboolean
389on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator);
390
391IndicatorPlugin *
392indicator_new ()
393{
394 IndicatorPlugin *indicator;
395 GtkOrientation orientation;
396 gint indicators_loaded = 0;
397
398 /* Hack! prevent the appmenu indicator from swallowing our own menubar */
399 setenv("APPMENU_DISPLAY_BOTH", "1");
400
401 /* allocate memory for the plugin structure */
402 indicator = g_new (IndicatorPlugin, 1);
403
404 indicator->container = gtk_plug_new(0);
405
406 /* Init some theme/icon stuff */
407 g_object_set (gtk_settings_get_default(), "gtk-theme-name", "Ambiance", NULL);
408 g_object_set (gtk_settings_get_default(), "gtk-icon-theme-name", "ubuntu-mono-dark", NULL);
409 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
410 INDICATOR_ICONS_DIR);
411 gtk_rc_parse_string (
412 "widget \"indicator-applet*\" style \"panel\"\n"
413 "style \"indicator-applet-style\"\n"
414 "{\n"
415 " GtkMenuBar::shadow-type = none\n"
416 " GtkMenuBar::internal-padding = 0\n"
417 " GtkWidget::focus-line-width = 0\n"
418 " GtkWidget::focus-padding = 0\n"
419 "}\n"
420 "style \"indicator-applet-menubar-style\"\n"
421 "{\n"
422 " GtkMenuBar::shadow-type = none\n"
423 " GtkMenuBar::internal-padding = 0\n"
424 " GtkWidget::focus-line-width = 0\n"
425 " GtkWidget::focus-padding = 0\n"
426 " GtkMenuItem::horizontal-padding = 0\n"
427 "}\n"
428 "style \"indicator-applet-menuitem-style\"\n"
429 "{\n"
430 " GtkWidget::focus-line-width = 0\n"
431 " GtkWidget::focus-padding = 0\n"
432 " GtkMenuItem::horizontal-padding = 0\n"
433 "}\n"
434 "widget \"*.indicator-applet\" style \"indicator-applet-style\""
435 "widget \"*.indicator-applet-menuitem\" style \"indicator-applet-menuitem-style\""
436 "widget \"*.indicator-applet-menubar\" style \"indicator-applet-menubar-style\"");
437 gtk_widget_set_name(GTK_WIDGET (indicator->container), "indicator-applet");
438 /* create some panel widgets */
439
440 /* Build menu */
441 indicator->menu = gtk_menu_bar_new();
442 GTK_WIDGET_SET_FLAGS (indicator->menu, GTK_WIDGET_FLAGS(indicator->menu) | GTK_CAN_FOCUS);
443 gtk_widget_set_name(GTK_WIDGET (indicator->menu), "indicator-applet-menubar");
444 g_signal_connect(indicator->menu, "button-press-event", G_CALLBACK(on_menu_press), NULL);
445 //g_signal_connect_after(indicator->menu, "expose-event", G_CALLBACK(menu_on_expose), menu);
446 gtk_container_set_border_width(GTK_CONTAINER(indicator->menu), 0);
447
448 /* load 'em */
449 if (!g_file_test(INDICATOR_DIR, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
450 g_warning ("%s does not exist, cannot read any indicators", INDICATOR_DIR);
451 } else {
452 GDir *dir;
453 const gchar *name;
454
455 dir = g_dir_open(INDICATOR_DIR, 0, NULL);
456 while ((name = g_dir_read_name (dir)) != NULL) {
457 if (g_strcmp0(name, "libappmenu.so") == 0) {
458 continue;
459 }
460
461 if (load_module(name, indicator->menu)) {
462 indicators_loaded++;
463 } else {
464 g_warning("Failed to load module %s", name);
465 }
466 }
467 g_dir_close(dir);
468 }
469
470 if (indicators_loaded == 0) {
471 /* A label to allow for click through */
472 indicator->item = gtk_button_new();
473 gtk_button_set_label(GTK_BUTTON(indicator->item), "No Indicators");
474 gtk_widget_show(indicator->item);
475 gtk_container_add (GTK_CONTAINER (indicator->container), indicator->item);
476 } else {
477 gtk_widget_show(indicator->menu);
478 gtk_container_add (GTK_CONTAINER (indicator->container), indicator->menu);
479 }
480 return indicator;
481}
482
483
484
485void
486indicator_free (IndicatorPlugin *indicator)
487{
488 g_free(indicator);
489}
490
491
492#if 0
493static gboolean
494indicator_size_changed (XfcePanelPlugin *plugin,
495 gint size,
496 IndicatorPlugin *indicator)
497{
498 GtkOrientation orientation;
499
500 /* get the orientation of the plugin */
501 orientation = xfce_panel_plugin_get_orientation (plugin);
502
503 /* set the widget size */
504 if (orientation == GTK_ORIENTATION_HORIZONTAL)
505 gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size);
506 else
507 gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1);
508
509 /* we handled the orientation */
510 return TRUE;
511}
512#endif
513
514
515static gboolean
516on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator)
517{
518 if (indicator != NULL && event->button == 1) /* left click only */
519 {
520 /* gtk_menu_popup (GTK_MENU(indicator->menu), NULL, NULL, NULL, NULL, 0,
521 event->time);*/
522 return TRUE;
523 }
524 return FALSE ;
525}
5260
=== removed file 'panel/applets/indicator/indicator.h'
--- panel/applets/indicator/indicator.h 2011-06-22 14:49:34 +0000
+++ panel/applets/indicator/indicator.h 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17
18#ifndef __INDICATOR_H__
19#define __INDICATOR_H__
20
21#include <gtk/gtk.h>
22
23G_BEGIN_DECLS
24
25/* plugin structure */
26typedef struct _IndicatorPlugin
27{
28 GtkWidget *container;
29 /* panel widgets */
30 GtkWidget *menu;
31 GtkWidget *item;
32
33 /* indicator settings */
34}
35IndicatorPlugin;
36
37IndicatorPlugin *
38indicator_new ();
39
40void
41indicator_free(IndicatorPlugin*);
42
43G_END_DECLS
44
45#endif /* !__INDICATOR_H__ */
460
=== added file 'panel/applets/indicator/indicatorapplet.cpp'
--- panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/indicator/indicatorapplet.cpp 2011-08-04 16:31:58 +0000
@@ -0,0 +1,58 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorapplet.h"
23
24// Local
25#include <debug_p.h>
26#include <indicatorsmanager.h>
27#include <indicatorwidget.h>
28
29// Qt
30#include <QHBoxLayout>
31
32using namespace unity::indicator;
33
34IndicatorApplet::IndicatorApplet(IndicatorsManager* manager)
35: m_indicatorsManager(manager)
36{
37 QHBoxLayout* layout = new QHBoxLayout(this);
38 layout->setMargin(0);
39 layout->setSpacing(0);
40 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
41
42 m_indicatorsManager->indicators()->on_object_added.connect(
43 sigc::mem_fun(this, &IndicatorApplet::onObjectAdded)
44 );
45}
46
47void IndicatorApplet::onObjectAdded(Indicator::Ptr const& indicator)
48{
49 QString name = QString::fromStdString(indicator->name());
50 if (name == "libappmenu.so") {
51 // appmenu indicator is handled by AppNameApplet
52 return;
53 }
54 IndicatorWidget* widget = new IndicatorWidget(indicator, m_indicatorsManager);
55 layout()->addWidget(widget);
56}
57
58#include "indicatorapplet.moc"
059
=== removed file 'panel/applets/indicator/indicatorapplet.cpp'
--- panel/applets/indicator/indicatorapplet.cpp 2011-06-22 14:49:34 +0000
+++ panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000
@@ -1,114 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "indicatorapplet.h"
24
25// Local
26#include "abstractindicator.h"
27#include "datetimeindicator.h"
28#include "debug_p.h"
29#include "indicator.h"
30
31// Qt
32#include <QAction>
33#include <QDBusConnection>
34#include <QHBoxLayout>
35#include <QMenu>
36#include <QX11EmbedContainer>
37
38// Gtk
39#include <gdk/gdk.h>
40#include <gtk/gtk.h>
41
42IndicatorApplet::IndicatorApplet()
43{
44 setupUi();
45 loadIndicators();
46}
47
48void IndicatorApplet::setupUi()
49{
50 m_menuBar = new QMenuBar;
51 m_menuBar->setNativeMenuBar(false);
52 QHBoxLayout* layout = new QHBoxLayout(this);
53 layout->setMargin(0);
54 layout->addWidget(m_menuBar);
55
56 QMetaObject::invokeMethod(this, "createGtkIndicator", Qt::QueuedConnection);
57}
58
59void IndicatorApplet::createGtkIndicator()
60{
61 int* argc = 0;
62 char*** argv = 0;
63 gtk_init(argc, argv);
64
65 m_container = new QX11EmbedContainer;
66 layout()->addWidget(m_container);
67
68 m_gtkIndicator = indicator_new();
69 m_container->embedClient(gtk_plug_get_id(GTK_PLUG(m_gtkIndicator->container)));
70 gtk_widget_show(m_gtkIndicator->container);
71
72 QTimer* timer = new QTimer(this);
73 timer->setInterval(1000);
74 timer->setSingleShot(false);
75 connect(timer, SIGNAL(timeout()), SLOT(adjustGtkIndicatorSize()));
76 timer->start();
77}
78
79void IndicatorApplet::adjustGtkIndicatorSize()
80{
81 GtkRequisition requisition;
82 gtk_widget_size_request(m_gtkIndicator->menu, &requisition);
83 m_container->setFixedWidth(requisition.width);
84}
85
86void IndicatorApplet::loadIndicators()
87{
88#if 0
89 // FIXME: Using Qt plugins
90 QList<AbstractIndicator*> indicators = QList<AbstractIndicator*>()
91 << new DateTimeIndicator(this)
92 ;
93
94 Q_FOREACH(AbstractIndicator* indicator, indicators) {
95 connect(indicator, SIGNAL(actionAdded(QAction*)), SLOT(slotActionAdded(QAction*)));
96 connect(indicator, SIGNAL(actionRemoved(QAction*)), SLOT(slotActionRemoved(QAction*)));
97 indicator->init();
98 }
99#endif
100}
101
102void IndicatorApplet::slotActionAdded(QAction* action)
103{
104 UQ_VAR(action->text());
105 m_menuBar->addAction(action);
106}
107
108void IndicatorApplet::slotActionRemoved(QAction* action)
109{
110 m_menuBar->removeAction(action);
111}
112
113
114#include "indicatorapplet.moc"
1150
=== added file 'panel/applets/indicator/indicatorapplet.h'
--- panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000
+++ panel/applets/indicator/indicatorapplet.h 2011-08-04 16:31:58 +0000
@@ -0,0 +1,45 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INDICATORAPPLET_H
23#define INDICATORAPPLET_H
24
25// Local
26#include <applet.h>
27
28// libunity-core
29#include <UnityCore/Indicator.h>
30
31class IndicatorsManager;
32
33class IndicatorApplet : public Unity2d::Applet, public sigc::trackable
34{
35Q_OBJECT
36public:
37 IndicatorApplet(IndicatorsManager* manager);
38
39private:
40 Q_DISABLE_COPY(IndicatorApplet)
41 IndicatorsManager* m_indicatorsManager;
42 void onObjectAdded(unity::indicator::Indicator::Ptr const&);
43};
44
45#endif /* INDICATORAPPLET_H */
046
=== removed file 'panel/applets/indicator/indicatorapplet.h'
--- panel/applets/indicator/indicatorapplet.h 2011-01-15 01:41:03 +0000
+++ panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INDICATORAPPLET_H
23#define INDICATORAPPLET_H
24
25// Local
26#include <applet.h>
27
28// Qt
29#include <QDBusInterface>
30#include <QMenuBar>
31
32class QX11EmbedContainer;
33
34struct _IndicatorPlugin;
35
36class IndicatorApplet : public Unity2d::Applet
37{
38Q_OBJECT
39public:
40 IndicatorApplet();
41
42private Q_SLOTS:
43 void loadIndicators();
44 void slotActionAdded(QAction*);
45 void slotActionRemoved(QAction*);
46 void createGtkIndicator();
47 void adjustGtkIndicatorSize();
48
49private:
50 Q_DISABLE_COPY(IndicatorApplet)
51
52 QDBusInterface* m_watcher;
53 QMenuBar* m_menuBar;
54 QX11EmbedContainer* m_container;
55 struct _IndicatorPlugin* m_gtkIndicator;
56
57 void setupUi();
58};
59
60#endif /* INDICATORAPPLET_H */
610
=== removed file 'panel/applets/indicator/indicatorservicemanager.cpp'
--- panel/applets/indicator/indicatorservicemanager.cpp 2011-02-10 01:10:19 +0000
+++ panel/applets/indicator/indicatorservicemanager.cpp 1970-01-01 00:00:00 +0000
@@ -1,120 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "indicatorservicemanager.h"
24
25// Local
26#include "debug_p.h"
27
28// Qt
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches