Merge lp:~unity-team/unity/various-fixes-2011-03-08 into lp:unity
- various-fixes-2011-03-08
- Merge into trunk
Proposed by
Neil J. Patel
Status: | Merged | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 941 | ||||||||||||||||||||
Proposed branch: | lp:~unity-team/unity/various-fixes-2011-03-08 | ||||||||||||||||||||
Merge into: | lp:unity | ||||||||||||||||||||
Diff against target: |
1185 lines (+411/-111) 30 files modified
src/PanelIndicatorObjectEntryView.cpp (+1/-1) src/PanelMenuView.cpp (+2/-1) src/PanelTray.cpp (+8/-3) src/Place.h (+11/-0) src/PlaceEntry.h (+8/-0) src/PlaceEntryHome.cpp (+11/-0) src/PlaceEntryHome.h (+8/-3) src/PlaceEntryRemote.cpp (+26/-1) src/PlaceEntryRemote.h (+7/-1) src/PlaceFactoryFile.cpp (+0/-4) src/PlaceLauncherIcon.cpp (+43/-13) src/PlaceLauncherIcon.h (+3/-0) src/PlaceRemote.cpp (+85/-4) src/PlaceRemote.h (+11/-0) src/PlacesController.cpp (+1/-1) src/PlacesController.h (+1/-1) src/PlacesGroupController.cpp (+73/-37) src/PlacesGroupController.h (+3/-0) src/PlacesHomeView.cpp (+5/-0) src/PlacesResultsController.cpp (+11/-0) src/PlacesResultsController.h (+2/-0) src/PlacesSearchBar.cpp (+7/-0) src/PlacesSearchBar.h (+2/-0) src/PlacesSettings.cpp (+1/-1) src/PlacesSimpleTile.cpp (+6/-15) src/PlacesSimpleTile.h (+1/-3) src/PlacesTile.cpp (+10/-8) src/PlacesTile.h (+4/-3) src/PlacesView.cpp (+52/-10) src/PlacesView.h (+8/-1) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~unity-team/unity/various-fixes-2011-03-08 | ||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Taoko (community) | Approve | ||
Review via email: mp+52725@code.launchpad.net |
Commit message
Description of the change
Attached bugs should be fixed.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/PanelIndicatorObjectEntryView.cpp' |
2 | --- src/PanelIndicatorObjectEntryView.cpp 2011-02-23 17:02:01 +0000 |
3 | +++ src/PanelIndicatorObjectEntryView.cpp 2011-03-09 19:59:40 +0000 |
4 | @@ -239,7 +239,7 @@ |
5 | textcol.GetRed (), |
6 | textcol.GetGreen (), |
7 | textcol.GetBlue (), |
8 | - _proxy->label_sensitive ? 1.0f : 0.0f); |
9 | + _proxy->label_sensitive ? 1.0f : 0.5f); |
10 | cairo_move_to (cr, x, (int)((height - text_height)/2)); |
11 | pango_cairo_show_layout (cr, layout); |
12 | cairo_stroke (cr); |
13 | |
14 | === modified file 'src/PanelMenuView.cpp' |
15 | --- src/PanelMenuView.cpp 2011-03-07 10:59:31 +0000 |
16 | +++ src/PanelMenuView.cpp 2011-03-09 19:59:40 +0000 |
17 | @@ -170,7 +170,8 @@ |
18 | ret = _panel_titlebar_grab_area->OnEvent (ievent, ret, ProcessEventInfo); |
19 | } |
20 | |
21 | - ret = _menu_layout->ProcessEvent (ievent, ret, ProcessEventInfo); |
22 | + if (!_is_own_window) |
23 | + ret = _menu_layout->ProcessEvent (ievent, ret, ProcessEventInfo); |
24 | |
25 | return ret; |
26 | } |
27 | |
28 | === modified file 'src/PanelTray.cpp' |
29 | --- src/PanelTray.cpp 2011-02-22 23:11:20 +0000 |
30 | +++ src/PanelTray.cpp 2011-03-09 19:59:40 +0000 |
31 | @@ -29,9 +29,10 @@ |
32 | _settings = g_settings_new (SETTINGS_NAME); |
33 | _whitelist = g_settings_get_strv (_settings, "systray-whitelist"); |
34 | |
35 | - _window = gtk_window_new (GTK_WINDOW_POPUP); |
36 | + _window = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
37 | gtk_window_set_type_hint (GTK_WINDOW (_window), GDK_WINDOW_TYPE_HINT_DOCK); |
38 | - //gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE); |
39 | + gtk_window_set_has_resize_grip (GTK_WINDOW (_window), FALSE); |
40 | + gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE); |
41 | gtk_window_set_skip_pager_hint (GTK_WINDOW (_window), TRUE); |
42 | gtk_window_set_skip_taskbar_hint (GTK_WINDOW (_window), TRUE); |
43 | gtk_window_resize (GTK_WINDOW (_window), 1, 24); |
44 | @@ -138,7 +139,11 @@ |
45 | g_idle_add ((GSourceFunc)IdleSync, self); |
46 | } |
47 | |
48 | - g_debug ("TrayChild %s: %s %s", na_tray_child_get_title (icon), res_name, res_class); |
49 | + g_debug ("TrayChild %s: %s %s %s", |
50 | + accept ? "Accepted" : "Rejected", |
51 | + na_tray_child_get_title (icon), |
52 | + res_name, |
53 | + res_class); |
54 | |
55 | g_free (res_name); |
56 | g_free (res_class); |
57 | |
58 | === modified file 'src/Place.h' |
59 | --- src/Place.h 2010-12-11 13:49:37 +0000 |
60 | +++ src/Place.h 2011-03-09 19:59:40 +0000 |
61 | @@ -23,9 +23,17 @@ |
62 | #include <vector> |
63 | #include <sigc++/signal.h> |
64 | #include <sigc++/trackable.h> |
65 | +#include <glib.h> |
66 | |
67 | #include "PlaceEntry.h" |
68 | |
69 | +enum ActivationResult |
70 | +{ |
71 | + FALLBACK = 0, |
72 | + SHOW_DASH, |
73 | + HIDE_DASH |
74 | +}; |
75 | + |
76 | class Place : public sigc::trackable |
77 | { |
78 | public: |
79 | @@ -34,9 +42,12 @@ |
80 | virtual std::vector<PlaceEntry *>& GetEntries () = 0; |
81 | virtual guint32 GetNEntries () = 0; |
82 | |
83 | + virtual void ActivateResult (const char *uri, const char *mimetype) = 0; |
84 | + |
85 | // Signals |
86 | sigc::signal<void, PlaceEntry *> entry_added; |
87 | sigc::signal<void, PlaceEntry *> entry_removed; |
88 | + sigc::signal<void, const char *, ActivationResult> result_activated; |
89 | |
90 | protected: |
91 | std::vector<PlaceEntry *> _entries; |
92 | |
93 | === modified file 'src/PlaceEntry.h' |
94 | --- src/PlaceEntry.h 2011-03-06 17:40:56 +0000 |
95 | +++ src/PlaceEntry.h 2011-03-09 19:59:40 +0000 |
96 | @@ -15,6 +15,7 @@ |
97 | * |
98 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
99 | */ |
100 | + |
101 | #ifndef PLACE_ENTRY_H |
102 | #define PLACE_ENTRY_H |
103 | |
104 | @@ -26,6 +27,8 @@ |
105 | |
106 | #include <glib.h> |
107 | |
108 | +class Place; |
109 | + |
110 | class PlaceEntrySection |
111 | { |
112 | public: |
113 | @@ -74,6 +77,8 @@ |
114 | typedef sigc::slot<void, PlaceEntry *, PlaceEntryGroup&> GroupForeachCallback; |
115 | typedef sigc::slot<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> ResultForeachCallback; |
116 | |
117 | + virtual Place * GetParent () = 0; |
118 | + |
119 | virtual const char * GetId () = 0; |
120 | virtual const char * GetName () = 0; |
121 | virtual const char * GetIcon () = 0; |
122 | @@ -119,6 +124,9 @@ |
123 | virtual void GetResult (const void *id, ResultForeachCallback slot) = 0; |
124 | virtual void GetGlobalResult (const void *id, ResultForeachCallback slot) = 0; |
125 | |
126 | + virtual void ActivateResult (const void *id) = 0; |
127 | + virtual void ActivateGlobalResult (const void *id) = 0; |
128 | + |
129 | // Signals |
130 | |
131 | sigc::signal<void, bool> active_changed; |
132 | |
133 | === modified file 'src/PlaceEntryHome.cpp' |
134 | --- src/PlaceEntryHome.cpp 2011-03-06 17:51:59 +0000 |
135 | +++ src/PlaceEntryHome.cpp 2011-03-09 19:59:40 +0000 |
136 | @@ -281,3 +281,14 @@ |
137 | entry->GetGlobalResult (id, sigc::mem_fun (this, &PlaceEntryHome::OnForeachResult)); |
138 | } |
139 | } |
140 | + |
141 | +void |
142 | +PlaceEntryHome::ActivateResult (const void *id) |
143 | +{ |
144 | + PlaceEntry *entry = _id_to_entry[id]; |
145 | + |
146 | + if (entry) |
147 | + { |
148 | + entry->ActivateGlobalResult (id); |
149 | + } |
150 | +} |
151 | |
152 | === modified file 'src/PlaceEntryHome.h' |
153 | --- src/PlaceEntryHome.h 2011-03-06 17:51:59 +0000 |
154 | +++ src/PlaceEntryHome.h 2011-03-09 19:59:40 +0000 |
155 | @@ -37,6 +37,8 @@ |
156 | ~PlaceEntryHome (); |
157 | |
158 | /* Overrides */ |
159 | + Place * GetParent () { return NULL; } |
160 | + |
161 | const gchar * GetId (); |
162 | const gchar * GetName (); |
163 | const gchar * GetIcon (); |
164 | @@ -58,17 +60,20 @@ |
165 | void SetActiveSection (guint32 section_id); |
166 | void SetGlobalSearch (const gchar *search, std::map<gchar*, gchar*>& hints); |
167 | |
168 | - void ForeachSection (SectionForeachCallback slot) { }; |
169 | + void ForeachSection (SectionForeachCallback slot) {}; |
170 | |
171 | void ForeachGroup (GroupForeachCallback slot); |
172 | void ForeachResult (ResultForeachCallback slot); |
173 | |
174 | - void ForeachGlobalGroup (GroupForeachCallback slot) { }; |
175 | - void ForeachGlobalResult (ResultForeachCallback slot) { }; |
176 | + void ForeachGlobalGroup (GroupForeachCallback slot) {}; |
177 | + void ForeachGlobalResult (ResultForeachCallback slot) {}; |
178 | |
179 | void GetResult (const void *id, ResultForeachCallback slot); |
180 | void GetGlobalResult (const void *id, ResultForeachCallback slot) {}; |
181 | |
182 | + void ActivateResult (const void *id); |
183 | + void ActivateGlobalResult (const void *id) {}; |
184 | + |
185 | private: |
186 | void LoadExistingEntries (); |
187 | void OnPlaceAdded (Place *place); |
188 | |
189 | === modified file 'src/PlaceEntryRemote.cpp' |
190 | --- src/PlaceEntryRemote.cpp 2011-03-06 17:40:56 +0000 |
191 | +++ src/PlaceEntryRemote.cpp 2011-03-09 19:59:40 +0000 |
192 | @@ -180,8 +180,9 @@ |
193 | }; |
194 | |
195 | |
196 | -PlaceEntryRemote::PlaceEntryRemote (const gchar *dbus_name) |
197 | +PlaceEntryRemote::PlaceEntryRemote (Place *parent, const gchar *dbus_name) |
198 | : dirty (false), |
199 | + _parent (parent), |
200 | _dbus_path (NULL), |
201 | _name (NULL), |
202 | _icon (NULL), |
203 | @@ -303,6 +304,12 @@ |
204 | } |
205 | |
206 | /* Overrides */ |
207 | +Place * |
208 | +PlaceEntryRemote::GetParent () |
209 | +{ |
210 | + return _parent; |
211 | +} |
212 | + |
213 | const gchar * |
214 | PlaceEntryRemote::GetId () |
215 | { |
216 | @@ -627,6 +634,24 @@ |
217 | slot (this, group, result); |
218 | } |
219 | |
220 | +void |
221 | +PlaceEntryRemote::ActivateResult (const void *id) |
222 | +{ |
223 | + DeeModelIter *iter = (DeeModelIter *)id; |
224 | + |
225 | + _parent->ActivateResult (dee_model_get_string (_results_model, iter, RESULT_URI), |
226 | + dee_model_get_string (_results_model, iter, RESULT_MIMETYPE)); |
227 | +} |
228 | + |
229 | +void |
230 | +PlaceEntryRemote::ActivateGlobalResult (const void *id) |
231 | +{ |
232 | + DeeModelIter *iter = (DeeModelIter *)id; |
233 | + |
234 | + _parent->ActivateResult (dee_model_get_string (_global_results_model, iter, RESULT_URI), |
235 | + dee_model_get_string (_global_results_model, iter, RESULT_MIMETYPE)); |
236 | +} |
237 | + |
238 | /* Other methods */ |
239 | bool |
240 | PlaceEntryRemote::IsValid () |
241 | |
242 | === modified file 'src/PlaceEntryRemote.h' |
243 | --- src/PlaceEntryRemote.h 2011-03-06 17:40:56 +0000 |
244 | +++ src/PlaceEntryRemote.h 2011-03-09 19:59:40 +0000 |
245 | @@ -35,12 +35,14 @@ |
246 | class PlaceEntryRemote : public PlaceEntry |
247 | { |
248 | public: |
249 | - PlaceEntryRemote (const gchar *dbus_name); |
250 | + PlaceEntryRemote (Place *parent, const gchar *dbus_name); |
251 | ~PlaceEntryRemote (); |
252 | |
253 | void InitFromKeyFile (GKeyFile *key_file, const gchar *group); |
254 | |
255 | /* Overrides */ |
256 | + Place * GetParent (); |
257 | + |
258 | const gchar * GetId (); |
259 | const gchar * GetName (); |
260 | const gchar * GetIcon (); |
261 | @@ -73,6 +75,9 @@ |
262 | void GetResult (const void *id, ResultForeachCallback slot); |
263 | void GetGlobalResult (const void *id, ResultForeachCallback slot); |
264 | |
265 | + void ActivateResult (const void *id); |
266 | + void ActivateGlobalResult (const void *id); |
267 | + |
268 | /* Other methods */ |
269 | bool IsValid (); |
270 | const gchar * GetPath (); |
271 | @@ -110,6 +115,7 @@ |
272 | bool dirty; |
273 | |
274 | private: |
275 | + Place *_parent; |
276 | gchar *_dbus_name; |
277 | gchar *_dbus_path; |
278 | gchar *_name; |
279 | |
280 | === modified file 'src/PlaceFactoryFile.cpp' |
281 | --- src/PlaceFactoryFile.cpp 2011-02-21 17:48:29 +0000 |
282 | +++ src/PlaceFactoryFile.cpp 2011-03-09 19:59:40 +0000 |
283 | @@ -27,10 +27,6 @@ |
284 | |
285 | PlaceFactoryFile::PlaceFactoryFile (const char *directory) |
286 | { |
287 | - //FIXME: This is a temporary Alpha 2 fix |
288 | - g_spawn_command_line_sync ("killall unity-files-daemon", NULL, NULL, NULL, NULL); |
289 | - g_spawn_command_line_sync ("killall unity-applications-daemon", NULL, NULL, NULL, NULL); |
290 | - |
291 | /* Use the default lookup location */ |
292 | if (directory == NULL) |
293 | _directory = g_build_filename (DATADIR, "unity", "places", NULL); |
294 | |
295 | === modified file 'src/PlaceLauncherIcon.cpp' |
296 | --- src/PlaceLauncherIcon.cpp 2011-02-22 13:46:36 +0000 |
297 | +++ src/PlaceLauncherIcon.cpp 2011-03-09 19:59:40 +0000 |
298 | @@ -26,6 +26,8 @@ |
299 | |
300 | #include <glib/gi18n-lib.h> |
301 | |
302 | +#define SECTION_NUMBER "ted-loves-strings" |
303 | + |
304 | PlaceLauncherIcon::PlaceLauncherIcon (Launcher *launcher, PlaceEntry *entry) |
305 | : SimpleLauncherIcon(launcher), |
306 | _entry (entry) |
307 | @@ -87,24 +89,52 @@ |
308 | |
309 | } |
310 | |
311 | +void |
312 | +PlaceLauncherIcon::ForeachSectionCallback (PlaceEntry *entry, PlaceEntrySection& section) |
313 | +{ |
314 | + DbusmenuMenuitem *menu_item; |
315 | + char *temp; |
316 | + |
317 | + temp = g_markup_escape_text (section.GetName (), -1); |
318 | + menu_item = dbusmenu_menuitem_new (); |
319 | + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, section.GetName ()); |
320 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
321 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
322 | + dbusmenu_menuitem_property_set_int (menu_item, SECTION_NUMBER, _current_menu.size ()); |
323 | + _current_menu.push_back (menu_item); |
324 | + g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
325 | + G_CALLBACK (&PlaceLauncherIcon::OnOpen), this); |
326 | + g_free (temp); |
327 | +} |
328 | + |
329 | std::list<DbusmenuMenuitem *> |
330 | PlaceLauncherIcon::GetMenus () |
331 | { |
332 | - std::list<DbusmenuMenuitem *> result; |
333 | DbusmenuMenuitem *menu_item; |
334 | - |
335 | - menu_item = dbusmenu_menuitem_new (); |
336 | - |
337 | - dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, _("Open")); |
338 | - dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
339 | - dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
340 | - |
341 | + char * temp; |
342 | + |
343 | + _current_menu.erase (_current_menu.begin (), _current_menu.end ()); |
344 | + |
345 | + _entry->ForeachSection (sigc::mem_fun (this, &PlaceLauncherIcon::ForeachSectionCallback)); |
346 | + |
347 | + menu_item = dbusmenu_menuitem_new (); |
348 | + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); |
349 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
350 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
351 | + _current_menu.push_back (menu_item); |
352 | + |
353 | + temp = g_markup_escape_text (_entry->GetName (), -1); |
354 | + menu_item = dbusmenu_menuitem_new (); |
355 | + dbusmenu_menuitem_property_set (menu_item, DBUSMENU_MENUITEM_PROP_LABEL, temp); |
356 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true); |
357 | + dbusmenu_menuitem_property_set_bool (menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true); |
358 | + dbusmenu_menuitem_property_set_int (menu_item, SECTION_NUMBER, 0); |
359 | + _current_menu.push_back (menu_item); |
360 | g_signal_connect (menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, |
361 | G_CALLBACK (&PlaceLauncherIcon::OnOpen), this); |
362 | - |
363 | - result.push_back (menu_item); |
364 | - |
365 | - return result; |
366 | + g_free (temp); |
367 | + |
368 | + return _current_menu; |
369 | } |
370 | |
371 | void |
372 | @@ -121,7 +151,7 @@ |
373 | void |
374 | PlaceLauncherIcon::OnOpen (DbusmenuMenuitem *item, int time, PlaceLauncherIcon *self) |
375 | { |
376 | - self->ActivateLauncherIcon (); |
377 | + self->ActivatePlace (dbusmenu_menuitem_property_get_int (item, SECTION_NUMBER), ""); |
378 | } |
379 | |
380 | void |
381 | |
382 | === modified file 'src/PlaceLauncherIcon.h' |
383 | --- src/PlaceLauncherIcon.h 2011-02-22 13:46:36 +0000 |
384 | +++ src/PlaceLauncherIcon.h 2011-03-09 19:59:40 +0000 |
385 | @@ -44,10 +44,13 @@ |
386 | void ActivateLauncherIcon (); |
387 | void ActivatePlace (guint section_id, const char *search_string); |
388 | void OnActiveChanged (bool is_active); |
389 | + void ForeachSectionCallback (PlaceEntry *entry, PlaceEntrySection& section); |
390 | + |
391 | static void OnOpen (DbusmenuMenuitem *item, int time, PlaceLauncherIcon *self); |
392 | |
393 | private: |
394 | PlaceEntry *_entry; |
395 | + std::list<DbusmenuMenuitem *> _current_menu; |
396 | }; |
397 | |
398 | #endif // _PLACE_LAUNCHER_ICON_H__H |
399 | |
400 | === modified file 'src/PlaceRemote.cpp' |
401 | --- src/PlaceRemote.cpp 2011-01-19 22:52:54 +0000 |
402 | +++ src/PlaceRemote.cpp 2011-03-09 19:59:40 +0000 |
403 | @@ -32,6 +32,7 @@ |
404 | #define MIME_PATTERN "MimetypePattern" |
405 | |
406 | #define PLACE_IFACE "com.canonical.Unity.Place" |
407 | +#define ACTIVE_IFACE "com.canonical.Unity.Activation" |
408 | |
409 | static void on_service_proxy_ready (GObject *source, |
410 | GAsyncResult *result, |
411 | @@ -60,7 +61,6 @@ |
412 | GKeyFile *key_file; |
413 | GError *error = NULL; |
414 | |
415 | - g_debug ("Loading Place: %s", path); |
416 | _path = g_strdup (path); |
417 | |
418 | // A .place file is a keyfile, so we create on representing the .place file to |
419 | @@ -216,6 +216,17 @@ |
420 | NULL, |
421 | on_service_proxy_ready, |
422 | this); |
423 | + |
424 | + if (_uri_regex || _mime_regex) |
425 | + g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, |
426 | + G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, |
427 | + NULL, |
428 | + _dbus_name, |
429 | + _dbus_path, |
430 | + ACTIVE_IFACE, |
431 | + NULL, |
432 | + (GAsyncReadyCallback)PlaceRemote::OnActivationProxyReady, |
433 | + this); |
434 | } |
435 | |
436 | std::vector<PlaceEntry *>& |
437 | @@ -244,7 +255,7 @@ |
438 | |
439 | if (g_str_has_prefix (group, ENTRY_PREFIX)) |
440 | { |
441 | - PlaceEntryRemote *entry = new PlaceEntryRemote (_dbus_name); |
442 | + PlaceEntryRemote *entry = new PlaceEntryRemote (this, _dbus_name); |
443 | entry->InitFromKeyFile (key_file, group); |
444 | |
445 | if (entry->IsValid ()) |
446 | @@ -369,7 +380,7 @@ |
447 | |
448 | if (!existing) |
449 | { |
450 | - existing = new PlaceEntryRemote (_dbus_name); |
451 | + existing = new PlaceEntryRemote (this, _dbus_name); |
452 | |
453 | _entries.push_back (existing); |
454 | entry_added.emit (existing); |
455 | @@ -456,7 +467,7 @@ |
456 | &global_results_model, |
457 | &global_hints); |
458 | |
459 | - entry = new PlaceEntryRemote (_dbus_name); |
460 | + entry = new PlaceEntryRemote (this, _dbus_name); |
461 | entry->Update (dbus_path, |
462 | name, |
463 | icon, |
464 | @@ -512,6 +523,76 @@ |
465 | } |
466 | } |
467 | |
468 | +void |
469 | +PlaceRemote::OnActivationResultReceived (GObject *source, |
470 | + GAsyncResult *result, |
471 | + PlaceRemote *self) |
472 | +{ |
473 | + GVariant *args; |
474 | + GError *error = NULL; |
475 | + guint ret = 0; |
476 | + |
477 | + args = g_dbus_proxy_call_finish ((GDBusProxy *)source, result, &error); |
478 | + if (error) |
479 | + { |
480 | + g_warning ("Unable to call Activate() on: %s", |
481 | + error->message); |
482 | + g_error_free (error); |
483 | + return; |
484 | + } |
485 | + |
486 | + self->result_activated.emit (self->_active_uri.c_str (), (ActivationResult)ret); |
487 | + |
488 | + g_variant_unref (args); |
489 | +} |
490 | + |
491 | +void |
492 | +PlaceRemote::ActivateResult (const char *uri, const char *mimetype) |
493 | +{ |
494 | + if (G_IS_DBUS_PROXY (_activation_proxy) |
495 | + && ((_uri_regex && g_regex_match (_uri_regex, uri, (GRegexMatchFlags)0, NULL)) |
496 | + || (_mime_regex && g_regex_match (_mime_regex, mimetype, (GRegexMatchFlags)0, NULL)))) |
497 | + { |
498 | + _active_uri = uri; |
499 | + g_dbus_proxy_call (_activation_proxy, |
500 | + "Activate", |
501 | + g_variant_new ("(s)", uri), |
502 | + G_DBUS_CALL_FLAGS_NONE, |
503 | + -1, |
504 | + NULL, |
505 | + (GAsyncReadyCallback)OnActivationResultReceived, |
506 | + this); |
507 | + } |
508 | + else |
509 | + { |
510 | + result_activated.emit (uri, FALLBACK); |
511 | + } |
512 | +} |
513 | + |
514 | +void |
515 | +PlaceRemote::OnActivationProxyReady (GObject *source, |
516 | + GAsyncResult *result, |
517 | + PlaceRemote *self) |
518 | +{ |
519 | + GError *error = NULL; |
520 | + gchar *name_owner = NULL; |
521 | + |
522 | + self->_activation_proxy = g_dbus_proxy_new_for_bus_finish (result, &error); |
523 | + name_owner = g_dbus_proxy_get_name_owner (self->_activation_proxy); |
524 | + |
525 | + if (error || !name_owner) |
526 | + { |
527 | + g_warning ("Unable to connect to PlaceRemote Activation %s: %s", |
528 | + self->_dbus_name, |
529 | + error ? error->message : "No name owner"); |
530 | + if (error) |
531 | + g_error_free (error); |
532 | + } |
533 | + |
534 | + g_free (name_owner); |
535 | +} |
536 | + |
537 | + |
538 | /* |
539 | * C callbacks |
540 | */ |
541 | |
542 | === modified file 'src/PlaceRemote.h' |
543 | --- src/PlaceRemote.h 2010-12-12 19:55:40 +0000 |
544 | +++ src/PlaceRemote.h 2011-03-09 19:59:40 +0000 |
545 | @@ -49,10 +49,19 @@ |
546 | |
547 | const gchar * GetDBusName (); |
548 | |
549 | + void ActivateResult (const char *uri, const char *mimetype); |
550 | + |
551 | private: |
552 | void LoadKeyFileEntries (GKeyFile *key_file); |
553 | void Connect (); |
554 | |
555 | + static void OnActivationProxyReady (GObject *source, |
556 | + GAsyncResult *result, |
557 | + PlaceRemote *self); |
558 | + static void OnActivationResultReceived (GObject *source, |
559 | + GAsyncResult *result, |
560 | + PlaceRemote *self); |
561 | + |
562 | private: |
563 | char *_path; |
564 | char *_dbus_name; |
565 | @@ -63,6 +72,8 @@ |
566 | |
567 | GDBusProxy *_service_proxy; |
568 | GDBusProxy *_activation_proxy; |
569 | + |
570 | + std::string _active_uri; |
571 | }; |
572 | |
573 | #endif // PLACE_REMOTE_H |
574 | |
575 | === modified file 'src/PlacesController.cpp' |
576 | --- src/PlacesController.cpp 2011-03-04 15:01:07 +0000 |
577 | +++ src/PlacesController.cpp 2011-03-09 19:59:40 +0000 |
578 | @@ -47,7 +47,7 @@ |
579 | (UBusCallback)&PlacesController::CloseRequest, |
580 | this); |
581 | |
582 | - _factory = new PlaceFactoryFile (); |
583 | + _factory = PlaceFactory::GetDefault (); |
584 | |
585 | _window_layout = new nux::HLayout (); |
586 | |
587 | |
588 | === modified file 'src/PlacesController.h' |
589 | --- src/PlacesController.h 2011-03-09 15:04:54 +0000 |
590 | +++ src/PlacesController.h 2011-03-09 19:59:40 +0000 |
591 | @@ -63,7 +63,7 @@ |
592 | nux::BaseWindow *_window; |
593 | nux::HLayout *_window_layout; |
594 | PlacesView *_view; |
595 | - PlaceFactoryFile *_factory; |
596 | + PlaceFactory *_factory; |
597 | bool _visible; |
598 | bool _fullscren_request; |
599 | static int _launcher_size; |
600 | |
601 | === modified file 'src/PlacesGroupController.cpp' |
602 | --- src/PlacesGroupController.cpp 2011-03-06 17:40:56 +0000 |
603 | +++ src/PlacesGroupController.cpp 2011-03-09 19:59:40 +0000 |
604 | @@ -91,9 +91,12 @@ |
605 | |
606 | tile = new PlacesSimpleTile (result_icon, |
607 | result_name, |
608 | - style->GetTileIconSize ()); |
609 | + style->GetTileIconSize (), |
610 | + false, |
611 | + result.GetId ()); |
612 | tile->SetURI (result.GetURI ()); |
613 | tile->QueueRelayout (); |
614 | + tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::TileClicked)); |
615 | |
616 | _id_to_tile[result.GetId ()] = tile; |
617 | |
618 | @@ -105,21 +108,28 @@ |
619 | } |
620 | |
621 | void |
622 | +PlacesGroupController::TileClicked (PlacesTile *tile) |
623 | +{ |
624 | + if (_entry) |
625 | + { |
626 | + _entry->ActivateResult (tile->GetId ()); |
627 | + } |
628 | +} |
629 | + |
630 | +void |
631 | PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result) |
632 | { |
633 | PlacesStyle *style = PlacesStyle::GetDefault (); |
634 | |
635 | - if (!_group->GetExpanded () |
636 | - && _id_to_tile.size () >= (guint)style->GetDefaultNColumns ()) |
637 | - { |
638 | - _queue.push_back (result.GetId ()); |
639 | - } |
640 | - else |
641 | + _queue.push_back (result.GetId ()); |
642 | + |
643 | + if (_group->GetExpanded () |
644 | + || _id_to_tile.size () != (guint)style->GetDefaultNColumns ()) |
645 | { |
646 | AddTile (_entry, group, result); |
647 | } |
648 | |
649 | - _group->SetCounts (style->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ()); |
650 | + _group->SetCounts (style->GetDefaultNColumns (), _queue.size ()); |
651 | } |
652 | |
653 | void |
654 | @@ -134,19 +144,21 @@ |
655 | { |
656 | _queue.erase (it); |
657 | } |
658 | - else if ((tile = _id_to_tile[result.GetId ()])) |
659 | + |
660 | + if ((tile = _id_to_tile[result.GetId ()])) |
661 | { |
662 | - _id_to_tile.erase (result.GetId ()); |
663 | - |
664 | _group->GetChildLayout ()->RemoveChildObject (tile); |
665 | _group->Relayout (); |
666 | - _group->SetVisible (_id_to_tile.size ()); |
667 | } |
668 | + |
669 | + _id_to_tile.erase (result.GetId ()); |
670 | |
671 | if (!_check_tiles_id) |
672 | _check_tiles_id = g_timeout_add (0, (GSourceFunc)CheckTilesTimeout, this); |
673 | - |
674 | - _group->SetCounts (PlacesStyle::GetDefault ()->GetDefaultNColumns (), _id_to_tile.size () + _queue.size ()); |
675 | + |
676 | + _group->SetVisible (_queue.size ()); |
677 | + _group->SetCounts (PlacesStyle::GetDefault ()->GetDefaultNColumns (), |
678 | + _queue.size ()); |
679 | } |
680 | |
681 | void |
682 | @@ -162,7 +174,7 @@ |
683 | guint n_to_show; |
684 | |
685 | if (_group->GetExpanded ()) |
686 | - n_to_show = _id_to_tile.size () + _queue.size (); |
687 | + n_to_show = _queue.size (); |
688 | else |
689 | n_to_show = style->GetDefaultNColumns (); |
690 | |
691 | @@ -172,30 +184,34 @@ |
692 | } |
693 | else if (_id_to_tile.size () < n_to_show) |
694 | { |
695 | - while (_id_to_tile.size () < n_to_show && _queue.size ()) |
696 | - { |
697 | - _entry->GetResult ((*_queue.begin ()), sigc::mem_fun (this, &PlacesGroupController::AddTile)); |
698 | - _queue.erase (_queue.begin ()); |
699 | - } |
700 | - } |
701 | - else // Remove some |
702 | - { |
703 | - while (_id_to_tile.size () != n_to_show) |
704 | - { |
705 | - std::map<const void *, PlacesTile *>::reverse_iterator it; |
706 | - |
707 | - it = _id_to_tile.rbegin (); |
708 | - |
709 | - if (it != _id_to_tile.rend ()) |
710 | + std::vector<const void *>::iterator it = _queue.begin (); |
711 | + |
712 | + if (_queue.size () >= n_to_show) |
713 | + { |
714 | + it += _id_to_tile.size (); |
715 | + |
716 | + while (_id_to_tile.size () < n_to_show && it != _queue.end ()) |
717 | { |
718 | - _group->GetChildLayout ()->RemoveChildObject ((*it).second); |
719 | + _entry->GetResult ((*it), sigc::mem_fun (this, &PlacesGroupController::AddTile)); |
720 | + it++; |
721 | } |
722 | - |
723 | - _queue.insert (_queue.begin (), (*it).first); |
724 | - _id_to_tile.erase ((*it).first); |
725 | - } |
726 | - } |
727 | - |
728 | + } |
729 | + } |
730 | + else // Remove some |
731 | + { |
732 | + std::vector<const void *>::iterator it, eit = _queue.end (); |
733 | + |
734 | + for (it = _queue.begin () + n_to_show; it != eit; ++it) |
735 | + { |
736 | + PlacesTile *tile = _id_to_tile[*it]; |
737 | + |
738 | + if (tile) |
739 | + _group->GetChildLayout ()->RemoveChildObject (tile); |
740 | + |
741 | + _id_to_tile.erase (*it); |
742 | + } |
743 | + |
744 | + } |
745 | _group->Relayout (); |
746 | } |
747 | |
748 | @@ -208,6 +224,26 @@ |
749 | return FALSE; |
750 | } |
751 | |
752 | +bool |
753 | +PlacesGroupController::ActivateFirst () |
754 | +{ |
755 | + std::vector<const void *>::iterator it = _queue.begin (); |
756 | + |
757 | + if (it != _queue.end ()) |
758 | + { |
759 | + PlacesTile *tile = _id_to_tile[*it]; |
760 | + |
761 | + if (tile) |
762 | + { |
763 | + nux::Geometry geo = tile->GetGeometry (); |
764 | + tile->OnMouseClick.emit (geo.x, geo.y, 0, 0); |
765 | + return true; |
766 | + } |
767 | + } |
768 | + |
769 | + return false; |
770 | +} |
771 | + |
772 | // |
773 | // Introspectable |
774 | // |
775 | |
776 | === modified file 'src/PlacesGroupController.h' |
777 | --- src/PlacesGroupController.h 2011-03-06 17:40:56 +0000 |
778 | +++ src/PlacesGroupController.h 2011-03-09 19:59:40 +0000 |
779 | @@ -41,6 +41,8 @@ |
780 | |
781 | void Clear (); |
782 | |
783 | + bool ActivateFirst (); |
784 | + |
785 | protected: |
786 | const gchar* GetName (); |
787 | void AddProperties (GVariantBuilder *builder); |
788 | @@ -49,6 +51,7 @@ |
789 | void AddTile (PlaceEntry *ignore, PlaceEntryGroup& group, PlaceEntryResult& result); |
790 | void CheckTiles (); |
791 | static gboolean CheckTilesTimeout (PlacesGroupController *self); |
792 | + void TileClicked (PlacesTile *tile); |
793 | |
794 | private: |
795 | PlaceEntry *_entry; |
796 | |
797 | === modified file 'src/PlacesHomeView.cpp' |
798 | --- src/PlacesHomeView.cpp 2011-02-28 12:58:19 +0000 |
799 | +++ src/PlacesHomeView.cpp 2011-03-09 19:59:40 +0000 |
800 | @@ -126,6 +126,8 @@ |
801 | NULL, NULL); |
802 | |
803 | Refresh (); |
804 | + |
805 | + expanded.connect (sigc::mem_fun (this, &PlacesHomeView::Refresh)); |
806 | } |
807 | |
808 | PlacesHomeView::~PlacesHomeView () |
809 | @@ -156,6 +158,9 @@ |
810 | |
811 | _layout->Clear (); |
812 | |
813 | + if (!GetExpanded ()) |
814 | + return; |
815 | + |
816 | // Find Media Apps |
817 | markup = g_strdup_printf (temp, _("Find Media Apps")); |
818 | shortcut = new Shortcut (PKGDATADIR"/find_media_apps.png", |
819 | |
820 | === modified file 'src/PlacesResultsController.cpp' |
821 | --- src/PlacesResultsController.cpp 2011-03-06 17:40:56 +0000 |
822 | +++ src/PlacesResultsController.cpp 2011-03-09 19:59:40 +0000 |
823 | @@ -103,6 +103,17 @@ |
824 | _results_view->Clear (); |
825 | } |
826 | |
827 | +bool |
828 | +PlacesResultsController::ActivateFirst () |
829 | +{ |
830 | + std::map <const void *, PlacesGroupController *>::iterator it, eit = _id_to_group.end (); |
831 | + |
832 | + for (it = _id_to_group.begin (); it != eit; ++it) |
833 | + if ((it->second)->ActivateFirst ()) |
834 | + return true; |
835 | + |
836 | + return false; |
837 | +} |
838 | |
839 | // |
840 | // Introspection |
841 | |
842 | === modified file 'src/PlacesResultsController.h' |
843 | --- src/PlacesResultsController.h 2011-03-06 17:40:56 +0000 |
844 | +++ src/PlacesResultsController.h 2011-03-09 19:59:40 +0000 |
845 | @@ -44,6 +44,8 @@ |
846 | // Clears all the current groups and results |
847 | void Clear (); |
848 | |
849 | + bool ActivateFirst (); |
850 | + |
851 | protected: |
852 | const gchar* GetName (); |
853 | void AddProperties (GVariantBuilder *builder); |
854 | |
855 | === modified file 'src/PlacesSearchBar.cpp' |
856 | --- src/PlacesSearchBar.cpp 2011-03-05 18:11:55 +0000 |
857 | +++ src/PlacesSearchBar.cpp 2011-03-09 19:59:40 +0000 |
858 | @@ -74,6 +74,7 @@ |
859 | |
860 | _pango_entry = new nux::TextEntry ("", NUX_TRACKER_LOCATION); |
861 | _pango_entry->sigTextChanged.connect (sigc::mem_fun (this, &PlacesSearchBar::OnSearchChanged)); |
862 | + _pango_entry->activated.connect (sigc::mem_fun (this, &PlacesSearchBar::OnEntryActivated)); |
863 | _layered_layout->AddLayer (_pango_entry); |
864 | |
865 | _layered_layout->SetPaintAll (true); |
866 | @@ -300,6 +301,12 @@ |
867 | } |
868 | |
869 | void |
870 | +PlacesSearchBar::OnEntryActivated () |
871 | +{ |
872 | + activated.emit (); |
873 | +} |
874 | + |
875 | +void |
876 | PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self) |
877 | { |
878 | #define HOW_LARGE 8 |
879 | |
880 | === modified file 'src/PlacesSearchBar.h' |
881 | --- src/PlacesSearchBar.h 2011-03-05 18:11:55 +0000 |
882 | +++ src/PlacesSearchBar.h 2011-03-09 19:59:40 +0000 |
883 | @@ -55,6 +55,7 @@ |
884 | const char *search_string); |
885 | |
886 | sigc::signal<void, const char *> search_changed; |
887 | + sigc::signal<void> activated; |
888 | |
889 | bool CanFocus (); |
890 | |
891 | @@ -72,6 +73,7 @@ |
892 | void OnSectionAdded (PlaceEntry *entry, PlaceEntrySection& section); |
893 | void OnComboChanged (nux::ComboBoxSimple *simple); |
894 | void OnMenuClosing (nux::MenuPage *menu, int x, int y); |
895 | + void OnEntryActivated (); |
896 | |
897 | static bool OnLiveSearchTimeout (PlacesSearchBar *self); |
898 | static void OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self); |
899 | |
900 | === modified file 'src/PlacesSettings.cpp' |
901 | --- src/PlacesSettings.cpp 2011-02-21 11:20:17 +0000 |
902 | +++ src/PlacesSettings.cpp 2011-03-09 19:59:40 +0000 |
903 | @@ -54,7 +54,7 @@ |
904 | primary_monitor = gdk_screen_get_primary_monitor (screen); |
905 | gdk_screen_get_monitor_geometry (screen, primary_monitor, &geo); |
906 | |
907 | - _form_factor = geo.height > 800 ? DESKTOP : NETBOOK; |
908 | + _form_factor = geo.height > 799 ? DESKTOP : NETBOOK; |
909 | } |
910 | else |
911 | { |
912 | |
913 | === modified file 'src/PlacesSimpleTile.cpp' |
914 | --- src/PlacesSimpleTile.cpp 2011-03-01 04:08:36 +0000 |
915 | +++ src/PlacesSimpleTile.cpp 2011-03-09 19:59:40 +0000 |
916 | @@ -26,8 +26,12 @@ |
917 | |
918 | #include "PlacesSimpleTile.h" |
919 | |
920 | -PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, int icon_size, bool defer_icon_loading) |
921 | -: PlacesTile (NUX_TRACKER_LOCATION), |
922 | +PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, |
923 | + const char *label, |
924 | + int icon_size, |
925 | + bool defer_icon_loading, |
926 | + const void *id) |
927 | +: PlacesTile (NUX_TRACKER_LOCATION, id), |
928 | _label (NULL), |
929 | _icon (NULL), |
930 | _uri (NULL) |
931 | @@ -58,8 +62,6 @@ |
932 | |
933 | SetLayout (layout); |
934 | |
935 | - OnMouseClick.connect (sigc::mem_fun (this, &PlacesSimpleTile::Clicked)); |
936 | - |
937 | SetDndEnabled (true, false); |
938 | } |
939 | |
940 | @@ -190,17 +192,6 @@ |
941 | } |
942 | |
943 | void |
944 | -PlacesSimpleTile::Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags) |
945 | -{ |
946 | - if (_uri) |
947 | - { |
948 | - ubus_server_send_message (ubus_server_get_default (), |
949 | - UBUS_PLACE_TILE_ACTIVATE_REQUEST, |
950 | - g_variant_new_string (_uri)); |
951 | - } |
952 | -} |
953 | - |
954 | -void |
955 | PlacesSimpleTile::LoadIcon () |
956 | { |
957 | _icontex->LoadIcon (); |
958 | |
959 | === modified file 'src/PlacesSimpleTile.h' |
960 | --- src/PlacesSimpleTile.h 2011-03-01 04:08:36 +0000 |
961 | +++ src/PlacesSimpleTile.h 2011-03-09 19:59:40 +0000 |
962 | @@ -31,7 +31,7 @@ |
963 | { |
964 | public: |
965 | |
966 | - PlacesSimpleTile (const char *icon, const char *label, int icon_size=64, bool defer_icon_loading=false); |
967 | + PlacesSimpleTile (const char *icon, const char *label, int icon_size=64, bool defer_icon_loading=false, const void *id=NULL); |
968 | ~PlacesSimpleTile (); |
969 | |
970 | const char * GetLabel (); |
971 | @@ -53,8 +53,6 @@ |
972 | virtual std::list<const char *> DndSourceGetDragTypes (); |
973 | virtual const char * DndSourceGetDataForType (const char *type, int *size, int *format); |
974 | virtual void DndSourceDragFinished (nux::DndAction result); |
975 | -private: |
976 | - void Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags); |
977 | |
978 | private: |
979 | nux::Geometry _highlight_geometry; |
980 | |
981 | === modified file 'src/PlacesTile.cpp' |
982 | --- src/PlacesTile.cpp 2011-02-28 22:19:04 +0000 |
983 | +++ src/PlacesTile.cpp 2011-03-09 19:59:40 +0000 |
984 | @@ -27,8 +27,9 @@ |
985 | |
986 | #define PADDING 8 |
987 | |
988 | -PlacesTile::PlacesTile (NUX_FILE_LINE_DECL) : |
989 | +PlacesTile::PlacesTile (NUX_FILE_LINE_DECL, const void *id) : |
990 | View (NUX_FILE_LINE_PARAM), |
991 | + _id (id), |
992 | _hilight_background (NULL), |
993 | _hilight_layer (NULL), |
994 | _last_width (0), |
995 | @@ -55,7 +56,14 @@ |
996 | delete _hilight_layer; |
997 | } |
998 | |
999 | -void PlacesTile::OnFocusChanged (nux::Area *area) |
1000 | +const void * |
1001 | +PlacesTile::GetId () |
1002 | +{ |
1003 | + return _id; |
1004 | +} |
1005 | + |
1006 | +void |
1007 | +PlacesTile::OnFocusChanged (nux::Area *area) |
1008 | { |
1009 | QueueDraw (); |
1010 | } |
1011 | @@ -341,9 +349,3 @@ |
1012 | { |
1013 | QueueDraw (); |
1014 | } |
1015 | - |
1016 | -void |
1017 | -PlacesTile::ActivateFocus () |
1018 | -{ |
1019 | - sigClick.emit (this); |
1020 | -} |
1021 | |
1022 | === modified file 'src/PlacesTile.h' |
1023 | --- src/PlacesTile.h 2011-02-28 16:27:57 +0000 |
1024 | +++ src/PlacesTile.h 2011-03-09 19:59:40 +0000 |
1025 | @@ -31,13 +31,13 @@ |
1026 | class PlacesTile : public nux::View |
1027 | { |
1028 | public: |
1029 | - PlacesTile (NUX_FILE_LINE_PROTO); |
1030 | + PlacesTile (NUX_FILE_LINE_PROTO, const void *id=NULL); |
1031 | ~PlacesTile (); |
1032 | |
1033 | + const void * GetId (); |
1034 | + |
1035 | sigc::signal<void, PlacesTile*> sigClick; |
1036 | |
1037 | - virtual void ActivateFocus (); |
1038 | - |
1039 | protected: |
1040 | virtual nux::Geometry GetHighlightGeometry (); |
1041 | |
1042 | @@ -64,6 +64,7 @@ |
1043 | void DrawHighlight (const char *texid, int width, int height, nux::BaseTexture **texture); |
1044 | |
1045 | private: |
1046 | + const void *_id; |
1047 | nux::BaseTexture *_hilight_background; |
1048 | nux::TextureLayer *_hilight_layer; |
1049 | |
1050 | |
1051 | === modified file 'src/PlacesView.cpp' |
1052 | --- src/PlacesView.cpp 2011-03-06 17:40:56 +0000 |
1053 | +++ src/PlacesView.cpp 2011-03-09 19:59:40 +0000 |
1054 | @@ -43,6 +43,9 @@ |
1055 | _entry (NULL), |
1056 | _size_mode (SIZE_MODE_FULLSCREEN) |
1057 | { |
1058 | + LoadPlaces (); |
1059 | + _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded)); |
1060 | + |
1061 | _home_entry = new PlaceEntryHome (_factory); |
1062 | |
1063 | _layout = new nux::HLayout (NUX_TRACKER_LOCATION); |
1064 | @@ -58,6 +61,7 @@ |
1065 | AddChild (_search_bar); |
1066 | |
1067 | _search_bar->search_changed.connect (sigc::mem_fun (this, &PlacesView::OnSearchChanged)); |
1068 | + _search_bar->activated.connect (sigc::mem_fun (this, &PlacesView::OnEntryActivated)); |
1069 | |
1070 | _layered_layout = new nux::LayeredLayout (NUX_TRACKER_LOCATION); |
1071 | vlayout->AddLayout (_layered_layout, 1, nux::eCenter, nux::eFull); |
1072 | @@ -96,7 +100,7 @@ |
1073 | (UBusCallback)&PlacesView::CloseRequest, |
1074 | this); |
1075 | ubus_server_register_interest (ubus, UBUS_PLACE_TILE_ACTIVATE_REQUEST, |
1076 | - (UBusCallback)&PlacesView::OnResultClicked, |
1077 | + (UBusCallback)&PlacesView::OnResultActivated, |
1078 | this); |
1079 | ubus_server_register_interest (ubus, UBUS_PLACE_VIEW_QUEUE_DRAW, |
1080 | (UBusCallback)&PlacesView::OnPlaceViewQueueDrawNeeded, |
1081 | @@ -378,25 +382,17 @@ |
1082 | void |
1083 | PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result) |
1084 | { |
1085 | - //FIXME: We can't do anything with these do just ignore |
1086 | - if (g_str_has_prefix (result.GetURI (), "unity-install")) |
1087 | - return; |
1088 | - |
1089 | _results_controller->AddResult (entry, group, result); |
1090 | } |
1091 | |
1092 | void |
1093 | PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result) |
1094 | { |
1095 | - //FIXME: We can't do anything with these do just ignore |
1096 | - if (g_str_has_prefix (result.GetURI (), "unity-install")) |
1097 | - return; |
1098 | - |
1099 | _results_controller->RemoveResult (entry, group, result); |
1100 | } |
1101 | |
1102 | void |
1103 | -PlacesView::OnResultClicked (GVariant *data, PlacesView *self) |
1104 | +PlacesView::OnResultActivated (GVariant *data, PlacesView *self) |
1105 | { |
1106 | const char *uri; |
1107 | |
1108 | @@ -527,6 +523,52 @@ |
1109 | self->QueueDraw (); |
1110 | } |
1111 | |
1112 | +void |
1113 | +PlacesView::OnEntryActivated () |
1114 | +{ |
1115 | + if (!_results_controller->ActivateFirst ()) |
1116 | + g_debug ("Cannot activate anything"); |
1117 | +} |
1118 | + |
1119 | +void |
1120 | +PlacesView::LoadPlaces () |
1121 | +{ |
1122 | + std::vector<Place *>::iterator it, eit = _factory->GetPlaces ().end (); |
1123 | + |
1124 | + for (it = _factory->GetPlaces ().begin (); it != eit; ++it) |
1125 | + { |
1126 | + OnPlaceAdded (*it); |
1127 | + } |
1128 | +} |
1129 | + |
1130 | +void |
1131 | +PlacesView::OnPlaceAdded (Place *place) |
1132 | +{ |
1133 | + place->result_activated.connect (sigc::mem_fun (this, &PlacesView::OnPlaceResultActivated)); |
1134 | +} |
1135 | + |
1136 | +void |
1137 | +PlacesView::OnPlaceResultActivated (const char *uri, ActivationResult res) |
1138 | +{ |
1139 | + switch (res) |
1140 | + { |
1141 | + case FALLBACK: |
1142 | + OnResultActivated (g_variant_new_string (uri), this); |
1143 | + break; |
1144 | + case SHOW_DASH: |
1145 | + break; |
1146 | + case HIDE_DASH: |
1147 | + ubus_server_send_message (ubus_server_get_default (), |
1148 | + UBUS_PLACE_VIEW_CLOSE_REQUEST, |
1149 | + NULL); |
1150 | + break; |
1151 | + default: |
1152 | + g_warning ("Activation result %d not supported", res); |
1153 | + break; |
1154 | + }; |
1155 | +} |
1156 | + |
1157 | + |
1158 | // |
1159 | // Introspection |
1160 | // |
1161 | |
1162 | === modified file 'src/PlacesView.h' |
1163 | --- src/PlacesView.h 2011-03-01 09:22:43 +0000 |
1164 | +++ src/PlacesView.h 2011-03-09 19:59:40 +0000 |
1165 | @@ -95,12 +95,19 @@ |
1166 | void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); |
1167 | void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result); |
1168 | |
1169 | - static void OnResultClicked (GVariant *data, PlacesView *self); |
1170 | + bool TryPlaceActivation (const char *uri); |
1171 | + static void OnResultActivated (GVariant *data, PlacesView *self); |
1172 | void OnSearchChanged (const char *search_string); |
1173 | void OnResultsViewGeometryChanged (nux::Area *view, nux::Geometry& view_geo); |
1174 | |
1175 | static void OnPlaceViewQueueDrawNeeded (GVariant *data, PlacesView *self); |
1176 | |
1177 | + void OnEntryActivated (); |
1178 | + |
1179 | + void LoadPlaces (); |
1180 | + void OnPlaceAdded (Place *place); |
1181 | + void OnPlaceResultActivated (const char *uri, ActivationResult res); |
1182 | + |
1183 | private: |
1184 | PlaceFactory *_factory; |
1185 | nux::HLayout *_layout; |
Approved