3
// Copyright (C) 2008 GNOME Do
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, see <http://www.gnu.org/licenses/>.
20
using System.Collections.Generic;
34
using Docky.Interface.Menus;
35
using Docky.Interface.Painters;
36
using Docky.Utilities;
38
namespace Docky.Interface
41
public class DoDockItem : AbstractDockItem, IRightClickable
43
const string DoIcon = "gnome-do";
44
public const string EnableIcon = "gtk-apply";
45
public const string DisableIcon = "gtk-remove";
46
const string Text = "GNOME Do";
48
HotSeatPainter hot_seat_painter;
50
#region IDockItem implementation
52
public override ScalingType ScalingType {
54
return ScalingType.HighLow;
59
protected override Pixbuf GetSurfacePixbuf (int size)
61
return IconProvider.PixbufFromIconName (DoIcon, size);
65
public override void Clicked (uint button, ModifierType state, Gdk.Point position)
68
Services.Windowing.SummonMainWindow ();
70
hot_seat_painter.Show ();
75
public DoDockItem () : base ()
77
hot_seat_painter = new HotSeatPainter ();
78
DockServices.PainterService.RegisterPainter (hot_seat_painter);
80
SetText (Catalog.GetString (Text));
83
#region IDisposable implementation
87
public override bool Equals (AbstractDockItem other)
89
return other is DoDockItem;
92
#region IRightClickable implementation
94
public event EventHandler RemoveClicked;
96
public IEnumerable<AbstractMenuArgs> GetMenuItems ()
98
yield return new SeparatorMenuButtonArgs ();
100
yield return new SimpleMenuButtonArgs (() => DockPreferences.AutoHide = !DockPreferences.AutoHide,
101
Catalog.GetString ("Automatically Hide"), DockPreferences.AutoHide ? EnableIcon : DisableIcon).AsDark ();
103
if (!DockPreferences.AutoHide)
104
yield return new SimpleMenuButtonArgs (() => DockPreferences.AllowOverlap = !DockPreferences.AllowOverlap,
105
Catalog.GetString ("Allow Window Overlap"), DockPreferences.AllowOverlap ? EnableIcon : DisableIcon).AsDark ();
107
yield return new SimpleMenuButtonArgs (() => DockPreferences.IndicateMultipleWindows = !DockPreferences.IndicateMultipleWindows,
108
Catalog.GetString ("Advanced Indicators"), DockPreferences.IndicateMultipleWindows ? EnableIcon : DisableIcon).AsDark ();
110
yield return new SimpleMenuButtonArgs (() => DockPreferences.ZoomEnabled = !DockPreferences.ZoomEnabled,
111
Catalog.GetString ("Zoom Icons"), DockPreferences.ZoomEnabled ? EnableIcon : DisableIcon).AsDark ();
113
// if (DockPreferences.ZoomEnabled) {
114
// yield return new SeparatorMenuButtonArgs ();
115
// yield return new WidgetMenuArgs (BuildScaleWidget ());
118
if (Gdk.Screen.Default.NMonitors > 1)
119
yield return new SimpleMenuButtonArgs (() => DockPreferences.Monitor++,
120
Catalog.GetString ("Switch Monitors"), "display").AsDark ();
122
yield return new SeparatorMenuButtonArgs ();
124
foreach (AbstractDockletItem dockitem in DockServices.DockletService.Docklets) {
125
yield return new ToggleDockletMenuButtonArgs (dockitem).AsDark ();
128
foreach (IRunnableItem item in Services.Application.MainMenuItems) {
129
yield return new SeparatorMenuButtonArgs ();
130
yield return new RunnableMenuButtonArgs (item);
134
void HandleValueChanged(object sender, EventArgs e)
136
if (!(sender is HScale)) return;
138
HScale scale = sender as HScale;
139
DockPreferences.ZoomPercent = scale.Value;
144
Gtk.HScale BuildScaleWidget ()
146
Gtk.HScale hscale = new Gtk.HScale (1.1, 4, .1);
147
hscale.Value = DockPreferences.ZoomPercent;
148
hscale.Name = "Zoom";
149
hscale.CanFocus = false;
150
hscale.FormatValue +=HandleFormatValue;
151
hscale.ModifyFg (StateType.Normal, new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
152
hscale.ValueChanged +=HandleValueChanged;
156
void HandleFormatValue(object o, FormatValueArgs args)
158
args.RetVal = string.Format ("{0}%", Math.Round (args.Value * 100));