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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-07-27 12:33:12 +0000
+++ CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -24,38 +24,6 @@
24find_package(Qt4 REQUIRED)24find_package(Qt4 REQUIRED)
25find_package(X11 REQUIRED)25find_package(X11 REQUIRED)
26find_package(Gettext REQUIRED)26find_package(Gettext REQUIRED)
27<<<<<<< TREE
28pkg_check_modules(GLIB REQUIRED glib-2.0)
29pkg_check_modules(GDK REQUIRED gdk-2.0)
30pkg_check_modules(GTK REQUIRED gtk+-2.0)
31pkg_check_modules(GIO REQUIRED gio-2.0)
32pkg_check_modules(WNCK REQUIRED libwnck-1.0)
33
34
35# GSettings schemas
36pkg_check_modules(GLIB REQUIRED glib-2.0)
37set (UNITY_2D_SCHEMAS "com.canonical.Unity2d.gschema.xml")
38set (UNITY_2D_GCONF_CONVERT "unity-2d.convert")
39set (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/")
40set (GCONF_CONVERT_DIR "${CMAKE_INSTALL_PREFIX}/share/GConf/gsettings")
41execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE GLIB_COMPILE_SCHEMAS OUTPUT_STRIP_TRAILING_WHITESPACE)
42
43# Run the schemas validator and error if it fails
44execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${UNITY_2D_DATA_DIR} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
45
46if (_schemas_invalid)
47 message (SEND_ERROR "Schemas validation error: ${_schemas_invalid}")
48endif (_schemas_invalid)
49
50# Actually install and recompile the schemas
51message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}")
52install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_SCHEMAS} DESTINATION ${GSETTINGS_DIR})
53install (CODE "message (STATUS \"Compiling GSettings schemas\")")
54install (CODE "execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_DIR})")
55
56# Install GConf to GSettings conversion file
57install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR})
58=======
59pkg_check_modules(GLIB REQUIRED glib-2.0)27pkg_check_modules(GLIB REQUIRED glib-2.0)
60pkg_check_modules(GDK REQUIRED gdk-3.0)28pkg_check_modules(GDK REQUIRED gdk-3.0)
61pkg_check_modules(GTK REQUIRED gtk+-3.0)29pkg_check_modules(GTK REQUIRED gtk+-3.0)
@@ -86,7 +54,6 @@
8654
87# Install GConf to GSettings conversion file55# Install GConf to GSettings conversion file
88install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR})56install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR})
89>>>>>>> MERGE-SOURCE
9057
91include_directories(58include_directories(
92 ${CMAKE_BINARY_DIR}59 ${CMAKE_BINARY_DIR}
9360
=== renamed file 'debian/20_unity-2d-gconf-default' => 'debian/20_ubuntu-2d-gconf-default'
--- debian/20_unity-2d-gconf-default 2011-07-25 11:56:59 +0000
+++ debian/20_ubuntu-2d-gconf-default 2011-07-27 12:33:15 +0000
@@ -1,13 +1,5 @@
1/apps/gnome-power-manager/lock/use_screensaver_settings true
2/apps/gnome-power-manager/general/use_time_for_policy false
3/desktop/gnome/applications/window_manager/default /usr/bin/metacity
4/desktop/gnome/applications/window_manager/current /usr/bin/metacity
5/apps/metacity/general/show_maximized_titlebars false1/apps/metacity/general/show_maximized_titlebars false
6/apps/metacity/general/auto_maximize_windows true2/apps/metacity/general/auto_maximize_windows true
7/apps/metacity/general/capture_before_unmap true3/apps/metacity/general/capture_before_unmap true
8/apps/metacity/general/compositing_manager true4/apps/metacity/general/compositing_manager true
9/apps/metacity/general/compositor_effects false5/apps/metacity/general/compositor_effects false
10/apps/metacity/general/theme Ambiance
11/desktop/gnome/interface/gtk_theme Ambiance
12/desktop/gnome/interface/icon_theme ubuntu-mono-dark
13/desktop/gnome/peripherals/mouse/cursor_theme DMZ-White
146
=== renamed file 'debian/20_unity-2d-gconf-mandatory' => 'debian/20_ubuntu-2d-gconf-mandatory'
--- debian/20_unity-2d-gconf-mandatory 2011-06-15 13:05:38 +0000
+++ debian/20_ubuntu-2d-gconf-mandatory 2011-07-27 12:33:15 +0000
@@ -1,3 +1,2 @@
1/apps/nautilus/preferences/exit_with_last_window false
2/apps/metacity/global_keybindings/panel_main_menu disabled1/apps/metacity/global_keybindings/panel_main_menu disabled
3/apps/metacity/global_keybindings/panel_run_dialog disabled2/apps/metacity/global_keybindings/panel_run_dialog disabled
43
=== modified file 'debian/changelog'
--- debian/changelog 2011-07-22 16:57:49 +0000
+++ debian/changelog 2011-07-27 12:33:15 +0000
@@ -1,6 +1,7 @@
1unity-2d (3.8.12-0ubuntu1) UNRELEASED; urgency=low1unity-2d (3.8.12-0ubuntu1) UNRELEASED; urgency=low
22
3 [ Florian Boucault ]3 [ Florian Boucault ]
4 * Upstreamed patch 01_build_with_new_indicator.patch
4 * do not run pkgbinarymangler to convert images to 8bit since this breaks5 * do not run pkgbinarymangler to convert images to 8bit since this breaks
5 the launcher icon background handling. (LP: #809205)6 the launcher icon background handling. (LP: #809205)
6 (QT upstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-4459)7 (QT upstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-4459)
@@ -23,7 +24,16 @@
2324
24 -- Florian Boucault <florian.boucault@canonical.com> Fri, 22 Jul 2011 18:56:33 +020025 -- Florian Boucault <florian.boucault@canonical.com> Fri, 22 Jul 2011 18:56:33 +0200
2526
26unity-2d (3.8.10-0ubuntu1) natty; urgency=low27unity-2d (3.8.10-0ubuntu2) oneiric; urgency=low
28
29 * debian/control:
30 - rebuild with new indicator 0.4
31 * 01_build_with_new_indicator.patch:
32 - patch to build with the new indicator 0.4 stack
33
34 -- Didier Roche <didrocks@ubuntu.com> Sun, 10 Jul 2011 23:48:01 +0200
35
36unity-2d (3.8.10-0ubuntu1) oneiric; urgency=low
2737
28 [ Florian Boucault ]38 [ Florian Boucault ]
29 * debian/unity-2d-launcher.install:39 * debian/unity-2d-launcher.install:
@@ -46,10 +56,17 @@
46 - Missing a GConf schema file for the /desktop/unity-2d/… keys56 - Missing a GConf schema file for the /desktop/unity-2d/… keys
47 (LP: #750303)57 (LP: #750303)
48 - [dash] home screen search hint should be 'Search' (LP: #797825)58 - [dash] home screen search hint should be 'Search' (LP: #797825)
4959 * debian/unity-2d.gconf-defaults,
50 -- Florian Boucault <florian.boucault@canonical.com> Wed, 13 Jul 2011 11:59:29 +020060 debian/20_ubuntu-2d-gconf-default:
5161 - transition some gconf keys from session-wide to system-wide
52unity-2d (3.8.8-0ubuntu1) natty; urgency=low62 (LP: #797672, #797676)
63 * debian/control:
64 - ensure we are still using gtk2 indicator for alpha2 (LP: #804938)
65 - bump standards-version
66
67 -- Didier Roche <didrocks@ubuntu.com> Mon, 04 Jul 2011 11:05:54 +0200
68
69unity-2d (3.8.8-0ubuntu1) oneiric; urgency=low
5370
54 [ Didier Roche ]71 [ Didier Roche ]
55 * new upstream release:72 * new upstream release:
@@ -96,7 +113,21 @@
96113
97 -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200114 -- Didier Roche <didrocks@ubuntu.com> Tue, 14 Jun 2011 16:14:18 +0200
98115
99unity-2d (3.8.6-0ubuntu1) natty; urgency=low116unity-2d (3.8.6-0ubuntu3~ppa1) oneiric; urgency=low
117
118 * Rebuild with new gcc
119
120 -- Didier Roche <didrocks@ubuntu.com> Tue, 07 Jun 2011 15:00:32 +0200
121
122unity-2d (3.8.6-0ubuntu2) oneiric; urgency=low
123
124 * debian/unity-2d.postinst, debian/unity-2d.postrm:
125 - remove the magic to set unity-2d in oneiric as the default session in gdm
126 as it's now installed on the ubuntu CD.
127
128 -- Didier Roche <didrocks@ubuntu.com> Wed, 01 Jun 2011 09:42:21 +0200
129
130unity-2d (3.8.6-0ubuntu1) oneiric; urgency=low
100131
101 * New upstream release:132 * New upstream release:
102 - [launcher] Support static shortcuts in the quicklists. (LP: #669923)133 - [launcher] Support static shortcuts in the quicklists. (LP: #669923)
@@ -140,6 +171,18 @@
140 * debian/libunity-2d-private0.post*171 * debian/libunity-2d-private0.post*
141 - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass172 - removed: ldconfig is generated directly by dh_makeshlibs as we don't pass
142 -n anymore173 -n anymore
174 * don't install unity-2d session as it's in gnome-session now
175 * debian/unity-2d.install
176 debian/20_ubuntu-2d-gconf-default
177 debian/20_ubuntu-2d-gconf-mandatory
178 debian/gconf/ubuntu-2d.default.path
179 debian/gconf/ubuntu-2d.mandatory.path:
180 - remove uneeded defaults and mandatory
181 - remove some deprecated keys
182 - the session is now called ubuntu-2d and not unity-2d anymore
183 * debian/unity-2d.preinst, debian/unity-2d.postinst
184 debian/unity-2d.postrm:
185 - take into account the natty -> oneiric migration with session name change
143186
144 -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200187 -- Didier Roche <didrocks@ubuntu.com> Wed, 25 May 2011 12:19:25 +0200
145188
146189
=== modified file 'debian/control'
--- debian/control 2011-07-27 12:33:12 +0000
+++ debian/control 2011-07-27 12:33:15 +0000
@@ -20,9 +20,10 @@
20 libindicator3-dev,20 libindicator3-dev,
21 libgtk-3-dev,21 libgtk-3-dev,
22 libutouch-geis-dev,22 libutouch-geis-dev,
23 libstartup-notification0-dev23 libstartup-notification0-dev,
24Standards-Version: 3.9.124 libunity-core-4.0-dev,
25Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/trunk25Standards-Version: 3.9.2
26Vcs-Bzr: http://bazaar.launchpad.net/~unity-2d-team/unity-2d/oneiric
2627
27Package: unity-2d28Package: unity-2d
28Architecture: all29Architecture: all
@@ -71,13 +72,13 @@
71 ${misc:Depends},72 ${misc:Depends},
72 libunity-2d-private073 libunity-2d-private0
73Provides: indicator-renderer74Provides: indicator-renderer
74Recommends: indicator-application,75Recommends: indicator-application-gtk2,
75 indicator-appmenu,76 indicator-appmenu-gtk2,
76 indicator-datetime,77 indicator-datetime-gtk2,
77 indicator-me,78 indicator-me-gtk2,
78 indicator-messages,79 indicator-messages-gtk2,
79 indicator-session,80 indicator-session-gtk2,
80 indicator-sound,81 indicator-sound-gtk2,
81Description: Unity 2D Panel82Description: Unity 2D Panel
82 The Unity 2D panel displays a top panel containing the application menu and83 The Unity 2D panel displays a top panel containing the application menu and
83 various indicators. It is part of Unity 2D and can not run as a standalone84 various indicators. It is part of Unity 2D and can not run as a standalone
8485
=== renamed file 'debian/gconf/unity-2d.default.path' => 'debian/gconf/ubuntu-2d.default.path'
--- debian/gconf/unity-2d.default.path 2011-06-15 13:05:38 +0000
+++ debian/gconf/ubuntu-2d.default.path 2011-07-27 12:33:15 +0000
@@ -1,3 +1,3 @@
1# Additional mandatory path for unity-2d experience1# Additional mandatory path for ubuntu-2d experience
2xml:readonly:/var/lib/gconf/unity-2d.default2xml:readonly:/var/lib/gconf/ubuntu-2d.default
33
44
=== renamed file 'debian/gconf/unity-2d.mandatory.path' => 'debian/gconf/ubuntu-2d.mandatory.path'
--- debian/gconf/unity-2d.mandatory.path 2011-06-15 13:05:38 +0000
+++ debian/gconf/ubuntu-2d.mandatory.path 2011-07-27 12:33:15 +0000
@@ -1,3 +1,3 @@
1# Additional mandatory path for unity-2d experience1# Additional mandatory path for ubuntu-2d experience
2xml:readonly:/var/lib/gconf/unity-2d.mandatory2xml:readonly:/var/lib/gconf/ubuntu-2d.mandatory
33
44
=== modified file 'debian/unity-2d-panel.install'
--- debian/unity-2d-panel.install 2011-01-14 21:41:39 +0000
+++ debian/unity-2d-panel.install 2011-07-27 12:33:15 +0000
@@ -1,4 +1,2 @@
1usr/bin/unity-2d-panel1usr/bin/unity-2d-panel
2usr/share/applications/unity-2d-panel.desktop2usr/share/applications/unity-2d-panel.desktop
3usr/share/unity-2d/panel/artwork/background.png
4usr/share/unity-2d/panel/artwork/divider.png
53
=== added file 'debian/unity-2d.gconf-defaults'
--- debian/unity-2d.gconf-defaults 1970-01-01 00:00:00 +0000
+++ debian/unity-2d.gconf-defaults 2011-07-27 12:33:15 +0000
@@ -0,0 +1,4 @@
1/desktop/unity-2d/launcher/favorites [ubiquity-gtkui.desktop,nautilus-home.desktop,firefox.desktop,libreoffice-writer.desktop,libreoffice-calc.desktop,libreoffice-impress.desktop,ubuntu-software-center.desktop,ubuntuone-control-panel-gtk.desktop]
2/desktop/unity-2d/launcher/hide_mode 2
3/desktop/unity-2d/launcher/use_strut false
4/desktop/unity-2d/launcher/super_key_enable true
05
=== modified file 'debian/unity-2d.install'
--- debian/unity-2d.install 2011-07-22 14:44:57 +0000
+++ debian/unity-2d.install 2011-07-27 12:33:15 +0000
@@ -1,9 +1,7 @@
1debian/unity-2d.py /usr/share/apport/package-hooks1debian/unity-2d.py /usr/share/apport/package-hooks
2debian/gconf/* /usr/share/gconf2debian/gconf/* /usr/share/gconf
3session/unity-2d.desktop /usr/share/xsessions3debian/20_ubuntu-2d-gconf-mandatory /usr/share/gconf/ubuntu-2d/mandatory
4session/2d-ubuntu.session /usr/share/gnome-session/sessions4debian/20_ubuntu-2d-gconf-default /usr/share/gconf/ubuntu-2d/default
5debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory
6debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default
7usr/share/locale/*/LC_MESSAGES/unity-2d.mo5usr/share/locale/*/LC_MESSAGES/unity-2d.mo
8usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml6usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml
9usr/share/GConf/gsettings7usr/share/GConf/gsettings
108
=== modified file 'debian/unity-2d.postinst'
--- debian/unity-2d.postinst 2011-06-15 13:05:38 +0000
+++ debian/unity-2d.postinst 2011-07-27 12:33:15 +0000
@@ -9,24 +9,21 @@
99
10case "$1" in10case "$1" in
11 configure|upgrade)11 configure|upgrade)
12 if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
13 /usr/lib/gdm/gdm-set-default-session --keep-old unity-2d || true
14 fi
15 if which update-gconf-defaults >/dev/null 2>&1 ; then12 if which update-gconf-defaults >/dev/null 2>&1 ; then
16 mkdir -p /var/lib/gconf/unity-2d.mandatory13 mkdir -p /var/lib/gconf/ubuntu-2d.mandatory
17 mkdir -p /var/lib/gconf/unity-2d.default14 mkdir -p /var/lib/gconf/ubuntu-2d.default
18 fi15 fi
19 ;;16 ;;
20 triggered)17 triggered)
21 for trigger in $2; do18 for trigger in $2; do
22 case $trigger in19 case $trigger in
23 /usr/share/gconf/unity-2d/mandatory)20 /usr/share/gconf/ubuntu-2d/mandatory)
24 update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \21 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
25 --destination /var/lib/gconf/unity-2d.mandatory --no-signal22 --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
26 ;;23 ;;
27 /usr/share/gconf/unity-2d/default)24 /usr/share/gconf/ubuntu-2d/default)
28 update-gconf-defaults --source /usr/share/gconf/unity-2d/default \25 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
29 --destination /var/lib/gconf/unity-2d.default --no-signal26 --destination /var/lib/gconf/ubuntu-2d.default --no-signal
30 ;;27 ;;
31 esac28 esac
32 done29 done
@@ -39,9 +36,9 @@
3936
40# Upon installation/upgrade, regenerate all databases, because in this case 37# Upon installation/upgrade, regenerate all databases, because in this case
41# there will be no trigger run38# there will be no trigger run
42update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \39update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
43 --destination /var/lib/gconf/unity-2d.mandatory --no-signal40 --destination /var/lib/gconf/ubuntu-2d.mandatory --no-signal
44update-gconf-defaults --source /usr/share/gconf/unity-2d/default \41update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
45 --destination /var/lib/gconf/unity-2d.default --no-signal42 --destination /var/lib/gconf/ubuntu-2d.default --no-signal
46signal_daemons43signal_daemons
4744
4845
=== modified file 'debian/unity-2d.postrm'
--- debian/unity-2d.postrm 2011-06-15 13:05:38 +0000
+++ debian/unity-2d.postrm 2011-07-27 12:33:15 +0000
@@ -3,20 +3,17 @@
33
4case "$1" in4case "$1" in
5 remove|purge)5 remove|purge)
6 if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/unity-2d ]; then6 if which update-gconf-defaults >/dev/null 2>&1 && [ -d /usr/share/gconf/mandatory/ubuntu-2d ]; then
7 update-gconf-defaults --source /usr/share/gconf/unity-2d/mandatory \7 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/mandatory \
8 --destination /var/lib/gconf/unity-2d.mandatory8 --destination /var/lib/gconf/ubuntu-2d.mandatory
9 update-gconf-defaults --source /usr/share/gconf/unity-2d/default \9 update-gconf-defaults --source /usr/share/gconf/ubuntu-2d/default \
10 --destination /var/lib/gconf/unity-2d.default10 --destination /var/lib/gconf/ubuntu-2d.default
11 fi11 fi
12 if [ -d /var/lib/gconf/unity-2d.mandatory ]; then12 if [ -d /var/lib/gconf/ubuntu-2d.mandatory ]; then
13 rm -rf /var/lib/gconf/unity-2d.mandatory13 rm -rf /var/lib/gconf/ubuntu-2d.mandatory
14 fi14 fi
15 if [ -d /var/lib/gconf/unity-2d.default ]; then15 if [ -d /var/lib/gconf/ubuntu-2d.default ]; then
16 rm -rf /var/lib/gconf/unity-2d.default16 rm -rf /var/lib/gconf/ubuntu-2d.default
17 fi
18 if [ -x /usr/lib/gdm/gdm-set-default-session ] ; then
19 /usr/lib/gdm/gdm-set-default-session --remove unity-2d || true
20 fi17 fi
21 ;;18 ;;
22esac19esac
2320
=== added file 'debian/unity-2d.preinst'
--- debian/unity-2d.preinst 1970-01-01 00:00:00 +0000
+++ debian/unity-2d.preinst 2011-07-27 12:33:15 +0000
@@ -0,0 +1,16 @@
1#!/bin/sh
2set -e
3
4case "$1" in
5 install|upgrade)
6 if dpkg --compare-versions "$2" le "3.8.6-0ubuntu1"; then
7 if [ -d /var/lib/gconf/unity-2d.mandatory ]; then
8 mv /var/lib/gconf/unity-2d.mandatory /var/lib/gconf/ubuntu-2d.mandatory || true
9 mv /var/lib/gconf/unity-2d.default /var/lib/gconf/ubuntu-2d.default || true
10 fi
11 fi
12 ;;
13esac
14
15#DEBHELPER#
16
017
=== modified file 'libunity-2d-private/Unity2d/CMakeLists.txt'
--- libunity-2d-private/Unity2d/CMakeLists.txt 2011-07-27 12:33:12 +0000
+++ libunity-2d-private/Unity2d/CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -4,13 +4,8 @@
4pkg_check_modules(QTDEE REQUIRED libqtdee)4pkg_check_modules(QTDEE REQUIRED libqtdee)
5pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)5pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
6pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0)6pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0)
7<<<<<<< TREE
8pkg_check_modules(INDICATOR REQUIRED indicator)
9pkg_check_modules(DCONFQT REQUIRED dconf-qt)
10=======
11pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)7pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)
12pkg_check_modules(DCONFQT REQUIRED dconf-qt)8pkg_check_modules(DCONFQT REQUIRED dconf-qt)
13>>>>>>> MERGE-SOURCE
149
15# Sources10# Sources
16set(unity-2d-private-qml_SRCS11set(unity-2d-private-qml_SRCS
1712
=== modified file 'libunity-2d-private/src/CMakeLists.txt'
--- libunity-2d-private/src/CMakeLists.txt 2011-07-27 12:33:12 +0000
+++ libunity-2d-private/src/CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -1,5 +1,6 @@
1# Sources1# Sources
2set(libunity-2d-private_SRCS2set(libunity-2d-private_SRCS
3 debug.cpp
3 gconnector.cpp4 gconnector.cpp
4 gnomesessionclient.cpp5 gnomesessionclient.cpp
5 keyboardmodifiersmonitor.cpp6 keyboardmodifiersmonitor.cpp
67
=== added file 'libunity-2d-private/src/debug.cpp'
--- libunity-2d-private/src/debug.cpp 1970-01-01 00:00:00 +0000
+++ libunity-2d-private/src/debug.cpp 2011-07-27 12:33:15 +0000
@@ -0,0 +1,23 @@
1/* This file is part of unity-2d
2 Copyright 2011 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; version 3.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17// Self
18#include <debug_p.h>
19
20QDebug operator<<(QDebug& dbg, const std::string& str)
21{
22 return dbg << QString::fromUtf8(str.c_str());
23}
024
=== modified file 'libunity-2d-private/src/debug_p.h'
--- libunity-2d-private/src/debug_p.h 2011-03-28 14:06:14 +0000
+++ libunity-2d-private/src/debug_p.h 2011-07-27 12:33:15 +0000
@@ -17,8 +17,12 @@
17#ifndef DEBUG_P_H17#ifndef DEBUG_P_H
18#define DEBUG_P_H18#define DEBUG_P_H
1919
20// Qt
20#include <QDebug>21#include <QDebug>
2122
23// STL
24#include <string>
25
22#define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space()26#define _UQ_TRACE(level) (level().nospace() << __PRETTY_FUNCTION__ << ":").space()
2327
24// Simple macros to get KDebug like support28// Simple macros to get KDebug like support
@@ -62,5 +66,7 @@
6266
63#define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__)67#define UQ_DEBUG_BLOCK Unity2dDebugBlock __unity2dDebugBlock__(__PRETTY_FUNCTION__)
6468
69// Support for outputing std::string with qDebug
70QDebug operator<<(QDebug& dbg, const std::string& str);
6571
66#endif /* DEBUG_P_H */72#endif /* DEBUG_P_H */
6773
=== modified file 'libunity-2d-private/src/unity2dapplication.cpp'
--- libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 12:33:12 +0000
+++ libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 12:33:15 +0000
@@ -41,30 +41,6 @@
41 }41 }
42}42}
4343
44<<<<<<< TREE
45void Unity2dApplication::earlySetup(int& argc, char** argv)
46{
47 // Parts of unity-2d uses GTK so it needs to be initialized
48 gtk_init(&argc, &argv);
49
50 Unity2dDebug::installHandlers();
51
52 /* When the environment variable QT_GRAPHICSSYSTEM is not set, force
53 * graphics system to 'raster' instead of the default 'native' which on X11
54 * is 'XRender'. 'XRender' defaults to using a TrueColor visual. We do
55 * _not_ mimick that behaviour with 'raster' by calling
56 * QApplication::setColorSpec because of bugs where some pixmaps become
57 * blueish or black rectangular artifacts were appearing randomly:
58 *
59 * https://bugs.launchpad.net/unity-2d/+bug/689877
60 * https://bugs.launchpad.net/unity-2d/+bug/734143
61 */
62 if(getenv("QT_GRAPHICSSYSTEM") == 0) {
63 QApplication::setGraphicsSystem("raster");
64 }
65}
66
67=======
68static bool arrayContains(char** begin, char** end, const char* string)44static bool arrayContains(char** begin, char** end, const char* string)
69{45{
70 for (char** ptr = begin; ptr != end; ++ptr) {46 for (char** ptr = begin; ptr != end; ++ptr) {
@@ -105,7 +81,6 @@
105 }81 }
106}82}
10783
108>>>>>>> MERGE-SOURCE
109Unity2dApplication::Unity2dApplication(int& argc, char** argv)84Unity2dApplication::Unity2dApplication(int& argc, char** argv)
110: QApplication(argc, argv)85: QApplication(argc, argv)
111{86{
11287
=== modified file 'panel/CMakeLists.txt'
--- panel/CMakeLists.txt 2011-06-27 13:40:51 +0000
+++ panel/CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -1,5 +1,8 @@
1project(unity-2d-panel)1project(unity-2d-panel)
22
3# Dependencies
4pkg_check_modules(UNITYCORE REQUIRED unity-core-4.0)
5
3# Source6# Source
4include_directories(7include_directories(
5 ${libunity-2d-private_SOURCE_DIR}/src8 ${libunity-2d-private_SOURCE_DIR}/src
@@ -8,8 +11,3 @@
8add_subdirectory(applets)11add_subdirectory(applets)
9add_subdirectory(app)12add_subdirectory(app)
10add_subdirectory(tests)13add_subdirectory(tests)
11
12# Install
13install(DIRECTORY artwork
14 DESTINATION ${UNITY_2D_DIR}/panel
15 )
1614
=== modified file 'panel/app/CMakeLists.txt'
--- panel/app/CMakeLists.txt 2011-07-27 12:33:12 +0000
+++ panel/app/CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -12,6 +12,7 @@
12 ${GTK_INCLUDE_DIRS}12 ${GTK_INCLUDE_DIRS}
13 ${uqapplets_SOURCE_DIR}13 ${uqapplets_SOURCE_DIR}
14 ${uqapplets_SOURCE_DIR}/common14 ${uqapplets_SOURCE_DIR}/common
15 ${UNITYCORE_INCLUDE_DIRS}
15 ${libunity-2d-private_SOURCE_DIR}/src16 ${libunity-2d-private_SOURCE_DIR}/src
16 )17 )
1718
1819
=== modified file 'panel/app/main.cpp'
--- panel/app/main.cpp 2011-07-27 12:33:12 +0000
+++ panel/app/main.cpp 2011-07-27 12:33:15 +0000
@@ -22,6 +22,7 @@
22// Local22// Local
23#include <config.h>23#include <config.h>
24#include <panelmanager.h>24#include <panelmanager.h>
25#include <panelstyle.h>
2526
26// Unity27// Unity
27#include <gnomesessionclient.h>28#include <gnomesessionclient.h>
@@ -54,6 +55,9 @@
54 Unity2dApplication::earlySetup(argc, argv);55 Unity2dApplication::earlySetup(argc, argv);
55 Unity2dApplication app(argc, argv);56 Unity2dApplication app(argc, argv);
5657
58 // Instantiate a PanelStyle so that it configures QApplication
59 PanelStyle::instance();
60
57 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop");61 GnomeSessionClient client(INSTALL_PREFIX "/share/applications/unity-2d-panel.desktop");
58 client.connectToSessionManager();62 client.connectToSessionManager();
5963
6064
=== modified file 'panel/app/panelmanager.cpp'
--- panel/app/panelmanager.cpp 2011-06-12 23:01:35 +0000
+++ panel/app/panelmanager.cpp 2011-07-27 12:33:15 +0000
@@ -24,6 +24,8 @@
2424
25// Local25// Local
26#include <config.h>26#include <config.h>
27#include <panelstyle.h>
28#include <indicatorsmanager.h>
2729
28// Applets30// Applets
29#include <appindicator/appindicatorapplet.h>31#include <appindicator/appindicatorapplet.h>
@@ -42,35 +44,37 @@
4244
43using namespace Unity2d;45using namespace Unity2d;
4446
45static QPalette getPalette()47static QWidget* createSeparator()
46{48{
47 QPalette palette;49 // Just a quick-hack: homebutton is going away anyway
4850 QWidget* widget = new QWidget;
49 /* Should use the panel's background provided by Unity but it turns51 widget->setFixedWidth(6);
50 out not to be good. It would look like:52 return widget;
5153}
52 QBrush bg(QPixmap("theme:/panel_background.png"));54
53 */55PanelManager::PanelManager(QObject* parent)
54 QBrush bg(QPixmap(unity2dDirectory() + "/panel/artwork/background.png"));56: QObject(parent)
55 palette.setBrush(QPalette::Window, bg);57, m_indicatorsManager(new IndicatorsManager(this))
56 palette.setBrush(QPalette::Button, bg);58{
57 return palette;59 QDesktopWidget* desktop = QApplication::desktop();
58}60 for(int i = 0; i < desktop->screenCount(); ++i) {
5961 Unity2dPanel* panel = instantiatePanel(i);
60static QLabel* createSeparator()62 m_panels.append(panel);
61{63 panel->show();
62 QLabel* label = new QLabel;64 panel->move(desktop->screenGeometry(i).topLeft());
63 QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png");65 }
64 label->setPixmap(pix);66 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
65 label->setFixedSize(pix.size());67}
66 return label;68
67}69PanelManager::~PanelManager()
6870{
69static Unity2dPanel* instantiatePanel(int screen)71 qDeleteAll(m_panels);
72}
73
74Unity2dPanel* PanelManager::instantiatePanel(int screen)
70{75{
71 Unity2dPanel* panel = new Unity2dPanel;76 Unity2dPanel* panel = new Unity2dPanel;
72 panel->setEdge(Unity2dPanel::TopEdge);77 panel->setEdge(Unity2dPanel::TopEdge);
73 panel->setPalette(getPalette());
74 panel->setFixedHeight(24);78 panel->setFixedHeight(24);
7579
76 int leftmost = QApplication::desktop()->screenNumber(QPoint());80 int leftmost = QApplication::desktop()->screenNumber(QPoint());
@@ -78,34 +82,16 @@
78 panel->addWidget(new HomeButtonApplet);82 panel->addWidget(new HomeButtonApplet);
79 panel->addWidget(createSeparator());83 panel->addWidget(createSeparator());
80 }84 }
81 panel->addWidget(new AppNameApplet);85 panel->addWidget(new AppNameApplet(m_indicatorsManager));
82 if (screen == leftmost) {86 if (screen == leftmost) {
83 /* It doesn’t make sense to have more than one instance of the systray,87 /* It doesn’t make sense to have more than one instance of the systray,
84 XEmbed’ed windows can be displayed only once anyway. */88 XEmbed’ed windows can be displayed only once anyway. */
85 panel->addWidget(new LegacyTrayApplet);89 panel->addWidget(new LegacyTrayApplet);
86 }90 }
87 panel->addWidget(new IndicatorApplet);91 panel->addWidget(new IndicatorApplet(m_indicatorsManager));
88 return panel;92 return panel;
89}93}
9094
91PanelManager::PanelManager(QObject* parent)
92 : QObject(parent)
93{
94 QDesktopWidget* desktop = QApplication::desktop();
95 for(int i = 0; i < desktop->screenCount(); ++i) {
96 Unity2dPanel* panel = instantiatePanel(i);
97 m_panels.append(panel);
98 panel->show();
99 panel->move(desktop->screenGeometry(i).topLeft());
100 }
101 connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
102}
103
104PanelManager::~PanelManager()
105{
106 qDeleteAll(m_panels);
107}
108
109void95void
110PanelManager::onScreenCountChanged(int newCount)96PanelManager::onScreenCountChanged(int newCount)
111{97{
11298
=== modified file 'panel/app/panelmanager.h'
--- panel/app/panelmanager.h 2011-04-04 16:41:15 +0000
+++ panel/app/panelmanager.h 2011-07-27 12:33:15 +0000
@@ -26,6 +26,7 @@
26#include <QObject>26#include <QObject>
27#include <QList>27#include <QList>
2828
29class IndicatorsManager;
29class Unity2dPanel;30class Unity2dPanel;
3031
31class PanelManager : public QObject32class PanelManager : public QObject
@@ -38,8 +39,11 @@
3839
39private:40private:
40 Q_DISABLE_COPY(PanelManager)41 Q_DISABLE_COPY(PanelManager)
42 IndicatorsManager* m_indicatorsManager;
41 QList<Unity2dPanel*> m_panels;43 QList<Unity2dPanel*> m_panels;
4244
45 Unity2dPanel* instantiatePanel(int screen);
46
43private Q_SLOTS:47private Q_SLOTS:
44 void onScreenCountChanged(int newCount);48 void onScreenCountChanged(int newCount);
45};49};
4650
=== modified file 'panel/applets/CMakeLists.txt'
--- panel/applets/CMakeLists.txt 2011-07-27 12:33:12 +0000
+++ panel/applets/CMakeLists.txt 2011-07-27 12:33:15 +0000
@@ -1,29 +1,11 @@
1project(uqapplets)1project(uqapplets)
22
3macro(read_pkg_variable cmake_var pkg pkg_var)
4 execute_process(
5 COMMAND pkg-config --variable=${pkg_var} ${pkg}
6 OUTPUT_VARIABLE tmp
7 )
8 # Remove trailing newline from ${tmp}
9 string(STRIP "${tmp}" ${cmake_var})
10endmacro(read_pkg_variable)
11
12# Dependencies3# Dependencies
13include(FindPkgConfig)4include(FindPkgConfig)
145
15pkg_check_modules(QTBAMF REQUIRED libqtbamf)6pkg_check_modules(QTBAMF REQUIRED libqtbamf)
16pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)7pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt)
17<<<<<<< TREE8pkg_check_modules(PANGO REQUIRED pango)
18pkg_check_modules(INDICATOR REQUIRED indicator)
19=======
20pkg_check_modules(INDICATOR REQUIRED indicator3-0.4)
21>>>>>>> MERGE-SOURCE
22
23# Get indicator dirs from pkgconfig
24read_pkg_variable(INDICATOR_DIR indicator3 indicatordir)
25read_pkg_variable(INDICATOR_ICONS_DIR indicator3 iconsdir)
26configure_file(indicator-config.h.in indicator-config.h)
279
28# Sources10# Sources
29set(uqapplets_SRCS11set(uqapplets_SRCS
@@ -31,13 +13,15 @@
31 appindicator/sniitem.cpp13 appindicator/sniitem.cpp
32 appname/appnameapplet.cpp14 appname/appnameapplet.cpp
33 appname/menubarwidget.cpp15 appname/menubarwidget.cpp
34 appname/registrar.cpp
35 appname/windowhelper.cpp16 appname/windowhelper.cpp
36 common/applet.cpp17 common/applet.cpp
18 common/indicatorentrywidget.cpp
19 common/indicatorsmanager.cpp
20 common/indicatorwidget.cpp
21 common/panelstyle.cpp
37 homebutton/homebuttonapplet.cpp22 homebutton/homebuttonapplet.cpp
38 homebutton/homebutton.cpp23 homebutton/homebutton.cpp
39 indicator/indicatorapplet.cpp24 indicator/indicatorapplet.cpp
40 indicator/indicator.c
41 legacytray/legacytrayapplet.cpp25 legacytray/legacytrayapplet.cpp
42 legacytray/fdoselectionmanager.cpp26 legacytray/fdoselectionmanager.cpp
43 legacytray/fdotask.cpp27 legacytray/fdotask.cpp
@@ -46,10 +30,6 @@
46 legacytray/x11embedpainter.cpp30 legacytray/x11embedpainter.cpp
47 )31 )
4832
49qt4_add_dbus_adaptor(uqapplets_SRCS appname/com.canonical.AppMenu.Registrar.xml
50 registrar.h Registrar
51 )
52
53qt4_automoc(${uqapplets_SRCS})33qt4_automoc(${uqapplets_SRCS})
5434
55# Build35# Build
@@ -59,13 +39,15 @@
59 ${CMAKE_CURRENT_SOURCE_DIR}/common39 ${CMAKE_CURRENT_SOURCE_DIR}/common
60 ${CMAKE_CURRENT_SOURCE_DIR}/homebutton40 ${CMAKE_CURRENT_SOURCE_DIR}/homebutton
61 ${CMAKE_CURRENT_SOURCE_DIR}/indicator41 ${CMAKE_CURRENT_SOURCE_DIR}/indicator
42 ${CMAKE_CURRENT_SOURCE_DIR}/unitycore
62 ${QTBAMF_INCLUDE_DIRS}43 ${QTBAMF_INCLUDE_DIRS}
63 ${DBUSMENUQT_INCLUDE_DIRS}44 ${DBUSMENUQT_INCLUDE_DIRS}
64 ${GTK_INCLUDE_DIRS}45 ${GTK_INCLUDE_DIRS}
65 ${INDICATOR_INCLUDE_DIRS}
66 ${WNCK_INCLUDE_DIRS}46 ${WNCK_INCLUDE_DIRS}
67 ${CMAKE_CURRENT_BINARY_DIR}47 ${CMAKE_CURRENT_BINARY_DIR}
68 ${X11_INCLUDE_DIR}48 ${X11_INCLUDE_DIR}
49 ${UNITYCORE_INCLUDE_DIRS}
50 ${PANGO_INCLUDE_DIRS}
69 ${libunity-2d-private_SOURCE_DIR}/src51 ${libunity-2d-private_SOURCE_DIR}/src
70 )52 )
7153
@@ -77,12 +59,13 @@
77 ${DBUSMENUQT_LDFLAGS}59 ${DBUSMENUQT_LDFLAGS}
78 ${QTBAMF_LDFLAGS}60 ${QTBAMF_LDFLAGS}
79 ${GTK_LDFLAGS}61 ${GTK_LDFLAGS}
80 ${INDICATOR_LDFLAGS}
81 ${WNCK_LDFLAGS}62 ${WNCK_LDFLAGS}
82 ${X11_LIBRARIES}63 ${X11_LIBRARIES}
83 ${X11_Xrender_LIB}64 ${X11_Xrender_LIB}
84 ${X11_Xcomposite_LIB}65 ${X11_Xcomposite_LIB}
85 ${X11_Xdamage_LIB}66 ${X11_Xdamage_LIB}
86 ${X11_Xfixes_LIB}67 ${X11_Xfixes_LIB}
68 ${UNITYCORE_LDFLAGS}
69 ${PANGO_LDFLAGS}
87 unity-2d-private70 unity-2d-private
88 )71 )
8972
=== modified file 'panel/applets/appname/appnameapplet.cpp'
--- panel/applets/appname/appnameapplet.cpp 2011-07-27 12:33:12 +0000
+++ panel/applets/appname/appnameapplet.cpp 2011-07-27 12:33:15 +0000
@@ -200,10 +200,10 @@
200 q, SLOT(updateWidgets()));200 q, SLOT(updateWidgets()));
201 }201 }
202202
203 void setupMenuBarWidget()203 void setupMenuBarWidget(IndicatorsManager* manager)
204 {204 {
205 m_menuBarWidget = new MenuBarWidget(0 /* Window menu */);205 m_menuBarWidget = new MenuBarWidget(manager);
206 QObject::connect(m_menuBarWidget, SIGNAL(menuBarChanged()),206 QObject::connect(m_menuBarWidget, SIGNAL(isOpenedChanged()),
207 q, SLOT(updateWidgets()));207 q, SLOT(updateWidgets()));
208 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),208 QObject::connect(m_menuBarWidget, SIGNAL(isEmptyChanged()),
209 q, SLOT(updateWidgets()));209 q, SLOT(updateWidgets()));
@@ -216,21 +216,16 @@
216 }216 }
217};217};
218218
219AppNameApplet::AppNameApplet()219AppNameApplet::AppNameApplet(IndicatorsManager* indicatorsManager)
220: d(new AppNameAppletPrivate)220: d(new AppNameAppletPrivate)
221{221{
222 d->q = this;222 d->q = this;
223 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);223 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum);
224224
225 QPalette palette;
226 palette.setColor(QPalette::WindowText, Qt::white);
227 palette.setColor(QPalette::ButtonText, Qt::white);
228 setPalette(palette);
229
230 d->setupWindowHelper();225 d->setupWindowHelper();
231 d->setupLabel();226 d->setupLabel();
232 d->setupWindowButtonWidget();227 d->setupWindowButtonWidget();
233 d->setupMenuBarWidget();228 d->setupMenuBarWidget(indicatorsManager);
234 d->setupKeyboardModifiersMonitor();229 d->setupKeyboardModifiersMonitor();
235230
236 QHBoxLayout* layout = new QHBoxLayout(this);231 QHBoxLayout* layout = new QHBoxLayout(this);
237232
=== modified file 'panel/applets/appname/appnameapplet.h'
--- panel/applets/appname/appnameapplet.h 2011-06-06 09:06:55 +0000
+++ panel/applets/appname/appnameapplet.h 2011-07-27 12:33:15 +0000
@@ -29,6 +29,8 @@
2929
30class QEvent;30class QEvent;
3131
32class IndicatorsManager;
33
32namespace Unity2d34namespace Unity2d
33{35{
3436
@@ -37,7 +39,7 @@
37{39{
38Q_OBJECT40Q_OBJECT
39public:41public:
40 AppNameApplet();42 AppNameApplet(IndicatorsManager*);
41 ~AppNameApplet();43 ~AppNameApplet();
4244
43protected:45protected:
4446
=== removed file 'panel/applets/appname/com.canonical.AppMenu.Registrar.xml'
--- panel/applets/appname/com.canonical.AppMenu.Registrar.xml 2011-02-10 01:10:19 +0000
+++ panel/applets/appname/com.canonical.AppMenu.Registrar.xml 1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
3 <dox:d><![CDATA[
4 @mainpage
5  
6 An interface to register menus that are associated with a window in an application.  The
7 main interface is docuemented here: @ref com::canonical::AppMenu::Registrar.
8     
9 The actual menus are transported using the dbusmenu protocol which is available
10 here: @ref com::canonical::dbusmenu.
11 ]]></dox:d>
12 <interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
13 <dox:d>
14 An interface to register a menu from an application's window to be displayed in another
15 window.  This manages that association between XWindow Window IDs and the dbus
16 address and object that provides the menu using the dbusmenu dbus interface.
17 </dox:d>
18 <method name="RegisterWindow">
19 <dox:d><![CDATA[
20 Associates a dbusmenu with a window
21      
22 /note this method assumes that the connection from the caller is the DBus connection
23 to use for the object.  Applications that use multiple DBus connections will need to
24 ensure this method is called with the same connection that implmenets the object.
25 ]]></dox:d>
26 <arg name="windowId" type="u" direction="in">
27 <dox:d>The XWindow ID of the window</dox:d>
28 </arg>
29 <arg name="menuObjectPath" type="o" direction="in">
30 <dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d>
31 </arg>
32 </method>
33 <method name="UnregisterWindow">
34 <dox:d>
35 A method to allow removing a window from the database. Windows will also be removed
36 when the client drops off DBus so this is not required. It is polite though. And
37 important for testing.
38 </dox:d>
39 <arg name="windowId" type="u" direction="in">
40 <dox:d>The XWindow ID of the window</dox:d>
41 </arg>
42 </method>
43 <method name="GetMenuForWindow">
44 <dox:d>Gets the registered menu for a given window ID.</dox:d>
45 <arg name="windowId" type="u" direction="in">
46 <dox:d>The XWindow ID of the window to get</dox:d>
47 </arg>
48 <arg name="service" type="s" direction="out">
49 <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
50 </arg>
51 <arg name="menuObjectPath" type="o" direction="out">
52 <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
53 </arg>
54 </method>
55 <method name="GetMenus">
56 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MenuInfoList"/>
57 <dox:d>Gets the information on all menus that the registrar knows about. This
58 is useful for debugging or bringing up a new renderer.</dox:d>
59 <arg name="menus" type="a(uso)" direction="out">
60 <dox:d>An array of structures containing the same parameters as @GetMenuForWindow. Window ID, Service and ObjectPath.</dox:d>
61 </arg>
62 </method>
63 <signal name="WindowRegistered">
64 <dox:d>Signals when the registrar gets a new menu registered</dox:d>
65 <arg name="windowId" type="u" direction="out">
66 <dox:d>The XWindow ID of the window</dox:d>
67 </arg>
68 <arg name="service" type="s" direction="out">
69 <dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
70 </arg>
71 <arg name="menuObjectPath" type="o" direction="out">
72 <dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
73 </arg>
74 </signal>
75 <signal name="WindowUnregistered">
76 <dox:d>Signals when the registrar removes a menu registration</dox:d>
77 <arg name="windowId" type="u" direction="out">
78 <dox:d>The XWindow ID of the window</dox:d>
79 </arg>
80 </signal>
81 </interface>
82</node>
830
=== modified file 'panel/applets/appname/menubarwidget.cpp'
--- panel/applets/appname/menubarwidget.cpp 2011-07-27 12:33:12 +0000
+++ panel/applets/appname/menubarwidget.cpp 2011-07-27 12:33:15 +0000
@@ -20,312 +20,98 @@
20 */20 */
2121
22// Self22// Self
23#include "menubarwidget.h"23#include <menubarwidget.h>
2424
25// Local25// Local
26#include "config.h"26#include <debug_p.h>
27#include "debug_p.h"27#include <indicatorentrywidget.h>
28#include "keyboardmodifiersmonitor.h"28#include <indicatorsmanager.h>
29#include "registrar.h"
30
31// dbusmenu-qt
32#include <dbusmenuimporter.h>
33
34// bamf
35#include <bamf-matcher.h>
36#include <bamf-window.h>
3729
38// Qt30// Qt
39#include <QActionEvent>
40#include <QHBoxLayout>31#include <QHBoxLayout>
41#include <QLabel>32
42#include <QMenuBar>33static const int MENU_ITEM_PADDING = 6;
43#include <QTimer>34
4435MenuBarWidget::MenuBarWidget(IndicatorsManager* indicatorsManager, QWidget* parent)
45class MyDBusMenuImporter : public DBusMenuImporter
46{
47public:
48 MyDBusMenuImporter(const QString &service, const QString &path, QObject *parent)
49 : DBusMenuImporter(service, path, parent)
50 , m_service(service)
51 , m_path(path)
52 {}
53
54 QString service() const { return m_service; }
55 QString path() const { return m_path; }
56
57private:
58 QString m_service;
59 QString m_path;
60};
61
62MenuBarWidget::MenuBarWidget(QMenu* windowMenu, QWidget* parent)
63: QWidget(parent)36: QWidget(parent)
64, m_windowMenu(windowMenu)37, m_indicatorsManager(indicatorsManager)
65, m_isMenuOpen(false)38, m_layout(new QHBoxLayout(this))
66{39, m_isEmpty(true)
67 m_activeWinId = 0;40, m_isOpened(false)
68 setupRegistrar();41{
69 setupMenuBar();42 m_layout->setMargin(0);
7043 m_layout->setSpacing(0);
71 connect(&BamfMatcher::get_default(), SIGNAL(ActiveWindowChanged(BamfWindow*, BamfWindow*)),44 indicatorsManager->indicators()->on_object_added.connect(
72 SLOT(slotActiveWindowChanged(BamfWindow*, BamfWindow*)));45 sigc::mem_fun(this, &MenuBarWidget::onObjectAdded)
73 /* Work around a bug in BAMF: the ActiveWindowChanged signal is not emitted46 );
74 for some windows that open maximized. This is for example the case of the47 indicatorsManager->indicators()->on_entry_activated.connect(
75 LibreOffice startcenter. */48 sigc::mem_fun(this, &MenuBarWidget::onEntryActivated)
76 connect(&BamfMatcher::get_default(), SIGNAL(ViewOpened(BamfView*)),49 );
77 SLOT(slotViewOpened()));50 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
78 updateActiveWinId(BamfMatcher::get_default().active_window());51 m_layout->addStretch();
79}
80
81void MenuBarWidget::setupRegistrar()
82{
83 m_registrar = Registrar::instance();
84 if (!m_registrar->connectToBus()) {
85 UQ_WARNING << "could not connect registrar to DBus";
86 }
87
88 connect(m_registrar, SIGNAL(WindowRegistered(WId, const QString&, const QDBusObjectPath&)),
89 SLOT(slotWindowRegistered(WId, const QString&, const QDBusObjectPath&)));
90 connect(m_registrar, SIGNAL(WindowUnregistered(WId)),
91 SLOT(slotWindowUnregistered(WId)));
92}
93
94void MenuBarWidget::setupMenuBar()
95{
96 m_menuBar = new QMenuBar;
97 m_menuBarMonitor = new MenuBarClosedHelper(this);
98
99 QHBoxLayout* layout = new QHBoxLayout(this);
100 layout->setMargin(0);
101 layout->setSpacing(0);
102 layout->addWidget(m_menuBar);
103 m_menuBar->setNativeMenuBar(false);
104
105 m_updateMenuBarTimer = new QTimer(this);
106 m_updateMenuBarTimer->setSingleShot(true);
107 m_updateMenuBarTimer->setInterval(0);
108 connect(m_updateMenuBarTimer, SIGNAL(timeout()),
109 SLOT(updateMenuBar()));
110
111 // Repaint the menubar when modifiers change so that the shortcut underline
112 // is drawn or not
113 connect(KeyboardModifiersMonitor::instance(), SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)),
114 m_menuBar, SLOT(update()));
115
116 // Watch when the menubar's menus close so that it can be hidden
117 connect(m_menuBarMonitor, SIGNAL(menuBarClosed()), SLOT(slotMenuBarClosed()));
118}
119
120void MenuBarWidget::slotActiveWindowChanged(BamfWindow* /*former*/, BamfWindow* current)
121{
122 if (current) {
123 updateActiveWinId(current);
124 }
125}
126
127void MenuBarWidget::slotViewOpened()
128{
129 BamfWindow* active = BamfMatcher::get_default().active_window();
130 if (active != NULL) {
131 if (active->xid() != m_activeWinId) {
132 /* This shouldn’t be needed as BAMF should have emitted the
133 ActiveWindowChanged signal, but it sometimes doesn’t (e.g. when
134 LibreOffice startcenter starts automatically maximized). */
135 updateActiveWinId(active);
136 }
137 }
138}
139
140void MenuBarWidget::slotWindowRegistered(WId wid, const QString& service, const QDBusObjectPath& menuObjectPath)
141{
142 MyDBusMenuImporter* importer = new MyDBusMenuImporter(service, menuObjectPath.path(), this);
143 delete m_importers.take(wid);
144 m_importers.insert(wid, importer);
145 connect(importer, SIGNAL(menuUpdated()), SLOT(slotMenuUpdated()));
146 connect(importer, SIGNAL(actionActivationRequested(QAction*)), SLOT(slotActionActivationRequested(QAction*)));
147 QMetaObject::invokeMethod(importer, "updateMenu", Qt::QueuedConnection);
148}
149
150void MenuBarWidget::slotWindowUnregistered(WId wid)
151{
152 MyDBusMenuImporter* importer = m_importers.take(wid);
153 if (importer) {
154 importer->deleteLater();
155 }
156 if (wid == m_activeWinId) {
157 m_activeWinId = 0;
158 updateMenuBar();
159 }
160}
161
162void MenuBarWidget::slotMenuUpdated()
163{
164 DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
165
166 if (m_importers.value(m_activeWinId) == importer) {
167 updateMenuBar();
168 }
169}
170
171void MenuBarWidget::slotActionActivationRequested(QAction* action)
172{
173 DBusMenuImporter* importer = static_cast<DBusMenuImporter*>(sender());
174
175 if (m_importers.value(m_activeWinId) == importer) {
176 m_isMenuOpen = true;
177 Q_EMIT menuBarChanged();
178 m_menuBar->setActiveAction(action);
179 }
180}
181
182void MenuBarWidget::slotMenuBarClosed()
183{
184 m_isMenuOpen = false;
185 Q_EMIT menuBarChanged();
186}
187
188QMenu* MenuBarWidget::menuForWinId(WId wid) const
189{
190 MyDBusMenuImporter* importer = m_importers.value(wid);
191 return importer ? importer->menu() : 0;
192}
193
194void MenuBarWidget::updateActiveWinId(BamfWindow* bamfWindow)
195{
196 WId id = bamfWindow ? bamfWindow->xid() : 0;
197 if (id == m_activeWinId) {
198 return;
199 }
200 if (id == window()->winId()) {
201 // Do not update id if the active window is the one hosting this applet
202 return;
203 }
204 m_activeWinId = id;
205 updateMenuBar();
206}
207
208void MenuBarWidget::updateMenuBar()
209{
210 WId winId = m_activeWinId;
211 QMenu* menu = menuForWinId(winId);
212
213 if (!menu) {
214 if (winId) {
215 menu = m_windowMenu;
216 } else {
217 // No active window, show a desktop menubar
218 // FIXME: Empty menu
219 /*
220 menu = mEmptyMenu;
221 */
222 }
223 }
224
225 m_menuBar->clear();
226 // FIXME: Empty menu
227 if (!menu) {
228 return;
229 }
230 menu->installEventFilter(this);
231 Q_FOREACH(QAction* action, menu->actions()) {
232 if (action->isSeparator()) {
233 continue;
234 }
235 m_menuBar->addAction(action);
236 }
237}
238
239bool MenuBarWidget::eventFilter(QObject* object, QEvent* event)
240{
241 switch (event->type()) {
242 case QEvent::ActionAdded:
243 case QEvent::ActionRemoved:
244 case QEvent::ActionChanged:
245 m_updateMenuBarTimer->start();
246 break;
247 default:
248 break;
249 }
250 return false;
251}52}
25253
253bool MenuBarWidget::isEmpty() const54bool MenuBarWidget::isEmpty() const
254{55{
255 return m_menuBar->actions().isEmpty();56 return m_isEmpty;
256}57}
25758
258bool MenuBarWidget::isOpened() const59bool MenuBarWidget::isOpened() const
259{60{
260 return m_isMenuOpen;61 return m_isOpened;
261}62}
26263
263// MenuBarClosedHelper ----------------------------------------64void MenuBarWidget::onObjectAdded(const unity::indicator::Indicator::Ptr& indicator)
264MenuBarClosedHelper::MenuBarClosedHelper(MenuBarWidget* widget)65{
265: QObject(widget)66 QString name = QString::fromStdString(indicator->name());
266, m_widget(widget)67 if (name == "libappmenu.so") {
267{68 indicator->on_entry_added.connect(sigc::mem_fun(this, &MenuBarWidget::onEntryAdded));
268 widget->m_menuBar->installEventFilter(this);69 }
269}70}
27071
271bool MenuBarClosedHelper::eventFilter(QObject* object, QEvent* event)72void MenuBarWidget::onEntryAdded(const unity::indicator::Entry::Ptr& entry)
272{73{
273 if (object == m_widget->m_menuBar) {74 IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
274 switch (event->type()) {75 widget->setPadding(MENU_ITEM_PADDING);
275 case QEvent::ActionAdded:76 connect(widget, SIGNAL(isEmptyChanged()), SLOT(updateIsEmpty()));
276 case QEvent::ActionRemoved:77
277 case QEvent::ActionChanged:78 m_widgetList.append(widget);
278 menuBarActionEvent(static_cast<QActionEvent*>(event));79 m_indicatorsManager->addIndicatorEntryWidget(widget);
279 break;80
280 default:81 // Insert *before* stretch
281 break;82 m_layout->insertWidget(m_layout->count() - 1, widget);
282 }83}
283 } else {84
284 // Top-level menus85void MenuBarWidget::updateIsEmpty()
285 if (event->type() == QEvent::Hide) {86{
286 // menu hide themselves when the menubar is closed but also when87 bool empty = true;
287 // one goes from one menu to another. The way to know this is to88 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
288 // check the value of QMenuBar::activeAction(), but at this point89 if (!widget->isEmpty()) {
289 // it has not been updated yet, so we check in a delayed method.90 empty = false;
290 QMetaObject::invokeMethod(this, "emitMenuBarClosed", Qt::QueuedConnection);91 break;
291 }92 }
292 }93 }
293 return false;94 if (m_isEmpty != empty) {
294}95 m_isEmpty = empty;
29596 isEmptyChanged();
296void MenuBarClosedHelper::emitMenuBarClosed()97 }
297{98}
298 //If there is still no menu action active, then menu must be closed.99
299 if (!m_widget->m_menuBar->activeAction()) {100void MenuBarWidget::onEntryActivated(const std::string& id)
300 Q_EMIT menuBarClosed();101{
301 }102 bool isOpened = false;
302}103 if (!id.empty()) {
303104 // We only cares about menubar entries
304void MenuBarClosedHelper::menuBarActionEvent(QActionEvent* event)105 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
305{106 if (widget->entry()->id() == id) {
306 QMenu* menu = event->action()->menu();107 isOpened = true;
307 if (menu) {108 break;
308 // Install/remove event filters on top level menus so that know when109 }
309 // they hide themselves and can emit menuBarClosed()110 }
310 switch (event->type()) {111 }
311 case QEvent::ActionAdded:112 if (m_isOpened != isOpened) {
312 case QEvent::ActionChanged:113 m_isOpened = isOpened;
313 menu->installEventFilter(this);114 isOpenedChanged();
314 break;
315 case QEvent::ActionRemoved:
316 menu->removeEventFilter(this);
317 break;
318 default:
319 break;
320 }
321 }
322
323 // Emit isEmptyChanged() if necessary
324 QList<QAction*> actions = m_widget->m_menuBar->actions();
325 if (event->type() == QEvent::ActionAdded && actions.count() == 1) {
326 QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
327 } else if (event->type() == QEvent::ActionRemoved && actions.isEmpty()) {
328 QMetaObject::invokeMethod(m_widget, "isEmptyChanged");
329 }115 }
330}116}
331117
332118
=== modified file 'panel/applets/appname/menubarwidget.h'
--- panel/applets/appname/menubarwidget.h 2011-07-27 12:33:12 +0000
+++ panel/applets/appname/menubarwidget.h 2011-07-27 12:33:15 +0000
@@ -23,92 +23,45 @@
23#define MENUBARWIDGET_H23#define MENUBARWIDGET_H
2424
25// Qt25// Qt
26#include <QHash>
27#include <QWidget>26#include <QWidget>
2827
29class BamfWindow;28// libunity-core
3029#include <UnityCore/Indicator.h>
31class QActionEvent;30#include <UnityCore/IndicatorEntry.h>
32class QDBusObjectPath;31
33class QMenu;32class QHBoxLayout;
34class QMenuBar;33
35class QTimer;34class IndicatorEntryWidget;
3635class IndicatorsManager;
37class MyDBusMenuImporter;36
38class Registrar;37class MenuBarWidget : public QWidget, public sigc::trackable
3938{
40typedef QHash<WId, MyDBusMenuImporter*> ImporterForWId;39Q_OBJECT
4140public:
42class MenuBarWidget;41 MenuBarWidget(IndicatorsManager*, QWidget* parent = 0);
43
44/**
45 * An helper class which monitors the menubar and emits MenuBarWidget::menuBarClosed()
46 * to indicate if the menu was closed or updated.
47 */
48class MenuBarClosedHelper : public QObject
49{
50Q_OBJECT
51public:
52 MenuBarClosedHelper(MenuBarWidget*);
53
54Q_SIGNALS:
55 void menuBarClosed();
56
57protected:
58 bool eventFilter(QObject*, QEvent*); //reimp
59
60private Q_SLOTS:
61 void emitMenuBarClosed();
62
63private:
64 MenuBarWidget* m_widget;
65 void menuBarActionEvent(QActionEvent*);
66};
67
68class MenuBarWidget : public QWidget
69{
70Q_OBJECT
71public:
72 MenuBarWidget(QMenu* windowMenu, QWidget* parent = 0);
7342
74 bool isEmpty() const;43 bool isEmpty() const;
75 bool isOpened() const;44 bool isOpened() const;
7645
77Q_SIGNALS:46Q_SIGNALS:
78 void menuBarChanged();47 void isOpenedChanged();
79 void isEmptyChanged();48 void isEmptyChanged();
8049
81protected:
82 bool eventFilter(QObject*, QEvent*); // reimp
83
84private Q_SLOTS:50private Q_SLOTS:
85 void slotActiveWindowChanged(BamfWindow*, BamfWindow*);51 void updateIsEmpty();
86 void slotViewOpened();
87 void slotWindowRegistered(WId, const QString& service, const QDBusObjectPath& menuObjectPath);
88 void slotWindowUnregistered(WId);
89 void slotMenuUpdated();
90 void slotActionActivationRequested(QAction* action);
91 void slotMenuBarClosed();
92 void updateMenuBar();
9352
94private:53private:
95 Q_DISABLE_COPY(MenuBarWidget)54 Q_DISABLE_COPY(MenuBarWidget)
9655
97 QMenuBar* m_menuBar;56 IndicatorsManager* m_indicatorsManager;
98 MenuBarClosedHelper* m_menuBarMonitor;57 QHBoxLayout* m_layout;
99 Registrar* m_registrar;58 bool m_isEmpty;
100 ImporterForWId m_importers;59 bool m_isOpened;
101 WId m_activeWinId;60 QList<IndicatorEntryWidget*> m_widgetList;
102 QMenu* m_windowMenu;61
103 QTimer* m_updateMenuBarTimer;62 void onObjectAdded(const unity::indicator::Indicator::Ptr&);
104 bool m_isMenuOpen;63 void onEntryAdded(const unity::indicator::Entry::Ptr&);
10564 void onEntryActivated(const std::string&);
106 void setupRegistrar();
107 void setupMenuBar();
108 QMenu* menuForWinId(WId) const;
109 void updateActiveWinId(BamfWindow*);
110
111 friend class MenuBarClosedHelper;
112};65};
11366
114#endif /* MENUBARWIDGET_H */67#endif /* MENUBARWIDGET_H */
11568
=== removed file 'panel/applets/appname/registrar.cpp'
--- panel/applets/appname/registrar.cpp 2011-04-04 16:46:14 +0000
+++ panel/applets/appname/registrar.cpp 1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@
1/*
2 * Plasma applet to display application window menus
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "registrar.h"
24
25// Qt
26#include <QApplication>
27#include <QDBusMessage>
28#include <QDBusObjectPath>
29#include <QDBusServiceWatcher>
30
31// Local
32#include "registraradaptor.h"
33
34static const char* DBUS_SERVICE = "com.canonical.AppMenu.Registrar";
35static const char* DBUS_OBJECT_PATH = "/com/canonical/AppMenu/Registrar";
36
37// Marshalling code for MenuInfo
38QDBusArgument& operator<<(QDBusArgument& argument, const MenuInfo& info)
39{
40 argument.beginStructure();
41 argument << info.winId << info.service << info.path;
42 argument.endStructure();
43 return argument;
44}
45
46const QDBusArgument& operator>>(const QDBusArgument& argument, MenuInfo& info)
47{
48 argument.beginStructure();
49 argument >> info.winId >> info.service >> info.path;
50 argument.endStructure();
51 return argument;
52}
53
54Registrar::Registrar()
55: QObject()
56, mServiceWatcher(new QDBusServiceWatcher(this))
57{
58 qDBusRegisterMetaType<MenuInfo>();
59 qDBusRegisterMetaType<MenuInfoList>();
60 mServiceWatcher->setConnection(QDBusConnection::sessionBus());
61 mServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
62 connect(mServiceWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
63}
64
65Registrar::~Registrar()
66{
67 QDBusConnection::sessionBus().unregisterService(mService);
68}
69
70Registrar* Registrar::instance()
71{
72 static Registrar singleton;
73 return &singleton;
74}
75
76bool Registrar::connectToBus(const QString& _service, const QString& _path)
77{
78 mService = _service.isEmpty() ? DBUS_SERVICE : _service;
79 QString path = _path.isEmpty() ? DBUS_OBJECT_PATH : _path;
80
81 bool ok = QDBusConnection::sessionBus().registerService(mService);
82 if (!ok) {
83 return false;
84 }
85 new RegistrarAdaptor(this);
86 QDBusConnection::sessionBus().registerObject(path, this);
87
88 return true;
89}
90
91void Registrar::RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath)
92{
93 MenuInfo info;
94 info.winId = wid;
95 info.service = message().service();
96 info.path = menuObjectPath;
97 mDb.insert(wid, info);
98 mServiceWatcher->addWatchedService(info.service);
99 WindowRegistered(wid, info.service, info.path);
100}
101
102void Registrar::UnregisterWindow(WId wid)
103{
104 mDb.remove(wid);
105 WindowUnregistered(wid);
106}
107
108QString Registrar::GetMenuForWindow(WId winId, QDBusObjectPath& menuObjectPath)
109{
110 MenuInfo info = mDb.value(winId);
111 QString service = info.service;
112 menuObjectPath = info.path;
113 return service;
114}
115
116MenuInfoList Registrar::GetMenus()
117{
118 return mDb.values();
119}
120
121void Registrar::slotServiceUnregistered(const QString& service)
122{
123 MenuInfoDb::Iterator
124 it = mDb.begin(),
125 end = mDb.end();
126 for (;it != end;) {
127 if (it.value().service == service) {
128 WId id = it.key();
129 it = mDb.erase(it);
130 WindowUnregistered(id);
131 } else {
132 ++it;
133 }
134 }
135 mServiceWatcher->removeWatchedService(service);
136}
137
138#include "registrar.moc"
1390
=== removed file 'panel/applets/appname/registrar.h'
--- panel/applets/appname/registrar.h 2011-04-04 16:47:28 +0000
+++ panel/applets/appname/registrar.h 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
1/*
2 * Plasma applet to display application window menus
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef REGISTRAR_H
23#define REGISTRAR_H
24
25// Qt
26#include <QDBusContext>
27#include <QDBusObjectPath>
28#include <QObject>
29#include <QWidget> // For WId
30
31class QDBusObjectPath;
32class QDBusServiceWatcher;
33class QMenu;
34
35struct MenuInfo
36{
37 MenuInfo()
38 : winId(0)
39 , path("/")
40 {}
41
42 uint winId;
43 QString service;
44 QDBusObjectPath path;
45};
46Q_DECLARE_METATYPE(MenuInfo)
47
48typedef QList<MenuInfo> MenuInfoList;
49Q_DECLARE_METATYPE(MenuInfoList)
50
51class Registrar : public QObject, protected QDBusContext
52{
53 Q_OBJECT
54
55public:
56 /* The registrar is a singleton shared between all instances of MenuBarWidget. */
57 static Registrar* instance();
58
59 bool connectToBus(const QString& service = QString(), const QString& objectPath = QString());
60
61Q_SIGNALS:
62 void WindowRegistered(WId wid, const QString& service, const QDBusObjectPath&);
63 void WindowUnregistered(WId wid);
64
65public Q_SLOTS:
66 Q_NOREPLY void RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath);
67 Q_NOREPLY void UnregisterWindow(WId wid);
68 QString GetMenuForWindow(WId wid, QDBusObjectPath& menuObjectPath);
69 MenuInfoList GetMenus();
70
71private Q_SLOTS:
72 void slotServiceUnregistered(const QString& service);
73
74private:
75 Registrar();
76 Q_DISABLE_COPY(Registrar)
77 ~Registrar();
78
79 QDBusServiceWatcher* mServiceWatcher;
80 typedef QHash<WId, MenuInfo> MenuInfoDb;
81 MenuInfoDb mDb;
82 QString mService;
83};
84
85#endif /* REGISTRAR_H */
860
=== added file 'panel/applets/common/fakecairo.h'
--- panel/applets/common/fakecairo.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/fakecairo.h 2011-07-27 12:33:15 +0000
@@ -0,0 +1,125 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef FAKECAIRO_H
22#define FAKECAIRO_H
23
24// NuxCore
25#include <NuxCore/Color.h>
26
27// Qt
28#include <QPainter>
29#include <QPainterPath>
30
31/*
32 * This module attempts to fake Cairo calls using QPainter, making it easier to
33 * port Cairo paint operations to Qt
34 */
35struct fcairo_t
36{
37 fcairo_t(QPainter* _painter)
38 : painter(_painter)
39 {
40 painter->save();
41 }
42
43 ~fcairo_t()
44 {
45 painter->restore();
46 }
47
48 QPainter* painter;
49 QPainterPath path;
50};
51
52inline void fcairo_arc(fcairo_t& cr, qreal xc, qreal yc, qreal radius, qreal angle1, qreal angle2)
53{
54 QRectF rect(xc - radius, yc - radius, radius * 2, radius * 2);
55
56 while (angle2 < angle1) {
57 angle2 += 2 * M_PI;
58 }
59
60 qreal start = (2. - angle1 / M_PI) * 180;
61 qreal stop = (2. - angle2 / M_PI) * 180;
62 cr.path.arcTo(rect, start, stop - start);
63}
64
65inline void fcairo_move_to(fcairo_t& cr, qreal x, qreal y)
66{
67 cr.path.moveTo(x, y);
68}
69
70inline void fcairo_line_to(fcairo_t& cr, qreal x, qreal y)
71{
72 cr.path.lineTo(x, y);
73}
74
75inline void fcairo_fill_preserve(fcairo_t& cr)
76{
77 cr.painter->fillPath(cr.path, cr.painter->brush());
78}
79
80inline void fcairo_stroke(fcairo_t& cr)
81{
82 QPen pen(cr.painter->brush().color(), 1);
83 cr.painter->strokePath(cr.path, pen);
84 cr.path = QPainterPath();
85}
86
87typedef QGradient fcairo_pattern_t;
88
89inline fcairo_pattern_t* fcairo_pattern_create_linear (qreal x1, qreal y1, qreal x2, qreal y2)
90{
91 return new QLinearGradient(x1, y1, x2, y2);
92}
93
94inline void fcairo_pattern_destroy(fcairo_pattern_t* pattern)
95{
96 delete pattern;
97}
98
99inline void fcairo_pattern_add_color_stop_rgba(fcairo_pattern_t* pattern, qreal offset, qreal r, qreal g, qreal b, qreal a)
100{
101 pattern->setColorAt(offset, QColor::fromRgbF(r, g, b, a));
102}
103
104inline void fcairo_set_source(fcairo_t& cr, fcairo_pattern_t* pattern)
105{
106 cr.painter->setPen(Qt::NoPen);
107 cr.painter->setBrush(*pattern);
108}
109
110inline void fcairo_set_source_rgb(fcairo_t& cr, qreal r, qreal g, qreal b)
111{
112 cr.painter->setBrush(QColor::fromRgbF(r, g, b));
113}
114
115inline nux::color::Color nuxColorFromQColor(const QColor& qColor)
116{
117 nux::color::Color color;
118 color.red = qColor.redF();
119 color.green = qColor.greenF();
120 color.blue = qColor.blueF();
121 color.alpha = qColor.alphaF();
122 return color;
123}
124
125#endif /* FAKECAIRO_H */
0126
=== added file 'panel/applets/common/indicatorentrywidget.cpp'
--- panel/applets/common/indicatorentrywidget.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorentrywidget.cpp 2011-07-27 12:33:15 +0000
@@ -0,0 +1,388 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorentrywidget.h"
23
24// Local
25#include <debug_p.h>
26#include <fakecairo.h>
27#include <panelstyle.h>
28
29// Qt
30#include <QIcon>
31#include <QPainter>
32#include <QWheelEvent>
33
34// GTK
35#include <gtk/gtk.h>
36
37// libc
38#include <time.h>
39
40static const int SPACING = 3;
41static const int PADDING = 3;
42
43using namespace unity::indicator;
44
45// Copied from libdbusmenu-qt
46static QString swapMnemonicChar(const QString &in, const char src, const char dst)
47{
48 QString out;
49 bool mnemonicFound = false;
50
51 for (int pos = 0; pos < in.length(); ) {
52 QChar ch = in[pos];
53 if (ch == src) {
54 if (pos == in.length() - 1) {
55 // 'src' at the end of string, skip it
56 ++pos;
57 } else {
58 if (in[pos + 1] == src) {
59 // A real 'src'
60 out += src;
61 pos += 2;
62 } else if (!mnemonicFound) {
63 // We found the mnemonic
64 mnemonicFound = true;
65 out += dst;
66 ++pos;
67 } else {
68 // We already have a mnemonic, just skip the char
69 ++pos;
70 }
71 }
72 } else if (ch == dst) {
73 // Escape 'dst'
74 out += dst;
75 out += dst;
76 ++pos;
77 } else {
78 out += ch;
79 ++pos;
80 }
81 }
82
83 return out;
84}
85
86IndicatorEntryWidget::IndicatorEntryWidget(const Entry::Ptr& entry)
87: m_entry(entry)
88, m_padding(PADDING)
89, m_hasIcon(false)
90, m_hasLabel(false)
91{
92 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
93 m_entry->updated.connect(sigc::mem_fun(this, &IndicatorEntryWidget::updatePix));
94 updatePix();
95}
96
97QSize IndicatorEntryWidget::minimumSizeHint() const
98{
99 return sizeHint();
100}
101
102QSize IndicatorEntryWidget::sizeHint() const
103{
104 return m_pix.size();
105}
106
107void IndicatorEntryWidget::paintEvent(QPaintEvent*)
108{
109 if (!m_pix.isNull()) {
110 QPainter painter(this);
111 if (m_entry->active()) {
112 paintActiveBackground(&painter);
113 }
114 painter.drawPixmap(0, 0, m_pix);
115 }
116}
117
118
119void IndicatorEntryWidget::paintActiveBackground(QPainter* painter)
120{
121 // This code should be kept in sync with the draw_menu_bg() function from
122 // plugins/unityshell/src/PanelIndicatorObjectEntryView.cpp
123 int radius = 4;
124 double x = 0;
125 double y = 0;
126 double xos = 0.5;
127 double yos = 0.5;
128 /* FIXME */
129 double mpi = 3.14159265358979323846;
130
131 PanelStyle* style = PanelStyle::instance();
132 nux::color::Color bgtop = nuxColorFromQColor(style->backgroundTopColor());
133 nux::color::Color bgbot = nuxColorFromQColor(style->backgroundBottomColor());
134 nux::color::Color line = nuxColorFromQColor(style->lineColor());
135
136 painter->setRenderHint(QPainter::Antialiasing);
137
138 fcairo_t cr(painter);
139
140 fcairo_move_to (cr, x+xos+radius, y+yos);
141 fcairo_arc (cr, x+xos+width()-xos*2-radius, y+yos+radius, radius, mpi*1.5, mpi*2);
142 fcairo_line_to (cr, x+xos+width()-xos*2, y+yos+height()-yos*2+2);
143 fcairo_line_to (cr, x+xos, y+yos+height()-yos*2+2);
144 fcairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
145
146 fcairo_pattern_t * pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+2);
147 fcairo_pattern_add_color_stop_rgba (pat, 0.0,
148 bgtop.red,
149 bgtop.green,
150 bgtop.blue,
151 1.0f - bgbot.red);
152 fcairo_pattern_add_color_stop_rgba (pat, 1.0,
153 bgbot.red,
154 bgbot.green,
155 bgbot.blue,
156 1.0f - bgtop.red);
157 fcairo_set_source (cr, pat);
158 fcairo_fill_preserve (cr);
159 fcairo_pattern_destroy (pat);
160
161 /*
162 pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+2);
163 fcairo_pattern_add_color_stop_rgba (pat, 0.0,
164 line.red,
165 line.green,
166 line.blue,
167 1.0f);
168 fcairo_pattern_add_color_stop_rgba (pat, 1.0,
169 line.red,
170 line.green,
171 line.blue,
172 1.0f);
173 fcairo_set_source (cr, pat);
174 */
175 fcairo_set_source_rgb (cr, line.red, line.green, line.blue);
176 fcairo_stroke (cr);
177 //fcairo_pattern_destroy (pat);
178
179 xos++;
180 yos++;
181
182 /* enlarging the area to not draw the lightborder at bottom, ugly trick :P */
183 fcairo_move_to (cr, x+radius+xos, y+yos);
184 fcairo_arc (cr, x+xos+width()-xos*2-radius, y+yos+radius, radius, mpi*1.5, mpi*2);
185 fcairo_line_to (cr, x+xos+width()-xos*2, y+yos+height()-yos*2+3);
186 fcairo_line_to (cr, x+xos, y+yos+height()-yos*2+3);
187 fcairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
188
189 /*
190 pat = fcairo_pattern_create_linear (x+xos, y, x+xos, y+height()-yos*2+3);
191 fcairo_pattern_add_color_stop_rgba (pat, 0.0,
192 bgbot.red,
193 bgbot.green,
194 bgbot.blue,
195 1.0f);
196 fcairo_pattern_add_color_stop_rgba (pat, 1.0,
197 bgbot.red,
198 bgbot.green,
199 bgbot.blue,
200 1.0f);
201 fcairo_set_source (cr, pat);
202 */
203 fcairo_set_source_rgb (cr, bgbot.red, bgbot.green, bgbot.blue);
204 fcairo_stroke (cr);
205 //fcairo_pattern_destroy (pat);
206}
207
208void IndicatorEntryWidget::updatePix()
209{
210 bool oldIsEmpty = isEmpty();
211
212 int width = m_padding;
213 int iconX = m_padding;
214 int labelX = 0;
215
216 // Compute width, labelX and update m_has{Icon,Label}
217 QPixmap iconPix;
218 if (m_entry->image_visible()) {
219 iconPix = decodeIcon();
220 m_hasIcon = !iconPix.isNull();
221 } else {
222 m_hasIcon = false;
223 }
224 if (m_hasIcon) {
225 width += iconPix.width();
226 }
227
228 QString label = QString::fromUtf8(m_entry->label().c_str());
229 label = swapMnemonicChar(label, '_', '&');
230 m_hasLabel = !label.isEmpty() && m_entry->label_visible();
231 if (m_hasLabel) {
232 if (m_hasIcon) {
233 width += SPACING;
234 }
235 labelX = width;
236 QString visibleLabel = label;
237 visibleLabel.remove('&');
238 width += fontMetrics().width(visibleLabel);
239 }
240
241 width += m_padding;
242
243 // Paint
244 QPixmap oldPix = m_pix;
245 if (!m_hasIcon && !m_hasLabel) {
246 m_pix = QPixmap();
247 } else {
248 m_pix = QPixmap(width, 24);
249 m_pix.fill(Qt::transparent);
250 QPainter painter(&m_pix);
251 painter.initFrom(this);
252 if (m_hasIcon) {
253 bool disabled = !m_entry->image_sensitive();
254 if (disabled) {
255 painter.setOpacity(0.5);
256 }
257 painter.drawPixmap(iconX, 0, iconPix);
258 if (disabled) {
259 painter.setOpacity(1);
260 }
261 }
262 if (m_hasLabel) {
263 PanelStyle* style = PanelStyle::instance();
264
265 int flags = Qt::AlignLeft | Qt::AlignVCenter;
266 flags |= m_entry->show_now() ? Qt::TextShowMnemonic : Qt::TextHideMnemonic;
267
268 // Shadow
269 QColor color = style->textShadowColor();
270 color.setAlphaF(1. - color.redF());
271 painter.setPen(color);
272 painter.drawText(labelX, 1, width - labelX, m_pix.height(), flags, label);
273
274 // Text
275 color = style->textColor();
276 color.setAlphaF(m_entry->label_sensitive() ? 1. : .5);
277 painter.setPen(color);
278 painter.drawText(labelX, 0, width - labelX, m_pix.height(), flags, label);
279 }
280 }
281
282 // Notify others we changed, but only trigger a layout update if necessary
283 if (m_pix.size() == oldPix.size()) {
284 update();
285 } else {
286 updateGeometry();
287 }
288 bool newIsEmpty = isEmpty();
289 if (newIsEmpty != oldIsEmpty) {
290 // If we emit isEmptyChanged() directly it won't reach any connected
291 // slot. I assume this is because this method is called as a response
292 // to a sigc++ signal.
293 QMetaObject::invokeMethod(this, "isEmptyChanged", Qt::QueuedConnection);
294 }
295}
296
297QPixmap IndicatorEntryWidget::decodeIcon()
298{
299 QPixmap pix;
300
301 int type = m_entry->image_type();
302
303 if (type == 0) {
304 // No icon
305 } else if (type == GTK_IMAGE_PIXBUF) {
306 QByteArray data = QByteArray::fromBase64(m_entry->image_data().c_str());
307 QImage image;
308 bool ok = image.loadFromData(data);
309 if (ok) {
310 pix = QPixmap::fromImage(image);
311 } else {
312 UQ_WARNING << "Failed to decode image";
313 }
314 } else if (type == GTK_IMAGE_ICON_NAME) {
315 QString name = QString::fromStdString(m_entry->image_data());
316 QIcon icon = QIcon::fromTheme(name);
317 pix = icon.pixmap(24, 24);
318 } else if (type == GTK_IMAGE_GICON) {
319 UQ_WARNING << "FIXME: Implement support for GTK_IMAGE_GICON image type";
320 } else {
321 UQ_WARNING << "Unknown image type" << m_entry->image_type();
322 }
323 return pix;
324}
325
326void IndicatorEntryWidget::mousePressEvent(QMouseEvent*)
327{
328 UQ_RETURN_IF_FAIL(m_hasIcon || m_hasLabel);
329 showMenu(Qt::LeftButton);
330}
331
332void IndicatorEntryWidget::mouseReleaseEvent(QMouseEvent*)
333{
334 UQ_VAR(this);
335 update();
336}
337
338void IndicatorEntryWidget::wheelEvent(QWheelEvent* event)
339{
340 m_entry->Scroll(event->delta());
341}
342
343void IndicatorEntryWidget::showMenu(Qt::MouseButton qtButton)
344{
345 if (m_entry->active()) {
346 return;
347 }
348 int nuxButton = qtButton == Qt::NoButton ? 0 : 1;
349 QPoint pos = mapToGlobal(rect().bottomLeft());
350 m_entry->ShowMenu(pos.x(), pos.y(),
351 time(NULL),
352 nuxButton
353 );
354}
355
356void IndicatorEntryWidget::setPadding(int padding)
357{
358 if (m_padding != padding) {
359 m_padding = padding;
360 updatePix();
361 }
362}
363
364bool IndicatorEntryWidget::event(QEvent* ev)
365{
366 bool ret = QWidget::event(ev);
367 switch (ev->type()) {
368 case QEvent::FontChange:
369 case QEvent::PaletteChange:
370 updatePix();
371 break;
372 default:
373 break;
374 }
375 return ret;
376}
377
378bool IndicatorEntryWidget::isEmpty() const
379{
380 return !m_hasIcon && !m_hasLabel;
381}
382
383unity::indicator::Entry::Ptr IndicatorEntryWidget::entry() const
384{
385 return m_entry;
386}
387
388#include "indicatorentrywidget.moc"
0389
=== added file 'panel/applets/common/indicatorentrywidget.h'
--- panel/applets/common/indicatorentrywidget.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorentrywidget.h 2011-07-27 12:33:15 +0000
@@ -0,0 +1,81 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORENTRYWIDGET_H
22#define INDICATORENTRYWIDGET_H
23
24// Local
25
26// libunity-core
27#include <UnityCore/IndicatorEntry.h>
28
29// Qt
30#include <QWidget>
31
32class QPainter;
33
34class IndicatorEntryWidget : public QWidget, public sigc::trackable
35{
36Q_OBJECT
37public:
38 IndicatorEntryWidget(const unity::indicator::Entry::Ptr& entry);
39
40 QSize minimumSizeHint() const;
41 QSize sizeHint() const;
42
43 void setPadding(int);
44
45 bool isEmpty() const;
46
47 unity::indicator::Entry::Ptr entry() const;
48
49 /**
50 * Shows the menu.
51 *
52 * When this method is called because of a click, button
53 * must be set to Qt::LeftButton.
54 *
55 * When it is called because user previously clicked an indicator and moved the
56 * mouse to another indicator, button must be set to Qt::NoButton.
57 */
58 void showMenu(Qt::MouseButton button);
59
60Q_SIGNALS:
61 void isEmptyChanged();
62
63protected:
64 void paintEvent(QPaintEvent*);
65 void mousePressEvent(QMouseEvent*);
66 void mouseReleaseEvent(QMouseEvent*);
67 void wheelEvent(QWheelEvent*);
68 bool event(QEvent*);
69
70private:
71 unity::indicator::Entry::Ptr m_entry;
72 QPixmap m_pix;
73 int m_padding;
74 bool m_hasIcon;
75 bool m_hasLabel;
76 void updatePix();
77 QPixmap decodeIcon();
78 void paintActiveBackground(QPainter*);
79};
80
81#endif /* INDICATORENTRYWIDGET_H */
082
=== added file 'panel/applets/common/indicatorsmanager.cpp'
--- panel/applets/common/indicatorsmanager.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorsmanager.cpp 2011-07-27 12:33:15 +0000
@@ -0,0 +1,176 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorsmanager.h"
23
24// Local
25#include <debug_p.h>
26#include <indicatorentrywidget.h>
27
28// Qt
29#include <QApplication>
30#include <QTimer>
31#include <QX11Info>
32
33// X11
34#include <X11/Xlib.h>
35
36using namespace unity::indicator;
37
38IndicatorsManager::IndicatorsManager(QObject* parent)
39: QObject(parent)
40, m_indicators(new DBusIndicators)
41, m_geometrySyncTimer(new QTimer(this))
42{
43 m_geometrySyncTimer->setInterval(0);
44 m_geometrySyncTimer->setSingleShot(true);
45 connect(m_geometrySyncTimer, SIGNAL(timeout()), SLOT(syncGeometries()));
46
47 m_indicators->on_entry_show_menu.connect(
48 sigc::mem_fun(this, &IndicatorsManager::onEntryShowMenu)
49 );
50
51 m_indicators->on_menu_pointer_moved.connect(
52 sigc::mem_fun(this, &IndicatorsManager::onMenuPointerMoved)
53 );
54
55 m_indicators->on_entry_activate_request.connect(
56 sigc::mem_fun(this, &IndicatorsManager::onEntryActivateRequest)
57 );
58
59 m_indicators->on_synced.connect(
60 sigc::mem_fun(this, &IndicatorsManager::onSynced)
61 );
62}
63
64unity::indicator::DBusIndicators::Ptr IndicatorsManager::indicators() const
65{
66 return m_indicators;
67}
68
69void IndicatorsManager::onEntryShowMenu(const std::string& /*entryId*/, int posX, int posY, int /*timestamp*/, int /*button*/)
70{
71 // Copied from plugins/unityshell/src/PanelView.cpp, in OnEntryShowMenu()
72 // Without this code, menus cannot be shown from mousePressEvent() (but can
73 // be shown from mouseReleaseEvent())
74 /*
75 Neil explanation:
76 On button down, X automatically gives Qt a passive grab on the mouse this
77 means that, if the panel service tries to grab the pointer to show the menu
78 (gtk does this automatically), it fails and the menu can't show.
79 We connect to the on_entry_show_menu signal, which is emitted before
80 DBusIndicators does anything else, and just break the grab.
81 */
82 Display* display = QX11Info::display();
83 XUngrabPointer(display, CurrentTime);
84 XFlush(display);
85
86 XButtonEvent event = {
87 ButtonRelease,
88 0,
89 False,
90 display,
91 0,
92 0,
93 0,
94 CurrentTime,
95 posX, posY,
96 posX, posY,
97 0,
98 Button1,
99 True
100 };
101 qApp->x11ProcessEvent(reinterpret_cast<XEvent*>(&event));
102}
103
104void IndicatorsManager::onMenuPointerMoved(int posX, int posY)
105{
106 QWidget* widget = QApplication::widgetAt(posX, posY);
107 IndicatorEntryWidget* entryWidget = qobject_cast<IndicatorEntryWidget*>(widget);
108 if (!entryWidget) {
109 return;
110 }
111 entryWidget->showMenu(Qt::NoButton);
112}
113
114void IndicatorsManager::onEntryActivateRequest(const std::string& entryId)
115{
116 if (entryId.empty()) {
117 return;
118 }
119 IndicatorEntryWidget* widget = 0;
120 Q_FOREACH(widget, m_widgetList) {
121 if (widget->entry()->id() == entryId) {
122 break;
123 }
124 }
125 if (!widget) {
126 UQ_WARNING << "Could not find a widget for IndicatorEntry with id" << QString::fromStdString(entryId);
127 return;
128 }
129 widget->showMenu(Qt::NoButton);
130}
131
132void IndicatorsManager::onSynced()
133{
134 QMetaObject::invokeMethod(m_geometrySyncTimer, "start", Qt::QueuedConnection);
135}
136
137void IndicatorsManager::addIndicatorEntryWidget(IndicatorEntryWidget* widget)
138{
139 m_widgetList.append(widget);
140 widget->installEventFilter(this);
141}
142
143bool IndicatorsManager::eventFilter(QObject*, QEvent* event)
144{
145 switch (event->type()) {
146 case QEvent::Show:
147 case QEvent::Hide:
148 case QEvent::Move:
149 case QEvent::Resize:
150 m_geometrySyncTimer->start();
151 break;
152 default:
153 break;
154 }
155 return false;
156}
157
158void IndicatorsManager::syncGeometries()
159{
160 EntryLocationMap locations;
161 Q_FOREACH(IndicatorEntryWidget* widget, m_widgetList) {
162 if (!widget->isVisible()) {
163 continue;
164 }
165 Entry::Ptr entry = widget->entry();
166 if (entry->IsUnused()) {
167 continue;
168 }
169 QPoint topLeft = widget->mapToGlobal(QPoint(0, 0));
170 nux::Rect rect(topLeft.x(), topLeft.y(), widget->width(), widget->height());
171 locations[widget->entry()->id()] = rect;
172 }
173 m_indicators->SyncGeometries("Panel", locations);
174}
175
176#include "indicatorsmanager.moc"
0177
=== added file 'panel/applets/common/indicatorsmanager.h'
--- panel/applets/common/indicatorsmanager.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorsmanager.h 2011-07-27 12:33:15 +0000
@@ -0,0 +1,70 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORSMANAGER_H
22#define INDICATORSMANAGER_H
23
24// Local
25
26// Qt
27#include <QMap>
28#include <QObject>
29
30// libunity-core
31#include <UnityCore/DBusIndicators.h>
32
33class QTimer;
34
35class IndicatorEntryWidget;
36
37/**
38 * Instantiates DBusIndicators and implement common behavior
39 */
40class IndicatorsManager : public QObject, public sigc::trackable
41{
42 Q_OBJECT
43public:
44 IndicatorsManager(QObject* parent);
45
46 unity::indicator::DBusIndicators::Ptr indicators() const;
47
48 void addIndicatorEntryWidget(IndicatorEntryWidget* widget);
49
50protected:
51 bool eventFilter(QObject*, QEvent*);
52
53private Q_SLOTS:
54 void syncGeometries();
55
56private:
57 Q_DISABLE_COPY(IndicatorsManager)
58 unity::indicator::DBusIndicators::Ptr m_indicators;
59 QTimer* m_geometrySyncTimer;
60
61 typedef QList<IndicatorEntryWidget*> IndicatorEntryWidgetList;
62 IndicatorEntryWidgetList m_widgetList;
63
64 void onSynced();
65 void onEntryShowMenu(const std::string&, int x, int y, int timestamp, int button);
66 void onMenuPointerMoved(int x, int y);
67 void onEntryActivateRequest(const std::string& entryId);
68};
69
70#endif /* INDICATORSMANAGER_H */
071
=== added file 'panel/applets/common/indicatorwidget.cpp'
--- panel/applets/common/indicatorwidget.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorwidget.cpp 2011-07-27 12:33:15 +0000
@@ -0,0 +1,53 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "indicatorwidget.h"
23
24// Local
25#include <debug_p.h>
26#include <indicatorentrywidget.h>
27#include <indicatorsmanager.h>
28
29// Qt
30#include <QHBoxLayout>
31
32using namespace unity::indicator;
33
34IndicatorWidget::IndicatorWidget(const Indicator::Ptr& indicator, IndicatorsManager* manager)
35: m_layout(new QHBoxLayout(this))
36, m_indicatorsManager(manager)
37, m_indicator(indicator)
38{
39 m_layout->setMargin(0);
40 m_layout->setSpacing(0);
41
42 m_indicator->on_entry_added.connect(sigc::mem_fun(this, &IndicatorWidget::onEntryAdded));
43}
44
45void IndicatorWidget::onEntryAdded(const Entry::Ptr& entry)
46{
47 IndicatorEntryWidget* widget = new IndicatorEntryWidget(entry);
48 m_indicatorsManager->addIndicatorEntryWidget(widget);
49 m_layout->addWidget(widget);
50}
51
52
53#include "indicatorwidget.moc"
054
=== added file 'panel/applets/common/indicatorwidget.h'
--- panel/applets/common/indicatorwidget.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/indicatorwidget.h 2011-07-27 12:33:15 +0000
@@ -0,0 +1,52 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef INDICATORWIDGET_H
22#define INDICATORWIDGET_H
23
24// Local
25
26// libunity-core
27#include <UnityCore/Indicator.h>
28#include <UnityCore/IndicatorEntry.h>
29
30// Qt
31#include <QWidget>
32
33class QHBoxLayout;
34
35class IndicatorEntryWidget;
36class IndicatorsManager;
37
38class IndicatorWidget : public QWidget, public sigc::trackable
39{
40Q_OBJECT
41public:
42 IndicatorWidget(const unity::indicator::Indicator::Ptr& indicator, IndicatorsManager* manager);
43
44private:
45 QHBoxLayout* m_layout;
46 IndicatorsManager* m_indicatorsManager;
47 unity::indicator::Indicator::Ptr m_indicator;
48
49 void onEntryAdded(const unity::indicator::Entry::Ptr& entry);
50};
51
52#endif /* INDICATORWIDGET_H */
053
=== added file 'panel/applets/common/panelstyle.cpp'
--- panel/applets/common/panelstyle.cpp 1970-01-01 00:00:00 +0000
+++ panel/applets/common/panelstyle.cpp 2011-07-27 12:33:15 +0000
@@ -0,0 +1,175 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21// Self
22#include "panelstyle.h"
23
24// libunity-2d
25#include <debug_p.h>
26#include <gconnector.h>
27#include <gscopedpointer.h>
28
29// Qt
30#include <QApplication>
31#include <QColor>
32#include <QFont>
33#include <QPalette>
34
35// GTK
36#include <gtk/gtk.h>
37#include <pango/pango.h>
38
39typedef void (*ColorGetter)(GtkStyleContext*, GtkStateFlags, GdkRGBA*);
40
41inline QColor colorFromContext(ColorGetter getter, GtkStyleContext* context, GtkStateFlags state)
42{
43 GdkRGBA color;
44 getter(context, state, &color);
45 return QColor::fromRgbF(color.red, color.green, color.blue, color.alpha);
46}
47
48class PanelStylePrivate
49{
50public:
51 PanelStyle* q;
52 GtkWidget* m_offScreenWindow;
53 GConnector m_gConnector;
54
55 QColor m_textColor;
56 QColor m_backgroundTopColor;
57 QColor m_backgroundBottomColor;
58 QColor m_textShadowColor;
59 QColor m_lineColor;
60 QFont m_font;
61
62 static void onThemeChanged(GObject*, GParamSpec*, gpointer data)
63 {
64 PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data);
65 priv->updatePalette();
66 }
67
68 static void onFontChanged(GObject*, GParamSpec*, gpointer data)
69 {
70 PanelStylePrivate* priv = reinterpret_cast<PanelStylePrivate*>(data);
71 priv->updateFont();
72 }
73
74 void updatePalette()
75 {
76 GtkStyleContext* context = gtk_widget_get_style_context(m_offScreenWindow);
77 UQ_RETURN_IF_FAIL(context);
78
79 m_textColor = colorFromContext(gtk_style_context_get_color, context, GTK_STATE_FLAG_NORMAL);
80 m_textShadowColor = colorFromContext(gtk_style_context_get_color, context, GTK_STATE_FLAG_SELECTED);
81 m_lineColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_NORMAL).darker(130);
82 m_backgroundTopColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_ACTIVE);
83 m_backgroundBottomColor = colorFromContext(gtk_style_context_get_background_color, context, GTK_STATE_FLAG_NORMAL);
84
85 QPalette pal;
86 pal.setColor(QPalette::Window, m_backgroundTopColor);
87 pal.setColor(QPalette::Button, m_backgroundTopColor);
88 pal.setColor(QPalette::Text, m_textColor);
89 pal.setColor(QPalette::WindowText, m_textColor);
90 pal.setColor(QPalette::ButtonText, m_textColor);
91 QApplication::setPalette(pal);
92 }
93
94 void updateFont()
95 {
96 gchar* fontName = 0;
97 g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontName, NULL);
98 GScopedPointer<PangoFontDescription, pango_font_description_free> fontDescription(
99 pango_font_description_from_string(fontName)
100 );
101 g_free(fontName);
102
103 int size = pango_font_description_get_size(fontDescription.data());
104
105 m_font = QFont(
106 pango_font_description_get_family(fontDescription.data()),
107 size / PANGO_SCALE
108 );
109
110 QApplication::setFont(m_font);
111 }
112};
113
114PanelStyle::PanelStyle(QObject* parent)
115: d(new PanelStylePrivate)
116{
117 d->q = this;
118 d->m_offScreenWindow = gtk_offscreen_window_new();
119 gtk_widget_set_name(d->m_offScreenWindow, "UnityPanelWidget");
120 gtk_widget_set_size_request(d->m_offScreenWindow, 100, 24);
121 gtk_style_context_add_class(gtk_widget_get_style_context(d->m_offScreenWindow), "menubar");
122 gtk_widget_show_all(d->m_offScreenWindow);
123
124 d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name",
125 G_CALLBACK(PanelStylePrivate::onThemeChanged), d);
126 d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-font-name",
127 G_CALLBACK(PanelStylePrivate::onFontChanged), d);
128
129 d->updatePalette();
130 d->updateFont();
131}
132
133PanelStyle::~PanelStyle()
134{
135 gtk_widget_destroy(d->m_offScreenWindow);
136 delete d;
137}
138
139PanelStyle* PanelStyle::instance()
140{
141 static PanelStyle style;
142 return &style;
143}
144
145QColor PanelStyle::textColor() const
146{
147 return d->m_textColor;
148}
149
150QColor PanelStyle::backgroundTopColor() const
151{
152 return d->m_backgroundTopColor;
153}
154
155QColor PanelStyle::backgroundBottomColor() const
156{
157 return d->m_backgroundBottomColor;
158}
159
160QColor PanelStyle::textShadowColor() const
161{
162 return d->m_textShadowColor;
163}
164
165QColor PanelStyle::lineColor() const
166{
167 return d->m_lineColor;
168}
169
170QFont PanelStyle::font() const
171{
172 return d->m_font;
173}
174
175#include "panelstyle.moc"
0176
=== added file 'panel/applets/common/panelstyle.h'
--- panel/applets/common/panelstyle.h 1970-01-01 00:00:00 +0000
+++ panel/applets/common/panelstyle.h 2011-07-27 12:33:15 +0000
@@ -0,0 +1,59 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef PANELSTYLE_H
22#define PANELSTYLE_H
23
24// Local
25
26// Qt
27#include <QObject>
28
29class QColor;
30class QFont;
31
32class PanelStylePrivate;
33/**
34 * Provides easy access to panel colors
35 */
36class PanelStyle : public QObject
37{
38 Q_OBJECT
39public:
40 PanelStyle(QObject* parent = 0);
41 ~PanelStyle();
42
43 static PanelStyle* instance();
44
45 QColor textColor() const;
46 QColor backgroundTopColor() const;
47 QColor backgroundBottomColor() const;
48 QColor textShadowColor() const;
49 QColor lineColor() const;
50
51 QFont font() const;
52
53private:
54 friend class PanelStylePrivate;
55 // Use a pimpl to avoid the need for gtk includes here
56 PanelStylePrivate* const d;
57};
58
59#endif /* PANELSTYLE_H */
060
=== removed directory 'panel/applets/indicator'
=== removed file 'panel/applets/indicator-config.h.in'
--- panel/applets/indicator-config.h.in 2011-03-01 09:04:13 +0000
+++ panel/applets/indicator-config.h.in 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1#ifndef INDICATOR_CONFIG_H
2#define INDICATOR_CONFIG_H
3
4#define INDICATOR_ICONS_DIR "${INDICATOR_ICONS_DIR}"
5#define INDICATOR_DIR "${INDICATOR_DIR}"
6
7#endif /* INDICATOR_CONFIG_H */
80
=== removed file 'panel/applets/indicator/indicator.c'
--- panel/applets/indicator/indicator.c 2011-07-27 12:33:12 +0000
+++ panel/applets/indicator/indicator.c 1970-01-01 00:00:00 +0000
@@ -1,526 +0,0 @@
1/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17
18#include <string.h>
19
20#include <gtk/gtk.h>
21#include <gtk/gtkx.h>
22#include <libindicator/indicator-object.h>
23
24#include "indicator.h"
25
26#include "indicator-config.h"
27
28/* default settings */
29#define DEFAULT_SETTING1 NULL
30#define DEFAULT_SETTING2 1
31#define DEFAULT_SETTING3 FALSE
32
33typedef enum {
34 PANEL_APPLET_ORIENT_LEFT,
35 PANEL_APPLET_ORIENT_RIGHT,
36 PANEL_APPLET_ORIENT_TOP,
37 PANEL_APPLET_ORIENT_BOTTOM
38} PanelAppletOrient;
39
40// <indicator-applet-copy>
41static gchar * indicator_order[] = {
42 "libappmenu.so",
43 "libapplication.so",
44 "libsoundmenu.so",
45 "libnetworkmenu.so",
46 "libmessaging.so",
47 "libdatetime.so",
48 "libme.so",
49 "libsession.so",
50 NULL
51};
52
53static GtkPackDirection packdirection;
54static PanelAppletOrient orient;
55
56#define MENU_DATA_INDICATOR_OBJECT "indicator-object"
57#define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
58
59#define IO_DATA_ORDER_NUMBER "indicator-order-number"
60
61static gint
62name2order (const gchar * name) {
63 int i;
64
65 for (i = 0; indicator_order[i] != NULL; i++) {
66 if (g_strcmp0(name, indicator_order[i]) == 0) {
67 return i;
68 }
69 }
70
71 return -1;
72}
73
74typedef struct _incoming_position_t incoming_position_t;
75struct _incoming_position_t {
76 gint objposition;
77 gint entryposition;
78 gint menupos;
79 gboolean found;
80};
81
82/* This function helps by determining where in the menu list
83 this new entry should be placed. It compares the objects
84 that they're on, and then the individual entries. Each
85 is progressively more expensive. */
86static void
87place_in_menu (GtkWidget * widget, gpointer user_data)
88{
89 incoming_position_t * position = (incoming_position_t *)user_data;
90 if (position->found) {
91 /* We've already been placed, just finish the foreach */
92 return;
93 }
94
95 IndicatorObject * io = INDICATOR_OBJECT(g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_OBJECT));
96 g_assert(io != NULL);
97
98 gint objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
99 /* We've already passed it, well, then this is where
100 we should be be. Stop! */
101 if (objposition > position->objposition) {
102 position->found = TRUE;
103 return;
104 }
105
106 /* The objects don't match yet, keep looking */
107 if (objposition < position->objposition) {
108 position->menupos++;
109 return;
110 }
111
112 /* The objects are the same, let's start looking at entries. */
113 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
114 gint entryposition = indicator_object_get_location(io, entry);
115
116 if (entryposition > position->entryposition) {
117 position->found = TRUE;
118 return;
119 }
120
121 if (entryposition < position->entryposition) {
122 position->menupos++;
123 return;
124 }
125
126 /* We've got the same object and the same entry. Well,
127 let's just put it right here then. */
128 position->found = TRUE;
129 return;
130}
131
132static void
133something_shown (GtkWidget * widget, gpointer user_data)
134{
135 GtkWidget * menuitem = GTK_WIDGET(user_data);
136 gtk_widget_show(menuitem);
137}
138
139static void
140something_hidden (GtkWidget * widget, gpointer user_data)
141{
142 GtkWidget * menuitem = GTK_WIDGET(user_data);
143 gtk_widget_hide(menuitem);
144}
145
146static void
147sensitive_cb (GObject * obj, GParamSpec * pspec, gpointer user_data)
148{
149 g_return_if_fail(GTK_IS_WIDGET(obj));
150 g_return_if_fail(GTK_IS_WIDGET(user_data));
151
152 gtk_widget_set_sensitive(GTK_WIDGET(user_data), gtk_widget_get_sensitive(GTK_WIDGET(obj)));
153 return;
154}
155
156static gboolean
157entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data)
158{
159 IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT);
160 IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY);
161
162 g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE);
163
164 g_signal_emit_by_name (io, "scroll", 1, event->direction);
165 g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction);
166
167 return FALSE;
168}
169
170static void
171entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
172{
173 g_debug("Signal: Entry Added");
174 gboolean something_visible = FALSE;
175 gboolean something_sensitive = FALSE;
176
177 GtkWidget * menuitem = gtk_menu_item_new();
178 GtkWidget * box = (packdirection == GTK_PACK_DIRECTION_LTR) ?
179 gtk_hbox_new(FALSE, 3) : gtk_vbox_new(FALSE, 3);
180
181 g_object_set_data (G_OBJECT (menuitem), "indicator", io);
182 g_object_set_data (G_OBJECT (menuitem), "box", box);
183
184 if (entry->image != NULL) {
185 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 0);
186 if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
187 something_visible = TRUE;
188 }
189
190 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->image))) {
191 something_sensitive = TRUE;
192 }
193
194 g_signal_connect(G_OBJECT(entry->image), "show", G_CALLBACK(something_shown), menuitem);
195 g_signal_connect(G_OBJECT(entry->image), "hide", G_CALLBACK(something_hidden), menuitem);
196
197 g_signal_connect(G_OBJECT(entry->image), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
198 }
199 if (entry->label != NULL) {
200 switch(packdirection) {
201 case GTK_PACK_DIRECTION_LTR:
202 gtk_label_set_angle(GTK_LABEL(entry->label), 0.0);
203 break;
204 case GTK_PACK_DIRECTION_TTB:
205 gtk_label_set_angle(GTK_LABEL(entry->label),
206 (orient == PANEL_APPLET_ORIENT_LEFT) ?
207 270.0 : 90.0);
208 break;
209 default:
210 break;
211 }
212 gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->label), FALSE, FALSE, 0);
213
214 if (gtk_widget_get_visible(GTK_WIDGET(entry->label))) {
215 something_visible = TRUE;
216 }
217
218 if (gtk_widget_get_sensitive(GTK_WIDGET(entry->label))) {
219 something_sensitive = TRUE;
220 }
221
222 g_signal_connect(G_OBJECT(entry->label), "show", G_CALLBACK(something_shown), menuitem);
223 g_signal_connect(G_OBJECT(entry->label), "hide", G_CALLBACK(something_hidden), menuitem);
224
225 g_signal_connect(G_OBJECT(entry->label), "notify::sensitive", G_CALLBACK(sensitive_cb), menuitem);
226 }
227 gtk_container_add(GTK_CONTAINER(menuitem), box);
228 gtk_widget_show(box);
229
230 if (entry->menu != NULL) {
231 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(entry->menu));
232 }
233
234 incoming_position_t position;
235 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
236 position.entryposition = indicator_object_get_location(io, entry);
237 position.menupos = 0;
238 position.found = FALSE;
239
240 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
241
242 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), menuitem, position.menupos);
243
244 if (something_visible) {
245 gtk_widget_show(menuitem);
246 }
247 gtk_widget_set_sensitive(menuitem, something_sensitive);
248
249 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry);
250 g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io);
251 g_signal_connect(G_OBJECT (menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL);
252
253 return;
254}
255
256static void
257entry_removed_cb (GtkWidget * widget, gpointer userdata)
258{
259 gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
260
261 if (data != userdata) {
262 return;
263 }
264
265 IndicatorObjectEntry * entry = (IndicatorObjectEntry *)data;
266 if (entry->label != NULL) {
267 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_shown), widget);
268 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(something_hidden), widget);
269 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->label), G_CALLBACK(sensitive_cb), widget);
270 }
271 if (entry->image != NULL) {
272 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_shown), widget);
273 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(something_hidden), widget);
274 g_signal_handlers_disconnect_by_func(G_OBJECT(entry->image), G_CALLBACK(sensitive_cb), widget);
275 }
276
277 gtk_widget_destroy(widget);
278 return;
279}
280
281static void
282entry_removed (IndicatorObject * io G_GNUC_UNUSED, IndicatorObjectEntry * entry,
283 gpointer user_data)
284{
285 g_debug("Signal: Entry Removed");
286
287 gtk_container_foreach(GTK_CONTAINER(user_data), entry_removed_cb, entry);
288
289 return;
290}
291
292static void
293entry_moved_find_cb (GtkWidget * widget, gpointer userdata)
294{
295 gpointer * array = (gpointer *)userdata;
296 if (array[1] != NULL) {
297 return;
298 }
299
300 gpointer data = g_object_get_data(G_OBJECT(widget), MENU_DATA_INDICATOR_ENTRY);
301
302 if (data != array[0]) {
303 return;
304 }
305
306 array[1] = widget;
307 return;
308}
309
310/* Gets called when an entry for an object was moved. */
311static void
312entry_moved (IndicatorObject * io, IndicatorObjectEntry * entry,
313 gint old G_GNUC_UNUSED, gint new G_GNUC_UNUSED, gpointer user_data)
314{
315 GtkWidget * menubar = GTK_WIDGET(user_data);
316
317 gpointer array[2];
318 array[0] = entry;
319 array[1] = NULL;
320
321 gtk_container_foreach(GTK_CONTAINER(menubar), entry_moved_find_cb, array);
322 if (array[1] == NULL) {
323 g_warning("Moving an entry that isn't in our menus.");
324 return;
325 }
326
327 GtkWidget * mi = GTK_WIDGET(array[1]);
328 g_object_ref(G_OBJECT(mi));
329 gtk_container_remove(GTK_CONTAINER(menubar), mi);
330
331 incoming_position_t position;
332 position.objposition = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER));
333 position.entryposition = indicator_object_get_location(io, entry);
334 position.menupos = 0;
335 position.found = FALSE;
336
337 gtk_container_foreach(GTK_CONTAINER(menubar), place_in_menu, &position);
338
339 gtk_menu_shell_insert(GTK_MENU_SHELL(menubar), mi, position.menupos);
340
341 g_object_unref(G_OBJECT(mi));
342
343 return;
344}
345
346static gboolean
347load_module (const gchar * name, GtkWidget * menubar)
348{
349 g_debug("Looking at Module: %s", name);
350 g_return_val_if_fail(name != NULL, FALSE);
351
352 if (!g_str_has_suffix(name, G_MODULE_SUFFIX)) {
353 return FALSE;
354 }
355
356 g_debug("Loading Module: %s", name);
357
358 /* Build the object for the module */
359 gchar * fullpath = g_build_filename(INDICATOR_DIR, name, NULL);
360 IndicatorObject * io = indicator_object_new_from_file(fullpath);
361 g_free(fullpath);
362 g_return_val_if_fail(io != NULL, FALSE);
363
364 /* Attach the 'name' to the object */
365 g_object_set_data(G_OBJECT(io), IO_DATA_ORDER_NUMBER, GINT_TO_POINTER(name2order(name)));
366
367 /* Connect to its signals */
368 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
369 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
370 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
371
372 /* Work on the entries */
373 GList * entries = indicator_object_get_entries(io);
374 GList * entry = NULL;
375
376 for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
377 IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
378 entry_added(io, entrydata, menubar);
379 }
380
381 g_list_free(entries);
382
383 return TRUE;
384}
385// </indicator-applet-copy>
386
387
388/* prototypes */
389static gboolean
390on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator);
391
392IndicatorPlugin *
393indicator_new ()
394{
395 IndicatorPlugin *indicator;
396 GtkOrientation orientation;
397 gint indicators_loaded = 0;
398
399 /* Hack! prevent the appmenu indicator from swallowing our own menubar */
400 setenv("APPMENU_DISPLAY_BOTH", "1");
401
402 /* allocate memory for the plugin structure */
403 indicator = g_new (IndicatorPlugin, 1);
404
405 indicator->container = gtk_plug_new(0);
406
407 /* Init some theme/icon stuff */
408 g_object_set (gtk_settings_get_default(), "gtk-theme-name", "Ambiance", NULL);
409 g_object_set (gtk_settings_get_default(), "gtk-icon-theme-name", "ubuntu-mono-dark", NULL);
410 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
411 INDICATOR_ICONS_DIR);
412 gtk_rc_parse_string (
413 "widget \"indicator-applet*\" style \"panel\"\n"
414 "style \"indicator-applet-style\"\n"
415 "{\n"
416 " GtkMenuBar::shadow-type = none\n"
417 " GtkMenuBar::internal-padding = 0\n"
418 " GtkWidget::focus-line-width = 0\n"
419 " GtkWidget::focus-padding = 0\n"
420 "}\n"
421 "style \"indicator-applet-menubar-style\"\n"
422 "{\n"
423 " GtkMenuBar::shadow-type = none\n"
424 " GtkMenuBar::internal-padding = 0\n"
425 " GtkWidget::focus-line-width = 0\n"
426 " GtkWidget::focus-padding = 0\n"
427 " GtkMenuItem::horizontal-padding = 0\n"
428 "}\n"
429 "style \"indicator-applet-menuitem-style\"\n"
430 "{\n"
431 " GtkWidget::focus-line-width = 0\n"
432 " GtkWidget::focus-padding = 0\n"
433 " GtkMenuItem::horizontal-padding = 0\n"
434 "}\n"
435 "widget \"*.indicator-applet\" style \"indicator-applet-style\""
436 "widget \"*.indicator-applet-menuitem\" style \"indicator-applet-menuitem-style\""
437 "widget \"*.indicator-applet-menubar\" style \"indicator-applet-menubar-style\"");
438 gtk_widget_set_name(GTK_WIDGET (indicator->container), "indicator-applet");
439 /* create some panel widgets */
440
441 /* Build menu */
442 indicator->menu = gtk_menu_bar_new();
443 gtk_widget_set_can_focus(GTK_WIDGET (indicator->menu), TRUE);
444 gtk_widget_set_name(GTK_WIDGET (indicator->menu), "indicator-applet-menubar");
445 g_signal_connect(indicator->menu, "button-press-event", G_CALLBACK(on_menu_press), NULL);
446 //g_signal_connect_after(indicator->menu, "expose-event", G_CALLBACK(menu_on_expose), menu);
447 gtk_container_set_border_width(GTK_CONTAINER(indicator->menu), 0);
448
449 /* load 'em */
450 if (!g_file_test(INDICATOR_DIR, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
451 g_warning ("%s does not exist, cannot read any indicators", INDICATOR_DIR);
452 } else {
453 GDir *dir;
454 const gchar *name;
455
456 dir = g_dir_open(INDICATOR_DIR, 0, NULL);
457 while ((name = g_dir_read_name (dir)) != NULL) {
458 if (g_strcmp0(name, "libappmenu.so") == 0) {
459 continue;
460 }
461
462 if (load_module(name, indicator->menu)) {
463 indicators_loaded++;
464 } else {
465 g_warning("Failed to load module %s", name);
466 }
467 }
468 g_dir_close(dir);
469 }
470
471 if (indicators_loaded == 0) {
472 /* A label to allow for click through */
473 indicator->item = gtk_button_new();
474 gtk_button_set_label(GTK_BUTTON(indicator->item), "No Indicators");
475 gtk_widget_show(indicator->item);
476 gtk_container_add (GTK_CONTAINER (indicator->container), indicator->item);
477 } else {
478 gtk_widget_show(indicator->menu);
479 gtk_container_add (GTK_CONTAINER (indicator->container), indicator->menu);
480 }
481 return indicator;
482}
483
484
485
486void
487indicator_free (IndicatorPlugin *indicator)
488{
489 g_free(indicator);
490}
491
492
493#if 0
494static gboolean
495indicator_size_changed (XfcePanelPlugin *plugin,
496 gint size,
497 IndicatorPlugin *indicator)
498{
499 GtkOrientation orientation;
500
501 /* get the orientation of the plugin */
502 orientation = xfce_panel_plugin_get_orientation (plugin);
503
504 /* set the widget size */
505 if (orientation == GTK_ORIENTATION_HORIZONTAL)
506 gtk_widget_set_size_request (GTK_WIDGET (plugin), -1, size);
507 else
508 gtk_widget_set_size_request (GTK_WIDGET (plugin), size, -1);
509
510 /* we handled the orientation */
511 return TRUE;
512}
513#endif
514
515
516static gboolean
517on_menu_press (GtkWidget *widget, GdkEventButton *event, IndicatorPlugin *indicator)
518{
519 if (indicator != NULL && event->button == 1) /* left click only */
520 {
521 /* gtk_menu_popup (GTK_MENU(indicator->menu), NULL, NULL, NULL, NULL, 0,
522 event->time);*/
523 return TRUE;
524 }
525 return FALSE ;
526}
5270
=== removed file 'panel/applets/indicator/indicator.h'
--- panel/applets/indicator/indicator.h 2011-06-22 14:49:34 +0000
+++ panel/applets/indicator/indicator.h 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1/* Copyright (c) 2009 Mark Trompell <mark@foresightlinux.org>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17
18#ifndef __INDICATOR_H__
19#define __INDICATOR_H__
20
21#include <gtk/gtk.h>
22
23G_BEGIN_DECLS
24
25/* plugin structure */
26typedef struct _IndicatorPlugin
27{
28 GtkWidget *container;
29 /* panel widgets */
30 GtkWidget *menu;
31 GtkWidget *item;
32
33 /* indicator settings */
34}
35IndicatorPlugin;
36
37IndicatorPlugin *
38indicator_new ();
39
40void
41indicator_free(IndicatorPlugin*);
42
43G_END_DECLS
44
45#endif /* !__INDICATOR_H__ */
460
=== removed file 'panel/applets/indicator/indicatorapplet.cpp'
--- panel/applets/indicator/indicatorapplet.cpp 2011-07-27 12:33:12 +0000
+++ panel/applets/indicator/indicatorapplet.cpp 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22// Self
23#include "indicatorapplet.h"
24
25// Local
26#include "debug_p.h"
27#include "indicator.h"
28
29// Qt
30#include <QHBoxLayout>
31#include <QTimer>
32#include <QX11EmbedContainer>
33
34// Gtk
35#include <gtk/gtk.h>
36#include <gtk/gtkx.h>
37
38IndicatorApplet::IndicatorApplet()
39{
40 setupUi();
41}
42
43void IndicatorApplet::setupUi()
44{
45 m_menuBar = new QMenuBar;
46 m_menuBar->setNativeMenuBar(false);
47 QHBoxLayout* layout = new QHBoxLayout(this);
48 layout->setMargin(0);
49 layout->addWidget(m_menuBar);
50
51 QMetaObject::invokeMethod(this, "createGtkIndicator", Qt::QueuedConnection);
52}
53
54void IndicatorApplet::createGtkIndicator()
55{
56 m_container = new QX11EmbedContainer;
57 layout()->addWidget(m_container);
58
59 m_gtkIndicator = indicator_new();
60 m_container->embedClient(gtk_plug_get_id(GTK_PLUG(m_gtkIndicator->container)));
61 gtk_widget_show(m_gtkIndicator->container);
62
63 QTimer* timer = new QTimer(this);
64 timer->setInterval(1000);
65 timer->setSingleShot(false);
66 connect(timer, SIGNAL(timeout()), SLOT(adjustGtkIndicatorSize()));
67 timer->start();
68}
69
70void IndicatorApplet::adjustGtkIndicatorSize()
71{
72 GtkRequisition minimum, natural;
73 gtk_widget_get_preferred_size(m_gtkIndicator->menu, &minimum, &natural);
74 m_container->setFixedWidth(minimum.width);
75}
76
77#include "indicatorapplet.moc"
780
=== removed file 'panel/applets/indicator/indicatorapplet.h'
--- panel/applets/indicator/indicatorapplet.h 2011-07-27 12:33:12 +0000
+++ panel/applets/indicator/indicatorapplet.h 1970-01-01 00:00:00 +0000
@@ -1,57 +0,0 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2010 Canonical Ltd.
5 *
6 * Authors:
7 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef INDICATORAPPLET_H
23#define INDICATORAPPLET_H
24
25// Local
26#include <applet.h>
27
28// Qt
29#include <QDBusInterface>
30#include <QMenuBar>
31
32class QX11EmbedContainer;
33
34struct _IndicatorPlugin;
35
36class IndicatorApplet : public Unity2d::Applet
37{
38Q_OBJECT
39public:
40 IndicatorApplet();
41
42private Q_SLOTS:
43 void createGtkIndicator();
44 void adjustGtkIndicatorSize();
45
46private:
47 Q_DISABLE_COPY(IndicatorApplet)
48
49 QDBusInterface* m_watcher;
50 QMenuBar* m_menuBar;
51 QX11EmbedContainer* m_container;
52 struct _IndicatorPlugin* m_gtkIndicator;
53
54 void setupUi();
55};
56
57#endif /* INDICATORAPPLET_H */
580
=== removed directory 'panel/artwork'
=== removed file 'panel/artwork/background.png'
59Binary files panel/artwork/background.png 2010-11-23 16:13:46 +0000 and panel/artwork/background.png 1970-01-01 00:00:00 +0000 differ1Binary 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
=== removed file 'panel/artwork/divider.png'
60Binary files panel/artwork/divider.png 2010-11-23 16:13:46 +0000 and panel/artwork/divider.png 1970-01-01 00:00:00 +0000 differ2Binary 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
=== modified file 'places/HomeShortcuts.qml'
--- places/HomeShortcuts.qml 2011-07-04 23:07:20 +0000
+++ places/HomeShortcuts.qml 2011-07-27 12:33:15 +0000
@@ -58,9 +58,9 @@
58 contentType: "x-scheme-handler/http"58 contentType: "x-scheme-handler/http"
59 }59 }
6060
61 HomeButtonApplication {61 HomeButtonDefaultApplication {
62 label: u2d.tr("View Photos")62 label: u2d.tr("View Photos")
63 desktopFile: "shotwell.desktop"63 contentType: "image/jpeg"
64 }64 }
6565
66 HomeButtonDefaultApplication {66 HomeButtonDefaultApplication {
@@ -68,9 +68,9 @@
68 contentType: "x-scheme-handler/mailto"68 contentType: "x-scheme-handler/mailto"
69 }69 }
7070
71 HomeButtonApplication {71 HomeButtonDefaultApplication {
72 label: u2d.tr("Listen to Music")72 label: u2d.tr("Listen to Music")
73 key: "/desktop/gnome/applications/media/exec"73 contentType: "audio/x-vorbis+ogg"
74 }74 }
75}75}
7676

Subscribers

People subscribed via source and target branches