Merge lp:~wingpanel-devs/slingshot/dnd_to_plank into lp:~elementary-pantheon/slingshot/trunk

Proposed by Djax on 2016-07-02
Status: Merged
Approved by: Felipe Escoto on 2016-07-04
Approved revision: 662
Merged at revision: 667
Proposed branch: lp:~wingpanel-devs/slingshot/dnd_to_plank
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 214 lines (+63/-34)
5 files modified
src/Slingshot.vala (+0/-2)
src/SlingshotView.vala (+4/-5)
src/Widgets/AppEntry.vala (+3/-3)
src/Widgets/SearchItem.vala (+6/-17)
src/Widgets/SearchView.vala (+50/-7)
To merge this branch: bzr merge lp:~wingpanel-devs/slingshot/dnd_to_plank
Reviewer Review Type Date Requested Status
Felipe Escoto 2016-07-02 Approve on 2016-07-04
Review via email: mp+298978@code.launchpad.net

Commit message

Fix regression regarding to DnD behavior

Description of the change

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Slingshot.vala'
2--- src/Slingshot.vala 2016-02-17 19:06:52 +0000
3+++ src/Slingshot.vala 2016-07-02 16:12:12 +0000
4@@ -17,7 +17,6 @@
5 //
6
7 public class Slingshot.Slingshot : Wingpanel.Indicator {
8-
9 private SlingshotView? view = null;
10
11 private Gtk.Label? indicator_label = null;
12@@ -75,7 +74,6 @@
13 public override void closed () {
14 // TODO: Do we need to do anyhting here?
15 }
16-
17 }
18
19 public Wingpanel.Indicator get_indicator (Module module) {
20
21=== modified file 'src/SlingshotView.vala'
22--- src/SlingshotView.vala 2016-02-17 19:06:52 +0000
23+++ src/SlingshotView.vala 2016-07-02 16:12:12 +0000
24@@ -73,7 +73,7 @@
25 private int primary_monitor = 0;
26
27 Gdk.Screen screen;
28-
29+
30 public signal void close_indicator ();
31
32 public SlingshotView () {
33@@ -223,7 +223,6 @@
34 } else if (event.x_root >= 1 || event.y_root >= 1) {
35 can_trigger_hotcorner = true;
36 }
37-
38 return false;
39 }
40
41@@ -295,7 +294,7 @@
42 update_launcher_entry (sender_name, parameters, true);
43 return false;
44 });
45-
46+
47 return;
48 }
49
50@@ -386,7 +385,7 @@
51 case "Return":
52 case "KP_Enter":
53 return false;
54-
55+
56 case "Alt_L":
57 case "Alt_R":
58 break;
59@@ -781,6 +780,6 @@
60 } else if (delta_column < 0 || delta_row < 0) {
61 search_entry.grab_focus ();
62 }
63- }
64+ }
65 }
66 }
67
68=== modified file 'src/Widgets/AppEntry.vala'
69--- src/Widgets/AppEntry.vala 2016-02-17 19:06:52 +0000
70+++ src/Widgets/AppEntry.vala 2016-07-02 16:12:12 +0000
71@@ -134,9 +134,9 @@
72 return false;
73 });
74
75- this.drag_begin.connect ( (ctx) => {
76+ this.drag_begin.connect ((ctx) => {
77 this.dragging = true;
78- Gtk.drag_set_icon_gicon (ctx, app.icon, 0, 0);
79+ Gtk.drag_set_icon_gicon (ctx, this.image.gicon, 16, 16);
80 });
81
82 this.drag_end.connect ( () => {
83@@ -183,7 +183,7 @@
84
85 count_image.set_from_surface (surface.Internal);
86 }
87-#endif
88+#endif
89
90 private void create_menu () {
91 // Display the apps static quicklist items in a popover menu
92
93=== modified file 'src/Widgets/SearchItem.vala'
94--- src/Widgets/SearchItem.vala 2016-04-21 18:23:20 +0000
95+++ src/Widgets/SearchItem.vala 2016-07-02 16:12:12 +0000
96@@ -39,10 +39,9 @@
97 public Backend.App app { get; construct; }
98 public ResultType result_type { public get; construct; }
99
100- public bool dragging = false; //prevent launching
101-
102 private Gtk.Label name_label;
103- private Gtk.Image icon;
104+ public Gtk.Image icon { public get; private set; }
105+ public string? app_uri { get; private set; }
106 private Cancellable? cancellable = null;
107
108 public SearchItem (Backend.App app, string search_term = "", ResultType result_type = ResultType.UNKNOWN) {
109@@ -89,24 +88,14 @@
110
111 add (grid);
112
113- if (result_type != SearchItem.ResultType.APP_ACTIONS)
114+ if (result_type != SearchItem.ResultType.APP_ACTIONS) {
115 launch_app.connect (app.launch);
116+ }
117
118+ app_uri = null;
119 var app_match = app.match as Synapse.ApplicationMatch;
120 if (app_match != null) {
121- Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
122- Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
123- Gdk.DragAction.COPY);
124- this.drag_begin.connect ( (ctx) => {
125- this.dragging = true;
126- Gtk.drag_set_icon_gicon (ctx, app.icon, 0, 0);
127- });
128- this.drag_end.connect ( () => {
129- this.dragging = false;
130- });
131- this.drag_data_get.connect ( (ctx, sel, info, time) => {
132- sel.set_uris ({File.new_for_path (app_match.filename).get_uri ()});
133- });
134+ app_uri = File.new_for_path (app_match.filename).get_uri ();
135 }
136 }
137
138
139=== modified file 'src/Widgets/SearchView.vala'
140--- src/Widgets/SearchView.vala 2016-05-04 02:46:59 +0000
141+++ src/Widgets/SearchView.vala 2016-07-02 16:12:12 +0000
142@@ -33,6 +33,9 @@
143 private Gtk.ListBox list_box;
144 Gee.HashMap<SearchItem.ResultType, uint> limitator;
145
146+ private bool dragging = false;
147+ private string? drag_uri = null;
148+
149 public SearchView () {
150
151 }
152@@ -46,15 +49,55 @@
153 list_box.activate_on_single_click = true;
154 list_box.set_sort_func ((row1, row2) => update_sort (row1, row2));
155 list_box.set_header_func ((Gtk.ListBoxUpdateHeaderFunc) update_header);
156+ list_box.set_selection_mode (Gtk.SelectionMode.BROWSE);
157 list_box.row_activated.connect ((row) => {
158 var search_item = row as SearchItem;
159- if (search_item.result_type == SearchItem.ResultType.APP_ACTIONS || search_item.result_type == SearchItem.ResultType.LINK) {
160- search_item.app.match.execute (null);
161- } else {
162- search_item.app.launch ();
163- }
164-
165- app_launched ();
166+ if (!dragging) {
167+ if (search_item.result_type == SearchItem.ResultType.APP_ACTIONS || search_item.result_type == SearchItem.ResultType.LINK) {
168+ search_item.app.match.execute (null);
169+ } else {
170+ search_item.app.launch ();
171+ }
172+
173+ app_launched ();
174+ }
175+ });
176+
177+ // Drag support
178+ Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
179+ Gtk.drag_source_set (list_box, Gdk.ModifierType.BUTTON1_MASK, {dnd}, Gdk.DragAction.COPY);
180+
181+ list_box.motion_notify_event.connect ((event) => {
182+ if (!dragging) {
183+ list_box.select_row (list_box.get_row_at_y ((int)event.y));
184+ }
185+ return false;
186+ });
187+
188+ list_box.drag_begin.connect ( (ctx) => {
189+ var sr = list_box.get_selected_rows ();
190+ if (sr.length () > 0) {
191+ var di = (SearchItem)(sr.first ().data);
192+ drag_uri = di.app_uri;
193+ if (drag_uri != null) {
194+ dragging = true;
195+ Gtk.drag_set_icon_gicon (ctx, di.icon.gicon, 16, 16);
196+ }
197+ }
198+ });
199+
200+ list_box.drag_end.connect ( () => {
201+ if (drag_uri != null) {
202+ app_launched (); /* This causes indicator to close */
203+ }
204+ dragging = false;
205+ drag_uri = null;
206+ });
207+
208+ list_box.drag_data_get.connect ( (ctx, sel, info, time) => {
209+ if (drag_uri != null) {
210+ sel.set_uris ({drag_uri});
211+ }
212 });
213
214 // alert view

Subscribers

People subscribed via source and target branches