~ubuntu-branches/debian/sid/docky/sid

« back to all changes in this revision

Viewing changes to Docky/Docky/Items/DockyItem.cs

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2012-01-19 19:03:38 UTC
  • mfrom: (1.1.14) (10.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20120119190338-n44q7tmqsrkudvk7
Tags: 2.1.3-2
* Upload to unstable
* debian/watch:
  + Look for xz tarballs from now on

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
using System;
19
19
using System.Collections.Generic;
20
 
using System.Collections.ObjectModel;
21
20
using System.Linq;
22
 
using System.Text;
23
21
 
24
22
using Cairo;
25
23
using Gdk;
27
25
 
28
26
using Docky.Menus;
29
27
using Docky.Services;
 
28
using Docky.Services.Prefs;
30
29
 
31
30
namespace Docky.Items
32
31
{
33
32
        internal class DockyItem : ColoredIconDockItem, INonPersistedItem
34
33
        {
 
34
                static IPreferences prefs = DockServices.Preferences.Get <DockyItem> ();
 
35
                
 
36
                public bool Show {
 
37
                        get {
 
38
                                return prefs.Get<bool> ("ShowDockyItem", true);
 
39
                        }
 
40
                }
 
41
                
 
42
                public bool ShowSettings {
 
43
                        get {
 
44
                                return prefs.Get<bool> ("ShowSettings", true);
 
45
                        }
 
46
                }
 
47
                
 
48
                public bool ShowQuit {
 
49
                        get {
 
50
                                return prefs.Get<bool> ("ShowQuit", true);
 
51
                        }
 
52
                }
 
53
                
 
54
                public int Hue {
 
55
                        get {
 
56
                                return prefs.Get<int> ("Hue", 0);
 
57
                        }
 
58
                }
35
59
                
36
60
                public DockyItem ()
37
61
                {
38
62
                        Indicator = ActivityIndicator.Single;
39
 
                        HoverText = "Docky";
 
63
                        HoverText = prefs.Get<string> ("HoverText", "Docky");
40
64
                        Icon = "docky";
 
65
                        HueShift = Hue;
41
66
                }
42
67
                
43
68
                protected string AboutIcon {
58
83
                        }
59
84
                }
60
85
                
 
86
                protected string HelpIcon {
 
87
                        get {
 
88
                                return "[monochrome]help.svg@" + GetType ().Assembly.FullName;
 
89
                        }
 
90
                }
 
91
                
61
92
                protected override void OnStyleSet (Gtk.Style style)
62
93
                {
 
94
                        // if we set a hue manually, we don't want to reset the hue when the style changes
 
95
                        if (Hue != 0)
 
96
                                return;
 
97
                        
63
98
                        Gdk.Color gdkColor = Style.Backgrounds [(int) Gtk.StateType.Selected];
64
99
                        int hue = (int) new Cairo.Color ((double) gdkColor.Red / ushort.MaxValue,
65
100
                                                                                        (double) gdkColor.Green / ushort.MaxValue,
73
108
                {
74
109
                        return "DockyItem";
75
110
                }
76
 
                
77
 
                protected override void OnScrolled (ScrollDirection direction, ModifierType mod)
78
 
                {
79
 
                }
80
 
                
 
111
 
81
112
                protected override ClickAnimation OnClicked (uint button, Gdk.ModifierType mod, double xPercent, double yPercent)
82
113
                {
83
114
                        if (button == 1) {
84
 
                                ConfigurationWindow.Instance.Show ();
 
115
                                string command = prefs.Get<string> ("DockyItemCommand", "");
 
116
                                if (!string.IsNullOrEmpty (command))
 
117
                                        DockServices.System.Execute (command);
 
118
                                else if (ShowSettings)
 
119
                                        ConfigurationWindow.Instance.Show ();
 
120
                                else
 
121
                                        return ClickAnimation.None;
 
122
                                
85
123
                                return ClickAnimation.Bounce;
86
124
                        }
87
125
                        return ClickAnimation.None;
90
128
                protected override MenuList OnGetMenuItems ()
91
129
                {
92
130
                        MenuList list = new MenuList ();
93
 
                        list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Settings"), PrefsIcon, (o, a) => ConfigurationWindow.Instance.Show ()));
 
131
                        if (ShowSettings)
 
132
                                list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Settings"), PrefsIcon, (o, a) => ConfigurationWindow.Instance.Show ()));
94
133
                        list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_About"), AboutIcon, (o, a) => Docky.ShowAbout ()));
95
 
                        list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Quit Docky"), CloseIcon, (o, a) => Docky.Quit ()));
 
134
                        list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Help"), HelpIcon, (o, a) => DockServices.System.Open ("http://wiki.go-docky.com")));
 
135
                        if (ShowQuit)
 
136
                                list[MenuListContainer.Actions].Add (new MenuItem (Catalog.GetString ("_Quit Docky"), CloseIcon, (o, a) => Docky.Quit ()));
96
137
                        return list;
97
138
                }
98
139