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
1=== modified file 'StandardPlugins/Clock/src/ClockDockItem.cs'
2--- StandardPlugins/Clock/src/ClockDockItem.cs 2010-08-03 02:44:47 +0000
3+++ StandardPlugins/Clock/src/ClockDockItem.cs 2010-09-29 07:48:40 +0000
4@@ -79,6 +79,17 @@
5 prefs.Set<bool> ("ShowDate", value);
6 }
7 }
8+
9+ bool day_first = prefs.Get<bool> ("DayFirst", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern.StartsWith("d"));
10+ public bool DayFirst {
11+ get { return day_first; }
12+ set {
13+ if (day_first == value)
14+ return;
15+ day_first = value;
16+ prefs.Set<bool> ("DayFirst", value);
17+ }
18+ }
19
20 string current_theme = prefs.Get<string> ("ClockTheme", "default");
21 public string CurrentTheme {
22@@ -88,7 +99,6 @@
23 return;
24 current_theme = value;
25 prefs.Set<string> ("ClockTheme", value);
26- ShowMilitary = value.EndsWith ("-24");
27 CheckForThemes ();
28 }
29 }
30@@ -115,30 +125,16 @@
31 if (ShowDigital)
32 return;
33
34- // check if we have a 24hr theme available
35- bool has24hourtheme = false;
36-
37- if (CurrentTheme.EndsWith ("-24") || Directory.Exists (ThemePath + "-24"))
38- has24hourtheme = true;
39-
40- // check if we have a 12hr theme available
41- bool has12hourtheme = false;
42+ // check if we have the theme available
43+ bool hasTheme = false;
44
45 if (!CurrentTheme.EndsWith ("-24") || Directory.Exists (ThemePath.Substring (0, ThemePath.Length - 3)))
46- has12hourtheme = true;
47+ hasTheme = true;
48
49- // make sure military and the theme match
50- if (ShowMilitary) {
51- if (!has24hourtheme)
52- ShowMilitary = false;
53- else if (!CurrentTheme.EndsWith ("-24"))
54- CurrentTheme = CurrentTheme + "-24";
55- } else {
56- if (!has12hourtheme)
57- ShowMilitary = true;
58- else if (CurrentTheme.EndsWith ("-24"))
59- CurrentTheme = CurrentTheme.Substring (0, CurrentTheme.Length - 3);
60- }
61+ if (!hasTheme)
62+ ShowMilitary = true;
63+ else if (CurrentTheme.EndsWith ("-24"))
64+ CurrentTheme = CurrentTheme.Substring (0, CurrentTheme.Length - 3);
65 }
66
67 public ClockDockItem ()
68@@ -190,11 +186,20 @@
69
70 protected override void PaintIconSurface (DockySurface surface)
71 {
72- if (ShowMilitary)
73- HoverText = DateTime.Now.ToString ("ddd, MMM dd HH:mm");
74+ string timeFormat = "";
75+
76+ if (DayFirst)
77+ timeFormat += "ddd dd MMM, ";
78+ else
79+ timeFormat += "ddd, MMM dd ";
80+
81+ if (ShowMilitary)
82+ timeFormat += "HH:mm";
83 else
84- HoverText = DateTime.Now.ToString ("ddd, MMM dd h:mm tt");
85-
86+ timeFormat += "h:mm tt";
87+
88+ HoverText = DateTime.Now.ToString (timeFormat);
89+
90 if (!ShowDigital)
91 MakeAnalogIcon (surface.Context, Math.Min (surface.Width, surface.Height));
92 else if (Square)
93@@ -208,10 +213,10 @@
94 Context cr = surface.Context;
95
96 // useful sizes
97- int timeSize = surface.Height / 4;
98- int dateSize = surface.Height / 5;
99+ int timeSize = ShowMilitary ? surface.Height / 3 : surface.Height / 4;
100+ int dateSize = ShowMilitary ? surface.Height / 4 : surface.Height / 5;
101 int ampmSize = surface.Height / 5;
102- int spacing = timeSize / 2;
103+ int spacing = surface.Height / 8;
104 int center = surface.Height / 2;
105
106 // shared by all text
107@@ -221,7 +226,6 @@
108 layout.Ellipsize = Pango.EllipsizeMode.None;
109 layout.Width = Pango.Units.FromPixels (surface.Width);
110
111-
112 // draw the time, outlined
113 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize);
114
115@@ -233,7 +237,7 @@
116 Pango.Rectangle inkRect, logicalRect;
117 layout.GetPixelExtents (out inkRect, out logicalRect);
118
119- int timeYOffset = ShowMilitary ? timeSize : timeSize / 2;
120+ int timeYOffset = ShowMilitary ? timeSize / 4 * 3 : timeSize / 2;
121 int timeXOffset = (surface.Width - inkRect.Width) / 2;
122 if (ShowDate)
123 cr.MoveTo (timeXOffset, timeYOffset);
124@@ -251,7 +255,7 @@
125 if (ShowDate) {
126 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);
127
128- layout.SetText (DateTime.Now.ToString ("MMM dd"));
129+ layout.SetText (DateTime.Now.ToString (DayFirst ? "dd MMM" : "MMM dd"));
130 layout.GetPixelExtents (out inkRect, out logicalRect);
131 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);
132
133@@ -335,7 +339,7 @@
134 if (ShowDate) {
135 layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize);
136
137- layout.SetText (DateTime.Now.ToString ("MMM dd"));
138+ layout.SetText (DateTime.Now.ToString (DayFirst ? "dd MMM" : "MMM dd"));
139 layout.GetPixelExtents (out inkRect, out logicalRect);
140 cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize);
141

Subscribers

People subscribed via source and target branches

to status/vote changes: