Merge lp:~nmurphy/do-plugins/batteryFullInvisible into lp:do-plugins/docklets

Proposed by Niall Murphy
Status: Rejected
Rejected by: Robert Dyer
Proposed branch: lp:~nmurphy/do-plugins/batteryFullInvisible
Merge into: lp:do-plugins/docklets
Diff against target: None lines
To merge this branch: bzr merge lp:~nmurphy/do-plugins/batteryFullInvisible
Reviewer Review Type Date Requested Status
Robert Dyer (community) Disapprove
Review via email: mp+8211@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Niall Murphy (nmurphy) wrote :

The battery docklet checks now if it is full enough and hides its self if over 98%.
Its a bit hacky, if the person looks in the "active docklets" bit of the options they see the docklet as inactive.
When the battery is below 98% the docklet reactivates itself.

Revision history for this message
Robert Dyer (psybers) wrote :

I tried out a variation of this. It's a no-go. We will need to implement a way for docklets to be 'active' but hidden for this.

Part of the problem is that if you manually toggle the battery docklet 'off', it can turn itself back on! That just can't happen!

review: Disapprove

Unmerged revisions

53. By Niall Murphy

modified to hide the battery notifyier when it is full

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'BatteryMonitor/src/BatteryMonitor.cs'
2--- BatteryMonitor/src/BatteryMonitor.cs 2009-06-03 15:40:26 +0000
3+++ BatteryMonitor/src/BatteryMonitor.cs 2009-07-04 09:02:56 +0000
4@@ -30,6 +30,7 @@
5 using Do.Interface;
6
7 using Docky.Interface;
8+using Docky.Core;
9
10 namespace BatteryMonitor
11 {
12@@ -162,20 +163,42 @@
13 CairoHelper.SetSourcePixbuf (cr, pbuf, x + ((pbuf.Width - size) / 2), y + ((pbuf.Height - size) / 2));
14 cr.Paint ();
15 }
16-
17+
18+ bool IsVisible ()
19+ {
20+ bool visible = false;
21+ foreach (AbstractDockletItem visibleDocklet in DockServices.DockletService.ActiveDocklets)
22+ {
23+ if (visibleDocklet.Name == "Battery Monitor"){
24+ visible = true;
25+ break;
26+ }
27+ }
28+ return visible;
29+ }
30+
31 protected override Surface MakeIconSurface (Cairo.Surface similar, int size)
32 {
33 Surface sr = similar.CreateSimilar (similar.Content, size, size);
34- using (Context cr = new Context (sr)) {
35- RenderSvgOnContext (cr, BottomSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
36- if (RoundedCapacity > 0)
37- RenderSvgOnContext (cr, string.Format (InsideSvg, RoundedCapacity) + "@" + GetType ().Assembly.FullName, size, 0, 0);
38- RenderSvgOnContext (cr, TopSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
39- if (!Services.System.GetOnBatteryPower ()) {
40- RenderSvgOnContext (cr, PluggedSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
41+ if (RoundedCapacity >= 97){
42+ if (IsVisible())
43+ DockServices.DockletService.ToggleDocklet (this); //toggle invisible
44+ }
45+ else
46+ {
47+ if (!IsVisible())
48+ DockServices.DockletService.ToggleDocklet (this); //toggle visible
49+
50+ using (Context cr = new Context (sr)) {
51+ RenderSvgOnContext (cr, BottomSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
52+ if (RoundedCapacity > 0)
53+ RenderSvgOnContext (cr, string.Format (InsideSvg, RoundedCapacity) + "@" + GetType ().Assembly.FullName, size, 0, 0);
54+ RenderSvgOnContext (cr, TopSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
55+ if (!Services.System.GetOnBatteryPower ())
56+ RenderSvgOnContext (cr, PluggedSvg + "@" + GetType ().Assembly.FullName, size, 0, 0);
57+
58 }
59 }
60-
61 return sr;
62 }
63

Subscribers

People subscribed via source and target branches