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