Merge lp:~marcobiscaro2112/unity/fixes-748676 into lp:unity

Proposed by Marco Biscaro on 2011-04-16
Status: Merged
Merged at revision: 1147
Proposed branch: lp:~marcobiscaro2112/unity/fixes-748676
Merge into: lp:unity
Diff against target: 182 lines (+77/-5)
4 files modified
src/PanelHomeButton.cpp (+64/-3)
src/PanelHomeButton.h (+5/-0)
src/PanelStyle.cpp (+6/-2)
src/PanelStyle.h (+2/-0)
To merge this branch: bzr merge lp:~marcobiscaro2112/unity/fixes-748676
Reviewer Review Type Date Requested Status
Didier Roche 2011-04-16 Approve on 2011-04-18
Review via email: mp+58007@code.launchpad.net

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

To post a comment you must log in.
Didier Roche (didrocks) wrote : Posted in a previous version of this proposal

Hey Marco, really awesome work! :)
I just set the branch as Need information as it needs design request, UI freeze exception and such, feel free to reput the branch in another state once we will have an answer :)

Otherwise, the code looks good!

review: Needs Information
Didier Roche (didrocks) wrote :

Looks excellent Marco!
Last week, I was planning to add the Unregistering interest in ubus but you did it meanwhile! Thanks ;)
I just took the liberty to add a one pixel offset vertically as well as I found that just moving it right was weird.

Excellent work, merging ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PanelHomeButton.cpp'
2--- src/PanelHomeButton.cpp 2011-04-12 14:34:08 +0000
3+++ src/PanelHomeButton.cpp 2011-04-16 17:41:28 +0000
4@@ -44,6 +44,7 @@
5 {
6 _urgent_count = 0;
7 _button_width = 66;
8+ _pressed = false;
9 SetMinMaxSize (_button_width, PANEL_HEIGHT);
10
11 OnMouseClick.connect (sigc::mem_fun (this, &PanelHomeButton::RecvMouseClick));
12@@ -61,6 +62,16 @@
13 (UBusCallback) &PanelHomeButton::OnLauncherIconUrgentChanged,
14 this);
15
16+ _shown_interest = ubus_server_register_interest (ubus_server_get_default (),
17+ UBUS_PLACE_VIEW_SHOWN,
18+ (UBusCallback)&PanelHomeButton::OnPlaceShown,
19+ this);
20+
21+ _hidden_interest = ubus_server_register_interest (ubus_server_get_default (),
22+ UBUS_PLACE_VIEW_HIDDEN,
23+ (UBusCallback)&PanelHomeButton::OnPlaceHidden,
24+ this);
25+
26 Refresh ();
27
28 SetDndEnabled (false, true);
29@@ -74,6 +85,14 @@
30 if (_urgent_interest != 0)
31 ubus_server_unregister_interest (ubus_server_get_default (),
32 _urgent_interest);
33+
34+ if (_shown_interest != 0)
35+ ubus_server_unregister_interest (ubus_server_get_default (),
36+ _shown_interest);
37+
38+ if (_hidden_interest != 0)
39+ ubus_server_unregister_interest (ubus_server_get_default (),
40+ _hidden_interest);
41 }
42
43 void
44@@ -112,6 +131,7 @@
45 int width = _button_width;
46 int height = PANEL_HEIGHT;
47 GdkPixbuf *pixbuf;
48+ GdkPixbuf *overlay;
49
50 SetMinMaxSize (_button_width, PANEL_HEIGHT);
51
52@@ -119,17 +139,40 @@
53 cairo_t *cr = cairo_graphics.GetContext();
54 cairo_set_line_width (cr, 1);
55
56+ /* button pressed effect */
57+ if (_pressed) {
58+ if (PanelStyle::GetDefault ()->IsAmbianceOrRadiance ()) {
59+ /* loads background panel upside-down */
60+ overlay = gdk_pixbuf_flip (PanelStyle::GetDefault ()->GetBackground (width - 2, height), FALSE);
61+ if (GDK_IS_PIXBUF (overlay)) {
62+ gdk_cairo_set_source_pixbuf (cr, overlay, 0, 0);
63+ cairo_paint (cr);
64+ g_object_unref (overlay);
65+ }
66+ } else {
67+ /* draws an translucent overlay */
68+ cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.3f);
69+ cairo_rectangle (cr, 0, 0, width-1, height);
70+ cairo_fill (cr);
71+ }
72+ }
73+
74 pixbuf = PanelStyle::GetDefault ()->GetHomeButton ();
75 if (GDK_IS_PIXBUF (pixbuf))
76 {
77+ int offset = 0;
78+
79+ /* if the button pressed, draw the icon 1 px to the right */
80+ if (_pressed) {
81+ offset = 1;
82+ }
83 gdk_cairo_set_source_pixbuf (cr, pixbuf,
84- (_button_width-gdk_pixbuf_get_width (pixbuf))/2,
85+ (_button_width-gdk_pixbuf_get_width (pixbuf))/2 + offset,
86 (PANEL_HEIGHT-gdk_pixbuf_get_height (pixbuf))/2);
87+ cairo_paint (cr);
88 g_object_unref (pixbuf);
89 }
90
91- cairo_paint (cr);
92-
93 cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.2f);
94 cairo_rectangle (cr, width-2, 2, 1, height-4);
95 cairo_fill (cr);
96@@ -293,6 +336,24 @@
97 self->Refresh ();
98 }
99
100+void
101+PanelHomeButton::OnPlaceShown (GVariant *data, gpointer user_data)
102+{
103+ PanelHomeButton *self = static_cast<PanelHomeButton *> (user_data);
104+
105+ self->_pressed = true;
106+ self->Refresh ();
107+}
108+
109+void
110+PanelHomeButton::OnPlaceHidden (GVariant *data, gpointer user_data)
111+{
112+ PanelHomeButton *self = static_cast<PanelHomeButton *> (user_data);
113+
114+ self->_pressed = false;
115+ self->Refresh ();
116+}
117+
118 void
119 PanelHomeButton::ProcessDndEnter ()
120 {
121
122=== modified file 'src/PanelHomeButton.h'
123--- src/PanelHomeButton.h 2011-04-07 20:32:56 +0000
124+++ src/PanelHomeButton.h 2011-04-16 17:41:28 +0000
125@@ -59,13 +59,18 @@
126 static void OnIconThemeChanged (GtkIconTheme *icon_theme, gpointer data);
127
128 static void OnLauncherIconUrgentChanged (GVariant *data, gpointer user_data);
129+ static void OnPlaceShown (GVariant *data, gpointer user_data);
130+ static void OnPlaceHidden (GVariant *data, gpointer user_data);
131
132 private:
133 int _button_width;
134 int _urgent_count;
135+ bool _pressed;
136
137 gulong _theme_changed_id;
138 guint _urgent_interest;
139+ guint _shown_interest;
140+ guint _hidden_interest;
141 };
142
143 #endif // PANEL_HOME_BUTTON_H
144
145=== modified file 'src/PanelStyle.cpp'
146--- src/PanelStyle.cpp 2011-03-29 12:23:52 +0000
147+++ src/PanelStyle.cpp 2011-04-16 17:41:28 +0000
148@@ -168,8 +168,7 @@
149 // I wish there was a magic bullet here, but not all themes actually set the panel to be
150 // the same style as the window titlebars (e.g. Clearlooks) so we can just grab the
151 // metacity window buttons as that would look horrible
152- if (g_strcmp0 (_theme_name, "Ambiance") == 0
153- || g_strcmp0 (_theme_name, "Radiance") == 0)
154+ if (IsAmbianceOrRadiance ())
155 {
156 char *filename;
157 GdkPixbuf *pixbuf;
158@@ -198,6 +197,11 @@
159 return texture;
160 }
161
162+bool
163+PanelStyle::IsAmbianceOrRadiance() {
164+ return g_strcmp0 (_theme_name, "Ambiance") == 0 || g_strcmp0 (_theme_name, "Radiance") == 0;
165+}
166+
167 nux::BaseTexture *
168 PanelStyle::GetWindowButtonForTheme (WindowButtonType type, WindowState state)
169 {
170
171=== modified file 'src/PanelStyle.h'
172--- src/PanelStyle.h 2011-03-29 12:23:52 +0000
173+++ src/PanelStyle.h 2011-04-16 17:41:28 +0000
174@@ -62,6 +62,8 @@
175
176 sigc::signal<void> changed;
177
178+ bool IsAmbianceOrRadiance ();
179+
180 private:
181 void Refresh ();
182 static void OnStyleChanged (GObject* gobject,