Merge lp:~xapantu/granite/fix-959552 into lp:~elementary-pantheon/granite/granite

Proposed by xapantu
Status: Merged
Approved by: Victor Martinez
Approved revision: 203
Merged at revision: 203
Proposed branch: lp:~xapantu/granite/fix-959552
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 44 lines (+9/-0)
2 files modified
demo/main.vala (+1/-0)
lib/Widgets/DynamicNotebook.vala (+8/-0)
To merge this branch: bzr merge lp:~xapantu/granite/fix-959552
Reviewer Review Type Date Requested Status
Victor Martinez (community) Approve
Andrea Basso (community) Approve
Review via email: mp+98482@code.launchpad.net

Commit message

Fix bug #959552: double click on tabbar to create new tab

Description of the change

Fix bug #959552: double click on tabbar to create new tab

To post a comment you must log in.
Revision history for this message
Andrea Basso (voluntatefaber) wrote :

Everything seems okay :)

review: Approve
Revision history for this message
Victor Martinez (victored) wrote :

I think the same as Andrea.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'demo/main.vala'
2--- demo/main.vala 2012-03-11 17:33:51 +0000
3+++ demo/main.vala 2012-03-20 18:43:20 +0000
4@@ -212,6 +212,7 @@
5 dynamic_notebook.append_page (new Gtk.Label ("Page 1"), "Page 1");
6 dynamic_notebook.append_page (new Gtk.Label ("Page 2"), "Page 2");
7 dynamic_notebook.append_page (new Gtk.Label ("Page 3"), "Page 3");
8+ dynamic_notebook.add_button_clicked.connect ( () => { dynamic_notebook.append_page (new Gtk.Label("New page"), "New tab"); });
9
10 /* window properties */
11 win.show_all();
12
13=== modified file 'lib/Widgets/DynamicNotebook.vala'
14--- lib/Widgets/DynamicNotebook.vala 2012-03-19 18:39:32 +0000
15+++ lib/Widgets/DynamicNotebook.vala 2012-03-20 18:43:20 +0000
16@@ -157,6 +157,10 @@
17
18 public signal void switch_page (Tab tab);
19 public signal void page_removed (Tab tab);
20+ /**
21+ * Emitted when the user makes a double click on an empty space.
22+ **/
23+ public signal void need_new_tab ();
24
25 public Tabs () {
26 tabs = new Gee.ArrayList<Tab>();
27@@ -531,6 +535,9 @@
28 start_dragging = (int)(event.x/(width - overlap));
29 if (start_dragging >= tabs.size) {
30 start_dragging = -1;
31+ /* click on an empty space */
32+ if (event.type == Gdk.EventType.2BUTTON_PRESS)
33+ need_new_tab ();
34 }
35 else {
36 tabs[start_dragging].drag_origin = event.x - start_dragging * (width - overlap);
37@@ -759,6 +766,7 @@
38 tabs.page_removed.connect ( (t) => {
39 page_removed (t.widget, 0);
40 });
41+ tabs.need_new_tab.connect ( () => { add_button_clicked (); });
42
43 tabs.show_all ();
44 add_eventbox.show_all ();

Subscribers

People subscribed via source and target branches