~ubuntu-branches/ubuntu/wily/gnome-do/wily

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/DockyConfigurationWidget.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 10:40:45 UTC
  • mfrom: (1.1.8 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090627104045-7st10y1cqr6dpz37
Tags: 0.8.2+dfsg-1
* New upstream release
  + No longer uses a plugin repository.  Fixes many plugin-
    related issues. (LP: #343096, LP: #330025, LP #345001)
  + No longer blocks on "About Do" (LP: #361679)
  + Reacts correctly when a Composite manager is enabled/
    disabled at runtime. (LP: #346347, LP: #390150)
  + Fixes for space reserved by Docky blocking drag and 
    drop operations. (LP: #354729, LP: #347052, LP: #382843)
  + Properly sets "Hidden" key on autostart files in response to 
    "Start on login" option.  (Closes: #526023) (LP: #369988)
* debian/patches/10_application_search_path:
  + Drop; included upstream
* debian/patches/10_sk_translation_update:
  + Import sk translation update from Debian BTS.
    (Closes: #531779)
* debian/patches/11_fix_autostart_when_directory_does_not_exist:
  + Patch from upstream.  Fixes the "Start on login" option when the 
    ~/.config/autostart directory does not exist. (LP: #393729)
* debian/control:
  + Update standards version to 3.8.2; no changes required.
  + Add libtool to Build-Depends; required for autoreconf.
  + Add Recommends: on new gnome-do-docklets package.
* debian/gnome-do.1
  + Fix spelling: GNOME-Do => GNOME Do.
  + Miscelaneous lintian fixes; NAME section, escaping minus signs with \-
* debian/copyright:
  + Update for new copyright holders.
  + Minor update to DEP-5 format

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.Linq;
 
21
 
 
22
using Cairo;
 
23
using Gdk;
 
24
using Gtk;
 
25
 
 
26
using Docky.Core;
 
27
using Docky.Utilities;
 
28
 
 
29
namespace Docky.Interface
 
30
{
 
31
        
 
32
        
 
33
        [System.ComponentModel.ToolboxItem(true)]
 
34
        public partial class DockyConfigurationWidget : Gtk.Bin
 
35
        {
 
36
                NodeView docklets_nodeview;
 
37
                
 
38
                [TreeNode (ListOnly=true)]
 
39
                class DockletTreeNode : TreeNode {
 
40
                        AbstractDockletItem docklet;
 
41
                        
 
42
                        public DockletTreeNode (AbstractDockletItem docklet) 
 
43
                        {
 
44
                                this.docklet = docklet;
 
45
                        }
 
46
                        
 
47
                        [TreeNodeValue (Column=0)]
 
48
                        public bool Enabled { 
 
49
                                get { return DockServices.DockletService.ActiveDocklets.Contains (docklet); }
 
50
                        }
 
51
                        
 
52
                        [TreeNodeValue (Column=1)]
 
53
                        public string Name {
 
54
                                get { return docklet.Name; }
 
55
                        }
 
56
                        
 
57
                        public void Toggle ()
 
58
                        {
 
59
                                DockServices.DockletService.ToggleDocklet (docklet);
 
60
                        }
 
61
                }
 
62
                
 
63
                bool setup = false;
 
64
                
 
65
                NodeStore store;
 
66
                NodeStore Store {
 
67
                        get {
 
68
                                if (store == null) {
 
69
                                        store = new NodeStore (typeof (DockletTreeNode));
 
70
                                        
 
71
                                }
 
72
                                return store;
 
73
                        }
 
74
                }
 
75
                
 
76
                public DockyConfigurationWidget()
 
77
                {
 
78
                        setup = true;
 
79
                        this.Build();
 
80
                        
 
81
                        zoom_scale.Digits = 1;
 
82
                        zoom_scale.SetRange (1.1, 4);
 
83
                        zoom_scale.SetIncrements (.1, .1);
 
84
                        zoom_scale.Value = DockPreferences.ZoomPercent;
 
85
                        
 
86
                        icon_size_scale.Value = DockPreferences.IconSize;
 
87
                        
 
88
                        advanced_indicators_checkbutton.Active = DockPreferences.IndicateMultipleWindows;
 
89
                        zoom_checkbutton.Active = DockPreferences.ZoomEnabled;
 
90
                        
 
91
                        orientation_combobox.AppendText (DockOrientation.Bottom.ToString ());
 
92
                        orientation_combobox.AppendText (DockOrientation.Top.ToString ());
 
93
                        orientation_combobox.Active = DockPreferences.Orientation == DockOrientation.Bottom ? 0 : 1;
 
94
                        
 
95
                        autohide_combo.AppendText (((AutohideType) 0).ToString ());
 
96
                        autohide_combo.AppendText (((AutohideType) 1).ToString ());
 
97
                        autohide_combo.AppendText (((AutohideType) 2).ToString ());
 
98
                        autohide_combo.Active = (int) DockPreferences.AutohideType;
 
99
                        
 
100
                        BuildDocklets ();
 
101
                        
 
102
                        SetSensitivity ();
 
103
                        
 
104
                        DockPreferences.IconSizeChanged += HandleIconSizeChanged; 
 
105
                        
 
106
                        Gtk.Application.Invoke (delegate { setup = false; });
 
107
                }
 
108
 
 
109
                void HandleIconSizeChanged()
 
110
                {
 
111
                        SetSensitivity ();
 
112
                }
 
113
                
 
114
                void BuildDocklets ()
 
115
                {
 
116
                        docklets_nodeview = new NodeView (Store);
 
117
                        docklets_nodeview.RulesHint = true;
 
118
                        scrolled_window.Add (docklets_nodeview);
 
119
                        
 
120
                        Gtk.CellRendererToggle toggle = new Gtk.CellRendererToggle ();
 
121
                        toggle.Toggled += HandleToggled;
 
122
                        docklets_nodeview.AppendColumn ("Enabled", toggle, "active", 0);
 
123
                        docklets_nodeview.AppendColumn ("Name", new Gtk.CellRendererText (), "text", 1);
 
124
                        
 
125
                        docklets_nodeview.HeadersVisible = false;
 
126
                        
 
127
                        foreach (AbstractDockletItem adi in DockServices.DockletService.Docklets) {
 
128
                                Store.AddNode (new DockletTreeNode (adi));
 
129
                        }
 
130
                        
 
131
                        scrolled_window.ShowAll ();
 
132
                }
 
133
                
 
134
                void SetSensitivity ()
 
135
                {
 
136
                        zoom_scale.Sensitive = DockPreferences.ZoomEnabled;
 
137
                }
 
138
 
 
139
                void HandleToggled (object o, ToggledArgs args)
 
140
                {
 
141
                        DockletTreeNode node = Store.GetNode (new Gtk.TreePath (args.Path)) as DockletTreeNode;
 
142
                        node.Toggle ();
 
143
                }
 
144
                
 
145
                protected virtual void OnZoomScaleFormatValue (object o, Gtk.FormatValueArgs args)
 
146
                {
 
147
                        args.RetVal = string.Format ("{0}%", Math.Round (args.Value * 100));
 
148
                }
 
149
 
 
150
                protected virtual void OnZoomScaleValueChanged (object sender, System.EventArgs e)
 
151
                {
 
152
                        if (setup || !(sender is HScale)) return;
 
153
                        
 
154
                        HScale scale = sender as HScale;
 
155
                        DockPreferences.ZoomPercent = scale.Value;
 
156
                }
 
157
 
 
158
                protected virtual void OnAdvancedIndicatorsCheckbuttonToggled (object sender, System.EventArgs e)
 
159
                {
 
160
                        if (setup) return;
 
161
                        DockPreferences.IndicateMultipleWindows = advanced_indicators_checkbutton.Active;
 
162
                }
 
163
 
 
164
                protected virtual void OnZoomCheckbuttonToggled (object sender, System.EventArgs e)
 
165
                {
 
166
                        if (setup) return;
 
167
                        DockPreferences.ZoomEnabled = zoom_checkbutton.Active;
 
168
                        
 
169
                        setup = true;
 
170
                        zoom_scale.Value = DockPreferences.ZoomPercent;
 
171
                        Gtk.Application.Invoke (delegate { setup = false; });
 
172
                }
 
173
 
 
174
                protected virtual void OnOrientationComboboxChanged (object sender, System.EventArgs e)
 
175
                {
 
176
                        if (setup) return;
 
177
                        DockPreferences.Orientation = (DockOrientation) orientation_combobox.Active;
 
178
                }
 
179
                
 
180
                protected virtual void OnAutohideComboChanged (object sender, System.EventArgs e)
 
181
                {
 
182
                        if (setup) return;
 
183
                        DockPreferences.AutohideType = (AutohideType) autohide_combo.Active;
 
184
                }
 
185
                
 
186
                public override void Dispose ()
 
187
                {
 
188
                        DockPreferences.IconSizeChanged -= HandleIconSizeChanged;
 
189
                        base.Dispose ();
 
190
                }
 
191
 
 
192
                protected virtual void OnIconSizeScaleValueChanged (object sender, System.EventArgs e)
 
193
                {
 
194
                        if (setup) return;
 
195
                        int val = (int) icon_size_scale.Value;
 
196
                        DockPreferences.IconSize = val;
 
197
                        
 
198
                        if (DockPreferences.IconSize != val) {
 
199
                                icon_size_scale.Value = DockPreferences.IconSize;
 
200
                        }
 
201
                }
 
202
 
 
203
                protected virtual void OnClearRemovedButtonClicked (object sender, System.EventArgs e)
 
204
                {
 
205
                        DockPreferences.ClearBlacklist ();
 
206
                        DockServices.ItemsService.ForceUpdate ();
 
207
                }
 
208
        }
 
209
}