Merge lp:~unity-team/unity/panel-fixes-2011-03-17 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: 967
Proposed branch: lp:~unity-team/unity/panel-fixes-2011-03-17
Merge into: lp:unity
Diff against target: 556 lines (+206/-19)
17 files modified
services/panel-main.c (+29/-0)
services/panel-marshal.list (+1/-0)
services/panel-service.c (+31/-0)
src/DeviceLauncherIcon.cpp (+6/-0)
src/IndicatorObjectEntryProxy.h (+3/-1)
src/IndicatorObjectEntryProxyRemote.cpp (+10/-1)
src/IndicatorObjectEntryProxyRemote.h (+2/-0)
src/IndicatorObjectFactoryRemote.cpp (+45/-11)
src/IndicatorObjectFactoryRemote.h (+1/-0)
src/IndicatorObjectProxyRemote.cpp (+1/-1)
src/PanelIndicatorObjectEntryView.cpp (+33/-1)
src/PanelIndicatorObjectEntryView.h (+1/-0)
src/PanelMenuView.cpp (+22/-4)
src/PanelMenuView.h (+2/-0)
src/PlaceEntryHome.cpp (+15/-0)
src/PlaceEntryHome.h (+1/-0)
src/PlaceEntryRemote.cpp (+3/-0)
To merge this branch: bzr merge lp:~unity-team/unity/panel-fixes-2011-03-17
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Review via email: mp+53824@code.launchpad.net

Description of the change

Bugs attached

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'services/panel-main.c'
2--- services/panel-main.c 2011-03-17 12:02:24 +0000
3+++ services/panel-main.c 2011-03-17 14:17:24 +0000
4@@ -89,6 +89,11 @@
5 " <arg type='s' name='entry_id' />"
6 " </signal>"
7 ""
8+ " <signal name='EntryShowNowChanged'>"
9+ " <arg type='s' name='entry_id' />"
10+ " <arg type='b' name='show_now_state' />"
11+ " </signal>"
12+ ""
13 " </interface>"
14 "</node>";
15
16@@ -278,6 +283,28 @@
17 }
18
19 static void
20+on_service_entry_show_now_changed (PanelService *service,
21+ const gchar *entry_id,
22+ gboolean show_now_state,
23+ GDBusConnection *connection)
24+{
25+ GError *error = NULL;
26+ g_dbus_connection_emit_signal (connection,
27+ S_NAME,
28+ S_PATH,
29+ S_IFACE,
30+ "EntryShowNowChanged",
31+ g_variant_new ("(sb)", entry_id, show_now_state),
32+ &error);
33+
34+ if (error)
35+ {
36+ g_warning ("Unable to emit EntryShowNowChanged signal: %s", error->message);
37+ g_error_free (error);
38+ }
39+}
40+
41+static void
42 on_bus_acquired (GDBusConnection *connection,
43 const gchar *name,
44 gpointer user_data)
45@@ -300,6 +327,8 @@
46 G_CALLBACK (on_service_active_menu_pointer_motion), connection);
47 g_signal_connect (service, "entry-activate-request",
48 G_CALLBACK (on_service_entry_activate_request), connection);
49+ g_signal_connect (service, "entry-show-now-changed",
50+ G_CALLBACK (on_service_entry_show_now_changed), connection);
51
52 g_debug ("%s", G_STRFUNC);
53 g_assert (reg_id > 0);
54
55=== modified file 'services/panel-marshal.list'
56--- services/panel-marshal.list 2011-03-01 15:39:36 +0000
57+++ services/panel-marshal.list 2011-03-17 14:17:24 +0000
58@@ -1,1 +1,2 @@
59 NONE:OBJECT,POINTER,INT,INT,INT,INT
60+VOID:STRING,BOOLEAN
61
62=== modified file 'services/panel-service.c'
63--- services/panel-service.c 2011-03-14 08:51:09 +0000
64+++ services/panel-service.c 2011-03-17 14:17:24 +0000
65@@ -28,6 +28,8 @@
66 #include <gtk/gtk.h>
67 #include <gdk/gdkx.h>
68
69+#include "panel-marshal.h"
70+
71 G_DEFINE_TYPE (PanelService, panel_service, G_TYPE_OBJECT);
72
73 #define GET_PRIVATE(o) \
74@@ -68,6 +70,7 @@
75 RE_SYNC,
76 ACTIVE_MENU_POINTER_MOTION,
77 ENTRY_ACTIVATE_REQUEST,
78+ ENTRY_SHOW_NOW_CHANGED,
79 GEOMETRIES_CHANGED,
80
81 LAST_SIGNAL
82@@ -192,6 +195,15 @@
83 G_TYPE_OBJECT, G_TYPE_POINTER,
84 G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
85
86+ _service_signals[ENTRY_SHOW_NOW_CHANGED] =
87+ g_signal_new ("entry-show-now-changed",
88+ G_OBJECT_CLASS_TYPE (obj_class),
89+ G_SIGNAL_RUN_LAST,
90+ 0,
91+ NULL, NULL,
92+ panel_marshal_VOID__STRING_BOOLEAN,
93+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
94+
95
96 g_type_class_add_private (obj_class, sizeof (PanelServicePrivate));
97 }
98@@ -540,6 +552,23 @@
99 }
100
101 static void
102+on_indicator_menu_show_now_changed (IndicatorObject *object,
103+ IndicatorObjectEntry *entry,
104+ gboolean show_now_changed,
105+ PanelService *self)
106+{
107+ gchar *entry_id;
108+
109+ g_return_if_fail (PANEL_IS_SERVICE (self));
110+
111+ entry_id = g_strdup_printf ("%p", entry);
112+
113+ g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);
114+
115+ g_free (entry_id);
116+}
117+
118+static void
119 load_indicator (PanelService *self, IndicatorObject *object, const gchar *_name)
120 {
121 PanelServicePrivate *priv = self->priv;
122@@ -563,6 +592,8 @@
123 G_CALLBACK (on_entry_moved), self);
124 g_signal_connect (object, INDICATOR_OBJECT_SIGNAL_MENU_SHOW,
125 G_CALLBACK (on_indicator_menu_show), self);
126+ g_signal_connect (object, INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED,
127+ G_CALLBACK (on_indicator_menu_show_now_changed), self);
128
129 entries = indicator_object_get_entries (object);
130 for (entry = entries; entry != NULL; entry = entry->next)
131
132=== modified file 'src/DeviceLauncherIcon.cpp'
133--- src/DeviceLauncherIcon.cpp 2011-03-07 21:15:07 +0000
134+++ src/DeviceLauncherIcon.cpp 2011-03-17 14:17:24 +0000
135@@ -284,6 +284,7 @@
136 void
137 DeviceLauncherIcon::OnRemoved (GVolume *volume, DeviceLauncherIcon *self)
138 {
139+ self->_volume = NULL;
140 self->Remove ();
141 }
142
143@@ -315,6 +316,11 @@
144 {
145 GDrive *drive;
146
147+ if (!self || !G_IS_VOLUME (self->_volume))
148+ {
149+ return;
150+ }
151+
152 drive = g_volume_get_drive (self->_volume);
153 g_drive_stop_finish (drive, result, NULL);
154 g_object_unref (drive);
155
156=== modified file 'src/IndicatorObjectEntryProxy.h'
157--- src/IndicatorObjectEntryProxy.h 2011-01-11 15:48:03 +0000
158+++ src/IndicatorObjectEntryProxy.h 2011-03-17 14:17:24 +0000
159@@ -35,17 +35,19 @@
160 virtual void SetActive (bool active) = 0;
161 virtual bool GetActive () = 0;
162 virtual void ShowMenu (int x, int y, guint32 timestamp, guint32 button) = 0;
163- virtual void Scroll (int delta) = 0;
164+ virtual void Scroll (int delta) = 0;
165
166 // Signals
167 sigc::signal<void> updated;
168 sigc::signal<void, bool> active_changed;
169+ sigc::signal<void, bool> show_now_changed;
170
171 public:
172 bool label_visible;
173 bool label_sensitive;
174 bool icon_visible;
175 bool icon_sensitive;
176+ bool show_now;
177 };
178
179 #endif // INDICATOR_OBJECT_ENTRY_PROXY_H
180
181=== modified file 'src/IndicatorObjectEntryProxyRemote.cpp'
182--- src/IndicatorObjectEntryProxyRemote.cpp 2011-01-11 15:48:03 +0000
183+++ src/IndicatorObjectEntryProxyRemote.cpp 2011-03-17 14:17:24 +0000
184@@ -33,6 +33,7 @@
185 label_sensitive = true;
186 icon_visible = false;
187 icon_sensitive = true;
188+ show_now = false;
189 }
190
191
192@@ -146,6 +147,14 @@
193 updated.emit ();
194 }
195
196+void
197+IndicatorObjectEntryProxyRemote::OnShowNowChanged (bool show_now_state)
198+{
199+ show_now = show_now_state;
200+ show_now_changed.emit (show_now_state);
201+ updated.emit ();
202+}
203+
204 const char *
205 IndicatorObjectEntryProxyRemote::GetId ()
206 {
207@@ -162,4 +171,4 @@
208 IndicatorObjectEntryProxyRemote::Scroll (int delta)
209 {
210 OnScroll.emit(_id, delta);
211-}
212\ No newline at end of file
213+}
214
215=== modified file 'src/IndicatorObjectEntryProxyRemote.h'
216--- src/IndicatorObjectEntryProxyRemote.h 2011-01-11 15:48:03 +0000
217+++ src/IndicatorObjectEntryProxyRemote.h 2011-03-17 14:17:24 +0000
218@@ -58,6 +58,8 @@
219 bool __image_sensitive,
220 bool __image_visible);
221
222+ void OnShowNowChanged (bool show_now_state);
223+
224 // Signals
225 sigc::signal<void, const char *, int, int, guint32, guint32> OnShowMenuRequest;
226 sigc::signal<void, const char *, int> OnScroll;
227
228=== modified file 'src/IndicatorObjectFactoryRemote.cpp'
229--- src/IndicatorObjectFactoryRemote.cpp 2011-03-17 09:28:30 +0000
230+++ src/IndicatorObjectFactoryRemote.cpp 2011-03-17 14:17:24 +0000
231@@ -246,14 +246,14 @@
232 {
233 std::vector<IndicatorObjectProxy*>::iterator it;
234
235- for (it = _indicators.begin(); it != _indicators.end(); it++)
236+ for (it = _indicators.begin(); it != _indicators.end(); ++it)
237 {
238 IndicatorObjectProxyRemote *object = static_cast<IndicatorObjectProxyRemote *> (*it);
239- std::vector<IndicatorObjectEntryProxy*>::iterator it;
240+ std::vector<IndicatorObjectEntryProxy*>::iterator it2;
241
242- for (it = object->GetEntries ().begin(); it != object->GetEntries ().end(); it++)
243+ for (it2 = object->GetEntries ().begin(); it2 != object->GetEntries ().end(); ++it2)
244 {
245- IndicatorObjectEntryProxyRemote *entry = static_cast<IndicatorObjectEntryProxyRemote *> (*it);
246+ IndicatorObjectEntryProxyRemote *entry = static_cast<IndicatorObjectEntryProxyRemote *> (*it2);
247
248 entry->SetActive (g_strcmp0 (entry_id, entry->GetId ()) == 0);
249 }
250@@ -268,6 +268,29 @@
251 OnEntryActivateRequest.emit (entry_id);
252 }
253
254+void
255+IndicatorObjectFactoryRemote::OnEntryShowNowChanged (const char *entry_id, bool show_now_state)
256+{
257+ std::vector<IndicatorObjectProxy*>::iterator it;
258+
259+ for (it = _indicators.begin(); it != _indicators.end(); ++it)
260+ {
261+ IndicatorObjectProxyRemote *object = static_cast<IndicatorObjectProxyRemote *> (*it);
262+ std::vector<IndicatorObjectEntryProxy*>::iterator it2;
263+
264+ for (it2 = object->GetEntries ().begin(); it2 != object->GetEntries ().end(); ++it2)
265+ {
266+ IndicatorObjectEntryProxyRemote *entry = static_cast<IndicatorObjectEntryProxyRemote *> (*it2);
267+
268+ if (g_strcmp0 (entry_id, entry->GetId ()) == 0)
269+ {
270+ entry->OnShowNowChanged (show_now_state);
271+ return;
272+ }
273+ }
274+ }
275+}
276+
277 IndicatorObjectProxyRemote *
278 IndicatorObjectFactoryRemote::IndicatorForID (const char *id)
279 {
280@@ -498,13 +521,24 @@
281 remote);
282 }
283 else if (g_strcmp0 (signal_name, "ActiveMenuPointerMotion") == 0)
284- {
285- int x=0, y=0;
286-
287- g_variant_get (parameters, "(ii)", &x, &y);
288-
289- remote->OnMenuPointerMoved.emit (x, y);
290- }
291+ {
292+ int x=0, y=0;
293+
294+ g_variant_get (parameters, "(ii)", &x, &y);
295+
296+ remote->OnMenuPointerMoved.emit (x, y);
297+ }
298+ else if (g_strcmp0 (signal_name, "EntryShowNowChanged") == 0)
299+ {
300+ gchar *id = NULL;
301+ bool show_now_state;
302+
303+ g_variant_get (parameters, "(sb)", &id, &show_now_state);
304+
305+ remote->OnEntryShowNowChanged (id, show_now_state ? true : false);
306+
307+ g_free (id);
308+ }
309 }
310
311 static void
312
313=== modified file 'src/IndicatorObjectFactoryRemote.h'
314--- src/IndicatorObjectFactoryRemote.h 2011-01-11 15:48:03 +0000
315+++ src/IndicatorObjectFactoryRemote.h 2011-03-17 14:17:24 +0000
316@@ -46,6 +46,7 @@
317 void Sync (GVariant *args);
318 void OnEntryActivateRequestReceived (const char *entry_id);
319 void Reconnect ();
320+ void OnEntryShowNowChanged (const char *entry_id, bool show_now_state);
321
322 void AddProperties (GVariantBuilder *builder);
323
324
325=== modified file 'src/IndicatorObjectProxyRemote.cpp'
326--- src/IndicatorObjectProxyRemote.cpp 2011-01-11 15:48:03 +0000
327+++ src/IndicatorObjectProxyRemote.cpp 2011-03-17 14:17:24 +0000
328@@ -149,7 +149,7 @@
329
330 void
331 IndicatorObjectProxyRemote::OnScrollReceived (const char *entry_id,
332- int delta)
333+ int delta)
334 {
335 OnScroll.emit(entry_id, delta);
336 }
337
338=== modified file 'src/PanelIndicatorObjectEntryView.cpp'
339--- src/PanelIndicatorObjectEntryView.cpp 2011-03-10 13:39:09 +0000
340+++ src/PanelIndicatorObjectEntryView.cpp 2011-03-17 14:17:24 +0000
341@@ -126,9 +126,10 @@
342 PanelIndicatorObjectEntryView::Refresh ()
343 {
344 GdkPixbuf *pixbuf = _proxy->GetPixbuf ();
345- char *label = fix_string (_proxy->GetLabel ());
346+ char *label = NULL;
347 PangoLayout *layout = NULL;
348 PangoFontDescription *desc = NULL;
349+ PangoAttrList *attrs = NULL;
350 GtkSettings *settings = gtk_settings_get_default ();
351 cairo_t *cr;
352 char *font_description = NULL;
353@@ -147,6 +148,25 @@
354 nux::Color textcol = style->GetTextColor ();
355 nux::Color textshadowcol = style->GetTextShadow ();
356
357+ if (_proxy->show_now)
358+ {
359+ if (!pango_parse_markup (_proxy->GetLabel (),
360+ -1,
361+ '_',
362+ &attrs,
363+ &label,
364+ NULL,
365+ NULL))
366+ {
367+ label = g_strdup (_proxy->GetLabel ());
368+ g_debug ("failed");
369+ }
370+ }
371+ else
372+ {
373+ label = fix_string (_proxy->GetLabel ());
374+ }
375+
376 // First lets figure out our size
377 if (pixbuf && _proxy->icon_visible)
378 {
379@@ -169,6 +189,12 @@
380 pango_font_description_set_weight (desc, PANGO_WEIGHT_NORMAL);
381
382 layout = pango_cairo_create_layout (cr);
383+ if (attrs)
384+ {
385+ pango_layout_set_attributes (layout, attrs);
386+ pango_attr_list_unref (attrs);
387+ }
388+
389 pango_layout_set_font_description (layout, desc);
390 pango_layout_set_text (layout, label, -1);
391
392@@ -395,3 +421,9 @@
393
394 g_variant_builder_add (builder, "{sv}", "active", g_variant_new_boolean (_proxy->GetActive ()));
395 }
396+
397+bool
398+PanelIndicatorObjectEntryView::GetShowNow ()
399+{
400+ return _proxy ? _proxy->show_now : false;
401+}
402
403=== modified file 'src/PanelIndicatorObjectEntryView.h'
404--- src/PanelIndicatorObjectEntryView.h 2011-01-25 15:35:00 +0000
405+++ src/PanelIndicatorObjectEntryView.h 2011-03-17 14:17:24 +0000
406@@ -43,6 +43,7 @@
407 void OnMouseWheel (int x, int y, int delta, unsigned long mouse_state, unsigned long key_state);
408 void Activate ();
409 void OnActiveChanged (bool is_active);
410+ bool GetShowNow ();
411
412 const gchar * GetName ();
413 void AddProperties (GVariantBuilder *builder);
414
415=== modified file 'src/PanelMenuView.cpp'
416--- src/PanelMenuView.cpp 2011-03-13 21:40:17 +0000
417+++ src/PanelMenuView.cpp 2011-03-17 14:17:24 +0000
418@@ -65,7 +65,8 @@
419 _last_active_view (NULL),
420 _last_width (0),
421 _last_height (0),
422- _places_showing (false)
423+ _places_showing (false),
424+ _show_now_activated (false)
425 {
426 WindowManager *win_manager;
427
428@@ -255,12 +256,12 @@
429 }
430 else if (_is_maximized)
431 {
432- if (!_is_inside && !_last_active_view)
433+ if (!_is_inside && !_last_active_view && !_show_now_activated)
434 gPainter.PushDrawLayer (GfxContext, GetGeometry (), _title_layer);
435 }
436 else
437 {
438- if ((_is_inside || _last_active_view) && _entries.size ())
439+ if ((_is_inside || _last_active_view || _show_now_activated) && _entries.size ())
440 {
441 if (_gradient_texture == NULL)
442 {
443@@ -349,7 +350,7 @@
444
445 if (!_is_own_window && !_places_showing)
446 {
447- if (_is_inside || _last_active_view)
448+ if (_is_inside || _last_active_view || _show_now_activated)
449 {
450 _layout->ProcessDraw (GfxContext, force_draw);
451 }
452@@ -603,6 +604,7 @@
453 PanelIndicatorObjectEntryView *view = new PanelIndicatorObjectEntryView (proxy, 6);
454 view->active_changed.connect (sigc::mem_fun (this, &PanelMenuView::OnActiveChanged));
455 view->refreshed.connect (sigc::mem_fun (this, &PanelMenuView::OnEntryRefreshed));
456+ proxy->show_now_changed.connect (sigc::mem_fun (this, &PanelMenuView::UpdateShowNow));
457 _menu_layout->AddView (view, 0, nux::eCenter, nux::eFull);
458 _menu_layout->SetContentDistribution (nux::eStackLeft);
459
460@@ -914,3 +916,19 @@
461 self->QueueDraw ();
462 }
463
464+void
465+PanelMenuView::UpdateShowNow (bool ignore)
466+{
467+ std::vector<PanelIndicatorObjectEntryView *>::iterator it;
468+ _show_now_activated = false;
469+
470+ for (it = _entries.begin(); it != _entries.end(); it++)
471+ {
472+ PanelIndicatorObjectEntryView *view = static_cast<PanelIndicatorObjectEntryView *> (*it);
473+ if (view->GetShowNow ())
474+ _show_now_activated = true;
475+
476+ }
477+ QueueDraw ();
478+}
479+
480
481=== modified file 'src/PanelMenuView.h'
482--- src/PanelMenuView.h 2011-03-13 21:40:17 +0000
483+++ src/PanelMenuView.h 2011-03-17 14:17:24 +0000
484@@ -95,6 +95,7 @@
485 gchar * GetActiveViewName ();
486 static void OnPlaceViewShown (GVariant *data, PanelMenuView *self);
487 static void OnPlaceViewHidden (GVariant *data, PanelMenuView *self);
488+ void UpdateShowNow (bool ignore);
489
490 private:
491 BamfMatcher* _matcher;
492@@ -123,5 +124,6 @@
493 int _last_height;
494
495 bool _places_showing;
496+ bool _show_now_activated;
497 };
498 #endif
499
500=== modified file 'src/PlaceEntryHome.cpp'
501--- src/PlaceEntryHome.cpp 2011-03-15 10:39:09 +0000
502+++ src/PlaceEntryHome.cpp 2011-03-17 14:17:24 +0000
503@@ -21,6 +21,7 @@
504 #include "PlaceEntryHome.h"
505
506 #include <glib/gi18n-lib.h>
507+#include <algorithm>
508
509 class PlaceEntryGroupHome : public PlaceEntryGroup
510 {
511@@ -95,6 +96,20 @@
512 PlaceEntry *entry = static_cast<PlaceEntry *> (*i);
513 OnPlaceEntryAdded (entry);
514 }
515+
516+ place->entry_removed.connect (sigc::mem_fun (this, &PlaceEntryHome::OnPlaceEntryRemoved));
517+}
518+
519+void
520+PlaceEntryHome::OnPlaceEntryRemoved (PlaceEntry *entry)
521+{
522+ std::vector<PlaceEntry *>::iterator it;
523+
524+ it = std::find (_entries.begin (), _entries.end (), entry);
525+ if (it != _entries.end ())
526+ {
527+ _entries.erase (it);
528+ }
529 }
530
531 void
532
533=== modified file 'src/PlaceEntryHome.h'
534--- src/PlaceEntryHome.h 2011-03-15 10:39:09 +0000
535+++ src/PlaceEntryHome.h 2011-03-17 14:17:24 +0000
536@@ -79,6 +79,7 @@
537 void LoadExistingEntries ();
538 void OnPlaceAdded (Place *place);
539 void OnPlaceEntryAdded (PlaceEntry *entry);
540+ void OnPlaceEntryRemoved (PlaceEntry *entry);
541 void RefreshEntry (PlaceEntry *entry);
542
543 void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
544
545=== modified file 'src/PlaceEntryRemote.cpp'
546--- src/PlaceEntryRemote.cpp 2011-03-15 10:39:09 +0000
547+++ src/PlaceEntryRemote.cpp 2011-03-17 14:17:24 +0000
548@@ -605,6 +605,9 @@
549 DeeModelIter *iter = (DeeModelIter *)id;
550 DeeModelIter *group_iter;
551
552+ if (iter == NULL || dee_model_is_last (_results_model, iter))
553+ return;
554+
555 n_group = dee_model_get_uint32 (_results_model, iter, RESULT_GROUP_ID);
556 group_iter = dee_model_get_iter_at_row (_groups_model, n_group);
557