Merge lp:~azzar1/unity/dnd-enhancements into lp:unity
- dnd-enhancements
- Merge into trunk
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 |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+71003@code.launchpad.net |
Commit message
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.
Jason Smith (jassmith) wrote : | # |
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.
Andrea Azzarone (azzar1) wrote : | # |
So I should fix that?
Jason Smith (jassmith) wrote : | # |
Yes
Andrea Azzarone (azzar1) wrote : | # |
The problem should be gone away...
Preview Diff
1 | === modified file 'plugins/unityshell/src/AbstractLauncherIcon.h' | |||
2 | --- plugins/unityshell/src/AbstractLauncherIcon.h 2011-08-05 06:20:39 +0000 | |||
3 | +++ plugins/unityshell/src/AbstractLauncherIcon.h 2011-08-19 08:55:26 +0000 | |||
4 | @@ -31,6 +31,8 @@ | |||
5 | 31 | 31 | ||
6 | 32 | #include <libdbusmenu-glib/menuitem.h> | 32 | #include <libdbusmenu-glib/menuitem.h> |
7 | 33 | 33 | ||
8 | 34 | #include "DndData.h" | ||
9 | 35 | |||
10 | 34 | class ActionArg | 36 | class ActionArg |
11 | 35 | { | 37 | { |
12 | 36 | public: | 38 | public: |
13 | @@ -161,9 +163,9 @@ | |||
14 | 161 | 163 | ||
15 | 162 | virtual std::list<DbusmenuMenuitem*> Menus() = 0; | 164 | virtual std::list<DbusmenuMenuitem*> Menus() = 0; |
16 | 163 | 165 | ||
18 | 164 | virtual nux::DndAction QueryAcceptDrop(std::list<char*> paths) = 0; | 166 | virtual nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data) = 0; |
19 | 165 | 167 | ||
21 | 166 | virtual void AcceptDrop(std::list<char*> paths) = 0; | 168 | virtual void AcceptDrop(unity::DndData& dnd_data) = 0; |
22 | 167 | 169 | ||
23 | 168 | virtual void SendDndEnter() = 0; | 170 | virtual void SendDndEnter() = 0; |
24 | 169 | 171 | ||
25 | 170 | 172 | ||
26 | === modified file 'plugins/unityshell/src/BamfLauncherIcon.cpp' | |||
27 | --- plugins/unityshell/src/BamfLauncherIcon.cpp 2011-08-18 00:38:22 +0000 | |||
28 | +++ plugins/unityshell/src/BamfLauncherIcon.cpp 2011-08-19 08:55:26 +0000 | |||
29 | @@ -21,12 +21,11 @@ | |||
30 | 21 | #include "Nux/BaseWindow.h" | 21 | #include "Nux/BaseWindow.h" |
31 | 22 | 22 | ||
32 | 23 | #include "BamfLauncherIcon.h" | 23 | #include "BamfLauncherIcon.h" |
33 | 24 | #include "FavoriteStore.h" | ||
34 | 24 | #include "Launcher.h" | 25 | #include "Launcher.h" |
35 | 25 | #include "PluginAdapter.h" | 26 | #include "PluginAdapter.h" |
38 | 26 | #include "FavoriteStore.h" | 27 | #include "UBusMessages.h" |
37 | 27 | |||
39 | 28 | #include "ubus-server.h" | 28 | #include "ubus-server.h" |
40 | 29 | #include "UBusMessages.h" | ||
41 | 30 | 29 | ||
42 | 31 | #include <glib/gi18n-lib.h> | 30 | #include <glib/gi18n-lib.h> |
43 | 32 | #include <gio/gdesktopappinfo.h> | 31 | #include <gio/gdesktopappinfo.h> |
44 | @@ -34,6 +33,8 @@ | |||
45 | 34 | #include <core/core.h> | 33 | #include <core/core.h> |
46 | 35 | #include <core/atoms.h> | 34 | #include <core/atoms.h> |
47 | 36 | 35 | ||
48 | 36 | #include <UnityCore/GLibWrapper.h> | ||
49 | 37 | |||
50 | 37 | using unity::FavoriteStore; | 38 | using unity::FavoriteStore; |
51 | 38 | 39 | ||
52 | 39 | struct _ShortcutData | 40 | struct _ShortcutData |
53 | @@ -133,7 +134,9 @@ | |||
54 | 133 | } | 134 | } |
55 | 134 | 135 | ||
56 | 135 | BamfLauncherIcon::BamfLauncherIcon(Launcher* IconManager, BamfApplication* app, CompScreen* screen) | 136 | BamfLauncherIcon::BamfLauncherIcon(Launcher* IconManager, BamfApplication* app, CompScreen* screen) |
58 | 136 | : SimpleLauncherIcon(IconManager) | 137 | : SimpleLauncherIcon(IconManager) |
59 | 138 | , _supported_types_filled(false) | ||
60 | 139 | , _fill_supported_types_id(0) | ||
61 | 137 | { | 140 | { |
62 | 138 | _cached_desktop_file = NULL; | 141 | _cached_desktop_file = NULL; |
63 | 139 | _cached_name = NULL; | 142 | _cached_name = NULL; |
64 | @@ -188,8 +191,11 @@ | |||
65 | 188 | PluginAdapter::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized)); | 191 | PluginAdapter::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized)); |
66 | 189 | IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged)); | 192 | IconManager->hidden_changed.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnLauncherHiddenChanged)); |
67 | 190 | 193 | ||
69 | 191 | /* hack */ | 194 | // hack |
70 | 192 | SetProgress(0.0f); | 195 | SetProgress(0.0f); |
71 | 196 | |||
72 | 197 | // Calls when there are no higher priority events pending to the default main loop. | ||
73 | 198 | _fill_supported_types_id = g_idle_add((GSourceFunc)FillSupportedTypes, this); | ||
74 | 193 | 199 | ||
75 | 194 | } | 200 | } |
76 | 195 | 201 | ||
77 | @@ -213,6 +219,9 @@ | |||
78 | 213 | if (_on_desktop_file_changed_handler_id != 0) | 219 | if (_on_desktop_file_changed_handler_id != 0) |
79 | 214 | g_signal_handler_disconnect((gpointer) _desktop_file_monitor, | 220 | g_signal_handler_disconnect((gpointer) _desktop_file_monitor, |
80 | 215 | _on_desktop_file_changed_handler_id); | 221 | _on_desktop_file_changed_handler_id); |
81 | 222 | |||
82 | 223 | if (_fill_supported_types_id != 0) | ||
83 | 224 | g_source_remove(_fill_supported_types_id); | ||
84 | 216 | 225 | ||
85 | 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); |
86 | 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); |
87 | @@ -352,11 +361,10 @@ | |||
88 | 352 | return owns; | 361 | return owns; |
89 | 353 | } | 362 | } |
90 | 354 | 363 | ||
92 | 355 | void BamfLauncherIcon::OpenInstanceWithUris(std::list<char*> uris) | 364 | void BamfLauncherIcon::OpenInstanceWithUris(std::set<std::string> uris) |
93 | 356 | { | 365 | { |
94 | 357 | GDesktopAppInfo* appInfo; | 366 | GDesktopAppInfo* appInfo; |
95 | 358 | GError* error = NULL; | 367 | GError* error = NULL; |
96 | 359 | std::list<char*>::iterator it; | ||
97 | 360 | 368 | ||
98 | 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))); |
99 | 362 | 370 | ||
100 | @@ -364,18 +372,19 @@ | |||
101 | 364 | { | 372 | { |
102 | 365 | GList* list = NULL; | 373 | GList* list = NULL; |
103 | 366 | 374 | ||
106 | 367 | for (it = uris.begin(); it != uris.end(); it++) | 375 | for (auto it : uris) |
107 | 368 | list = g_list_prepend(list, *it); | 376 | list = g_list_prepend(list, g_strdup(it.c_str())); |
108 | 369 | 377 | ||
109 | 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); |
111 | 371 | g_list_free(list); | 379 | g_list_free_full(list, g_free); |
112 | 372 | } | 380 | } |
113 | 373 | else if (g_app_info_supports_files(G_APP_INFO(appInfo))) | 381 | else if (g_app_info_supports_files(G_APP_INFO(appInfo))) |
114 | 374 | { | 382 | { |
115 | 375 | GList* list = NULL, *l; | 383 | GList* list = NULL, *l; |
117 | 376 | for (it = uris.begin(); it != uris.end(); it++) | 384 | |
118 | 385 | for (auto it : uris) | ||
119 | 377 | { | 386 | { |
121 | 378 | GFile* file = g_file_new_for_uri(*it); | 387 | GFile* file = g_file_new_for_uri(it.c_str()); |
122 | 379 | list = g_list_prepend(list, file); | 388 | list = g_list_prepend(list, file); |
123 | 380 | } | 389 | } |
124 | 381 | g_app_info_launch(G_APP_INFO(appInfo), list, NULL, &error); | 390 | g_app_info_launch(G_APP_INFO(appInfo), list, NULL, &error); |
125 | @@ -403,7 +412,7 @@ | |||
126 | 403 | 412 | ||
127 | 404 | void BamfLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg) | 413 | void BamfLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg) |
128 | 405 | { | 414 | { |
130 | 406 | std::list<char*> empty; | 415 | std::set<std::string> empty; |
131 | 407 | OpenInstanceWithUris(empty); | 416 | OpenInstanceWithUris(empty); |
132 | 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); |
133 | 409 | } | 418 | } |
134 | @@ -1038,62 +1047,21 @@ | |||
135 | 1038 | return _remote_uri; | 1047 | return _remote_uri; |
136 | 1039 | } | 1048 | } |
137 | 1040 | 1049 | ||
139 | 1041 | std::list<char*> BamfLauncherIcon::ValidateUrisForLaunch(std::list<char*> uris) | 1050 | std::set<std::string> BamfLauncherIcon::ValidateUrisForLaunch(unity::DndData& uris) |
140 | 1042 | { | 1051 | { |
180 | 1043 | GKeyFile* key_file; | 1052 | std::set<std::string> result; |
181 | 1044 | const char* desktop_file; | 1053 | |
182 | 1045 | GError* error = NULL; | 1054 | for (auto i : uris.Types()) |
183 | 1046 | std::list<char*> results; | 1055 | for (auto j : GetSupportedTypes()) |
184 | 1047 | 1056 | if (g_content_type_is_a(i.c_str(), j.c_str())) | |
146 | 1048 | desktop_file = DesktopFile(); | ||
147 | 1049 | |||
148 | 1050 | if (!desktop_file || strlen(desktop_file) <= 1) | ||
149 | 1051 | return results; | ||
150 | 1052 | |||
151 | 1053 | key_file = g_key_file_new(); | ||
152 | 1054 | g_key_file_load_from_file(key_file, desktop_file, (GKeyFileFlags) 0, &error); | ||
153 | 1055 | |||
154 | 1056 | if (error) | ||
155 | 1057 | { | ||
156 | 1058 | g_error_free(error); | ||
157 | 1059 | g_key_file_free(key_file); | ||
158 | 1060 | return results; | ||
159 | 1061 | } | ||
160 | 1062 | |||
161 | 1063 | char** mimes = g_key_file_get_string_list(key_file, "Desktop Entry", "MimeType", NULL, NULL); | ||
162 | 1064 | if (!mimes) | ||
163 | 1065 | { | ||
164 | 1066 | g_key_file_free(key_file); | ||
165 | 1067 | return results; | ||
166 | 1068 | } | ||
167 | 1069 | |||
168 | 1070 | std::list<char*>::iterator it; | ||
169 | 1071 | for (it = uris.begin(); it != uris.end(); it++) | ||
170 | 1072 | { | ||
171 | 1073 | GFile* file = g_file_new_for_uri(*it); | ||
172 | 1074 | GFileInfo* info = g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); | ||
173 | 1075 | const char* content_type = g_file_info_get_content_type(info); | ||
174 | 1076 | |||
175 | 1077 | int i = 0; | ||
176 | 1078 | for (; mimes[i]; i++) | ||
177 | 1079 | { | ||
178 | 1080 | char* super_type = g_content_type_from_mime_type(mimes[i]); | ||
179 | 1081 | if (g_content_type_is_a(content_type, super_type)) | ||
185 | 1082 | { | 1057 | { |
187 | 1083 | results.push_back(*it); | 1058 | for (auto k : uris.UrisByType(i)) |
188 | 1059 | result.insert(k); | ||
189 | 1060 | |||
190 | 1084 | break; | 1061 | break; |
191 | 1085 | } | 1062 | } |
203 | 1086 | g_free(super_type); | 1063 | |
204 | 1087 | } | 1064 | return result; |
194 | 1088 | |||
195 | 1089 | |||
196 | 1090 | g_object_unref(file); | ||
197 | 1091 | g_object_unref(info); | ||
198 | 1092 | } | ||
199 | 1093 | |||
200 | 1094 | g_strfreev(mimes); | ||
201 | 1095 | g_key_file_free(key_file); | ||
202 | 1096 | return results; | ||
205 | 1097 | } | 1065 | } |
206 | 1098 | 1066 | ||
207 | 1099 | gboolean BamfLauncherIcon::OnDndHoveredTimeout(gpointer data) | 1067 | gboolean BamfLauncherIcon::OnDndHoveredTimeout(gpointer data) |
208 | @@ -1121,14 +1089,14 @@ | |||
209 | 1121 | _dnd_hover_timer = 0; | 1089 | _dnd_hover_timer = 0; |
210 | 1122 | } | 1090 | } |
211 | 1123 | 1091 | ||
213 | 1124 | nux::DndAction BamfLauncherIcon::OnQueryAcceptDrop(std::list<char*> uris) | 1092 | nux::DndAction BamfLauncherIcon::OnQueryAcceptDrop(unity::DndData& dnd_data) |
214 | 1125 | { | 1093 | { |
216 | 1126 | return ValidateUrisForLaunch(uris).empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY; | 1094 | return ValidateUrisForLaunch(dnd_data).empty() ? nux::DNDACTION_NONE : nux::DNDACTION_COPY; |
217 | 1127 | } | 1095 | } |
218 | 1128 | 1096 | ||
220 | 1129 | void BamfLauncherIcon::OnAcceptDrop(std::list<char*> uris) | 1097 | void BamfLauncherIcon::OnAcceptDrop(unity::DndData& dnd_data) |
221 | 1130 | { | 1098 | { |
223 | 1131 | OpenInstanceWithUris(ValidateUrisForLaunch(uris)); | 1099 | OpenInstanceWithUris(ValidateUrisForLaunch(dnd_data)); |
224 | 1132 | } | 1100 | } |
225 | 1133 | 1101 | ||
226 | 1134 | void BamfLauncherIcon::OnDesktopFileChanged(GFileMonitor* monitor, | 1102 | void BamfLauncherIcon::OnDesktopFileChanged(GFileMonitor* monitor, |
227 | @@ -1181,3 +1149,65 @@ | |||
228 | 1181 | g_list_free(children); | 1149 | g_list_free(children); |
229 | 1182 | return result; | 1150 | return result; |
230 | 1183 | } | 1151 | } |
231 | 1152 | |||
232 | 1153 | const std::set<std::string>& | ||
233 | 1154 | BamfLauncherIcon::GetSupportedTypes() | ||
234 | 1155 | { | ||
235 | 1156 | if (!_supported_types_filled) | ||
236 | 1157 | FillSupportedTypes(this); | ||
237 | 1158 | |||
238 | 1159 | return _supported_types; | ||
239 | 1160 | } | ||
240 | 1161 | |||
241 | 1162 | gboolean | ||
242 | 1163 | BamfLauncherIcon::FillSupportedTypes(gpointer data) | ||
243 | 1164 | { | ||
244 | 1165 | BamfLauncherIcon* self = (BamfLauncherIcon*) data; | ||
245 | 1166 | |||
246 | 1167 | if (self->_fill_supported_types_id) | ||
247 | 1168 | { | ||
248 | 1169 | g_source_remove(self->_fill_supported_types_id); | ||
249 | 1170 | self->_fill_supported_types_id = 0; | ||
250 | 1171 | } | ||
251 | 1172 | |||
252 | 1173 | if (!self->_supported_types_filled) | ||
253 | 1174 | { | ||
254 | 1175 | self->_supported_types_filled = true; | ||
255 | 1176 | |||
256 | 1177 | self->_supported_types.clear(); | ||
257 | 1178 | |||
258 | 1179 | const char* desktop_file = self->DesktopFile(); | ||
259 | 1180 | |||
260 | 1181 | if (!desktop_file || strlen(desktop_file) <= 1) | ||
261 | 1182 | return false; | ||
262 | 1183 | |||
263 | 1184 | GKeyFile* key_file = g_key_file_new(); | ||
264 | 1185 | unity::glib::Error error; | ||
265 | 1186 | |||
266 | 1187 | g_key_file_load_from_file(key_file, desktop_file, (GKeyFileFlags) 0, &error); | ||
267 | 1188 | |||
268 | 1189 | if (error) | ||
269 | 1190 | { | ||
270 | 1191 | g_key_file_free(key_file); | ||
271 | 1192 | return false; | ||
272 | 1193 | } | ||
273 | 1194 | |||
274 | 1195 | char** mimes = g_key_file_get_string_list(key_file, "Desktop Entry", "MimeType", NULL, NULL); | ||
275 | 1196 | if (!mimes) | ||
276 | 1197 | { | ||
277 | 1198 | g_key_file_free(key_file); | ||
278 | 1199 | return false; | ||
279 | 1200 | } | ||
280 | 1201 | |||
281 | 1202 | for (int i=0; mimes[i]; i++) | ||
282 | 1203 | { | ||
283 | 1204 | unity::glib::String super_type(g_content_type_from_mime_type(mimes[i])); | ||
284 | 1205 | self->_supported_types.insert(super_type.Str()); | ||
285 | 1206 | } | ||
286 | 1207 | |||
287 | 1208 | g_key_file_free(key_file); | ||
288 | 1209 | g_strfreev(mimes); | ||
289 | 1210 | } | ||
290 | 1211 | |||
291 | 1212 | return false; | ||
292 | 1213 | } | ||
293 | 1184 | 1214 | ||
294 | === modified file 'plugins/unityshell/src/BamfLauncherIcon.h' | |||
295 | --- plugins/unityshell/src/BamfLauncherIcon.h 2011-08-04 20:19:46 +0000 | |||
296 | +++ plugins/unityshell/src/BamfLauncherIcon.h 2011-08-19 08:55:26 +0000 | |||
297 | @@ -63,14 +63,14 @@ | |||
298 | 63 | 63 | ||
299 | 64 | const gchar* GetRemoteUri(); | 64 | const gchar* GetRemoteUri(); |
300 | 65 | 65 | ||
303 | 66 | nux::DndAction OnQueryAcceptDrop(std::list<char*> uris); | 66 | nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data); |
304 | 67 | void OnAcceptDrop(std::list<char*> uris); | 67 | void OnAcceptDrop(unity::DndData& dnd_data); |
305 | 68 | void OnDndEnter(); | 68 | void OnDndEnter(); |
306 | 69 | void OnDndLeave(); | 69 | void OnDndLeave(); |
307 | 70 | 70 | ||
308 | 71 | void OpenInstanceLauncherIcon(ActionArg arg); | 71 | void OpenInstanceLauncherIcon(ActionArg arg); |
309 | 72 | 72 | ||
311 | 73 | std::list<char*> ValidateUrisForLaunch(std::list<char*> uris); | 73 | std::set<std::string> ValidateUrisForLaunch(unity::DndData& dnd_data); |
312 | 74 | 74 | ||
313 | 75 | const char* BamfName(); | 75 | const char* BamfName(); |
314 | 76 | 76 | ||
315 | @@ -89,15 +89,18 @@ | |||
316 | 89 | gchar* _cached_desktop_file; | 89 | gchar* _cached_desktop_file; |
317 | 90 | gchar* _cached_name; | 90 | gchar* _cached_name; |
318 | 91 | 91 | ||
319 | 92 | |||
320 | 93 | GFileMonitor* _desktop_file_monitor; | 92 | GFileMonitor* _desktop_file_monitor; |
321 | 94 | gulong _on_desktop_file_changed_handler_id; | 93 | gulong _on_desktop_file_changed_handler_id; |
322 | 94 | |||
323 | 95 | std::set<std::string> _supported_types; | ||
324 | 96 | bool _supported_types_filled; | ||
325 | 97 | guint _fill_supported_types_id; | ||
326 | 95 | 98 | ||
327 | 96 | void EnsureWindowState(); | 99 | void EnsureWindowState(); |
328 | 97 | 100 | ||
329 | 98 | void UpdateMenus(); | 101 | void UpdateMenus(); |
330 | 99 | 102 | ||
332 | 100 | void OpenInstanceWithUris(std::list<char*> uris); | 103 | void OpenInstanceWithUris(std::set<std::string> uris); |
333 | 101 | void Focus(); | 104 | void Focus(); |
334 | 102 | bool Spread(int state, bool force); | 105 | bool Spread(int state, bool force); |
335 | 103 | 106 | ||
336 | @@ -105,6 +108,8 @@ | |||
337 | 105 | 108 | ||
338 | 106 | void OnWindowMinimized(guint32 xid); | 109 | void OnWindowMinimized(guint32 xid); |
339 | 107 | bool OwnsWindow(Window w); | 110 | bool OwnsWindow(Window w); |
340 | 111 | |||
341 | 112 | const std::set<std::string>& GetSupportedTypes(); | ||
342 | 108 | 113 | ||
343 | 109 | static void OnClosed(BamfView* view, gpointer data); | 114 | static void OnClosed(BamfView* view, gpointer data); |
344 | 110 | static void OnUserVisibleChanged(BamfView* view, gboolean visible, gpointer data); | 115 | static void OnUserVisibleChanged(BamfView* view, gboolean visible, gpointer data); |
345 | @@ -125,6 +130,7 @@ | |||
346 | 125 | gpointer data); | 130 | gpointer data); |
347 | 126 | 131 | ||
348 | 127 | static gboolean OnDndHoveredTimeout(gpointer data); | 132 | static gboolean OnDndHoveredTimeout(gpointer data); |
349 | 133 | static gboolean FillSupportedTypes(gpointer data); | ||
350 | 128 | }; | 134 | }; |
351 | 129 | 135 | ||
352 | 130 | #endif // BAMFLAUNCHERICON_H | 136 | #endif // BAMFLAUNCHERICON_H |
353 | 131 | 137 | ||
354 | === added file 'plugins/unityshell/src/DNDCollectionWindow.cpp' | |||
355 | --- plugins/unityshell/src/DNDCollectionWindow.cpp 1970-01-01 00:00:00 +0000 | |||
356 | +++ plugins/unityshell/src/DNDCollectionWindow.cpp 2011-08-19 08:55:26 +0000 | |||
357 | @@ -0,0 +1,63 @@ | |||
358 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
359 | 2 | /* | ||
360 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
361 | 4 | * | ||
362 | 5 | * This program is free software: you can redistribute it and/or modify | ||
363 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
364 | 7 | * published by the Free Software Foundation. | ||
365 | 8 | * | ||
366 | 9 | * This program is distributed in the hope that it will be useful, | ||
367 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
368 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
369 | 12 | * GNU General Public License for more details. | ||
370 | 13 | * | ||
371 | 14 | * You should have received a copy of the GNU General Public License | ||
372 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
373 | 16 | * | ||
374 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
375 | 18 | */ | ||
376 | 19 | |||
377 | 20 | #include "DNDCollectionWindow.h" | ||
378 | 21 | |||
379 | 22 | namespace unity { | ||
380 | 23 | |||
381 | 24 | NUX_IMPLEMENT_OBJECT_TYPE(DNDCollectionWindow); | ||
382 | 25 | |||
383 | 26 | DNDCollectionWindow::DNDCollectionWindow(CompScreen* screen) | ||
384 | 27 | : nux::BaseWindow("") | ||
385 | 28 | { | ||
386 | 29 | SetBackgroundColor(nux::Color(0x00000000)); | ||
387 | 30 | SetBaseSize(screen->width(), screen->height()); | ||
388 | 31 | SetBaseXY(0, 0); | ||
389 | 32 | |||
390 | 33 | ShowWindow(true); | ||
391 | 34 | PushToBack(); | ||
392 | 35 | // Hack | ||
393 | 36 | EnableInputWindow(true, "DNDCollectionWindow"); | ||
394 | 37 | EnableInputWindow(false, "DNDCollectionWindow"); | ||
395 | 38 | SetDndEnabled(false, true); | ||
396 | 39 | } | ||
397 | 40 | |||
398 | 41 | DNDCollectionWindow::~DNDCollectionWindow() | ||
399 | 42 | { | ||
400 | 43 | for (auto it : mimes_) | ||
401 | 44 | g_free(it); | ||
402 | 45 | } | ||
403 | 46 | |||
404 | 47 | void DNDCollectionWindow::ProcessDndMove(int x, int y, std::list<char*> mimes) | ||
405 | 48 | { | ||
406 | 49 | // Hide the window as soon as possible | ||
407 | 50 | EnableInputWindow(false, "DNDCollectionWindow"); | ||
408 | 51 | |||
409 | 52 | for (auto it : mimes_) | ||
410 | 53 | g_free(it); | ||
411 | 54 | mimes_.clear(); | ||
412 | 55 | |||
413 | 56 | // Duplicate the list | ||
414 | 57 | for (auto it : mimes) | ||
415 | 58 | mimes_.push_back(g_strdup(it)); | ||
416 | 59 | |||
417 | 60 | collected.emit(mimes_); | ||
418 | 61 | } | ||
419 | 62 | |||
420 | 63 | } // namespace unity | ||
421 | 0 | 64 | ||
422 | === added file 'plugins/unityshell/src/DNDCollectionWindow.h' | |||
423 | --- plugins/unityshell/src/DNDCollectionWindow.h 1970-01-01 00:00:00 +0000 | |||
424 | +++ plugins/unityshell/src/DNDCollectionWindow.h 2011-08-19 08:55:26 +0000 | |||
425 | @@ -0,0 +1,55 @@ | |||
426 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
427 | 2 | /* | ||
428 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
429 | 4 | * | ||
430 | 5 | * This program is free software: you can redistribute it and/or modify | ||
431 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
432 | 7 | * published by the Free Software Foundation. | ||
433 | 8 | * | ||
434 | 9 | * This program is distributed in the hope that it will be useful, | ||
435 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
436 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
437 | 12 | * GNU General Public License for more details. | ||
438 | 13 | * | ||
439 | 14 | * You should have received a copy of the GNU General Public License | ||
440 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
441 | 16 | * | ||
442 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
443 | 18 | */ | ||
444 | 19 | |||
445 | 20 | #ifndef DNDCOLLECTIONWINDOW_H | ||
446 | 21 | #define DNDCOLLECTIONWINDOW_H | ||
447 | 22 | |||
448 | 23 | #include <list> | ||
449 | 24 | |||
450 | 25 | #include <core/screen.h> | ||
451 | 26 | #include <Nux/Nux.h> | ||
452 | 27 | #include <Nux/BaseWindow.h> | ||
453 | 28 | #include <sigc++/sigc++.h> | ||
454 | 29 | |||
455 | 30 | namespace unity { | ||
456 | 31 | |||
457 | 32 | class DNDCollectionWindow : public nux::BaseWindow | ||
458 | 33 | { | ||
459 | 34 | NUX_DECLARE_OBJECT_TYPE(DNDCollectionWindow, nux::BaseWindow); | ||
460 | 35 | |||
461 | 36 | // Methods | ||
462 | 37 | public: | ||
463 | 38 | DNDCollectionWindow(CompScreen* screen); | ||
464 | 39 | ~DNDCollectionWindow(); | ||
465 | 40 | |||
466 | 41 | private: | ||
467 | 42 | void ProcessDndMove(int x, int y, std::list<char*> mimes); | ||
468 | 43 | |||
469 | 44 | // Members | ||
470 | 45 | public: | ||
471 | 46 | sigc::signal<void, const std::list<char*>&> collected; | ||
472 | 47 | |||
473 | 48 | private: | ||
474 | 49 | std::list<char*> mimes_; | ||
475 | 50 | |||
476 | 51 | }; | ||
477 | 52 | |||
478 | 53 | } // namespace unity | ||
479 | 54 | |||
480 | 55 | #endif // DNDCOLLECTIONWINDOW_H | ||
481 | 0 | 56 | ||
482 | === added file 'plugins/unityshell/src/DndData.cpp' | |||
483 | --- plugins/unityshell/src/DndData.cpp 1970-01-01 00:00:00 +0000 | |||
484 | +++ plugins/unityshell/src/DndData.cpp 2011-08-19 08:55:26 +0000 | |||
485 | @@ -0,0 +1,63 @@ | |||
486 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
487 | 2 | /* | ||
488 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
489 | 4 | * | ||
490 | 5 | * This program is free software: you can redistribute it and/or modify | ||
491 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
492 | 7 | * published by the Free Software Foundation. | ||
493 | 8 | * | ||
494 | 9 | * This program is distributed in the hope that it will be useful, | ||
495 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
496 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
497 | 12 | * GNU General Public License for more details. | ||
498 | 13 | * | ||
499 | 14 | * You should have received a copy of the GNU General Public License | ||
500 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
501 | 16 | * | ||
502 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
503 | 18 | */ | ||
504 | 19 | |||
505 | 20 | #include "DndData.h" | ||
506 | 21 | |||
507 | 22 | #include <cstring> | ||
508 | 23 | #include <vector> | ||
509 | 24 | |||
510 | 25 | #include <gio/gio.h> | ||
511 | 26 | |||
512 | 27 | #include <UnityCore/GLibWrapper.h> | ||
513 | 28 | |||
514 | 29 | namespace unity { | ||
515 | 30 | |||
516 | 31 | void DndData::Fill(char* uris) | ||
517 | 32 | { | ||
518 | 33 | Reset(); | ||
519 | 34 | |||
520 | 35 | char* pch = strtok (uris, "\r\n"); | ||
521 | 36 | while (pch != NULL) | ||
522 | 37 | { | ||
523 | 38 | glib::Object<GFile> file(g_file_new_for_uri(pch)); | ||
524 | 39 | glib::Object<GFileInfo> info(g_file_query_info(file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL)); | ||
525 | 40 | const char* content_type = g_file_info_get_content_type(info); | ||
526 | 41 | |||
527 | 42 | uris_.insert(pch); | ||
528 | 43 | |||
529 | 44 | if (content_type != NULL) | ||
530 | 45 | { | ||
531 | 46 | types_.insert(content_type); | ||
532 | 47 | uris_to_types_[pch] = content_type; | ||
533 | 48 | types_to_uris_[content_type].insert(pch); | ||
534 | 49 | } | ||
535 | 50 | |||
536 | 51 | pch = strtok (NULL, "\r\n"); | ||
537 | 52 | } | ||
538 | 53 | } | ||
539 | 54 | |||
540 | 55 | void DndData::Reset() | ||
541 | 56 | { | ||
542 | 57 | uris_.clear(); | ||
543 | 58 | types_.clear(); | ||
544 | 59 | uris_to_types_.clear(); | ||
545 | 60 | types_to_uris_.clear(); | ||
546 | 61 | } | ||
547 | 62 | |||
548 | 63 | } // namespace unity | ||
549 | 0 | 64 | ||
550 | === added file 'plugins/unityshell/src/DndData.h' | |||
551 | --- plugins/unityshell/src/DndData.h 1970-01-01 00:00:00 +0000 | |||
552 | +++ plugins/unityshell/src/DndData.h 2011-08-19 08:55:26 +0000 | |||
553 | @@ -0,0 +1,71 @@ | |||
554 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
555 | 2 | /* | ||
556 | 3 | * Copyright (C) 2011 Canonical Ltd | ||
557 | 4 | * | ||
558 | 5 | * This program is free software: you can redistribute it and/or modify | ||
559 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
560 | 7 | * published by the Free Software Foundation. | ||
561 | 8 | * | ||
562 | 9 | * This program is distributed in the hope that it will be useful, | ||
563 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
564 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
565 | 12 | * GNU General Public License for more details. | ||
566 | 13 | * | ||
567 | 14 | * You should have received a copy of the GNU General Public License | ||
568 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
569 | 16 | * | ||
570 | 17 | * Authored by: Andrea Azzarone <azzaronea@gmail.com> | ||
571 | 18 | */ | ||
572 | 19 | |||
573 | 20 | #ifndef DNDDATA_H | ||
574 | 21 | #define DNDDATA_H | ||
575 | 22 | |||
576 | 23 | #include <map> | ||
577 | 24 | #include <set> | ||
578 | 25 | #include <string> | ||
579 | 26 | |||
580 | 27 | namespace unity { | ||
581 | 28 | |||
582 | 29 | class DndData | ||
583 | 30 | { | ||
584 | 31 | public: | ||
585 | 32 | /** | ||
586 | 33 | * Fills the object given a list of uris. | ||
587 | 34 | **/ | ||
588 | 35 | void Fill(char* uris); | ||
589 | 36 | |||
590 | 37 | /** | ||
591 | 38 | * Resets the object. Call this function when no longer need data | ||
592 | 39 | **/ | ||
593 | 40 | void Reset(); | ||
594 | 41 | |||
595 | 42 | /** | ||
596 | 43 | * Returns a std::set<std::string> with all the uris. | ||
597 | 44 | **/ | ||
598 | 45 | std::set<std::string>& Uris() { return uris_; } | ||
599 | 46 | |||
600 | 47 | /** | ||
601 | 48 | * Returns a std::set<std::string> with all the types. | ||
602 | 49 | **/ | ||
603 | 50 | std::set<std::string>& Types() { return types_; } | ||
604 | 51 | |||
605 | 52 | /** | ||
606 | 53 | * Returns a std::set<std::string> with all uris of a given type. | ||
607 | 54 | **/ | ||
608 | 55 | std::set<std::string>& UrisByType(const std::string& type) { return types_to_uris_[type]; } | ||
609 | 56 | |||
610 | 57 | /** | ||
611 | 58 | * Returns a std::set<std::string> with all types of a given uri. | ||
612 | 59 | **/ | ||
613 | 60 | std::string& TypeByUri(const std::string& uris) { return uris_to_types_[uris]; } | ||
614 | 61 | |||
615 | 62 | private: | ||
616 | 63 | std::set<std::string> uris_; | ||
617 | 64 | std::set<std::string> types_; | ||
618 | 65 | std::map<std::string, std::string> uris_to_types_; | ||
619 | 66 | std::map<std::string, std::set<std::string>> types_to_uris_; | ||
620 | 67 | }; | ||
621 | 68 | |||
622 | 69 | } // namespace unity | ||
623 | 70 | |||
624 | 71 | #endif // DNDDATA_H | ||
625 | 0 | 72 | ||
626 | === modified file 'plugins/unityshell/src/Launcher.cpp' | |||
627 | --- plugins/unityshell/src/Launcher.cpp 2011-08-13 06:17:26 +0000 | |||
628 | +++ plugins/unityshell/src/Launcher.cpp 2011-08-19 08:55:26 +0000 | |||
629 | @@ -48,12 +48,11 @@ | |||
630 | 48 | #include "ubus-server.h" | 48 | #include "ubus-server.h" |
631 | 49 | #include "UBusMessages.h" | 49 | #include "UBusMessages.h" |
632 | 50 | 50 | ||
633 | 51 | #include <UnityCore/GLibWrapper.h> | ||
634 | 51 | #include <UnityCore/Variant.h> | 52 | #include <UnityCore/Variant.h> |
635 | 52 | 53 | ||
636 | 53 | using namespace unity::ui; | 54 | using namespace unity::ui; |
637 | 54 | 55 | ||
638 | 55 | using namespace unity::ui; | ||
639 | 56 | |||
640 | 57 | namespace | 56 | namespace |
641 | 58 | { | 57 | { |
642 | 59 | 58 | ||
643 | @@ -136,13 +135,15 @@ | |||
644 | 136 | Launcher::Launcher(nux::BaseWindow* parent, | 135 | Launcher::Launcher(nux::BaseWindow* parent, |
645 | 137 | CompScreen* screen, | 136 | CompScreen* screen, |
646 | 138 | NUX_FILE_LINE_DECL) | 137 | NUX_FILE_LINE_DECL) |
653 | 139 | : View(NUX_FILE_LINE_PARAM) | 138 | : View(NUX_FILE_LINE_PARAM) |
654 | 140 | , m_ContentOffsetY(0) | 139 | , m_ContentOffsetY(0) |
655 | 141 | , m_BackgroundLayer(0) | 140 | , m_BackgroundLayer(0) |
656 | 142 | , _model(0) | 141 | , _model(0) |
657 | 143 | , _background_color (nux::color::DimGray) | 142 | , _collection_window(NULL) |
658 | 144 | , _dash_is_open (false) | 143 | , _background_color(nux::color::DimGray) |
659 | 144 | , _dash_is_open(false) | ||
660 | 145 | { | 145 | { |
661 | 146 | |||
662 | 146 | _parent = parent; | 147 | _parent = parent; |
663 | 147 | _screen = screen; | 148 | _screen = screen; |
664 | 148 | _active_quicklist = 0; | 149 | _active_quicklist = 0; |
665 | @@ -263,6 +264,11 @@ | |||
666 | 263 | _bfb_width = 1; | 264 | _bfb_width = 1; |
667 | 264 | _bfb_height = 1; | 265 | _bfb_height = 1; |
668 | 265 | 266 | ||
669 | 267 | _data_checked = false; | ||
670 | 268 | _collection_window = new unity::DNDCollectionWindow(_screen); | ||
671 | 269 | _collection_window->SinkReference(); | ||
672 | 270 | _on_data_collected_connection = _collection_window->collected.connect(sigc::mem_fun(this, &Launcher::OnDNDDataCollected)); | ||
673 | 271 | |||
674 | 266 | // 0 out timers to avoid wonky startups | 272 | // 0 out timers to avoid wonky startups |
675 | 267 | int i; | 273 | int i; |
676 | 268 | for (i = 0; i < TIME_LAST; ++i) | 274 | for (i = 0; i < TIME_LAST; ++i) |
677 | @@ -271,6 +277,7 @@ | |||
678 | 271 | _times[i].tv_nsec = 0; | 277 | _times[i].tv_nsec = 0; |
679 | 272 | } | 278 | } |
680 | 273 | 279 | ||
681 | 280 | _dnd_hovered_icon = NULL; | ||
682 | 274 | _drag_window = NULL; | 281 | _drag_window = NULL; |
683 | 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); |
684 | 276 | 283 | ||
685 | @@ -350,6 +357,9 @@ | |||
686 | 350 | 357 | ||
687 | 351 | if (_launcher_animation_timeout > 0) | 358 | if (_launcher_animation_timeout > 0) |
688 | 352 | g_source_remove(_launcher_animation_timeout); | 359 | g_source_remove(_launcher_animation_timeout); |
689 | 360 | |||
690 | 361 | if (_on_data_collected_connection.connected()) | ||
691 | 362 | _on_data_collected_connection.disconnect(); | ||
692 | 353 | 363 | ||
693 | 354 | UBusServer* ubus = ubus_server_get_default(); | 364 | UBusServer* ubus = ubus_server_get_default(); |
694 | 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) |
695 | @@ -359,6 +369,9 @@ | |||
696 | 359 | } | 369 | } |
697 | 360 | 370 | ||
698 | 361 | g_idle_remove_by_data(this); | 371 | g_idle_remove_by_data(this); |
699 | 372 | |||
700 | 373 | if (_collection_window) | ||
701 | 374 | _collection_window->UnReference(); | ||
702 | 362 | 375 | ||
703 | 363 | delete _hover_machine; | 376 | delete _hover_machine; |
704 | 364 | delete _hide_machine; | 377 | delete _hide_machine; |
705 | @@ -656,7 +669,7 @@ | |||
706 | 656 | time = icon->GetQuirkTime(LauncherIcon::QUIRK_PROGRESS); | 669 | time = icon->GetQuirkTime(LauncherIcon::QUIRK_PROGRESS); |
707 | 657 | if (TimeDelta(¤t, &time) < ANIM_DURATION) | 670 | if (TimeDelta(¤t, &time) < ANIM_DURATION) |
708 | 658 | return true; | 671 | return true; |
710 | 659 | 672 | ||
711 | 660 | time = icon->GetQuirkTime(LauncherIcon::QUIRK_DROP_DIM); | 673 | time = icon->GetQuirkTime(LauncherIcon::QUIRK_DROP_DIM); |
712 | 661 | if (TimeDelta(¤t, &time) < ANIM_DURATION) | 674 | if (TimeDelta(¤t, &time) < ANIM_DURATION) |
713 | 662 | return true; | 675 | return true; |
714 | @@ -1091,7 +1104,7 @@ | |||
715 | 1091 | arg.alpha *= size_modifier; | 1104 | arg.alpha *= size_modifier; |
716 | 1092 | center.z = 300.0f * (1.0f - size_modifier); | 1105 | center.z = 300.0f * (1.0f - size_modifier); |
717 | 1093 | } | 1106 | } |
719 | 1094 | 1107 | ||
720 | 1095 | float drop_dim_value = 0.2f + 0.8f * IconDropDimValue(icon, current); | 1108 | float drop_dim_value = 0.2f + 0.8f * IconDropDimValue(icon, current); |
721 | 1096 | 1109 | ||
722 | 1097 | if (drop_dim_value < 1.0f) | 1110 | if (drop_dim_value < 1.0f) |
723 | @@ -1513,7 +1526,7 @@ | |||
724 | 1513 | _parent->EnableInputWindow(!hidden, "launcher", false, false); | 1526 | _parent->EnableInputWindow(!hidden, "launcher", false, false); |
725 | 1514 | 1527 | ||
726 | 1515 | if (!hidden && GetActionState() == ACTION_DRAG_EXTERNAL) | 1528 | if (!hidden && GetActionState() == ACTION_DRAG_EXTERNAL) |
728 | 1516 | ProcessDndLeave(); | 1529 | DndLeave(); |
729 | 1517 | 1530 | ||
730 | 1518 | EnsureAnimation(); | 1531 | EnsureAnimation(); |
731 | 1519 | 1532 | ||
732 | @@ -1614,10 +1627,19 @@ | |||
733 | 1614 | 1627 | ||
734 | 1615 | if (drag_owner && (mask & (Button1Mask | Button2Mask | Button3Mask))) | 1628 | if (drag_owner && (mask & (Button1Mask | Button2Mask | Button3Mask))) |
735 | 1616 | { | 1629 | { |
737 | 1617 | self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true); | 1630 | if (self->_data_checked == false) |
738 | 1631 | { | ||
739 | 1632 | self->_data_checked = true; | ||
740 | 1633 | self->_collection_window->EnableInputWindow(true, "DNDCollectionWindow"); | ||
741 | 1634 | } | ||
742 | 1635 | |||
743 | 1618 | return true; | 1636 | return true; |
744 | 1619 | } | 1637 | } |
745 | 1638 | |||
746 | 1639 | self->_data_checked = false; | ||
747 | 1640 | self->_collection_window->EnableInputWindow(false, "DNDCollectionWindow"); | ||
748 | 1620 | 1641 | ||
749 | 1642 | self->DndLeave(); | ||
750 | 1621 | self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false); | 1643 | self->_hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false); |
751 | 1622 | self->_hide_machine->SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, false); | 1644 | self->_hide_machine->SetQuirk(LauncherHideMachine::DND_PUSHED_OFF, false); |
752 | 1623 | 1645 | ||
753 | @@ -1681,11 +1703,6 @@ | |||
754 | 1681 | 1703 | ||
755 | 1682 | if (_hidemode == LAUNCHER_HIDE_NEVER) | 1704 | if (_hidemode == LAUNCHER_HIDE_NEVER) |
756 | 1683 | return; | 1705 | return; |
757 | 1684 | |||
758 | 1685 | if (PluginAdapter::Default ()->IsScaleActive ()) | ||
759 | 1686 | _parent->InputWindowEnableStruts (true); | ||
760 | 1687 | else | ||
761 | 1688 | _parent->InputWindowEnableStruts (false); | ||
762 | 1689 | } | 1706 | } |
763 | 1690 | 1707 | ||
764 | 1691 | Launcher::LauncherHideMode Launcher::GetHideMode() | 1708 | Launcher::LauncherHideMode Launcher::GetHideMode() |
765 | @@ -2803,10 +2820,51 @@ | |||
766 | 2803 | nux::GetWindowCompositor().RestoreRenderingSurface(); | 2820 | nux::GetWindowCompositor().RestoreRenderingSurface(); |
767 | 2804 | } | 2821 | } |
768 | 2805 | 2822 | ||
769 | 2823 | void Launcher::OnDNDDataCollected(const std::list<char*>& mimes) | ||
770 | 2824 | { | ||
771 | 2825 | _dnd_data.Reset(); | ||
772 | 2826 | |||
773 | 2827 | unity::glib::String uri_list_const(g_strdup("text/uri-list")); | ||
774 | 2828 | |||
775 | 2829 | for (auto it : mimes) | ||
776 | 2830 | { | ||
777 | 2831 | if (!g_str_equal(it, uri_list_const.Value())) | ||
778 | 2832 | continue; | ||
779 | 2833 | |||
780 | 2834 | _dnd_data.Fill(nux::GetWindow().GetDndData(uri_list_const.Value())); | ||
781 | 2835 | break; | ||
782 | 2836 | } | ||
783 | 2837 | |||
784 | 2838 | if (!_dnd_data.Uris().size()) | ||
785 | 2839 | return; | ||
786 | 2840 | |||
787 | 2841 | _hide_machine->SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, true); | ||
788 | 2842 | |||
789 | 2843 | for (auto it : _dnd_data.Uris()) | ||
790 | 2844 | { | ||
791 | 2845 | if (g_str_has_suffix(it.c_str(), ".desktop")) | ||
792 | 2846 | { | ||
793 | 2847 | _steal_drag = true; | ||
794 | 2848 | break; | ||
795 | 2849 | } | ||
796 | 2850 | } | ||
797 | 2851 | |||
798 | 2852 | if (!_steal_drag) | ||
799 | 2853 | { | ||
800 | 2854 | for (auto it : *_model) | ||
801 | 2855 | { | ||
802 | 2856 | if (it->QueryAcceptDrop(_dnd_data) != nux::DNDACTION_NONE) | ||
803 | 2857 | it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true); | ||
804 | 2858 | else | ||
805 | 2859 | it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true); | ||
806 | 2860 | } | ||
807 | 2861 | } | ||
808 | 2862 | } | ||
809 | 2863 | |||
810 | 2806 | void | 2864 | void |
811 | 2807 | Launcher::ProcessDndEnter() | 2865 | Launcher::ProcessDndEnter() |
812 | 2808 | { | 2866 | { |
814 | 2809 | _drag_data.clear(); | 2867 | _dnd_data.Reset(); |
815 | 2810 | _drag_action = nux::DNDACTION_NONE; | 2868 | _drag_action = nux::DNDACTION_NONE; |
816 | 2811 | _steal_drag = false; | 2869 | _steal_drag = false; |
817 | 2812 | _data_checked = false; | 2870 | _data_checked = false; |
818 | @@ -2815,35 +2873,32 @@ | |||
819 | 2815 | } | 2873 | } |
820 | 2816 | 2874 | ||
821 | 2817 | void | 2875 | void |
822 | 2876 | Launcher::DndLeave() | ||
823 | 2877 | { | ||
824 | 2878 | |||
825 | 2879 | _dnd_data.Reset(); | ||
826 | 2880 | |||
827 | 2881 | for (auto it : *_model) | ||
828 | 2882 | { | ||
829 | 2883 | it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, false); | ||
830 | 2884 | it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, false); | ||
831 | 2885 | } | ||
832 | 2886 | |||
833 | 2887 | ProcessDndLeave(); | ||
834 | 2888 | } | ||
835 | 2889 | |||
836 | 2890 | void | ||
837 | 2818 | Launcher::ProcessDndLeave() | 2891 | Launcher::ProcessDndLeave() |
838 | 2819 | { | 2892 | { |
839 | 2820 | SetStateMouseOverLauncher(false); | 2893 | SetStateMouseOverLauncher(false); |
840 | 2821 | _drag_edge_touching = false; | 2894 | _drag_edge_touching = false; |
841 | 2822 | 2895 | ||
842 | 2823 | SetActionState(ACTION_NONE); | 2896 | SetActionState(ACTION_NONE); |
861 | 2824 | 2897 | ||
844 | 2825 | if (!_drag_data.empty()) | ||
845 | 2826 | { | ||
846 | 2827 | std::list<char*>::iterator it; | ||
847 | 2828 | for (it = _drag_data.begin(); it != _drag_data.end(); it++) | ||
848 | 2829 | { | ||
849 | 2830 | g_free(*it); | ||
850 | 2831 | } | ||
851 | 2832 | } | ||
852 | 2833 | _drag_data.clear(); | ||
853 | 2834 | |||
854 | 2835 | LauncherModel::iterator it; | ||
855 | 2836 | for (it = _model->begin(); it != _model->end(); it++) | ||
856 | 2837 | { | ||
857 | 2838 | (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, false); | ||
858 | 2839 | (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, false); | ||
859 | 2840 | } | ||
860 | 2841 | |||
862 | 2842 | if (_steal_drag && _dnd_hovered_icon) | 2898 | if (_steal_drag && _dnd_hovered_icon) |
863 | 2843 | { | 2899 | { |
864 | 2844 | _dnd_hovered_icon->SetQuirk(LauncherIcon::QUIRK_VISIBLE, false); | 2900 | _dnd_hovered_icon->SetQuirk(LauncherIcon::QUIRK_VISIBLE, false); |
865 | 2845 | _dnd_hovered_icon->remove.emit(_dnd_hovered_icon); | 2901 | _dnd_hovered_icon->remove.emit(_dnd_hovered_icon); |
866 | 2846 | |||
867 | 2847 | } | 2902 | } |
868 | 2848 | 2903 | ||
869 | 2849 | if (!_steal_drag && _dnd_hovered_icon) | 2904 | if (!_steal_drag && _dnd_hovered_icon) |
870 | @@ -2854,58 +2909,33 @@ | |||
871 | 2854 | 2909 | ||
872 | 2855 | _steal_drag = false; | 2910 | _steal_drag = false; |
873 | 2856 | _dnd_hovered_icon = 0; | 2911 | _dnd_hovered_icon = 0; |
874 | 2857 | |||
875 | 2858 | } | ||
876 | 2859 | |||
877 | 2860 | std::list<char*> | ||
878 | 2861 | Launcher::StringToUriList(char* input) | ||
879 | 2862 | { | ||
880 | 2863 | std::list<char*> result; | ||
881 | 2864 | |||
882 | 2865 | if (!input) | ||
883 | 2866 | return result; | ||
884 | 2867 | |||
885 | 2868 | char** imtrappedinastringfactory = g_strsplit(input, "\r\n", -1); | ||
886 | 2869 | int i = 0; | ||
887 | 2870 | while (imtrappedinastringfactory[i]) // get kinda bored | ||
888 | 2871 | { | ||
889 | 2872 | // empty string check | ||
890 | 2873 | if (imtrappedinastringfactory[i][0]) | ||
891 | 2874 | result.push_back(g_strdup(imtrappedinastringfactory[i])); | ||
892 | 2875 | ++i; | ||
893 | 2876 | } | ||
894 | 2877 | |||
895 | 2878 | g_strfreev(imtrappedinastringfactory); | ||
896 | 2879 | |||
897 | 2880 | return result; | ||
898 | 2881 | } | 2912 | } |
899 | 2882 | 2913 | ||
900 | 2883 | void | 2914 | void |
901 | 2884 | Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) | 2915 | Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) |
902 | 2885 | { | 2916 | { |
903 | 2886 | std::list<char*>::iterator it; | ||
904 | 2887 | nux::Area* parent = GetToplevel(); | 2917 | nux::Area* parent = GetToplevel(); |
906 | 2888 | char* uri_list_const = g_strdup("text/uri-list"); | 2918 | unity::glib::String uri_list_const(g_strdup("text/uri-list")); |
907 | 2889 | 2919 | ||
908 | 2890 | if (!_data_checked) | 2920 | if (!_data_checked) |
909 | 2891 | { | 2921 | { |
910 | 2892 | _data_checked = true; | 2922 | _data_checked = true; |
912 | 2893 | _drag_data.clear(); | 2923 | _dnd_data.Reset(); |
913 | 2894 | 2924 | ||
914 | 2895 | // get the data | 2925 | // get the data |
918 | 2896 | for (it = mimes.begin(); it != mimes.end(); it++) | 2926 | for (auto it : mimes) |
919 | 2897 | { | 2927 | { |
920 | 2898 | if (!g_str_equal(*it, uri_list_const)) | 2928 | if (!g_str_equal(it, uri_list_const.Value())) |
921 | 2899 | continue; | 2929 | continue; |
922 | 2900 | 2930 | ||
924 | 2901 | _drag_data = StringToUriList(nux::GetWindow().GetDndData(uri_list_const)); | 2931 | _dnd_data.Fill(nux::GetWindow().GetDndData(uri_list_const.Value())); |
925 | 2902 | break; | 2932 | break; |
926 | 2903 | } | 2933 | } |
928 | 2904 | 2934 | ||
929 | 2905 | // see if the launcher wants this one | 2935 | // see if the launcher wants this one |
931 | 2906 | for (it = _drag_data.begin(); it != _drag_data.end(); it++) | 2936 | for (auto it : _dnd_data.Uris()) |
932 | 2907 | { | 2937 | { |
934 | 2908 | if (g_str_has_suffix(*it, ".desktop")) | 2938 | if (g_str_has_suffix(it.c_str(), ".desktop")) |
935 | 2909 | { | 2939 | { |
936 | 2910 | _steal_drag = true; | 2940 | _steal_drag = true; |
937 | 2911 | break; | 2941 | break; |
938 | @@ -2916,19 +2946,18 @@ | |||
939 | 2916 | SetActionState(ACTION_DRAG_EXTERNAL); | 2946 | SetActionState(ACTION_DRAG_EXTERNAL); |
940 | 2917 | SetStateMouseOverLauncher(true); | 2947 | SetStateMouseOverLauncher(true); |
941 | 2918 | 2948 | ||
944 | 2919 | LauncherModel::iterator it; | 2949 | if (!_steal_drag) |
943 | 2920 | for (it = _model->begin(); it != _model->end() && !_steal_drag; it++) | ||
945 | 2921 | { | 2950 | { |
950 | 2922 | if ((*it)->QueryAcceptDrop(_drag_data) != nux::DNDACTION_NONE && !_steal_drag) | 2951 | for (auto it : *_model) |
951 | 2923 | (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true); | 2952 | { |
952 | 2924 | else | 2953 | if (it->QueryAcceptDrop(_dnd_data) != nux::DNDACTION_NONE) |
953 | 2925 | (*it)->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true); | 2954 | it->SetQuirk(LauncherIcon::QUIRK_DROP_PRELIGHT, true); |
954 | 2955 | else | ||
955 | 2956 | it->SetQuirk(LauncherIcon::QUIRK_DROP_DIM, true); | ||
956 | 2957 | } | ||
957 | 2926 | } | 2958 | } |
958 | 2927 | |||
959 | 2928 | } | 2959 | } |
960 | 2929 | 2960 | ||
961 | 2930 | g_free(uri_list_const); | ||
962 | 2931 | |||
963 | 2932 | SetMousePosition(x - parent->GetGeometry().x, y - parent->GetGeometry().y); | 2961 | SetMousePosition(x - parent->GetGeometry().x, y - parent->GetGeometry().y); |
964 | 2933 | 2962 | ||
965 | 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) |
966 | @@ -2991,7 +3020,7 @@ | |||
967 | 2991 | if (hovered_icon) | 3020 | if (hovered_icon) |
968 | 2992 | { | 3021 | { |
969 | 2993 | hovered_icon->SendDndEnter(); | 3022 | hovered_icon->SendDndEnter(); |
971 | 2994 | _drag_action = hovered_icon->QueryAcceptDrop(_drag_data); | 3023 | _drag_action = hovered_icon->QueryAcceptDrop(_dnd_data); |
972 | 2995 | } | 3024 | } |
973 | 2996 | else | 3025 | else |
974 | 2997 | { | 3026 | { |
975 | @@ -3020,23 +3049,21 @@ | |||
976 | 3020 | if (_steal_drag) | 3049 | if (_steal_drag) |
977 | 3021 | { | 3050 | { |
978 | 3022 | char* path = 0; | 3051 | char* path = 0; |
979 | 3023 | std::list<char*>::iterator it; | ||
980 | 3024 | 3052 | ||
982 | 3025 | for (it = _drag_data.begin(); it != _drag_data.end(); it++) | 3053 | for (auto it : _dnd_data.Uris()) |
983 | 3026 | { | 3054 | { |
985 | 3027 | if (g_str_has_suffix(*it, ".desktop")) | 3055 | if (g_str_has_suffix(it.c_str(), ".desktop")) |
986 | 3028 | { | 3056 | { |
988 | 3029 | if (g_str_has_prefix(*it, "application://")) | 3057 | if (g_str_has_prefix(it.c_str(), "application://")) |
989 | 3030 | { | 3058 | { |
994 | 3031 | const char* tmp = *it + strlen("application://"); | 3059 | const char* tmp = it.c_str() + strlen("application://"); |
995 | 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)); |
996 | 3033 | path = g_filename_from_uri(tmp2, NULL, NULL); | 3061 | path = g_filename_from_uri(tmp2.Value(), NULL, NULL); |
993 | 3034 | g_free(tmp2); | ||
997 | 3035 | break; | 3062 | break; |
998 | 3036 | } | 3063 | } |
1000 | 3037 | else if (g_str_has_prefix(*it, "file://")) | 3064 | else if (g_str_has_prefix(it.c_str(), "file://")) |
1001 | 3038 | { | 3065 | { |
1003 | 3039 | path = g_filename_from_uri(*it, NULL, NULL); | 3066 | path = g_filename_from_uri(it.c_str(), NULL, NULL); |
1004 | 3040 | break; | 3067 | break; |
1005 | 3041 | } | 3068 | } |
1006 | 3042 | } | 3069 | } |
1007 | @@ -3050,7 +3077,7 @@ | |||
1008 | 3050 | } | 3077 | } |
1009 | 3051 | else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE) | 3078 | else if (_dnd_hovered_icon && _drag_action != nux::DNDACTION_NONE) |
1010 | 3052 | { | 3079 | { |
1012 | 3053 | _dnd_hovered_icon->AcceptDrop(_drag_data); | 3080 | _dnd_hovered_icon->AcceptDrop(_dnd_data); |
1013 | 3054 | } | 3081 | } |
1014 | 3055 | 3082 | ||
1015 | 3056 | if (_drag_action != nux::DNDACTION_NONE) | 3083 | if (_drag_action != nux::DNDACTION_NONE) |
1016 | @@ -3059,10 +3086,9 @@ | |||
1017 | 3059 | SendDndFinished(false, _drag_action); | 3086 | SendDndFinished(false, _drag_action); |
1018 | 3060 | 3087 | ||
1019 | 3061 | // reset our shiz | 3088 | // reset our shiz |
1021 | 3062 | ProcessDndLeave(); | 3089 | DndLeave(); |
1022 | 3063 | } | 3090 | } |
1023 | 3064 | 3091 | ||
1024 | 3065 | |||
1025 | 3066 | /* | 3092 | /* |
1026 | 3067 | * Returns the current selected icon if it is in keynavmode | 3093 | * Returns the current selected icon if it is in keynavmode |
1027 | 3068 | * It will return NULL if it is not on keynavmode | 3094 | * It will return NULL if it is not on keynavmode |
1028 | 3069 | 3095 | ||
1029 | === modified file 'plugins/unityshell/src/Launcher.h' | |||
1030 | --- plugins/unityshell/src/Launcher.h 2011-08-13 06:17:26 +0000 | |||
1031 | +++ plugins/unityshell/src/Launcher.h 2011-08-19 08:55:26 +0000 | |||
1032 | @@ -27,6 +27,10 @@ | |||
1033 | 27 | #include <Nux/View.h> | 27 | #include <Nux/View.h> |
1034 | 28 | #include <Nux/BaseWindow.h> | 28 | #include <Nux/BaseWindow.h> |
1035 | 29 | 29 | ||
1036 | 30 | #include "AbstractIconRenderer.h" | ||
1037 | 31 | #include "DNDCollectionWindow.h" | ||
1038 | 32 | #include "DndData.h" | ||
1039 | 33 | #include "GeisAdapter.h" | ||
1040 | 30 | #include "Introspectable.h" | 34 | #include "Introspectable.h" |
1041 | 31 | #include "LauncherIcon.h" | 35 | #include "LauncherIcon.h" |
1042 | 32 | #include "LauncherDragWindow.h" | 36 | #include "LauncherDragWindow.h" |
1043 | @@ -35,9 +39,6 @@ | |||
1044 | 35 | #include "NuxGraphics/IOpenGLAsmShader.h" | 39 | #include "NuxGraphics/IOpenGLAsmShader.h" |
1045 | 36 | #include "Nux/TimerProc.h" | 40 | #include "Nux/TimerProc.h" |
1046 | 37 | #include "PluginAdapter.h" | 41 | #include "PluginAdapter.h" |
1047 | 38 | #include "GeisAdapter.h" | ||
1048 | 39 | |||
1049 | 40 | #include "AbstractIconRenderer.h" | ||
1050 | 41 | 42 | ||
1051 | 42 | #define ANIM_DURATION_SHORT 125 | 43 | #define ANIM_DURATION_SHORT 125 |
1052 | 43 | #define ANIM_DURATION 200 | 44 | #define ANIM_DURATION 200 |
1053 | @@ -204,6 +205,7 @@ | |||
1054 | 204 | const gchar* GetName(); | 205 | const gchar* GetName(); |
1055 | 205 | void AddProperties(GVariantBuilder* builder); | 206 | void AddProperties(GVariantBuilder* builder); |
1056 | 206 | 207 | ||
1057 | 208 | void DndLeave(); | ||
1058 | 207 | void ProcessDndEnter(); | 209 | void ProcessDndEnter(); |
1059 | 208 | void ProcessDndLeave(); | 210 | void ProcessDndLeave(); |
1060 | 209 | void ProcessDndMove(int x, int y, std::list<char*> mimes); | 211 | void ProcessDndMove(int x, int y, std::list<char*> mimes); |
1061 | @@ -361,9 +363,9 @@ | |||
1062 | 361 | 363 | ||
1063 | 362 | gboolean TapOnSuper(); | 364 | gboolean TapOnSuper(); |
1064 | 363 | 365 | ||
1065 | 364 | std::list<char*> StringToUriList(char* input); | ||
1066 | 365 | |||
1067 | 366 | static void SettingsChanged(GSettings* settings, gchar* key, Launcher* self); | 366 | static void SettingsChanged(GSettings* settings, gchar* key, Launcher* self); |
1068 | 367 | |||
1069 | 368 | void OnDNDDataCollected(const std::list<char*>& mimes); | ||
1070 | 367 | 369 | ||
1071 | 368 | nux::HLayout* m_Layout; | 370 | nux::HLayout* m_Layout; |
1072 | 369 | int m_ContentOffsetY; | 371 | int m_ContentOffsetY; |
1073 | @@ -446,12 +448,14 @@ | |||
1074 | 446 | LauncherHoverMachine* _hover_machine; | 448 | LauncherHoverMachine* _hover_machine; |
1075 | 447 | CompScreen* _screen; | 449 | CompScreen* _screen; |
1076 | 448 | 450 | ||
1078 | 449 | std::list<char*> _drag_data; | 451 | unity::DndData _dnd_data; |
1079 | 450 | nux::DndAction _drag_action; | 452 | nux::DndAction _drag_action; |
1080 | 451 | bool _data_checked; | 453 | bool _data_checked; |
1081 | 452 | bool _steal_drag; | 454 | bool _steal_drag; |
1082 | 453 | bool _drag_edge_touching; | 455 | bool _drag_edge_touching; |
1083 | 454 | LauncherIcon* _dnd_hovered_icon; | 456 | LauncherIcon* _dnd_hovered_icon; |
1084 | 457 | unity::DNDCollectionWindow* _collection_window; | ||
1085 | 458 | sigc::connection _on_data_collected_connection; | ||
1086 | 455 | 459 | ||
1087 | 456 | Atom _selection_atom; | 460 | Atom _selection_atom; |
1088 | 457 | 461 | ||
1089 | @@ -489,5 +493,3 @@ | |||
1090 | 489 | }; | 493 | }; |
1091 | 490 | 494 | ||
1092 | 491 | #endif // LAUNCHER_H | 495 | #endif // LAUNCHER_H |
1093 | 492 | |||
1094 | 493 | |||
1095 | 494 | 496 | ||
1096 | === modified file 'plugins/unityshell/src/LauncherIcon.cpp' | |||
1097 | --- plugins/unityshell/src/LauncherIcon.cpp 2011-08-10 12:12:18 +0000 | |||
1098 | +++ plugins/unityshell/src/LauncherIcon.cpp 2011-08-19 08:55:26 +0000 | |||
1099 | @@ -804,10 +804,10 @@ | |||
1100 | 804 | { | 804 | { |
1101 | 805 | if (_quirks[quirk] == value) | 805 | if (_quirks[quirk] == value) |
1102 | 806 | return; | 806 | return; |
1104 | 807 | 807 | ||
1105 | 808 | if (quirk == QUIRK_PULSE_ONCE) | 808 | if (quirk == QUIRK_PULSE_ONCE) |
1106 | 809 | _launcher->HideMachine()->SetQuirk(LauncherHideMachine::LAUNCHER_PULSE, value); | 809 | _launcher->HideMachine()->SetQuirk(LauncherHideMachine::LAUNCHER_PULSE, value); |
1108 | 810 | 810 | ||
1109 | 811 | _quirks[quirk] = value; | 811 | _quirks[quirk] = value; |
1110 | 812 | if (quirk == QUIRK_VISIBLE) | 812 | if (quirk == QUIRK_VISIBLE) |
1111 | 813 | Launcher::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT); | 813 | Launcher::SetTimeStruct(&(_quirk_times[quirk]), &(_quirk_times[quirk]), ANIM_DURATION_SHORT); |
1112 | 814 | 814 | ||
1113 | === modified file 'plugins/unityshell/src/LauncherIcon.h' | |||
1114 | --- plugins/unityshell/src/LauncherIcon.h 2011-08-07 23:19:44 +0000 | |||
1115 | +++ plugins/unityshell/src/LauncherIcon.h 2011-08-19 08:55:26 +0000 | |||
1116 | @@ -21,6 +21,9 @@ | |||
1117 | 21 | #ifndef LAUNCHERICON_H | 21 | #ifndef LAUNCHERICON_H |
1118 | 22 | #define LAUNCHERICON_H | 22 | #define LAUNCHERICON_H |
1119 | 23 | 23 | ||
1120 | 24 | #include <set> | ||
1121 | 25 | #include <string> | ||
1122 | 26 | |||
1123 | 24 | #include <Nux/Nux.h> | 27 | #include <Nux/Nux.h> |
1124 | 25 | #include <Nux/BaseWindow.h> | 28 | #include <Nux/BaseWindow.h> |
1125 | 26 | #include <NuxCore/Math/MathInc.h> | 29 | #include <NuxCore/Math/MathInc.h> |
1126 | @@ -43,7 +46,6 @@ | |||
1127 | 43 | 46 | ||
1128 | 44 | class Launcher; | 47 | class Launcher; |
1129 | 45 | 48 | ||
1130 | 46 | |||
1131 | 47 | class LauncherIcon : public AbstractLauncherIcon, public unity::Introspectable, public nux::InitiallyUnownedObject | 49 | class LauncherIcon : public AbstractLauncherIcon, public unity::Introspectable, public nux::InitiallyUnownedObject |
1132 | 48 | { | 50 | { |
1133 | 49 | NUX_DECLARE_OBJECT_TYPE(LauncherIcon, nux::InitiallyUnownedObject); | 51 | NUX_DECLARE_OBJECT_TYPE(LauncherIcon, nux::InitiallyUnownedObject); |
1134 | @@ -150,14 +152,14 @@ | |||
1135 | 150 | 152 | ||
1136 | 151 | void RemoveEntryRemote(LauncherEntryRemote* remote); | 153 | void RemoveEntryRemote(LauncherEntryRemote* remote); |
1137 | 152 | 154 | ||
1139 | 153 | nux::DndAction QueryAcceptDrop(std::list<char*> paths) | 155 | nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data) |
1140 | 154 | { | 156 | { |
1142 | 155 | return OnQueryAcceptDrop(paths); | 157 | return OnQueryAcceptDrop(dnd_data); |
1143 | 156 | } | 158 | } |
1144 | 157 | 159 | ||
1146 | 158 | void AcceptDrop(std::list<char*> paths) | 160 | void AcceptDrop(unity::DndData& dnd_data) |
1147 | 159 | { | 161 | { |
1149 | 160 | return OnAcceptDrop(paths); | 162 | return OnAcceptDrop(dnd_data); |
1150 | 161 | } | 163 | } |
1151 | 162 | 164 | ||
1152 | 163 | void SendDndEnter() | 165 | void SendDndEnter() |
1153 | @@ -221,12 +223,12 @@ | |||
1154 | 221 | return 0; | 223 | return 0; |
1155 | 222 | } | 224 | } |
1156 | 223 | 225 | ||
1158 | 224 | virtual nux::DndAction OnQueryAcceptDrop(std::list<char*> files) | 226 | virtual nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data) |
1159 | 225 | { | 227 | { |
1160 | 226 | return nux::DNDACTION_NONE; | 228 | return nux::DNDACTION_NONE; |
1161 | 227 | } | 229 | } |
1162 | 228 | 230 | ||
1164 | 229 | virtual void OnAcceptDrop(std::list<char*> files) {} | 231 | virtual void OnAcceptDrop(unity::DndData& dnd_data) {} |
1165 | 230 | 232 | ||
1166 | 231 | virtual void OnDndEnter() {} | 233 | virtual void OnDndEnter() {} |
1167 | 232 | 234 | ||
1168 | @@ -327,7 +329,7 @@ | |||
1169 | 327 | 329 | ||
1170 | 328 | std::list<LauncherEntryRemote*> _entry_list; | 330 | std::list<LauncherEntryRemote*> _entry_list; |
1171 | 329 | std::map<std::string, std::vector<nux::Vector4> > transform_map; | 331 | std::map<std::string, std::vector<nux::Vector4> > transform_map; |
1173 | 330 | 332 | ||
1174 | 331 | }; | 333 | }; |
1175 | 332 | 334 | ||
1176 | 333 | #endif // LAUNCHERICON_H | 335 | #endif // LAUNCHERICON_H |
1177 | 334 | 336 | ||
1178 | === modified file 'plugins/unityshell/src/MockLauncherIcon.h' | |||
1179 | --- plugins/unityshell/src/MockLauncherIcon.h 2011-08-04 20:19:46 +0000 | |||
1180 | +++ plugins/unityshell/src/MockLauncherIcon.h 2011-08-19 08:55:26 +0000 | |||
1181 | @@ -179,12 +179,12 @@ | |||
1182 | 179 | return std::list<DbusmenuMenuitem*> (); | 179 | return std::list<DbusmenuMenuitem*> (); |
1183 | 180 | } | 180 | } |
1184 | 181 | 181 | ||
1186 | 182 | nux::DndAction QueryAcceptDrop(std::list<char*> paths) | 182 | nux::DndAction QueryAcceptDrop(unity::DndData& dnd_data) |
1187 | 183 | { | 183 | { |
1188 | 184 | return nux::DNDACTION_NONE; | 184 | return nux::DNDACTION_NONE; |
1189 | 185 | } | 185 | } |
1190 | 186 | 186 | ||
1192 | 187 | void AcceptDrop(std::list<char*> paths) {} | 187 | void AcceptDrop(unity::DndData& dnd_data) {} |
1193 | 188 | 188 | ||
1194 | 189 | void SendDndEnter() {} | 189 | void SendDndEnter() {} |
1195 | 190 | 190 | ||
1196 | 191 | 191 | ||
1197 | === modified file 'plugins/unityshell/src/TrashLauncherIcon.cpp' | |||
1198 | --- plugins/unityshell/src/TrashLauncherIcon.cpp 2011-07-30 09:00:43 +0000 | |||
1199 | +++ plugins/unityshell/src/TrashLauncherIcon.cpp 2011-08-19 08:55:26 +0000 | |||
1200 | @@ -18,15 +18,17 @@ | |||
1201 | 18 | */ | 18 | */ |
1202 | 19 | 19 | ||
1203 | 20 | #include "TrashLauncherIcon.h" | 20 | #include "TrashLauncherIcon.h" |
1204 | 21 | |||
1205 | 22 | #include <Nux/WindowCompositor.h> | ||
1206 | 23 | |||
1207 | 24 | #include <gio/gio.h> | ||
1208 | 25 | #include <glib/gi18n-lib.h> | ||
1209 | 26 | #include <gconf/gconf-client.h> | ||
1210 | 27 | |||
1211 | 21 | #include "Launcher.h" | 28 | #include "Launcher.h" |
1212 | 22 | #include "Nux/WindowCompositor.h" | ||
1213 | 23 | |||
1214 | 24 | #include "QuicklistManager.h" | 29 | #include "QuicklistManager.h" |
1215 | 25 | #include "QuicklistMenuItemLabel.h" | 30 | #include "QuicklistMenuItemLabel.h" |
1216 | 26 | 31 | ||
1217 | 27 | #include <gio/gio.h> | ||
1218 | 28 | #include <glib/gi18n-lib.h> | ||
1219 | 29 | #include <gconf/gconf-client.h> | ||
1220 | 30 | 32 | ||
1221 | 31 | #define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash" | 33 | #define ASK_CONFIRMATION_KEY "/apps/nautilus/preferences/confirm_trash" |
1222 | 32 | 34 | ||
1223 | @@ -277,19 +279,17 @@ | |||
1224 | 277 | } | 279 | } |
1225 | 278 | 280 | ||
1226 | 279 | nux::DndAction | 281 | nux::DndAction |
1228 | 280 | TrashLauncherIcon::OnQueryAcceptDrop(std::list<char*> uris) | 282 | TrashLauncherIcon::OnQueryAcceptDrop(unity::DndData& dnd_data) |
1229 | 281 | { | 283 | { |
1230 | 282 | return nux::DNDACTION_MOVE; | 284 | return nux::DNDACTION_MOVE; |
1231 | 283 | } | 285 | } |
1232 | 284 | 286 | ||
1233 | 285 | void | 287 | void |
1235 | 286 | TrashLauncherIcon::OnAcceptDrop(std::list<char*> uris) | 288 | TrashLauncherIcon::OnAcceptDrop(unity::DndData& dnd_data) |
1236 | 287 | { | 289 | { |
1240 | 288 | std::list<char*>::iterator it; | 290 | for (auto it : dnd_data.Uris()) |
1238 | 289 | |||
1239 | 290 | for (it = uris.begin(); it != uris.end(); it++) | ||
1241 | 291 | { | 291 | { |
1243 | 292 | GFile* file = g_file_new_for_uri(*it); | 292 | GFile* file = g_file_new_for_uri(it.c_str()); |
1244 | 293 | g_file_trash(file, NULL, NULL); | 293 | g_file_trash(file, NULL, NULL); |
1245 | 294 | g_object_unref(file); | 294 | g_object_unref(file); |
1246 | 295 | } | 295 | } |
1247 | 296 | 296 | ||
1248 | === modified file 'plugins/unityshell/src/TrashLauncherIcon.h' | |||
1249 | --- plugins/unityshell/src/TrashLauncherIcon.h 2011-07-21 14:59:25 +0000 | |||
1250 | +++ plugins/unityshell/src/TrashLauncherIcon.h 2011-08-19 08:55:26 +0000 | |||
1251 | @@ -20,6 +20,7 @@ | |||
1252 | 20 | #ifndef TRASHLAUNCHERICON_H | 20 | #ifndef TRASHLAUNCHERICON_H |
1253 | 21 | #define TRASHLAUNCHERICON_H | 21 | #define TRASHLAUNCHERICON_H |
1254 | 22 | 22 | ||
1255 | 23 | #include "DndData.h" | ||
1256 | 23 | #include "SimpleLauncherIcon.h" | 24 | #include "SimpleLauncherIcon.h" |
1257 | 24 | 25 | ||
1258 | 25 | class TrashLauncherIcon : public SimpleLauncherIcon | 26 | class TrashLauncherIcon : public SimpleLauncherIcon |
1259 | @@ -35,8 +36,8 @@ | |||
1260 | 35 | protected: | 36 | protected: |
1261 | 36 | void UpdateTrashIcon(); | 37 | void UpdateTrashIcon(); |
1262 | 37 | 38 | ||
1265 | 38 | nux::DndAction OnQueryAcceptDrop(std::list<char*> uris); | 39 | nux::DndAction OnQueryAcceptDrop(unity::DndData& dnd_data); |
1266 | 39 | void OnAcceptDrop(std::list<char*> uris); | 40 | void OnAcceptDrop(unity::DndData& dnd_data); |
1267 | 40 | 41 | ||
1268 | 41 | private: | 42 | private: |
1269 | 42 | gulong _on_trash_changed_handler_id; | 43 | gulong _on_trash_changed_handler_id; |
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 :)