~ubuntu-branches/ubuntu/trusty/gnome-do/trusty-proposed

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ClockDockItem.cs

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2009-03-13 18:00:35 UTC
  • mfrom: (1.1.6 upstream) (0.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090313180035-08lo8130dasdg7n8
Tags: 0.8.1.3-0ubuntu1
* New upstream release (LP: #344578).
  + Gnome Do causes keyboard keys to be remapped (LP: #308143)
  + Docky window too small when summoned (LP: #317381)
  + Minimize/Maximize does not work on all windows (LP: #317908)
  + Docky blocks drag and drop over large areas of the screen
    (LP: #318471)
  + Docky fails to autohide properly when changing themes
    (LP: #318672)
  + Paste via ctrl+v does not work in 1st pane (LP: #318922)
  + Autostart is in wrong assembly (LP: #319114)
  + Docky has no results list (LP: #319797)
  + Docky trash applet does not reflect current state
    (LP: #320621)
  + Docky panels splits into two when over filled (LP: #324648)
  + Docky ui division is inconsistent and confusing
    (LP: #324718)
  + poor performance with two screens (LP: #323294)
  + Docky trash applet doesn't check if trash exists
    (LP: #323453)
  + docky panel splits into two when overfilled (LP: #324648)
  + Docky's UI division is inconsistent and confusing
    (LP: #324718)
  + Do crashes when using a pastebin launcher with docky
    (LP: #325178)
  + Make docky aware of icon theme switch (LP: #328721)
  + Docky doesn't update icon status for some apps that minimize
    to system tray. (LP: #329120)
  + Docky does not work properly with pull-down window
    (LP: #334663)
  + sensitivity of zooming the icons in the dock isn't
    configurable (LP: #336214)
  + Regression: In 0.8.1, "Request attention" is no longer
    indicated (LP: #337594)
  + Clock's Calendar mode auto-hides when leaving the bounds of
    the original dock (LP: #337783)
  + gnome-do does not notice change of icon theme (LP: #204368)
  + Thumbnails are never displayed when files have spaces in
    their names (LP: #311551)
  + Open improperly escapes URLs. (LP: #317416)
  + Docky: Right-click dialog appears on wrong monitor
    (LP: #319062)
  + Dragging items off Docky possible in summon mode
    (LP: #319452)
  + Docky shows icon according to the filename (LP: #320892)
  + Mouse click inactive when Do(cky) is summoned (LP: #324937)
  + Docky trash don't have a right-click menu (LP: #317947)
  + Polish docky's window name labels (LP: #318487)
  + Docky: Scroll on window icon should switch between windows
    of that app (LP: #319805)
  + Docky does not preserve window stack (z?) order when
    switching apps by clicking on app icon (LP: #326661)
  + Docky window switching should be easier. (LP: #327079)
  + Color of indicators on Docky cannot be changed
    (LP: #332936)
  + Do's ResultWindow is using wrong text color (LP: #288771)
  + Docky won't unhide after rev 1053 (LP: #337113)
  + Do's icon label in Docky should be "GNOME Do" instead of
    "Summon GNOME Do" (LP: #338496)
* Build against gtk, gnome mono packages from Experimental.
* debian/control:
  + Bump versioned dep on libgtk2.0-cil to ensure
    Gdk.Screen.IsComposited exists
  + Add libwnck2.20-cil build-dep
  + Add librsvg2-2.18-cil build-dep
  + gnome-sharp2 transition.
* debian/patches/03_show_in_all_DEs
  + Drop; fixed in new upstream
* debian/gnome-do.1
  + Update for new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  
 
2
//  Copyright (C) 2009 GNOME Do
 
3
// 
 
4
//  This program is free software: you can redistribute it and/or modify
 
5
//  it under the terms of the GNU General Public License as published by
 
6
//  the Free Software Foundation, either version 3 of the License, or
 
7
//  (at your option) any later version.
 
8
// 
 
9
//  This program is distributed in the hope that it will be useful,
 
10
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
//  GNU General Public License for more details.
 
13
// 
 
14
//  You should have received a copy of the GNU General Public License
 
15
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
// 
 
17
 
 
18
using System;
 
19
using System.Collections.Generic;
 
20
using System.IO;
 
21
using System.Linq;
 
22
 
 
23
using Gdk;
 
24
using Cairo;
 
25
using Mono.Unix;
 
26
 
 
27
using Do.Interface;
 
28
using Do.Interface.CairoUtils;
 
29
using Do.Platform;
 
30
 
 
31
using Docky.Interface.Painters;
 
32
 
 
33
namespace Docky.Interface
 
34
{
 
35
        
 
36
        
 
37
        public class ClockDockItem : AbstractDockletItem
 
38
        {
 
39
                int minute;
 
40
                CalendarPainter cal_painter;
 
41
                
 
42
                public override string Name {
 
43
                        get {
 
44
                                return "Clock";
 
45
                        }
 
46
                }
 
47
                
 
48
                public override ScalingType ScalingType {
 
49
                        get {
 
50
                                return ScalingType.HighLow;
 
51
                        }
 
52
                }
 
53
                
 
54
                string ThemePath {
 
55
                        get {
 
56
                                if (Directory.Exists (System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme")))
 
57
                                        return System.IO.Path.Combine (Services.Paths.UserDataDirectory, "ClockTheme");
 
58
                                if (Directory.Exists ("/usr/share/gnome-do/ClockTheme"))
 
59
                                        return "/usr/share/gnome-do/ClockTheme";
 
60
                                if (Directory.Exists ("/usr/local/share/gnome-do/ClockTheme"))
 
61
                                        return "/usr/local/share/gnome-do/ClockTheme";
 
62
                                return "";
 
63
                        }
 
64
                }
 
65
                
 
66
                public ClockDockItem()
 
67
                {
 
68
                        cal_painter = new CalendarPainter (this);
 
69
                        Core.DockServices.PainterService.RegisterPainter (cal_painter);
 
70
                        GLib.Timeout.Add (1000, ClockUpdateTimer);
 
71
                }
 
72
                
 
73
                bool ClockUpdateTimer ()
 
74
                {
 
75
                        if (minute != DateTime.UtcNow.Minute) {
 
76
                                SetText (DateTime.Now.ToString ("ddd, MMM dd h:mm tt"));
 
77
                                RedrawIcon ();
 
78
                                minute = DateTime.UtcNow.Minute;
 
79
                        }
 
80
                        return true;
 
81
                }
 
82
                
 
83
                protected override Pixbuf GetSurfacePixbuf (int size)
 
84
                {
 
85
                        return null;
 
86
                }
 
87
                
 
88
                void RenderFileOntoContext (Context cr, string file, int size)
 
89
                {
 
90
                        if (!File.Exists (file))
 
91
                                return;
 
92
                        
 
93
                        Gdk.Pixbuf pbuf = Rsvg.Tool.PixbufFromFileAtSize (file, size, size);
 
94
                        CairoHelper.SetSourcePixbuf (cr, pbuf, 0, 0);
 
95
                        cr.Paint ();
 
96
                        pbuf.Dispose ();
 
97
                }
 
98
 
 
99
                protected override Surface MakeIconSurface (Cairo.Surface similar, int size)
 
100
                {
 
101
                        current_size = size;
 
102
                        Surface tmp_surface = similar.CreateSimilar (similar.Content, size, size);
 
103
                        
 
104
                        using (Context cr = new Context (tmp_surface)) {
 
105
                                cr.AlphaFill ();
 
106
                                
 
107
                                int center = size / 2;
 
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.svg"), radius * 2);
 
112
                                RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-marks.svg"), radius * 2);
 
113
                                RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-face-shadow.svg"), radius * 2);
 
114
                                RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-glass.svg"), radius * 2);
 
115
                                RenderFileOntoContext (cr, System.IO.Path.Combine (ThemePath, "clock-frame.svg"), radius * 2);
 
116
                                
 
117
                                cr.Translate (center, center);
 
118
                                cr.Color = new Cairo.Color (.15, .15, .15);
 
119
                                
 
120
                                cr.LineWidth = Math.Max (1, size / 48);
 
121
                                cr.LineCap = LineCap.Round;
 
122
                                double minuteRotation = 2 * Math.PI * (DateTime.Now.Minute / 60.0) + Math.PI;
 
123
                                cr.Rotate (minuteRotation);
 
124
                                cr.MoveTo (0, radius - radius * .35);
 
125
                                cr.LineTo (0, 0 - radius * .15);
 
126
                                cr.Stroke ();
 
127
                                cr.Rotate (0 - minuteRotation);
 
128
                                
 
129
                                cr.Color = new Cairo.Color (0, 0, 0);
 
130
                                double hourRotation = 2 * Math.PI * (DateTime.Now.Hour / 12.0) + 
 
131
                                        Math.PI + (Math.PI / 6) * DateTime.Now.Minute / 60.0;
 
132
                                cr.Rotate (hourRotation);
 
133
                                cr.MoveTo (0, radius - radius * .5);
 
134
                                cr.LineTo (0, 0 - radius * .15);
 
135
                                cr.Stroke ();
 
136
                                cr.Rotate (0 - hourRotation);
 
137
                                
 
138
                                cr.Translate (0 - center, 0 - center);
 
139
                        }
 
140
                        
 
141
                        return tmp_surface;
 
142
                }
 
143
                
 
144
                public override void Clicked (uint button, Gdk.ModifierType state, Gdk.Point position)
 
145
                {
 
146
                        cal_painter.Summon ();
 
147
                        base.Clicked (button, state, position);
 
148
                }
 
149
        }
 
150
}