Merge lp:~shippo/plank/fix-1251625 into lp:~shippo/plank/test

Proposed by Peter Feichtinger
Status: Merged
Approved by: Peter Feichtinger
Approved revision: 1591
Merged at revision: 1592
Proposed branch: lp:~shippo/plank/fix-1251625
Merge into: lp:~shippo/plank/test
Diff against target: 523 lines (+177/-62)
15 files modified
data/net.launchpad.plank.gschema.xml.in.in (+5/-0)
data/ui/preferences.ui (+24/-0)
docklets/Clippy/ClippyDockItem.vala (+1/-1)
docklets/Clock/ClockDockItem.vala (+1/-1)
docklets/Trash/TrashDockItem.vala (+1/-1)
lib/DockPreferences.vala (+3/-0)
lib/Items/ApplicationDockItem.vala (+77/-44)
lib/Items/DockElement.vala (+3/-6)
lib/Items/DockItem.vala (+12/-0)
lib/Items/FileDockItem.vala (+10/-3)
lib/Items/PlankDockItem.vala (+1/-1)
lib/Services/WindowControl.vala (+20/-0)
lib/Widgets/DockWindow.vala (+3/-3)
lib/Widgets/PreferencesWindow.vala (+13/-0)
lib/libplank.symbols (+3/-2)
To merge this branch: bzr merge lp:~shippo/plank/fix-1251625
Reviewer Review Type Date Requested Status
Peter Feichtinger Approve
Review via email: mp+319850@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Peter Feichtinger (shippo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/net.launchpad.plank.gschema.xml.in.in'
2--- data/net.launchpad.plank.gschema.xml.in.in 2016-03-09 08:51:55 +0000
3+++ data/net.launchpad.plank.gschema.xml.in.in 2017-03-14 17:23:07 +0000
4@@ -128,6 +128,11 @@
5 <_summary>Dock unhide delay</_summary>
6 <_description>Length of the delay before unhiding the dock, in milliseconds.</_description>
7 </key>
8+ <key name="use-window-menu" type="b">
9+ <default>false</default>
10+ <_summary>Use window menu when multiple windows are open</_summary>
11+ <_description>If true, clicking on an item with multiple windows will show the menu instead of activating all windows.</_description>
12+ </key>
13 <key name="zoom-enabled" type="b">
14 <default>false</default>
15 <_summary>Zoom dock items when hovered</_summary>
16
17=== modified file 'data/ui/preferences.ui'
18--- data/ui/preferences.ui 2016-03-09 08:51:55 +0000
19+++ data/ui/preferences.ui 2017-03-14 17:23:07 +0000
20@@ -554,6 +554,30 @@
21 </packing>
22 </child>
23 <child>
24+ <object class="GtkLabel" id="l_window_menu">
25+ <property name="visible">True</property>
26+ <property name="can_focus">False</property>
27+ <property name="halign">end</property>
28+ <property name="label" translatable="yes">Use Window Menu:</property>
29+ </object>
30+ <packing>
31+ <property name="left_attach">2</property>
32+ <property name="top_attach">6</property>
33+ </packing>
34+ </child>
35+ <child>
36+ <object class="GtkSwitch" id="sw_window_menu">
37+ <property name="visible">True</property>
38+ <property name="can_focus">True</property>
39+ <property name="halign">start</property>
40+ <property name="valign">center</property>
41+ </object>
42+ <packing>
43+ <property name="left_attach">3</property>
44+ <property name="top_attach">6</property>
45+ </packing>
46+ </child>
47+ <child>
48 <placeholder/>
49 </child>
50 <child>
51
52=== modified file 'docklets/Clippy/ClippyDockItem.vala'
53--- docklets/Clippy/ClippyDockItem.vala 2017-02-09 12:53:29 +0000
54+++ docklets/Clippy/ClippyDockItem.vala 2017-03-14 17:23:07 +0000
55@@ -158,7 +158,7 @@
56 return AnimationType.NONE;
57 }
58
59- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
60+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
61 {
62 var items = new Gee.ArrayList<Gtk.MenuItem> ();
63
64
65=== modified file 'docklets/Clock/ClockDockItem.vala'
66--- docklets/Clock/ClockDockItem.vala 2016-01-30 16:54:55 +0000
67+++ docklets/Clock/ClockDockItem.vala 2017-03-14 17:23:07 +0000
68@@ -246,7 +246,7 @@
69 render_file_onto_context (cr, current_theme + "/clock-frame.svg", radius * 2);
70 }
71
72- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
73+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
74 {
75 unowned ClockPreferences prefs = (ClockPreferences) Prefs;
76 var items = new Gee.ArrayList<Gtk.MenuItem> ();
77
78=== modified file 'docklets/Trash/TrashDockItem.vala'
79--- docklets/Trash/TrashDockItem.vala 2017-03-05 09:09:39 +0000
80+++ docklets/Trash/TrashDockItem.vala 2017-03-14 17:23:07 +0000
81@@ -159,7 +159,7 @@
82 return trashed;
83 }
84
85- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
86+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
87 {
88 var items = new Gee.ArrayList<Gtk.MenuItem> ();
89
90
91=== modified file 'lib/DockPreferences.vala'
92--- lib/DockPreferences.vala 2016-03-04 15:54:48 +0000
93+++ lib/DockPreferences.vala 2017-03-14 17:23:07 +0000
94@@ -30,6 +30,9 @@
95 public const int MIN_ICON_ZOOM = 100;
96 public const int MAX_ICON_ZOOM = 200;
97
98+ [Description(nick = "use-window-menu", blurb = "Whether to use a menu to switch between multiple windows of an application instead of showing all at once.")]
99+ public bool UseWindowMenu { get; set; }
100+
101 [Description(nick = "current-workspace-only", blurb = "Whether to show only windows of the current workspace.")]
102 public bool CurrentWorkspaceOnly { get; set; }
103
104
105=== modified file 'lib/Items/ApplicationDockItem.vala'
106--- lib/Items/ApplicationDockItem.vala 2017-02-09 12:53:29 +0000
107+++ lib/Items/ApplicationDockItem.vala 2017-03-14 17:23:07 +0000
108@@ -38,6 +38,9 @@
109
110 private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"};
111
112+ private const Gdk.ModifierType ANY_MODIFIER =
113+ Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.MOD1_MASK;
114+
115 /**
116 * Signal fired when the item's 'keep in dock' menu item is pressed.
117 */
118@@ -393,9 +396,27 @@
119 /**
120 * {@inheritDoc}
121 */
122- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
123+ public override bool show_menu (PopupButton button, Gdk.ModifierType modifiers)
124+ {
125+ bool useWindowMenu = get_dock ().prefs.UseWindowMenu;
126+ if (button == PopupButton.LEFT && (modifiers & ANY_MODIFIER) == 0 && App != null && useWindowMenu) {
127+ var count = 0;
128+ foreach (var view in App.get_windows ()) {
129+ unowned Bamf.Window? window = (view as Bamf.Window);
130+ if (window != null && window.get_transient () == null && ++count > 1)
131+ return true;
132+ }
133+ }
134+ return base.show_menu (button, modifiers);
135+ }
136+
137+ /**
138+ * {@inheritDoc}
139+ */
140+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
141 {
142 var items = new Gee.ArrayList<Gtk.MenuItem> ();
143+ var event_time = Gtk.get_current_event_time ();
144
145 GLib.List<unowned Bamf.View>? windows = null;
146 if (App != null)
147@@ -405,51 +426,52 @@
148 if (windows != null)
149 window_count = windows.length ();
150
151- unowned DefaultApplicationDockItemProvider? default_provider = (Container as DefaultApplicationDockItemProvider);
152- if (default_provider != null
153- && !default_provider.Prefs.LockItems
154- && !is_window ()) {
155- var item = new Gtk.CheckMenuItem.with_mnemonic (_("_Keep in Dock"));
156- item.active = !(this is TransientDockItem);
157- item.activate.connect (() => pin_launcher ());
158- items.add (item);
159- }
160-
161- var event_time = Gtk.get_current_event_time ();
162- if (is_running () && window_count > 0) {
163- var item = create_menu_item ((window_count > 1 ? _("_Close All") : _("_Close")), "window-close-symbolic;;window-close");
164- item.activate.connect (() => WindowControl.close_all (App, event_time));
165- items.add (item);
166- }
167-
168+ if (button == PopupButton.RIGHT) {
169+ unowned DefaultApplicationDockItemProvider? default_provider = (Container as DefaultApplicationDockItemProvider);
170+ if (default_provider != null
171+ && !default_provider.Prefs.LockItems
172+ && !is_window ()) {
173+ var item = new Gtk.CheckMenuItem.with_mnemonic (_("_Keep in Dock"));
174+ item.active = !(this is TransientDockItem);
175+ item.activate.connect (() => pin_launcher ());
176+ items.add (item);
177+ }
178+
179+ if (is_running () && window_count > 0) {
180+ var item = create_menu_item ((window_count > 1 ? _("_Close All") : _("_Close")), "window-close-symbolic;;window-close");
181+ item.activate.connect (() => WindowControl.close_all (App, event_time));
182+ items.add (item);
183+ }
184+
185 #if HAVE_DBUSMENU
186- if (Quicklist != null) {
187- if (items.size > 0)
188- items.add (new Gtk.SeparatorMenuItem ());
189-
190- var dm_root = Quicklist.get_root ();
191- if (dm_root != null) {
192- Logger.verbose ("%i quicklist menuitems for %s", dm_root.get_children ().length (), Text);
193- foreach (var menuitem in dm_root.get_children ())
194- items.add (Quicklist.menuitem_get (menuitem));
195+ if (Quicklist != null) {
196+ if (items.size > 0)
197+ items.add (new Gtk.SeparatorMenuItem ());
198+
199+ var dm_root = Quicklist.get_root ();
200+ if (dm_root != null) {
201+ Logger.verbose ("%i quicklist menuitems for %s", dm_root.get_children ().length (), Text);
202+ foreach (var menuitem in dm_root.get_children ())
203+ items.add (Quicklist.menuitem_get (menuitem));
204+ }
205 }
206- }
207 #endif
208-
209- if (!is_window () && actions.size > 0) {
210- if (items.size > 0)
211- items.add (new Gtk.SeparatorMenuItem ());
212
213- foreach (var s in actions) {
214- var values = actions_map.get (s).split (";;");
215+ if (!is_window () && actions.size > 0) {
216+ if (items.size > 0)
217+ items.add (new Gtk.SeparatorMenuItem ());
218
219- var item = create_menu_item (s, values[1], true);
220- item.activate.connect (() => {
221- try {
222- AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null);
223- } catch { }
224- });
225- items.add (item);
226+ foreach (var s in actions) {
227+ var values = actions_map.get (s).split (";;");
228+
229+ var item = create_menu_item (s, values[1], true);
230+ item.activate.connect (() => {
231+ try {
232+ AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null);
233+ } catch { }
234+ });
235+ items.add (item);
236+ }
237 }
238 }
239
240@@ -472,10 +494,21 @@
241 else
242 window_item = create_literal_menu_item (window_name, Icon);
243
244- if (window.is_active ())
245- window_item.set_sensitive (false);
246- else
247+ if (window.is_active ()) {
248+ window_item.activate.connect (() => WindowControl.minimize_window (window, event_time));
249+
250+ unowned Gtk.Label? label = (window_item.get_child () as Gtk.Label);
251+ if (label != null) {
252+ Pango.AttrList attrs = new Pango.AttrList ();
253+ attrs.change (Pango.attr_weight_new (Pango.Weight.BOLD));
254+ label.set_attributes (attrs);
255+ }
256+ } else {
257 window_item.activate.connect (() => WindowControl.focus_window (window, event_time));
258+
259+ if (WindowControl.is_window_minimized (window))
260+ window_item.set_opacity (0.5);
261+ }
262
263 items.add (window_item);
264 }
265
266=== modified file 'lib/Items/DockElement.vala'
267--- lib/Items/DockElement.vala 2017-02-09 12:53:29 +0000
268+++ lib/Items/DockElement.vala 2017-03-14 17:23:07 +0000
269@@ -54,11 +54,6 @@
270 public bool IsVisible { get; set; default = true; }
271
272 /**
273- * The buttons this item shows popup menus for.
274- */
275- public PopupButton Button { get; protected set; default = PopupButton.RIGHT; }
276-
277- /**
278 * The animation to show for the item's last click event.
279 */
280 public AnimationType ClickedAnimation { get; protected set; default = AnimationType.NONE; }
281@@ -211,9 +206,11 @@
282 /**
283 * Returns a list of the item's menu items.
284 *
285+ * @param button The button that is pressed.
286+ * @param modifiers The modifiers pressed.
287 * @return the item's menu items
288 */
289- public virtual Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
290+ public virtual Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
291 {
292 return new Gee.ArrayList<Gtk.MenuItem> ();
293 }
294
295=== modified file 'lib/Items/DockItem.vala'
296--- lib/Items/DockItem.vala 2016-06-01 09:48:44 +0000
297+++ lib/Items/DockItem.vala 2017-03-14 17:23:07 +0000
298@@ -600,6 +600,18 @@
299 }
300
301 /**
302+ * Check whether the menu should be shown.
303+ *
304+ * @param button The button that is pressed.
305+ * @param modifiers The modifiers pressed.
306+ * @return Whether the menu should be shown.
307+ */
308+ public virtual bool show_menu (PopupButton button, Gdk.ModifierType modifiers)
309+ {
310+ return button == PopupButton.RIGHT;
311+ }
312+
313+ /**
314 * Copy all property value of this dockitem instance to target instance.
315 *
316 * @param target the dockitem to copy the values to
317
318=== modified file 'lib/Items/FileDockItem.vala'
319--- lib/Items/FileDockItem.vala 2017-02-09 12:53:29 +0000
320+++ lib/Items/FileDockItem.vala 2017-03-14 17:23:07 +0000
321@@ -96,8 +96,6 @@
322
323 // pop up the dir contents on a left click too
324 if (OwnedFile.query_file_type (0) == FileType.DIRECTORY) {
325- Button = PopupButton.RIGHT | PopupButton.LEFT;
326-
327 try {
328 dir_monitor = OwnedFile.monitor_directory (0);
329 dir_monitor.changed.connect (handle_dir_changed);
330@@ -259,7 +257,16 @@
331 /**
332 * {@inheritDoc}
333 */
334- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
335+ public override bool show_menu (PopupButton button, Gdk.ModifierType modifiers)
336+ {
337+ return button == PopupButton.RIGHT
338+ || (OwnedFile.query_file_type (0) == FileType.DIRECTORY && button == PopupButton.LEFT);
339+ }
340+
341+ /**
342+ * {@inheritDoc}
343+ */
344+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
345 {
346 if (OwnedFile.query_file_type (0) == FileType.DIRECTORY)
347 return get_dir_menu_items ();
348
349=== modified file 'lib/Items/PlankDockItem.vala'
350--- lib/Items/PlankDockItem.vala 2015-11-14 14:37:32 +0000
351+++ lib/Items/PlankDockItem.vala 2017-03-14 17:23:07 +0000
352@@ -66,7 +66,7 @@
353 /**
354 * {@inheritDoc}
355 */
356- public override Gee.ArrayList<Gtk.MenuItem> get_menu_items ()
357+ public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers)
358 {
359 var items = new Gee.ArrayList<Gtk.MenuItem> ();
360
361
362=== modified file 'lib/Services/WindowControl.vala'
363--- lib/Services/WindowControl.vala 2016-11-05 19:48:09 +0000
364+++ lib/Services/WindowControl.vala 2017-03-14 17:23:07 +0000
365@@ -139,6 +139,13 @@
366 return pbuf;
367 }
368
369+ public static bool is_window_minimized (Bamf.Window window)
370+ {
371+ Wnck.Screen.get_default ();
372+ unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ());
373+ return w.is_minimized ();
374+ }
375+
376 public static bool has_maximized_window (Bamf.Application app)
377 {
378 Wnck.Screen.get_default ();
379@@ -251,6 +258,19 @@
380 center_and_focus_window (w, event_time);
381 }
382
383+ public static void minimize_window (Bamf.Window window, uint32 event_time)
384+ {
385+ Wnck.Screen.get_default ();
386+ unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ());
387+
388+ warn_if_fail (w != null);
389+
390+ if (w == null)
391+ return;
392+
393+ w.minimize ();
394+ }
395+
396 static int find_active_xid_index (Array<uint32>? xids)
397 {
398 var i = 0;
399
400=== modified file 'lib/Widgets/DockWindow.vala'
401--- lib/Widgets/DockWindow.vala 2016-11-04 19:03:20 +0000
402+++ lib/Widgets/DockWindow.vala 2017-03-14 17:23:07 +0000
403@@ -606,14 +606,14 @@
404
405 if ((button & PopupButton.RIGHT) != 0
406 && (item == null || (event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) {
407- menu_items = Factory.item_factory.get_item_for_dock ().get_menu_items ();
408+ menu_items = Factory.item_factory.get_item_for_dock ().get_menu_items (button, event.state);
409 if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0
410 && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0)
411 menu_items.add_all (get_dock_debug_menu_items (controller));
412 set_hovered_provider (null);
413 set_hovered (null);
414- } else if (item != null && item.is_valid () && (item.Button & button) != 0) {
415- menu_items = item.get_menu_items ();
416+ } else if (item != null && item.is_valid () && item.show_menu (button, event.state)) {
417+ menu_items = item.get_menu_items (button, event.state);
418 if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0
419 && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0)
420 menu_items.add_all (get_item_debug_menu_items (item));
421
422=== modified file 'lib/Widgets/PreferencesWindow.vala'
423--- lib/Widgets/PreferencesWindow.vala 2016-03-09 08:51:55 +0000
424+++ lib/Widgets/PreferencesWindow.vala 2017-03-14 17:23:07 +0000
425@@ -76,6 +76,8 @@
426 Gtk.Switch sw_pressure_reveal;
427 [GtkChild]
428 Gtk.Switch sw_zoom_enabled;
429+ [GtkChild]
430+ Gtk.Switch sw_window_menu;
431
432 [GtkChild]
433 Gtk.IconView view_docklets;
434@@ -180,6 +182,9 @@
435 case "ZoomPercent":
436 adj_zoom_percent.value = prefs.ZoomPercent;
437 break;
438+ case "UseWindowMenu":
439+ sw_window_menu.set_active (prefs.UseWindowMenu);
440+ break;
441 // Ignored settings
442 case "DockItems":
443 break;
444@@ -276,6 +281,11 @@
445 }
446 }
447
448+ void window_menu_toggled (GLib.Object widget, ParamSpec param)
449+ {
450+ prefs.UseWindowMenu = ((Gtk.Switch) widget).get_active ();
451+ }
452+
453 void iconsize_changed (Gtk.Adjustment adj)
454 {
455 prefs.IconSize = (int) adj.value;
456@@ -328,6 +338,7 @@
457 sw_zoom_enabled.notify["active"].connect (zoom_enabled_toggled);
458 cb_alignment.changed.connect (alignment_changed);
459 cb_items_alignment.changed.connect (items_alignment_changed);
460+ sw_window_menu.notify["active"].connect (window_menu_toggled);
461 }
462
463 void disconnect_signals ()
464@@ -352,6 +363,7 @@
465 sw_zoom_enabled.notify["active"].disconnect (zoom_enabled_toggled);
466 cb_alignment.changed.disconnect (alignment_changed);
467 cb_items_alignment.changed.disconnect (items_alignment_changed);
468+ sw_window_menu.notify["active"].disconnect (window_menu_toggled);
469 }
470
471 void init_dock_tab ()
472@@ -401,6 +413,7 @@
473 cb_alignment.active_id = ((int) prefs.Alignment).to_string ();
474 cb_items_alignment.active_id = ((int) prefs.ItemsAlignment).to_string ();
475 cb_items_alignment.sensitive = (prefs.Alignment == Gtk.Align.FILL);
476+ sw_window_menu.set_active (prefs.UseWindowMenu);
477 }
478
479 void init_docklets_tab ()
480
481=== modified file 'lib/libplank.symbols'
482--- lib/libplank.symbols 2017-02-09 12:53:29 +0000
483+++ lib/libplank.symbols 2017-03-14 17:23:07 +0000
484@@ -157,7 +157,6 @@
485 plank_dock_element_create_menu_item
486 plank_dock_element_create_menu_item_with_pixbuf
487 plank_dock_element_get_AddTime
488-plank_dock_element_get_Button
489 plank_dock_element_get_ClickedAnimation
490 plank_dock_element_get_Container
491 plank_dock_element_get_dock
492@@ -184,7 +183,6 @@
493 plank_dock_element_reset_buffers
494 plank_dock_element_scrolled
495 plank_dock_element_set_AddTime
496-plank_dock_element_set_Button
497 plank_dock_element_set_ClickedAnimation
498 plank_dock_element_set_Container
499 plank_dock_element_set_HoveredAnimation
500@@ -265,6 +263,7 @@
501 plank_dock_item_set_Progress
502 plank_dock_item_set_ProgressVisible
503 plank_dock_item_set_State
504+plank_dock_item_show_menu
505 plank_dock_item_unset_move_state
506 plank_docklet_get_description
507 plank_docklet_get_icon
508@@ -303,6 +302,7 @@
509 plank_dock_preferences_get_TooltipsEnabled
510 plank_dock_preferences_get_type
511 plank_dock_preferences_get_UnhideDelay
512+plank_dock_preferences_get_UseWindowMenu
513 plank_dock_preferences_get_ZoomEnabled
514 plank_dock_preferences_get_ZoomPercent
515 plank_dock_preferences_increase_icon_size
516@@ -326,6 +326,7 @@
517 plank_dock_preferences_set_Theme
518 plank_dock_preferences_set_TooltipsEnabled
519 plank_dock_preferences_set_UnhideDelay
520+plank_dock_preferences_set_UseWindowMenu
521 plank_dock_preferences_set_ZoomEnabled
522 plank_dock_preferences_set_ZoomPercent
523 plank_dock_renderer_animate_items

Subscribers

People subscribed via source and target branches

to all changes: