Merge lp:~shippo/plank/fix-1251625 into lp:plank
- fix-1251625
- Merge into trunk
Status: | Needs review |
---|---|
Proposed branch: | lp:~shippo/plank/fix-1251625 |
Merge into: | lp:plank |
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Peter Feichtinger (community) | Needs Resubmitting | ||
Rico Tzschichholz | Needs Information | ||
Review via email: mp+317909@code.launchpad.net |
Commit message
Description of the change
This fixes Bug #1251625 (partially).
There are two related changes in this branch which could be merged individually, but I think they belong together:
* First, there is now a new preference setting that, when enabled, causes application items to show their menu when left clicked, instead of bringing all windows up. This way a window to be brought up can be selected from the menu without having to right click.
* Second, the application item menu is changed to indicate the currently active window (in bold font) and allow it to be minimized by selecting it, and to indicate minimized windows by dimming their items slightly.
There is no window preview as requested in the original bug report, but I think this change makes the dock way more usable (and doesn't change the default behavior when disabled, aside from the new menu item styles).
Peter Feichtinger (shippo) wrote : | # |
Hm, I don't know how to merge several commits.
Should I just revert the branch and make new commits, or is there some clever way to achieve that?
You are right concerning the menu, I will try and exclude the other entries.
And I just realized that I will then need new commits anyway :-)
As for the coding style, I followed what was already there as closely as possible.
If you want me to break consistency I will, but I'd rather not.
Peter Feichtinger (shippo) wrote : | # |
Never mind about the coding style, I see what you mean.
Peter Feichtinger (shippo) wrote : | # |
So, I changed the implementation but now my local branch and the one on here have diverged, because I uncommitted the changed in my local branch before making the requested changes.
How do I fix this, should I just force push (by passing --override, I don't know if this will work anyway), or is there a smarter move?
Rico Tzschichholz (ricotz) wrote : | # |
Yes, you need to use "bzr push --overwrite lp:~shippo/plank/fix-1251625" to push your altered branch.
- 1589. By Peter Feichtinger
-
Add support for switching windows when an application item is clicked.
* It should be possible for a DockItem to show a menu based on the
current number of open windows, so a new method in DockItem is used in
DockWindow to check whether an item wants to show a menu when any
button is pressed.
* ApplicationDockItem is changed to show the window menu on left click,
when more than one window is open for the application.
* A new preference switch for using the window menu is added: when
'Use Window Menu' is enabled, left clicking on an item with multiple
windows will open the item menu, allowing selection of only one window
to show. When disabled, clicking has the default behavior. - 1590. By Peter Feichtinger
-
Add indication for active and minimized windows and allow mimizing.
This adds an indication in the window menu for the currently active
window, as well as for minimized windows. The active window is minimized
when selected.
Peter Feichtinger (shippo) wrote : | # |
Ooh nice, launchpad already put my changed branch here :-)
So, I implemented the changes you requested:
* The menu shown when multiple windows are open only contains the windows. This is done by passing the button and modifiers to get_menu_items, which presumably breaks ABI compatibility.
* I double checked that I followed the coding style, I hope this time I really did ;-)
- 1591. By Peter Feichtinger
-
Fix window menu showing with only one item.
Peter Feichtinger (shippo) wrote : | # |
Do I need to resubmit?
Rico Tzschichholz (ricotz) wrote : | # |
Sorry, I still have not get around to take a closer look at this. So no need for action from your side yet.
Unmerged revisions
- 1591. By Peter Feichtinger
-
Fix window menu showing with only one item.
- 1590. By Peter Feichtinger
-
Add indication for active and minimized windows and allow mimizing.
This adds an indication in the window menu for the currently active
window, as well as for minimized windows. The active window is minimized
when selected. - 1589. By Peter Feichtinger
-
Add support for switching windows when an application item is clicked.
* It should be possible for a DockItem to show a menu based on the
current number of open windows, so a new method in DockItem is used in
DockWindow to check whether an item wants to show a menu when any
button is pressed.
* ApplicationDockItem is changed to show the window menu on left click,
when more than one window is open for the application.
* A new preference switch for using the window menu is added: when
'Use Window Menu' is enabled, left clicking on an item with multiple
windows will open the item menu, allowing selection of only one window
to show. When disabled, clicking has the default behavior.
Preview Diff
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 12:02:51 +0000 | |||
4 | @@ -128,6 +128,11 @@ | |||
5 | 128 | <_summary>Dock unhide delay</_summary> | 128 | <_summary>Dock unhide delay</_summary> |
6 | 129 | <_description>Length of the delay before unhiding the dock, in milliseconds.</_description> | 129 | <_description>Length of the delay before unhiding the dock, in milliseconds.</_description> |
7 | 130 | </key> | 130 | </key> |
8 | 131 | <key name="use-window-menu" type="b"> | ||
9 | 132 | <default>false</default> | ||
10 | 133 | <_summary>Use window menu when multiple windows are open</_summary> | ||
11 | 134 | <_description>If true, clicking on an item with multiple windows will show the menu instead of activating all windows.</_description> | ||
12 | 135 | </key> | ||
13 | 131 | <key name="zoom-enabled" type="b"> | 136 | <key name="zoom-enabled" type="b"> |
14 | 132 | <default>false</default> | 137 | <default>false</default> |
15 | 133 | <_summary>Zoom dock items when hovered</_summary> | 138 | <_summary>Zoom dock items when hovered</_summary> |
16 | 134 | 139 | ||
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 12:02:51 +0000 | |||
20 | @@ -554,6 +554,30 @@ | |||
21 | 554 | </packing> | 554 | </packing> |
22 | 555 | </child> | 555 | </child> |
23 | 556 | <child> | 556 | <child> |
24 | 557 | <object class="GtkLabel" id="l_window_menu"> | ||
25 | 558 | <property name="visible">True</property> | ||
26 | 559 | <property name="can_focus">False</property> | ||
27 | 560 | <property name="halign">end</property> | ||
28 | 561 | <property name="label" translatable="yes">Use Window Menu:</property> | ||
29 | 562 | </object> | ||
30 | 563 | <packing> | ||
31 | 564 | <property name="left_attach">2</property> | ||
32 | 565 | <property name="top_attach">6</property> | ||
33 | 566 | </packing> | ||
34 | 567 | </child> | ||
35 | 568 | <child> | ||
36 | 569 | <object class="GtkSwitch" id="sw_window_menu"> | ||
37 | 570 | <property name="visible">True</property> | ||
38 | 571 | <property name="can_focus">True</property> | ||
39 | 572 | <property name="halign">start</property> | ||
40 | 573 | <property name="valign">center</property> | ||
41 | 574 | </object> | ||
42 | 575 | <packing> | ||
43 | 576 | <property name="left_attach">3</property> | ||
44 | 577 | <property name="top_attach">6</property> | ||
45 | 578 | </packing> | ||
46 | 579 | </child> | ||
47 | 580 | <child> | ||
48 | 557 | <placeholder/> | 581 | <placeholder/> |
49 | 558 | </child> | 582 | </child> |
50 | 559 | <child> | 583 | <child> |
51 | 560 | 584 | ||
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 12:02:51 +0000 | |||
55 | @@ -158,7 +158,7 @@ | |||
56 | 158 | return AnimationType.NONE; | 158 | return AnimationType.NONE; |
57 | 159 | } | 159 | } |
58 | 160 | 160 | ||
60 | 161 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 161 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) |
61 | 162 | { | 162 | { |
62 | 163 | var items = new Gee.ArrayList<Gtk.MenuItem> (); | 163 | var items = new Gee.ArrayList<Gtk.MenuItem> (); |
63 | 164 | 164 | ||
64 | 165 | 165 | ||
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 12:02:51 +0000 | |||
68 | @@ -246,7 +246,7 @@ | |||
69 | 246 | render_file_onto_context (cr, current_theme + "/clock-frame.svg", radius * 2); | 246 | render_file_onto_context (cr, current_theme + "/clock-frame.svg", radius * 2); |
70 | 247 | } | 247 | } |
71 | 248 | 248 | ||
73 | 249 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 249 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) |
74 | 250 | { | 250 | { |
75 | 251 | unowned ClockPreferences prefs = (ClockPreferences) Prefs; | 251 | unowned ClockPreferences prefs = (ClockPreferences) Prefs; |
76 | 252 | var items = new Gee.ArrayList<Gtk.MenuItem> (); | 252 | var items = new Gee.ArrayList<Gtk.MenuItem> (); |
77 | 253 | 253 | ||
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 12:02:51 +0000 | |||
81 | @@ -159,7 +159,7 @@ | |||
82 | 159 | return trashed; | 159 | return trashed; |
83 | 160 | } | 160 | } |
84 | 161 | 161 | ||
86 | 162 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 162 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) |
87 | 163 | { | 163 | { |
88 | 164 | var items = new Gee.ArrayList<Gtk.MenuItem> (); | 164 | var items = new Gee.ArrayList<Gtk.MenuItem> (); |
89 | 165 | 165 | ||
90 | 166 | 166 | ||
91 | === modified file 'lib/DockPreferences.vala' | |||
92 | --- lib/DockPreferences.vala 2016-03-04 15:54:48 +0000 | |||
93 | +++ lib/DockPreferences.vala 2017-03-14 12:02:51 +0000 | |||
94 | @@ -30,6 +30,9 @@ | |||
95 | 30 | public const int MIN_ICON_ZOOM = 100; | 30 | public const int MIN_ICON_ZOOM = 100; |
96 | 31 | public const int MAX_ICON_ZOOM = 200; | 31 | public const int MAX_ICON_ZOOM = 200; |
97 | 32 | 32 | ||
98 | 33 | [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 | 34 | public bool UseWindowMenu { get; set; } | ||
100 | 35 | |||
101 | 33 | [Description(nick = "current-workspace-only", blurb = "Whether to show only windows of the current workspace.")] | 36 | [Description(nick = "current-workspace-only", blurb = "Whether to show only windows of the current workspace.")] |
102 | 34 | public bool CurrentWorkspaceOnly { get; set; } | 37 | public bool CurrentWorkspaceOnly { get; set; } |
103 | 35 | 38 | ||
104 | 36 | 39 | ||
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 12:02:51 +0000 | |||
108 | @@ -38,6 +38,9 @@ | |||
109 | 38 | 38 | ||
110 | 39 | private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"}; | 39 | private const string[] SUPPORTED_GETTEXT_DOMAINS_KEYS = {"X-Ubuntu-Gettext-Domain", "X-GNOME-Gettext-Domain"}; |
111 | 40 | 40 | ||
112 | 41 | private const Gdk.ModifierType ANY_MODIFIER = | ||
113 | 42 | Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK | Gdk.ModifierType.MOD1_MASK; | ||
114 | 43 | |||
115 | 41 | /** | 44 | /** |
116 | 42 | * Signal fired when the item's 'keep in dock' menu item is pressed. | 45 | * Signal fired when the item's 'keep in dock' menu item is pressed. |
117 | 43 | */ | 46 | */ |
118 | @@ -393,9 +396,27 @@ | |||
119 | 393 | /** | 396 | /** |
120 | 394 | * {@inheritDoc} | 397 | * {@inheritDoc} |
121 | 395 | */ | 398 | */ |
123 | 396 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 399 | public override bool show_menu (PopupButton button, Gdk.ModifierType modifiers) |
124 | 400 | { | ||
125 | 401 | bool useWindowMenu = get_dock ().prefs.UseWindowMenu; | ||
126 | 402 | if (button == PopupButton.LEFT && (modifiers & ANY_MODIFIER) == 0 && App != null && useWindowMenu) { | ||
127 | 403 | var count = 0; | ||
128 | 404 | foreach (var view in App.get_windows ()) { | ||
129 | 405 | unowned Bamf.Window? window = (view as Bamf.Window); | ||
130 | 406 | if (window != null && window.get_transient () == null && ++count > 1) | ||
131 | 407 | return true; | ||
132 | 408 | } | ||
133 | 409 | } | ||
134 | 410 | return base.show_menu (button, modifiers); | ||
135 | 411 | } | ||
136 | 412 | |||
137 | 413 | /** | ||
138 | 414 | * {@inheritDoc} | ||
139 | 415 | */ | ||
140 | 416 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) | ||
141 | 397 | { | 417 | { |
142 | 398 | var items = new Gee.ArrayList<Gtk.MenuItem> (); | 418 | var items = new Gee.ArrayList<Gtk.MenuItem> (); |
143 | 419 | var event_time = Gtk.get_current_event_time (); | ||
144 | 399 | 420 | ||
145 | 400 | GLib.List<unowned Bamf.View>? windows = null; | 421 | GLib.List<unowned Bamf.View>? windows = null; |
146 | 401 | if (App != null) | 422 | if (App != null) |
147 | @@ -405,51 +426,52 @@ | |||
148 | 405 | if (windows != null) | 426 | if (windows != null) |
149 | 406 | window_count = windows.length (); | 427 | window_count = windows.length (); |
150 | 407 | 428 | ||
168 | 408 | unowned DefaultApplicationDockItemProvider? default_provider = (Container as DefaultApplicationDockItemProvider); | 429 | if (button == PopupButton.RIGHT) { |
169 | 409 | if (default_provider != null | 430 | unowned DefaultApplicationDockItemProvider? default_provider = (Container as DefaultApplicationDockItemProvider); |
170 | 410 | && !default_provider.Prefs.LockItems | 431 | if (default_provider != null |
171 | 411 | && !is_window ()) { | 432 | && !default_provider.Prefs.LockItems |
172 | 412 | var item = new Gtk.CheckMenuItem.with_mnemonic (_("_Keep in Dock")); | 433 | && !is_window ()) { |
173 | 413 | item.active = !(this is TransientDockItem); | 434 | var item = new Gtk.CheckMenuItem.with_mnemonic (_("_Keep in Dock")); |
174 | 414 | item.activate.connect (() => pin_launcher ()); | 435 | item.active = !(this is TransientDockItem); |
175 | 415 | items.add (item); | 436 | item.activate.connect (() => pin_launcher ()); |
176 | 416 | } | 437 | items.add (item); |
177 | 417 | 438 | } | |
178 | 418 | var event_time = Gtk.get_current_event_time (); | 439 | |
179 | 419 | if (is_running () && window_count > 0) { | 440 | if (is_running () && window_count > 0) { |
180 | 420 | var item = create_menu_item ((window_count > 1 ? _("_Close All") : _("_Close")), "window-close-symbolic;;window-close"); | 441 | var item = create_menu_item ((window_count > 1 ? _("_Close All") : _("_Close")), "window-close-symbolic;;window-close"); |
181 | 421 | item.activate.connect (() => WindowControl.close_all (App, event_time)); | 442 | item.activate.connect (() => WindowControl.close_all (App, event_time)); |
182 | 422 | items.add (item); | 443 | items.add (item); |
183 | 423 | } | 444 | } |
184 | 424 | 445 | ||
185 | 425 | #if HAVE_DBUSMENU | 446 | #if HAVE_DBUSMENU |
195 | 426 | if (Quicklist != null) { | 447 | if (Quicklist != null) { |
196 | 427 | if (items.size > 0) | 448 | if (items.size > 0) |
197 | 428 | items.add (new Gtk.SeparatorMenuItem ()); | 449 | items.add (new Gtk.SeparatorMenuItem ()); |
198 | 429 | 450 | ||
199 | 430 | var dm_root = Quicklist.get_root (); | 451 | var dm_root = Quicklist.get_root (); |
200 | 431 | if (dm_root != null) { | 452 | if (dm_root != null) { |
201 | 432 | Logger.verbose ("%i quicklist menuitems for %s", dm_root.get_children ().length (), Text); | 453 | Logger.verbose ("%i quicklist menuitems for %s", dm_root.get_children ().length (), Text); |
202 | 433 | foreach (var menuitem in dm_root.get_children ()) | 454 | foreach (var menuitem in dm_root.get_children ()) |
203 | 434 | items.add (Quicklist.menuitem_get (menuitem)); | 455 | items.add (Quicklist.menuitem_get (menuitem)); |
204 | 456 | } | ||
205 | 435 | } | 457 | } |
206 | 436 | } | ||
207 | 437 | #endif | 458 | #endif |
208 | 438 | |||
209 | 439 | if (!is_window () && actions.size > 0) { | ||
210 | 440 | if (items.size > 0) | ||
211 | 441 | items.add (new Gtk.SeparatorMenuItem ()); | ||
212 | 442 | 459 | ||
215 | 443 | foreach (var s in actions) { | 460 | if (!is_window () && actions.size > 0) { |
216 | 444 | var values = actions_map.get (s).split (";;"); | 461 | if (items.size > 0) |
217 | 462 | items.add (new Gtk.SeparatorMenuItem ()); | ||
218 | 445 | 463 | ||
226 | 446 | var item = create_menu_item (s, values[1], true); | 464 | foreach (var s in actions) { |
227 | 447 | item.activate.connect (() => { | 465 | var values = actions_map.get (s).split (";;"); |
228 | 448 | try { | 466 | |
229 | 449 | AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null); | 467 | var item = create_menu_item (s, values[1], true); |
230 | 450 | } catch { } | 468 | item.activate.connect (() => { |
231 | 451 | }); | 469 | try { |
232 | 452 | items.add (item); | 470 | AppInfo.create_from_commandline (values[0], null, AppInfoCreateFlags.NONE).launch (null, null); |
233 | 471 | } catch { } | ||
234 | 472 | }); | ||
235 | 473 | items.add (item); | ||
236 | 474 | } | ||
237 | 453 | } | 475 | } |
238 | 454 | } | 476 | } |
239 | 455 | 477 | ||
240 | @@ -472,10 +494,21 @@ | |||
241 | 472 | else | 494 | else |
242 | 473 | window_item = create_literal_menu_item (window_name, Icon); | 495 | window_item = create_literal_menu_item (window_name, Icon); |
243 | 474 | 496 | ||
247 | 475 | if (window.is_active ()) | 497 | if (window.is_active ()) { |
248 | 476 | window_item.set_sensitive (false); | 498 | window_item.activate.connect (() => WindowControl.minimize_window (window, event_time)); |
249 | 477 | else | 499 | |
250 | 500 | unowned Gtk.Label? label = (window_item.get_child () as Gtk.Label); | ||
251 | 501 | if (label != null) { | ||
252 | 502 | Pango.AttrList attrs = new Pango.AttrList (); | ||
253 | 503 | attrs.change (Pango.attr_weight_new (Pango.Weight.BOLD)); | ||
254 | 504 | label.set_attributes (attrs); | ||
255 | 505 | } | ||
256 | 506 | } else { | ||
257 | 478 | window_item.activate.connect (() => WindowControl.focus_window (window, event_time)); | 507 | window_item.activate.connect (() => WindowControl.focus_window (window, event_time)); |
258 | 508 | |||
259 | 509 | if (WindowControl.is_window_minimized (window)) | ||
260 | 510 | window_item.set_opacity (0.5); | ||
261 | 511 | } | ||
262 | 479 | 512 | ||
263 | 480 | items.add (window_item); | 513 | items.add (window_item); |
264 | 481 | } | 514 | } |
265 | 482 | 515 | ||
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 12:02:51 +0000 | |||
269 | @@ -54,11 +54,6 @@ | |||
270 | 54 | public bool IsVisible { get; set; default = true; } | 54 | public bool IsVisible { get; set; default = true; } |
271 | 55 | 55 | ||
272 | 56 | /** | 56 | /** |
273 | 57 | * The buttons this item shows popup menus for. | ||
274 | 58 | */ | ||
275 | 59 | public PopupButton Button { get; protected set; default = PopupButton.RIGHT; } | ||
276 | 60 | |||
277 | 61 | /** | ||
278 | 62 | * The animation to show for the item's last click event. | 57 | * The animation to show for the item's last click event. |
279 | 63 | */ | 58 | */ |
280 | 64 | public AnimationType ClickedAnimation { get; protected set; default = AnimationType.NONE; } | 59 | public AnimationType ClickedAnimation { get; protected set; default = AnimationType.NONE; } |
281 | @@ -211,9 +206,11 @@ | |||
282 | 211 | /** | 206 | /** |
283 | 212 | * Returns a list of the item's menu items. | 207 | * Returns a list of the item's menu items. |
284 | 213 | * | 208 | * |
285 | 209 | * @param button The button that is pressed. | ||
286 | 210 | * @param modifiers The modifiers pressed. | ||
287 | 214 | * @return the item's menu items | 211 | * @return the item's menu items |
288 | 215 | */ | 212 | */ |
290 | 216 | public virtual Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 213 | public virtual Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) |
291 | 217 | { | 214 | { |
292 | 218 | return new Gee.ArrayList<Gtk.MenuItem> (); | 215 | return new Gee.ArrayList<Gtk.MenuItem> (); |
293 | 219 | } | 216 | } |
294 | 220 | 217 | ||
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 12:02:51 +0000 | |||
298 | @@ -600,6 +600,18 @@ | |||
299 | 600 | } | 600 | } |
300 | 601 | 601 | ||
301 | 602 | /** | 602 | /** |
302 | 603 | * Check whether the menu should be shown. | ||
303 | 604 | * | ||
304 | 605 | * @param button The button that is pressed. | ||
305 | 606 | * @param modifiers The modifiers pressed. | ||
306 | 607 | * @return Whether the menu should be shown. | ||
307 | 608 | */ | ||
308 | 609 | public virtual bool show_menu (PopupButton button, Gdk.ModifierType modifiers) | ||
309 | 610 | { | ||
310 | 611 | return button == PopupButton.RIGHT; | ||
311 | 612 | } | ||
312 | 613 | |||
313 | 614 | /** | ||
314 | 603 | * Copy all property value of this dockitem instance to target instance. | 615 | * Copy all property value of this dockitem instance to target instance. |
315 | 604 | * | 616 | * |
316 | 605 | * @param target the dockitem to copy the values to | 617 | * @param target the dockitem to copy the values to |
317 | 606 | 618 | ||
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 12:02:51 +0000 | |||
321 | @@ -96,8 +96,6 @@ | |||
322 | 96 | 96 | ||
323 | 97 | // pop up the dir contents on a left click too | 97 | // pop up the dir contents on a left click too |
324 | 98 | if (OwnedFile.query_file_type (0) == FileType.DIRECTORY) { | 98 | if (OwnedFile.query_file_type (0) == FileType.DIRECTORY) { |
325 | 99 | Button = PopupButton.RIGHT | PopupButton.LEFT; | ||
326 | 100 | |||
327 | 101 | try { | 99 | try { |
328 | 102 | dir_monitor = OwnedFile.monitor_directory (0); | 100 | dir_monitor = OwnedFile.monitor_directory (0); |
329 | 103 | dir_monitor.changed.connect (handle_dir_changed); | 101 | dir_monitor.changed.connect (handle_dir_changed); |
330 | @@ -259,7 +257,16 @@ | |||
331 | 259 | /** | 257 | /** |
332 | 260 | * {@inheritDoc} | 258 | * {@inheritDoc} |
333 | 261 | */ | 259 | */ |
335 | 262 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 260 | public override bool show_menu (PopupButton button, Gdk.ModifierType modifiers) |
336 | 261 | { | ||
337 | 262 | return button == PopupButton.RIGHT | ||
338 | 263 | || (OwnedFile.query_file_type (0) == FileType.DIRECTORY && button == PopupButton.LEFT); | ||
339 | 264 | } | ||
340 | 265 | |||
341 | 266 | /** | ||
342 | 267 | * {@inheritDoc} | ||
343 | 268 | */ | ||
344 | 269 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) | ||
345 | 263 | { | 270 | { |
346 | 264 | if (OwnedFile.query_file_type (0) == FileType.DIRECTORY) | 271 | if (OwnedFile.query_file_type (0) == FileType.DIRECTORY) |
347 | 265 | return get_dir_menu_items (); | 272 | return get_dir_menu_items (); |
348 | 266 | 273 | ||
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 12:02:51 +0000 | |||
352 | @@ -66,7 +66,7 @@ | |||
353 | 66 | /** | 66 | /** |
354 | 67 | * {@inheritDoc} | 67 | * {@inheritDoc} |
355 | 68 | */ | 68 | */ |
357 | 69 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items () | 69 | public override Gee.ArrayList<Gtk.MenuItem> get_menu_items (PopupButton button, Gdk.ModifierType modifiers) |
358 | 70 | { | 70 | { |
359 | 71 | var items = new Gee.ArrayList<Gtk.MenuItem> (); | 71 | var items = new Gee.ArrayList<Gtk.MenuItem> (); |
360 | 72 | 72 | ||
361 | 73 | 73 | ||
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 12:02:51 +0000 | |||
365 | @@ -139,6 +139,13 @@ | |||
366 | 139 | return pbuf; | 139 | return pbuf; |
367 | 140 | } | 140 | } |
368 | 141 | 141 | ||
369 | 142 | public static bool is_window_minimized (Bamf.Window window) | ||
370 | 143 | { | ||
371 | 144 | Wnck.Screen.get_default (); | ||
372 | 145 | unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ()); | ||
373 | 146 | return w.is_minimized (); | ||
374 | 147 | } | ||
375 | 148 | |||
376 | 142 | public static bool has_maximized_window (Bamf.Application app) | 149 | public static bool has_maximized_window (Bamf.Application app) |
377 | 143 | { | 150 | { |
378 | 144 | Wnck.Screen.get_default (); | 151 | Wnck.Screen.get_default (); |
379 | @@ -251,6 +258,19 @@ | |||
380 | 251 | center_and_focus_window (w, event_time); | 258 | center_and_focus_window (w, event_time); |
381 | 252 | } | 259 | } |
382 | 253 | 260 | ||
383 | 261 | public static void minimize_window (Bamf.Window window, uint32 event_time) | ||
384 | 262 | { | ||
385 | 263 | Wnck.Screen.get_default (); | ||
386 | 264 | unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ()); | ||
387 | 265 | |||
388 | 266 | warn_if_fail (w != null); | ||
389 | 267 | |||
390 | 268 | if (w == null) | ||
391 | 269 | return; | ||
392 | 270 | |||
393 | 271 | w.minimize (); | ||
394 | 272 | } | ||
395 | 273 | |||
396 | 254 | static int find_active_xid_index (Array<uint32>? xids) | 274 | static int find_active_xid_index (Array<uint32>? xids) |
397 | 255 | { | 275 | { |
398 | 256 | var i = 0; | 276 | var i = 0; |
399 | 257 | 277 | ||
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 12:02:51 +0000 | |||
403 | @@ -606,14 +606,14 @@ | |||
404 | 606 | 606 | ||
405 | 607 | if ((button & PopupButton.RIGHT) != 0 | 607 | if ((button & PopupButton.RIGHT) != 0 |
406 | 608 | && (item == null || (event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) { | 608 | && (item == null || (event.state & Gdk.ModifierType.CONTROL_MASK) != 0)) { |
408 | 609 | menu_items = Factory.item_factory.get_item_for_dock ().get_menu_items (); | 609 | menu_items = Factory.item_factory.get_item_for_dock ().get_menu_items (button, event.state); |
409 | 610 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0 | 610 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0 |
410 | 611 | && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0) | 611 | && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0) |
411 | 612 | menu_items.add_all (get_dock_debug_menu_items (controller)); | 612 | menu_items.add_all (get_dock_debug_menu_items (controller)); |
412 | 613 | set_hovered_provider (null); | 613 | set_hovered_provider (null); |
413 | 614 | set_hovered (null); | 614 | set_hovered (null); |
416 | 615 | } else if (item != null && item.is_valid () && (item.Button & button) != 0) { | 615 | } else if (item != null && item.is_valid () && item.show_menu (button, event.state)) { |
417 | 616 | menu_items = item.get_menu_items (); | 616 | menu_items = item.get_menu_items (button, event.state); |
418 | 617 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0 | 617 | if ((event.state & Gdk.ModifierType.MOD1_MASK) != 0 |
419 | 618 | && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0) | 618 | && (event.state & Gdk.ModifierType.SHIFT_MASK) != 0) |
420 | 619 | menu_items.add_all (get_item_debug_menu_items (item)); | 619 | menu_items.add_all (get_item_debug_menu_items (item)); |
421 | 620 | 620 | ||
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 12:02:51 +0000 | |||
425 | @@ -76,6 +76,8 @@ | |||
426 | 76 | Gtk.Switch sw_pressure_reveal; | 76 | Gtk.Switch sw_pressure_reveal; |
427 | 77 | [GtkChild] | 77 | [GtkChild] |
428 | 78 | Gtk.Switch sw_zoom_enabled; | 78 | Gtk.Switch sw_zoom_enabled; |
429 | 79 | [GtkChild] | ||
430 | 80 | Gtk.Switch sw_window_menu; | ||
431 | 79 | 81 | ||
432 | 80 | [GtkChild] | 82 | [GtkChild] |
433 | 81 | Gtk.IconView view_docklets; | 83 | Gtk.IconView view_docklets; |
434 | @@ -180,6 +182,9 @@ | |||
435 | 180 | case "ZoomPercent": | 182 | case "ZoomPercent": |
436 | 181 | adj_zoom_percent.value = prefs.ZoomPercent; | 183 | adj_zoom_percent.value = prefs.ZoomPercent; |
437 | 182 | break; | 184 | break; |
438 | 185 | case "UseWindowMenu": | ||
439 | 186 | sw_window_menu.set_active (prefs.UseWindowMenu); | ||
440 | 187 | break; | ||
441 | 183 | // Ignored settings | 188 | // Ignored settings |
442 | 184 | case "DockItems": | 189 | case "DockItems": |
443 | 185 | break; | 190 | break; |
444 | @@ -276,6 +281,11 @@ | |||
445 | 276 | } | 281 | } |
446 | 277 | } | 282 | } |
447 | 278 | 283 | ||
448 | 284 | void window_menu_toggled (GLib.Object widget, ParamSpec param) | ||
449 | 285 | { | ||
450 | 286 | prefs.UseWindowMenu = ((Gtk.Switch) widget).get_active (); | ||
451 | 287 | } | ||
452 | 288 | |||
453 | 279 | void iconsize_changed (Gtk.Adjustment adj) | 289 | void iconsize_changed (Gtk.Adjustment adj) |
454 | 280 | { | 290 | { |
455 | 281 | prefs.IconSize = (int) adj.value; | 291 | prefs.IconSize = (int) adj.value; |
456 | @@ -328,6 +338,7 @@ | |||
457 | 328 | sw_zoom_enabled.notify["active"].connect (zoom_enabled_toggled); | 338 | sw_zoom_enabled.notify["active"].connect (zoom_enabled_toggled); |
458 | 329 | cb_alignment.changed.connect (alignment_changed); | 339 | cb_alignment.changed.connect (alignment_changed); |
459 | 330 | cb_items_alignment.changed.connect (items_alignment_changed); | 340 | cb_items_alignment.changed.connect (items_alignment_changed); |
460 | 341 | sw_window_menu.notify["active"].connect (window_menu_toggled); | ||
461 | 331 | } | 342 | } |
462 | 332 | 343 | ||
463 | 333 | void disconnect_signals () | 344 | void disconnect_signals () |
464 | @@ -352,6 +363,7 @@ | |||
465 | 352 | sw_zoom_enabled.notify["active"].disconnect (zoom_enabled_toggled); | 363 | sw_zoom_enabled.notify["active"].disconnect (zoom_enabled_toggled); |
466 | 353 | cb_alignment.changed.disconnect (alignment_changed); | 364 | cb_alignment.changed.disconnect (alignment_changed); |
467 | 354 | cb_items_alignment.changed.disconnect (items_alignment_changed); | 365 | cb_items_alignment.changed.disconnect (items_alignment_changed); |
468 | 366 | sw_window_menu.notify["active"].disconnect (window_menu_toggled); | ||
469 | 355 | } | 367 | } |
470 | 356 | 368 | ||
471 | 357 | void init_dock_tab () | 369 | void init_dock_tab () |
472 | @@ -401,6 +413,7 @@ | |||
473 | 401 | cb_alignment.active_id = ((int) prefs.Alignment).to_string (); | 413 | cb_alignment.active_id = ((int) prefs.Alignment).to_string (); |
474 | 402 | cb_items_alignment.active_id = ((int) prefs.ItemsAlignment).to_string (); | 414 | cb_items_alignment.active_id = ((int) prefs.ItemsAlignment).to_string (); |
475 | 403 | cb_items_alignment.sensitive = (prefs.Alignment == Gtk.Align.FILL); | 415 | cb_items_alignment.sensitive = (prefs.Alignment == Gtk.Align.FILL); |
476 | 416 | sw_window_menu.set_active (prefs.UseWindowMenu); | ||
477 | 404 | } | 417 | } |
478 | 405 | 418 | ||
479 | 406 | void init_docklets_tab () | 419 | void init_docklets_tab () |
480 | 407 | 420 | ||
481 | === modified file 'lib/libplank.symbols' | |||
482 | --- lib/libplank.symbols 2017-02-09 12:53:29 +0000 | |||
483 | +++ lib/libplank.symbols 2017-03-14 12:02:51 +0000 | |||
484 | @@ -157,7 +157,6 @@ | |||
485 | 157 | plank_dock_element_create_menu_item | 157 | plank_dock_element_create_menu_item |
486 | 158 | plank_dock_element_create_menu_item_with_pixbuf | 158 | plank_dock_element_create_menu_item_with_pixbuf |
487 | 159 | plank_dock_element_get_AddTime | 159 | plank_dock_element_get_AddTime |
488 | 160 | plank_dock_element_get_Button | ||
489 | 161 | plank_dock_element_get_ClickedAnimation | 160 | plank_dock_element_get_ClickedAnimation |
490 | 162 | plank_dock_element_get_Container | 161 | plank_dock_element_get_Container |
491 | 163 | plank_dock_element_get_dock | 162 | plank_dock_element_get_dock |
492 | @@ -184,7 +183,6 @@ | |||
493 | 184 | plank_dock_element_reset_buffers | 183 | plank_dock_element_reset_buffers |
494 | 185 | plank_dock_element_scrolled | 184 | plank_dock_element_scrolled |
495 | 186 | plank_dock_element_set_AddTime | 185 | plank_dock_element_set_AddTime |
496 | 187 | plank_dock_element_set_Button | ||
497 | 188 | plank_dock_element_set_ClickedAnimation | 186 | plank_dock_element_set_ClickedAnimation |
498 | 189 | plank_dock_element_set_Container | 187 | plank_dock_element_set_Container |
499 | 190 | plank_dock_element_set_HoveredAnimation | 188 | plank_dock_element_set_HoveredAnimation |
500 | @@ -265,6 +263,7 @@ | |||
501 | 265 | plank_dock_item_set_Progress | 263 | plank_dock_item_set_Progress |
502 | 266 | plank_dock_item_set_ProgressVisible | 264 | plank_dock_item_set_ProgressVisible |
503 | 267 | plank_dock_item_set_State | 265 | plank_dock_item_set_State |
504 | 266 | plank_dock_item_show_menu | ||
505 | 268 | plank_dock_item_unset_move_state | 267 | plank_dock_item_unset_move_state |
506 | 269 | plank_docklet_get_description | 268 | plank_docklet_get_description |
507 | 270 | plank_docklet_get_icon | 269 | plank_docklet_get_icon |
508 | @@ -303,6 +302,7 @@ | |||
509 | 303 | plank_dock_preferences_get_TooltipsEnabled | 302 | plank_dock_preferences_get_TooltipsEnabled |
510 | 304 | plank_dock_preferences_get_type | 303 | plank_dock_preferences_get_type |
511 | 305 | plank_dock_preferences_get_UnhideDelay | 304 | plank_dock_preferences_get_UnhideDelay |
512 | 305 | plank_dock_preferences_get_UseWindowMenu | ||
513 | 306 | plank_dock_preferences_get_ZoomEnabled | 306 | plank_dock_preferences_get_ZoomEnabled |
514 | 307 | plank_dock_preferences_get_ZoomPercent | 307 | plank_dock_preferences_get_ZoomPercent |
515 | 308 | plank_dock_preferences_increase_icon_size | 308 | plank_dock_preferences_increase_icon_size |
516 | @@ -326,6 +326,7 @@ | |||
517 | 326 | plank_dock_preferences_set_Theme | 326 | plank_dock_preferences_set_Theme |
518 | 327 | plank_dock_preferences_set_TooltipsEnabled | 327 | plank_dock_preferences_set_TooltipsEnabled |
519 | 328 | plank_dock_preferences_set_UnhideDelay | 328 | plank_dock_preferences_set_UnhideDelay |
520 | 329 | plank_dock_preferences_set_UseWindowMenu | ||
521 | 329 | plank_dock_preferences_set_ZoomEnabled | 330 | plank_dock_preferences_set_ZoomEnabled |
522 | 330 | plank_dock_preferences_set_ZoomPercent | 331 | plank_dock_preferences_set_ZoomPercent |
523 | 331 | plank_dock_renderer_animate_items | 332 | plank_dock_renderer_animate_items |
Overall this looks good, besides some minor code-style issues.
I would prefer if the special left-click menu would *only* contain the window-listing.
Also making it *2* commits is sufficient:
* the menuitem-style change
* the new menu including its requirements
- don't be lazy with variable names like "lbl" -> "label"
- prefix connectors in if-conditions in case of line-breaks