Merge lp:~parnold-x/slingshot/fix-1008352 into lp:~elementary-pantheon/slingshot/trunk

Proposed by Djax on 2014-08-11
Status: Merged
Approved by: Cody Garver on 2014-11-08
Approved revision: 436
Merged at revision: 479
Proposed branch: lp:~parnold-x/slingshot/fix-1008352
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 74 lines (+26/-5)
2 files modified
src/Widgets/SearchItem.vala (+21/-2)
src/Widgets/SearchView.vala (+5/-3)
To merge this branch: bzr merge lp:~parnold-x/slingshot/fix-1008352
Reviewer Review Type Date Requested Status
elementary Pantheon team 2014-08-11 Pending
Review via email: mp+230258@code.launchpad.net

Commit message

Support dragging apps in search view (lp:1008352)

Description of the change

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/SearchItem.vala'
2--- src/Widgets/SearchItem.vala 2014-06-12 09:14:57 +0000
3+++ src/Widgets/SearchItem.vala 2014-08-11 08:42:29 +0000
4@@ -28,12 +28,13 @@
5 private Gtk.Image icon;
6
7 private Cancellable? cancellable = null;
8+ public bool dragging = false; //prevent launching
9
10 public signal bool launch_app ();
11
12 public SearchItem (Backend.App app, string search_term = "") {
13 Object (app: app);
14-
15+
16 get_style_context ().add_class ("app");
17 get_style_context ().add_class ("search-item");
18
19@@ -68,6 +69,24 @@
20 add (box);
21
22 launch_app.connect (app.launch);
23+
24+ var app_match = app.match as Synapse.ApplicationMatch;
25+ if (app_match != null) {
26+ Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
27+ Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
28+ Gdk.DragAction.COPY);
29+ this.drag_begin.connect ( (ctx) => {
30+ this.dragging = true;
31+ Gtk.drag_set_icon_pixbuf (ctx, app.icon, 0, 0);
32+ });
33+ this.drag_end.connect ( () => {
34+ this.dragging = false;
35+ });
36+ this.drag_data_get.connect ( (ctx, sel, info, time) => {
37+ sel.set_uris ({File.new_for_path (app_match.filename).get_uri ()});
38+ });
39+ }
40+
41 }
42
43 public override void destroy () {
44@@ -79,4 +98,4 @@
45 }
46 }
47
48-}
49+}
50\ No newline at end of file
51
52=== modified file 'src/Widgets/SearchView.vala'
53--- src/Widgets/SearchView.vala 2014-06-12 09:14:57 +0000
54+++ src/Widgets/SearchView.vala 2014-08-11 08:42:29 +0000
55@@ -216,8 +216,10 @@
56 var search_item = new SearchItem (app, search_term);
57 app.start_search.connect ((search, target) => start_search (search, target));
58 search_item.button_release_event.connect (() => {
59- app.launch ();
60- app_launched ();
61+ if (!search_item.dragging) {
62+ app.launch ();
63+ app_launched ();
64+ }
65 return true;
66 });
67
68@@ -352,4 +354,4 @@
69
70 }
71
72-}
73+}
74\ No newline at end of file

Subscribers

People subscribed via source and target branches