Merge lp:~junrrein/granite/fix-1196721 into lp:~elementary-pantheon/granite/granite

Proposed by Julián Unrrein
Status: Merged
Approved by: David Gomes
Approved revision: 598
Merged at revision: 609
Proposed branch: lp:~junrrein/granite/fix-1196721
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 79 lines (+16/-15)
1 file modified
lib/Widgets/DynamicNotebook.vala (+16/-15)
To merge this branch: bzr merge lp:~junrrein/granite/fix-1196721
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+174846@code.launchpad.net

Commit message

[DynamicNotebook] Let tabs handle clicks over their icons and spinners to fix bug #1196721.

Description of the change

[DynamicNotebook] Let tabs handle clicks over their icons and spinners to fix bug #1196721.

To post a comment you must log in.
lp:~junrrein/granite/fix-1196721 updated
596. By Julián Unrrein

Don't let the icon or the spinner take more space than it should.

597. By Julián Unrrein

Force icons and spinners to have the same minimum size to avoid padding issues in tabs.

Revision history for this message
Julián Unrrein (junrrein) wrote :

Rev597 increments the spinner size a bit to make it the same size as the icon (in Midori, at least).

I did this to prevent a padding problem when the tab has a short label (opening Google in Midori, for example). The size of the default spinner is 14px, while the size of the icon is 16px. This causes text to move a little to the sides when changing from an icon to a spinner and viceversa.

This can also be worked around incrementing the padding around the spinner. I don't know which way is preferable.

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

s/lblbox/label_box

Don't be lazy when it comes to variable names.

It does seem to work pretty well, I'll test more before approving and it will be merged if you fix the above.

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

Also, double clicking slightly below the close button still causes a new tab to be opened.

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

Actually, not just below, to the left too. Quite interesting this is.

lp:~junrrein/granite/fix-1196721 updated
598. By Julián Unrrein

Base Granite.Widgets.Tab on Gtk.EventBox instead of Gtk.Box.

Revision history for this message
Julián Unrrein (junrrein) wrote :

I didn't notice the bug about clicks around the close button. After testing some more, it seems it also happens when clicking under the label and the icon (tested with right-click).

I turned the entire thing into an EventBox to try to catch all mouse events and prevent this, but the situation is the same.

I then discovered that those mouse events don't even reach the EventBox (added debug output that is not present here to check that).

Also notice that I commented out a section of code that referred to the original Gtk.Box. What's the intention of that piece of code?

Revision history for this message
Julián Unrrein (junrrein) wrote :

It seems it isn't possible to even switch tabs if clicking in the lower border of a tab.

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

I just know it's doable because Gtk.Notebook works that way.

Revision history for this message
Julián Unrrein (junrrein) wrote :

I know what you mean, but that is a different issue from the one at hand.

Revision history for this message
David Gomes (davidgomes) :
review: Approve

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-07-13 22:40:24 +0000
3+++ lib/Widgets/DynamicNotebook.vala 2013-07-20 22:06:26 +0000
4@@ -27,7 +27,7 @@
5 /**
6 * This is a standard tab which can be used in a notebook to form a tabbed UI.
7 */
8- public class Tab : Gtk.Box {
9+ public class Tab : Gtk.EventBox {
10
11 Gtk.Label _label;
12 public string label {
13@@ -94,7 +94,7 @@
14 internal Gtk.Button close;
15 public Gtk.Menu menu { get; set; }
16
17- //we need to be able to toggle those from the notebook
18+ //We need to be able to toggle these from the notebook.
19 internal Gtk.MenuItem new_window_m;
20 internal Gtk.MenuItem duplicate_m;
21
22@@ -117,16 +117,18 @@
23 close.tooltip_text = _("Close Tab");
24 close.relief = Gtk.ReliefStyle.NONE;
25
26- var lbl = new Gtk.EventBox ();
27+ var tab_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
28+ tab_box.pack_start (close, false);
29+ tab_box.pack_start (_label);
30+ tab_box.pack_start (_icon, false);
31+ tab_box.pack_start (_working, false);
32 _label.set_tooltip_text (label);
33- lbl.add (_label);
34 _label.ellipsize = Pango.EllipsizeMode.END;
35- lbl.visible_window = false;
36-
37- this.pack_start (this.close, false);
38- this.pack_start (lbl);
39- this.pack_start (this._icon, false);
40- this.pack_start (this._working, false);
41+ _icon.set_size_request (16, 16);
42+ _working.set_size_request (16, 16);
43+ this.visible_window = false;
44+
45+ this.add (tab_box);
46
47 page_container = new Gtk.EventBox ();
48 this.page = page ?? new Gtk.Label("");
49@@ -152,7 +154,7 @@
50 new_window_m.activate.connect (() => new_window () );
51 duplicate_m.activate.connect (() => duplicate () );
52
53- lbl.scroll_event.connect ((e) => {
54+ this.scroll_event.connect ((e) => {
55 var notebook = (this.get_parent () as Gtk.Notebook);
56 switch (e.direction) {
57 case Gdk.ScrollDirection.UP:
58@@ -175,8 +177,7 @@
59 return false;
60 });
61
62- lbl.button_press_event.connect ((e) => {
63-
64+ this.button_press_event.connect ((e) => {
65 e.state &= MODIFIER_MASK;
66
67 if (e.button == 2 && e.state == 0 && close.visible) {
68@@ -197,9 +198,9 @@
69 return true;
70 });
71
72- this.button_press_event.connect ((e) => {
73+ /*this.button_press_event.connect ((e) => {
74 return (e.type == Gdk.EventType.2BUTTON_PRESS || e.button != 1);
75- });
76+ });*/
77
78 page_container.button_press_event.connect (() => { return true; }); //dont let clicks pass through
79 close.clicked.connect ( () => this.closed () );

Subscribers

People subscribed via source and target branches