Merge lp:~mathijshenquet/docky/date-enhance into lp:docky

Proposed by Mathijs Henquet
Status: Needs review
Proposed branch: lp:~mathijshenquet/docky/date-enhance
Merge into: lp:docky
Diff against target: 140 lines (+37/-33)
1 file modified
StandardPlugins/Clock/src/ClockDockItem.cs (+37/-33)
To merge this branch: bzr merge lp:~mathijshenquet/docky/date-enhance
Reviewer Review Type Date Requested Status
Rico Tzschichholz Needs Fixing
Review via email: mp+36607@code.launchpad.net

Description of the change

DateTime Docklet now has better 24 hour and internationalized functionality:
 * Removed the 24 hour analog clock
 * Resized the date and time in 24 digital
 * Added a Day First gconf option to show the day of the month before the month, the users date format is probed on the first run to determain what format should b eused

Fixes Bug #593592

To post a comment you must log in.
1646. By Mathijs Henquet

Removed ui option for day first, the ShortDateFormat is now checked instead

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Please update the proposal and remove all 24-hour-analog clock related stuff (like the obsolete theme files)

review: Needs Fixing
Revision history for this message
Mathijs Henquet (mathijshenquet) wrote :

I'm on holliday right now but i'll take a look at it next monday. Thanks for taking a look at it.

Mathijs Henquet

Op 29 dec. 2010 om 21:06 heeft Rico Tzschichholz <email address hidden> het volgende geschreven:

> Review: Needs Fixing
> Please update the proposal and remove all 24-hour-analog clock related stuff (like the obsolete theme files)
> --
> https://code.launchpad.net/~mathijshenquet/docky/date-enhance/+merge/36607
> You are the owner of lp:~mathijshenquet/docky/date-enhance.

Unmerged revisions

1646. By Mathijs Henquet

Removed ui option for day first, the ShortDateFormat is now checked instead

1645. By Mathijs Henquet

DateTime Docklet now has better 24 hour and internationalized functionality:
 * Removed the 24 hour analog clock
 * Resized the date and time in 24 digital
 * Added a Day First option to show the day of the month before the month

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'StandardPlugins/Clock/src/ClockDockItem.cs'
--- StandardPlugins/Clock/src/ClockDockItem.cs 2010-08-03 02:44:47 +0000
+++ StandardPlugins/Clock/src/ClockDockItem.cs 2010-09-29 07:48:40 +0000
@@ -79,6 +79,17 @@
79 prefs.Set<bool> ("ShowDate", value);79 prefs.Set<bool> ("ShowDate", value);
80 }80 }
81 }81 }
82
83 bool day_first = prefs.Get<bool> ("DayFirst", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.StartsWith("d"));
84 public bool DayFirst {
85 get { return day_first; }
86 set {
87 if (day_first == value)
88 return;
89 day_first = value;
90 prefs.Set<bool> ("DayFirst", value);
91 }
92 }
82 93
83 string current_theme = prefs.Get<string> ("ClockTheme", "default");94 string current_theme = prefs.Get<string> ("ClockTheme", "default");
84 public string CurrentTheme {95 public string CurrentTheme {
@@ -88,7 +99,6 @@
88 return;99 return;
89 current_theme = value;100 current_theme = value;
90 prefs.Set<string> ("ClockTheme", value);101 prefs.Set<string> ("ClockTheme", value);
91 ShowMilitary = value.EndsWith ("-24");
92 CheckForThemes ();102 CheckForThemes ();
93 }103 }
94 }104 }
@@ -115,30 +125,16 @@
115 if (ShowDigital)125 if (ShowDigital)
116 return;126 return;
117 127
118 // check if we have a 24hr theme available128 // check if we have the theme available
119 bool has24hourtheme = false;129 bool hasTheme = false;
120
121 if (CurrentTheme.EndsWith ("-24") || Directory.Exists (ThemePath + "-24"))
122 has24hourtheme = true;
123
124 // check if we have a 12hr theme available
125 bool has12hourtheme = false;
126 130
127 if (!CurrentTheme.EndsWith ("-24") || Directory.Exists (ThemePath.Substring (0, ThemePath.Length - 3)))131 if (!CurrentTheme.EndsWith ("-24") || Directory.Exists (ThemePath.Substring (0, ThemePath.Length - 3)))
128 has12hourtheme = true;132 hasTheme = true;
129 133
130 // make sure military and the theme match134 if (!hasTheme)
131 if (ShowMilitary) {135 ShowMilitary = true;
132 if (!has24hourtheme)136 else if (CurrentTheme.EndsWith ("-24"))
133 ShowMilitary = false;137 CurrentTheme = CurrentTheme.Substring (0, CurrentTheme.Length - 3);
134 else if (!CurrentTheme.EndsWith ("-24"))
135 CurrentTheme = CurrentTheme + "-24";
136 } else {
137 if (!has12hourtheme)
138 ShowMilitary = true;
139 else if (CurrentTheme.EndsWith ("-24"))
140 CurrentTheme = CurrentTheme.Substring (0, CurrentTheme.Length - 3);
141 }
142 }138 }
143 139
144 public ClockDockItem ()140 public ClockDockItem ()
@@ -190,11 +186,20 @@
190186
191 protected override void PaintIconSurface (DockySurface surface)187 protected override void PaintIconSurface (DockySurface surface)
192 {188 {
193 if (ShowMilitary)189 string timeFormat = "";
194 HoverText = DateTime.Now.ToString ("ddd, MMM dd HH:mm");190
191 if (DayFirst)
192 timeFormat += "ddd dd MMM, ";
193 else
194 timeFormat += "ddd, MMM dd ";
195
196 if (ShowMilitary)
197 timeFormat += "HH:mm";
195 else198 else
196 HoverText = DateTime.Now.ToString ("ddd, MMM dd h:mm tt");199 timeFormat += "h:mm tt";
197 200
201 HoverText = DateTime.Now.ToString (timeFormat);
202
198 if (!ShowDigital)203 if (!ShowDigital)
199 MakeAnalogIcon (surface.Context, Math.Min (surface.Width, surface.Height));204 MakeAnalogIcon (surface.Context, Math.Min (surface.Width, surface.Height));
200 else if (Square)205 else if (Square)
@@ -208,10 +213,10 @@
208 Context cr = surface.Context;213 Context cr = surface.Context;
209 214
210 // useful sizes215 // useful sizes
211 int timeSize = surface.Height / 4;216 int timeSize = ShowMilitary ? surface.Height / 3 : surface.Height / 4;
212 int dateSize = surface.Height / 5;217 int dateSize = ShowMilitary ? surface.Height / 4 : surface.Height / 5;
213 int ampmSize = surface.Height / 5;218 int ampmSize = surface.Height / 5;
214 int spacing = timeSize / 2;219 int spacing = surface.Height / 8;
215 int center = surface.Height / 2;220 int center = surface.Height / 2;
216 221
217 // shared by all text222 // shared by all text
@@ -221,7 +226,6 @@
221 layout.Ellipsize = Pango.EllipsizeMode.None;226 layout.Ellipsize = Pango.EllipsizeMode.None;
222 layout.Width = Pango.Units.FromPixels (surface.Width);227 layout.Width = Pango.Units.FromPixels (surface.Width);
223 228
224
225 // draw the time, outlined229 // draw the time, outlined
226 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize);230 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize);
227 231
@@ -233,7 +237,7 @@
233 Pango.Rectangle inkRect, logicalRect;237 Pango.Rectangle inkRect, logicalRect;
234 layout.GetPixelExtents (out inkRect, out logicalRect);238 layout.GetPixelExtents (out inkRect, out logicalRect);
235 239
236 int timeYOffset = ShowMilitary ? timeSize : timeSize / 2;240 int timeYOffset = ShowMilitary ? timeSize / 4 * 3 : timeSize / 2;
237 int timeXOffset = (surface.Width - inkRect.Width) / 2;241 int timeXOffset = (surface.Width - inkRect.Width) / 2;
238 if (ShowDate)242 if (ShowDate)
239 cr.MoveTo (timeXOffset, timeYOffset);243 cr.MoveTo (timeXOffset, timeYOffset);
@@ -251,7 +255,7 @@
251 if (ShowDate) {255 if (ShowDate) {
252 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);256 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);
253 257
254 layout.SetText (DateTime.Now.ToString ("MMM dd"));258 layout.SetText (DateTime.Now.ToString (DayFirst ? "dd MMM" : "MMM dd"));
255 layout.GetPixelExtents (out inkRect, out logicalRect);259 layout.GetPixelExtents (out inkRect, out logicalRect);
256 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);260 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);
257 261
@@ -335,7 +339,7 @@
335 if (ShowDate) {339 if (ShowDate) {
336 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);340 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);
337 341
338 layout.SetText (DateTime.Now.ToString ("MMM dd"));342 layout.SetText (DateTime.Now.ToString (DayFirst ? "dd MMM" : "MMM dd"));
339 layout.GetPixelExtents (out inkRect, out logicalRect);343 layout.GetPixelExtents (out inkRect, out logicalRect);
340 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);344 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);
341 345

Subscribers

People subscribed via source and target branches

to status/vote changes: