Merge lp:~jconti/unity-greeter/hide-hidden-indicators into lp:~robert-ancell/unity-greeter/trunk

Proposed by Jason Conti
Status: Merged
Approved by: Robert Ancell
Approved revision: 138
Merged at revision: 152
Proposed branch: lp:~jconti/unity-greeter/hide-hidden-indicators
Merge into: lp:~robert-ancell/unity-greeter/trunk
Diff against target: 97 lines (+67/-12)
1 file modified
src/user-list.vala (+67/-12)
To merge this branch: bzr merge lp:~jconti/unity-greeter/hide-hidden-indicators
Reviewer Review Type Date Requested Status
Robert Ancell Pending
Review via email: mp+73455@code.launchpad.net

Description of the change

indicator-power hides its entry image if no battery information is available. This branch adds support to show/hide an indicator menuitem based on the visibility of its entry image/label. Uses a method similar to the indicator-applet.

This is related to lp:830175

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi Jason,

Thanks very much for that!

Unity greeter requires contributions to be give under the Canonical contributor agreement [1]. Could you please have a look at that and sign it if you agree?

Thanks again,
--Robert

[1] http://www.canonical.com/contributors

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/user-list.vala'
--- src/user-list.vala 2011-08-30 04:41:21 +0000
+++ src/user-list.vala 2011-08-30 22:08:24 +0000
@@ -39,6 +39,64 @@
39 }39 }
40}40}
4141
42private class IndicatorMenuItem : Gtk.MenuItem
43{
44 private Gtk.HBox _hbox;
45 private Gtk.Image _image = null;
46 private Gtk.Label _label = null;
47
48 public IndicatorMenuItem ()
49 {
50 this._hbox = new Gtk.HBox (false, 3);
51 this.add (this._hbox);
52 this._hbox.show ();
53 }
54
55 public Gtk.Image entry_image
56 {
57 get { return this._image; }
58 set
59 {
60 if (value != null && this._image == null)
61 {
62 this._image = value;
63 this._image.show.connect (this.visibility_changed_cb);
64 this._image.hide.connect (this.visibility_changed_cb);
65 this._hbox.pack_start (this._image, false, false, 0);
66 }
67 }
68 }
69
70 public Gtk.Label entry_label
71 {
72 get { return this._label; }
73 set
74 {
75 if (value != null && this._label == null)
76 {
77 this._label = value;
78 this._label.show.connect (this.visibility_changed_cb);
79 this._label.hide.connect (this.visibility_changed_cb);
80 this._hbox.pack_start (this._label, false, false, 0);
81 }
82 }
83 }
84
85 public bool has_visible_child ()
86 {
87 return (this._image != null && this._image.get_visible ()) ||
88 (this._label != null && this._label.get_visible ());
89 }
90
91 public void visibility_changed_cb (Gtk.Widget widget)
92 {
93 if (this.has_visible_child ())
94 this.show ();
95 else
96 this.hide ();
97 }
98}
99
42private class SessionMenuItem : Gtk.RadioMenuItem100private class SessionMenuItem : Gtk.RadioMenuItem
43{101{
44 public string session_name;102 public string session_name;
@@ -403,20 +461,17 @@
403461
404 private void indicator_added_cb (Indicator.ObjectEntry entry)462 private void indicator_added_cb (Indicator.ObjectEntry entry)
405 {463 {
406 var menuitem = new Gtk.MenuItem ();464 var menuitem = new IndicatorMenuItem ();
407 menuitem.show ();465
408466 menuitem.entry_image = entry.image;
409 var hbox = new Gtk.HBox (false, 3);467 menuitem.entry_label = entry.label;
410 menuitem.add (hbox);468
411 hbox.show ();
412
413 if (entry.image != null)
414 hbox.pack_start (entry.image, false, false, 0);
415 if (entry.label != null)
416 hbox.pack_start (entry.label, false, false, 0);
417 if (entry.menu != null)469 if (entry.menu != null)
418 menuitem.submenu = entry.menu;470 menuitem.submenu = entry.menu;
419471
472 if (menuitem.has_visible_child ())
473 menuitem.show();
474
420 menubar.insert (menuitem, (int) menubar.get_children ().length () - 2);475 menubar.insert (menuitem, (int) menubar.get_children ().length () - 2);
421 }476 }
422477

Subscribers

People subscribed via source and target branches

to all changes: