Merge lp:~midori/midori/dragMeBabyeOneMoreTime into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6602
Merged at revision: 6618
Proposed branch: lp:~midori/midori/dragMeBabyeOneMoreTime
Merge into: lp:midori
Diff against target: 88 lines (+31/-15)
1 file modified
midori/midori-notebook.vala (+31/-15)
To merge this branch: bzr merge lp:~midori/midori/dragMeBabyeOneMoreTime
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+211201@code.launchpad.net

Commit message

Open URIs dragged on tab label or new tab button

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-notebook.vala'
2--- midori/midori-notebook.vala 2014-03-06 23:51:16 +0000
3+++ midori/midori-notebook.vala 2014-03-16 11:32:50 +0000
4@@ -72,11 +72,6 @@
5 notify_property ("close-button-left");
6 notify["close-button-visible"].connect (close_button_visible_changed);
7 notify_property ("close-button-visible");
8-
9- Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, (Gtk.TargetEntry[])null, Gdk.DragAction.COPY);
10- Gtk.drag_dest_add_text_targets (this);
11- Gtk.drag_dest_add_uri_targets (this);
12- drag_data_received.connect (uri_dragged);
13 }
14
15 #if !HAVE_GTK3
16@@ -153,16 +148,6 @@
17 spinner.visible = tab.progress > 0.0;
18 icon.visible = !spinner.visible;
19 }
20-
21- void uri_dragged (Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint ttype, uint timestamp) {
22- /* FIXME: Navigate to the URI
23- string[] uri = data.get_uris ();
24- if (uri != null)
25- tab.uri = uri[0];
26- else
27- tab.uri = data.get_text ();
28- */
29- }
30 }
31
32 public class Notebook : Gtk.EventBox {
33@@ -242,6 +227,7 @@
34 notebook.create_window.connect (window_created);
35
36 var add = new Gtk.Button ();
37+ add.tooltip_text = _("Open a new tab");
38 add.relief = Gtk.ReliefStyle.NONE;
39 add.add (new Gtk.Image.from_gicon (new ThemedIcon.with_default_fallbacks ("tab-new-symbolic"), Gtk.IconSize.MENU));
40 add.show_all ();
41@@ -249,10 +235,39 @@
42 add.clicked.connect (()=>{
43 new_tab ();
44 });
45+ take_incoming_uris (add);
46
47 button_press_event.connect (button_pressed);
48 }
49
50+ void take_incoming_uris (Gtk.Widget widget) {
51+ Gtk.drag_dest_set (widget, Gtk.DestDefaults.ALL, (Gtk.TargetEntry[])null, Gdk.DragAction.COPY);
52+ Gtk.drag_dest_add_text_targets (widget);
53+ Gtk.drag_dest_add_uri_targets (widget);
54+ widget.drag_drop.connect (uri_dropped);
55+ widget.drag_data_received.connect (uri_received);
56+ }
57+
58+ bool uri_dropped (Gtk.Widget widget, Gdk.DragContext context, int x, int y, uint timestamp) {
59+ Gtk.drag_finish (context, false, false, timestamp);
60+ return true;
61+ }
62+
63+ void uri_received (Gtk.Widget widget, Gdk.DragContext context, int x, int y, Gtk.SelectionData data, uint ttype, uint timestamp) {
64+ string[] uri = data.get_uris ();
65+ string drag_uri = uri != null ? uri[0] : data.get_text ();
66+ Midori.Tab drag_tab;
67+ if (widget is Tally)
68+ drag_tab = (widget as Tally).tab;
69+ else {
70+ new_tab ();
71+ // Browser will have focussed the new tab
72+ drag_tab = tab;
73+ }
74+ drag_tab.web_view.load_uri (drag_uri);
75+ }
76+
77+
78 ~Notebook () {
79 notebook.size_allocate.disconnect (size_allocated);
80 notebook.switch_page.disconnect (page_switched);
81@@ -316,6 +331,7 @@
82 tally.button_press_event.connect (tab_button_pressed);
83 tally.show ();
84 tally.set_size_request (tab.minimized ? -1 : last_tab_size, -1);
85+ take_incoming_uris (tally);
86
87 /* Minimum requirements for any tab */
88 tab.can_focus = tab.visible = true;

Subscribers

People subscribed via source and target branches

to all changes: