Merge lp:~azzar1/unity/dnd-enhancements into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Merged at revision: 1399
Proposed branch: lp:~azzar1/unity/dnd-enhancements
Merge into: lp:unity
Diff against target: 1269 lines (+524/-203)
14 files modified
plugins/unityshell/src/AbstractLauncherIcon.h (+4/-2)
plugins/unityshell/src/BamfLauncherIcon.cpp (+99/-69)
plugins/unityshell/src/BamfLauncherIcon.h (+11/-5)
plugins/unityshell/src/DNDCollectionWindow.cpp (+63/-0)
plugins/unityshell/src/DNDCollectionWindow.h (+55/-0)
plugins/unityshell/src/DndData.cpp (+63/-0)
plugins/unityshell/src/DndData.h (+71/-0)
plugins/unityshell/src/Launcher.cpp (+120/-94)
plugins/unityshell/src/Launcher.h (+10/-8)
plugins/unityshell/src/LauncherIcon.cpp (+2/-2)
plugins/unityshell/src/LauncherIcon.h (+10/-8)
plugins/unityshell/src/MockLauncherIcon.h (+2/-2)
plugins/unityshell/src/TrashLauncherIcon.cpp (+11/-11)
plugins/unityshell/src/TrashLauncherIcon.h (+3/-2)
To merge this branch: bzr merge lp:~azzar1/unity/dnd-enhancements
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Review via email: mp+71003@code.launchpad.net

Description of the change

THE DNDCOLLECTION WINDOW
The first objective of this branch is creating a DNDCollectionWindow to get nux/x drag and drop (dnd) data as soon as dnd starts and not when mouse pointer enters launcher window.
The DNDcolletionWindow hides itself as soon as processdndmove is called or when dnd ends (so there should be no "invisble window" problem). After that it emits a collected signal that is handled by the launcher.

THE DNDDATA CLASS
So I have created this facility class to manage the 1-N relationship between uris and uris types. This class uses std::set to avoid data duplication.

C++0x FOR
I have rewrited some for loops using new c++0x for.

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Im sorry it took me so long to get to this, I was gone last week.

I will be reviewing this with excitement tomorrow! Good work :)

Revision history for this message
Jason Smith (jassmith) wrote :

So after running the branch, it does a great job making the launcher appear and do the hinting as soon as a drag starts, however the actual act of dropping something on the launcher is broken in this branch.

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

So I should fix that?

Revision history for this message
Jason Smith (jassmith) wrote :

Yes

Revision history for this message
Andrea Azzarone (azzar1) wrote :

The problem should be gone away...

Revision history for this message
Jason Smith (jassmith) wrote :

Looking great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/AbstractLauncherIcon.h'
--- plugins/unityshell/src/AbstractLauncherIcon.h 2011-08-05 06:20:39 +0000
+++ plugins/unityshell/src/AbstractLauncherIcon.h 2011-08-19 08:55:26 +0000
@@ -31,6 +31,8 @@
3131
32#include <libdbusmenu-glib/menuitem.h>32#include <libdbusmenu-glib/menuitem.h>
3333
34#include "DndData.h"
35
34class ActionArg36class ActionArg
35{37{
36public:38public:
@@ -161,9 +163,9 @@
161163
162 virtual std::list<DbusmenuMenuitem*> Menus() = 0;164 virtual std::list<DbusmenuMenuitem*> Menus() = 0;
163165
164 virtual nux::DndAction QueryAcceptDrop(std::list<char*> paths) = 0;166 virtual nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data) = 0;
165167
166 virtual void AcceptDrop(std::list<char*> paths) = 0;168 virtual void AcceptDrop(unity::DndData& dnd_data) = 0;
167169
168 virtual void SendDndEnter() = 0;170 virtual void SendDndEnter() = 0;
169171
170172
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp'
--- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-08-18 00:38:22 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-08-19 08:55:26 +0000
@@ -21,12 +21,11 @@
21#include "Nux/BaseWindow.h"21#include "Nux/BaseWindow.h"
2222
23#include "BamfLauncherIcon.h"23#include "BamfLauncherIcon.h"
24#include "FavoriteStore.h"
24#include "Launcher.h"25#include "Launcher.h"
25#include "PluginAdapter.h"26#include "PluginAdapter.h"
26#include "FavoriteStore.h"27#include "UBusMessages.h"
27
28#include "ubus-server.h"28#include "ubus-server.h"
29#include "UBusMessages.h"
3029
31#include <glib/gi18n-lib.h>30#include <glib/gi18n-lib.h>
32#include <gio/gdesktopappinfo.h>31#include <gio/gdesktopappinfo.h>
@@ -34,6 +33,8 @@
34#include <core/core.h>33#include <core/core.h>
35#include <core/atoms.h>34#include <core/atoms.h>
3635
36#include <UnityCore/GLibWrapper.h>
37
37using unity::FavoriteStore;38using unity::FavoriteStore;
3839
39struct _ShortcutData40struct _ShortcutData
@@ -133,7 +134,9 @@
133}134}
134135
135BamfLauncherIcon::BamfLauncherIcon(Launcher* IconManager, BamfApplication* app, CompScreen* screen)136BamfLauncherIcon::BamfLauncherIcon(Launcher* IconManager, BamfApplication* app, CompScreen* screen)
136 : SimpleLauncherIcon(IconManager)137 : SimpleLauncherIcon(IconManager)
138 , _supported_types_filled(false)
139 , _fill_supported_types_id(0)
137{140{
138 _cached_desktop_file = NULL;141 _cached_desktop_file = NULL;
139 _cached_name = NULL;142 _cached_name = NULL;
@@ -188,8 +191,11 @@
188 PluginAdapter::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized));191 PluginAdapter::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized));
189 IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged));192 IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged));
190193
191 /* hack */194 // hack
192 SetProgress(0.0f);195 SetProgress(0.0f);
196
197 // Calls when there are no higher priority events pending to the default main loop.
198 _fill_supported_types_id = g_idle_add((GSourceFunc)FillSupportedTypes, this);
193199
194}200}
195201
@@ -213,6 +219,9 @@
213 if (_on_desktop_file_changed_handler_id != 0)219 if (_on_desktop_file_changed_handler_id != 0)
214 g_signal_handler_disconnect((gpointer) _desktop_file_monitor,220 g_signal_handler_disconnect((gpointer) _desktop_file_monitor,
215 _on_desktop_file_changed_handler_id);221 _on_desktop_file_changed_handler_id);
222
223 if (_fill_supported_types_id != 0)
224 g_source_remove(_fill_supported_types_id);
216225
217 g_signal_handlers_disconnect_by_func(m_App, (void*) &BamfLauncherIcon::OnChildRemoved, this);226 g_signal_handlers_disconnect_by_func(m_App, (void*) &BamfLauncherIcon::OnChildRemoved, this);
218 g_signal_handlers_disconnect_by_func(m_App, (void*) &BamfLauncherIcon::OnChildAdded, this);227 g_signal_handlers_disconnect_by_func(m_App, (void*) &BamfLauncherIcon::OnChildAdded, this);
@@ -352,11 +361,10 @@
352 return owns;361 return owns;
353}362}
354363
355void BamfLauncherIcon::OpenInstanceWithUris(std::list<char*> uris)364void BamfLauncherIcon::OpenInstanceWithUris(std::set<std::string> uris)
356{365{
357 GDesktopAppInfo* appInfo;366 GDesktopAppInfo* appInfo;
358 GError* error = NULL;367 GError* error = NULL;
359 std::list<char*>::iterator it;
360368
361 appInfo = g_desktop_app_info_new_from_filename(bamf_application_get_desktop_file(BAMF_APPLICATION(m_App)));369 appInfo = g_desktop_app_info_new_from_filename(bamf_application_get_desktop_file(BAMF_APPLICATION(m_App)));
362370
@@ -364,18 +372,19 @@
364 {372 {
365 GList* list = NULL;373 GList* list = NULL;
366374
367 for (it = uris.begin(); it != uris.end(); it++)375 for (auto it : uris)
368 list = g_list_prepend(list, *it);376 list = g_list_prepend(list, g_strdup(it.c_str()));
369377
370 g_app_info_launch_uris(G_APP_INFO(appInfo), list, NULL, &error);378 g_app_info_launch_uris(G_APP_INFO(appInfo), list, NULL, &error);
371 g_list_free(list);379 g_list_free_full(list, g_free);
372 }380 }
373 else if (g_app_info_supports_files(G_APP_INFO(appInfo)))381 else if (g_app_info_supports_files(G_APP_INFO(appInfo)))
374 {382 {
375 GList* list = NULL, *l;383 GList* list = NULL, *l;
376 for (it = uris.begin(); it != uris.end(); it++)384
385 for (auto it : uris)
377 {386 {
378 GFile* file = g_file_new_for_uri(*it);387 GFile* file = g_file_new_for_uri(it.c_str());
379 list = g_list_prepend(list, file);388 list = g_list_prepend(list, file);
380 }389 }
381 g_app_info_launch(G_APP_INFO(appInfo), list, NULL, &error);390 g_app_info_launch(G_APP_INFO(appInfo), list, NULL, &error);
@@ -403,7 +412,7 @@
403412
404void BamfLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg)413void BamfLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg)
405{414{
406 std::list<char*> empty;415 std::set<std::string> empty;
407 OpenInstanceWithUris(empty);416 OpenInstanceWithUris(empty);
408 ubus_server_send_message(ubus_server_get_default(), UBUS_LAUNCHER_ACTION_DONE, NULL);417 ubus_server_send_message(ubus_server_get_default(), UBUS_LAUNCHER_ACTION_DONE, NULL);
409}418}
@@ -1038,62 +1047,21 @@
1038 return _remote_uri;1047 return _remote_uri;
1039}1048}
10401049
1041std::list<char*> BamfLauncherIcon::ValidateUrisForLaunch(std::list<char*> uris)1050std::set<std::string> BamfLauncherIcon::ValidateUrisForLaunch(unity::DndData& uris)
1042{1051{
1043 GKeyFile* key_file;1052 std::set<std::string> result;
1044 const char* desktop_file;1053
1045 GError* error = NULL;1054 for (auto i : uris.Types())
1046 std::list<char*> results;1055 for (auto j : GetSupportedTypes())
10471056 if (g_content_type_is_a(i.c_str(), j.c_str()))
1048 desktop_file = DesktopFile();
1049
1050 if (!desktop_file || strlen(desktop_file) <= 1)
1051 return results;
1052
1053 key_file = g_key_file_new();
1054 g_key_file_load_from_file(key_file, desktop_file, (GKeyFileFlags) 0, &error);
1055
1056 if (error)
1057 {
1058 g_error_free(error);
1059 g_key_file_free(key_file);
1060 return results;
1061 }
1062
1063 char** mimes = g_key_file_get_string_list(key_file, "Desktop Entry", "MimeType", NULL, NULL);
1064 if (!mimes)
1065 {
1066 g_key_file_free(key_file);
1067 return results;
1068 }
1069
1070 std::list<char*>::iterator it;
1071 for (it = uris.begin(); it != uris.end(); it++)
1072 {
1073 GFile* file = g_file_new_for_uri(*it);
1074 GFileInfo* info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
1075 const char* content_type = g_file_info_get_content_type(info);
1076
1077 int i = 0;
1078 for (; mimes[i]; i++)
1079 {
1080 char* super_type = g_content_type_from_mime_type(mimes[i]);
1081 if (g_content_type_is_a(content_type, super_type))
1082 {1057 {
1083 results.push_back(*it);1058 for (auto k : uris.UrisByType(i))
1059 result.insert(k);
1060
1084 break;1061 break;
1085 }1062 }
1086 g_free(super_type);1063
1087 }1064 return result;
1088
1089
1090 g_object_unref(file);
1091 g_object_unref(info);
1092 }
1093
1094 g_strfreev(mimes);
1095 g_key_file_free(key_file);
1096 return results;
1097}1065}
10981066
1099gboolean BamfLauncherIcon::OnDndHoveredTimeout(gpointer data)1067gboolean BamfLauncherIcon::OnDndHoveredTimeout(gpointer data)
@@ -1121,14 +1089,14 @@
1121 _dnd_hover_timer = 0;1089 _dnd_hover_timer = 0;
1122}1090}
11231091
1124nux::DndAction BamfLauncherIcon::OnQueryAcceptDrop(std::list<char*> uris)1092nux::DndAction BamfLauncherIcon::OnQueryAcceptDrop(unity::DndData& dnd_data)
1125{1093{
1126 return ValidateUrisForLaunch(uris).empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY;1094 return ValidateUrisForLaunch(dnd_data).empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY;
1127}1095}
11281096
1129void BamfLauncherIcon::OnAcceptDrop(std::list<char*> uris)1097void BamfLauncherIcon::OnAcceptDrop(unity::DndData& dnd_data)
1130{1098{
1131 OpenInstanceWithUris(ValidateUrisForLaunch(uris));1099 OpenInstanceWithUris(ValidateUrisForLaunch(dnd_data));
1132}1100}
11331101
1134void BamfLauncherIcon::OnDesktopFileChanged(GFileMonitor* monitor,1102void BamfLauncherIcon::OnDesktopFileChanged(GFileMonitor* monitor,
@@ -1181,3 +1149,65 @@
1181 g_list_free(children);1149 g_list_free(children);
1182 return result;1150 return result;
1183}1151}
1152
1153const std::set<std::string>&
1154BamfLauncherIcon::GetSupportedTypes()
1155{
1156 if (!_supported_types_filled)
1157 FillSupportedTypes(this);
1158
1159 return _supported_types;
1160}
1161
1162gboolean
1163BamfLauncherIcon::FillSupportedTypes(gpointer data)
1164{
1165 BamfLauncherIcon* self = (BamfLauncherIcon*) data;
1166
1167 if (self->_fill_supported_types_id)
1168 {
1169 g_source_remove(self->_fill_supported_types_id);
1170 self->_fill_supported_types_id = 0;
1171 }
1172
1173 if (!self->_supported_types_filled)
1174 {
1175 self->_supported_types_filled = true;
1176
1177 self->_supported_types.clear();
1178
1179 const char* desktop_file = self->DesktopFile();
1180
1181 if (!desktop_file || strlen(desktop_file) <= 1)
1182 return false;
1183
1184 GKeyFile* key_file = g_key_file_new();
1185 unity::glib::Error error;
1186
1187 g_key_file_load_from_file(key_file, desktop_file, (GKeyFileFlags) 0, &error);
1188
1189 if (error)
1190 {
1191 g_key_file_free(key_file);
1192 return false;
1193 }
1194
1195 char** mimes = g_key_file_get_string_list(key_file, "Desktop Entry", "MimeType", NULL, NULL);
1196 if (!mimes)
1197 {
1198 g_key_file_free(key_file);
1199 return false;
1200 }
1201
1202 for (int i=0; mimes[i]; i++)
1203 {
1204 unity::glib::String super_type(g_content_type_from_mime_type(mimes[i]));
1205 self->_supported_types.insert(super_type.Str());
1206 }
1207
1208 g_key_file_free(key_file);
1209 g_strfreev(mimes);
1210 }
1211
1212 return false;
1213}
11841214
=== modified file 'plugins/unityshell/src/BamfLauncherIcon.h'
--- plugins/unityshell/src/BamfLauncherIcon.h 2011-08-04 20:19:46 +0000
+++ plugins/unityshell/src/BamfLauncherIcon.h 2011-08-19 08:55:26 +0000
@@ -63,14 +63,14 @@
6363
64 const gchar* GetRemoteUri();64 const gchar* GetRemoteUri();
6565
66 nux::DndAction OnQueryAcceptDrop(std::list<char*> uris);66 nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data);
67 void OnAcceptDrop(std::list<char*> uris);67 void OnAcceptDrop(unity::DndData& dnd_data);
68 void OnDndEnter();68 void OnDndEnter();
69 void OnDndLeave();69 void OnDndLeave();
7070
71 void OpenInstanceLauncherIcon(ActionArg arg);71 void OpenInstanceLauncherIcon(ActionArg arg);
7272
73 std::list<char*> ValidateUrisForLaunch(std::list<char*> uris);73 std::set<std::string> ValidateUrisForLaunch(unity::DndData& dnd_data);
7474
75 const char* BamfName();75 const char* BamfName();
7676
@@ -89,15 +89,18 @@
89 gchar* _cached_desktop_file;89 gchar* _cached_desktop_file;
90 gchar* _cached_name;90 gchar* _cached_name;
9191
92
93 GFileMonitor* _desktop_file_monitor;92 GFileMonitor* _desktop_file_monitor;
94 gulong _on_desktop_file_changed_handler_id;93 gulong _on_desktop_file_changed_handler_id;
94
95 std::set<std::string> _supported_types;
96 bool _supported_types_filled;
97 guint _fill_supported_types_id;
9598
96 void EnsureWindowState();99 void EnsureWindowState();
97100
98 void UpdateMenus();101 void UpdateMenus();
99102
100 void OpenInstanceWithUris(std::list<char*> uris);103 void OpenInstanceWithUris(std::set<std::string> uris);
101 void Focus();104 void Focus();
102 bool Spread(int state, bool force);105 bool Spread(int state, bool force);
103106
@@ -105,6 +108,8 @@
105108
106 void OnWindowMinimized(guint32 xid);109 void OnWindowMinimized(guint32 xid);
107 bool OwnsWindow(Window w);110 bool OwnsWindow(Window w);
111
112 const std::set<std::string>& GetSupportedTypes();
108113
109 static void OnClosed(BamfView* view, gpointer data);114 static void OnClosed(BamfView* view, gpointer data);
110 static void OnUserVisibleChanged(BamfView* view, gboolean visible, gpointer data);115 static void OnUserVisibleChanged(BamfView* view, gboolean visible, gpointer data);
@@ -125,6 +130,7 @@
125 gpointer data);130 gpointer data);
126131
127 static gboolean OnDndHoveredTimeout(gpointer data);132 static gboolean OnDndHoveredTimeout(gpointer data);
133 static gboolean FillSupportedTypes(gpointer data);
128};134};
129135
130#endif // BAMFLAUNCHERICON_H136#endif // BAMFLAUNCHERICON_H
131137
=== added file 'plugins/unityshell/src/DNDCollectionWindow.cpp'
--- plugins/unityshell/src/DNDCollectionWindow.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/DNDCollectionWindow.cpp 2011-08-19 08:55:26 +0000
@@ -0,0 +1,63 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzarone <azzaronea@gmail.com>
18*/
19
20#include "DNDCollectionWindow.h"
21
22namespace unity {
23
24NUX_IMPLEMENT_OBJECT_TYPE(DNDCollectionWindow);
25
26DNDCollectionWindow::DNDCollectionWindow(CompScreen* screen)
27 : nux::BaseWindow("")
28{
29 SetBackgroundColor(nux::Color(0x00000000));
30 SetBaseSize(screen->width(), screen->height());
31 SetBaseXY(0, 0);
32
33 ShowWindow(true);
34 PushToBack();
35 // Hack
36 EnableInputWindow(true, "DNDCollectionWindow");
37 EnableInputWindow(false, "DNDCollectionWindow");
38 SetDndEnabled(false, true);
39}
40
41DNDCollectionWindow::~DNDCollectionWindow()
42{
43 for (auto it : mimes_)
44 g_free(it);
45}
46
47void DNDCollectionWindow::ProcessDndMove(int x, int y, std::list<char*> mimes)
48{
49 // Hide the window as soon as possible
50 EnableInputWindow(false, "DNDCollectionWindow");
51
52 for (auto it : mimes_)
53 g_free(it);
54 mimes_.clear();
55
56 // Duplicate the list
57 for (auto it : mimes)
58 mimes_.push_back(g_strdup(it));
59
60 collected.emit(mimes_);
61}
62
63} // namespace unity
064
=== added file 'plugins/unityshell/src/DNDCollectionWindow.h'
--- plugins/unityshell/src/DNDCollectionWindow.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/DNDCollectionWindow.h 2011-08-19 08:55:26 +0000
@@ -0,0 +1,55 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzarone <azzaronea@gmail.com>
18*/
19
20#ifndef DNDCOLLECTIONWINDOW_H
21#define DNDCOLLECTIONWINDOW_H
22
23#include <list>
24
25#include <core/screen.h>
26#include <Nux/Nux.h>
27#include <Nux/BaseWindow.h>
28#include <sigc++/sigc++.h>
29
30namespace unity {
31
32class DNDCollectionWindow : public nux::BaseWindow
33{
34NUX_DECLARE_OBJECT_TYPE(DNDCollectionWindow, nux::BaseWindow);
35
36// Methods
37public:
38 DNDCollectionWindow(CompScreen* screen);
39 ~DNDCollectionWindow();
40
41private:
42 void ProcessDndMove(int x, int y, std::list<char*> mimes);
43
44// Members
45public:
46 sigc::signal<void, const std::list<char*>&> collected;
47
48private:
49 std::list<char*> mimes_;
50
51};
52
53} // namespace unity
54
55#endif // DNDCOLLECTIONWINDOW_H
056
=== added file 'plugins/unityshell/src/DndData.cpp'
--- plugins/unityshell/src/DndData.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/DndData.cpp 2011-08-19 08:55:26 +0000
@@ -0,0 +1,63 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzarone <azzaronea@gmail.com>
18*/
19
20#include "DndData.h"
21
22#include <cstring>
23#include <vector>
24
25#include <gio/gio.h>
26
27#include <UnityCore/GLibWrapper.h>
28
29namespace unity {
30
31void DndData::Fill(char* uris)
32{
33 Reset();
34
35 char* pch = strtok (uris, "\r\n");
36 while (pch != NULL)
37 {
38 glib::Object<GFile> file(g_file_new_for_uri(pch));
39 glib::Object<GFileInfo> info(g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL));
40 const char* content_type = g_file_info_get_content_type(info);
41
42 uris_.insert(pch);
43
44 if (content_type != NULL)
45 {
46 types_.insert(content_type);
47 uris_to_types_[pch] = content_type;
48 types_to_uris_[content_type].insert(pch);
49 }
50
51 pch = strtok (NULL, "\r\n");
52 }
53}
54
55void DndData::Reset()
56{
57 uris_.clear();
58 types_.clear();
59 uris_to_types_.clear();
60 types_to_uris_.clear();
61}
62
63} // namespace unity
064
=== added file 'plugins/unityshell/src/DndData.h'
--- plugins/unityshell/src/DndData.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/DndData.h 2011-08-19 08:55:26 +0000
@@ -0,0 +1,71 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3* Copyright (C) 2011 Canonical Ltd
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.
16*
17* Authored by: Andrea Azzarone <azzaronea@gmail.com>
18*/
19
20#ifndef DNDDATA_H
21#define DNDDATA_H
22
23#include <map>
24#include <set>
25#include <string>
26
27namespace unity {
28
29class DndData
30{
31public:
32 /**
33 * Fills the object given a list of uris.
34 **/
35 void Fill(char* uris);
36
37 /**
38 * Resets the object. Call this function when no longer need data
39 **/
40 void Reset();
41
42 /**
43 * Returns a std::set<std::string> with all the uris.
44 **/
45 std::set<std::string>& Uris() { return uris_; }
46
47 /**
48 * Returns a std::set<std::string> with all the types.
49 **/
50 std::set<std::string>& Types() { return types_; }
51
52 /**
53 * Returns a std::set<std::string> with all uris of a given type.
54 **/
55 std::set<std::string>& UrisByType(const std::string& type) { return types_to_uris_[type]; }
56
57 /**
58 * Returns a std::set<std::string> with all types of a given uri.
59 **/
60 std::string& TypeByUri(const std::string& uris) { return uris_to_types_[uris]; }
61
62private:
63 std::set<std::string> uris_;
64 std::set<std::string> types_;
65 std::map<std::string, std::string> uris_to_types_;
66 std::map<std::string, std::set<std::string>> types_to_uris_;
67};
68
69} // namespace unity
70
71#endif // DNDDATA_H
072
=== modified file 'plugins/unityshell/src/Launcher.cpp'
--- plugins/unityshell/src/Launcher.cpp 2011-08-13 06:17:26 +0000
+++ plugins/unityshell/src/Launcher.cpp 2011-08-19 08:55:26 +0000
@@ -48,12 +48,11 @@
48#include "ubus-server.h"48#include "ubus-server.h"
49#include "UBusMessages.h"49#include "UBusMessages.h"
5050
51#include <UnityCore/GLibWrapper.h>
51#include <UnityCore/Variant.h>52#include <UnityCore/Variant.h>
5253
53using namespace unity::ui;54using namespace unity::ui;
5455
55using namespace unity::ui;
56
57namespace56namespace
58{57{
5958
@@ -136,13 +135,15 @@
136Launcher::Launcher(nux::BaseWindow* parent,135Launcher::Launcher(nux::BaseWindow* parent,
137 CompScreen* screen,136 CompScreen* screen,
138 NUX_FILE_LINE_DECL)137 NUX_FILE_LINE_DECL)
139 : View(NUX_FILE_LINE_PARAM)138 : View(NUX_FILE_LINE_PARAM)
140 , m_ContentOffsetY(0)139 , m_ContentOffsetY(0)
141 , m_BackgroundLayer(0)140 , m_BackgroundLayer(0)
142 , _model(0)141 , _model(0)
143 , _background_color (nux::color::DimGray)142 , _collection_window(NULL)
144 , _dash_is_open (false)143 , _background_color(nux::color::DimGray)
144 , _dash_is_open(false)
145{145{
146
146 _parent = parent;147 _parent = parent;
147 _screen = screen;148 _screen = screen;
148 _active_quicklist = 0;149 _active_quicklist = 0;
@@ -263,6 +264,11 @@
263 _bfb_width = 1;264 _bfb_width = 1;
264 _bfb_height = 1;265 _bfb_height = 1;
265266
267 _data_checked = false;
268 _collection_window = new unity::DNDCollectionWindow(_screen);
269 _collection_window->SinkReference();
270 _on_data_collected_connection = _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected));
271
266 // 0 out timers to avoid wonky startups272 // 0 out timers to avoid wonky startups
267 int i;273 int i;
268 for (i = 0; i < TIME_LAST; ++i)274 for (i = 0; i < TIME_LAST; ++i)
@@ -271,6 +277,7 @@
271 _times[i].tv_nsec = 0;277 _times[i].tv_nsec = 0;
272 }278 }
273279
280 _dnd_hovered_icon = NULL;
274 _drag_window = NULL;281 _drag_window = NULL;
275 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);282 _offscreen_drag_texture = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture(2, 2, 1, nux::BITFMT_R8G8B8A8);
276283
@@ -350,6 +357,9 @@
350357
351 if (_launcher_animation_timeout > 0)358 if (_launcher_animation_timeout > 0)
352 g_source_remove(_launcher_animation_timeout);359 g_source_remove(_launcher_animation_timeout);
360
361 if (_on_data_collected_connection.connected())
362 _on_data_collected_connection.disconnect();
353363
354 UBusServer* ubus = ubus_server_get_default();364 UBusServer* ubus = ubus_server_get_default();
355 for (unsigned int i = 0; i < G_N_ELEMENTS(_ubus_handles); ++i)365 for (unsigned int i = 0; i < G_N_ELEMENTS(_ubus_handles); ++i)
@@ -359,6 +369,9 @@
359 }369 }
360370
361 g_idle_remove_by_data(this);371 g_idle_remove_by_data(this);
372
373 if (_collection_window)
374 _collection_window->UnReference();
362375
363 delete _hover_machine;376 delete _hover_machine;
364 delete _hide_machine;377 delete _hide_machine;
@@ -656,7 +669,7 @@
656 time = icon->GetQuirkTime(LauncherIcon::QUIRK_PROGRESS);669 time = icon->GetQuirkTime(LauncherIcon::QUIRK_PROGRESS);
657 if (TimeDelta(&current, &time) < ANIM_DURATION)670 if (TimeDelta(&current, &time) < ANIM_DURATION)
658 return true;671 return true;
659672
660 time = icon->GetQuirkTime(LauncherIcon::QUIRK_DROP_DIM);673 time = icon->GetQuirkTime(LauncherIcon::QUIRK_DROP_DIM);
661 if (TimeDelta(&current, &time) < ANIM_DURATION)674 if (TimeDelta(&current, &time) < ANIM_DURATION)
662 return true;675 return true;
@@ -1091,7 +1104,7 @@
1091 arg.alpha *= size_modifier;1104 arg.alpha *= size_modifier;
1092 center.z = 300.0f * (1.0f - size_modifier);1105 center.z = 300.0f * (1.0f - size_modifier);
1093 }1106 }
10941107
1095 float drop_dim_value = 0.2f + 0.8f * IconDropDimValue(icon, current);1108 float drop_dim_value = 0.2f + 0.8f * IconDropDimValue(icon, current);
10961109
1097 if (drop_dim_value < 1.0f)1110 if (drop_dim_value < 1.0f)
@@ -1513,7 +1526,7 @@
1513 _parent->EnableInputWindow(!hidden, "launcher", false, false);1526 _parent->EnableInputWindow(!hidden, "launcher", false, false);
15141527
1515 if (!hidden && GetActionState() == ACTION_DRAG_EXTERNAL)1528 if (!hidden && GetActionState() == ACTION_DRAG_EXTERNAL)
1516 ProcessDndLeave();1529 DndLeave();
15171530
1518 EnsureAnimation();1531 EnsureAnimation();
15191532
@@ -1614,10 +1627,19 @@
16141627
1615 if (drag_owner && (mask & (Button1Mask | Button2Mask | Button3Mask)))1628 if (drag_owner && (mask & (Button1Mask | Button2Mask | Button3Mask)))
1616 {1629 {
1617 self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true);1630 if (self->_data_checked == false)
1631 {
1632 self->_data_checked = true;
1633 self->_collection_window->EnableInputWindow(true, "DNDCollectionWindow");
1634 }
1635
1618 return true;1636 return true;
1619 }1637 }
1638
1639 self->_data_checked = false;
1640 self->_collection_window->EnableInputWindow(false, "DNDCollectionWindow");
16201641
1642 self->DndLeave();
1621 self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);1643 self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
1622 self->_hide_machine->SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, false);1644 self->_hide_machine->SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, false);
16231645
@@ -1681,11 +1703,6 @@
1681 1703
1682 if (_hidemode == LAUNCHER_HIDE_NEVER)1704 if (_hidemode == LAUNCHER_HIDE_NEVER)
1683 return;1705 return;
1684
1685 if (PluginAdapter::Default ()->IsScaleActive ())
1686 _parent->InputWindowEnableStruts (true);
1687 else
1688 _parent->InputWindowEnableStruts (false);
1689}1706}
16901707
1691Launcher::LauncherHideMode Launcher::GetHideMode()1708Launcher::LauncherHideMode Launcher::GetHideMode()
@@ -2803,10 +2820,51 @@
2803 nux::GetWindowCompositor().RestoreRenderingSurface();2820 nux::GetWindowCompositor().RestoreRenderingSurface();
2804}2821}
28052822
2823void Launcher::OnDNDDataCollected(const std::list<char*>& mimes)
2824{
2825 _dnd_data.Reset();
2826
2827 unity::glib::String uri_list_const(g_strdup("text/uri-list"));
2828
2829 for (auto it : mimes)
2830 {
2831 if (!g_str_equal(it, uri_list_const.Value()))
2832 continue;
2833
2834 _dnd_data.Fill(nux::GetWindow().GetDndData(uri_list_const.Value()));
2835 break;
2836 }
2837
2838 if (!_dnd_data.Uris().size())
2839 return;
2840
2841 _hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true);
2842
2843 for (auto it : _dnd_data.Uris())
2844 {
2845 if (g_str_has_suffix(it.c_str(), ".desktop"))
2846 {
2847 _steal_drag = true;
2848 break;
2849 }
2850 }
2851
2852 if (!_steal_drag)
2853 {
2854 for (auto it : *_model)
2855 {
2856 if (it->QueryAcceptDrop(_dnd_data) != nux::DNDACTION_NONE)
2857 it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true);
2858 else
2859 it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true);
2860 }
2861 }
2862}
2863
2806void2864void
2807Launcher::ProcessDndEnter()2865Launcher::ProcessDndEnter()
2808{2866{
2809 _drag_data.clear();2867 _dnd_data.Reset();
2810 _drag_action = nux::DNDACTION_NONE;2868 _drag_action = nux::DNDACTION_NONE;
2811 _steal_drag = false;2869 _steal_drag = false;
2812 _data_checked = false;2870 _data_checked = false;
@@ -2815,35 +2873,32 @@
2815}2873}
28162874
2817void2875void
2876Launcher::DndLeave()
2877{
2878
2879 _dnd_data.Reset();
2880
2881 for (auto it : *_model)
2882 {
2883 it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, false);
2884 it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, false);
2885 }
2886
2887 ProcessDndLeave();
2888}
2889
2890void
2818Launcher::ProcessDndLeave()2891Launcher::ProcessDndLeave()
2819{2892{
2820 SetStateMouseOverLauncher(false);2893 SetStateMouseOverLauncher(false);
2821 _drag_edge_touching = false;2894 _drag_edge_touching = false;
28222895
2823 SetActionState(ACTION_NONE);2896 SetActionState(ACTION_NONE);
28242897
2825 if (!_drag_data.empty())
2826 {
2827 std::list<char*>::iterator it;
2828 for (it = _drag_data.begin(); it != _drag_data.end(); it++)
2829 {
2830 g_free(*it);
2831 }
2832 }
2833 _drag_data.clear();
2834
2835 LauncherModel::iterator it;
2836 for (it = _model->begin(); it != _model->end(); it++)
2837 {
2838 (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, false);
2839 (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, false);
2840 }
2841
2842 if (_steal_drag && _dnd_hovered_icon)2898 if (_steal_drag && _dnd_hovered_icon)
2843 {2899 {
2844 _dnd_hovered_icon->SetQuirk(LauncherIcon::QUIRK_VISIBLE, false);2900 _dnd_hovered_icon->SetQuirk(LauncherIcon::QUIRK_VISIBLE, false);
2845 _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);2901 _dnd_hovered_icon->remove.emit(_dnd_hovered_icon);
2846
2847 }2902 }
28482903
2849 if (!_steal_drag && _dnd_hovered_icon)2904 if (!_steal_drag && _dnd_hovered_icon)
@@ -2854,58 +2909,33 @@
28542909
2855 _steal_drag = false;2910 _steal_drag = false;
2856 _dnd_hovered_icon = 0;2911 _dnd_hovered_icon = 0;
2857
2858}
2859
2860std::list<char*>
2861Launcher::StringToUriList(char* input)
2862{
2863 std::list<char*> result;
2864
2865 if (!input)
2866 return result;
2867
2868 char** imtrappedinastringfactory = g_strsplit(input, "\r\n", -1);
2869 int i = 0;
2870 while (imtrappedinastringfactory[i]) // get kinda bored
2871 {
2872 // empty string check
2873 if (imtrappedinastringfactory[i][0])
2874 result.push_back(g_strdup(imtrappedinastringfactory[i]));
2875 ++i;
2876 }
2877
2878 g_strfreev(imtrappedinastringfactory);
2879
2880 return result;
2881}2912}
28822913
2883void2914void
2884Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)2915Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes)
2885{2916{
2886 std::list<char*>::iterator it;
2887 nux::Area* parent = GetToplevel();2917 nux::Area* parent = GetToplevel();
2888 char* uri_list_const = g_strdup("text/uri-list");2918 unity::glib::String uri_list_const(g_strdup("text/uri-list"));
28892919
2890 if (!_data_checked)2920 if (!_data_checked)
2891 {2921 {
2892 _data_checked = true;2922 _data_checked = true;
2893 _drag_data.clear();2923 _dnd_data.Reset();
28942924
2895 // get the data2925 // get the data
2896 for (it = mimes.begin(); it != mimes.end(); it++)2926 for (auto it : mimes)
2897 {2927 {
2898 if (!g_str_equal(*it, uri_list_const))2928 if (!g_str_equal(it, uri_list_const.Value()))
2899 continue;2929 continue;
29002930
2901 _drag_data = StringToUriList(nux::GetWindow().GetDndData(uri_list_const));2931 _dnd_data.Fill(nux::GetWindow().GetDndData(uri_list_const.Value()));
2902 break;2932 break;
2903 }2933 }
29042934
2905 // see if the launcher wants this one2935 // see if the launcher wants this one
2906 for (it = _drag_data.begin(); it != _drag_data.end(); it++)2936 for (auto it : _dnd_data.Uris())
2907 {2937 {
2908 if (g_str_has_suffix(*it, ".desktop"))2938 if (g_str_has_suffix(it.c_str(), ".desktop"))
2909 {2939 {
2910 _steal_drag = true;2940 _steal_drag = true;
2911 break;2941 break;
@@ -2916,19 +2946,18 @@
2916 SetActionState(ACTION_DRAG_EXTERNAL);2946 SetActionState(ACTION_DRAG_EXTERNAL);
2917 SetStateMouseOverLauncher(true);2947 SetStateMouseOverLauncher(true);
29182948
2919 LauncherModel::iterator it;2949 if (!_steal_drag)
2920 for (it = _model->begin(); it != _model->end() && !_steal_drag; it++)
2921 {2950 {
2922 if ((*it)->QueryAcceptDrop(_drag_data) != nux::DNDACTION_NONE && !_steal_drag)2951 for (auto it : *_model)
2923 (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true);2952 {
2924 else2953 if (it->QueryAcceptDrop(_dnd_data) != nux::DNDACTION_NONE)
2925 (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true);2954 it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true);
2955 else
2956 it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true);
2957 }
2926 }2958 }
2927
2928 }2959 }
29292960
2930 g_free(uri_list_const);
2931
2932 SetMousePosition(x - parent->GetGeometry().x, y - parent->GetGeometry().y);2961 SetMousePosition(x - parent->GetGeometry().x, y - parent->GetGeometry().y);
29332962
2934 if (_mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)2963 if (_mouse_position.x == 0 && _mouse_position.y <= (_parent->GetGeometry().height - _icon_size - 2 * _space_between_icons) && !_drag_edge_touching)
@@ -2991,7 +3020,7 @@
2991 if (hovered_icon)3020 if (hovered_icon)
2992 {3021 {
2993 hovered_icon->SendDndEnter();3022 hovered_icon->SendDndEnter();
2994 _drag_action = hovered_icon->QueryAcceptDrop(_drag_data);3023 _drag_action = hovered_icon->QueryAcceptDrop(_dnd_data);
2995 }3024 }
2996 else3025 else
2997 {3026 {
@@ -3020,23 +3049,21 @@
3020 if (_steal_drag)3049 if (_steal_drag)
3021 {3050 {
3022 char* path = 0;3051 char* path = 0;
3023 std::list<char*>::iterator it;
30243052
3025 for (it = _drag_data.begin(); it != _drag_data.end(); it++)3053 for (auto it : _dnd_data.Uris())
3026 {3054 {
3027 if (g_str_has_suffix(*it, ".desktop"))3055 if (g_str_has_suffix(it.c_str(), ".desktop"))
3028 {3056 {
3029 if (g_str_has_prefix(*it, "application://"))3057 if (g_str_has_prefix(it.c_str(), "application://"))
3030 {3058 {
3031 const char* tmp = *it + strlen("application://");3059 const char* tmp = it.c_str() + strlen("application://");
3032 char* tmp2 = g_strdup_printf("file:///usr/share/applications/%s", tmp);3060 unity::glib::String tmp2(g_strdup_printf("file:///usr/share/applications/%s", tmp));
3033 path = g_filename_from_uri(tmp2, NULL, NULL);3061 path = g_filename_from_uri(tmp2.Value(), NULL, NULL);
3034 g_free(tmp2);
3035 break;3062 break;
3036 }3063 }
3037 else if (g_str_has_prefix(*it, "file://"))3064 else if (g_str_has_prefix(it.c_str(), "file://"))
3038 {3065 {
3039 path = g_filename_from_uri(*it, NULL, NULL);3066 path = g_filename_from_uri(it.c_str(), NULL, NULL);
3040 break;3067 break;
3041 }3068 }
3042 }3069 }
@@ -3050,7 +3077,7 @@
3050 }3077 }
3051 else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE)3078 else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE)
3052 {3079 {
3053 _dnd_hovered_icon->AcceptDrop(_drag_data);3080 _dnd_hovered_icon->AcceptDrop(_dnd_data);
3054 }3081 }
30553082
3056 if (_drag_action != nux::DNDACTION_NONE)3083 if (_drag_action != nux::DNDACTION_NONE)
@@ -3059,10 +3086,9 @@
3059 SendDndFinished(false, _drag_action);3086 SendDndFinished(false, _drag_action);
30603087
3061 // reset our shiz3088 // reset our shiz
3062 ProcessDndLeave();3089 DndLeave();
3063}3090}
30643091
3065
3066/*3092/*
3067 * Returns the current selected icon if it is in keynavmode3093 * Returns the current selected icon if it is in keynavmode
3068 * It will return NULL if it is not on keynavmode3094 * It will return NULL if it is not on keynavmode
30693095
=== modified file 'plugins/unityshell/src/Launcher.h'
--- plugins/unityshell/src/Launcher.h 2011-08-13 06:17:26 +0000
+++ plugins/unityshell/src/Launcher.h 2011-08-19 08:55:26 +0000
@@ -27,6 +27,10 @@
27#include <Nux/View.h>27#include <Nux/View.h>
28#include <Nux/BaseWindow.h>28#include <Nux/BaseWindow.h>
2929
30#include "AbstractIconRenderer.h"
31#include "DNDCollectionWindow.h"
32#include "DndData.h"
33#include "GeisAdapter.h"
30#include "Introspectable.h"34#include "Introspectable.h"
31#include "LauncherIcon.h"35#include "LauncherIcon.h"
32#include "LauncherDragWindow.h"36#include "LauncherDragWindow.h"
@@ -35,9 +39,6 @@
35#include "NuxGraphics/IOpenGLAsmShader.h"39#include "NuxGraphics/IOpenGLAsmShader.h"
36#include "Nux/TimerProc.h"40#include "Nux/TimerProc.h"
37#include "PluginAdapter.h"41#include "PluginAdapter.h"
38#include "GeisAdapter.h"
39
40#include "AbstractIconRenderer.h"
4142
42#define ANIM_DURATION_SHORT 12543#define ANIM_DURATION_SHORT 125
43#define ANIM_DURATION 20044#define ANIM_DURATION 200
@@ -204,6 +205,7 @@
204 const gchar* GetName();205 const gchar* GetName();
205 void AddProperties(GVariantBuilder* builder);206 void AddProperties(GVariantBuilder* builder);
206207
208 void DndLeave();
207 void ProcessDndEnter();209 void ProcessDndEnter();
208 void ProcessDndLeave();210 void ProcessDndLeave();
209 void ProcessDndMove(int x, int y, std::list<char*> mimes);211 void ProcessDndMove(int x, int y, std::list<char*> mimes);
@@ -361,9 +363,9 @@
361363
362 gboolean TapOnSuper();364 gboolean TapOnSuper();
363365
364 std::list<char*> StringToUriList(char* input);
365
366 static void SettingsChanged(GSettings* settings, gchar* key, Launcher* self);366 static void SettingsChanged(GSettings* settings, gchar* key, Launcher* self);
367
368 void OnDNDDataCollected(const std::list<char*>& mimes);
367369
368 nux::HLayout* m_Layout;370 nux::HLayout* m_Layout;
369 int m_ContentOffsetY;371 int m_ContentOffsetY;
@@ -446,12 +448,14 @@
446 LauncherHoverMachine* _hover_machine;448 LauncherHoverMachine* _hover_machine;
447 CompScreen* _screen;449 CompScreen* _screen;
448450
449 std::list<char*> _drag_data;451 unity::DndData _dnd_data;
450 nux::DndAction _drag_action;452 nux::DndAction _drag_action;
451 bool _data_checked;453 bool _data_checked;
452 bool _steal_drag;454 bool _steal_drag;
453 bool _drag_edge_touching;455 bool _drag_edge_touching;
454 LauncherIcon* _dnd_hovered_icon;456 LauncherIcon* _dnd_hovered_icon;
457 unity::DNDCollectionWindow* _collection_window;
458 sigc::connection _on_data_collected_connection;
455459
456 Atom _selection_atom;460 Atom _selection_atom;
457461
@@ -489,5 +493,3 @@
489};493};
490494
491#endif // LAUNCHER_H495#endif // LAUNCHER_H
492
493
494496
=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
--- plugins/unityshell/src/LauncherIcon.cpp 2011-08-10 12:12:18 +0000
+++ plugins/unityshell/src/LauncherIcon.cpp 2011-08-19 08:55:26 +0000
@@ -804,10 +804,10 @@
804{804{
805 if (_quirks[quirk] == value)805 if (_quirks[quirk] == value)
806 return;806 return;
807 807
808 if (quirk == QUIRK_PULSE_ONCE)808 if (quirk == QUIRK_PULSE_ONCE)
809 _launcher->HideMachine()->SetQuirk(LauncherHideMachine::LAUNCHER_PULSE, value);809 _launcher->HideMachine()->SetQuirk(LauncherHideMachine::LAUNCHER_PULSE, value);
810810
811 _quirks[quirk] = value;811 _quirks[quirk] = value;
812 if (quirk == QUIRK_VISIBLE)812 if (quirk == QUIRK_VISIBLE)
813 Launcher::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT);813 Launcher::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT);
814814
=== modified file 'plugins/unityshell/src/LauncherIcon.h'
--- plugins/unityshell/src/LauncherIcon.h 2011-08-07 23:19:44 +0000
+++ plugins/unityshell/src/LauncherIcon.h 2011-08-19 08:55:26 +0000
@@ -21,6 +21,9 @@
21#ifndef LAUNCHERICON_H21#ifndef LAUNCHERICON_H
22#define LAUNCHERICON_H22#define LAUNCHERICON_H
2323
24#include <set>
25#include <string>
26
24#include <Nux/Nux.h>27#include <Nux/Nux.h>
25#include <Nux/BaseWindow.h>28#include <Nux/BaseWindow.h>
26#include <NuxCore/Math/MathInc.h>29#include <NuxCore/Math/MathInc.h>
@@ -43,7 +46,6 @@
4346
44class Launcher;47class Launcher;
4548
46
47class LauncherIcon : public AbstractLauncherIcon, public unity::Introspectable, public nux::InitiallyUnownedObject49class LauncherIcon : public AbstractLauncherIcon, public unity::Introspectable, public nux::InitiallyUnownedObject
48{50{
49 NUX_DECLARE_OBJECT_TYPE(LauncherIcon, nux::InitiallyUnownedObject);51 NUX_DECLARE_OBJECT_TYPE(LauncherIcon, nux::InitiallyUnownedObject);
@@ -150,14 +152,14 @@
150152
151 void RemoveEntryRemote(LauncherEntryRemote* remote);153 void RemoveEntryRemote(LauncherEntryRemote* remote);
152154
153 nux::DndAction QueryAcceptDrop(std::list<char*> paths)155 nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data)
154 {156 {
155 return OnQueryAcceptDrop(paths);157 return OnQueryAcceptDrop(dnd_data);
156 }158 }
157159
158 void AcceptDrop(std::list<char*> paths)160 void AcceptDrop(unity::DndData& dnd_data)
159 {161 {
160 return OnAcceptDrop(paths);162 return OnAcceptDrop(dnd_data);
161 }163 }
162164
163 void SendDndEnter()165 void SendDndEnter()
@@ -221,12 +223,12 @@
221 return 0;223 return 0;
222 }224 }
223225
224 virtual nux::DndAction OnQueryAcceptDrop(std::list<char*> files)226 virtual nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data)
225 {227 {
226 return nux::DNDACTION_NONE;228 return nux::DNDACTION_NONE;
227 }229 }
228230
229 virtual void OnAcceptDrop(std::list<char*> files) {}231 virtual void OnAcceptDrop(unity::DndData& dnd_data) {}
230232
231 virtual void OnDndEnter() {}233 virtual void OnDndEnter() {}
232234
@@ -327,7 +329,7 @@
327329
328 std::list<LauncherEntryRemote*> _entry_list;330 std::list<LauncherEntryRemote*> _entry_list;
329 std::map<std::string, std::vector<nux::Vector4> > transform_map;331 std::map<std::string, std::vector<nux::Vector4> > transform_map;
330332
331};333};
332334
333#endif // LAUNCHERICON_H335#endif // LAUNCHERICON_H
334336
=== modified file 'plugins/unityshell/src/MockLauncherIcon.h'
--- plugins/unityshell/src/MockLauncherIcon.h 2011-08-04 20:19:46 +0000
+++ plugins/unityshell/src/MockLauncherIcon.h 2011-08-19 08:55:26 +0000
@@ -179,12 +179,12 @@
179 return std::list<DbusmenuMenuitem*> ();179 return std::list<DbusmenuMenuitem*> ();
180 }180 }
181181
182 nux::DndAction QueryAcceptDrop(std::list<char*> paths)182 nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data)
183 {183 {
184 return nux::DNDACTION_NONE;184 return nux::DNDACTION_NONE;
185 }185 }
186186
187 void AcceptDrop(std::list<char*> paths) {}187 void AcceptDrop(unity::DndData& dnd_data) {}
188188
189 void SendDndEnter() {}189 void SendDndEnter() {}
190190
191191
=== modified file 'plugins/unityshell/src/TrashLauncherIcon.cpp'
--- plugins/unityshell/src/TrashLauncherIcon.cpp 2011-07-30 09:00:43 +0000
+++ plugins/unityshell/src/TrashLauncherIcon.cpp 2011-08-19 08:55:26 +0000
@@ -18,15 +18,17 @@
18 */18 */
1919
20#include "TrashLauncherIcon.h"20#include "TrashLauncherIcon.h"
21
22#include <Nux/WindowCompositor.h>
23
24#include <gio/gio.h>
25#include <glib/gi18n-lib.h>
26#include <gconf/gconf-client.h>
27
21#include "Launcher.h"28#include "Launcher.h"
22#include "Nux/WindowCompositor.h"
23
24#include "QuicklistManager.h"29#include "QuicklistManager.h"
25#include "QuicklistMenuItemLabel.h"30#include "QuicklistMenuItemLabel.h"
2631
27#include <gio/gio.h>
28#include <glib/gi18n-lib.h>
29#include <gconf/gconf-client.h>
3032
31#define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash"33#define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash"
3234
@@ -277,19 +279,17 @@
277}279}
278280
279nux::DndAction281nux::DndAction
280TrashLauncherIcon::OnQueryAcceptDrop(std::list<char*> uris)282TrashLauncherIcon::OnQueryAcceptDrop(unity::DndData& dnd_data)
281{283{
282 return nux::DNDACTION_MOVE;284 return nux::DNDACTION_MOVE;
283}285}
284286
285void287void
286TrashLauncherIcon::OnAcceptDrop(std::list<char*> uris)288TrashLauncherIcon::OnAcceptDrop(unity::DndData& dnd_data)
287{289{
288 std::list<char*>::iterator it;290 for (auto it : dnd_data.Uris())
289
290 for (it = uris.begin(); it != uris.end(); it++)
291 {291 {
292 GFile* file = g_file_new_for_uri(*it);292 GFile* file = g_file_new_for_uri(it.c_str());
293 g_file_trash(file, NULL, NULL);293 g_file_trash(file, NULL, NULL);
294 g_object_unref(file);294 g_object_unref(file);
295 }295 }
296296
=== modified file 'plugins/unityshell/src/TrashLauncherIcon.h'
--- plugins/unityshell/src/TrashLauncherIcon.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/TrashLauncherIcon.h 2011-08-19 08:55:26 +0000
@@ -20,6 +20,7 @@
20#ifndef TRASHLAUNCHERICON_H20#ifndef TRASHLAUNCHERICON_H
21#define TRASHLAUNCHERICON_H21#define TRASHLAUNCHERICON_H
2222
23#include "DndData.h"
23#include "SimpleLauncherIcon.h"24#include "SimpleLauncherIcon.h"
2425
25class TrashLauncherIcon : public SimpleLauncherIcon26class TrashLauncherIcon : public SimpleLauncherIcon
@@ -35,8 +36,8 @@
35protected:36protected:
36 void UpdateTrashIcon();37 void UpdateTrashIcon();
3738
38 nux::DndAction OnQueryAcceptDrop(std::list<char*> uris);39 nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data);
39 void OnAcceptDrop(std::list<char*> uris);40 void OnAcceptDrop(unity::DndData& dnd_data);
4041
41private:42private:
42 gulong _on_trash_changed_handler_id;43 gulong _on_trash_changed_handler_id;