Merge lp:~julien-spautz/granite/1157257 into lp:~elementary-pantheon/granite/granite

Proposed by Julien Spautz
Status: Merged
Approved by: David Gomes
Approved revision: no longer in the source branch.
Merged at revision: 544
Proposed branch: lp:~julien-spautz/granite/1157257
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 52 lines (+17/-10)
1 file modified
lib/Widgets/DynamicNotebook.vala (+17/-10)
To merge this branch: bzr merge lp:~julien-spautz/granite/1157257
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+154463@code.launchpad.net

Description of the change

Fixes bug #1157257 by implementing the following 2 shortcuts:

· duplicate tab on double click
· close other tabs on Shift + middle click

The first one was in the original spec: https://blueprints.launchpad.net/granite/+spec/tabbar

Dan confirmed the bug so I assume he agrees with the changes.

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

Align diff lines 10, 11, and 12 correctly according to line 9.

review: Needs Fixing
Revision history for this message
David Gomes (davidgomes) wrote :

Good code, works just fine, good job.

review: Approve
lp:~julien-spautz/granite/1157257 updated
544. By Julien Spautz

Fixed bug #1157257 - new mouse shortcuts for DynamicNotebook. Approved by David Gomes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/DynamicNotebook.vala'
2--- lib/Widgets/DynamicNotebook.vala 2013-03-19 14:51:46 +0000
3+++ lib/Widgets/DynamicNotebook.vala 2013-03-20 19:41:34 +0000
4@@ -20,6 +20,11 @@
5
6 namespace Granite.Widgets {
7
8+ // a mask to ignore modifiers like num lock or caps lock that are irrelevant to keyboard shortcuts
9+ internal const Gdk.ModifierType MODIFIER_MASK = (Gdk.ModifierType.SHIFT_MASK |
10+ Gdk.ModifierType.SUPER_MASK |
11+ Gdk.ModifierType.CONTROL_MASK |
12+ Gdk.ModifierType.MOD1_MASK);
13 /**
14 * This is a standard tab which can be used in a notebook to form a tabbed UI.
15 */
16@@ -134,24 +139,26 @@
17 duplicate_m.activate.connect (() => duplicate () );
18
19 lbl.button_press_event.connect ((e) => {
20- if (e.button == 2 && close.visible) { //if !close.visible, closable if false
21+
22+ e.state &= MODIFIER_MASK;
23+
24+ if (e.button == 2 && e.state == 0 && close.visible) {
25 this.closed ();
26- return true;
27+ } else if (e.button == 2 && e.state == Gdk.ModifierType.SHIFT_MASK && close.visible) {
28+ this.close_others ();
29+ } else if (e.button == 1 && e.type == Gdk.EventType.2BUTTON_PRESS && duplicate_m.visible) {
30+ this.duplicate ();
31 } else if (e.button == 3) {
32 menu.popup (null, null, null, 3, e.time);
33 uint num_tabs = (this.get_parent () as Gtk.Container).get_children ().length ();
34 close_other_m.label = ngettext (_("Close Other Tab"), _("Close Other Tabs"), num_tabs - 1);
35 if (num_tabs == 1)
36 close_other_m.sensitive = false;
37- return true;
38+ } else {
39+ return false;
40 }
41-
42- return false;
43- });
44-
45- /* Disable the double click signal on the tab */
46- this.button_press_event.connect ((e) => {
47- return (e.type == Gdk.EventType.2BUTTON_PRESS);
48+
49+ return true;
50 });
51
52 page_container.button_press_event.connect (() => { return true; }); //dont let clicks pass through

Subscribers

People subscribed via source and target branches