Merge lp://qastaging/~psybers/do/clock-themes into lp://qastaging/do
- clock-themes
- Merge into trunk
Proposed by
Robert Dyer
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 1295 | ||||
Proposed branch: | lp://qastaging/~psybers/do/clock-themes | ||||
Merge into: | lp://qastaging/do | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp://qastaging/~psybers/do/clock-themes | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Dyer (psybers) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jason Smith (jassmith) wrote : | # |
Looks good, please merge
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ClockDockItem.cs' |
2 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ClockDockItem.cs 2009-06-30 06:33:29 +0000 |
3 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ClockDockItem.cs 2009-08-20 08:27:24 +0000 |
4 | @@ -21,6 +21,7 @@ |
5 | using System.Linq; |
6 | |
7 | using Gdk; |
8 | +using Gtk; |
9 | using Cairo; |
10 | using Mono.Unix; |
11 | |
12 | @@ -80,14 +81,23 @@ |
13 | } |
14 | } |
15 | |
16 | + string current_theme = prefs.Get<string> ("ClockTheme", "default"); |
17 | + public string CurrentTheme { |
18 | + get { return current_theme; } |
19 | + protected set { |
20 | + current_theme = value; |
21 | + prefs.Set<string> ("ClockTheme", value); |
22 | + } |
23 | + } |
24 | + |
25 | string ThemePath { |
26 | get { |
27 | - if (Directory.Exists (System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme"))) |
28 | - return System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme"); |
29 | - if (Directory.Exists ("/usr/share/gnome-do/ClockTheme")) |
30 | - return "/usr/share/gnome-do/ClockTheme"; |
31 | - if (Directory.Exists ("/usr/local/share/gnome-do/ClockTheme")) |
32 | - return "/usr/local/share/gnome-do/ClockTheme"; |
33 | + if (Directory.Exists (System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme/" + CurrentTheme))) |
34 | + return System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme/" + CurrentTheme); |
35 | + if (Directory.Exists ("/usr/share/gnome-do/ClockTheme/" + CurrentTheme)) |
36 | + return "/usr/share/gnome-do/ClockTheme/" + CurrentTheme; |
37 | + if (Directory.Exists ("/usr/local/share/gnome-do/ClockTheme/" + CurrentTheme)) |
38 | + return "/usr/local/share/gnome-do/ClockTheme/" + CurrentTheme; |
39 | return ""; |
40 | } |
41 | } |
42 | @@ -149,9 +159,9 @@ |
43 | textContext.FontSize = size / 4; |
44 | int yOffset = ShowMilitary ? textContext.FontSize / 2 : 0; |
45 | if (ShowDate) |
46 | - textContext.LeftCenteredPoint = new Gdk.Point (- size / 20, yOffset + textContext.FontSize); |
47 | + textContext.LeftCenteredPoint = new Gdk.Point (0, yOffset + textContext.FontSize); |
48 | else |
49 | - textContext.LeftCenteredPoint = new Gdk.Point (- size / 20, yOffset + size / 2 - size / 8); |
50 | + textContext.LeftCenteredPoint = new Gdk.Point (0, yOffset + size / 2 - size / 8); |
51 | |
52 | if (ShowMilitary) |
53 | textContext.Text = string.Format ("<b>{0}</b>", DateTime.Now.ToString ("HH:mm")); |
54 | @@ -161,24 +171,21 @@ |
55 | DockServices.DrawingService.TextPathAtPoint (textContext); |
56 | cr.LineWidth = 3; |
57 | cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
58 | - cr.Stroke (); |
59 | - |
60 | - DockServices.DrawingService.TextPathAtPoint (textContext); |
61 | + cr.StrokePreserve (); |
62 | cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
63 | cr.Fill (); |
64 | |
65 | // draw the date, outlined |
66 | if (ShowDate) { |
67 | textContext.FontSize = size / 5; |
68 | - textContext.LeftCenteredPoint = new Gdk.Point (-size / 20, size - textContext.FontSize); |
69 | + textContext.LeftCenteredPoint = new Gdk.Point (0, size - textContext.FontSize); |
70 | |
71 | textContext.Text = string.Format ("<b>{0}</b>", DateTime.Now.ToString ("MMM dd")); |
72 | |
73 | DockServices.DrawingService.TextPathAtPoint (textContext); |
74 | + cr.LineWidth = 2.5; |
75 | cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
76 | - cr.Stroke (); |
77 | - |
78 | - DockServices.DrawingService.TextPathAtPoint (textContext); |
79 | + cr.StrokePreserve (); |
80 | cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
81 | cr.Fill (); |
82 | } |
83 | @@ -196,9 +203,9 @@ |
84 | |
85 | textContext.Text = "<b>am</b>"; |
86 | if (ShowDate) |
87 | - textContext.LeftCenteredPoint = new Gdk.Point (0, size / 2); |
88 | + textContext.LeftCenteredPoint = new Gdk.Point (size / 10, size / 2); |
89 | else |
90 | - textContext.LeftCenteredPoint = new Gdk.Point (0, size / 8 + size / 2 + textContext.FontSize); |
91 | + textContext.LeftCenteredPoint = new Gdk.Point (size / 10, size / 8 + size / 2 + textContext.FontSize); |
92 | DockServices.DrawingService.TextPathAtPoint (textContext); |
93 | cr.Fill (); |
94 | |
95 | @@ -210,9 +217,9 @@ |
96 | |
97 | textContext.Text = "<b>pm</b>"; |
98 | if (ShowDate) |
99 | - textContext.LeftCenteredPoint = new Gdk.Point (size / 2, size / 2); |
100 | + textContext.LeftCenteredPoint = new Gdk.Point (size / 10 + size / 2, size / 2); |
101 | else |
102 | - textContext.LeftCenteredPoint = new Gdk.Point (size / 2, size / 8 + size / 2 + textContext.FontSize); |
103 | + textContext.LeftCenteredPoint = new Gdk.Point (size / 10 + size / 2, size / 8 + size / 2 + textContext.FontSize); |
104 | DockServices.DrawingService.TextPathAtPoint (textContext); |
105 | cr.Fill (); |
106 | } |
107 | @@ -226,11 +233,9 @@ |
108 | int radius = center; |
109 | |
110 | RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-drop-shadow.svg"), radius * 2); |
111 | + RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face-shadow.svg"), radius * 2); |
112 | RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face.svg"), radius * 2); |
113 | RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-marks.svg"), radius * 2); |
114 | - RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face-shadow.svg"), radius * 2); |
115 | - RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-glass.svg"), radius * 2); |
116 | - RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-frame.svg"), radius * 2); |
117 | |
118 | cr.Translate (center, center); |
119 | cr.Color = new Cairo.Color (.15, .15, .15); |
120 | @@ -245,8 +250,8 @@ |
121 | cr.Rotate (0 - minuteRotation); |
122 | |
123 | cr.Color = new Cairo.Color (0, 0, 0); |
124 | - double hourRotation = 2 * Math.PI * (DateTime.Now.Hour / 12.0) + |
125 | - Math.PI + (Math.PI / 6) * DateTime.Now.Minute / 60.0; |
126 | + double hourRotation = 2 * Math.PI * (DateTime.Now.Hour / (ShowMilitary ? 24.0 : 12.0)) + |
127 | + Math.PI + (Math.PI / (ShowMilitary ? 12.0 : 6.0)) * DateTime.Now.Minute / 60.0; |
128 | cr.Rotate (hourRotation); |
129 | cr.MoveTo (0, radius - radius * .5); |
130 | cr.LineTo (0, 0 - radius * .15); |
131 | @@ -254,6 +259,9 @@ |
132 | cr.Rotate (0 - hourRotation); |
133 | |
134 | cr.Translate (0 - center, 0 - center); |
135 | + |
136 | + RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-glass.svg"), radius * 2); |
137 | + RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-frame.svg"), radius * 2); |
138 | } |
139 | |
140 | public override void Clicked (uint button, Gdk.ModifierType state, PointD position) |
141 | @@ -262,6 +270,17 @@ |
142 | base.Clicked (button, state, position); |
143 | } |
144 | |
145 | + public void SetTheme (string theme) |
146 | + { |
147 | + if (string.IsNullOrEmpty (theme)) |
148 | + return; |
149 | + |
150 | + Services.Application.RunOnMainThread (() => { |
151 | + CurrentTheme = theme; |
152 | + RedrawIcon (); |
153 | + }); |
154 | + } |
155 | + |
156 | #region IRightClickable implementation |
157 | |
158 | public event EventHandler RemoveClicked; |
159 | @@ -276,11 +295,88 @@ |
160 | yield return new SimpleMenuButtonArgs (() => { ShowMilitary = !ShowMilitary; RedrawIcon (); }, |
161 | Catalog.GetString ("24-Hour Clock"), ShowMilitary ? "gtk-apply" : "gtk-remove"); |
162 | |
163 | - if (ShowDigital) |
164 | - yield return new SimpleMenuButtonArgs (() => { ShowDate = !ShowDate; RedrawIcon (); }, |
165 | - Catalog.GetString ("Show Date"), ShowDate ? "gtk-apply" : "gtk-remove"); |
166 | + yield return new SimpleMenuButtonArgs (() => { ShowDate = !ShowDate; RedrawIcon (); }, |
167 | + Catalog.GetString ("Show Date"), ShowDate ? "gtk-apply" : "gtk-remove", !ShowDigital); |
168 | + |
169 | + yield return new SimpleMenuButtonArgs (() => { new ClockThemeSelector (this).Show (); }, |
170 | + Catalog.GetString ("Select Theme"), "preferences-desktop-theme", ShowDigital); |
171 | } |
172 | |
173 | #endregion |
174 | } |
175 | + |
176 | + public class ClockThemeSelector : Gtk.Dialog |
177 | + { |
178 | + TreeStore labelTreeStore = new TreeStore (typeof (string)); |
179 | + TreeView labelTreeView = new TreeView (); |
180 | + |
181 | + ClockDockItem DockItem { get; set; } |
182 | + |
183 | + public ClockThemeSelector (ClockDockItem dockItem) |
184 | + { |
185 | + DockItem = dockItem; |
186 | + Title = Catalog.GetString ("Themes"); |
187 | + |
188 | + labelTreeView.Model = labelTreeStore; |
189 | + labelTreeView.HeadersVisible = false; |
190 | + labelTreeView.Selection.Changed += OnLabelSelectionChanged; |
191 | + labelTreeView.AppendColumn (Catalog.GetString ("Theme"), new CellRendererText (), "text", 0); |
192 | + |
193 | + ScrolledWindow win = new ScrolledWindow (); |
194 | + win.Add (labelTreeView); |
195 | + win.SetSizeRequest (200, 300); |
196 | + win.Show (); |
197 | + VBox.PackEnd (win); |
198 | + VBox.ShowAll (); |
199 | + AddButton ("Close", ResponseType.Close); |
200 | + |
201 | + UpdateThemeList (); |
202 | + } |
203 | + |
204 | + public void UpdateThemeList () |
205 | + { |
206 | + List<string> themes = new List<string> (); |
207 | + |
208 | + if (Directory.Exists (System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme"))) { |
209 | + DirectoryInfo root = new DirectoryInfo (System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme")); |
210 | + root.GetDirectories ().ForEach (p => themes.Add (p.Name)); |
211 | + } |
212 | + if (Directory.Exists ("/usr/share/gnome-do/ClockTheme")) { |
213 | + DirectoryInfo root = new DirectoryInfo ("/usr/share/gnome-do/ClockTheme"); |
214 | + root.GetDirectories ().ForEach (p => themes.Add (p.Name)); |
215 | + } |
216 | + if (Directory.Exists ("/usr/local/share/gnome-do/ClockTheme")) { |
217 | + DirectoryInfo root = new DirectoryInfo ("/usr/local/share/gnome-do/ClockTheme"); |
218 | + root.GetDirectories ().ForEach (p => themes.Add (p.Name)); |
219 | + } |
220 | + |
221 | + labelTreeStore.Clear (); |
222 | + |
223 | + themes.Sort (); |
224 | + |
225 | + int i = 0, selected = -1; |
226 | + themes.Distinct ().ForEach (p => { |
227 | + if (p == DockItem.CurrentTheme) |
228 | + selected = i; |
229 | + labelTreeStore.AppendValues (p); |
230 | + i++; |
231 | + }); |
232 | + |
233 | + labelTreeView.Selection.SelectPath(new TreePath("" + selected)); |
234 | + } |
235 | + |
236 | + protected virtual void OnLabelSelectionChanged (object o, System.EventArgs args) |
237 | + { |
238 | + TreeIter iter; |
239 | + TreeModel model; |
240 | + |
241 | + if (((TreeSelection)o).GetSelected (out model, out iter)) |
242 | + DockItem.SetTheme ((string) model.GetValue (iter, 0)); |
243 | + } |
244 | + |
245 | + protected override void OnResponse (ResponseType response_id) |
246 | + { |
247 | + Destroy (); |
248 | + } |
249 | + } |
250 | } |
251 | |
252 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs' |
253 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-05-23 05:26:56 +0000 |
254 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-08-20 08:19:48 +0000 |
255 | @@ -43,6 +43,7 @@ |
256 | string description, icon; |
257 | |
258 | public bool Dark { get; set; } |
259 | + public bool Disabled { get; set; } |
260 | |
261 | public virtual double IconOpacity { |
262 | get { return 1; } |
263 | @@ -126,8 +127,10 @@ |
264 | |
265 | void HandleButtonReleaseEvent(object o, ButtonReleaseEventArgs args) |
266 | { |
267 | - Action (); |
268 | - base.OnActivated (); |
269 | + if (!Disabled) { |
270 | + Action (); |
271 | + base.OnActivated (); |
272 | + } |
273 | } |
274 | |
275 | void HandleLeaveNotifyEvent(object o, LeaveNotifyEventArgs args) |
276 | @@ -150,7 +153,7 @@ |
277 | LinearGradient lg = new LinearGradient (area.X, area.Y, area.X, area.Y + area.Height); |
278 | |
279 | Cairo.Color background = (Dark) ? DockPopupMenu.BackgroundColor.ShadeColor (.7) : DockPopupMenu.BackgroundColor; |
280 | - if (hovered) { |
281 | + if (hovered && !Disabled) { |
282 | Cairo.Color high = background |
283 | .ConvertToGdk () |
284 | .SetMinimumValue (25) |
285 | @@ -177,13 +180,13 @@ |
286 | |
287 | DockServices.DrawingService.TextPathAtPoint (renderContext); |
288 | |
289 | - cr.Color = new Cairo.Color (1, 1, 1); |
290 | + cr.Color = new Cairo.Color (1, 1, 1, Disabled ? 0.5 : 1); |
291 | cr.Fill (); |
292 | } |
293 | |
294 | if (Pixbuf != null) { |
295 | CairoHelper.SetSourcePixbuf (cr, Pixbuf, WidthBuffer, (Height - Pixbuf.Height) / 2); |
296 | - cr.PaintWithAlpha (IconOpacity); |
297 | + cr.PaintWithAlpha (Disabled ? IconOpacity / 2 : IconOpacity); |
298 | } |
299 | } |
300 | } |
301 | @@ -197,6 +200,12 @@ |
302 | |
303 | public abstract void Action (); |
304 | |
305 | + public AbstractMenuButtonArgs AsDisabled () |
306 | + { |
307 | + Disabled = true; |
308 | + return this; |
309 | + } |
310 | + |
311 | public AbstractMenuButtonArgs AsDark () |
312 | { |
313 | Dark = true; |
314 | |
315 | === modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SimpleMenuButtonArgs.cs' |
316 | --- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SimpleMenuButtonArgs.cs 2009-03-01 04:24:20 +0000 |
317 | +++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SimpleMenuButtonArgs.cs 2009-08-20 08:19:48 +0000 |
318 | @@ -31,6 +31,12 @@ |
319 | this.action = action; |
320 | } |
321 | |
322 | + public SimpleMenuButtonArgs (Action action, string description, string icon, bool disabled) : base (description, icon) |
323 | + { |
324 | + this.action = action; |
325 | + Disabled = disabled; |
326 | + } |
327 | + |
328 | public override void Action () |
329 | { |
330 | action.Invoke (); |
331 | |
332 | === modified file 'data/Docky.DefaultClockTheme/Makefile.am' |
333 | --- data/Docky.DefaultClockTheme/Makefile.am 2009-02-04 06:33:40 +0000 |
334 | +++ data/Docky.DefaultClockTheme/Makefile.am 2009-08-20 08:19:48 +0000 |
335 | @@ -1,4 +1,4 @@ |
336 | -clockthemedir = $(datadir)/gnome-do/ClockTheme |
337 | +clockthemedir = $(datadir)/gnome-do/ClockTheme/default |
338 | clocktheme_DATA = clock-drop-shadow.svg \ |
339 | clock-face.svg \ |
340 | clock-glass.svg \ |
341 | @@ -6,4 +6,4 @@ |
342 | clock-frame.svg \ |
343 | clock-marks.svg |
344 | |
345 | -EXTRA_DIST = $(clocktheme_DATA) |
346 | \ No newline at end of file |
347 | +EXTRA_DIST = $(clocktheme_DATA) |
Adding semi-official theme support for the Clock docklet.
1) SimpleMenuButto nArgs now supports 'disabled' menu items. This was needed to make the popup for the clock a bit more sane, as the digital/analog settings each have their own specific items and thus the menu *was* changing quite a bit. Now it's static but just greys out items, which seems better.
2) The directory for the default clock theme was changed to a subdirectory 'default' of where it was. This was done so that new themes can be installed in the (old) ClockTheme directory.
3) Added a setting for the current theme.
4) Added a dialog to select the theme.
5) Did some minor tweaking to how the clock draws.