Merge lp:~unity-team/unity/panel-fixes into lp:unity

Proposed by Neil J. Patel
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 867
Proposed branch: lp:~unity-team/unity/panel-fixes
Merge into: lp:unity
Diff against target: 1855 lines (+1043/-202)
21 files modified
CMakeLists.txt (+1/-1)
com.canonical.Unity.gschema.xml (+7/-0)
services/panel-service.c (+11/-2)
src/PanelHomeButton.cpp (+11/-7)
src/PanelHomeButton.h (+0/-1)
src/PanelIndicatorObjectEntryView.cpp (+62/-22)
src/PanelIndicatorObjectView.cpp (+7/-3)
src/PanelMenuView.cpp (+49/-36)
src/PanelMenuView.h (+1/-0)
src/PanelStyle.cpp (+274/-0)
src/PanelStyle.h (+79/-0)
src/PanelTray.cpp (+231/-0)
src/PanelTray.h (+73/-0)
src/PanelView.cpp (+126/-43)
src/PanelView.h (+20/-3)
src/WindowButtons.cpp (+27/-71)
src/unityshell.cpp (+34/-7)
src/unityshell.h (+8/-0)
tests/CMakeLists.txt (+4/-0)
tests/TestPanel.cpp (+2/-2)
unityshell.xml.in (+16/-4)
To merge this branch: bzr merge lp:~unity-team/unity/panel-fixes
Reviewer Review Type Date Requested Status
Gord Allott Pending
Review via email: mp+50109@code.launchpad.net

Description of the change

All bugs linked, the only thing different is that I added an option to change panel opacity :)

I had to change the GSettings schemas, so you'll need to make sure that they are installed correctly locally and your exporting XDG_DATA_DIRS=$your_prefix/share:/usr/local/share:/usr/share (or whatever makes sense for your system :)

*update* Install latest libunity-misc too.

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

You have a few conflict markers there, and also you copied Mirco's email in the
header blocks :-)

Revision history for this message
Neil J. Patel (njpatel) wrote :

Fixed conflicts. Mirco's name is because I merged a branch of his with the initial implementation of style object but, yeah, I forgot to add my own name when I updated it :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2011-02-10 17:00:18 +0000
+++ CMakeLists.txt 2011-02-17 10:02:19 +0000
@@ -88,7 +88,7 @@
88#88#
89# src (Compiz Plugin)89# src (Compiz Plugin)
90#90#
91set (UNITY_PLUGIN_DEPS "nux-0.9;libbamf;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator;atk")91set (UNITY_PLUGIN_DEPS "nux-0.9;libbamf;dee-1.0;gio-2.0;gio-unix-2.0;dbusmenu-glib-0.4;x11;libstartup-notification-1.0;gthread-2.0;indicator;atk;unity-misc")
9292
93find_package (Compiz REQUIRED)93find_package (Compiz REQUIRED)
94include (CompizPlugin)94include (CompizPlugin)
9595
=== modified file 'com.canonical.Unity.gschema.xml'
--- com.canonical.Unity.gschema.xml 2010-11-30 14:19:02 +0000
+++ com.canonical.Unity.gschema.xml 2011-02-17 10:02:19 +0000
@@ -11,4 +11,11 @@
11 <description>This is a detection key for the favorite migration script to know whether the needed migration is done or not.</description>11 <description>This is a detection key for the favorite migration script to know whether the needed migration is done or not.</description>
12 </key>12 </key>
13 </schema>13 </schema>
14 <schema path="/desktop/unity/panel/" id="com.canonical.Unity.Panel" gettext-domain="unity">
15 <key type="as" name="systray-whitelist">
16 <default>[ 'JavaEmbeddedFrame', 'Wine', 'Skype' ]</default>
17 <summary>List of client names, resource classes or wm classes to allow in the Panel's systray implementation.</summary>
18 <description>"" (empty) will not allow any tray icons, "all" will allow all tray icons, otherwise there will be an attempt to match each icon to a value here.</description>
19 </key>
20 </schema>
14</schemalist>21</schemalist>
1522
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-02-08 11:50:18 +0000
+++ services/panel-service.c 2011-02-17 10:02:19 +0000
@@ -963,10 +963,13 @@
963{963{
964 PanelServicePrivate *priv = self->priv;964 PanelServicePrivate *priv = self->priv;
965 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);965 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);
966 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);966 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
967 GtkWidget *last_menu;
967968
968 if (priv->last_entry == entry)969 if (priv->last_entry == entry)
969 return;970 return;
971
972 last_menu = GTK_WIDGET (priv->last_menu);
970 973
971 if (GTK_IS_MENU (priv->last_menu))974 if (GTK_IS_MENU (priv->last_menu))
972 {975 {
@@ -975,7 +978,6 @@
975978
976 g_signal_handler_disconnect (priv->last_menu, priv->last_menu_id);979 g_signal_handler_disconnect (priv->last_menu, priv->last_menu_id);
977 g_signal_handler_disconnect (priv->last_menu, priv->last_menu_move_id);980 g_signal_handler_disconnect (priv->last_menu, priv->last_menu_move_id);
978 gtk_menu_popdown (GTK_MENU (priv->last_menu));
979981
980 priv->last_entry = NULL;982 priv->last_entry = NULL;
981 priv->last_menu = NULL;983 priv->last_menu = NULL;
@@ -1016,6 +1018,13 @@
10161018
1017 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id);1019 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id);
1018 }1020 }
1021
1022 /* We popdown the old one last so we don't accidently send key focus back to the
1023 * active application (which will make it change colour (as state changes), which
1024 * then looks like flickering to the user.
1025 */
1026 if (GTK_MENU (last_menu))
1027 gtk_menu_popdown (GTK_MENU (last_menu));
1019}1028}
10201029
1021void1030void
10221031
=== modified file 'src/PanelHomeButton.cpp'
--- src/PanelHomeButton.cpp 2011-02-16 14:51:55 +0000
+++ src/PanelHomeButton.cpp 2011-02-17 10:02:19 +0000
@@ -32,6 +32,8 @@
32#include <pango/pangocairo.h>32#include <pango/pangocairo.h>
33#include <gtk/gtk.h>33#include <gtk/gtk.h>
3434
35#include "PanelStyle.h"
36
35#define PANEL_HEIGHT 2437#define PANEL_HEIGHT 24
36#define BUTTON_WIDTH 6638#define BUTTON_WIDTH 66
3739
@@ -41,7 +43,6 @@
41: TextureArea (NUX_TRACKER_LOCATION),43: TextureArea (NUX_TRACKER_LOCATION),
42 _util_cg (CAIRO_FORMAT_ARGB32, BUTTON_WIDTH, PANEL_HEIGHT)44 _util_cg (CAIRO_FORMAT_ARGB32, BUTTON_WIDTH, PANEL_HEIGHT)
43{45{
44 _pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/bfb.png", NULL);
45 SetMinMaxSize (BUTTON_WIDTH, PANEL_HEIGHT);46 SetMinMaxSize (BUTTON_WIDTH, PANEL_HEIGHT);
4647
47 OnMouseClick.connect (sigc::mem_fun (this, &PanelHomeButton::RecvMouseClick));48 OnMouseClick.connect (sigc::mem_fun (this, &PanelHomeButton::RecvMouseClick));
@@ -51,12 +52,12 @@
51 OnMouseLeave.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseLeave));52 OnMouseLeave.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseLeave));
52 OnMouseMove.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseMove));53 OnMouseMove.connect (sigc::mem_fun(this, &PanelHomeButton::RecvMouseMove));
5354
55 PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &PanelHomeButton::Refresh));
54 Refresh ();56 Refresh ();
55}57}
5658
57PanelHomeButton::~PanelHomeButton ()59PanelHomeButton::~PanelHomeButton ()
58{60{
59 g_object_unref (_pixbuf);
60}61}
6162
62void63void
@@ -64,14 +65,18 @@
64{65{
65 int width = BUTTON_WIDTH;66 int width = BUTTON_WIDTH;
66 int height = PANEL_HEIGHT;67 int height = PANEL_HEIGHT;
68 GdkPixbuf *pixbuf;
6769
68 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);70 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, width, height);
69 cairo_t *cr = cairo_graphics.GetContext();71 cairo_t *cr = cairo_graphics.GetContext();
70 cairo_set_line_width (cr, 1);72 cairo_set_line_width (cr, 1);
7173
72 gdk_cairo_set_source_pixbuf (cr, _pixbuf,74 pixbuf = PanelStyle::GetDefault ()->GetHomeButton ();
73 (BUTTON_WIDTH-gdk_pixbuf_get_width (_pixbuf))/2,75 gdk_cairo_set_source_pixbuf (cr, pixbuf,
74 (PANEL_HEIGHT-gdk_pixbuf_get_height (_pixbuf))/2);76 (BUTTON_WIDTH-gdk_pixbuf_get_width (pixbuf))/2,
77 (PANEL_HEIGHT-gdk_pixbuf_get_height (pixbuf))/2);
78 g_object_unref (pixbuf);
79
75 cairo_paint (cr);80 cairo_paint (cr);
7681
77 cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.2f);82 cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.2f);
@@ -102,7 +107,7 @@
102 nux::TextureLayer* texture_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),107 nux::TextureLayer* texture_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),
103 texxform, // The Oject that defines the texture wraping and coordinate transformation.108 texxform, // The Oject that defines the texture wraping and coordinate transformation.
104 nux::Color::White, // The color used to modulate the texture.109 nux::Color::White, // The color used to modulate the texture.
105 false, // Write the alpha value of the texture to the destination buffer.110 true, // Write the alpha value of the texture to the destination buffer.
106 rop // Use the given raster operation to set the blending when the layer is being rendered.111 rop // Use the given raster operation to set the blending when the layer is being rendered.
107 );112 );
108113
@@ -205,5 +210,4 @@
205 g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));210 g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));
206 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));211 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
207 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));212 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
208 g_variant_builder_add (builder, "{sv}", "have-pixbuf", g_variant_new_boolean (GDK_IS_PIXBUF (_pixbuf)));
209}213}
210214
=== modified file 'src/PanelHomeButton.h'
--- src/PanelHomeButton.h 2011-02-14 13:18:26 +0000
+++ src/PanelHomeButton.h 2011-02-17 10:02:19 +0000
@@ -51,7 +51,6 @@
5151
52private:52private:
53 nux::CairoGraphics _util_cg;53 nux::CairoGraphics _util_cg;
54 GdkPixbuf *_pixbuf;
55};54};
5655
57#endif // PANEL_HOME_BUTTON_H56#endif // PANEL_HOME_BUTTON_H
5857
=== modified file 'src/PanelIndicatorObjectEntryView.cpp'
--- src/PanelIndicatorObjectEntryView.cpp 2011-01-20 12:48:09 +0000
+++ src/PanelIndicatorObjectEntryView.cpp 2011-02-17 10:02:19 +0000
@@ -26,6 +26,7 @@
26#include "Nux/WindowCompositor.h"26#include "Nux/WindowCompositor.h"
2727
28#include "PanelIndicatorObjectEntryView.h"28#include "PanelIndicatorObjectEntryView.h"
29#include "PanelStyle.h"
2930
30#include <glib.h>31#include <glib.h>
31#include <pango/pangocairo.h>32#include <pango/pangocairo.h>
@@ -47,7 +48,8 @@
4748
48 InputArea::OnMouseDown.connect (sigc::mem_fun (this, &PanelIndicatorObjectEntryView::OnMouseDown));49 InputArea::OnMouseDown.connect (sigc::mem_fun (this, &PanelIndicatorObjectEntryView::OnMouseDown));
49 InputArea::OnMouseWheel.connect (sigc::mem_fun (this, &PanelIndicatorObjectEntryView::OnMouseWheel));50 InputArea::OnMouseWheel.connect (sigc::mem_fun (this, &PanelIndicatorObjectEntryView::OnMouseWheel));
50 51
52 PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &PanelIndicatorObjectEntryView::Refresh));
51 Refresh ();53 Refresh ();
52}54}
5355
@@ -141,6 +143,9 @@
141 int text_width = 0;143 int text_width = 0;
142 int text_height = 0;144 int text_height = 0;
143145
146 PanelStyle *style = PanelStyle::GetDefault ();
147 nux::Color textcol = style->GetTextColor ();
148 nux::Color textshadowcol = style->GetTextShadow ();
144149
145 // First lets figure out our size150 // First lets figure out our size
146 if (pixbuf && _proxy->icon_visible)151 if (pixbuf && _proxy->icon_visible)
@@ -194,6 +199,11 @@
194 cr = cairo_graphics.GetContext();199 cr = cairo_graphics.GetContext();
195 cairo_set_line_width (cr, 1);200 cairo_set_line_width (cr, 1);
196201
202 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
203 cairo_paint (cr);
204
205 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
206
197 if (_proxy->GetActive ())207 if (_proxy->GetActive ())
198 draw_menu_bg (cr, width, height);208 draw_menu_bg (cr, width, height);
199209
@@ -215,13 +225,20 @@
215 pango_cairo_update_layout (cr, layout);225 pango_cairo_update_layout (cr, layout);
216226
217 // Once for the homies that couldn't be here227 // Once for the homies that couldn't be here
218 cairo_set_source_rgb (cr, 50/255.0f, 50/255.0f, 45/255.0f);228 cairo_set_source_rgba (cr,
229 textshadowcol.GetRed (),
230 textshadowcol.GetGreen (),
231 textshadowcol.GetBlue (),
232 1.0f - textshadowcol.GetRed ());
219 cairo_move_to (cr, x, ((height - text_height)/2)-1);233 cairo_move_to (cr, x, ((height - text_height)/2)-1);
220 pango_cairo_show_layout (cr, layout);234 pango_cairo_show_layout (cr, layout);
221 cairo_stroke (cr);235 cairo_stroke (cr);
222236
223 // Once again for the homies that could237 // Once again for the homies that could
224 cairo_set_source_rgba (cr, 223/255.0f, 219/255.0f, 210/255.0f,238 cairo_set_source_rgba (cr,
239 textcol.GetRed (),
240 textcol.GetGreen (),
241 textcol.GetBlue (),
225 _proxy->label_sensitive ? 1.0f : 0.0f);242 _proxy->label_sensitive ? 1.0f : 0.0f);
226 cairo_move_to (cr, x, (height - text_height)/2);243 cairo_move_to (cr, x, (height - text_height)/2);
227 pango_cairo_show_layout (cr, layout);244 pango_cairo_show_layout (cr, layout);
@@ -244,23 +261,17 @@
244 texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);261 texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
245 262
246 nux::ROPConfig rop; 263 nux::ROPConfig rop;
247 rop.Blend = true; // Enable the blending. By default rop.Blend is false.264 rop.Blend = true;
248 rop.SrcBlend = GL_ONE; // Set the source blend factor.265 rop.SrcBlend = GL_ONE;
249 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; // Set the destination blend factor.266 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
250 nux::TextureLayer* texture_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),267 nux::TextureLayer* texture_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),
251 texxform, // The Oject that defines the texture wraping and coordinate transformation.268 texxform,
252 nux::Color::White, // The color used to modulate the texture.269 nux::Color::White,
253 false, // Write the alpha value of the texture to the destination buffer.270 true,
254 rop // Use the given raster operation to set the blending when the layer is being rendered.271 rop);
255 );
256
257 SetPaintLayer (texture_layer);272 SetPaintLayer (texture_layer);
258 273
259 // We don't need the texture anymore. Since it hasn't been reference, it ref count should still be 1.
260 // UnReference it and it will be destroyed.
261 texture2D->UnReference ();274 texture2D->UnReference ();
262
263 // The texture layer has been cloned by this object when calling SetPaintLayer. It is safe to delete it now.
264 delete texture_layer;275 delete texture_layer;
265276
266 NeedRedraw ();277 NeedRedraw ();
@@ -281,6 +292,11 @@
281 /* FIXME */292 /* FIXME */
282 double mpi = 3.14159265358979323846;293 double mpi = 3.14159265358979323846;
283294
295 PanelStyle *style = PanelStyle::GetDefault ();
296 nux::Color bgtop = style->GetBackgroundTop ();
297 nux::Color bgbot = style->GetBackgroundBottom ();
298 nux::Color line = style->GetTextShadow ();
299
284 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);300 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
285301
286 cairo_set_line_width (cr, 1.0);302 cairo_set_line_width (cr, 1.0);
@@ -294,15 +310,31 @@
294 cairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);310 cairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
295311
296 cairo_pattern_t * pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+2);312 cairo_pattern_t * pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+2);
297 cairo_pattern_add_color_stop_rgba (pat, 0.0, 83/255.0f, 82/255.0f, 78/255.0f, 1.0f);313 cairo_pattern_add_color_stop_rgba (pat, 0.0,
298 cairo_pattern_add_color_stop_rgba (pat, 1.0, 66/255.0f, 65/255.0f, 63/255.0f, 1.0f);314 bgtop.GetRed (),
315 bgtop.GetGreen (),
316 bgtop.GetBlue (),
317 1.0f - bgbot.GetRed ());
318 cairo_pattern_add_color_stop_rgba (pat, 1.0,
319 bgbot.GetRed (),
320 bgbot.GetGreen (),
321 bgbot.GetBlue (),
322 1.0f - bgtop.GetRed ());
299 cairo_set_source (cr, pat);323 cairo_set_source (cr, pat);
300 cairo_fill_preserve (cr);324 cairo_fill_preserve (cr);
301 cairo_pattern_destroy (pat);325 cairo_pattern_destroy (pat);
302326
303 pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+2);327 pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+2);
304 cairo_pattern_add_color_stop_rgba (pat, 0.0, 62/255.0f, 61/255.0f, 58/255.0f, 1.0f);328 cairo_pattern_add_color_stop_rgba (pat, 0.0,
305 cairo_pattern_add_color_stop_rgba (pat, 1.0, 54/255.0f, 54/255.0f, 52/255.0f, 1.0f);329 line.GetRed (),
330 line.GetGreen (),
331 line.GetBlue (),
332 1.0f);
333 cairo_pattern_add_color_stop_rgba (pat, 1.0,
334 line.GetRed (),
335 line.GetGreen (),
336 line.GetBlue (),
337 1.0f);
306 cairo_set_source (cr, pat);338 cairo_set_source (cr, pat);
307 cairo_stroke (cr);339 cairo_stroke (cr);
308 cairo_pattern_destroy (pat);340 cairo_pattern_destroy (pat);
@@ -318,8 +350,16 @@
318 cairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);350 cairo_arc (cr, x+xos+radius, y+yos+radius, radius, mpi, mpi*1.5);
319351
320 pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+3);352 pat = cairo_pattern_create_linear (x+xos, y, x+xos, y+height-yos*2+3);
321 cairo_pattern_add_color_stop_rgba (pat, 0.0, 92/255.0f, 90/255.0f, 85/255.0f, 1.0f);353 cairo_pattern_add_color_stop_rgba (pat, 0.0,
322 cairo_pattern_add_color_stop_rgba (pat, 1.0, 70/255.0f, 69/255.0f, 66/255.0f, 1.0f);354 bgbot.GetRed (),
355 bgbot.GetGreen (),
356 bgbot.GetBlue (),
357 1.0f);
358 cairo_pattern_add_color_stop_rgba (pat, 1.0,
359 bgbot.GetRed (),
360 bgbot.GetGreen (),
361 bgbot.GetBlue (),
362 1.0f);
323 cairo_set_source (cr, pat);363 cairo_set_source (cr, pat);
324 cairo_stroke (cr);364 cairo_stroke (cr);
325 cairo_pattern_destroy (pat);365 cairo_pattern_destroy (pat);
326366
=== modified file 'src/PanelIndicatorObjectView.cpp'
--- src/PanelIndicatorObjectView.cpp 2011-01-25 15:45:12 +0000
+++ src/PanelIndicatorObjectView.cpp 2011-02-17 10:02:19 +0000
@@ -1,4 +1,4 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-1
2/*2/*
3 * Copyright (C) 2010 Canonical Ltd3 * Copyright (C) 2010 Canonical Ltd
4 *4 *
@@ -33,6 +33,7 @@
3333
34PanelIndicatorObjectView::PanelIndicatorObjectView ()34PanelIndicatorObjectView::PanelIndicatorObjectView ()
35: View (NUX_TRACKER_LOCATION),35: View (NUX_TRACKER_LOCATION),
36 _layout (NULL),
36 _proxy (NULL),37 _proxy (NULL),
37 _entries ()38 _entries ()
38{39{
@@ -65,7 +66,9 @@
65PanelIndicatorObjectView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)66PanelIndicatorObjectView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
66{67{
67 long ret = TraverseInfo;68 long ret = TraverseInfo;
68 ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);69
70 if (_layout)
71 ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);
69 return ret;72 return ret;
70}73}
7174
@@ -79,7 +82,8 @@
79PanelIndicatorObjectView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)82PanelIndicatorObjectView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
80{83{
81 GfxContext.PushClippingRectangle (GetGeometry() );84 GfxContext.PushClippingRectangle (GetGeometry() );
82 _layout->ProcessDraw (GfxContext, force_draw);85 if (_layout)
86 _layout->ProcessDraw (GfxContext, force_draw);
83 GfxContext.PopClippingRectangle();87 GfxContext.PopClippingRectangle();
84}88}
8589
8690
=== modified file 'src/PanelMenuView.cpp'
--- src/PanelMenuView.cpp 2011-02-16 19:21:10 +0000
+++ src/PanelMenuView.cpp 2011-02-17 10:02:19 +0000
@@ -29,6 +29,7 @@
29#include "Nux/WindowCompositor.h"29#include "Nux/WindowCompositor.h"
3030
31#include "PanelMenuView.h"31#include "PanelMenuView.h"
32#include "PanelStyle.h"
3233
33#include "WindowManager.h"34#include "WindowManager.h"
3435
@@ -56,6 +57,7 @@
56 _title_tex (NULL),57 _title_tex (NULL),
57 _is_inside (false),58 _is_inside (false),
58 _is_maximized (false),59 _is_maximized (false),
60 _is_own_window (false),
59 _last_active_view (NULL)61 _last_active_view (NULL)
60{62{
61 WindowManager *win_manager;63 WindowManager *win_manager;
@@ -98,6 +100,8 @@
98 win_manager->window_restored.connect (sigc::mem_fun (this, &PanelMenuView::OnWindowRestored));100 win_manager->window_restored.connect (sigc::mem_fun (this, &PanelMenuView::OnWindowRestored));
99 win_manager->window_unmapped.connect (sigc::mem_fun (this, &PanelMenuView::OnWindowUnmapped));101 win_manager->window_unmapped.connect (sigc::mem_fun (this, &PanelMenuView::OnWindowUnmapped));
100102
103 PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &PanelMenuView::Refresh));
104
101 Refresh ();105 Refresh ();
102}106}
103107
@@ -223,14 +227,18 @@
223 nux::ColorLayer layer (nux::Color (0x00000000), true, rop);227 nux::ColorLayer layer (nux::Color (0x00000000), true, rop);
224 gPainter.PushDrawLayer (GfxContext, GetGeometry (), &layer);228 gPainter.PushDrawLayer (GfxContext, GetGeometry (), &layer);
225229
226 if (_is_maximized)230 if (_is_own_window)
231 {
232
233 }
234 else if (_is_maximized)
227 {235 {
228 if (!_is_inside && !_last_active_view)236 if (!_is_inside && !_last_active_view)
229 gPainter.PushDrawLayer (GfxContext, GetGeometry (), _title_layer);237 gPainter.PushDrawLayer (GfxContext, GetGeometry (), _title_layer);
230 }238 }
231 else239 else
232 {240 {
233 if (_is_inside || _last_active_view)241 if ((_is_inside || _last_active_view) && _entries.size ())
234 {242 {
235 if (_gradient_texture == NULL)243 if (_gradient_texture == NULL)
236 {244 {
@@ -273,9 +281,10 @@
273 }281 }
274 _gradient_texture->UnlockRect (0);282 _gradient_texture->UnlockRect (0);
275 }283 }
284 guint alpha = 0, src = 0, dest = 0;
276285
277 GfxContext.GetRenderStates ().SetBlend (true);286 GfxContext.GetRenderStates ().GetBlend (alpha, src, dest);
278 GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);287 GfxContext.GetRenderStates ().SetBlend (true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
279288
280 nux::TexCoordXForm texxform0;289 nux::TexCoordXForm texxform0;
281 nux::TexCoordXForm texxform1;290 nux::TexCoordXForm texxform1;
@@ -289,8 +298,7 @@
289 texxform1,298 texxform1,
290 nux::Color::White);299 nux::Color::White);
291300
292 GfxContext.GetRenderStates ().SetBlend(false);301 GfxContext.GetRenderStates ().SetBlend (alpha, src, dest);
293
294 // The previous blend is too aggressive on the texture and therefore there302 // The previous blend is too aggressive on the texture and therefore there
295 // is a slight loss of clarity. This fixes that303 // is a slight loss of clarity. This fixes that
296 geo.width = button_width * (factor - 1);304 geo.width = button_width * (factor - 1);
@@ -317,14 +325,17 @@
317325
318 GfxContext.PushClippingRectangle (geo);326 GfxContext.PushClippingRectangle (geo);
319327
320 if (_is_inside || _last_active_view)328 if (!_is_own_window)
321 {329 {
322 _layout->ProcessDraw (GfxContext, force_draw);330 if (_is_inside || _last_active_view)
323 }331 {
332 _layout->ProcessDraw (GfxContext, force_draw);
333 }
324334
325 if (_is_maximized)335 if (_is_maximized)
326 {336 {
327 _window_buttons->ProcessDraw (GfxContext, true);337 _window_buttons->ProcessDraw (GfxContext, true);
338 }
328 }339 }
329340
330 GfxContext.PopClippingRectangle();341 GfxContext.PopClippingRectangle();
@@ -333,7 +344,20 @@
333gchar *344gchar *
334PanelMenuView::GetActiveViewName ()345PanelMenuView::GetActiveViewName ()
335{346{
336 gchar *label = NULL;347 gchar *label = NULL;
348 BamfWindow *window;
349
350 // There's probably a better way to do this, but we really only want to ignore our own windows
351 // as there could be cases where windows like ours have menus and we don't want them to fall
352 // into this statement. Still, will investigate better ways to do this.
353 window = bamf_matcher_get_active_window (_matcher);
354 if (BAMF_IS_WINDOW (window)
355 && g_str_has_prefix (bamf_view_get_name (BAMF_VIEW (window)), "nux input"))
356 {
357 _is_own_window = true;
358 }
359 else
360 _is_own_window = false;
337361
338 if (_is_maximized)362 if (_is_maximized)
339 {363 {
@@ -448,6 +472,11 @@
448 cr = cairo_graphics.GetContext();472 cr = cairo_graphics.GetContext();
449 cairo_set_line_width (cr, 1);473 cairo_set_line_width (cr, 1);
450474
475 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
476 cairo_paint (cr);
477
478 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
479
451 x = _padding;480 x = _padding;
452 y = 0;481 y = 0;
453482
@@ -456,43 +485,27 @@
456485
457 if (label)486 if (label)
458 {487 {
488 nux::Color col = PanelStyle::GetDefault ()->GetTextColor ();
489 float red = col.GetRed (), blue = col.GetBlue (), green = col.GetGreen ();
490
459 pango_cairo_update_layout (cr, layout);491 pango_cairo_update_layout (cr, layout);
460492
461 y += (height - text_height)/2;493 y += (height - text_height)/2;
462 double startalpha = 1.0 - ((double)text_margin/(double)width);494 double startalpha = 1.0 - ((double)text_margin/(double)width);
463495
464 // Once for the homies that couldn't be here
465 if (x+text_width >= width-1)
466 {
467 linpat = cairo_pattern_create_linear (x, y-1, width-1, y-1+text_height);
468 cairo_pattern_add_color_stop_rgb (linpat, 0, 50/255.0f, 50/255.0f, 45/255.0f);
469 cairo_pattern_add_color_stop_rgb (linpat, startalpha, 50/255.0f, 50/255.0f, 45/255.0f);
470 cairo_pattern_add_color_stop_rgba (linpat, startalpha, 0, 0.0, 0.0, 0);
471 cairo_pattern_add_color_stop_rgba (linpat, 1, 0, 0.0, 0.0, 0);
472 cairo_set_source(cr, linpat);
473 cairo_pattern_destroy(linpat);
474 }
475 else
476 {
477 cairo_set_source_rgb (cr, 50/255.0f, 50/255.0f, 45/255.0f);
478 }
479 cairo_move_to (cr, x, y-1);
480 pango_cairo_show_layout (cr, layout);
481 cairo_stroke (cr);
482
483 // Once again for the homies that could496 // Once again for the homies that could
484 if (x+text_width >= width-1)497 if (x+text_width >= width-1)
485 {498 {
486 linpat = cairo_pattern_create_linear (x, y, width-1, y+text_height);499 linpat = cairo_pattern_create_linear (x, y, width-1, y+text_height);
487 cairo_pattern_add_color_stop_rgb (linpat, 0, 223/255.0f, 219/255.0f, 210/255.0f);500 cairo_pattern_add_color_stop_rgb (linpat, 0, red, green, blue);
488 cairo_pattern_add_color_stop_rgb (linpat, startalpha, 223/255.0f, 219/255.0f, 210/255.0f);501 cairo_pattern_add_color_stop_rgb (linpat, startalpha, red, green, blue);
489 cairo_pattern_add_color_stop_rgba (linpat, 1, 0, 0.0, 0.0, 0);502 cairo_pattern_add_color_stop_rgba (linpat, 1, 0, 0.0, 0.0, 0);
490 cairo_set_source(cr, linpat);503 cairo_set_source(cr, linpat);
491 cairo_pattern_destroy(linpat);504 cairo_pattern_destroy(linpat);
492 }505 }
493 else506 else
494 {507 {
495 cairo_set_source_rgb (cr, 223/255.0f, 219/255.0f, 210/255.0f);508 cairo_set_source_rgb (cr, red, green, blue);
496 }509 }
497 cairo_move_to (cr, x, y);510 cairo_move_to (cr, x, y);
498 pango_cairo_show_layout (cr, layout);511 pango_cairo_show_layout (cr, layout);
@@ -524,7 +537,7 @@
524 _title_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),537 _title_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),
525 texxform,538 texxform,
526 nux::Color::White,539 nux::Color::White,
527 false, 540 true,
528 rop);541 rop);
529542
530 543
531544
=== modified file 'src/PanelMenuView.h'
--- src/PanelMenuView.h 2011-02-08 14:18:09 +0000
+++ src/PanelMenuView.h 2011-02-17 10:02:19 +0000
@@ -106,6 +106,7 @@
106 bool _is_inside;106 bool _is_inside;
107 bool _is_grabbed;107 bool _is_grabbed;
108 bool _is_maximized; 108 bool _is_maximized;
109 bool _is_own_window;
109 PanelIndicatorObjectEntryView *_last_active_view;110 PanelIndicatorObjectEntryView *_last_active_view;
110111
111 WindowButtons * _window_buttons;112 WindowButtons * _window_buttons;
112113
=== added file 'src/PanelStyle.cpp'
--- src/PanelStyle.cpp 1970-01-01 00:00:00 +0000
+++ src/PanelStyle.cpp 2011-02-17 10:02:19 +0000
@@ -0,0 +1,274 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Mirco Müller <mirco.mueller@canonical.com>
17 * Neil Jagdish Patel <neil.patel@canonical.com>
18 */
19
20#include "config.h"
21
22#include <math.h>
23#include <gtk/gtk.h>
24
25#include <Nux/Nux.h>
26#include <NuxGraphics/GraphicsEngine.h>
27#include <NuxImage/CairoGraphics.h>
28
29#include "PanelStyle.h"
30
31static PanelStyle *_style = NULL;
32
33PanelStyle::PanelStyle ()
34: _theme_name (NULL)
35{
36 _offscreen = gtk_offscreen_window_new ();
37 gtk_widget_set_name (_offscreen, "UnityPanelWidget");
38 gtk_widget_set_size_request (_offscreen, 100, 24);
39 gtk_widget_show_all (_offscreen);
40
41 g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name",
42 G_CALLBACK (PanelStyle::OnStyleChanged), this);
43
44 Refresh ();
45}
46
47PanelStyle::~PanelStyle ()
48{
49 gtk_widget_destroy (_offscreen);
50
51 if (_style == this)
52 _style = NULL;
53
54 g_free (_theme_name);
55}
56
57PanelStyle *
58PanelStyle::GetDefault ()
59{
60 if (G_UNLIKELY (!_style))
61 _style = new PanelStyle ();
62
63 return _style;
64}
65
66void
67PanelStyle::Refresh ()
68{
69 GtkStyle* style = NULL;
70
71 if (_theme_name)
72 g_free (_theme_name);
73
74 _theme_name = NULL;
75 g_object_get (gtk_settings_get_default (), "gtk-theme-name", &_theme_name, NULL);
76
77 style = gtk_widget_get_style (_offscreen);
78
79 _text.SetRed ((float) style->text[0].red / (float) 0xffff);
80 _text.SetGreen ((float) style->text[0].green / (float) 0xffff);
81 _text.SetBlue ((float) style->text[0].blue / (float) 0xffff);
82 _text.SetAlpha (1.0f);
83
84 _text_shadow.SetRed ((float) style->dark[0].red / (float) 0xffff);
85 _text_shadow.SetGreen ((float) style->dark[0].green / (float) 0xffff);
86 _text_shadow.SetBlue ((float) style->dark[0].blue / (float) 0xffff);
87 _text_shadow.SetAlpha (1.0f);
88
89 _bg_top.SetRed ((float) style->bg[1].red / (float) 0xffff);
90 _bg_top.SetGreen ((float) style->bg[1].green / (float) 0xffff);
91 _bg_top.SetBlue ((float) style->bg[1].blue / (float) 0xffff);
92 _bg_top.SetAlpha (1.0f);
93
94 _bg_bottom.SetRed ((float) style->bg[0].red / (float) 0xffff);
95 _bg_bottom.SetGreen ((float) style->bg[0].green / (float) 0xffff);
96 _bg_bottom.SetBlue ((float) style->bg[0].blue / (float) 0xffff);
97 _bg_bottom.SetAlpha (1.0f);
98
99 changed.emit ();
100}
101
102nux::Color&
103PanelStyle::GetTextColor ()
104{
105 return _text;
106}
107
108nux::Color&
109PanelStyle::GetBackgroundTop ()
110{
111 return _bg_top;
112}
113
114nux::Color&
115PanelStyle::GetBackgroundBottom ()
116{
117 return _bg_bottom;
118}
119
120nux::Color&
121PanelStyle::GetTextShadow ()
122{
123 return _text_shadow;
124}
125
126void
127PanelStyle::OnStyleChanged (GObject* gobject,
128 GParamSpec* pspec,
129 gpointer data)
130{
131 PanelStyle* self = (PanelStyle*) data;
132
133 self->Refresh ();
134}
135
136GdkPixbuf *
137PanelStyle::GetBackground (int width, int height)
138{
139 gtk_widget_set_size_request (_offscreen, width, height);
140 gdk_window_process_updates (gtk_widget_get_window (_offscreen), TRUE);
141
142 return gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (_offscreen));
143}
144
145nux::BaseTexture *
146PanelStyle::GetWindowButton (WindowButtonType type, WindowState state)
147{
148#define ICON_LOCATION "/usr/share/themes/%s/metacity-1/%s%s.png"
149 nux::BaseTexture * texture = NULL;
150 const char *names[] = { "close", "minimize", "unmaximize" };
151 const char *states[] = { "", "_focused_prelight", "_focused_pressed" };
152
153 // I wish there was a magic bullet here, but not all themes actually set the panel to be
154 // the same style as the window titlebars (e.g. Clearlooks) so we can just grab the
155 // metacity window buttons as that would look horrible
156 if (g_strcmp0 (_theme_name, "Ambiance") == 0
157 || g_strcmp0 (_theme_name, "Radiance") == 0)
158 {
159 char *filename;
160 GdkPixbuf *pixbuf;
161 GError *error = NULL;
162
163 filename = g_strdup_printf (ICON_LOCATION, _theme_name, names[type], states[state]);
164
165 pixbuf = gdk_pixbuf_new_from_file (filename, &error);
166 if (error)
167 {
168 g_warning ("Unable to load window button %s: %s", filename, error->message);
169 g_error_free (error);
170 error = NULL;
171 }
172 else
173 texture = nux::CreateTexture2DFromPixbuf (pixbuf, true);
174
175 g_free (filename);
176 g_object_unref (pixbuf);
177 }
178 else
179 {
180 texture = GetWindowButtonForTheme (type, state);
181 }
182
183 return texture;
184}
185
186nux::BaseTexture *
187PanelStyle::GetWindowButtonForTheme (WindowButtonType type, WindowState state)
188{
189 nux::BaseTexture *texture = NULL;
190 int width = 18, height = 18;
191 float w = width/3.0f;
192 float h = height/3.0f;
193 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, 22, 22);
194 cairo_t *cr;
195 nux::Color main = _text;
196
197 if (type == WINDOW_BUTTON_CLOSE)
198 {
199 main = nux::Color (1.0f, 0.3f, 0.3f, 0.8f);
200 }
201
202 if (state == WINDOW_STATE_PRELIGHT)
203 main = main * 1.2f;
204 else if (state == WINDOW_STATE_PRESSED)
205 main = main * 0.8f;
206
207 cr = cairo_graphics.GetContext();
208 cairo_translate (cr, 0.5, 0.5);
209 cairo_set_line_width (cr, 1.5f);
210
211 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
212 cairo_paint (cr);
213
214 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
215
216 cairo_set_source_rgba (cr, main.GetRed (), main.GetGreen (), main.GetBlue (), main.GetAlpha ());
217
218 cairo_arc (cr, width/2.0f, height/2.0f, (width - 2)/2.0f, 0.0f, 360 * (M_PI/180));
219 cairo_stroke (cr);
220
221 if (type == WINDOW_BUTTON_CLOSE)
222 {
223 cairo_move_to (cr, w, h);
224 cairo_line_to (cr, width - w, height - h);
225 cairo_move_to (cr, width -w, h);
226 cairo_line_to (cr, w, height - h);
227 }
228 else if (type == WINDOW_BUTTON_MINIMIZE)
229 {
230 cairo_move_to (cr, w, height/2.0f);
231 cairo_line_to (cr, width - w, height/2.0f);
232 }
233 else
234 {
235 cairo_move_to (cr, w, h);
236 cairo_line_to (cr, width - w, h);
237 cairo_line_to (cr, width - w, height - h);
238 cairo_line_to (cr, w, height -h);
239 cairo_close_path (cr);
240 }
241
242 cairo_stroke (cr);
243
244 cairo_destroy (cr);
245
246 nux::NBitmapData* bitmap = cairo_graphics.GetBitmap();
247 texture = nux::GetThreadGLDeviceFactory ()->CreateSystemCapableTexture ();
248 texture->Update(bitmap);
249 delete bitmap;
250
251 return texture;
252}
253
254GdkPixbuf *
255PanelStyle::GetHomeButton ()
256{
257 GdkPixbuf *pixbuf = NULL;
258
259 if (g_str_has_prefix (_theme_name, "Ambiance"))
260 pixbuf = gdk_pixbuf_new_from_file (PKGDATADIR"/bfb.png", NULL);
261 else
262 pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
263 "start-here",
264 24,
265 (GtkIconLookupFlags)0,
266 NULL);
267 if (pixbuf == NULL)
268 pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
269 "distributor-logo",
270 24,
271 (GtkIconLookupFlags)0,
272 NULL);
273 return pixbuf;
274}
0275
=== added file 'src/PanelStyle.h'
--- src/PanelStyle.h 1970-01-01 00:00:00 +0000
+++ src/PanelStyle.h 2011-02-17 10:02:19 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Mirco Müller <mirco.mueller@canonical.com>
17 * Neil Jagdish Patel <neil.patel@canonical.com>
18 */
19
20#ifndef PANEL_STYLE_H
21#define PANEL_STYLE_H
22
23#include <Nux/Nux.h>
24
25#include <gtk/gtk.h>
26
27class PanelStyle : public nux::Object
28{
29 public:
30 typedef enum
31 {
32 WINDOW_BUTTON_CLOSE = 0,
33 WINDOW_BUTTON_MINIMIZE,
34 WINDOW_BUTTON_UNMAXIMIZE
35
36 } WindowButtonType;
37
38 typedef enum
39 {
40 WINDOW_STATE_NORMAL,
41 WINDOW_STATE_PRELIGHT,
42 WINDOW_STATE_PRESSED
43
44 } WindowState;
45
46 static PanelStyle * GetDefault ();
47
48 PanelStyle ();
49 ~PanelStyle ();
50
51 nux::Color& GetTextColor ();
52 nux::Color& GetBackgroundTop ();
53 nux::Color& GetBackgroundBottom ();
54 nux::Color& GetTextShadow ();
55
56 GdkPixbuf * GetBackground (int width, int height);
57
58 nux::BaseTexture * GetWindowButton (WindowButtonType type, WindowState state);
59
60 GdkPixbuf * GetHomeButton ();
61
62 sigc::signal<void> changed;
63
64 private:
65 void Refresh ();
66 static void OnStyleChanged (GObject* gobject,
67 GParamSpec* pspec,
68 gpointer data);
69 nux::BaseTexture * GetWindowButtonForTheme (WindowButtonType type, WindowState state);
70 private:
71 GtkWidget *_offscreen;
72 char *_theme_name;
73 nux::Color _text;
74 nux::Color _bg_top;
75 nux::Color _bg_bottom;
76 nux::Color _text_shadow;
77};
78
79#endif // PANEL_STYLE_H
080
=== added file 'src/PanelTray.cpp'
--- src/PanelTray.cpp 1970-01-01 00:00:00 +0000
+++ src/PanelTray.cpp 2011-02-17 10:02:19 +0000
@@ -0,0 +1,231 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#include "PanelTray.h"
20
21#define SETTINGS_NAME "com.canonical.Unity.Panel"
22#define PADDING 3
23
24PanelTray::PanelTray ()
25: _n_children (0),
26 _last_x (0),
27 _last_y (0)
28{
29 _settings = g_settings_new (SETTINGS_NAME);
30 _whitelist = g_settings_get_strv (_settings, "systray-whitelist");
31
32 _window = gtk_window_new (GTK_WINDOW_POPUP);
33 gtk_window_set_type_hint (GTK_WINDOW (_window), GDK_WINDOW_TYPE_HINT_DOCK);
34 //gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE);
35 gtk_window_set_skip_pager_hint (GTK_WINDOW (_window), TRUE);
36 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (_window), TRUE);
37 gtk_window_resize (GTK_WINDOW (_window), 1, 24);
38 gtk_window_move (GTK_WINDOW (_window), 200, 12);
39 gtk_widget_set_name (_window, "UnityPanelApplet");
40 gtk_widget_set_colormap (_window, gdk_screen_get_rgba_colormap (gdk_screen_get_default ()));
41 gtk_widget_realize (_window);
42 gdk_window_set_back_pixmap (_window->window, NULL, FALSE);
43 gtk_widget_set_app_paintable (_window, TRUE);
44 g_signal_connect (_window, "expose-event", G_CALLBACK (PanelTray::OnTrayExpose), this);
45
46 if (!g_getenv ("UNITY_PANEL_TRAY_DISABLE"))
47 {
48 _tray = na_tray_new_for_screen (gdk_screen_get_default (),
49 GTK_ORIENTATION_HORIZONTAL,
50 (NaTrayFilterCallback)FilterTrayCallback,
51 this);
52 g_signal_connect (na_tray_get_manager (_tray), "tray_icon_removed",
53 G_CALLBACK (PanelTray::OnTrayIconRemoved), this);
54
55 gtk_container_add (GTK_CONTAINER (_window), GTK_WIDGET (_tray));
56 gtk_widget_show (GTK_WIDGET (_tray));
57
58 gtk_widget_show_all (_window);
59 }
60}
61
62PanelTray::~PanelTray ()
63{
64 g_strfreev (_whitelist);
65 g_object_unref (_settings);
66}
67
68void
69PanelTray::Draw (nux::GraphicsEngine& gfx_content, bool force_draw)
70{
71 nux::Geometry geo = GetGeometry ();
72
73 if (geo.x != _last_x || geo.y != _last_y)
74 {
75 _last_x = geo.x;
76 _last_y = geo.y;
77
78 gtk_window_move (GTK_WINDOW (_window), geo.x + PADDING, geo.y);
79 }
80}
81
82Window
83PanelTray::GetTrayWindow ()
84{
85 return GDK_WINDOW_XWINDOW (_window->window);
86}
87
88void
89PanelTray::Sync ()
90{
91 SetMinMaxSize ((_n_children * 24) + (PADDING * 2), 24);
92 ComputeChildLayout ();
93
94 QueueDraw ();
95}
96
97gboolean
98PanelTray::FilterTrayCallback (NaTray *tray, NaTrayChild *icon, PanelTray *self)
99{
100 char *title;
101 char *res_name = NULL;
102 char *res_class = NULL;
103 char *name;
104 int i = 0;
105 bool accept = false;
106
107 title = na_tray_child_get_title (icon);
108 na_tray_child_get_wm_class (icon, &res_name, &res_class);
109
110 while ((name = self->_whitelist[i]))
111 {
112 if (g_strcmp0 (name, "all") == 0)
113 {
114 accept = true;
115 break;
116 }
117 else if (!name || g_strcmp0 (name, "") == 0)
118 {
119 accept = false;
120 break;
121 }
122 else if (g_str_has_prefix (title, name)
123 || g_str_has_prefix (res_name, name)
124 || g_str_has_prefix (res_class, name))
125 {
126 accept = true;
127 break;
128 }
129
130 i++;
131 }
132
133 if (accept)
134 {
135 if (na_tray_child_has_alpha (icon))
136 na_tray_child_set_composited (icon, TRUE);
137
138 self->_n_children++;
139 g_idle_add ((GSourceFunc)IdleSync, self);
140 }
141
142 g_debug ("TrayChild %s: %s %s", na_tray_child_get_title (icon), res_name, res_class);
143
144 g_free (res_name);
145 g_free (res_class);
146 g_free (title);
147
148 return accept ? TRUE : FALSE;
149}
150
151void
152PanelTray::OnTrayIconRemoved (NaTrayManager *manager, NaTrayChild *child, PanelTray *self)
153{
154 g_idle_add ((GSourceFunc)IdleSync, self);
155 self->_n_children--;
156}
157
158gboolean
159PanelTray::IdleSync (PanelTray *self)
160{
161 self->Sync ();
162 return FALSE;
163}
164
165gboolean
166PanelTray::OnTrayExpose (GtkWidget *widget, GdkEventExpose *ev, PanelTray *tray)
167{
168 cairo_t *cr = gdk_cairo_create (widget->window);
169 GtkAllocation alloc;
170
171 gtk_widget_get_allocation (widget, &alloc);
172
173 gdk_cairo_region (cr, ev->region);
174 cairo_clip (cr);
175
176 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
177 cairo_paint (cr);
178
179 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
180 cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f);
181 cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
182 cairo_fill (cr);
183
184 cairo_destroy (cr);
185
186 gtk_container_propagate_expose (GTK_CONTAINER (widget),
187 gtk_bin_get_child (GTK_BIN (widget)),
188 ev);
189
190 return FALSE;
191}
192
193//
194// We don't use these
195//
196void
197PanelTray::OnEntryAdded (IndicatorObjectEntryProxy *proxy)
198{
199
200}
201
202void
203PanelTray::OnEntryMoved (IndicatorObjectEntryProxy *proxy)
204{
205
206}
207
208void
209PanelTray::OnEntryRemoved (IndicatorObjectEntryProxy *proxy)
210{
211
212}
213
214const gchar *
215PanelTray::GetName ()
216{
217 return "PanelTray";
218}
219
220const gchar *
221PanelTray::GetChildsName ()
222{
223 return "";
224}
225
226void
227PanelTray::AddProperties (GVariantBuilder *builder)
228{
229
230}
231
0232
=== added file 'src/PanelTray.h'
--- src/PanelTray.h 1970-01-01 00:00:00 +0000
+++ src/PanelTray.h 2011-02-17 10:02:19 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#ifndef PANEL_TRAY_H
20#define PANEL_TRAY_H
21
22#include <Nux/View.h>
23#include <gtk/gtk.h>
24
25#include <gdk/gdkx.h>
26
27#include "IndicatorObjectProxy.h"
28#include "Introspectable.h"
29#include "PanelIndicatorObjectView.h"
30
31#include <unity-misc/na-tray.h>
32#include <unity-misc/na-tray-child.h>
33#include <unity-misc/na-tray-manager.h>
34
35class PanelTray : public PanelIndicatorObjectView
36{
37public:
38
39 PanelTray ();
40 ~PanelTray ();
41
42 void Draw (nux::GraphicsEngine& gfx_content, bool force_draw);
43
44 Window GetTrayWindow ();
45
46 void Sync ();
47
48 void OnEntryAdded (IndicatorObjectEntryProxy *proxy);
49 void OnEntryMoved (IndicatorObjectEntryProxy *proxy);
50 void OnEntryRemoved (IndicatorObjectEntryProxy *proxy);
51
52public:
53 int _n_children;
54 char **_whitelist;
55protected:
56 const gchar * GetName ();
57 const gchar * GetChildsName ();
58 void AddProperties (GVariantBuilder *builder);
59
60private:
61 static gboolean FilterTrayCallback (NaTray *tray, NaTrayChild *child, PanelTray *self);
62 static void OnTrayIconRemoved (NaTrayManager *manager, NaTrayChild *child, PanelTray *self);
63 static gboolean IdleSync (PanelTray *tray);
64 static gboolean OnTrayExpose (GtkWidget *widget, GdkEventExpose *ev, PanelTray *tray);
65
66private:
67 GSettings *_settings;
68 GtkWidget *_window;
69 NaTray *_tray;
70 int _last_x;
71 int _last_y;
72};
73#endif
074
=== modified file 'src/PanelView.cpp'
--- src/PanelView.cpp 2011-02-11 12:44:17 +0000
+++ src/PanelView.cpp 2011-02-17 10:02:19 +0000
@@ -32,6 +32,7 @@
32#include <glib.h>32#include <glib.h>
3333
34#include "PanelView.h"34#include "PanelView.h"
35#include "PanelStyle.h"
3536
36#include "IndicatorObjectFactoryRemote.h"37#include "IndicatorObjectFactoryRemote.h"
37#include "PanelIndicatorObjectView.h"38#include "PanelIndicatorObjectView.h"
@@ -39,8 +40,13 @@
39NUX_IMPLEMENT_OBJECT_TYPE (PanelView);40NUX_IMPLEMENT_OBJECT_TYPE (PanelView);
4041
41PanelView::PanelView (NUX_FILE_LINE_DECL)42PanelView::PanelView (NUX_FILE_LINE_DECL)
42: View (NUX_FILE_LINE_PARAM)43: View (NUX_FILE_LINE_PARAM),
44 _is_dirty (true),
45 _opacity (1.0f)
43{46{
47 _style = new PanelStyle ();
48 _style->changed.connect (sigc::mem_fun (this, &PanelView::ForceUpdateBackground));
49
44 _bg_layer = new nux::ColorLayer (nux::Color (0xff595853), true);50 _bg_layer = new nux::ColorLayer (nux::Color (0xff595853), true);
4551
46 _layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);52 _layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
@@ -55,6 +61,10 @@
55 _layout->AddView (_menu_view, 1, nux::eCenter, nux::eFull);61 _layout->AddView (_menu_view, 1, nux::eCenter, nux::eFull);
56 AddChild (_menu_view);62 AddChild (_menu_view);
5763
64 _tray = new PanelTray ();
65 _layout->AddView (_tray, 0, nux::eCenter, nux::eFull);
66 AddChild (_tray);
67
58 _remote = new IndicatorObjectFactoryRemote ();68 _remote = new IndicatorObjectFactoryRemote ();
59 _remote->OnObjectAdded.connect (sigc::mem_fun (this, &PanelView::OnObjectAdded));69 _remote->OnObjectAdded.connect (sigc::mem_fun (this, &PanelView::OnObjectAdded));
60 _remote->OnMenuPointerMoved.connect (sigc::mem_fun (this, &PanelView::OnMenuPointerMoved));70 _remote->OnMenuPointerMoved.connect (sigc::mem_fun (this, &PanelView::OnMenuPointerMoved));
@@ -64,16 +74,11 @@
6474
65PanelView::~PanelView ()75PanelView::~PanelView ()
66{76{
77 _style->UnReference ();
67 delete _remote;78 delete _remote;
68 delete _bg_layer;79 delete _bg_layer;
69}80}
7081
71PanelHomeButton *
72PanelView::HomeButton ()
73{
74 return _home_button;
75}
76
77const gchar* PanelView::GetName ()82const gchar* PanelView::GetName ()
78{83{
79 return "Panel";84 return "Panel";
@@ -152,32 +157,16 @@
152{157{
153 nux::Geometry geo = GetGeometry ();158 nux::Geometry geo = GetGeometry ();
154159
155 if (geo.width == _last_width && geo.height == _last_height)160 if (geo.width == _last_width && geo.height == _last_height && !_is_dirty)
156 return;161 return;
157162
158 _last_width = geo.width;163 _last_width = geo.width;
159 _last_height = geo.height;164 _last_height = geo.height;
160165 _is_dirty = false;
161 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, _last_width, _last_height);166
162 cairo_t *cr = cairo_graphics.GetContext();167 GdkPixbuf *pixbuf = _style->GetBackground (geo.width, geo.height);
163 cairo_set_line_width (cr, 1);168 nux::BaseTexture * texture2D = nux::CreateTexture2DFromPixbuf (pixbuf, true);
164169 g_object_unref (pixbuf);
165 cairo_pattern_t *pat = cairo_pattern_create_linear (0, 0, 0, _last_height);
166 cairo_pattern_add_color_stop_rgb (pat, 0.0f, 89/255.0f, 88/255.0f, 83/255.0f);
167 cairo_pattern_add_color_stop_rgb (pat, 1.0f, 50/255.0f, 50/255.0f, 45/255.0f);
168 cairo_set_source (cr, pat);
169 cairo_rectangle (cr, 0, 0, _last_width, _last_height);
170 cairo_fill (cr);
171 cairo_pattern_destroy (pat);
172
173 cairo_destroy (cr);
174
175 nux::NBitmapData* bitmap = cairo_graphics.GetBitmap();
176
177 nux::BaseTexture* texture2D = nux::GetThreadGLDeviceFactory ()->CreateSystemCapableTexture ();
178 texture2D->Update(bitmap);
179 delete bitmap;
180
181 nux::TexCoordXForm texxform;170 nux::TexCoordXForm texxform;
182 texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);171 texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
183 texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);172 texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
@@ -185,42 +174,78 @@
185 delete _bg_layer;174 delete _bg_layer;
186175
187 nux::ROPConfig rop;176 nux::ROPConfig rop;
188 rop.Blend = false; // Disable the blending. By default rop.Blend is false.177 rop.Blend = true;
189 rop.SrcBlend = GL_ONE; // Set the source blend factor.178 rop.SrcBlend = GL_ONE;
190 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA; // Set the destination blend factor.179 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
180 nux::Color col = nux::Color::White;
181 col.SetAlpha (_opacity);
191 182
192 _bg_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),183 _bg_layer = new nux::TextureLayer (texture2D->GetDeviceTexture(),
193 texxform, // The Oject that defines the texture wraping and coordinate transformation.184 texxform,
194 nux::Color::White, // The color used to modulate the texture.185 col,
195 true, // Write the alpha value of the texture to the destination buffer.186 true,
196 rop // Use the given raster operation to set the blending when the layer is being rendered.187 rop);
197 );
198
199 texture2D->UnReference ();188 texture2D->UnReference ();
200189
201 NeedRedraw ();190 NeedRedraw ();
202}191}
203192
193void
194PanelView::ForceUpdateBackground ()
195{
196 std::list<Area *>::iterator it;
197
198 _is_dirty = true;
199 UpdateBackground ();
200
201 std::list<Area *> my_children = _layout->GetChildren ();
202 for (it = my_children.begin(); it != my_children.end(); it++)
203 {
204 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);
205
206 view->QueueDraw ();
207 if (view->_layout == NULL)
208 continue;
209
210 std::list<Area *>::iterator it2;
211
212 std::list<Area *> its_children = view->_layout->GetChildren ();
213 for (it2 = its_children.begin(); it2 != its_children.end(); it2++)
214 {
215 PanelIndicatorObjectEntryView *entry = static_cast<PanelIndicatorObjectEntryView *> (*it2);
216 entry->QueueDraw ();
217 }
218 }
219 _home_button->QueueDraw ();
220 QueueDraw ();
221}
222
204//223//
205// Signals224// Signals
206//225//
207void226void
208PanelView::OnObjectAdded (IndicatorObjectProxy *proxy)227PanelView::OnObjectAdded (IndicatorObjectProxy *proxy)
209{228{
210 PanelIndicatorObjectView *view = new PanelIndicatorObjectView (proxy);229 PanelIndicatorObjectView *view;
211230
212 // Appmenu is treated differently as it needs to expand231 // Appmenu is treated differently as it needs to expand
213 // We could do this in a more special way, but who has the time for special?232 // We could do this in a more special way, but who has the time for special?
214 if (g_strstr_len (proxy->GetName ().c_str (), -1, "appmenu") != NULL)233 if (g_strstr_len (proxy->GetName ().c_str (), -1, "appmenu") != NULL)
234 {
235 view = _menu_view;
215 _menu_view->SetProxy (proxy);236 _menu_view->SetProxy (proxy);
237 }
216 else238 else
239 {
240 view = new PanelIndicatorObjectView (proxy);
241
217 _layout->AddView (view, 0, nux::eCenter, nux::eFull);242 _layout->AddView (view, 0, nux::eCenter, nux::eFull);
243 AddChild (view);
244 }
218245
219 _layout->SetContentDistribution (nux::eStackLeft);246 _layout->SetContentDistribution (nux::eStackLeft);
220 247
221 AddChild (view);248 ComputeChildLayout ();
222
223 this->ComputeChildLayout ();
224 NeedRedraw ();249 NeedRedraw ();
225}250}
226251
@@ -307,3 +332,61 @@
307 if (g_strcmp0 (entry_id, "") == 0)332 if (g_strcmp0 (entry_id, "") == 0)
308 _menu_view->AllMenusClosed ();333 _menu_view->AllMenusClosed ();
309}334}
335
336//
337// Useful Public Methods
338//
339PanelHomeButton *
340PanelView::HomeButton ()
341{
342 return _home_button;
343}
344
345void
346PanelView::StartFirstMenuShow ()
347{
348
349}
350
351void
352PanelView::EndFirstMenuShow ()
353{
354 std::list<Area *>::iterator it;
355
356 std::list<Area *> my_children = _layout->GetChildren ();
357 for (it = my_children.begin(); it != my_children.end(); it++)
358 {
359 PanelIndicatorObjectView *view = static_cast<PanelIndicatorObjectView *> (*it);
360
361 if (view->_layout == NULL)
362 continue;
363
364 std::list<Area *>::iterator it2;
365
366 std::list<Area *> its_children = view->_layout->GetChildren ();
367 for (it2 = its_children.begin(); it2 != its_children.end(); it2++)
368 {
369 PanelIndicatorObjectEntryView *entry = static_cast<PanelIndicatorObjectEntryView *> (*it2);
370
371 entry->Activate ();
372 return;
373 }
374 }
375}
376
377Window
378PanelView::GetTrayWindow ()
379{
380 return _tray->GetTrayWindow ();
381}
382
383void
384PanelView::SetOpacity (float opacity)
385{
386 if (_opacity == opacity)
387 return;
388
389 _opacity = opacity;
390
391 ForceUpdateBackground ();
392}
310393
=== modified file 'src/PanelView.h'
--- src/PanelView.h 2011-02-14 13:18:26 +0000
+++ src/PanelView.h 2011-02-17 10:02:19 +0000
@@ -24,10 +24,14 @@
24#include <Nux/TextureArea.h>24#include <Nux/TextureArea.h>
25#include <NuxGraphics/GraphicsEngine.h>25#include <NuxGraphics/GraphicsEngine.h>
2626
27#include <gdk/gdkx.h>
28
29#include "IndicatorObjectFactoryRemote.h"
30#include "Introspectable.h"
27#include "PanelHomeButton.h"31#include "PanelHomeButton.h"
28#include "PanelMenuView.h"32#include "PanelMenuView.h"
29#include "IndicatorObjectFactoryRemote.h"33#include "PanelTray.h"
30#include "Introspectable.h"34#include "PanelStyle.h"
3135
32class PanelView : public Introspectable, public nux::View36class PanelView : public Introspectable, public nux::View
33{37{
@@ -50,6 +54,13 @@
50 54
51 PanelHomeButton * HomeButton ();55 PanelHomeButton * HomeButton ();
5256
57 void StartFirstMenuShow ();
58 void EndFirstMenuShow ();
59
60 Window GetTrayWindow ();
61
62 void SetOpacity (float opacity);
63
53protected:64protected:
54 // Introspectable methods65 // Introspectable methods
55 const gchar * GetName ();66 const gchar * GetName ();
@@ -58,17 +69,23 @@
5869
59private:70private:
60 void UpdateBackground ();71 void UpdateBackground ();
72 void ForceUpdateBackground ();
6173
62private:74private:
63 IndicatorObjectFactoryRemote *_remote;75 IndicatorObjectFactoryRemote *_remote;
6476
65 PanelHomeButton *_home_button;77 PanelHomeButton *_home_button;
66 PanelMenuView *_menu_view;78 PanelMenuView *_menu_view;
79 PanelTray *_tray;
67 nux::AbstractPaintLayer *_bg_layer;80 nux::AbstractPaintLayer *_bg_layer;
68 nux::HLayout *_layout;81 nux::HLayout *_layout;
6982
70 int _last_width;83 int _last_width;
71 int _last_height;84 int _last_height;
85
86 PanelStyle *_style;
87 bool _is_dirty;
88 float _opacity;
72};89};
7390
74#endif // PANEL_VIEW_H91#endif // PANEL_VIEW_H
7592
=== modified file 'src/WindowButtons.cpp'
--- src/WindowButtons.cpp 2011-02-01 17:33:26 +0000
+++ src/WindowButtons.cpp 2011-02-17 10:02:19 +0000
@@ -29,33 +29,20 @@
2929
30#include <glib.h>30#include <glib.h>
3131
3232#include "PanelStyle.h"
33// FIXME: This will be all automatic in the future
34#define AMBIANCE "/usr/share/themes/Ambiance/metacity-1"
35
36enum
37{
38 BUTTON_CLOSE=0,
39 BUTTON_MINIMISE,
40 BUTTON_UNMAXIMISE
41};
42
43class WindowButton : public nux::Button33class WindowButton : public nux::Button
44{34{
45 // A single window button35 // A single window button
46public:36public:
47 WindowButton (int type)37 WindowButton (PanelStyle::WindowButtonType type)
48 : nux::Button ("X", NUX_TRACKER_LOCATION),38 : nux::Button ("X", NUX_TRACKER_LOCATION),
39 _type (type),
49 _normal_tex (NULL),40 _normal_tex (NULL),
50 _prelight_tex (NULL),41 _prelight_tex (NULL),
51 _pressed_tex (NULL)42 _pressed_tex (NULL)
52 {43 {
53 if (type == BUTTON_CLOSE)44 LoadImages ();
54 LoadImages ("close");45 PanelStyle::GetDefault ()->changed.connect (sigc::mem_fun (this, &WindowButton::LoadImages));
55 else if (type == BUTTON_MINIMISE)
56 LoadImages ("minimize");
57 else
58 LoadImages ("unmaximize");
59 }46 }
6047
61 ~WindowButton ()48 ~WindowButton ()
@@ -101,60 +88,29 @@
101 GfxContext.PopClippingRectangle();88 GfxContext.PopClippingRectangle();
102 }89 }
10390
104 void LoadImages (const char *name)91 void LoadImages ()
105 {92 {
106 //FIXME: We need to somehow be theme aware. Or, at least support the themes93 PanelStyle *style = PanelStyle::GetDefault ();
107 // we know and have a good default fallback94
108 gchar *filename;95 if (_normal_tex)
109 GError *error = NULL;96 _normal_tex->UnReference ();
110 GdkPixbuf *_normal;97 if (_prelight_tex)
111 GdkPixbuf *_prelight;98 _prelight_tex->UnReference ();
112 GdkPixbuf *_pressed;99 if (_pressed_tex)
113100 _pressed_tex->UnReference ();
114 filename = g_strdup_printf ("%s/%s.png", AMBIANCE, name);101
115 _normal = gdk_pixbuf_new_from_file (filename, &error);102 _normal_tex = style->GetWindowButton (_type, PanelStyle::WINDOW_STATE_NORMAL);
116 if (error)103 _prelight_tex = style->GetWindowButton (_type, PanelStyle::WINDOW_STATE_PRELIGHT);
117 {104 _pressed_tex = style->GetWindowButton (_type, PanelStyle::WINDOW_STATE_PRESSED);
118 g_warning ("Unable to load window button %s: %s", filename, error->message);105
119 g_error_free (error);106 if (_normal_tex)
120 error = NULL;107 SetMinMaxSize (_normal_tex->GetWidth (), _normal_tex->GetHeight ());
121 }108
122 else109 QueueDraw ();
123 _normal_tex = nux::CreateTexture2DFromPixbuf (_normal, true);
124 g_free (filename);
125 g_object_unref (_normal);
126
127 filename = g_strdup_printf ("%s/%s_focused_prelight.png", AMBIANCE, name);
128 _prelight = gdk_pixbuf_new_from_file (filename, &error);
129 if (error)
130 {
131 g_warning ("Unable to load window button %s: %s", filename, error->message);
132 g_error_free (error);
133 error = NULL;
134 }
135 else
136 _prelight_tex = nux::CreateTexture2DFromPixbuf (_prelight, true);
137 g_free (filename);
138 g_object_unref (_prelight);
139
140 filename = g_strdup_printf ("%s/%s_focused_pressed.png", AMBIANCE, name);
141 _pressed = gdk_pixbuf_new_from_file (filename, &error);
142 if (error)
143 {
144 g_warning ("Unable to load window button %s: %s", name, error->message);
145 g_error_free (error);
146 error = NULL;
147 }
148 else
149 _pressed_tex = nux::CreateTexture2DFromPixbuf (_pressed, true);
150 g_free (filename);
151 g_object_unref (_pressed);
152
153 if (_normal_tex)
154 SetMinimumSize (_normal_tex->GetWidth (), _normal_tex->GetHeight ());
155 }110 }
156111
157private:112private:
113 PanelStyle::WindowButtonType _type;
158 nux::BaseTexture *_normal_tex;114 nux::BaseTexture *_normal_tex;
159 nux::BaseTexture *_prelight_tex;115 nux::BaseTexture *_prelight_tex;
160 nux::BaseTexture *_pressed_tex;116 nux::BaseTexture *_pressed_tex;
@@ -166,19 +122,19 @@
166{122{
167 WindowButton *but;123 WindowButton *but;
168124
169 but = new WindowButton (BUTTON_CLOSE);125 but = new WindowButton (PanelStyle::WINDOW_BUTTON_CLOSE);
170 AddView (but, 0, nux::eCenter, nux::eFix);126 AddView (but, 0, nux::eCenter, nux::eFix);
171 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnCloseClicked));127 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnCloseClicked));
172 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));128 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));
173 but->OnMouseLeave.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseLeave));129 but->OnMouseLeave.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseLeave));
174130
175 but = new WindowButton (BUTTON_MINIMISE);131 but = new WindowButton (PanelStyle::WINDOW_BUTTON_MINIMIZE);
176 AddView (but, 0, nux::eCenter, nux::eFix);132 AddView (but, 0, nux::eCenter, nux::eFix);
177 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnMinimizeClicked));133 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnMinimizeClicked));
178 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));134 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));
179 but->OnMouseLeave.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseLeave));135 but->OnMouseLeave.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseLeave));
180136
181 but = new WindowButton (BUTTON_UNMAXIMISE);137 but = new WindowButton (PanelStyle::WINDOW_BUTTON_UNMAXIMIZE);
182 AddView (but, 0, nux::eCenter, nux::eFix);138 AddView (but, 0, nux::eCenter, nux::eFix);
183 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnRestoreClicked));139 but->sigClick.connect (sigc::mem_fun (this, &WindowButtons::OnRestoreClicked));
184 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));140 but->OnMouseEnter.connect (sigc::mem_fun (this, &WindowButtons::RecvMouseEnter));
185141
=== modified file 'src/unityshell.cpp'
--- src/unityshell.cpp 2011-02-16 14:51:55 +0000
+++ src/unityshell.cpp 2011-02-17 10:02:19 +0000
@@ -223,6 +223,28 @@
223}223}
224224
225bool225bool
226UnityScreen::showPanelFirstMenuKeyInitiate (CompAction *action,
227 CompAction::State state,
228 CompOption::Vector &options)
229{
230 // to receive the Terminate event
231 if (state & CompAction::StateInitKey)
232 action->setState (action->state () | CompAction::StateTermKey);
233
234 panelView->StartFirstMenuShow ();
235 return false;
236}
237
238bool
239UnityScreen::showPanelFirstMenuKeyTerminate (CompAction *action,
240 CompAction::State state,
241 CompOption::Vector &options)
242{
243 panelView->EndFirstMenuShow ();
244 return false;
245}
246
247bool
226UnityScreen::setKeyboardFocusKeyInitiate (CompAction *action,248UnityScreen::setKeyboardFocusKeyInitiate (CompAction *action,
227 CompAction::State state,249 CompAction::State state,
228 CompOption::Vector &options)250 CompOption::Vector &options)
@@ -473,6 +495,8 @@
473 case UnityshellOptions::UrgentAnimation:495 case UnityshellOptions::UrgentAnimation:
474 launcher->SetUrgentAnimation ((Launcher::UrgentAnimation) optionGetUrgentAnimation ());496 launcher->SetUrgentAnimation ((Launcher::UrgentAnimation) optionGetUrgentAnimation ());
475 break;497 break;
498 case UnityshellOptions::PanelOpacity:
499 panelView->SetOpacity (optionGetPanelOpacity ());
476 case UnityshellOptions::AutohideAnimation:500 case UnityshellOptions::AutohideAnimation:
477 launcher->SetAutoHideAnimation ((Launcher::AutoHideAnimation) optionGetAutohideAnimation ());501 launcher->SetAutoHideAnimation ((Launcher::AutoHideAnimation) optionGetAutohideAnimation ());
478 break;502 break;
@@ -558,15 +582,18 @@
558582
559 debugger = new DebugDBusInterface (this);583 debugger = new DebugDBusInterface (this);
560584
561 optionSetLauncherHideModeNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));585 optionSetLauncherHideModeNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
562 optionSetBacklightModeNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));586 optionSetBacklightModeNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
563 optionSetLaunchAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));587 optionSetLaunchAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
564 optionSetUrgentAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));588 optionSetUrgentAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
589 optionSetPanelOpacityNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
565 optionSetAutohideAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));590 optionSetAutohideAnimationNotify (boost::bind (&UnityScreen::optionChanged, this, _1, _2));
566 optionSetShowLauncherInitiate (boost::bind (&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3));591 optionSetShowLauncherInitiate (boost::bind (&UnityScreen::showLauncherKeyInitiate, this, _1, _2, _3));
567 optionSetShowLauncherTerminate (boost::bind (&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3));592 optionSetShowLauncherTerminate (boost::bind (&UnityScreen::showLauncherKeyTerminate, this, _1, _2, _3));
568 optionSetKeyboardFocusInitiate (boost::bind (&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3));593 optionSetKeyboardFocusInitiate (boost::bind (&UnityScreen::setKeyboardFocusKeyInitiate, this, _1, _2, _3));
569 //optionSetKeyboardFocusTerminate (boost::bind (&UnityScreen::setKeyboardFocusKeyTerminate, this, _1, _2, _3));594 //optionSetKeyboardFocusTerminate (boost::bind (&UnityScreen::setKeyboardFocusKeyTerminate, this, _1, _2, _3));
595 optionSetPanelFirstMenuInitiate (boost::bind (&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
596 optionSetPanelFirstMenuTerminate(boost::bind (&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
570597
571 ubus_server_register_interest (ubus_server_get_default (),598 ubus_server_register_interest (ubus_server_get_default (),
572 UBUS_LAUNCHER_EXIT_KEY_NAV,599 UBUS_LAUNCHER_EXIT_KEY_NAV,
573600
=== modified file 'src/unityshell.h'
--- src/unityshell.h 2011-02-10 21:50:31 +0000
+++ src/unityshell.h 2011-02-17 10:02:19 +0000
@@ -104,6 +104,14 @@
104 CompOption::Vector &options);104 CompOption::Vector &options);
105105
106 bool106 bool
107 showPanelFirstMenuKeyInitiate (CompAction *action,
108 CompAction::State state,
109 CompOption::Vector &options);
110 bool
111 showPanelFirstMenuKeyTerminate (CompAction *action,
112 CompAction::State state,
113 CompOption::Vector &options);
114 bool
107 setKeyboardFocusKeyInitiate (CompAction* action,115 setKeyboardFocusKeyInitiate (CompAction* action,
108 CompAction::State state,116 CompAction::State state,
109 CompOption::Vector& options);117 CompOption::Vector& options);
110118
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2011-02-10 14:34:30 +0000
+++ tests/CMakeLists.txt 2011-02-17 10:02:19 +0000
@@ -75,6 +75,8 @@
7575
76add_executable (test-panel76add_executable (test-panel
77 TestPanel.cpp77 TestPanel.cpp
78 ../src/PanelStyle.cpp
79 ../src/PanelStyle.h
78 ../src/PanelView.cpp80 ../src/PanelView.cpp
79 ../src/PanelView.h81 ../src/PanelView.h
80 ../src/PanelIndicatorObjectView.cpp82 ../src/PanelIndicatorObjectView.cpp
@@ -83,6 +85,8 @@
83 ../src/PanelIndicatorObjectEntryView.h85 ../src/PanelIndicatorObjectEntryView.h
84 ../src/PanelTitlebarGrabAreaView.h86 ../src/PanelTitlebarGrabAreaView.h
85 ../src/PanelTitlebarGrabAreaView.cpp87 ../src/PanelTitlebarGrabAreaView.cpp
88 ../src/PanelTray.cpp
89 ../src/PanelTray.h
86 ../src/IndicatorObjectFactory.h90 ../src/IndicatorObjectFactory.h
87 ../src/IndicatorObjectProxy.h91 ../src/IndicatorObjectProxy.h
88 ../src/IndicatorObjectEntryProxy.h92 ../src/IndicatorObjectEntryProxy.h
8993
=== modified file 'tests/TestPanel.cpp'
--- tests/TestPanel.cpp 2010-11-05 17:00:30 +0000
+++ tests/TestPanel.cpp 2011-02-17 10:02:19 +0000
@@ -33,8 +33,8 @@
33 nux::VLayout *layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);33 nux::VLayout *layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION);
34 PanelView *view = new PanelView ();34 PanelView *view = new PanelView ();
3535
36 view->SetMinMaxSize(1024, 24);36 //view->SetMinMaxSize(1024, 24);
37 layout->AddView(view, 1, nux::eCenter, nux::eFix);37 layout->AddView(view, 1, nux::eCenter, nux::eFull);
38 layout->SetContentDistribution(nux::eStackCenter);38 layout->SetContentDistribution(nux::eStackCenter);
3939
40 nux::GetGraphicsThread()->SetLayout (layout);40 nux::GetGraphicsThread()->SetLayout (layout);
4141
=== modified file 'unityshell.xml.in'
--- unityshell.xml.in 2011-02-16 12:57:32 +0000
+++ unityshell.xml.in 2011-02-17 10:02:19 +0000
@@ -68,11 +68,15 @@
68 <default>&lt;Super&gt;</default>68 <default>&lt;Super&gt;</default>
69 </option>69 </option>
70 <option name="keyboard_focus" type="key">70 <option name="keyboard_focus" type="key">
71 <_short>Key to put keyboard-focus on launcher</_short>71 <_short>Key to put keyboard-focus on launcher</_short>
72 <_long>Set the keyboard-focus on the launcher so it can be navigated with the cursor-keys</_long>72 <_long>Set the keyboard-focus on the launcher so it can be navigated with the cursor-keys</_long>
73 <default>&lt;Alt&gt;F1</default>73 <default>&lt;Alt&gt;F1</default>
74 </option>74 </option>
75 </group>75 <option name="panel_first_menu" type="key">
76 <_short>Key to open the first panel menu</_short>
77 <_long>Open the first menu on the panel, allowing keyboard navigation thereafter.</_long>
78 <default>F10</default>
79 </option> </group>
76 <group>80 <group>
77 <_short>Experimental</_short>81 <_short>Experimental</_short>
78 <option name="backlight_mode" type="int">82 <option name="backlight_mode" type="int">
@@ -132,6 +136,14 @@
132 <_name>Wiggle</_name>136 <_name>Wiggle</_name>
133 </desc>137 </desc>
134 </option>138 </option>
139 <option type="float" name="panel_opacity">
140 <_short>Panel Opacity</_short>
141 <_long>The opacity of the Panel background.</_long>
142 <default>1.0</default>
143 <min>0.0</min>
144 <max>1.0</max>
145 <precision>0.01</precision>
146 </option>
135 <option name="autohide_animation" type="int">147 <option name="autohide_animation" type="int">
136 <_short>Hide Animation</_short>148 <_short>Hide Animation</_short>
137 <_long>Animation played when the launcher is showing or hiding</_long>149 <_long>Animation played when the launcher is showing or hiding</_long>