Merge lp:~agateau/unity-2d/unity-core into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Superseded
Proposed branch: lp:~agateau/unity-2d/unity-core
Merge into: lp:unity-2d/3.0
Prerequisite: lp:~agateau/unity-2d/gtk3
Diff against target: 3681 lines (+1487/-1601)
46 files modified
CMakeLists.txt (+0/-33)
debian/20_ubuntu-2d-gconf-default (+0/-8)
debian/20_ubuntu-2d-gconf-mandatory (+0/-1)
debian/changelog (+49/-6)
debian/control (+11/-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)
libunity-2d-private/Unity2d/CMakeLists.txt (+0/-5)
libunity-2d-private/src/CMakeLists.txt (+1/-0)
libunity-2d-private/src/debug.cpp (+23/-0)
libunity-2d-private/src/debug_p.h (+6/-0)
libunity-2d-private/src/unity2dapplication.cpp (+0/-25)
panel/CMakeLists.txt (+3/-5)
panel/app/CMakeLists.txt (+1/-0)
panel/app/main.cpp (+4/-0)
panel/app/panelmanager.cpp (+32/-46)
panel/app/panelmanager.h (+4/-0)
panel/applets/CMakeLists.txt (+10/-27)
panel/applets/appname/appnameapplet.cpp (+5/-10)
panel/applets/appname/appnameapplet.h (+3/-1)
panel/applets/appname/com.canonical.AppMenu.Registrar.xml (+0/-82)
panel/applets/appname/menubarwidget.cpp (+78/-292)
panel/applets/appname/menubarwidget.h (+25/-72)
panel/applets/appname/registrar.cpp (+0/-138)
panel/applets/appname/registrar.h (+0/-85)
panel/applets/common/fakecairo.h (+125/-0)
panel/applets/common/indicatorentrywidget.cpp (+388/-0)
panel/applets/common/indicatorentrywidget.h (+81/-0)
panel/applets/common/indicatorsmanager.cpp (+176/-0)
panel/applets/common/indicatorsmanager.h (+70/-0)
panel/applets/common/indicatorwidget.cpp (+53/-0)
panel/applets/common/indicatorwidget.h (+52/-0)
panel/applets/common/panelstyle.cpp (+175/-0)
panel/applets/common/panelstyle.h (+59/-0)
panel/applets/indicator-config.h.in (+0/-7)
panel/applets/indicator/indicator.c (+0/-526)
panel/applets/indicator/indicator.h (+0/-45)
panel/applets/indicator/indicatorapplet.cpp (+0/-77)
panel/applets/indicator/indicatorapplet.h (+0/-57)
places/HomeShortcuts.qml (+4/-4)
To merge this branch: bzr merge lp:~agateau/unity-2d/unity-core
Reviewer Review Type Date Requested Status
Florian Boucault (community) Needs Fixing
Tim Penhey Pending
Review via email: mp+69101@code.launchpad.net

This proposal supersedes a proposal from 2011-07-05.

This proposal has been superseded by a proposal from 2011-07-27.

Description of the change

This branch is an heavy refactor of unity-2d-panel to use the new indicator-panel-service provided by Unity 3D. It has been developed on Oneiric and most likely will not build and work properly on Natty as it depends on GTK3 and UnityCore, a new library provided by Unity 3D.

(resubmitted to mark lp:~agateau/unity-2d/gtk3 as a prerequisite branch)

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

Hi Aurélien,

I notice you have a GConnector class. It covers a very similar area to Neil's
latest work -
https://code.launchpad.net/~njpatel/unity/nicer-glib-signals/+merge/67439

I also notice you aren't using namespaces for your top level classes - like
the GConnector. Have you considered using one?

A slight niggle, <string> is in the C++ standard library, not the STL (they
don't say we work for pedantical for nothing).

Redeclaring nux::Color is a dangerous thing. Slightly convoluted due to the
actual nux Color being nux::color::Color, which is then used in the nux
namespace. That is probably the only reason you are not getting linker errors
with this.

review: Needs Information
Revision history for this message
Aurélien Gâteau (agateau) wrote : Posted in a previous version of this proposal

> Hi Aurélien,
>
> I notice you have a GConnector class. It covers a very similar area to Neil's
> latest work -
> https://code.launchpad.net/~njpatel/unity/nicer-glib-signals/+merge/67439

Yes, I discussed it briefly with Neil during Platform Rally, but from what I
understand it imposes the use of sigc++ signals. We already deal with GObject
and Qt signals so I prefer not adding another signal system to our stack
(granted, the code in this branch uses sigc++ signals when we deal with
UnityCore so this may be a moot point)

> I also notice you aren't using namespaces for your top level classes - like
> the GConnector. Have you considered using one?

Not really. GConnector is in libunity-2d-private, which is not supposed to be
reused outside of unity-2d. Therefore I don't see an advantage in using
namespaces here.

> A slight niggle, <string> is in the C++ standard library, not the STL (they
> don't say we work for pedantical for nothing).

Will fix :)

> Redeclaring nux::Color is a dangerous thing. Slightly convoluted due to the
> actual nux Color being nux::color::Color, which is then used in the nux
> namespace. That is probably the only reason you are not getting linker errors
> with this.

Granted, this code is hackish. It cannot cause link errors though:
nux::Color is in Nux and we only link to NuxCore, not to Nux. I would have
used nux::Color directly instead of reimplementing it otherwise.

This code is part of a fake Cairo API used to draw the border behind the active
menubar item:

I expected the corresponding code in unity-3d to continue to evolve based on
adjustments from Design and more drawing code to be added later on. It would
have been a pain to catch up with it if I had rewritten the whole drawing code
using Qt painting API. Instead I opted to fake the Cairo API, this way I
expected to be able to catch up by simply copying the drawing code from
unity-3d.

It turned out to be a not-so-smart move in the end because by the time I was
done with my fake Cairo API, Cimi started redoing the panel drawing code using
GTK3 style API :/. I plan on investigating whether it is possible for us to
directly call the GTK3 style API to paint on QWidgets so that we can keep
rendering synchronized. At this point this whole fake Cairo code should be
scrapped.

Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

On Tue, 12 Jul 2011 21:12:39 you wrote:
> > I also notice you aren't using namespaces for your top level classes -
> > like the GConnector. Have you considered using one?
>
> Not really. GConnector is in libunity-2d-private, which is not supposed to
> be reused outside of unity-2d. Therefore I don't see an advantage in using
> namespaces here.

You could say the same about unity, but I'm pushing for "namespace unity" (and
implementing).

> > Redeclaring nux::Color is a dangerous thing. Slightly convoluted due to
> > the actual nux Color being nux::color::Color, which is then used in the
> > nux namespace. That is probably the only reason you are not getting
> > linker errors with this.
>
> Granted, this code is hackish. It cannot cause link errors though:
> nux::Color is in Nux and we only link to NuxCore, not to Nux. I would have
> used nux::Color directly instead of reimplementing it otherwise.

No. nux::Color is in NuxCore, not Nux.

> This code is part of a fake Cairo API used to draw the border behind the
> active menubar item:
>
> I expected the corresponding code in unity-3d to continue to evolve based
> on adjustments from Design and more drawing code to be added later on. It
> would have been a pain to catch up with it if I had rewritten the whole
> drawing code using Qt painting API. Instead I opted to fake the Cairo API,
> this way I expected to be able to catch up by simply copying the drawing
> code from unity-3d.
>
> It turned out to be a not-so-smart move in the end because by the time I
> was done with my fake Cairo API, Cimi started redoing the panel drawing
> code using GTK3 style API :/. I plan on investigating whether it is
> possible for us to directly call the GTK3 style API to paint on QWidgets
> so that we can keep rendering synchronized. At this point this whole fake
> Cairo code should be scrapped.

Sure.

Revision history for this message
Aurélien Gâteau (agateau) wrote : Posted in a previous version of this proposal

> On Tue, 12 Jul 2011 21:12:39 you wrote:
> > > I also notice you aren't using namespaces for your top level classes -
> > > like the GConnector. Have you considered using one?
> >
> > Not really. GConnector is in libunity-2d-private, which is not supposed to
> > be reused outside of unity-2d. Therefore I don't see an advantage in using
> > namespaces here.
>
> You could say the same about unity, but I'm pushing for "namespace unity" (and
> implementing).

Not exactly, at least libunity-core is used by both unity-2d and unity-3d.

> > > Redeclaring nux::Color is a dangerous thing. Slightly convoluted due to
> > > the actual nux Color being nux::color::Color, which is then used in the
> > > nux namespace. That is probably the only reason you are not getting
> > > linker errors with this.
> >
> > Granted, this code is hackish. It cannot cause link errors though:
> > nux::Color is in Nux and we only link to NuxCore, not to Nux. I would have
> > used nux::Color directly instead of reimplementing it otherwise.
>
> No. nux::Color is in NuxCore, not Nux.

Oh. Will fix.

Aurélien

lp:~agateau/unity-2d/unity-core updated
680. By Aurélien Gâteau

Synced with gtk3 branch

681. By Aurélien Gâteau

[build] Fix build with libunity-core 4.4

UnityCore.h has been removed

Revision history for this message
Florian Boucault (fboucault) wrote :

lp:unity-2d/4.0 saw quite a few updates which caused a couple of conflicts. Do you mind fixing them while I do the code review?

Revision history for this message
Florian Boucault (fboucault) wrote :

It seems like quite a few panel bugs got fixed by this piece, nice!

I don't see any background gradient in the panel anymore, is that expected?
Also the datetime indicator is there but tiny (easy to spot by navigating with the keyboard in the panel).

Revision history for this message
Florian Boucault (fboucault) wrote :

> Also the datetime indicator is there but tiny (easy to spot by navigating with
> the keyboard in the panel).

This is fixed now for some reason.

Revision history for this message
Florian Boucault (fboucault) wrote :

* Height of 24 pixels is hardcoded in various places. It would be nice to define it only once.

* Texts in panel do not have a shadow (sunken) like in Unity 3D.
* In the indicator with the username displayed in it (is it called 'me menu'?), the icon is not vertically centered like in Unity 3D.

* In panel/applets/appname/menubarwidget.cpp:

bool MenuBarWidget::isOpened() const
{
    // FIXME
[...]

What is the FIXME about?

* Do you know why does the shared panel backend need to know about the geometry of the indicators?

Have you tested the new panel with multiple monitors? I don't have the means to do it at the moment unfortunately.

review: Needs Fixing
Revision history for this message
Aurélien Gâteau (agateau) wrote :

> lp:unity-2d/4.0 saw quite a few updates which caused a couple of conflicts. Do
> you mind fixing them while I do the code review?

I have a whole stack of branches right now but they are targeting trunk, not 4.0. Should I change this so they all target 4.0?

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> It seems like quite a few panel bugs got fixed by this piece, nice!
>
> I don't see any background gradient in the panel anymore, is that expected?

This is fixed in the next branch (use-gtk-rendering)

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> * Height of 24 pixels is hardcoded in various places. It would be nice to
> define it only once.

Yes, I got rid of a few of them in the use-gtk-rendering branch, but there are a few remainings.

> * Texts in panel do not have a shadow (sunken) like in Unity 3D.
> * In the indicator with the username displayed in it (is it called 'me
> menu'?), the icon is not vertically centered like in Unity 3D.

Both fixed in use-gtk-rendering.

> * In panel/applets/appname/menubarwidget.cpp:
>
> bool MenuBarWidget::isOpened() const
> {
> // FIXME
> [...]
>
> What is the FIXME about?

I just forgot to remove the comment. Fixed.

>
> * Do you know why does the shared panel backend need to know about the
> geometry of the indicators?

This is for accessibility support.

> Have you tested the new panel with multiple monitors? I don't have the means
> to do it at the moment unfortunately.

No I haven't. Will do.

lp:~agateau/unity-2d/unity-core updated
682. By Aurélien Gâteau

Remove forgotten FIXME comment

Revision history for this message
Florian Boucault (fboucault) wrote :

> > lp:unity-2d/4.0 saw quite a few updates which caused a couple of conflicts.
> Do
> > you mind fixing them while I do the code review?
>
> I have a whole stack of branches right now but they are targeting trunk, not
> 4.0. Should I change this so they all target 4.0?

Please do. 4.0 is basically the branch targetting oneiric.
For this MR you can drop the prerequisite lp:~agateau/unity-2d/gtk3 as this branch cannot be merged on its own: it basically breaks the indicators more than anything else and I reviewed its code changes as part of this MR.

Revision history for this message
Florian Boucault (fboucault) wrote :

Once you resubmitted this one and we are sure it works as before on multi monitors setup, it's good to merge (it will need a commit message).
I am onto https://code.launchpad.net/~agateau/unity-2d/use-gtk-rendering/+merge/69113 now.

lp:~agateau/unity-2d/unity-core updated
683. By Aurélien Gâteau

Sync with gtk3

684. By Aurélien Gâteau

Merge unity-2d/4.0 in

685. By Aurélien Gâteau

[panel] Empty commit to close bugs

686. By Aurélien Gâteau

Sync with unity-2d/4.0

687. By Aurélien Gâteau

[panel] Make sure indicators are present on hotplugged monitor

IndicatorsManager should not be shared among panels, otherwise when a new
monitor is plugged after unity-2d-panel startup, we don't get any indicators as
no on_object_added() signal is emitted.

Revision history for this message
Tim Penhey (thumper) wrote :

On Wed, 27 Jul 2011 23:39:33 you wrote:
> Please do. 4.0 is basically the branch targetting oneiric.
> For this MR you can drop the prerequisite lp:~agateau/unity-2d/gtk3 as this
> branch cannot be merged on its own: it basically breaks the indicators
> more than anything else and I reviewed its code changes as part of this
> MR.

Florian,

I regularly have dependent branches that can't be landed by themselves. It is
useful for review purposes. Showing particular changes in their own branch
can make reviews much easier. Merge proposals don't have to be landable by
themselves.

Launchpad knows when branches are merged, and when the subsequent merge
proposal is landed, the dependent merge proposal is marked as merged as well.

Tim

Unmerged revisions

687. By Aurélien Gâteau

[panel] Make sure indicators are present on hotplugged monitor

IndicatorsManager should not be shared among panels, otherwise when a new
monitor is plugged after unity-2d-panel startup, we don't get any indicators as
no on_object_added() signal is emitted.

686. By Aurélien Gâteau

Sync with unity-2d/4.0

685. By Aurélien Gâteau

[panel] Empty commit to close bugs

684. By Aurélien Gâteau

Merge unity-2d/4.0 in

683. By Aurélien Gâteau

Sync with gtk3

682. By Aurélien Gâteau

Remove forgotten FIXME comment

681. By Aurélien Gâteau

[build] Fix build with libunity-core 4.4

UnityCore.h has been removed

680. By Aurélien Gâteau

Synced with gtk3 branch

679. By Aurélien Gâteau

Cleanup

678. By Aurélien Gâteau

Merged gtk3 branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-07-27 12:33:12 +0000
3+++ CMakeLists.txt 2011-07-27 12:33:15 +0000
4@@ -24,38 +24,6 @@
5 find_package(Qt4 REQUIRED)
6 find_package(X11 REQUIRED)
7 find_package(Gettext REQUIRED)
8-<<<<<<< TREE
9-pkg_check_modules(GLIB REQUIRED glib-2.0)
10-pkg_check_modules(GDK REQUIRED gdk-2.0)
11-pkg_check_modules(GTK REQUIRED gtk+-2.0)
12-pkg_check_modules(GIO REQUIRED gio-2.0)
13-pkg_check_modules(WNCK REQUIRED libwnck-1.0)
14-
15-
16-# GSettings schemas
17-pkg_check_modules(GLIB REQUIRED glib-2.0)
18-set (UNITY_2D_SCHEMAS "com.canonical.Unity2d.gschema.xml")
19-set (UNITY_2D_GCONF_CONVERT "unity-2d.convert")
20-set (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/")
21-set (GCONF_CONVERT_DIR "${CMAKE_INSTALL_PREFIX}/share/GConf/gsettings")
22-execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE GLIB_COMPILE_SCHEMAS OUTPUT_STRIP_TRAILING_WHITESPACE)
23-
24-# Run the schemas validator and error if it fails
25-execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${UNITY_2D_DATA_DIR} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
26-
27-if (_schemas_invalid)
28- message (SEND_ERROR "Schemas validation error: ${_schemas_invalid}")
29-endif (_schemas_invalid)
30-
31-# Actually install and recompile the schemas
32-message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
33-install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_SCHEMAS} DESTINATION ${GSETTINGS_DIR})
34-install (CODE "message (STATUS \"Compiling GSettings schemas\")")
35-install (CODE "execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_DIR})")
36-
37-# Install GConf to GSettings conversion file
38-install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR})
39-=======
40 pkg_check_modules(GLIB REQUIRED glib-2.0)
41 pkg_check_modules(GDK REQUIRED gdk-3.0)
42 pkg_check_modules(GTK REQUIRED gtk+-3.0)
43@@ -86,7 +54,6 @@
44
45 # Install GConf to GSettings conversion file
46 install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR})
47->>>>>>> MERGE-SOURCE
48
49 include_directories(
50 ${CMAKE_BINARY_DIR}
51
52=== renamed file 'debian/20_unity-2d-gconf-default' => 'debian/20_ubuntu-2d-gconf-default'
53--- debian/20_unity-2d-gconf-default 2011-07-25 11:56:59 +0000
54+++ debian/20_ubuntu-2d-gconf-default 2011-07-27 12:33:15 +0000
55@@ -1,13 +1,5 @@
56-/apps/gnome-power-manager/lock/use_screensaver_settings true
57-/apps/gnome-power-manager/general/use_time_for_policy false
58-/desktop/gnome/applications/window_manager/default /usr/bin/metacity
59-/desktop/gnome/applications/window_manager/current /usr/bin/metacity
60 /apps/metacity/general/show_maximized_titlebars false
61 /apps/metacity/general/auto_maximize_windows true
62 /apps/metacity/general/capture_before_unmap true
63 /apps/metacity/general/compositing_manager true
64 /apps/metacity/general/compositor_effects false
65-/apps/metacity/general/theme Ambiance
66-/desktop/gnome/interface/gtk_theme Ambiance
67-/desktop/gnome/interface/icon_theme ubuntu-mono-dark
68-/desktop/gnome/peripherals/mouse/cursor_theme DMZ-White
69
70=== renamed file 'debian/20_unity-2d-gconf-mandatory' => 'debian/20_ubuntu-2d-gconf-mandatory'
71--- debian/20_unity-2d-gconf-mandatory 2011-06-15 13:05:38 +0000
72+++ debian/20_ubuntu-2d-gconf-mandatory 2011-07-27 12:33:15 +0000
73@@ -1,3 +1,2 @@
74-/apps/nautilus/preferences/exit_with_last_window false
75 /apps/metacity/global_keybindings/panel_main_menu disabled
76 /apps/metacity/global_keybindings/panel_run_dialog disabled
77
78=== modified file 'debian/changelog'
79--- debian/changelog 2011-07-22 16:57:49 +0000
80+++ debian/changelog 2011-07-27 12:33:15 +0000
81@@ -1,6 +1,7 @@
82 unity-2d (3.8.12-0ubuntu1) UNRELEASED; urgency=low
83
84 [ Florian Boucault ]
85+ * Upstreamed patch 01_build_with_new_indicator.patch
86 * do not run pkgbinarymangler to convert images to 8bit since this breaks
87 the launcher icon background handling. (LP: #809205)
88 (QT upstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-4459)
89@@ -23,7 +24,16 @@
90
91 -- Florian Boucault <florian.boucault@canonical.com> Fri, 22 Jul 2011 18:56:33 +0200
92
93-unity-2d (3.8.10-0ubuntu1) natty; urgency=low
94+unity-2d (3.8.10-0ubuntu2) oneiric; urgency=low
95+
96+ * debian/control:
97+ - rebuild with new indicator 0.4
98+ * 01_build_with_new_indicator.patch:
99+ - patch to build with the new indicator 0.4 stack
100+
101+ -- Didier Roche <didrocks@ubuntu.com> Sun, 10 Jul 2011 23:48:01 +0200
102+
103+unity-2d (3.8.10-0ubuntu1) oneiric; urgency=low
104
105 [ Florian Boucault ]
106 * debian/unity-2d-launcher.install:
107@@ -46,10 +56,17 @@
108 - Missing a GConf schema file for the /desktop/unity-2d/… keys
109 (LP: #750303)
110 - [dash] home screen search hint should be 'Search' (LP: #797825)
111-
112- -- Florian Boucault <florian.boucault@canonical.com> Wed, 13 Jul 2011 11:59:29 +0200
113-
114-unity-2d (3.8.8-0ubuntu1) natty; urgency=low
115+ * debian/unity-2d.gconf-defaults,
116+ debian/20_ubuntu-2d-gconf-default:
117+ - transition some gconf keys from session-wide to system-wide
118+ (LP: #797672, #797676)
119+ * debian/control:
120+ - ensure we are still using gtk2 indicator for alpha2 (LP: #804938)
121+ - bump standards-version
122+
123+ -- Didier Roche <didrocks@ubuntu.com> Mon, 04 Jul 2011 11:05:54 +0200
124+
125+unity-2d (3.8.8-0ubuntu1) oneiric; urgency=low
126
127 [ Didier Roche ]
128 * new upstream release:
129@@ -96,7 +113,21 @@
130
131 -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200
132
133-unity-2d (3.8.6-0ubuntu1) natty; urgency=low
134+unity-2d (3.8.6-0ubuntu3~ppa1) oneiric; urgency=low
135+
136+ * Rebuild with new gcc
137+
138+ -- Didier Roche <didrocks@ubuntu.com> Tue, 07 Jun 2011 15:00:32 +0200
139+
140+unity-2d (3.8.6-0ubuntu2) oneiric; urgency=low
141+
142+ * debian/unity-2d.postinst, debian/unity-2d.postrm:
143+ - remove the magic to set unity-2d in oneiric as the default session in gdm
144+ as it's now installed on the ubuntu CD.
145+
146+ -- Didier Roche <didrocks@ubuntu.com> Wed, 01 Jun 2011 09:42:21 +0200
147+
148+unity-2d (3.8.6-0ubuntu1) oneiric; urgency=low
149
150 * New upstream release:
151 - [launcher] Support static shortcuts in the quicklists. (LP: #669923)
152@@ -140,6 +171,18 @@
153 * debian/libunity-2d-private0.post*
154 - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass
155 -n anymore
156+ * don't install unity-2d session as it's in gnome-session now
157+ * debian/unity-2d.install
158+ debian/20_ubuntu-2d-gconf-default
159+ debian/20_ubuntu-2d-gconf-mandatory
160+ debian/gconf/ubuntu-2d.default.path
161+ debian/gconf/ubuntu-2d.mandatory.path:
162+ - remove uneeded defaults and mandatory
163+ - remove some deprecated keys
164+ - the session is now called ubuntu-2d and not unity-2d anymore
165+ * debian/unity-2d.preinst, debian/unity-2d.postinst
166+ debian/unity-2d.postrm:
167+ - take into account the natty -> oneiric migration with session name change
168
169 -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200
170
171
172=== modified file 'debian/control'
173--- debian/control 2011-07-27 12:33:12 +0000
174+++ debian/control 2011-07-27 12:33:15 +0000
175@@ -20,9 +20,10 @@
176 libindicator3-dev,
177 libgtk-3-dev,
178 libutouch-geis-dev,
179- libstartup-notification0-dev
180-Standards-Version: 3.9.1
181-Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/trunk
182+ libstartup-notification0-dev,
183+ libunity-core-4.0-dev,
184+Standards-Version: 3.9.2
185+Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/oneiric
186
187 Package: unity-2d
188 Architecture: all
189@@ -71,13 +72,13 @@
190 ${misc:Depends},
191 libunity-2d-private0
192 Provides: indicator-renderer
193-Recommends: indicator-application,
194- indicator-appmenu,
195- indicator-datetime,
196- indicator-me,
197- indicator-messages,
198- indicator-session,
199- indicator-sound,
200+Recommends: indicator-application-gtk2,
201+ indicator-appmenu-gtk2,
202+ indicator-datetime-gtk2,
203+ indicator-me-gtk2,
204+ indicator-messages-gtk2,
205+ indicator-session-gtk2,
206+ indicator-sound-gtk2,
207 Description: Unity 2D Panel
208 The Unity 2D panel displays a top panel containing the application menu and
209 various indicators. It is part of Unity 2D and can not run as a standalone
210
211=== renamed file 'debian/gconf/unity-2d.default.path' => 'debian/gconf/ubuntu-2d.default.path'
212--- debian/gconf/unity-2d.default.path 2011-06-15 13:05:38 +0000
213+++ debian/gconf/ubuntu-2d.default.path 2011-07-27 12:33:15 +0000
214@@ -1,3 +1,3 @@
215-# Additional mandatory path for unity-2d experience
216-xml:readonly:/var/lib/gconf/unity-2d.default
217+# Additional mandatory path for ubuntu-2d experience
218+xml:readonly:/var/lib/gconf/ubuntu-2d.default
219
220
221=== renamed file 'debian/gconf/unity-2d.mandatory.path' => 'debian/gconf/ubuntu-2d.mandatory.path'
222--- debian/gconf/unity-2d.mandatory.path 2011-06-15 13:05:38 +0000
223+++ debian/gconf/ubuntu-2d.mandatory.path 2011-07-27 12:33:15 +0000
224@@ -1,3 +1,3 @@
225-# Additional mandatory path for unity-2d experience
226-xml:readonly:/var/lib/gconf/unity-2d.mandatory
227+# Additional mandatory path for ubuntu-2d experience
228+xml:readonly:/var/lib/gconf/ubuntu-2d.mandatory
229
230
231=== modified file 'debian/unity-2d-panel.install'
232--- debian/unity-2d-panel.install 2011-01-14 21:41:39 +0000
233+++ debian/unity-2d-panel.install 2011-07-27 12:33:15 +0000
234@@ -1,4 +1,2 @@
235 usr/bin/unity-2d-panel
236 usr/share/applications/unity-2d-panel.desktop
237-usr/share/unity-2d/panel/artwork/background.png
238-usr/share/unity-2d/panel/artwork/divider.png
239
240=== added file 'debian/unity-2d.gconf-defaults'
241--- debian/unity-2d.gconf-defaults 1970-01-01 00:00:00 +0000
242+++ debian/unity-2d.gconf-defaults 2011-07-27 12:33:15 +0000
243@@ -0,0 +1,4 @@
244+/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]
245+/desktop/unity-2d/launcher/hide_mode 2
246+/desktop/unity-2d/launcher/use_strut false
247+/desktop/unity-2d/launcher/super_key_enable true
248
249=== modified file 'debian/unity-2d.install'
250--- debian/unity-2d.install 2011-07-22 14:44:57 +0000
251+++ debian/unity-2d.install 2011-07-27 12:33:15 +0000
252@@ -1,9 +1,7 @@
253 debian/unity-2d.py /usr/share/apport/package-hooks
254 debian/gconf/* /usr/share/gconf
255-session/unity-2d.desktop /usr/share/xsessions
256-session/2d-ubuntu.session /usr/share/gnome-session/sessions
257-debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory
258-debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default
259+debian/20_ubuntu-2d-gconf-mandatory /usr/share/gconf/ubuntu-2d/mandatory
260+debian/20_ubuntu-2d-gconf-default /usr/share/gconf/ubuntu-2d/default
261 usr/share/locale/*/LC_MESSAGES/unity-2d.mo
262 usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml
263 usr/share/GConf/gsettings
264
265=== modified file 'debian/unity-2d.postinst'
266--- debian/unity-2d.postinst 2011-06-15 13:05:38 +0000
267+++ debian/unity-2d.postinst 2011-07-27 12:33:15 +0000
268@@ -9,24 +9,21 @@
269
270 case "$1" in
271 configure|upgrade)
272- if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
273- /usr/lib/gdm/gdm-set-default-session --keep-old unity-2d || true
274- fi
275 if which update-gconf-defaults >/dev/null 2>&1 ; then
276- mkdir -p /var/lib/gconf/unity-2d.mandatory
277- mkdir -p /var/lib/gconf/unity-2d.default
278+ mkdir -p /var/lib/gconf/ubuntu-2d.mandatory
279+ mkdir -p /var/lib/gconf/ubuntu-2d.default
280 fi
281 ;;
282 triggered)
283 for trigger in $2; do
284 case $trigger in
285- /usr/share/gconf/unity-2d/mandatory)
286- update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \
287- --destination /var/lib/gconf/unity-2d.mandatory --no-signal
288+ /usr/share/gconf/ubuntu-2d/mandatory)
289+ update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
290+ --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
291 ;;
292- /usr/share/gconf/unity-2d/default)
293- update-gconf-defaults --source /usr/share/gconf/unity-2d/default \
294- --destination /var/lib/gconf/unity-2d.default --no-signal
295+ /usr/share/gconf/ubuntu-2d/default)
296+ update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
297+ --destination /var/lib/gconf/ubuntu-2d.default --no-signal
298 ;;
299 esac
300 done
301@@ -39,9 +36,9 @@
302
303 # Upon installation/upgrade, regenerate all databases, because in this case
304 # there will be no trigger run
305-update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \
306- --destination /var/lib/gconf/unity-2d.mandatory --no-signal
307-update-gconf-defaults --source /usr/share/gconf/unity-2d/default \
308- --destination /var/lib/gconf/unity-2d.default --no-signal
309+update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
310+ --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
311+update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
312+ --destination /var/lib/gconf/ubuntu-2d.default --no-signal
313 signal_daemons
314
315
316=== modified file 'debian/unity-2d.postrm'
317--- debian/unity-2d.postrm 2011-06-15 13:05:38 +0000
318+++ debian/unity-2d.postrm 2011-07-27 12:33:15 +0000
319@@ -3,20 +3,17 @@
320
321 case "$1" in
322 remove|purge)
323- if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/unity-2d ]; then
324- update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \
325- --destination /var/lib/gconf/unity-2d.mandatory
326- update-gconf-defaults --source /usr/share/gconf/unity-2d/default \
327- --destination /var/lib/gconf/unity-2d.default
328- fi
329- if [ -d /var/lib/gconf/unity-2d.mandatory ]; then
330- rm -rf /var/lib/gconf/unity-2d.mandatory
331- fi
332- if [ -d /var/lib/gconf/unity-2d.default ]; then
333- rm -rf /var/lib/gconf/unity-2d.default
334- fi
335- if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
336- /usr/lib/gdm/gdm-set-default-session --remove unity-2d || true
337+ if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/ubuntu-2d ]; then
338+ update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
339+ --destination /var/lib/gconf/ubuntu-2d.mandatory
340+ update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
341+ --destination /var/lib/gconf/ubuntu-2d.default
342+ fi
343+ if [ -d /var/lib/gconf/ubuntu-2d.mandatory ]; then
344+ rm -rf /var/lib/gconf/ubuntu-2d.mandatory
345+ fi
346+ if [ -d /var/lib/gconf/ubuntu-2d.default ]; then
347+ rm -rf /var/lib/gconf/ubuntu-2d.default
348 fi
349 ;;
350 esac
351
352=== added file 'debian/unity-2d.preinst'
353--- debian/unity-2d.preinst 1970-01-01 00:00:00 +0000
354+++ debian/unity-2d.preinst 2011-07-27 12:33:15 +0000
355@@ -0,0 +1,16 @@
356+#!/bin/sh
357+set -e
358+
359+case "$1" in
360+ install|upgrade)
361+ if dpkg --compare-versions "$2" le "3.8.6-0ubuntu1"; then
362+ if [ -d /var/lib/gconf/unity-2d.mandatory ]; then
363+ mv /var/lib/gconf/unity-2d.mandatory /var/lib/gconf/ubuntu-2d.mandatory || true
364+ mv /var/lib/gconf/unity-2d.default /var/lib/gconf/ubuntu-2d.default || true
365+ fi
366+ fi
367+ ;;
368+esac
369+
370+#DEBHELPER#
371+
372
373=== modified file 'libunity-2d-private/Unity2d/CMakeLists.txt'
374--- libunity-2d-private/Unity2d/CMakeLists.txt 2011-07-27 12:33:12 +0000
375+++ libunity-2d-private/Unity2d/CMakeLists.txt 2011-07-27 12:33:15 +0000
376@@ -4,13 +4,8 @@
377 pkg_check_modules(QTDEE REQUIRED libqtdee)
378 pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
379 pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0)
380-<<<<<<< TREE
381-pkg_check_modules(INDICATOR REQUIRED indicator)
382-pkg_check_modules(DCONFQT REQUIRED dconf-qt)
383-=======
384 pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)
385 pkg_check_modules(DCONFQT REQUIRED dconf-qt)
386->>>>>>> MERGE-SOURCE
387
388 # Sources
389 set(unity-2d-private-qml_SRCS
390
391=== modified file 'libunity-2d-private/src/CMakeLists.txt'
392--- libunity-2d-private/src/CMakeLists.txt 2011-07-27 12:33:12 +0000
393+++ libunity-2d-private/src/CMakeLists.txt 2011-07-27 12:33:15 +0000
394@@ -1,5 +1,6 @@
395 # Sources
396 set(libunity-2d-private_SRCS
397+ debug.cpp
398 gconnector.cpp
399 gnomesessionclient.cpp
400 keyboardmodifiersmonitor.cpp
401
402=== added file 'libunity-2d-private/src/debug.cpp'
403--- libunity-2d-private/src/debug.cpp 1970-01-01 00:00:00 +0000
404+++ libunity-2d-private/src/debug.cpp 2011-07-27 12:33:15 +0000
405@@ -0,0 +1,23 @@
406+/* This file is part of unity-2d
407+ Copyright 2011 Canonical
408+ Author: Aurelien Gateau <aurelien.gateau@canonical.com>
409+
410+ This program is free software; you can redistribute it and/or modify
411+ it under the terms of the GNU General Public License as published
412+ by the Free Software Foundation; version 3.
413+
414+ This program is distributed in the hope that it will be useful,
415+ but WITHOUT ANY WARRANTY; without even the implied warranty of
416+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
417+ GNU General Public License for more details.
418+
419+ You should have received a copy of the GNU General Public License
420+ along with this program. If not, see <http://www.gnu.org/licenses/>.
421+ */
422+// Self
423+#include <debug_p.h>
424+
425+QDebug operator<<(QDebug& dbg, const std::string& str)
426+{
427+ return dbg << QString::fromUtf8(str.c_str());
428+}
429
430=== modified file 'libunity-2d-private/src/debug_p.h'
431--- libunity-2d-private/src/debug_p.h 2011-03-28 14:06:14 +0000
432+++ libunity-2d-private/src/debug_p.h 2011-07-27 12:33:15 +0000
433@@ -17,8 +17,12 @@
434 #ifndef DEBUG_P_H
435 #define DEBUG_P_H
436
437+// Qt
438 #include <QDebug>
439
440+// STL
441+#include <string>
442+
443 #define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space()
444
445 // Simple macros to get KDebug like support
446@@ -62,5 +66,7 @@
447
448 #define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__)
449
450+// Support for outputing std::string with qDebug
451+QDebug operator<<(QDebug& dbg, const std::string& str);
452
453 #endif /* DEBUG_P_H */
454
455=== modified file 'libunity-2d-private/src/unity2dapplication.cpp'
456--- libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 12:33:12 +0000
457+++ libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 12:33:15 +0000
458@@ -41,30 +41,6 @@
459 }
460 }
461
462-<<<<<<< TREE
463-void Unity2dApplication::earlySetup(int& argc, char** argv)
464-{
465- // Parts of unity-2d uses GTK so it needs to be initialized
466- gtk_init(&argc, &argv);
467-
468- Unity2dDebug::installHandlers();
469-
470- /* When the environment variable QT_GRAPHICSSYSTEM is not set, force
471- * graphics system to 'raster' instead of the default 'native' which on X11
472- * is 'XRender'. 'XRender' defaults to using a TrueColor visual. We do
473- * _not_ mimick that behaviour with 'raster' by calling
474- * QApplication::setColorSpec because of bugs where some pixmaps become
475- * blueish or black rectangular artifacts were appearing randomly:
476- *
477- * https://bugs.launchpad.net/unity-2d/+bug/689877
478- * https://bugs.launchpad.net/unity-2d/+bug/734143
479- */
480- if(getenv("QT_GRAPHICSSYSTEM") == 0) {
481- QApplication::setGraphicsSystem("raster");
482- }
483-}
484-
485-=======
486 static bool arrayContains(char** begin, char** end, const char* string)
487 {
488 for (char** ptr = begin; ptr != end; ++ptr) {
489@@ -105,7 +81,6 @@
490 }
491 }
492
493->>>>>>> MERGE-SOURCE
494 Unity2dApplication::Unity2dApplication(int& argc, char** argv)
495 : QApplication(argc, argv)
496 {
497
498=== modified file 'panel/CMakeLists.txt'
499--- panel/CMakeLists.txt 2011-06-27 13:40:51 +0000
500+++ panel/CMakeLists.txt 2011-07-27 12:33:15 +0000
501@@ -1,5 +1,8 @@
502 project(unity-2d-panel)
503
504+# Dependencies
505+pkg_check_modules(UNITYCORE REQUIRED unity-core-4.0)
506+
507 # Source
508 include_directories(
509 ${libunity-2d-private_SOURCE_DIR}/src
510@@ -8,8 +11,3 @@
511 add_subdirectory(applets)
512 add_subdirectory(app)
513 add_subdirectory(tests)
514-
515-# Install
516-install(DIRECTORY artwork
517- DESTINATION ${UNITY_2D_DIR}/panel
518- )
519
520=== modified file 'panel/app/CMakeLists.txt'
521--- panel/app/CMakeLists.txt 2011-07-27 12:33:12 +0000
522+++ panel/app/CMakeLists.txt 2011-07-27 12:33:15 +0000
523@@ -12,6 +12,7 @@
524 ${GTK_INCLUDE_DIRS}
525 ${uqapplets_SOURCE_DIR}
526 ${uqapplets_SOURCE_DIR}/common
527+ ${UNITYCORE_INCLUDE_DIRS}
528 ${libunity-2d-private_SOURCE_DIR}/src
529 )
530
531
532=== modified file 'panel/app/main.cpp'
533--- panel/app/main.cpp 2011-07-27 12:33:12 +0000
534+++ panel/app/main.cpp 2011-07-27 12:33:15 +0000
535@@ -22,6 +22,7 @@
536 // Local
537 #include <config.h>
538 #include <panelmanager.h>
539+#include <panelstyle.h>
540
541 // Unity
542 #include <gnomesessionclient.h>
543@@ -54,6 +55,9 @@
544 Unity2dApplication::earlySetup(argc, argv);
545 Unity2dApplication app(argc, argv);
546
547+ // Instantiate a PanelStyle so that it configures QApplication
548+ PanelStyle::instance();
549+
550 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop");
551 client.connectToSessionManager();
552
553
554=== modified file 'panel/app/panelmanager.cpp'
555--- panel/app/panelmanager.cpp 2011-06-12 23:01:35 +0000
556+++ panel/app/panelmanager.cpp 2011-07-27 12:33:15 +0000
557@@ -24,6 +24,8 @@
558
559 // Local
560 #include <config.h>
561+#include <panelstyle.h>
562+#include <indicatorsmanager.h>
563
564 // Applets
565 #include <appindicator/appindicatorapplet.h>
566@@ -42,35 +44,37 @@
567
568 using namespace Unity2d;
569
570-static QPalette getPalette()
571-{
572- QPalette palette;
573-
574- /* Should use the panel's background provided by Unity but it turns
575- out not to be good. It would look like:
576-
577- QBrush bg(QPixmap("theme:/panel_background.png"));
578- */
579- QBrush bg(QPixmap(unity2dDirectory() + "/panel/artwork/background.png"));
580- palette.setBrush(QPalette::Window, bg);
581- palette.setBrush(QPalette::Button, bg);
582- return palette;
583-}
584-
585-static QLabel* createSeparator()
586-{
587- QLabel* label = new QLabel;
588- QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png");
589- label->setPixmap(pix);
590- label->setFixedSize(pix.size());
591- return label;
592-}
593-
594-static Unity2dPanel* instantiatePanel(int screen)
595+static QWidget* createSeparator()
596+{
597+ // Just a quick-hack: homebutton is going away anyway
598+ QWidget* widget = new QWidget;
599+ widget->setFixedWidth(6);
600+ return widget;
601+}
602+
603+PanelManager::PanelManager(QObject* parent)
604+: QObject(parent)
605+, m_indicatorsManager(new IndicatorsManager(this))
606+{
607+ QDesktopWidget* desktop = QApplication::desktop();
608+ for(int i = 0; i < desktop->screenCount(); ++i) {
609+ Unity2dPanel* panel = instantiatePanel(i);
610+ m_panels.append(panel);
611+ panel->show();
612+ panel->move(desktop->screenGeometry(i).topLeft());
613+ }
614+ connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
615+}
616+
617+PanelManager::~PanelManager()
618+{
619+ qDeleteAll(m_panels);
620+}
621+
622+Unity2dPanel* PanelManager::instantiatePanel(int screen)
623 {
624 Unity2dPanel* panel = new Unity2dPanel;
625 panel->setEdge(Unity2dPanel::TopEdge);
626- panel->setPalette(getPalette());
627 panel->setFixedHeight(24);
628
629 int leftmost = QApplication::desktop()->screenNumber(QPoint());
630@@ -78,34 +82,16 @@
631 panel->addWidget(new HomeButtonApplet);
632 panel->addWidget(createSeparator());
633 }
634- panel->addWidget(new AppNameApplet);
635+ panel->addWidget(new AppNameApplet(m_indicatorsManager));
636 if (screen == leftmost) {
637 /* It doesn’t make sense to have more than one instance of the systray,
638 XEmbed’ed windows can be displayed only once anyway. */
639 panel->addWidget(new LegacyTrayApplet);
640 }
641- panel->addWidget(new IndicatorApplet);
642+ panel->addWidget(new IndicatorApplet(m_indicatorsManager));
643 return panel;
644 }
645
646-PanelManager::PanelManager(QObject* parent)
647- : QObject(parent)
648-{
649- QDesktopWidget* desktop = QApplication::desktop();
650- for(int i = 0; i < desktop->screenCount(); ++i) {
651- Unity2dPanel* panel = instantiatePanel(i);
652- m_panels.append(panel);
653- panel->show();
654- panel->move(desktop->screenGeometry(i).topLeft());
655- }
656- connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
657-}
658-
659-PanelManager::~PanelManager()
660-{
661- qDeleteAll(m_panels);
662-}
663-
664 void
665 PanelManager::onScreenCountChanged(int newCount)
666 {
667
668=== modified file 'panel/app/panelmanager.h'
669--- panel/app/panelmanager.h 2011-04-04 16:41:15 +0000
670+++ panel/app/panelmanager.h 2011-07-27 12:33:15 +0000
671@@ -26,6 +26,7 @@
672 #include <QObject>
673 #include <QList>
674
675+class IndicatorsManager;
676 class Unity2dPanel;
677
678 class PanelManager : public QObject
679@@ -38,8 +39,11 @@
680
681 private:
682 Q_DISABLE_COPY(PanelManager)
683+ IndicatorsManager* m_indicatorsManager;
684 QList<Unity2dPanel*> m_panels;
685
686+ Unity2dPanel* instantiatePanel(int screen);
687+
688 private Q_SLOTS:
689 void onScreenCountChanged(int newCount);
690 };
691
692=== modified file 'panel/applets/CMakeLists.txt'
693--- panel/applets/CMakeLists.txt 2011-07-27 12:33:12 +0000
694+++ panel/applets/CMakeLists.txt 2011-07-27 12:33:15 +0000
695@@ -1,29 +1,11 @@
696 project(uqapplets)
697
698-macro(read_pkg_variable cmake_var pkg pkg_var)
699- execute_process(
700- COMMAND pkg-config --variable=${pkg_var} ${pkg}
701- OUTPUT_VARIABLE tmp
702- )
703- # Remove trailing newline from ${tmp}
704- string(STRIP "${tmp}" ${cmake_var})
705-endmacro(read_pkg_variable)
706-
707 # Dependencies
708 include(FindPkgConfig)
709
710 pkg_check_modules(QTBAMF REQUIRED libqtbamf)
711 pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
712-<<<<<<< TREE
713-pkg_check_modules(INDICATOR REQUIRED indicator)
714-=======
715-pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)
716->>>>>>> MERGE-SOURCE
717-
718-# Get indicator dirs from pkgconfig
719-read_pkg_variable(INDICATOR_DIR indicator3 indicatordir)
720-read_pkg_variable(INDICATOR_ICONS_DIR indicator3 iconsdir)
721-configure_file(indicator-config.h.in indicator-config.h)
722+pkg_check_modules(PANGO REQUIRED pango)
723
724 # Sources
725 set(uqapplets_SRCS
726@@ -31,13 +13,15 @@
727 appindicator/sniitem.cpp
728 appname/appnameapplet.cpp
729 appname/menubarwidget.cpp
730- appname/registrar.cpp
731 appname/windowhelper.cpp
732 common/applet.cpp
733+ common/indicatorentrywidget.cpp
734+ common/indicatorsmanager.cpp
735+ common/indicatorwidget.cpp
736+ common/panelstyle.cpp
737 homebutton/homebuttonapplet.cpp
738 homebutton/homebutton.cpp
739 indicator/indicatorapplet.cpp
740- indicator/indicator.c
741 legacytray/legacytrayapplet.cpp
742 legacytray/fdoselectionmanager.cpp
743 legacytray/fdotask.cpp
744@@ -46,10 +30,6 @@
745 legacytray/x11embedpainter.cpp
746 )
747
748-qt4_add_dbus_adaptor(uqapplets_SRCS appname/com.canonical.AppMenu.Registrar.xml
749- registrar.h Registrar
750- )
751-
752 qt4_automoc(${uqapplets_SRCS})
753
754 # Build
755@@ -59,13 +39,15 @@
756 ${CMAKE_CURRENT_SOURCE_DIR}/common
757 ${CMAKE_CURRENT_SOURCE_DIR}/homebutton
758 ${CMAKE_CURRENT_SOURCE_DIR}/indicator
759+ ${CMAKE_CURRENT_SOURCE_DIR}/unitycore
760 ${QTBAMF_INCLUDE_DIRS}
761 ${DBUSMENUQT_INCLUDE_DIRS}
762 ${GTK_INCLUDE_DIRS}
763- ${INDICATOR_INCLUDE_DIRS}
764 ${WNCK_INCLUDE_DIRS}
765 ${CMAKE_CURRENT_BINARY_DIR}
766 ${X11_INCLUDE_DIR}
767+ ${UNITYCORE_INCLUDE_DIRS}
768+ ${PANGO_INCLUDE_DIRS}
769 ${libunity-2d-private_SOURCE_DIR}/src
770 )
771
772@@ -77,12 +59,13 @@
773 ${DBUSMENUQT_LDFLAGS}
774 ${QTBAMF_LDFLAGS}
775 ${GTK_LDFLAGS}
776- ${INDICATOR_LDFLAGS}
777 ${WNCK_LDFLAGS}
778 ${X11_LIBRARIES}
779 ${X11_Xrender_LIB}
780 ${X11_Xcomposite_LIB}
781 ${X11_Xdamage_LIB}
782 ${X11_Xfixes_LIB}
783+ ${UNITYCORE_LDFLAGS}
784+ ${PANGO_LDFLAGS}
785 unity-2d-private
786 )
787
788=== modified file 'panel/applets/appname/appnameapplet.cpp'
789--- panel/applets/appname/appnameapplet.cpp 2011-07-27 12:33:12 +0000
790+++ panel/applets/appname/appnameapplet.cpp 2011-07-27 12:33:15 +0000
791@@ -200,10 +200,10 @@
792 q, SLOT(updateWidgets()));
793 }
794
795- void setupMenuBarWidget()
796+ void setupMenuBarWidget(IndicatorsManager* manager)
797 {
798- m_menuBarWidget = new MenuBarWidget(0 /* Window menu */);
799- QObject::connect(m_menuBarWidget, SIGNAL(menuBarChanged()),
800+ m_menuBarWidget = new MenuBarWidget(manager);
801+ QObject::connect(m_menuBarWidget, SIGNAL(isOpenedChanged()),
802 q, SLOT(updateWidgets()));
803 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),
804 q, SLOT(updateWidgets()));
805@@ -216,21 +216,16 @@
806 }
807 };
808
809-AppNameApplet::AppNameApplet()
810+AppNameApplet::AppNameApplet(IndicatorsManager* indicatorsManager)
811 : d(new AppNameAppletPrivate)
812 {
813 d->q = this;
814 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
815
816- QPalette palette;
817- palette.setColor(QPalette::WindowText, Qt::white);
818- palette.setColor(QPalette::ButtonText, Qt::white);
819- setPalette(palette);
820-
821 d->setupWindowHelper();
822 d->setupLabel();
823 d->setupWindowButtonWidget();
824- d->setupMenuBarWidget();
825+ d->setupMenuBarWidget(indicatorsManager);
826 d->setupKeyboardModifiersMonitor();
827
828 QHBoxLayout* layout = new QHBoxLayout(this);
829
830=== modified file 'panel/applets/appname/appnameapplet.h'
831--- panel/applets/appname/appnameapplet.h 2011-06-06 09:06:55 +0000
832+++ panel/applets/appname/appnameapplet.h 2011-07-27 12:33:15 +0000
833@@ -29,6 +29,8 @@
834
835 class QEvent;
836
837+class IndicatorsManager;
838+
839 namespace Unity2d
840 {
841
842@@ -37,7 +39,7 @@
843 {
844 Q_OBJECT
845 public:
846- AppNameApplet();
847+ AppNameApplet(IndicatorsManager*);
848 ~AppNameApplet();
849
850 protected:
851
852=== removed file 'panel/applets/appname/com.canonical.AppMenu.Registrar.xml'
853--- panel/applets/appname/com.canonical.AppMenu.Registrar.xml 2011-02-10 01:10:19 +0000
854+++ panel/applets/appname/com.canonical.AppMenu.Registrar.xml 1970-01-01 00:00:00 +0000
855@@ -1,82 +0,0 @@
856-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
857-<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
858- <dox:d><![CDATA[
859- @mainpage
860-  
861- An interface to register menus that are associated with a window in an application.  The
862- main interface is docuemented here: @ref com::canonical::AppMenu::Registrar.
863-     
864- The actual menus are transported using the dbusmenu protocol which is available
865- here: @ref com::canonical::dbusmenu.
866- ]]></dox:d>
867- <interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
868- <dox:d>
869- An interface to register a menu from an application's window to be displayed in another
870- window.  This manages that association between XWindow Window IDs and the dbus
871- address and object that provides the menu using the dbusmenu dbus interface.
872- </dox:d>
873- <method name="RegisterWindow">
874- <dox:d><![CDATA[
875- Associates a dbusmenu with a window
876-      
877- /note this method assumes that the connection from the caller is the DBus connection
878- to use for the object.  Applications that use multiple DBus connections will need to
879- ensure this method is called with the same connection that implmenets the object.
880- ]]></dox:d>
881- <arg name="windowId" type="u" direction="in">
882- <dox:d>The XWindow ID of the window</dox:d>
883- </arg>
884- <arg name="menuObjectPath" type="o" direction="in">
885- <dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d>
886- </arg>
887- </method>
888- <method name="UnregisterWindow">
889- <dox:d>
890- A method to allow removing a window from the database. Windows will also be removed
891- when the client drops off DBus so this is not required. It is polite though. And
892- important for testing.
893- </dox:d>
894- <arg name="windowId" type="u" direction="in">
895- <dox:d>The XWindow ID of the window</dox:d>
896- </arg>
897- </method>
898- <method name="GetMenuForWindow">
899- <dox:d>Gets the registered menu for a given window ID.</dox:d>
900- <arg name="windowId" type="u" direction="in">
901- <dox:d>The XWindow ID of the window to get</dox:d>
902- </arg>
903- <arg name="service" type="s" direction="out">
904- <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
905- </arg>
906- <arg name="menuObjectPath" type="o" direction="out">
907- <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
908- </arg>
909- </method>
910- <method name="GetMenus">
911- <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MenuInfoList"/>
912- <dox:d>Gets the information on all menus that the registrar knows about. This
913- is useful for debugging or bringing up a new renderer.</dox:d>
914- <arg name="menus" type="a(uso)" direction="out">
915- <dox:d>An array of structures containing the same parameters as @GetMenuForWindow. Window ID, Service and ObjectPath.</dox:d>
916- </arg>
917- </method>
918- <signal name="WindowRegistered">
919- <dox:d>Signals when the registrar gets a new menu registered</dox:d>
920- <arg name="windowId" type="u" direction="out">
921- <dox:d>The XWindow ID of the window</dox:d>
922- </arg>
923- <arg name="service" type="s" direction="out">
924- <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
925- </arg>
926- <arg name="menuObjectPath" type="o" direction="out">
927- <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
928- </arg>
929- </signal>
930- <signal name="WindowUnregistered">
931- <dox:d>Signals when the registrar removes a menu registration</dox:d>
932- <arg name="windowId" type="u" direction="out">
933- <dox:d>The XWindow ID of the window</dox:d>
934- </arg>
935- </signal>
936- </interface>
937-</node>
938
939=== modified file 'panel/applets/appname/menubarwidget.cpp'
940--- panel/applets/appname/menubarwidget.cpp 2011-07-27 12:33:12 +0000
941+++ panel/applets/appname/menubarwidget.cpp 2011-07-27 12:33:15 +0000
942@@ -20,312 +20,98 @@
943 */
944
945 // Self
946-#include "menubarwidget.h"
947+#include <menubarwidget.h>
948
949 // Local
950-#include "config.h"
951-#include "debug_p.h"
952-#include "keyboardmodifiersmonitor.h"
953-#include "registrar.h"
954-
955-// dbusmenu-qt
956-#include <dbusmenuimporter.h>
957-
958-// bamf
959-#include <bamf-matcher.h>
960-#include <bamf-window.h>
961+#include <debug_p.h>
962+#include <indicatorentrywidget.h>
963+#include <indicatorsmanager.h>
964
965 // Qt
966-#include <QActionEvent>
967 #include <QHBoxLayout>
968-#include <QLabel>
969-#include <QMenuBar>
970-#include <QTimer>
971-
972-class MyDBusMenuImporter : public DBusMenuImporter
973-{
974-public:
975- MyDBusMenuImporter(const QString &service, const QString &path, QObject *parent)
976- : DBusMenuImporter(service, path, parent)
977- , m_service(service)
978- , m_path(path)
979- {}
980-
981- QString service() const { return m_service; }
982- QString path() const { return m_path; }
983-
984-private:
985- QString m_service;
986- QString m_path;
987-};
988-
989-MenuBarWidget::MenuBarWidget(QMenu* windowMenu, QWidget* parent)
990+
991+static const int MENU_ITEM_PADDING = 6;
992+
993+MenuBarWidget::MenuBarWidget(IndicatorsManager* indicatorsManager, QWidget* parent)
994 : QWidget(parent)
995-, m_windowMenu(windowMenu)
996-, m_isMenuOpen(false)
997-{
998- m_activeWinId = 0;
999- setupRegistrar();
1000- setupMenuBar();
1001-
1002- connect(&BamfMatcher::get_default(), SIGNAL(ActiveWindowChanged(BamfWindow*, BamfWindow*)),
1003- SLOT(slotActiveWindowChanged(BamfWindow*, BamfWindow*)));
1004- /* Work around a bug in BAMF: the ActiveWindowChanged signal is not emitted
1005- for some windows that open maximized. This is for example the case of the
1006- LibreOffice startcenter. */
1007- connect(&BamfMatcher::get_default(), SIGNAL(ViewOpened(BamfView*)),
1008- SLOT(slotViewOpened()));
1009- updateActiveWinId(BamfMatcher::get_default().active_window());
1010-}
1011-
1012-void MenuBarWidget::setupRegistrar()
1013-{
1014- m_registrar = Registrar::instance();
1015- if (!m_registrar->connectToBus()) {
1016- UQ_WARNING << "could not connect registrar to DBus";
1017- }
1018-
1019- connect(m_registrar, SIGNAL(WindowRegistered(WId, const QString&, const QDBusObjectPath&)),
1020- SLOT(slotWindowRegistered(WId, const QString&, const QDBusObjectPath&)));
1021- connect(m_registrar, SIGNAL(WindowUnregistered(WId)),
1022- SLOT(slotWindowUnregistered(WId)));
1023-}
1024-
1025-void MenuBarWidget::setupMenuBar()
1026-{
1027- m_menuBar = new QMenuBar;
1028- m_menuBarMonitor = new MenuBarClosedHelper(this);
1029-
1030- QHBoxLayout* layout = new QHBoxLayout(this);
1031- layout->setMargin(0);
1032- layout->setSpacing(0);
1033- layout->addWidget(m_menuBar);
1034- m_menuBar->setNativeMenuBar(false);
1035-
1036- m_updateMenuBarTimer = new QTimer(this);
1037- m_updateMenuBarTimer->setSingleShot(true);
1038- m_updateMenuBarTimer->setInterval(0);
1039- connect(m_updateMenuBarTimer, SIGNAL(timeout()),
1040- SLOT(updateMenuBar()));
1041-
1042- // Repaint the menubar when modifiers change so that the shortcut underline
1043- // is drawn or not
1044- connect(KeyboardModifiersMonitor::instance(), SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
1045- m_menuBar, SLOT(update()));
1046-
1047- // Watch when the menubar's menus close so that it can be hidden
1048- connect(m_menuBarMonitor, SIGNAL(menuBarClosed()), SLOT(slotMenuBarClosed()));
1049-}
1050-
1051-void MenuBarWidget::slotActiveWindowChanged(BamfWindow* /*former*/, BamfWindow* current)
1052-{
1053- if (current) {
1054- updateActiveWinId(current);
1055- }
1056-}
1057-
1058-void MenuBarWidget::slotViewOpened()
1059-{
1060- BamfWindow* active = BamfMatcher::get_default().active_window();
1061- if (active != NULL) {
1062- if (active->xid() != m_activeWinId) {
1063- /* This shouldn’t be needed as BAMF should have emitted the
1064- ActiveWindowChanged signal, but it sometimes doesn’t (e.g. when
1065- LibreOffice startcenter starts automatically maximized). */
1066- updateActiveWinId(active);
1067- }
1068- }
1069-}
1070-
1071-void MenuBarWidget::slotWindowRegistered(WId wid, const QString& service, const QDBusObjectPath& menuObjectPath)
1072-{
1073- MyDBusMenuImporter* importer = new MyDBusMenuImporter(service, menuObjectPath.path(), this);
1074- delete m_importers.take(wid);
1075- m_importers.insert(wid, importer);
1076- connect(importer, SIGNAL(menuUpdated()), SLOT(slotMenuUpdated()));
1077- connect(importer, SIGNAL(actionActivationRequested(QAction*)), SLOT(slotActionActivationRequested(QAction*)));
1078- QMetaObject::invokeMethod(importer, "updateMenu", Qt::QueuedConnection);
1079-}
1080-
1081-void MenuBarWidget::slotWindowUnregistered(WId wid)
1082-{
1083- MyDBusMenuImporter* importer = m_importers.take(wid);
1084- if (importer) {
1085- importer->deleteLater();
1086- }
1087- if (wid == m_activeWinId) {
1088- m_activeWinId = 0;
1089- updateMenuBar();
1090- }
1091-}
1092-
1093-void MenuBarWidget::slotMenuUpdated()
1094-{
1095- DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
1096-
1097- if (m_importers.value(m_activeWinId) == importer) {
1098- updateMenuBar();
1099- }
1100-}
1101-
1102-void MenuBarWidget::slotActionActivationRequested(QAction* action)
1103-{
1104- DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
1105-
1106- if (m_importers.value(m_activeWinId) == importer) {
1107- m_isMenuOpen = true;
1108- Q_EMIT menuBarChanged();
1109- m_menuBar->setActiveAction(action);
1110- }
1111-}
1112-
1113-void MenuBarWidget::slotMenuBarClosed()
1114-{
1115- m_isMenuOpen = false;
1116- Q_EMIT menuBarChanged();
1117-}
1118-
1119-QMenu* MenuBarWidget::menuForWinId(WId wid) const
1120-{
1121- MyDBusMenuImporter* importer = m_importers.value(wid);
1122- return importer ? importer->menu() : 0;
1123-}
1124-
1125-void MenuBarWidget::updateActiveWinId(BamfWindow* bamfWindow)
1126-{
1127- WId id = bamfWindow ? bamfWindow->xid() : 0;
1128- if (id == m_activeWinId) {
1129- return;
1130- }
1131- if (id == window()->winId()) {
1132- // Do not update id if the active window is the one hosting this applet
1133- return;
1134- }
1135- m_activeWinId = id;
1136- updateMenuBar();
1137-}
1138-
1139-void MenuBarWidget::updateMenuBar()
1140-{
1141- WId winId = m_activeWinId;
1142- QMenu* menu = menuForWinId(winId);
1143-
1144- if (!menu) {
1145- if (winId) {
1146- menu = m_windowMenu;
1147- } else {
1148- // No active window, show a desktop menubar
1149- // FIXME: Empty menu
1150- /*
1151- menu = mEmptyMenu;
1152- */
1153- }
1154- }
1155-
1156- m_menuBar->clear();
1157- // FIXME: Empty menu
1158- if (!menu) {
1159- return;
1160- }
1161- menu->installEventFilter(this);
1162- Q_FOREACH(QAction* action, menu->actions()) {
1163- if (action->isSeparator()) {
1164- continue;
1165- }
1166- m_menuBar->addAction(action);
1167- }
1168-}
1169-
1170-bool MenuBarWidget::eventFilter(QObject* object, QEvent* event)
1171-{
1172- switch (event->type()) {
1173- case QEvent::ActionAdded:
1174- case QEvent::ActionRemoved:
1175- case QEvent::ActionChanged:
1176- m_updateMenuBarTimer->start();
1177- break;
1178- default:
1179- break;
1180- }
1181- return false;
1182+, m_indicatorsManager(indicatorsManager)
1183+, m_layout(new QHBoxLayout(this))
1184+, m_isEmpty(true)
1185+, m_isOpened(false)
1186+{
1187+ m_layout->setMargin(0);
1188+ m_layout->setSpacing(0);
1189+ indicatorsManager->indicators()->on_object_added.connect(
1190+ sigc::mem_fun(this, &MenuBarWidget::onObjectAdded)
1191+ );
1192+ indicatorsManager->indicators()->on_entry_activated.connect(
1193+ sigc::mem_fun(this, &MenuBarWidget::onEntryActivated)
1194+ );
1195+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
1196+ m_layout->addStretch();
1197 }
1198
1199 bool MenuBarWidget::isEmpty() const
1200 {
1201- return m_menuBar->actions().isEmpty();
1202+ return m_isEmpty;
1203 }
1204
1205 bool MenuBarWidget::isOpened() const
1206 {
1207- return m_isMenuOpen;
1208-}
1209-
1210-// MenuBarClosedHelper ----------------------------------------
1211-MenuBarClosedHelper::MenuBarClosedHelper(MenuBarWidget* widget)
1212-: QObject(widget)
1213-, m_widget(widget)
1214-{
1215- widget->m_menuBar->installEventFilter(this);
1216-}
1217-
1218-bool MenuBarClosedHelper::eventFilter(QObject* object, QEvent* event)
1219-{
1220- if (object == m_widget->m_menuBar) {
1221- switch (event->type()) {
1222- case QEvent::ActionAdded:
1223- case QEvent::ActionRemoved:
1224- case QEvent::ActionChanged:
1225- menuBarActionEvent(static_cast<QActionEvent*>(event));
1226- break;
1227- default:
1228- break;
1229- }
1230- } else {
1231- // Top-level menus
1232- if (event->type() == QEvent::Hide) {
1233- // menu hide themselves when the menubar is closed but also when
1234- // one goes from one menu to another. The way to know this is to
1235- // check the value of QMenuBar::activeAction(), but at this point
1236- // it has not been updated yet, so we check in a delayed method.
1237- QMetaObject::invokeMethod(this, "emitMenuBarClosed", Qt::QueuedConnection);
1238- }
1239- }
1240- return false;
1241-}
1242-
1243-void MenuBarClosedHelper::emitMenuBarClosed()
1244-{
1245- //If there is still no menu action active, then menu must be closed.
1246- if (!m_widget->m_menuBar->activeAction()) {
1247- Q_EMIT menuBarClosed();
1248- }
1249-}
1250-
1251-void MenuBarClosedHelper::menuBarActionEvent(QActionEvent* event)
1252-{
1253- QMenu* menu = event->action()->menu();
1254- if (menu) {
1255- // Install/remove event filters on top level menus so that know when
1256- // they hide themselves and can emit menuBarClosed()
1257- switch (event->type()) {
1258- case QEvent::ActionAdded:
1259- case QEvent::ActionChanged:
1260- menu->installEventFilter(this);
1261- break;
1262- case QEvent::ActionRemoved:
1263- menu->removeEventFilter(this);
1264- break;
1265- default:
1266- break;
1267- }
1268- }
1269-
1270- // Emit isEmptyChanged() if necessary
1271- QList<QAction*> actions = m_widget->m_menuBar->actions();
1272- if (event->type() == QEvent::ActionAdded && actions.count() == 1) {
1273- QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
1274- } else if (event->type() == QEvent::ActionRemoved && actions.isEmpty()) {
1275- QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
1276+ return m_isOpened;
1277+}
1278+
1279+void MenuBarWidget::onObjectAdded(const unity::indicator::Indicator::Ptr& indicator)
1280+{
1281+ QString name = QString::fromStdString(indicator->name());
1282+ if (name == "libappmenu.so") {
1283+ indicator->on_entry_added.connect(sigc::mem_fun(this, &MenuBarWidget::onEntryAdded));
1284+ }
1285+}
1286+
1287+void MenuBarWidget::onEntryAdded(const unity::indicator::Entry::Ptr& entry)
1288+{
1289+ IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
1290+ widget->setPadding(MENU_ITEM_PADDING);
1291+ connect(widget, SIGNAL(isEmptyChanged()), SLOT(updateIsEmpty()));
1292+
1293+ m_widgetList.append(widget);
1294+ m_indicatorsManager->addIndicatorEntryWidget(widget);
1295+
1296+ // Insert *before* stretch
1297+ m_layout->insertWidget(m_layout->count() - 1, widget);
1298+}
1299+
1300+void MenuBarWidget::updateIsEmpty()
1301+{
1302+ bool empty = true;
1303+ Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
1304+ if (!widget->isEmpty()) {
1305+ empty = false;
1306+ break;
1307+ }
1308+ }
1309+ if (m_isEmpty != empty) {
1310+ m_isEmpty = empty;
1311+ isEmptyChanged();
1312+ }
1313+}
1314+
1315+void MenuBarWidget::onEntryActivated(const std::string& id)
1316+{
1317+ bool isOpened = false;
1318+ if (!id.empty()) {
1319+ // We only cares about menubar entries
1320+ Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
1321+ if (widget->entry()->id() == id) {
1322+ isOpened = true;
1323+ break;
1324+ }
1325+ }
1326+ }
1327+ if (m_isOpened != isOpened) {
1328+ m_isOpened = isOpened;
1329+ isOpenedChanged();
1330 }
1331 }
1332
1333
1334=== modified file 'panel/applets/appname/menubarwidget.h'
1335--- panel/applets/appname/menubarwidget.h 2011-07-27 12:33:12 +0000
1336+++ panel/applets/appname/menubarwidget.h 2011-07-27 12:33:15 +0000
1337@@ -23,92 +23,45 @@
1338 #define MENUBARWIDGET_H
1339
1340 // Qt
1341-#include <QHash>
1342 #include <QWidget>
1343
1344-class BamfWindow;
1345-
1346-class QActionEvent;
1347-class QDBusObjectPath;
1348-class QMenu;
1349-class QMenuBar;
1350-class QTimer;
1351-
1352-class MyDBusMenuImporter;
1353-class Registrar;
1354-
1355-typedef QHash<WId, MyDBusMenuImporter*> ImporterForWId;
1356-
1357-class MenuBarWidget;
1358-
1359-/**
1360- * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed()
1361- * to indicate if the menu was closed or updated.
1362- */
1363-class MenuBarClosedHelper : public QObject
1364-{
1365-Q_OBJECT
1366-public:
1367- MenuBarClosedHelper(MenuBarWidget*);
1368-
1369-Q_SIGNALS:
1370- void menuBarClosed();
1371-
1372-protected:
1373- bool eventFilter(QObject*, QEvent*); //reimp
1374-
1375-private Q_SLOTS:
1376- void emitMenuBarClosed();
1377-
1378-private:
1379- MenuBarWidget* m_widget;
1380- void menuBarActionEvent(QActionEvent*);
1381-};
1382-
1383-class MenuBarWidget : public QWidget
1384-{
1385-Q_OBJECT
1386-public:
1387- MenuBarWidget(QMenu* windowMenu, QWidget* parent = 0);
1388+// libunity-core
1389+#include <UnityCore/Indicator.h>
1390+#include <UnityCore/IndicatorEntry.h>
1391+
1392+class QHBoxLayout;
1393+
1394+class IndicatorEntryWidget;
1395+class IndicatorsManager;
1396+
1397+class MenuBarWidget : public QWidget, public sigc::trackable
1398+{
1399+Q_OBJECT
1400+public:
1401+ MenuBarWidget(IndicatorsManager*, QWidget* parent = 0);
1402
1403 bool isEmpty() const;
1404 bool isOpened() const;
1405
1406 Q_SIGNALS:
1407- void menuBarChanged();
1408+ void isOpenedChanged();
1409 void isEmptyChanged();
1410
1411-protected:
1412- bool eventFilter(QObject*, QEvent*); // reimp
1413-
1414 private Q_SLOTS:
1415- void slotActiveWindowChanged(BamfWindow*, BamfWindow*);
1416- void slotViewOpened();
1417- void slotWindowRegistered(WId, const QString& service, const QDBusObjectPath& menuObjectPath);
1418- void slotWindowUnregistered(WId);
1419- void slotMenuUpdated();
1420- void slotActionActivationRequested(QAction* action);
1421- void slotMenuBarClosed();
1422- void updateMenuBar();
1423+ void updateIsEmpty();
1424
1425 private:
1426 Q_DISABLE_COPY(MenuBarWidget)
1427
1428- QMenuBar* m_menuBar;
1429- MenuBarClosedHelper* m_menuBarMonitor;
1430- Registrar* m_registrar;
1431- ImporterForWId m_importers;
1432- WId m_activeWinId;
1433- QMenu* m_windowMenu;
1434- QTimer* m_updateMenuBarTimer;
1435- bool m_isMenuOpen;
1436-
1437- void setupRegistrar();
1438- void setupMenuBar();
1439- QMenu* menuForWinId(WId) const;
1440- void updateActiveWinId(BamfWindow*);
1441-
1442- friend class MenuBarClosedHelper;
1443+ IndicatorsManager* m_indicatorsManager;
1444+ QHBoxLayout* m_layout;
1445+ bool m_isEmpty;
1446+ bool m_isOpened;
1447+ QList<IndicatorEntryWidget*> m_widgetList;
1448+
1449+ void onObjectAdded(const unity::indicator::Indicator::Ptr&);
1450+ void onEntryAdded(const unity::indicator::Entry::Ptr&);
1451+ void onEntryActivated(const std::string&);
1452 };
1453
1454 #endif /* MENUBARWIDGET_H */
1455
1456=== removed file 'panel/applets/appname/registrar.cpp'
1457--- panel/applets/appname/registrar.cpp 2011-04-04 16:46:14 +0000
1458+++ panel/applets/appname/registrar.cpp 1970-01-01 00:00:00 +0000
1459@@ -1,138 +0,0 @@
1460-/*
1461- * Plasma applet to display application window menus
1462- *
1463- * Copyright 2010 Canonical Ltd.
1464- *
1465- * Authors:
1466- * - Aurélien Gâteau <aurelien.gateau@canonical.com>
1467- *
1468- * This program is free software; you can redistribute it and/or modify
1469- * it under the terms of the GNU General Public License as published by
1470- * the Free Software Foundation; version 3.
1471- *
1472- * This program is distributed in the hope that it will be useful,
1473- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1474- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1475- * GNU General Public License for more details.
1476- *
1477- * You should have received a copy of the GNU General Public License
1478- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1479- */
1480-
1481-// Self
1482-#include "registrar.h"
1483-
1484-// Qt
1485-#include <QApplication>
1486-#include <QDBusMessage>
1487-#include <QDBusObjectPath>
1488-#include <QDBusServiceWatcher>
1489-
1490-// Local
1491-#include "registraradaptor.h"
1492-
1493-static const char* DBUS_SERVICE = "com.canonical.AppMenu.Registrar";
1494-static const char* DBUS_OBJECT_PATH = "/com/canonical/AppMenu/Registrar";
1495-
1496-// Marshalling code for MenuInfo
1497-QDBusArgument& operator<<(QDBusArgument& argument, const MenuInfo& info)
1498-{
1499- argument.beginStructure();
1500- argument << info.winId << info.service << info.path;
1501- argument.endStructure();
1502- return argument;
1503-}
1504-
1505-const QDBusArgument& operator>>(const QDBusArgument& argument, MenuInfo& info)
1506-{
1507- argument.beginStructure();
1508- argument >> info.winId >> info.service >> info.path;
1509- argument.endStructure();
1510- return argument;
1511-}
1512-
1513-Registrar::Registrar()
1514-: QObject()
1515-, mServiceWatcher(new QDBusServiceWatcher(this))
1516-{
1517- qDBusRegisterMetaType<MenuInfo>();
1518- qDBusRegisterMetaType<MenuInfoList>();
1519- mServiceWatcher->setConnection(QDBusConnection::sessionBus());
1520- mServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
1521- connect(mServiceWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
1522-}
1523-
1524-Registrar::~Registrar()
1525-{
1526- QDBusConnection::sessionBus().unregisterService(mService);
1527-}
1528-
1529-Registrar* Registrar::instance()
1530-{
1531- static Registrar singleton;
1532- return &singleton;
1533-}
1534-
1535-bool Registrar::connectToBus(const QString& _service, const QString& _path)
1536-{
1537- mService = _service.isEmpty() ? DBUS_SERVICE : _service;
1538- QString path = _path.isEmpty() ? DBUS_OBJECT_PATH : _path;
1539-
1540- bool ok = QDBusConnection::sessionBus().registerService(mService);
1541- if (!ok) {
1542- return false;
1543- }
1544- new RegistrarAdaptor(this);
1545- QDBusConnection::sessionBus().registerObject(path, this);
1546-
1547- return true;
1548-}
1549-
1550-void Registrar::RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath)
1551-{
1552- MenuInfo info;
1553- info.winId = wid;
1554- info.service = message().service();
1555- info.path = menuObjectPath;
1556- mDb.insert(wid, info);
1557- mServiceWatcher->addWatchedService(info.service);
1558- WindowRegistered(wid, info.service, info.path);
1559-}
1560-
1561-void Registrar::UnregisterWindow(WId wid)
1562-{
1563- mDb.remove(wid);
1564- WindowUnregistered(wid);
1565-}
1566-
1567-QString Registrar::GetMenuForWindow(WId winId, QDBusObjectPath& menuObjectPath)
1568-{
1569- MenuInfo info = mDb.value(winId);
1570- QString service = info.service;
1571- menuObjectPath = info.path;
1572- return service;
1573-}
1574-
1575-MenuInfoList Registrar::GetMenus()
1576-{
1577- return mDb.values();
1578-}
1579-
1580-void Registrar::slotServiceUnregistered(const QString& service)
1581-{
1582- MenuInfoDb::Iterator
1583- it = mDb.begin(),
1584- end = mDb.end();
1585- for (;it != end;) {
1586- if (it.value().service == service) {
1587- WId id = it.key();
1588- it = mDb.erase(it);
1589- WindowUnregistered(id);
1590- } else {
1591- ++it;
1592- }
1593- }
1594- mServiceWatcher->removeWatchedService(service);
1595-}
1596-
1597-#include "registrar.moc"
1598
1599=== removed file 'panel/applets/appname/registrar.h'
1600--- panel/applets/appname/registrar.h 2011-04-04 16:47:28 +0000
1601+++ panel/applets/appname/registrar.h 1970-01-01 00:00:00 +0000
1602@@ -1,85 +0,0 @@
1603-/*
1604- * Plasma applet to display application window menus
1605- *
1606- * Copyright 2010 Canonical Ltd.
1607- *
1608- * Authors:
1609- * - Aurélien Gâteau <aurelien.gateau@canonical.com>
1610- *
1611- * This program is free software; you can redistribute it and/or modify
1612- * it under the terms of the GNU General Public License as published by
1613- * the Free Software Foundation; version 3.
1614- *
1615- * This program is distributed in the hope that it will be useful,
1616- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1617- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1618- * GNU General Public License for more details.
1619- *
1620- * You should have received a copy of the GNU General Public License
1621- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1622- */
1623-
1624-#ifndef REGISTRAR_H
1625-#define REGISTRAR_H
1626-
1627-// Qt
1628-#include <QDBusContext>
1629-#include <QDBusObjectPath>
1630-#include <QObject>
1631-#include <QWidget> // For WId
1632-
1633-class QDBusObjectPath;
1634-class QDBusServiceWatcher;
1635-class QMenu;
1636-
1637-struct MenuInfo
1638-{
1639- MenuInfo()
1640- : winId(0)
1641- , path("/")
1642- {}
1643-
1644- uint winId;
1645- QString service;
1646- QDBusObjectPath path;
1647-};
1648-Q_DECLARE_METATYPE(MenuInfo)
1649-
1650-typedef QList<MenuInfo> MenuInfoList;
1651-Q_DECLARE_METATYPE(MenuInfoList)
1652-
1653-class Registrar : public QObject, protected QDBusContext
1654-{
1655- Q_OBJECT
1656-
1657-public:
1658- /* The registrar is a singleton shared between all instances of MenuBarWidget. */
1659- static Registrar* instance();
1660-
1661- bool connectToBus(const QString& service = QString(), const QString& objectPath = QString());
1662-
1663-Q_SIGNALS:
1664- void WindowRegistered(WId wid, const QString& service, const QDBusObjectPath&);
1665- void WindowUnregistered(WId wid);
1666-
1667-public Q_SLOTS:
1668- Q_NOREPLY void RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath);
1669- Q_NOREPLY void UnregisterWindow(WId wid);
1670- QString GetMenuForWindow(WId wid, QDBusObjectPath& menuObjectPath);
1671- MenuInfoList GetMenus();
1672-
1673-private Q_SLOTS:
1674- void slotServiceUnregistered(const QString& service);
1675-
1676-private:
1677- Registrar();
1678- Q_DISABLE_COPY(Registrar)
1679- ~Registrar();
1680-
1681- QDBusServiceWatcher* mServiceWatcher;
1682- typedef QHash<WId, MenuInfo> MenuInfoDb;
1683- MenuInfoDb mDb;
1684- QString mService;
1685-};
1686-
1687-#endif /* REGISTRAR_H */
1688
1689=== added file 'panel/applets/common/fakecairo.h'
1690--- panel/applets/common/fakecairo.h 1970-01-01 00:00:00 +0000
1691+++ panel/applets/common/fakecairo.h 2011-07-27 12:33:15 +0000
1692@@ -0,0 +1,125 @@
1693+/*
1694+ * This file is part of unity-2d
1695+ *
1696+ * Copyright 2011 Canonical Ltd.
1697+ *
1698+ * Authors:
1699+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
1700+ *
1701+ * This program is free software; you can redistribute it and/or modify
1702+ * it under the terms of the GNU General Public License as published by
1703+ * the Free Software Foundation; version 3.
1704+ *
1705+ * This program is distributed in the hope that it will be useful,
1706+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1707+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1708+ * GNU General Public License for more details.
1709+ *
1710+ * You should have received a copy of the GNU General Public License
1711+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1712+ */
1713+#ifndef FAKECAIRO_H
1714+#define FAKECAIRO_H
1715+
1716+// NuxCore
1717+#include <NuxCore/Color.h>
1718+
1719+// Qt
1720+#include <QPainter>
1721+#include <QPainterPath>
1722+
1723+/*
1724+ * This module attempts to fake Cairo calls using QPainter, making it easier to
1725+ * port Cairo paint operations to Qt
1726+ */
1727+struct fcairo_t
1728+{
1729+ fcairo_t(QPainter* _painter)
1730+ : painter(_painter)
1731+ {
1732+ painter->save();
1733+ }
1734+
1735+ ~fcairo_t()
1736+ {
1737+ painter->restore();
1738+ }
1739+
1740+ QPainter* painter;
1741+ QPainterPath path;
1742+};
1743+
1744+inline void fcairo_arc(fcairo_t& cr, qreal xc, qreal yc, qreal radius, qreal angle1, qreal angle2)
1745+{
1746+ QRectF rect(xc - radius, yc - radius, radius * 2, radius * 2);
1747+
1748+ while (angle2 < angle1) {
1749+ angle2 += 2 * M_PI;
1750+ }
1751+
1752+ qreal start = (2. - angle1 / M_PI) * 180;
1753+ qreal stop = (2. - angle2 / M_PI) * 180;
1754+ cr.path.arcTo(rect, start, stop - start);
1755+}
1756+
1757+inline void fcairo_move_to(fcairo_t& cr, qreal x, qreal y)
1758+{
1759+ cr.path.moveTo(x, y);
1760+}
1761+
1762+inline void fcairo_line_to(fcairo_t& cr, qreal x, qreal y)
1763+{
1764+ cr.path.lineTo(x, y);
1765+}
1766+
1767+inline void fcairo_fill_preserve(fcairo_t& cr)
1768+{
1769+ cr.painter->fillPath(cr.path, cr.painter->brush());
1770+}
1771+
1772+inline void fcairo_stroke(fcairo_t& cr)
1773+{
1774+ QPen pen(cr.painter->brush().color(), 1);
1775+ cr.painter->strokePath(cr.path, pen);
1776+ cr.path = QPainterPath();
1777+}
1778+
1779+typedef QGradient fcairo_pattern_t;
1780+
1781+inline fcairo_pattern_t* fcairo_pattern_create_linear (qreal x1, qreal y1, qreal x2, qreal y2)
1782+{
1783+ return new QLinearGradient(x1, y1, x2, y2);
1784+}
1785+
1786+inline void fcairo_pattern_destroy(fcairo_pattern_t* pattern)
1787+{
1788+ delete pattern;
1789+}
1790+
1791+inline void fcairo_pattern_add_color_stop_rgba(fcairo_pattern_t* pattern, qreal offset, qreal r, qreal g, qreal b, qreal a)
1792+{
1793+ pattern->setColorAt(offset, QColor::fromRgbF(r, g, b, a));
1794+}
1795+
1796+inline void fcairo_set_source(fcairo_t& cr, fcairo_pattern_t* pattern)
1797+{
1798+ cr.painter->setPen(Qt::NoPen);
1799+ cr.painter->setBrush(*pattern);
1800+}
1801+
1802+inline void fcairo_set_source_rgb(fcairo_t& cr, qreal r, qreal g, qreal b)
1803+{
1804+ cr.painter->setBrush(QColor::fromRgbF(r, g, b));
1805+}
1806+
1807+inline nux::color::Color nuxColorFromQColor(const QColor& qColor)
1808+{
1809+ nux::color::Color color;
1810+ color.red = qColor.redF();
1811+ color.green = qColor.greenF();
1812+ color.blue = qColor.blueF();
1813+ color.alpha = qColor.alphaF();
1814+ return color;
1815+}
1816+
1817+#endif /* FAKECAIRO_H */
1818
1819=== added file 'panel/applets/common/indicatorentrywidget.cpp'
1820--- panel/applets/common/indicatorentrywidget.cpp 1970-01-01 00:00:00 +0000
1821+++ panel/applets/common/indicatorentrywidget.cpp 2011-07-27 12:33:15 +0000
1822@@ -0,0 +1,388 @@
1823+/*
1824+ * This file is part of unity-2d
1825+ *
1826+ * Copyright 2011 Canonical Ltd.
1827+ *
1828+ * Authors:
1829+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
1830+ *
1831+ * This program is free software; you can redistribute it and/or modify
1832+ * it under the terms of the GNU General Public License as published by
1833+ * the Free Software Foundation; version 3.
1834+ *
1835+ * This program is distributed in the hope that it will be useful,
1836+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1837+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1838+ * GNU General Public License for more details.
1839+ *
1840+ * You should have received a copy of the GNU General Public License
1841+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1842+ */
1843+// Self
1844+#include "indicatorentrywidget.h"
1845+
1846+// Local
1847+#include <debug_p.h>
1848+#include <fakecairo.h>
1849+#include <panelstyle.h>
1850+
1851+// Qt
1852+#include <QIcon>
1853+#include <QPainter>
1854+#include <QWheelEvent>
1855+
1856+// GTK
1857+#include <gtk/gtk.h>
1858+
1859+// libc
1860+#include <time.h>
1861+
1862+static const int SPACING = 3;
1863+static const int PADDING = 3;
1864+
1865+using namespace unity::indicator;
1866+
1867+// Copied from libdbusmenu-qt
1868+static QString swapMnemonicChar(const QString &in, const char src, const char dst)
1869+{
1870+ QString out;
1871+ bool mnemonicFound = false;
1872+
1873+ for (int pos = 0; pos < in.length(); ) {
1874+ QChar ch = in[pos];
1875+ if (ch == src) {
1876+ if (pos == in.length() - 1) {
1877+ // 'src' at the end of string, skip it
1878+ ++pos;
1879+ } else {
1880+ if (in[pos + 1] == src) {
1881+ // A real 'src'
1882+ out += src;
1883+ pos += 2;
1884+ } else if (!mnemonicFound) {
1885+ // We found the mnemonic
1886+ mnemonicFound = true;
1887+ out += dst;
1888+ ++pos;
1889+ } else {
1890+ // We already have a mnemonic, just skip the char
1891+ ++pos;
1892+ }
1893+ }
1894+ } else if (ch == dst) {
1895+ // Escape 'dst'
1896+ out += dst;
1897+ out += dst;
1898+ ++pos;
1899+ } else {
1900+ out += ch;
1901+ ++pos;
1902+ }
1903+ }
1904+
1905+ return out;
1906+}
1907+
1908+IndicatorEntryWidget::IndicatorEntryWidget(const Entry::Ptr& entry)
1909+: m_entry(entry)
1910+, m_padding(PADDING)
1911+, m_hasIcon(false)
1912+, m_hasLabel(false)
1913+{
1914+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
1915+ m_entry->updated.connect(sigc::mem_fun(this, &IndicatorEntryWidget::updatePix));
1916+ updatePix();
1917+}
1918+
1919+QSize IndicatorEntryWidget::minimumSizeHint() const
1920+{
1921+ return sizeHint();
1922+}
1923+
1924+QSize IndicatorEntryWidget::sizeHint() const
1925+{
1926+ return m_pix.size();
1927+}
1928+
1929+void IndicatorEntryWidget::paintEvent(QPaintEvent*)
1930+{
1931+ if (!m_pix.isNull()) {
1932+ QPainter painter(this);
1933+ if (m_entry->active()) {
1934+ paintActiveBackground(&painter);
1935+ }
1936+ painter.drawPixmap(0, 0, m_pix);
1937+ }
1938+}
1939+
1940+
1941+void IndicatorEntryWidget::paintActiveBackground(QPainter* painter)
1942+{
1943+ // This code should be kept in sync with the draw_menu_bg() function from
1944+ // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp
1945+ int radius = 4;
1946+ double x = 0;
1947+ double y = 0;
1948+ double xos = 0.5;
1949+ double yos = 0.5;
1950+ /* FIXME */
1951+ double mpi = 3.14159265358979323846;
1952+
1953+ PanelStyle* style = PanelStyle::instance();
1954+ nux::color::Color bgtop = nuxColorFromQColor(style->backgroundTopColor());
1955+ nux::color::Color bgbot = nuxColorFromQColor(style->backgroundBottomColor());
1956+ nux::color::Color line = nuxColorFromQColor(style->lineColor());
1957+
1958+ painter->setRenderHint(QPainter::Antialiasing);
1959+
1960+ fcairo_t cr(painter);
1961+
1962+ fcairo_move_to (cr, x+xos+radius, y+yos);
1963+ fcairo_arc (cr, x+xos+width()-xos*2-radius, y+yos+radius, radius, mpi*1.5, mpi*2);
1964+ fcairo_line_to (cr, x+xos+width()-xos*2, y+yos+height()-yos*2+2);
1965+ fcairo_line_to (cr, x+xos, y+yos+height()-yos*2+2);
1966+ fcairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
1967+
1968+ fcairo_pattern_t * pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+2);
1969+ fcairo_pattern_add_color_stop_rgba (pat, 0.0,
1970+ bgtop.red,
1971+ bgtop.green,
1972+ bgtop.blue,
1973+ 1.0f - bgbot.red);
1974+ fcairo_pattern_add_color_stop_rgba (pat, 1.0,
1975+ bgbot.red,
1976+ bgbot.green,
1977+ bgbot.blue,
1978+ 1.0f - bgtop.red);
1979+ fcairo_set_source (cr, pat);
1980+ fcairo_fill_preserve (cr);
1981+ fcairo_pattern_destroy (pat);
1982+
1983+ /*
1984+ pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+2);
1985+ fcairo_pattern_add_color_stop_rgba (pat, 0.0,
1986+ line.red,
1987+ line.green,
1988+ line.blue,
1989+ 1.0f);
1990+ fcairo_pattern_add_color_stop_rgba (pat, 1.0,
1991+ line.red,
1992+ line.green,
1993+ line.blue,
1994+ 1.0f);
1995+ fcairo_set_source (cr, pat);
1996+ */
1997+ fcairo_set_source_rgb (cr, line.red, line.green, line.blue);
1998+ fcairo_stroke (cr);
1999+ //fcairo_pattern_destroy (pat);
2000+
2001+ xos++;
2002+ yos++;
2003+
2004+ /* enlarging the area to not draw the lightborder at bottom, ugly trick :P */
2005+ fcairo_move_to (cr, x+radius+xos, y+yos);
2006+ fcairo_arc (cr, x+xos+width()-xos*2-radius, y+yos+radius, radius, mpi*1.5, mpi*2);
2007+ fcairo_line_to (cr, x+xos+width()-xos*2, y+yos+height()-yos*2+3);
2008+ fcairo_line_to (cr, x+xos, y+yos+height()-yos*2+3);
2009+ fcairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
2010+
2011+ /*
2012+ pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+3);
2013+ fcairo_pattern_add_color_stop_rgba (pat, 0.0,
2014+ bgbot.red,
2015+ bgbot.green,
2016+ bgbot.blue,
2017+ 1.0f);
2018+ fcairo_pattern_add_color_stop_rgba (pat, 1.0,
2019+ bgbot.red,
2020+ bgbot.green,
2021+ bgbot.blue,
2022+ 1.0f);
2023+ fcairo_set_source (cr, pat);
2024+ */
2025+ fcairo_set_source_rgb (cr, bgbot.red, bgbot.green, bgbot.blue);
2026+ fcairo_stroke (cr);
2027+ //fcairo_pattern_destroy (pat);
2028+}
2029+
2030+void IndicatorEntryWidget::updatePix()
2031+{
2032+ bool oldIsEmpty = isEmpty();
2033+
2034+ int width = m_padding;
2035+ int iconX = m_padding;
2036+ int labelX = 0;
2037+
2038+ // Compute width, labelX and update m_has{Icon,Label}
2039+ QPixmap iconPix;
2040+ if (m_entry->image_visible()) {
2041+ iconPix = decodeIcon();
2042+ m_hasIcon = !iconPix.isNull();
2043+ } else {
2044+ m_hasIcon = false;
2045+ }
2046+ if (m_hasIcon) {
2047+ width += iconPix.width();
2048+ }
2049+
2050+ QString label = QString::fromUtf8(m_entry->label().c_str());
2051+ label = swapMnemonicChar(label, '_', '&');
2052+ m_hasLabel = !label.isEmpty() && m_entry->label_visible();
2053+ if (m_hasLabel) {
2054+ if (m_hasIcon) {
2055+ width += SPACING;
2056+ }
2057+ labelX = width;
2058+ QString visibleLabel = label;
2059+ visibleLabel.remove('&');
2060+ width += fontMetrics().width(visibleLabel);
2061+ }
2062+
2063+ width += m_padding;
2064+
2065+ // Paint
2066+ QPixmap oldPix = m_pix;
2067+ if (!m_hasIcon && !m_hasLabel) {
2068+ m_pix = QPixmap();
2069+ } else {
2070+ m_pix = QPixmap(width, 24);
2071+ m_pix.fill(Qt::transparent);
2072+ QPainter painter(&m_pix);
2073+ painter.initFrom(this);
2074+ if (m_hasIcon) {
2075+ bool disabled = !m_entry->image_sensitive();
2076+ if (disabled) {
2077+ painter.setOpacity(0.5);
2078+ }
2079+ painter.drawPixmap(iconX, 0, iconPix);
2080+ if (disabled) {
2081+ painter.setOpacity(1);
2082+ }
2083+ }
2084+ if (m_hasLabel) {
2085+ PanelStyle* style = PanelStyle::instance();
2086+
2087+ int flags = Qt::AlignLeft | Qt::AlignVCenter;
2088+ flags |= m_entry->show_now() ? Qt::TextShowMnemonic : Qt::TextHideMnemonic;
2089+
2090+ // Shadow
2091+ QColor color = style->textShadowColor();
2092+ color.setAlphaF(1. - color.redF());
2093+ painter.setPen(color);
2094+ painter.drawText(labelX, 1, width - labelX, m_pix.height(), flags, label);
2095+
2096+ // Text
2097+ color = style->textColor();
2098+ color.setAlphaF(m_entry->label_sensitive() ? 1. : .5);
2099+ painter.setPen(color);
2100+ painter.drawText(labelX, 0, width - labelX, m_pix.height(), flags, label);
2101+ }
2102+ }
2103+
2104+ // Notify others we changed, but only trigger a layout update if necessary
2105+ if (m_pix.size() == oldPix.size()) {
2106+ update();
2107+ } else {
2108+ updateGeometry();
2109+ }
2110+ bool newIsEmpty = isEmpty();
2111+ if (newIsEmpty != oldIsEmpty) {
2112+ // If we emit isEmptyChanged() directly it won't reach any connected
2113+ // slot. I assume this is because this method is called as a response
2114+ // to a sigc++ signal.
2115+ QMetaObject::invokeMethod(this, "isEmptyChanged", Qt::QueuedConnection);
2116+ }
2117+}
2118+
2119+QPixmap IndicatorEntryWidget::decodeIcon()
2120+{
2121+ QPixmap pix;
2122+
2123+ int type = m_entry->image_type();
2124+
2125+ if (type == 0) {
2126+ // No icon
2127+ } else if (type == GTK_IMAGE_PIXBUF) {
2128+ QByteArray data = QByteArray::fromBase64(m_entry->image_data().c_str());
2129+ QImage image;
2130+ bool ok = image.loadFromData(data);
2131+ if (ok) {
2132+ pix = QPixmap::fromImage(image);
2133+ } else {
2134+ UQ_WARNING << "Failed to decode image";
2135+ }
2136+ } else if (type == GTK_IMAGE_ICON_NAME) {
2137+ QString name = QString::fromStdString(m_entry->image_data());
2138+ QIcon icon = QIcon::fromTheme(name);
2139+ pix = icon.pixmap(24, 24);
2140+ } else if (type == GTK_IMAGE_GICON) {
2141+ UQ_WARNING << "FIXME: Implement support for GTK_IMAGE_GICON image type";
2142+ } else {
2143+ UQ_WARNING << "Unknown image type" << m_entry->image_type();
2144+ }
2145+ return pix;
2146+}
2147+
2148+void IndicatorEntryWidget::mousePressEvent(QMouseEvent*)
2149+{
2150+ UQ_RETURN_IF_FAIL(m_hasIcon || m_hasLabel);
2151+ showMenu(Qt::LeftButton);
2152+}
2153+
2154+void IndicatorEntryWidget::mouseReleaseEvent(QMouseEvent*)
2155+{
2156+ UQ_VAR(this);
2157+ update();
2158+}
2159+
2160+void IndicatorEntryWidget::wheelEvent(QWheelEvent* event)
2161+{
2162+ m_entry->Scroll(event->delta());
2163+}
2164+
2165+void IndicatorEntryWidget::showMenu(Qt::MouseButton qtButton)
2166+{
2167+ if (m_entry->active()) {
2168+ return;
2169+ }
2170+ int nuxButton = qtButton == Qt::NoButton ? 0 : 1;
2171+ QPoint pos = mapToGlobal(rect().bottomLeft());
2172+ m_entry->ShowMenu(pos.x(), pos.y(),
2173+ time(NULL),
2174+ nuxButton
2175+ );
2176+}
2177+
2178+void IndicatorEntryWidget::setPadding(int padding)
2179+{
2180+ if (m_padding != padding) {
2181+ m_padding = padding;
2182+ updatePix();
2183+ }
2184+}
2185+
2186+bool IndicatorEntryWidget::event(QEvent* ev)
2187+{
2188+ bool ret = QWidget::event(ev);
2189+ switch (ev->type()) {
2190+ case QEvent::FontChange:
2191+ case QEvent::PaletteChange:
2192+ updatePix();
2193+ break;
2194+ default:
2195+ break;
2196+ }
2197+ return ret;
2198+}
2199+
2200+bool IndicatorEntryWidget::isEmpty() const
2201+{
2202+ return !m_hasIcon && !m_hasLabel;
2203+}
2204+
2205+unity::indicator::Entry::Ptr IndicatorEntryWidget::entry() const
2206+{
2207+ return m_entry;
2208+}
2209+
2210+#include "indicatorentrywidget.moc"
2211
2212=== added file 'panel/applets/common/indicatorentrywidget.h'
2213--- panel/applets/common/indicatorentrywidget.h 1970-01-01 00:00:00 +0000
2214+++ panel/applets/common/indicatorentrywidget.h 2011-07-27 12:33:15 +0000
2215@@ -0,0 +1,81 @@
2216+/*
2217+ * This file is part of unity-2d
2218+ *
2219+ * Copyright 2011 Canonical Ltd.
2220+ *
2221+ * Authors:
2222+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2223+ *
2224+ * This program is free software; you can redistribute it and/or modify
2225+ * it under the terms of the GNU General Public License as published by
2226+ * the Free Software Foundation; version 3.
2227+ *
2228+ * This program is distributed in the hope that it will be useful,
2229+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2230+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2231+ * GNU General Public License for more details.
2232+ *
2233+ * You should have received a copy of the GNU General Public License
2234+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2235+ */
2236+#ifndef INDICATORENTRYWIDGET_H
2237+#define INDICATORENTRYWIDGET_H
2238+
2239+// Local
2240+
2241+// libunity-core
2242+#include <UnityCore/IndicatorEntry.h>
2243+
2244+// Qt
2245+#include <QWidget>
2246+
2247+class QPainter;
2248+
2249+class IndicatorEntryWidget : public QWidget, public sigc::trackable
2250+{
2251+Q_OBJECT
2252+public:
2253+ IndicatorEntryWidget(const unity::indicator::Entry::Ptr& entry);
2254+
2255+ QSize minimumSizeHint() const;
2256+ QSize sizeHint() const;
2257+
2258+ void setPadding(int);
2259+
2260+ bool isEmpty() const;
2261+
2262+ unity::indicator::Entry::Ptr entry() const;
2263+
2264+ /**
2265+ * Shows the menu.
2266+ *
2267+ * When this method is called because of a click, button
2268+ * must be set to Qt::LeftButton.
2269+ *
2270+ * When it is called because user previously clicked an indicator and moved the
2271+ * mouse to another indicator, button must be set to Qt::NoButton.
2272+ */
2273+ void showMenu(Qt::MouseButton button);
2274+
2275+Q_SIGNALS:
2276+ void isEmptyChanged();
2277+
2278+protected:
2279+ void paintEvent(QPaintEvent*);
2280+ void mousePressEvent(QMouseEvent*);
2281+ void mouseReleaseEvent(QMouseEvent*);
2282+ void wheelEvent(QWheelEvent*);
2283+ bool event(QEvent*);
2284+
2285+private:
2286+ unity::indicator::Entry::Ptr m_entry;
2287+ QPixmap m_pix;
2288+ int m_padding;
2289+ bool m_hasIcon;
2290+ bool m_hasLabel;
2291+ void updatePix();
2292+ QPixmap decodeIcon();
2293+ void paintActiveBackground(QPainter*);
2294+};
2295+
2296+#endif /* INDICATORENTRYWIDGET_H */
2297
2298=== added file 'panel/applets/common/indicatorsmanager.cpp'
2299--- panel/applets/common/indicatorsmanager.cpp 1970-01-01 00:00:00 +0000
2300+++ panel/applets/common/indicatorsmanager.cpp 2011-07-27 12:33:15 +0000
2301@@ -0,0 +1,176 @@
2302+/*
2303+ * This file is part of unity-2d
2304+ *
2305+ * Copyright 2011 Canonical Ltd.
2306+ *
2307+ * Authors:
2308+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2309+ *
2310+ * This program is free software; you can redistribute it and/or modify
2311+ * it under the terms of the GNU General Public License as published by
2312+ * the Free Software Foundation; version 3.
2313+ *
2314+ * This program is distributed in the hope that it will be useful,
2315+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2316+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2317+ * GNU General Public License for more details.
2318+ *
2319+ * You should have received a copy of the GNU General Public License
2320+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2321+ */
2322+// Self
2323+#include "indicatorsmanager.h"
2324+
2325+// Local
2326+#include <debug_p.h>
2327+#include <indicatorentrywidget.h>
2328+
2329+// Qt
2330+#include <QApplication>
2331+#include <QTimer>
2332+#include <QX11Info>
2333+
2334+// X11
2335+#include <X11/Xlib.h>
2336+
2337+using namespace unity::indicator;
2338+
2339+IndicatorsManager::IndicatorsManager(QObject* parent)
2340+: QObject(parent)
2341+, m_indicators(new DBusIndicators)
2342+, m_geometrySyncTimer(new QTimer(this))
2343+{
2344+ m_geometrySyncTimer->setInterval(0);
2345+ m_geometrySyncTimer->setSingleShot(true);
2346+ connect(m_geometrySyncTimer, SIGNAL(timeout()), SLOT(syncGeometries()));
2347+
2348+ m_indicators->on_entry_show_menu.connect(
2349+ sigc::mem_fun(this, &IndicatorsManager::onEntryShowMenu)
2350+ );
2351+
2352+ m_indicators->on_menu_pointer_moved.connect(
2353+ sigc::mem_fun(this, &IndicatorsManager::onMenuPointerMoved)
2354+ );
2355+
2356+ m_indicators->on_entry_activate_request.connect(
2357+ sigc::mem_fun(this, &IndicatorsManager::onEntryActivateRequest)
2358+ );
2359+
2360+ m_indicators->on_synced.connect(
2361+ sigc::mem_fun(this, &IndicatorsManager::onSynced)
2362+ );
2363+}
2364+
2365+unity::indicator::DBusIndicators::Ptr IndicatorsManager::indicators() const
2366+{
2367+ return m_indicators;
2368+}
2369+
2370+void IndicatorsManager::onEntryShowMenu(const std::string& /*entryId*/, int posX, int posY, int /*timestamp*/, int /*button*/)
2371+{
2372+ // Copied from plugins/unityshell/src/PanelView.cpp, in OnEntryShowMenu()
2373+ // Without this code, menus cannot be shown from mousePressEvent() (but can
2374+ // be shown from mouseReleaseEvent())
2375+ /*
2376+ Neil explanation:
2377+ On button down, X automatically gives Qt a passive grab on the mouse this
2378+ means that, if the panel service tries to grab the pointer to show the menu
2379+ (gtk does this automatically), it fails and the menu can't show.
2380+ We connect to the on_entry_show_menu signal, which is emitted before
2381+ DBusIndicators does anything else, and just break the grab.
2382+ */
2383+ Display* display = QX11Info::display();
2384+ XUngrabPointer(display, CurrentTime);
2385+ XFlush(display);
2386+
2387+ XButtonEvent event = {
2388+ ButtonRelease,
2389+ 0,
2390+ False,
2391+ display,
2392+ 0,
2393+ 0,
2394+ 0,
2395+ CurrentTime,
2396+ posX, posY,
2397+ posX, posY,
2398+ 0,
2399+ Button1,
2400+ True
2401+ };
2402+ qApp->x11ProcessEvent(reinterpret_cast<XEvent*>(&event));
2403+}
2404+
2405+void IndicatorsManager::onMenuPointerMoved(int posX, int posY)
2406+{
2407+ QWidget* widget = QApplication::widgetAt(posX, posY);
2408+ IndicatorEntryWidget* entryWidget = qobject_cast<IndicatorEntryWidget*>(widget);
2409+ if (!entryWidget) {
2410+ return;
2411+ }
2412+ entryWidget->showMenu(Qt::NoButton);
2413+}
2414+
2415+void IndicatorsManager::onEntryActivateRequest(const std::string& entryId)
2416+{
2417+ if (entryId.empty()) {
2418+ return;
2419+ }
2420+ IndicatorEntryWidget* widget = 0;
2421+ Q_FOREACH(widget, m_widgetList) {
2422+ if (widget->entry()->id() == entryId) {
2423+ break;
2424+ }
2425+ }
2426+ if (!widget) {
2427+ UQ_WARNING << "Could not find a widget for IndicatorEntry with id" << QString::fromStdString(entryId);
2428+ return;
2429+ }
2430+ widget->showMenu(Qt::NoButton);
2431+}
2432+
2433+void IndicatorsManager::onSynced()
2434+{
2435+ QMetaObject::invokeMethod(m_geometrySyncTimer, "start", Qt::QueuedConnection);
2436+}
2437+
2438+void IndicatorsManager::addIndicatorEntryWidget(IndicatorEntryWidget* widget)
2439+{
2440+ m_widgetList.append(widget);
2441+ widget->installEventFilter(this);
2442+}
2443+
2444+bool IndicatorsManager::eventFilter(QObject*, QEvent* event)
2445+{
2446+ switch (event->type()) {
2447+ case QEvent::Show:
2448+ case QEvent::Hide:
2449+ case QEvent::Move:
2450+ case QEvent::Resize:
2451+ m_geometrySyncTimer->start();
2452+ break;
2453+ default:
2454+ break;
2455+ }
2456+ return false;
2457+}
2458+
2459+void IndicatorsManager::syncGeometries()
2460+{
2461+ EntryLocationMap locations;
2462+ Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
2463+ if (!widget->isVisible()) {
2464+ continue;
2465+ }
2466+ Entry::Ptr entry = widget->entry();
2467+ if (entry->IsUnused()) {
2468+ continue;
2469+ }
2470+ QPoint topLeft = widget->mapToGlobal(QPoint(0, 0));
2471+ nux::Rect rect(topLeft.x(), topLeft.y(), widget->width(), widget->height());
2472+ locations[widget->entry()->id()] = rect;
2473+ }
2474+ m_indicators->SyncGeometries("Panel", locations);
2475+}
2476+
2477+#include "indicatorsmanager.moc"
2478
2479=== added file 'panel/applets/common/indicatorsmanager.h'
2480--- panel/applets/common/indicatorsmanager.h 1970-01-01 00:00:00 +0000
2481+++ panel/applets/common/indicatorsmanager.h 2011-07-27 12:33:15 +0000
2482@@ -0,0 +1,70 @@
2483+/*
2484+ * This file is part of unity-2d
2485+ *
2486+ * Copyright 2011 Canonical Ltd.
2487+ *
2488+ * Authors:
2489+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2490+ *
2491+ * This program is free software; you can redistribute it and/or modify
2492+ * it under the terms of the GNU General Public License as published by
2493+ * the Free Software Foundation; version 3.
2494+ *
2495+ * This program is distributed in the hope that it will be useful,
2496+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2497+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2498+ * GNU General Public License for more details.
2499+ *
2500+ * You should have received a copy of the GNU General Public License
2501+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2502+ */
2503+#ifndef INDICATORSMANAGER_H
2504+#define INDICATORSMANAGER_H
2505+
2506+// Local
2507+
2508+// Qt
2509+#include <QMap>
2510+#include <QObject>
2511+
2512+// libunity-core
2513+#include <UnityCore/DBusIndicators.h>
2514+
2515+class QTimer;
2516+
2517+class IndicatorEntryWidget;
2518+
2519+/**
2520+ * Instantiates DBusIndicators and implement common behavior
2521+ */
2522+class IndicatorsManager : public QObject, public sigc::trackable
2523+{
2524+ Q_OBJECT
2525+public:
2526+ IndicatorsManager(QObject* parent);
2527+
2528+ unity::indicator::DBusIndicators::Ptr indicators() const;
2529+
2530+ void addIndicatorEntryWidget(IndicatorEntryWidget* widget);
2531+
2532+protected:
2533+ bool eventFilter(QObject*, QEvent*);
2534+
2535+private Q_SLOTS:
2536+ void syncGeometries();
2537+
2538+private:
2539+ Q_DISABLE_COPY(IndicatorsManager)
2540+ unity::indicator::DBusIndicators::Ptr m_indicators;
2541+ QTimer* m_geometrySyncTimer;
2542+
2543+ typedef QList<IndicatorEntryWidget*> IndicatorEntryWidgetList;
2544+ IndicatorEntryWidgetList m_widgetList;
2545+
2546+ void onSynced();
2547+ void onEntryShowMenu(const std::string&, int x, int y, int timestamp, int button);
2548+ void onMenuPointerMoved(int x, int y);
2549+ void onEntryActivateRequest(const std::string& entryId);
2550+};
2551+
2552+#endif /* INDICATORSMANAGER_H */
2553
2554=== added file 'panel/applets/common/indicatorwidget.cpp'
2555--- panel/applets/common/indicatorwidget.cpp 1970-01-01 00:00:00 +0000
2556+++ panel/applets/common/indicatorwidget.cpp 2011-07-27 12:33:15 +0000
2557@@ -0,0 +1,53 @@
2558+/*
2559+ * This file is part of unity-2d
2560+ *
2561+ * Copyright 2011 Canonical Ltd.
2562+ *
2563+ * Authors:
2564+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2565+ *
2566+ * This program is free software; you can redistribute it and/or modify
2567+ * it under the terms of the GNU General Public License as published by
2568+ * the Free Software Foundation; version 3.
2569+ *
2570+ * This program is distributed in the hope that it will be useful,
2571+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2572+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2573+ * GNU General Public License for more details.
2574+ *
2575+ * You should have received a copy of the GNU General Public License
2576+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2577+ */
2578+// Self
2579+#include "indicatorwidget.h"
2580+
2581+// Local
2582+#include <debug_p.h>
2583+#include <indicatorentrywidget.h>
2584+#include <indicatorsmanager.h>
2585+
2586+// Qt
2587+#include <QHBoxLayout>
2588+
2589+using namespace unity::indicator;
2590+
2591+IndicatorWidget::IndicatorWidget(const Indicator::Ptr& indicator, IndicatorsManager* manager)
2592+: m_layout(new QHBoxLayout(this))
2593+, m_indicatorsManager(manager)
2594+, m_indicator(indicator)
2595+{
2596+ m_layout->setMargin(0);
2597+ m_layout->setSpacing(0);
2598+
2599+ m_indicator->on_entry_added.connect(sigc::mem_fun(this, &IndicatorWidget::onEntryAdded));
2600+}
2601+
2602+void IndicatorWidget::onEntryAdded(const Entry::Ptr& entry)
2603+{
2604+ IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
2605+ m_indicatorsManager->addIndicatorEntryWidget(widget);
2606+ m_layout->addWidget(widget);
2607+}
2608+
2609+
2610+#include "indicatorwidget.moc"
2611
2612=== added file 'panel/applets/common/indicatorwidget.h'
2613--- panel/applets/common/indicatorwidget.h 1970-01-01 00:00:00 +0000
2614+++ panel/applets/common/indicatorwidget.h 2011-07-27 12:33:15 +0000
2615@@ -0,0 +1,52 @@
2616+/*
2617+ * This file is part of unity-2d
2618+ *
2619+ * Copyright 2011 Canonical Ltd.
2620+ *
2621+ * Authors:
2622+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2623+ *
2624+ * This program is free software; you can redistribute it and/or modify
2625+ * it under the terms of the GNU General Public License as published by
2626+ * the Free Software Foundation; version 3.
2627+ *
2628+ * This program is distributed in the hope that it will be useful,
2629+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2630+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2631+ * GNU General Public License for more details.
2632+ *
2633+ * You should have received a copy of the GNU General Public License
2634+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2635+ */
2636+#ifndef INDICATORWIDGET_H
2637+#define INDICATORWIDGET_H
2638+
2639+// Local
2640+
2641+// libunity-core
2642+#include <UnityCore/Indicator.h>
2643+#include <UnityCore/IndicatorEntry.h>
2644+
2645+// Qt
2646+#include <QWidget>
2647+
2648+class QHBoxLayout;
2649+
2650+class IndicatorEntryWidget;
2651+class IndicatorsManager;
2652+
2653+class IndicatorWidget : public QWidget, public sigc::trackable
2654+{
2655+Q_OBJECT
2656+public:
2657+ IndicatorWidget(const unity::indicator::Indicator::Ptr& indicator, IndicatorsManager* manager);
2658+
2659+private:
2660+ QHBoxLayout* m_layout;
2661+ IndicatorsManager* m_indicatorsManager;
2662+ unity::indicator::Indicator::Ptr m_indicator;
2663+
2664+ void onEntryAdded(const unity::indicator::Entry::Ptr& entry);
2665+};
2666+
2667+#endif /* INDICATORWIDGET_H */
2668
2669=== added file 'panel/applets/common/panelstyle.cpp'
2670--- panel/applets/common/panelstyle.cpp 1970-01-01 00:00:00 +0000
2671+++ panel/applets/common/panelstyle.cpp 2011-07-27 12:33:15 +0000
2672@@ -0,0 +1,175 @@
2673+/*
2674+ * This file is part of unity-2d
2675+ *
2676+ * Copyright 2011 Canonical Ltd.
2677+ *
2678+ * Authors:
2679+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2680+ *
2681+ * This program is free software; you can redistribute it and/or modify
2682+ * it under the terms of the GNU General Public License as published by
2683+ * the Free Software Foundation; version 3.
2684+ *
2685+ * This program is distributed in the hope that it will be useful,
2686+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2687+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2688+ * GNU General Public License for more details.
2689+ *
2690+ * You should have received a copy of the GNU General Public License
2691+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2692+ */
2693+// Self
2694+#include "panelstyle.h"
2695+
2696+// libunity-2d
2697+#include <debug_p.h>
2698+#include <gconnector.h>
2699+#include <gscopedpointer.h>
2700+
2701+// Qt
2702+#include <QApplication>
2703+#include <QColor>
2704+#include <QFont>
2705+#include <QPalette>
2706+
2707+// GTK
2708+#include <gtk/gtk.h>
2709+#include <pango/pango.h>
2710+
2711+typedef void (*ColorGetter)(GtkStyleContext*, GtkStateFlags, GdkRGBA*);
2712+
2713+inline QColor colorFromContext(ColorGetter getter, GtkStyleContext* context, GtkStateFlags state)
2714+{
2715+ GdkRGBA color;
2716+ getter(context, state, &color);
2717+ return QColor::fromRgbF(color.red, color.green, color.blue, color.alpha);
2718+}
2719+
2720+class PanelStylePrivate
2721+{
2722+public:
2723+ PanelStyle* q;
2724+ GtkWidget* m_offScreenWindow;
2725+ GConnector m_gConnector;
2726+
2727+ QColor m_textColor;
2728+ QColor m_backgroundTopColor;
2729+ QColor m_backgroundBottomColor;
2730+ QColor m_textShadowColor;
2731+ QColor m_lineColor;
2732+ QFont m_font;
2733+
2734+ static void onThemeChanged(GObject*, GParamSpec*, gpointer data)
2735+ {
2736+ PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data);
2737+ priv->updatePalette();
2738+ }
2739+
2740+ static void onFontChanged(GObject*, GParamSpec*, gpointer data)
2741+ {
2742+ PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data);
2743+ priv->updateFont();
2744+ }
2745+
2746+ void updatePalette()
2747+ {
2748+ GtkStyleContext* context = gtk_widget_get_style_context(m_offScreenWindow);
2749+ UQ_RETURN_IF_FAIL(context);
2750+
2751+ m_textColor = colorFromContext(gtk_style_context_get_color, context, GTK_STATE_FLAG_NORMAL);
2752+ m_textShadowColor = colorFromContext(gtk_style_context_get_color, context, GTK_STATE_FLAG_SELECTED);
2753+ m_lineColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_NORMAL).darker(130);
2754+ m_backgroundTopColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_ACTIVE);
2755+ m_backgroundBottomColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_NORMAL);
2756+
2757+ QPalette pal;
2758+ pal.setColor(QPalette::Window, m_backgroundTopColor);
2759+ pal.setColor(QPalette::Button, m_backgroundTopColor);
2760+ pal.setColor(QPalette::Text, m_textColor);
2761+ pal.setColor(QPalette::WindowText, m_textColor);
2762+ pal.setColor(QPalette::ButtonText, m_textColor);
2763+ QApplication::setPalette(pal);
2764+ }
2765+
2766+ void updateFont()
2767+ {
2768+ gchar* fontName = 0;
2769+ g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontName, NULL);
2770+ GScopedPointer<PangoFontDescription, pango_font_description_free> fontDescription(
2771+ pango_font_description_from_string(fontName)
2772+ );
2773+ g_free(fontName);
2774+
2775+ int size = pango_font_description_get_size(fontDescription.data());
2776+
2777+ m_font = QFont(
2778+ pango_font_description_get_family(fontDescription.data()),
2779+ size / PANGO_SCALE
2780+ );
2781+
2782+ QApplication::setFont(m_font);
2783+ }
2784+};
2785+
2786+PanelStyle::PanelStyle(QObject* parent)
2787+: d(new PanelStylePrivate)
2788+{
2789+ d->q = this;
2790+ d->m_offScreenWindow = gtk_offscreen_window_new();
2791+ gtk_widget_set_name(d->m_offScreenWindow, "UnityPanelWidget");
2792+ gtk_widget_set_size_request(d->m_offScreenWindow, 100, 24);
2793+ gtk_style_context_add_class(gtk_widget_get_style_context(d->m_offScreenWindow), "menubar");
2794+ gtk_widget_show_all(d->m_offScreenWindow);
2795+
2796+ d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name",
2797+ G_CALLBACK(PanelStylePrivate::onThemeChanged), d);
2798+ d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-font-name",
2799+ G_CALLBACK(PanelStylePrivate::onFontChanged), d);
2800+
2801+ d->updatePalette();
2802+ d->updateFont();
2803+}
2804+
2805+PanelStyle::~PanelStyle()
2806+{
2807+ gtk_widget_destroy(d->m_offScreenWindow);
2808+ delete d;
2809+}
2810+
2811+PanelStyle* PanelStyle::instance()
2812+{
2813+ static PanelStyle style;
2814+ return &style;
2815+}
2816+
2817+QColor PanelStyle::textColor() const
2818+{
2819+ return d->m_textColor;
2820+}
2821+
2822+QColor PanelStyle::backgroundTopColor() const
2823+{
2824+ return d->m_backgroundTopColor;
2825+}
2826+
2827+QColor PanelStyle::backgroundBottomColor() const
2828+{
2829+ return d->m_backgroundBottomColor;
2830+}
2831+
2832+QColor PanelStyle::textShadowColor() const
2833+{
2834+ return d->m_textShadowColor;
2835+}
2836+
2837+QColor PanelStyle::lineColor() const
2838+{
2839+ return d->m_lineColor;
2840+}
2841+
2842+QFont PanelStyle::font() const
2843+{
2844+ return d->m_font;
2845+}
2846+
2847+#include "panelstyle.moc"
2848
2849=== added file 'panel/applets/common/panelstyle.h'
2850--- panel/applets/common/panelstyle.h 1970-01-01 00:00:00 +0000
2851+++ panel/applets/common/panelstyle.h 2011-07-27 12:33:15 +0000
2852@@ -0,0 +1,59 @@
2853+/*
2854+ * This file is part of unity-2d
2855+ *
2856+ * Copyright 2011 Canonical Ltd.
2857+ *
2858+ * Authors:
2859+ * - Aurélien Gâteau <aurelien.gateau@canonical.com>
2860+ *
2861+ * This program is free software; you can redistribute it and/or modify
2862+ * it under the terms of the GNU General Public License as published by
2863+ * the Free Software Foundation; version 3.
2864+ *
2865+ * This program is distributed in the hope that it will be useful,
2866+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2867+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2868+ * GNU General Public License for more details.
2869+ *
2870+ * You should have received a copy of the GNU General Public License
2871+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2872+ */
2873+#ifndef PANELSTYLE_H
2874+#define PANELSTYLE_H
2875+
2876+// Local
2877+
2878+// Qt
2879+#include <QObject>
2880+
2881+class QColor;
2882+class QFont;
2883+
2884+class PanelStylePrivate;
2885+/**
2886+ * Provides easy access to panel colors
2887+ */
2888+class PanelStyle : public QObject
2889+{
2890+ Q_OBJECT
2891+public:
2892+ PanelStyle(QObject* parent = 0);
2893+ ~PanelStyle();
2894+
2895+ static PanelStyle* instance();
2896+
2897+ QColor textColor() const;
2898+ QColor backgroundTopColor() const;
2899+ QColor backgroundBottomColor() const;
2900+ QColor textShadowColor() const;
2901+ QColor lineColor() const;
2902+
2903+ QFont font() const;
2904+
2905+private:
2906+ friend class PanelStylePrivate;
2907+ // Use a pimpl to avoid the need for gtk includes here
2908+ PanelStylePrivate* const d;
2909+};
2910+
2911+#endif /* PANELSTYLE_H */
2912
2913=== removed directory 'panel/applets/indicator'
2914=== removed file 'panel/applets/indicator-config.h.in'
2915--- panel/applets/indicator-config.h.in 2011-03-01 09:04:13 +0000
2916+++ panel/applets/indicator-config.h.in 1970-01-01 00:00:00 +0000
2917@@ -1,7 +0,0 @@
2918-#ifndef INDICATOR_CONFIG_H
2919-#define INDICATOR_CONFIG_H
2920-
2921-#define INDICATOR_ICONS_DIR "${INDICATOR_ICONS_DIR}"
2922-#define INDICATOR_DIR "${INDICATOR_DIR}"
2923-
2924-#endif /* INDICATOR_CONFIG_H */
2925
2926=== removed file 'panel/applets/indicator/indicator.c'
2927--- panel/applets/indicator/indicator.c 2011-07-27 12:33:12 +0000
2928+++ panel/applets/indicator/indicator.c 1970-01-01 00:00:00 +0000
2929@@ -1,526 +0,0 @@
2930-/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
2931- *
2932- * This program is free software; you can redistribute it and/or modify
2933- * it under the terms of the GNU General Public License as published by
2934- * the Free Software Foundation; either version 2 of the License, or
2935- * (at your option) any later version.
2936- *
2937- * This program is distributed in the hope that it will be useful,
2938- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2939- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2940- * GNU Library General Public License for more details.
2941- *
2942- * You should have received a copy of the GNU General Public License
2943- * along with this program; if not, write to the Free Software
2944- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2945- */
2946-
2947-#include <string.h>
2948-
2949-#include <gtk/gtk.h>
2950-#include <gtk/gtkx.h>
2951-#include <libindicator/indicator-object.h>
2952-
2953-#include "indicator.h"
2954-
2955-#include "indicator-config.h"
2956-
2957-/* default settings */
2958-#define DEFAULT_SETTING1 NULL
2959-#define DEFAULT_SETTING2 1
2960-#define DEFAULT_SETTING3 FALSE
2961-
2962-typedef enum {
2963- PANEL_APPLET_ORIENT_LEFT,
2964- PANEL_APPLET_ORIENT_RIGHT,
2965- PANEL_APPLET_ORIENT_TOP,
2966- PANEL_APPLET_ORIENT_BOTTOM
2967-} PanelAppletOrient;
2968-
2969-// <indicator-applet-copy>
2970-static gchar * indicator_order[] = {
2971- "libappmenu.so",
2972- "libapplication.so",
2973- "libsoundmenu.so",
2974- "libnetworkmenu.so",
2975- "libmessaging.so",
2976- "libdatetime.so",
2977- "libme.so",
2978- "libsession.so",
2979- NULL
2980-};
2981-
2982-static GtkPackDirection packdirection;
2983-static PanelAppletOrient orient;
2984-
2985-#define MENU_DATA_INDICATOR_OBJECT "indicator-object"
2986-#define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
2987-
2988-#define IO_DATA_ORDER_NUMBER "indicator-order-number"
2989-
2990-static gint
2991-name2order (const gchar * name) {
2992- int i;
2993-
2994- for (i = 0; indicator_order[i] != NULL; i++) {
2995- if (g_strcmp0(name, indicator_order[i]) == 0) {
2996- return i;
2997- }
2998- }
2999-
3000- return -1;
3001-}
3002-
3003-typedef struct _incoming_position_t incoming_position_t;
3004-struct _incoming_position_t {
3005- gint objposition;
3006- gint entryposition;
3007- gint menupos;
3008- gboolean found;
3009-};
3010-
3011-/* This function helps by determining where in the menu list
3012- this new entry should be placed. It compares the objects
3013- that they're on, and then the individual entries. Each
3014- is progressively more expensive. */
3015-static void
3016-place_in_menu (GtkWidget * widget, gpointer user_data)
3017-{
3018- incoming_position_t * position = (incoming_position_t *)user_data;
3019- if (position->found) {
3020- /* We've already been placed, just finish the foreach */
3021- return;
3022- }
3023-
3024- IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
3025- g_assert(io != NULL);
3026-
3027- gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
3028- /* We've already passed it, well, then this is where
3029- we should be be. Stop! */
3030- if (objposition > position->objposition) {
3031- position->found = TRUE;
3032- return;
3033- }
3034-
3035- /* The objects don't match yet, keep looking */
3036- if (objposition < position->objposition) {
3037- position->menupos++;
3038- return;
3039- }
3040-
3041- /* The objects are the same, let's start looking at entries. */
3042- IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
3043- gint entryposition = indicator_object_get_location(io, entry);
3044-
3045- if (entryposition > position->entryposition) {
3046- position->found = TRUE;
3047- return;
3048- }
3049-
3050- if (entryposition < position->entryposition) {
3051- position->menupos++;
3052- return;
3053- }
3054-
3055- /* We've got the same object and the same entry. Well,
3056- let's just put it right here then. */
3057- position->found = TRUE;
3058- return;
3059-}
3060-
3061-static void
3062-something_shown (GtkWidget * widget, gpointer user_data)
3063-{
3064- GtkWidget * menuitem = GTK_WIDGET(user_data);
3065- gtk_widget_show(menuitem);
3066-}
3067-
3068-static void
3069-something_hidden (GtkWidget * widget, gpointer user_data)
3070-{
3071- GtkWidget * menuitem = GTK_WIDGET(user_data);
3072- gtk_widget_hide(menuitem);
3073-}
3074-
3075-static void
3076-sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
3077-{
3078- g_return_if_fail(GTK_IS_WIDGET(obj));
3079- g_return_if_fail(GTK_IS_WIDGET(user_data));
3080-
3081- gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
3082- return;
3083-}
3084-
3085-static gboolean
3086-entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
3087-{
3088- IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
3089- IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
3090-
3091- g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
3092-
3093- g_signal_emit_by_name (io, "scroll", 1, event->direction);
3094- g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
3095-
3096- return FALSE;
3097-}
3098-
3099-static void
3100-entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
3101-{
3102- g_debug("Signal: Entry Added");
3103- gboolean something_visible = FALSE;
3104- gboolean something_sensitive = FALSE;
3105-
3106- GtkWidget * menuitem = gtk_menu_item_new();
3107- GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
3108- gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3);
3109-
3110- g_object_set_data (G_OBJECT (menuitem), "indicator", io);
3111- g_object_set_data (G_OBJECT (menuitem), "box", box);
3112-
3113- if (entry->image != NULL) {
3114- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
3115- if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
3116- something_visible = TRUE;
3117- }
3118-
3119- if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
3120- something_sensitive = TRUE;
3121- }
3122-
3123- g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
3124- g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
3125-
3126- g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
3127- }
3128- if (entry->label != NULL) {
3129- switch(packdirection) {
3130- case GTK_PACK_DIRECTION_LTR:
3131- gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
3132- break;
3133- case GTK_PACK_DIRECTION_TTB:
3134- gtk_label_set_angle(GTK_LABEL(entry->label),
3135- (orient == PANEL_APPLET_ORIENT_LEFT) ?
3136- 270.0 : 90.0);
3137- break;
3138- default:
3139- break;
3140- }
3141- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
3142-
3143- if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
3144- something_visible = TRUE;
3145- }
3146-
3147- if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
3148- something_sensitive = TRUE;
3149- }
3150-
3151- g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
3152- g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
3153-
3154- g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
3155- }
3156- gtk_container_add(GTK_CONTAINER(menuitem), box);
3157- gtk_widget_show(box);
3158-
3159- if (entry->menu != NULL) {
3160- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
3161- }
3162-
3163- incoming_position_t position;
3164- position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
3165- position.entryposition = indicator_object_get_location(io, entry);
3166- position.menupos = 0;
3167- position.found = FALSE;
3168-
3169- gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
3170-
3171- gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
3172-
3173- if (something_visible) {
3174- gtk_widget_show(menuitem);
3175- }
3176- gtk_widget_set_sensitive(menuitem, something_sensitive);
3177-
3178- g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
3179- g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
3180- g_signal_connect(G_OBJECT (menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
3181-
3182- return;
3183-}
3184-
3185-static void
3186-entry_removed_cb (GtkWidget * widget, gpointer userdata)
3187-{
3188- gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
3189-
3190- if (data != userdata) {
3191- return;
3192- }
3193-
3194- IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
3195- if (entry->label != NULL) {
3196- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
3197- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
3198- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
3199- }
3200- if (entry->image != NULL) {
3201- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
3202- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
3203- g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
3204- }
3205-
3206- gtk_widget_destroy(widget);
3207- return;
3208-}
3209-
3210-static void
3211-entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
3212- gpointer user_data)
3213-{
3214- g_debug("Signal: Entry Removed");
3215-
3216- gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
3217-
3218- return;
3219-}
3220-
3221-static void
3222-entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
3223-{
3224- gpointer * array = (gpointer *)userdata;
3225- if (array[1] != NULL) {
3226- return;
3227- }
3228-
3229- gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
3230-
3231- if (data != array[0]) {
3232- return;
3233- }
3234-
3235- array[1] = widget;
3236- return;
3237-}
3238-
3239-/* Gets called when an entry for an object was moved. */
3240-static void
3241-entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
3242- gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
3243-{
3244- GtkWidget * menubar = GTK_WIDGET(user_data);
3245-
3246- gpointer array[2];
3247- array[0] = entry;
3248- array[1] = NULL;
3249-
3250- gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
3251- if (array[1] == NULL) {
3252- g_warning("Moving an entry that isn't in our menus.");
3253- return;
3254- }
3255-
3256- GtkWidget * mi = GTK_WIDGET(array[1]);
3257- g_object_ref(G_OBJECT(mi));
3258- gtk_container_remove(GTK_CONTAINER(menubar), mi);
3259-
3260- incoming_position_t position;
3261- position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
3262- position.entryposition = indicator_object_get_location(io, entry);
3263- position.menupos = 0;
3264- position.found = FALSE;
3265-
3266- gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
3267-
3268- gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
3269-
3270- g_object_unref(G_OBJECT(mi));
3271-
3272- return;
3273-}
3274-
3275-static gboolean
3276-load_module (const gchar * name, GtkWidget * menubar)
3277-{
3278- g_debug("Looking at Module: %s", name);
3279- g_return_val_if_fail(name != NULL, FALSE);
3280-
3281- if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
3282- return FALSE;
3283- }
3284-
3285- g_debug("Loading Module: %s", name);
3286-
3287- /* Build the object for the module */
3288- gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
3289- IndicatorObject * io = indicator_object_new_from_file(fullpath);
3290- g_free(fullpath);
3291- g_return_val_if_fail(io != NULL, FALSE);
3292-
3293- /* Attach the 'name' to the object */
3294- g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name)));
3295-
3296- /* Connect to its signals */
3297- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
3298- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
3299- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
3300-
3301- /* Work on the entries */
3302- GList * entries = indicator_object_get_entries(io);
3303- GList * entry = NULL;
3304-
3305- for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
3306- IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
3307- entry_added(io, entrydata, menubar);
3308- }
3309-
3310- g_list_free(entries);
3311-
3312- return TRUE;
3313-}
3314-// </indicator-applet-copy>
3315-
3316-
3317-/* prototypes */
3318-static gboolean
3319-on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator);
3320-
3321-IndicatorPlugin *
3322-indicator_new ()
3323-{
3324- IndicatorPlugin *indicator;
3325- GtkOrientation orientation;
3326- gint indicators_loaded = 0;
3327-
3328- /* Hack! prevent the appmenu indicator from swallowing our own menubar */
3329- setenv("APPMENU_DISPLAY_BOTH", "1");
3330-
3331- /* allocate memory for the plugin structure */
3332- indicator = g_new (IndicatorPlugin, 1);
3333-
3334- indicator->container = gtk_plug_new(0);
3335-
3336- /* Init some theme/icon stuff */
3337- g_object_set (gtk_settings_get_default(), "gtk-theme-name", "Ambiance", NULL);
3338- g_object_set (gtk_settings_get_default(), "gtk-icon-theme-name", "ubuntu-mono-dark", NULL);
3339- gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
3340- INDICATOR_ICONS_DIR);
3341- gtk_rc_parse_string (
3342- "widget \"indicator-applet*\" style \"panel\"\n"
3343- "style \"indicator-applet-style\"\n"
3344- "{\n"
3345- " GtkMenuBar::shadow-type = none\n"
3346- " GtkMenuBar::internal-padding = 0\n"
3347- " GtkWidget::focus-line-width = 0\n"
3348- " GtkWidget::focus-padding = 0\n"
3349- "}\n"
3350- "style \"indicator-applet-menubar-style\"\n"
3351- "{\n"
3352- " GtkMenuBar::shadow-type = none\n"
3353- " GtkMenuBar::internal-padding = 0\n"
3354- " GtkWidget::focus-line-width = 0\n"
3355- " GtkWidget::focus-padding = 0\n"
3356- " GtkMenuItem::horizontal-padding = 0\n"
3357- "}\n"
3358- "style \"indicator-applet-menuitem-style\"\n"
3359- "{\n"
3360- " GtkWidget::focus-line-width = 0\n"
3361- " GtkWidget::focus-padding = 0\n"
3362- " GtkMenuItem::horizontal-padding = 0\n"
3363- "}\n"
3364- "widget \"*.indicator-applet\" style \"indicator-applet-style\""
3365- "widget \"*.indicator-applet-menuitem\" style \"indicator-applet-menuitem-style\""
3366- "widget \"*.indicator-applet-menubar\" style \"indicator-applet-menubar-style\"");
3367- gtk_widget_set_name(GTK_WIDGET (indicator->container), "indicator-applet");
3368- /* create some panel widgets */
3369-
3370- /* Build menu */
3371- indicator->menu = gtk_menu_bar_new();
3372- gtk_widget_set_can_focus(GTK_WIDGET (indicator->menu), TRUE);
3373- gtk_widget_set_name(GTK_WIDGET (indicator->menu), "indicator-applet-menubar");
3374- g_signal_connect(indicator->menu, "button-press-event", G_CALLBACK(on_menu_press), NULL);
3375- //g_signal_connect_after(indicator->menu, "expose-event", G_CALLBACK(menu_on_expose), menu);
3376- gtk_container_set_border_width(GTK_CONTAINER(indicator->menu), 0);
3377-
3378- /* load 'em */
3379- if (!g_file_test(INDICATOR_DIR, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
3380- g_warning ("%s does not exist, cannot read any indicators", INDICATOR_DIR);
3381- } else {
3382- GDir *dir;
3383- const gchar *name;
3384-
3385- dir = g_dir_open(INDICATOR_DIR, 0, NULL);
3386- while ((name = g_dir_read_name (dir)) != NULL) {
3387- if (g_strcmp0(name, "libappmenu.so") == 0) {
3388- continue;
3389- }
3390-
3391- if (load_module(name, indicator->menu)) {
3392- indicators_loaded++;
3393- } else {
3394- g_warning("Failed to load module %s", name);
3395- }
3396- }
3397- g_dir_close(dir);
3398- }
3399-
3400- if (indicators_loaded == 0) {
3401- /* A label to allow for click through */
3402- indicator->item = gtk_button_new();
3403- gtk_button_set_label(GTK_BUTTON(indicator->item), "No Indicators");
3404- gtk_widget_show(indicator->item);
3405- gtk_container_add (GTK_CONTAINER (indicator->container), indicator->item);
3406- } else {
3407- gtk_widget_show(indicator->menu);
3408- gtk_container_add (GTK_CONTAINER (indicator->container), indicator->menu);
3409- }
3410- return indicator;
3411-}
3412-
3413-
3414-
3415-void
3416-indicator_free (IndicatorPlugin *indicator)
3417-{
3418- g_free(indicator);
3419-}
3420-
3421-
3422-#if 0
3423-static gboolean
3424-indicator_size_changed (XfcePanelPlugin *plugin,
3425- gint size,
3426- IndicatorPlugin *indicator)
3427-{
3428- GtkOrientation orientation;
3429-
3430- /* get the orientation of the plugin */
3431- orientation = xfce_panel_plugin_get_orientation (plugin);
3432-
3433- /* set the widget size */
3434- if (orientation == GTK_ORIENTATION_HORIZONTAL)
3435- gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size);
3436- else
3437- gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1);
3438-
3439- /* we handled the orientation */
3440- return TRUE;
3441-}
3442-#endif
3443-
3444-
3445-static gboolean
3446-on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator)
3447-{
3448- if (indicator != NULL && event->button == 1) /* left click only */
3449- {
3450- /* gtk_menu_popup (GTK_MENU(indicator->menu), NULL, NULL, NULL, NULL, 0,
3451- event->time);*/
3452- return TRUE;
3453- }
3454- return FALSE ;
3455-}
3456
3457=== removed file 'panel/applets/indicator/indicator.h'
3458--- panel/applets/indicator/indicator.h 2011-06-22 14:49:34 +0000
3459+++ panel/applets/indicator/indicator.h 1970-01-01 00:00:00 +0000
3460@@ -1,45 +0,0 @@
3461-/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
3462- *
3463- * This program is free software; you can redistribute it and/or modify
3464- * it under the terms of the GNU General Public License as published by
3465- * the Free Software Foundation; either version 2 of the License, or
3466- * (at your option) any later version.
3467- *
3468- * This program is distributed in the hope that it will be useful,
3469- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3470- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3471- * GNU Library General Public License for more details.
3472- *
3473- * You should have received a copy of the GNU General Public License
3474- * along with this program; if not, write to the Free Software
3475- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3476- */
3477-
3478-#ifndef __INDICATOR_H__
3479-#define __INDICATOR_H__
3480-
3481-#include <gtk/gtk.h>
3482-
3483-G_BEGIN_DECLS
3484-
3485-/* plugin structure */
3486-typedef struct _IndicatorPlugin
3487-{
3488- GtkWidget *container;
3489- /* panel widgets */
3490- GtkWidget *menu;
3491- GtkWidget *item;
3492-
3493- /* indicator settings */
3494-}
3495-IndicatorPlugin;
3496-
3497-IndicatorPlugin *
3498-indicator_new ();
3499-
3500-void
3501-indicator_free(IndicatorPlugin*);
3502-
3503-G_END_DECLS
3504-
3505-#endif /* !__INDICATOR_H__ */
3506
3507=== removed file 'panel/applets/indicator/indicatorapplet.cpp'
3508--- panel/applets/indicator/indicatorapplet.cpp 2011-07-27 12:33:12 +0000
3509+++ panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000
3510@@ -1,77 +0,0 @@
3511-/*
3512- * This file is part of unity-2d
3513- *
3514- * Copyright 2010 Canonical Ltd.
3515- *
3516- * Authors:
3517- * - Aurélien Gâteau <aurelien.gateau@canonical.com>
3518- *
3519- * This program is free software; you can redistribute it and/or modify
3520- * it under the terms of the GNU General Public License as published by
3521- * the Free Software Foundation; version 3.
3522- *
3523- * This program is distributed in the hope that it will be useful,
3524- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3525- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3526- * GNU General Public License for more details.
3527- *
3528- * You should have received a copy of the GNU General Public License
3529- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3530- */
3531-
3532-// Self
3533-#include "indicatorapplet.h"
3534-
3535-// Local
3536-#include "debug_p.h"
3537-#include "indicator.h"
3538-
3539-// Qt
3540-#include <QHBoxLayout>
3541-#include <QTimer>
3542-#include <QX11EmbedContainer>
3543-
3544-// Gtk
3545-#include <gtk/gtk.h>
3546-#include <gtk/gtkx.h>
3547-
3548-IndicatorApplet::IndicatorApplet()
3549-{
3550- setupUi();
3551-}
3552-
3553-void IndicatorApplet::setupUi()
3554-{
3555- m_menuBar = new QMenuBar;
3556- m_menuBar->setNativeMenuBar(false);
3557- QHBoxLayout* layout = new QHBoxLayout(this);
3558- layout->setMargin(0);
3559- layout->addWidget(m_menuBar);
3560-
3561- QMetaObject::invokeMethod(this, "createGtkIndicator", Qt::QueuedConnection);
3562-}
3563-
3564-void IndicatorApplet::createGtkIndicator()
3565-{
3566- m_container = new QX11EmbedContainer;
3567- layout()->addWidget(m_container);
3568-
3569- m_gtkIndicator = indicator_new();
3570- m_container->embedClient(gtk_plug_get_id(GTK_PLUG(m_gtkIndicator->container)));
3571- gtk_widget_show(m_gtkIndicator->container);
3572-
3573- QTimer* timer = new QTimer(this);
3574- timer->setInterval(1000);
3575- timer->setSingleShot(false);
3576- connect(timer, SIGNAL(timeout()), SLOT(adjustGtkIndicatorSize()));
3577- timer->start();
3578-}
3579-
3580-void IndicatorApplet::adjustGtkIndicatorSize()
3581-{
3582- GtkRequisition minimum, natural;
3583- gtk_widget_get_preferred_size(m_gtkIndicator->menu, &minimum, &natural);
3584- m_container->setFixedWidth(minimum.width);
3585-}
3586-
3587-#include "indicatorapplet.moc"
3588
3589=== removed file 'panel/applets/indicator/indicatorapplet.h'
3590--- panel/applets/indicator/indicatorapplet.h 2011-07-27 12:33:12 +0000
3591+++ panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000
3592@@ -1,57 +0,0 @@
3593-/*
3594- * This file is part of unity-2d
3595- *
3596- * Copyright 2010 Canonical Ltd.
3597- *
3598- * Authors:
3599- * - Aurélien Gâteau <aurelien.gateau@canonical.com>
3600- *
3601- * This program is free software; you can redistribute it and/or modify
3602- * it under the terms of the GNU General Public License as published by
3603- * the Free Software Foundation; version 3.
3604- *
3605- * This program is distributed in the hope that it will be useful,
3606- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3607- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3608- * GNU General Public License for more details.
3609- *
3610- * You should have received a copy of the GNU General Public License
3611- * along with this program. If not, see <http://www.gnu.org/licenses/>.
3612- */
3613-
3614-#ifndef INDICATORAPPLET_H
3615-#define INDICATORAPPLET_H
3616-
3617-// Local
3618-#include <applet.h>
3619-
3620-// Qt
3621-#include <QDBusInterface>
3622-#include <QMenuBar>
3623-
3624-class QX11EmbedContainer;
3625-
3626-struct _IndicatorPlugin;
3627-
3628-class IndicatorApplet : public Unity2d::Applet
3629-{
3630-Q_OBJECT
3631-public:
3632- IndicatorApplet();
3633-
3634-private Q_SLOTS:
3635- void createGtkIndicator();
3636- void adjustGtkIndicatorSize();
3637-
3638-private:
3639- Q_DISABLE_COPY(IndicatorApplet)
3640-
3641- QDBusInterface* m_watcher;
3642- QMenuBar* m_menuBar;
3643- QX11EmbedContainer* m_container;
3644- struct _IndicatorPlugin* m_gtkIndicator;
3645-
3646- void setupUi();
3647-};
3648-
3649-#endif /* INDICATORAPPLET_H */
3650
3651=== removed directory 'panel/artwork'
3652=== removed file 'panel/artwork/background.png'
3653Binary files panel/artwork/background.png 2010-11-23 16:13:46 +0000 and panel/artwork/background.png 1970-01-01 00:00:00 +0000 differ
3654=== removed file 'panel/artwork/divider.png'
3655Binary files panel/artwork/divider.png 2010-11-23 16:13:46 +0000 and panel/artwork/divider.png 1970-01-01 00:00:00 +0000 differ
3656=== modified file 'places/HomeShortcuts.qml'
3657--- places/HomeShortcuts.qml 2011-07-04 23:07:20 +0000
3658+++ places/HomeShortcuts.qml 2011-07-27 12:33:15 +0000
3659@@ -58,9 +58,9 @@
3660 contentType: "x-scheme-handler/http"
3661 }
3662
3663- HomeButtonApplication {
3664+ HomeButtonDefaultApplication {
3665 label: u2d.tr("View Photos")
3666- desktopFile: "shotwell.desktop"
3667+ contentType: "image/jpeg"
3668 }
3669
3670 HomeButtonDefaultApplication {
3671@@ -68,9 +68,9 @@
3672 contentType: "x-scheme-handler/mailto"
3673 }
3674
3675- HomeButtonApplication {
3676+ HomeButtonDefaultApplication {
3677 label: u2d.tr("Listen to Music")
3678- key: "/desktop/gnome/applications/media/exec"
3679+ contentType: "audio/x-vorbis+ogg"
3680 }
3681 }
3682

Subscribers

People subscribed via source and target branches