Do

Merge lp:~jassmith/do/menu-theme into lp:do

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jassmith/do/menu-theme
Merge into: lp:do
Diff against target: None lines
To merge this branch: bzr merge lp:~jassmith/do/menu-theme
Reviewer Review Type Date Requested Status
David Siegel (community) Approve
Review via email: mp+4157@code.launchpad.net
To post a comment you must log in.
Revision history for this message
David Siegel (djsiegel-deactivatedaccount) wrote :

Looks good to me.

return (window.IsMinimized) ? .5 : base.IconOpacity;

You don't need to parenthesize the boolean expression.

return window.IsMinimized ? .5 : base.IconOpacity;

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/DockArea.cs'
2--- Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-03-04 16:09:06 +0000
3+++ Do.Interface.Linux.Docky/src/Docky.Interface/DockArea.cs 2009-03-04 16:10:30 +0000
4@@ -538,7 +538,10 @@
5 itemPosition = itemPosition.RelativeMovePoint ((int) (IconSize * itemZoom * .9 * .5), RelativeMove.Inward);
6 itemPosition = itemPosition.RelativePointToRootPoint (window);
7
8- PopupMenu.PopUp ((CurrentDockItem as IRightClickable).GetMenuItems (), itemPosition.X, itemPosition.Y);
9+ PopupMenu.PopUp (CurrentDockItem.Description,
10+ (CurrentDockItem as IRightClickable).GetMenuItems (),
11+ itemPosition.X,
12+ itemPosition.Y);
13 return;
14 }
15 }
16
17=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs'
18--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs 2009-03-02 18:47:42 +0000
19+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ApplicationDockItem.cs 2009-03-03 14:40:15 +0000
20@@ -305,16 +305,18 @@
21
22 public IEnumerable<AbstractMenuArgs> GetMenuItems ()
23 {
24+ yield return new SeparatorMenuButtonArgs ();
25+
26 yield return new SimpleMenuButtonArgs (() => WindowControl.MinimizeRestoreWindows (VisibleWindows),
27- MinimizeRestoreText, MinimizeIcon);
28+ MinimizeRestoreText, MinimizeIcon).AsDark ();
29
30 yield return new SimpleMenuButtonArgs (() => WindowControl.CloseWindows (VisibleWindows),
31- CloseText, Gtk.Stock.Quit);
32-
33- yield return new SeparatorMenuButtonArgs ();
34-
35- foreach (Wnck.Window window in VisibleWindows)
36+ CloseText, Gtk.Stock.Quit).AsDark ();
37+
38+ foreach (Wnck.Window window in VisibleWindows) {
39+ yield return new SeparatorMenuButtonArgs ();
40 yield return new WindowMenuButtonArgs (window, window.Name, WindowIcon);
41+ }
42 }
43
44 public override void Dispose ()
45
46=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/DoDockItem.cs'
47--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/DoDockItem.cs 2009-03-01 07:47:37 +0000
48+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/DoDockItem.cs 2009-03-04 05:05:46 +0000
49@@ -95,35 +95,38 @@
50
51 public IEnumerable<AbstractMenuArgs> GetMenuItems ()
52 {
53+ yield return new SeparatorMenuButtonArgs ();
54+
55 yield return new SimpleMenuButtonArgs (() => DockPreferences.AutoHide = !DockPreferences.AutoHide,
56- Catalog.GetString ("Automatically Hide"), DockPreferences.AutoHide ? EnableIcon : DisableIcon);
57+ Catalog.GetString ("Automatically Hide"), DockPreferences.AutoHide ? EnableIcon : DisableIcon).AsDark ();
58
59 if (!DockPreferences.AutoHide)
60 yield return new SimpleMenuButtonArgs (() => DockPreferences.AllowOverlap = !DockPreferences.AllowOverlap,
61- Catalog.GetString ("Allow Window Overlap"), DockPreferences.AllowOverlap ? EnableIcon : DisableIcon);
62+ Catalog.GetString ("Allow Window Overlap"), DockPreferences.AllowOverlap ? EnableIcon : DisableIcon).AsDark ();
63
64 yield return new SimpleMenuButtonArgs (() => DockPreferences.IndicateMultipleWindows = !DockPreferences.IndicateMultipleWindows,
65- Catalog.GetString ("Advanced Indicators"), DockPreferences.IndicateMultipleWindows ? EnableIcon : DisableIcon);
66+ Catalog.GetString ("Advanced Indicators"), DockPreferences.IndicateMultipleWindows ? EnableIcon : DisableIcon).AsDark ();
67
68 yield return new SimpleMenuButtonArgs (() => DockPreferences.ZoomEnabled = !DockPreferences.ZoomEnabled,
69- Catalog.GetString ("Zoom Icons"), DockPreferences.ZoomEnabled ? EnableIcon : DisableIcon);
70+ Catalog.GetString ("Zoom Icons"), DockPreferences.ZoomEnabled ? EnableIcon : DisableIcon).AsDark ();
71
72- if (DockPreferences.ZoomEnabled)
73+ if (DockPreferences.ZoomEnabled) {
74+ yield return new SeparatorMenuButtonArgs ();
75 yield return new WidgetMenuArgs (BuildScaleWidget ());
76+ }
77
78 if (Gdk.Screen.Default.NMonitors > 1)
79 yield return new SimpleMenuButtonArgs (() => DockPreferences.Monitor++,
80- Catalog.GetString ("Switch Monitors"), "display");
81+ Catalog.GetString ("Switch Monitors"), "display").AsDark ();
82
83 yield return new SeparatorMenuButtonArgs ();
84
85 foreach (AbstractDockletItem dockitem in DockServices.DockletService.Docklets) {
86- yield return new ToggleDockletMenuButtonArgs (dockitem);
87+ yield return new ToggleDockletMenuButtonArgs (dockitem).AsDark ();
88 }
89
90- yield return new SeparatorMenuButtonArgs ();
91-
92 foreach (IRunnableItem item in Services.Application.MainMenuItems) {
93+ yield return new SeparatorMenuButtonArgs ();
94 yield return new RunnableMenuButtonArgs (item);
95 }
96 }
97
98=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs'
99--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs 2009-03-02 18:47:42 +0000
100+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/ItemDockItem.cs 2009-03-04 18:28:37 +0000
101@@ -90,7 +90,7 @@
102 .OrderByDescending (act => act.GetType ().Name != "WindowCloseAction")
103 .ThenByDescending (act => act.GetType ().Name != "WindowMinimizeAction")
104 .ThenByDescending (act => act.GetType ().Name != "WindowMaximizeAction")
105- .ThenByDescending (act => act.Relevance))
106+ .ThenBy (act => act.Name.Length))
107 yield return act;
108 }
109 }
110@@ -283,13 +283,21 @@
111 {
112 bool hasApps = HasVisibleApps;
113
114- foreach (Act act in ActionsForItem)
115- yield return new LaunchMenuButtonArgs (act, element, act.Name, act.Icon);
116-
117- if (hasApps) {
118- yield return new SeparatorMenuButtonArgs ();
119- foreach (Wnck.Window window in VisibleWindows)
120- yield return new WindowMenuButtonArgs (window, window.Name, Icon);
121+ yield return new SeparatorMenuButtonArgs ();
122+
123+ if (hasApps) {
124+ foreach (Act act in ActionsForItem)
125+ yield return new LaunchMenuButtonArgs (act, element, act.Name, act.Icon).AsDark ();
126+ } else {
127+ foreach (Act act in ActionsForItem)
128+ yield return new LaunchMenuButtonArgs (act, element, act.Name, act.Icon);
129+ }
130+
131+ if (hasApps) {
132+ foreach (Wnck.Window window in VisibleWindows) {
133+ yield return new SeparatorMenuButtonArgs ();
134+ yield return new WindowMenuButtonArgs (window, window.Name, Icon);
135+ }
136 }
137
138 }
139
140=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/TrashDockItem.cs'
141--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/TrashDockItem.cs 2009-03-03 00:47:10 +0000
142+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Items/TrashDockItem.cs 2009-03-04 05:30:39 +0000
143@@ -146,6 +146,8 @@
144
145 public IEnumerable<AbstractMenuArgs> GetMenuItems ()
146 {
147+ yield return new SeparatorMenuButtonArgs ();
148+
149 yield return new SimpleMenuButtonArgs (
150 () => Services.Environment.OpenUrl ("trash://"),
151 Catalog.GetString ("Open Trash"), TrashFullIcon);
152
153=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs'
154--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-03-01 07:35:08 +0000
155+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-03-04 05:17:38 +0000
156@@ -18,9 +18,14 @@
157
158 using System;
159
160+using Cairo;
161+using Gdk;
162 using Gtk;
163 using Mono.Unix;
164
165+using Docky.Core;
166+using Docky.Utilities;
167+
168 using Do.Interface;
169 using Do.Interface.CairoUtils;
170 using Do.Platform;
171@@ -29,7 +34,18 @@
172 {
173 public abstract class AbstractMenuButtonArgs : AbstractMenuArgs
174 {
175+ const string FormatString = "{0}";
176+ const int WidthBuffer = 4;
177+ const int Height = 22;
178+
179 Gtk.Widget widget;
180+ bool hovered;
181+
182+ public bool Dark { get; set; }
183+
184+ public virtual double IconOpacity {
185+ get { return 1; }
186+ }
187
188 public override Gtk.Widget Widget {
189 get {
190@@ -54,44 +70,98 @@
191 Icon = icon;
192 }
193
194- Gtk.Button BuildWidget ()
195+ Widget BuildWidget ()
196 {
197- HBox hbox = new HBox ();
198- Label label = new Label ();
199- label.Markup = "<span color=\"#ffffff\"><b>" + Description + "</b></span>";
200- label.ModifyFg (StateType.Normal, new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
201- label.ModifyText (StateType.Normal, new Gdk.Color (byte.MaxValue, byte.MaxValue, byte.MaxValue));
202- label.Xalign = 0f;
203- label.Ellipsize = Pango.EllipsizeMode.End;
204- label.Ypad = 0;
205-
206- Gtk.Image image;
207- using (Gdk.Pixbuf pbuf = IconProvider.PixbufFromIconName (Icon, 16)) {
208- image = new Gtk.Image (pbuf);
209- }
210-
211- hbox.PackStart (image, false, false, 0);
212- hbox.PackStart (label, true, true, 2);
213-
214- Gtk.Button button = new Gtk.Button (hbox);
215-
216- button.Relief = ReliefStyle.None;
217- button.CanFocus = false;
218- button.BorderWidth = 0;
219-
220- button.ModifyBg (StateType.Prelight, new Gdk.Color ((byte) (byte.MaxValue * 0.25),
221- (byte) (byte.MaxValue * 0.25),
222- (byte) (byte.MaxValue * 0.25)));
223-
224- button.Clicked += (sender, e) => Action ();
225- button.Clicked += (sender, e) => base.OnActivated ();
226- button.ShowAll ();
227+ DrawingArea button = new DrawingArea ();
228+
229+ button.ExposeEvent += HandleExposeEvent;
230+ button.EnterNotifyEvent += HandleEnterNotifyEvent;
231+ button.LeaveNotifyEvent += HandleLeaveNotifyEvent;
232+ button.ButtonReleaseEvent += HandleButtonReleaseEvent;
233+
234+ button.AddEvents ((int) (EventMask.EnterNotifyMask | EventMask.LeaveNotifyMask | EventMask.ButtonReleaseMask));
235+ button.HeightRequest = Height;
236+
237+ button.SetCompositeColormap ();
238
239 return button;
240 }
241
242+ void HandleButtonReleaseEvent(object o, ButtonReleaseEventArgs args)
243+ {
244+ Action ();
245+ base.OnActivated ();
246+ }
247+
248+ void HandleLeaveNotifyEvent(object o, LeaveNotifyEventArgs args)
249+ {
250+ (o as Widget).QueueDraw ();
251+ hovered = false;
252+ }
253+
254+ void HandleEnterNotifyEvent(object o, EnterNotifyEventArgs args)
255+ {
256+ (o as Widget).QueueDraw ();
257+ hovered = true;
258+ }
259+
260+ void HandleExposeEvent(object o, ExposeEventArgs args)
261+ {
262+ using (Context cr = CairoHelper.Create (args.Event.Window)) {
263+ Gdk.Rectangle area = args.Event.Area;
264+ cr.AlphaFill ();
265+ LinearGradient lg = new LinearGradient (area.X, area.Y, area.X, area.Y + area.Height);
266+
267+ Cairo.Color background = (Dark) ? DockPopupMenu.BackgroundColor.ShadeColor (.7) : DockPopupMenu.BackgroundColor;
268+ if (hovered) {
269+ Cairo.Color high = background
270+ .ConvertToGdk ()
271+ .SetMinimumValue (25)
272+ .ConvertToCairo (background.A);
273+
274+ lg.AddColorStop (0, high);
275+ lg.AddColorStop (1, background);
276+ } else {
277+ lg.AddColorStop (0, background);
278+ lg.AddColorStop (1, background);
279+ }
280+ cr.Pattern = lg;
281+ cr.Paint ();
282+ lg.Destroy ();
283+
284+ Gdk.Point textPoint;
285+ int width;
286+ textPoint = new Gdk.Point (area.X + WidthBuffer + 25, area.Y + area.Height / 2);
287+ width = area.Width - WidthBuffer * 2 - 25;
288+
289+ DockServices.DrawingService.TextPathAtPoint (cr,
290+ string.Format (FormatString, Description),
291+ textPoint,
292+ width,
293+ Pango.Alignment.Left);
294+ cr.Color = new Cairo.Color (1, 1, 1);
295+ cr.Fill ();
296+
297+ Gdk.Pixbuf pbuf = GetPixbuf (Height - 8);
298+ CairoHelper.SetSourcePixbuf (cr, pbuf, WidthBuffer, (Height - pbuf.Height) / 2);
299+ cr.PaintWithAlpha (IconOpacity);
300+ pbuf.Dispose ();
301+ }
302+ }
303+
304+ protected virtual Gdk.Pixbuf GetPixbuf (int size)
305+ {
306+ return IconProvider.PixbufFromIconName (Icon, size);
307+ }
308+
309 public abstract void Action ();
310
311+ public AbstractMenuButtonArgs AsDark ()
312+ {
313+ Dark = true;
314+ return this;
315+ }
316+
317 public override void Dispose ()
318 {
319 Widget.Destroy ();
320
321=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockItemMenu.cs'
322--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockItemMenu.cs 2009-03-01 07:35:08 +0000
323+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockItemMenu.cs 2009-03-03 14:40:15 +0000
324@@ -42,7 +42,7 @@
325 {
326 }
327
328- public override void PopUp (IEnumerable<AbstractMenuArgs> args, int x, int y)
329+ public override void PopUp (string header, IEnumerable<AbstractMenuArgs> args, int x, int y)
330 {
331 current_args = args;
332
333@@ -53,7 +53,7 @@
334 }
335 ShowAll ();
336
337- base.PopUp (args, x, y);
338+ base.PopUp (header, args, x, y);
339 }
340
341 void OnButtonClicked (object o, EventArgs args)
342
343=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs'
344--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs 2009-03-01 04:24:20 +0000
345+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs 2009-03-04 18:28:37 +0000
346@@ -36,10 +36,13 @@
347
348 public class DockPopupMenu : Gtk.Window
349 {
350+ public static readonly Cairo.Color BackgroundColor = new Cairo.Color (0.13, 0.13, 0.13, .95);
351+
352 const int TailHeight = 25;
353 new const int BorderWidth = 2;
354- const int Radius = 10;
355- const int Width = 230;
356+ const int HeaderSize = 20;
357+ const int Radius = 7;
358+ const int Width = 180;
359 const double Pointiness = 1.5;
360 const double Curviness = 1;
361 const double Bluntness = 2;
362@@ -47,6 +50,8 @@
363 int horizontal_offset;
364 int vertical_offset;
365
366+ string header;
367+
368 Gtk.Alignment align;
369
370 public Gtk.VBox Container { get; private set; }
371@@ -54,6 +59,15 @@
372 // we are making a new one here for speed reasons
373 public new bool Visible { get; private set; }
374
375+ int HeaderTextOffset {
376+ get {
377+ if (DockPreferences.Orientation == DockOrientation.Bottom)
378+ return (HeaderSize + 10) / 2;
379+ else
380+ return (TailHeight + 3) + (HeaderSize + 10) / 2;
381+ }
382+ }
383+
384 public DockPopupMenu() : base (Gtk.WindowType.Popup)
385 {
386 Decorated = false;
387@@ -82,26 +96,29 @@
388 protected virtual void Build ()
389 {
390 align = new Gtk.Alignment (0.5f, 0.5f, 1, 1);
391- align.LeftPadding = align.RightPadding = align.TopPadding = align.BottomPadding = 2;
392+ align.LeftPadding = 4;
393+ align.RightPadding = 3;
394+ align.TopPadding = align.BottomPadding = 7;
395+ align.TopPadding += HeaderSize;
396
397 switch (DockPreferences.Orientation) {
398 case DockOrientation.Bottom:
399- align.BottomPadding += TailHeight;
400+ align.BottomPadding += TailHeight + 3;
401 break;
402 case DockOrientation.Top:
403- align.TopPadding += TailHeight;
404+ align.TopPadding += TailHeight + 3;
405 break;
406 }
407
408 align.Add (Container);
409- Container.BorderWidth = 5;
410 Add (align);
411 align.ShowAll ();
412 }
413
414
415- public virtual void PopUp (IEnumerable<AbstractMenuArgs> args, int x, int y)
416+ public virtual void PopUp (string description, IEnumerable<AbstractMenuArgs> args, int x, int y)
417 {
418+ header = description;
419 vertical_offset = horizontal_offset = 0;
420 ShowAll ();
421 Gdk.Rectangle geo = LayoutUtils.MonitorGemonetry ();
422@@ -183,12 +200,23 @@
423
424 SetBackgroundPath (cr);
425
426- cr.Color = new Cairo.Color (0.1, 0.1, 0.1, .9);
427+ cr.Color = BackgroundColor;
428 cr.FillPreserve ();
429
430- cr.Color = new Cairo.Color (1, 1, 1, .4);
431+ cr.LineWidth = 3;
432+ cr.StrokePreserve ();
433+
434+ cr.Color = new Cairo.Color (1, 1, 1, .25);
435 cr.LineWidth = 1;
436 cr.Stroke ();
437+
438+ Core.DockServices.DrawingService.TextPathAtPoint (cr,
439+ string.Format ("<b>{0}</b>", header),
440+ new Gdk.Point (8, HeaderTextOffset),
441+ Width - 16,
442+ Pango.Alignment.Center);
443+ cr.Color = new Cairo.Color (1, 1, 1);
444+ cr.Fill ();
445 }
446
447 void SetBackgroundPath (Context context)
448
449=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SeparatorMenuButtonArgs.cs'
450--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SeparatorMenuButtonArgs.cs 2009-03-01 07:35:08 +0000
451+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/SeparatorMenuButtonArgs.cs 2009-03-03 14:40:15 +0000
452@@ -30,16 +30,19 @@
453 {
454 public CustomSeparator () : base ()
455 {
456- HeightRequest = 3;
457+ HeightRequest = 2;
458 }
459
460 protected override bool OnExposeEvent (Gdk.EventExpose evnt)
461 {
462 using (Context cr = CairoHelper.Create (GdkWindow)) {
463+ cr.Rectangle (evnt.Area.X, evnt.Area.Y, evnt.Area.Width, 1);
464+ cr.Color = new Cairo.Color (0, 0, 0, .2);
465+ cr.Fill ();
466+
467 cr.Rectangle (evnt.Area.X, evnt.Area.Y + 1, evnt.Area.Width, 1);
468- cr.Color = new Cairo.Color (.8, .8, .8, .7);
469+ cr.Color = new Cairo.Color (1, 1, 1, .1);
470 cr.Fill ();
471-
472 }
473 return true;
474 }
475
476=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs'
477--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs 2009-03-01 04:24:20 +0000
478+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs 2009-03-04 05:05:46 +0000
479@@ -18,19 +18,30 @@
480
481 using System;
482
483+using Gdk;
484+
485 using Wnck;
486
487 using Docky.Utilities;
488
489+using Do.Interface;
490+
491 namespace Docky.Interface.Menus
492 {
493
494
495 public class WindowMenuButtonArgs : AbstractMenuButtonArgs
496 {
497- Window window;
498-
499- public WindowMenuButtonArgs (Window window, string description, string icon) : base (description, icon)
500+ Wnck.Window window;
501+
502+ public override double IconOpacity {
503+ get {
504+ return (window.IsMinimized) ? .5 : base.IconOpacity;
505+ }
506+ }
507+
508+
509+ public WindowMenuButtonArgs (Wnck.Window window, string description, string icon) : base (description, icon)
510 {
511 this.window = window;
512 }
513@@ -39,6 +50,5 @@
514 {
515 window.CenterAndFocusWindow ();
516 }
517-
518 }
519 }