Merge lp:~unity-team/unity/dash-niceness-2011-03-24 into lp:unity

Proposed by Neil J. Patel on 2011-03-24
Status: Merged
Merged at revision: 1018
Proposed branch: lp:~unity-team/unity/dash-niceness-2011-03-24
Merge into: lp:unity
Diff against target: 1428 lines (+729/-51) (has conflicts)
25 files modified
src/IconLoader.cpp (+36/-13)
src/IconLoader.h (+7/-3)
src/IconTexture.cpp (+5/-0)
src/PanelMenuView.cpp (+7/-0)
src/PanelMenuView.h (+1/-0)
src/PlaceEntry.h (+2/-0)
src/PlaceEntryHome.cpp (+25/-1)
src/PlaceEntryHome.h (+6/-0)
src/PlaceEntryRemote.cpp (+13/-1)
src/PlacesEmptyView.cpp (+88/-0)
src/PlacesEmptyView.h (+55/-0)
src/PlacesGroupController.cpp (+51/-0)
src/PlacesGroupController.h (+2/-0)
src/PlacesSearchBar.cpp (+15/-10)
src/PlacesSearchBar.h (+4/-1)
src/PlacesSearchBarSpinner.cpp (+183/-0)
src/PlacesSearchBarSpinner.h (+72/-0)
src/PlacesSimpleTile.cpp (+0/-11)
src/PlacesStyle.cpp (+22/-0)
src/PlacesStyle.h (+4/-0)
src/PlacesView.cpp (+92/-7)
src/PlacesView.h (+14/-0)
src/StaticCairoText.cpp (+12/-4)
src/StaticCairoText.h (+4/-0)
tests/CMakeLists.txt (+9/-0)
Text conflict in tests/CMakeLists.txt
To merge this branch: bzr merge lp:~unity-team/unity/dash-niceness-2011-03-24
Reviewer Review Type Date Requested Status
Jay Taoko (community) 2011-03-24 Approve on 2011-03-24
Review via email: mp+54637@code.launchpad.net

Description of the change

Lots of dash fixes, bugs linked where I could find them, off the top of my head:

- Shows no-results stuff for the individual places
- Shows a spinner during search (this will go into timeoutmode if you don't ahve very latest place daemons and libunity)
- Protects against pressing enter before we have all the restuls, but if you get impatient it activates whatever is there
- Fixes blur!

Some other stuff, have fun :)

To post a comment you must log in.
Jay Taoko (jaytaoko) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'resources/search_clear_alone.png'
2Binary files resources/search_clear_alone.png 1970-01-01 00:00:00 +0000 and resources/search_clear_alone.png 2011-03-24 01:52:23 +0000 differ
3=== added file 'resources/search_clear_spinner.png'
4Binary files resources/search_clear_spinner.png 1970-01-01 00:00:00 +0000 and resources/search_clear_spinner.png 2011-03-24 01:52:23 +0000 differ
5=== modified file 'src/IconLoader.cpp'
6--- src/IconLoader.cpp 2011-02-09 20:44:45 +0000
7+++ src/IconLoader.cpp 2011-03-24 01:52:23 +0000
8@@ -109,23 +109,46 @@
9 guint size,
10 IconLoaderCallback slot)
11 {
12+ GFile *file;
13+ gchar *uri;
14+
15+ g_return_if_fail (filename);
16+ g_return_if_fail (size > 1);
17+
18+ if (_no_load)
19+ return;
20+
21+ file = g_file_new_for_path (filename);
22+ uri = g_file_get_uri (file);
23+
24+ LoadFromURI (uri, size, slot);
25+
26+ g_free (uri);
27+ g_object_unref (file);
28+}
29+
30+void
31+IconLoader::LoadFromURI (const char *uri,
32+ guint size,
33+ IconLoaderCallback slot)
34+{
35 char *key;
36
37- g_return_if_fail (filename);
38+ g_return_if_fail (uri);
39 g_return_if_fail (size > 1);
40
41 if (_no_load)
42 return;
43
44- key = Hash (filename, size);
45+ key = Hash (uri, size);
46
47- if (CacheLookup (key, filename, size, slot))
48+ if (CacheLookup (key, uri, size, slot))
49 {
50 g_free (key);
51 return;
52 }
53
54- QueueTask (key, filename, size, slot, REQUEST_TYPE_FILENAME);
55+ QueueTask (key, uri, size, slot, REQUEST_TYPE_URI);
56
57 g_free (key);
58 }
59@@ -207,9 +230,9 @@
60 {
61 task_complete = ProcessGIconTask (task);
62 }
63- else if (task->type == REQUEST_TYPE_FILENAME)
64+ else if (task->type == REQUEST_TYPE_URI)
65 {
66- task_complete = ProcessFilenameTask (task);
67+ task_complete = ProcessURITask (task);
68 }
69 else
70 {
71@@ -285,9 +308,9 @@
72 file = g_file_icon_get_file (G_FILE_ICON (icon));
73
74 g_free (task->data);
75- task->type = REQUEST_TYPE_FILENAME;
76- task->data = g_file_get_path (file);
77- ret = ProcessFilenameTask (task);
78+ task->type = REQUEST_TYPE_URI;
79+ task->data = g_file_get_uri (file);
80+ ret = ProcessURITask (task);
81
82 g_object_unref (icon);
83
84@@ -362,11 +385,11 @@
85 }
86
87 bool
88-IconLoader::ProcessFilenameTask (IconLoaderTask *task)
89+IconLoader::ProcessURITask (IconLoaderTask *task)
90 {
91 GFile *file;
92
93- file = g_file_new_for_path (task->data);
94+ file = g_file_new_for_uri (task->data);
95
96 g_file_load_contents_async (file,
97 NULL,
98@@ -378,7 +401,7 @@
99 }
100
101 void
102-IconLoader::ProcessFilenameTaskReady (IconLoaderTask *task, char *contents, gsize length)
103+IconLoader::ProcessURITaskReady (IconLoaderTask *task, char *contents, gsize length)
104 {
105 GdkPixbuf *pixbuf = NULL;
106 GInputStream *stream;
107@@ -470,7 +493,7 @@
108
109 if (g_file_load_contents_finish (G_FILE (obj), res, &contents, &length, NULL, &error))
110 {
111- task->self->ProcessFilenameTaskReady (task, contents, length);
112+ task->self->ProcessURITaskReady (task, contents, length);
113
114 g_free (contents);
115 }
116
117=== modified file 'src/IconLoader.h'
118--- src/IconLoader.h 2011-02-09 12:24:11 +0000
119+++ src/IconLoader.h 2011-03-24 01:52:23 +0000
120@@ -47,13 +47,17 @@
121 void LoadFromFilename (const char *filename,
122 guint size,
123 IconLoaderCallback slot);
124+
125+ void LoadFromURI (const char *uri,
126+ guint size,
127+ IconLoaderCallback slot);
128 private:
129
130 enum IconLoaderRequestType
131 {
132 REQUEST_TYPE_ICON_NAME=0,
133 REQUEST_TYPE_GICON_STRING,
134- REQUEST_TYPE_FILENAME
135+ REQUEST_TYPE_URI,
136 };
137
138 struct IconLoaderTask
139@@ -80,8 +84,8 @@
140 bool ProcessTask (IconLoaderTask *task);
141 bool ProcessIconNameTask (IconLoaderTask *task);
142 bool ProcessGIconTask (IconLoaderTask *task);
143- bool ProcessFilenameTask (IconLoaderTask *task);
144- void ProcessFilenameTaskReady (IconLoaderTask *task, char *contents, gsize length);
145+ bool ProcessURITask (IconLoaderTask *task);
146+ void ProcessURITaskReady (IconLoaderTask *task, char *contents, gsize length);
147 bool Iteration ();
148 void FreeTask (IconLoaderTask *task);
149
150
151=== modified file 'src/IconTexture.cpp'
152--- src/IconTexture.cpp 2011-03-13 19:01:59 +0000
153+++ src/IconTexture.cpp 2011-03-24 01:52:23 +0000
154@@ -113,6 +113,11 @@
155 sigc::mem_fun (this, &IconTexture::IconLoaded));
156 g_object_unref (icon);
157 }
158+ else if (g_str_has_prefix (_icon_name, "http://"))
159+ {
160+ IconLoader::GetDefault ()->LoadFromURI (_icon_name,
161+ _size, sigc::mem_fun (this, &IconTexture::IconLoaded));
162+ }
163 else
164 {
165 IconLoader::GetDefault ()->LoadFromIconName (_icon_name,
166
167=== modified file 'src/PanelMenuView.cpp'
168--- src/PanelMenuView.cpp 2011-03-23 16:43:07 +0000
169+++ src/PanelMenuView.cpp 2011-03-24 01:52:23 +0000
170@@ -458,6 +458,12 @@
171 PanelMenuView::Refresh ()
172 {
173 nux::Geometry geo = GetGeometry ();
174+
175+ // We can get into a race that causes the geometry to be wrong as there hasn't been a layout
176+ // cycle before the first callback. This is to protect from that.
177+ if (geo.width > _monitor_geo.width)
178+ return;
179+
180 char *label = GetActiveViewName ();
181 PangoLayout *layout = NULL;
182 PangoFontDescription *desc = NULL;
183@@ -1026,6 +1032,7 @@
184 PanelMenuView::SetMonitor (int monitor)
185 {
186 _monitor = monitor;
187+ _monitor_geo = UScreen::GetDefault ()->GetMonitorGeometry (_monitor);
188 }
189
190 bool
191
192=== modified file 'src/PanelMenuView.h'
193--- src/PanelMenuView.h 2011-03-22 16:56:41 +0000
194+++ src/PanelMenuView.h 2011-03-24 01:52:23 +0000
195@@ -139,5 +139,6 @@
196 int _monitor;
197 guint32 _active_xid;
198 guint32 _active_moved_id;
199+ nux::Geometry _monitor_geo;
200 };
201 #endif
202
203=== modified file 'src/PlaceEntry.h'
204--- src/PlaceEntry.h 2011-03-15 10:39:09 +0000
205+++ src/PlaceEntry.h 2011-03-24 01:52:23 +0000
206@@ -162,6 +162,8 @@
207 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&> global_group_added;
208 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_added;
209 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_removed;
210+
211+ sigc::signal<void, const char *, guint32, std::map<const char *, const char *>&> search_finished;
212 };
213
214 #endif // PLACE_ENTRY_H
215
216=== modified file 'src/PlaceEntryHome.cpp'
217--- src/PlaceEntryHome.cpp 2011-03-17 13:56:52 +0000
218+++ src/PlaceEntryHome.cpp 2011-03-24 01:52:23 +0000
219@@ -62,7 +62,8 @@
220
221
222 PlaceEntryHome::PlaceEntryHome (PlaceFactory *factory)
223-: _factory (factory)
224+: _factory (factory),
225+ _n_searches_done (0)
226 {
227 LoadExistingEntries ();
228 _factory->place_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnPlaceAdded));
229@@ -117,10 +118,14 @@
230 {
231 PlaceEntryGroupHome group (entry);
232
233+ if (!entry->ShowInGlobal ())
234+ return;
235+
236 _entries.push_back (entry);
237
238 entry->global_result_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultAdded));
239 entry->global_result_removed.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultRemoved));
240+ entry->search_finished.connect (sigc::mem_fun (this, &PlaceEntryHome::OnSearchFinished));
241
242 group_added.emit (this, group);
243 }
244@@ -241,6 +246,9 @@
245 {
246 std::vector<PlaceEntry *>::iterator it, eit = _entries.end ();
247
248+ _n_searches_done = 0;
249+ _last_search = search;
250+
251 for (it = _entries.begin (); it != eit; ++it)
252 {
253 (*it)->SetGlobalSearch (search, hints);
254@@ -313,3 +321,19 @@
255 entry->ActivateGlobalResult (id);
256 }
257 }
258+
259+void
260+PlaceEntryHome::OnSearchFinished (const char *search_string,
261+ guint32 section_id,
262+ std::map<const char *, const char *>& hints)
263+{
264+ if (_last_search == search_string)
265+ {
266+ _n_searches_done++;
267+ if (_n_searches_done == _entries.size ())
268+ {
269+ search_finished.emit (search_string, section_id, hints);
270+ }
271+ }
272+}
273+
274
275=== modified file 'src/PlaceEntryHome.h'
276--- src/PlaceEntryHome.h 2011-03-17 13:56:52 +0000
277+++ src/PlaceEntryHome.h 2011-03-24 01:52:23 +0000
278@@ -85,6 +85,9 @@
279 void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
280 void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
281 void OnForeachResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
282+ void OnSearchFinished (const char *search_string,
283+ guint32 section_id,
284+ std::map<const char *, const char *>& hints);
285
286 public:
287 PlaceFactory *_factory;
288@@ -94,6 +97,9 @@
289 std::map<const void *, PlaceEntry *> _id_to_entry;
290
291 ResultForeachCallback _foreach_callback;
292+
293+ guint _n_searches_done;
294+ std::string _last_search;
295 };
296
297 #endif // PLACE_ENTRY_HOME_H
298
299=== modified file 'src/PlaceEntryRemote.cpp'
300--- src/PlaceEntryRemote.cpp 2011-03-17 13:33:30 +0000
301+++ src/PlaceEntryRemote.cpp 2011-03-24 01:52:23 +0000
302@@ -1025,5 +1025,17 @@
303 {
304 PlaceEntryRemote *self = static_cast<PlaceEntryRemote *> (user_data);
305
306- g_debug ("%p: %s", self, sender_name);
307+ if (g_strcmp0 (signal_name, "SearchFinished") == 0)
308+ {
309+ guint32 section = 0;
310+ gchar *search_string = NULL;
311+ GVariantIter *iter;
312+ std::map<const char *, const char*> hints;
313+
314+ g_variant_get (parameters, "(usa{ss})", &section, &search_string, &iter);
315+ self->search_finished.emit (search_string, section, hints);
316+
317+ g_free (search_string);
318+ g_variant_iter_free (iter);
319+ }
320 }
321
322=== added file 'src/PlacesEmptyView.cpp'
323--- src/PlacesEmptyView.cpp 1970-01-01 00:00:00 +0000
324+++ src/PlacesEmptyView.cpp 2011-03-24 01:52:23 +0000
325@@ -0,0 +1,88 @@
326+/*
327+ * Copyright (C) 2010 Canonical Ltd
328+ *
329+ * This program is free software: you can redistribute it and/or modify
330+ * it under the terms of the GNU General Public License version 3 as
331+ * published by the Free Software Foundation.
332+ *
333+ * This program is distributed in the hope that it will be useful,
334+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
335+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
336+ * GNU General Public License for more details.
337+ *
338+ * You should have received a copy of the GNU General Public License
339+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
340+ *
341+ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
342+ */
343+
344+#include "PlacesEmptyView.h"
345+
346+#include "PlacesStyle.h"
347+
348+NUX_IMPLEMENT_OBJECT_TYPE (PlacesEmptyView);
349+
350+PlacesEmptyView::PlacesEmptyView ()
351+: nux::View (NUX_TRACKER_LOCATION)
352+{
353+ SetLayout (new nux::HLayout (NUX_TRACKER_LOCATION));
354+
355+ _text = new nux::StaticCairoText ("");
356+ _text->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
357+ _text->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
358+ _text->SetTextVerticalAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
359+ _text->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.8f));
360+
361+ GetCompositionLayout ()->AddSpace (1, 1);
362+ GetCompositionLayout ()->AddView (_text, 1, nux::eCenter, nux::eFix);
363+ GetCompositionLayout ()->AddSpace (1, 1);
364+}
365+
366+PlacesEmptyView::~PlacesEmptyView ()
367+{
368+
369+}
370+
371+long
372+PlacesEmptyView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
373+{
374+ return GetCompositionLayout ()->ProcessEvent (ievent, TraverseInfo, ProcessEventInfo);
375+}
376+
377+void
378+PlacesEmptyView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
379+{
380+}
381+
382+void
383+PlacesEmptyView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
384+{
385+ GetCompositionLayout ()->ProcessDraw (GfxContext, force_draw);
386+}
387+
388+void
389+PlacesEmptyView::SetText (const char *text)
390+{
391+ char *clean;
392+ char *markup;
393+
394+ clean = g_markup_escape_text (text, -1);
395+ markup = g_strdup_printf ("<big>%s</big>", clean);
396+
397+ _text->SetText (markup);
398+
399+ g_free (clean);
400+ g_free (markup);
401+}
402+
403+const gchar*
404+PlacesEmptyView::GetName ()
405+{
406+ return "PlacesEmptyView";
407+}
408+
409+void
410+PlacesEmptyView::AddProperties (GVariantBuilder *builder)
411+{
412+
413+}
414
415=== added file 'src/PlacesEmptyView.h'
416--- src/PlacesEmptyView.h 1970-01-01 00:00:00 +0000
417+++ src/PlacesEmptyView.h 2011-03-24 01:52:23 +0000
418@@ -0,0 +1,55 @@
419+/*
420+ * Copyright (C) 2010 Canonical Ltd
421+ *
422+ * This program is free software: you can redistribute it and/or modify
423+ * it under the terms of the GNU General Public License version 3 as
424+ * published by the Free Software Foundation.
425+ *
426+ * This program is distributed in the hope that it will be useful,
427+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
428+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
429+ * GNU General Public License for more details.
430+ *
431+ * You should have received a copy of the GNU General Public License
432+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
433+ *
434+ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
435+ */
436+
437+#ifndef PLACES_EMPTY_VIEW_H
438+#define PLACES_EMPTY_VIEW_H
439+
440+#include <Nux/Nux.h>
441+#include <Nux/View.h>
442+#include <NuxGraphics/GraphicsEngine.h>
443+#include <Nux/HLayout.h>
444+#include <Nux/VLayout.h>
445+#include "Introspectable.h"
446+#include "StaticCairoText.h"
447+
448+class PlacesEmptyView : public nux::View, public Introspectable
449+{
450+ NUX_DECLARE_OBJECT_TYPE (PlacesEmptyView, nux::View);
451+public:
452+
453+ PlacesEmptyView ();
454+ ~PlacesEmptyView ();
455+
456+ // nux::View overrides
457+ long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
458+ void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
459+ void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
460+
461+ void SetText (const char *text);
462+
463+protected:
464+
465+ const gchar* GetName ();
466+ void AddProperties (GVariantBuilder *builder);
467+
468+private:
469+
470+ nux::StaticCairoText *_text;
471+};
472+
473+#endif // PLACES_EMPTY_VIEW_H
474
475=== modified file 'src/PlacesGroupController.cpp'
476--- src/PlacesGroupController.cpp 2011-03-23 17:55:51 +0000
477+++ src/PlacesGroupController.cpp 2011-03-24 01:52:23 +0000
478@@ -19,6 +19,7 @@
479 #include "PlacesGroupController.h"
480
481 #include <Nux/GridHLayout.h>
482+#include <glib/gi18n-lib.h>
483
484 #include "PlacesStyle.h"
485 #include "PlacesSimpleTile.h"
486@@ -55,12 +56,22 @@
487
488 _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
489 style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
490+
491+ _more_tile = new PlacesSimpleTile ("gtk-add",
492+ _("Load more results..."),
493+ style->GetTileIconSize (),
494+ false,
495+ "more-tile");
496+ _more_tile->Reference ();
497+ _more_tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::MoreTileClicked));
498 }
499
500 PlacesGroupController::~PlacesGroupController ()
501 {
502 if (_check_tiles_id)
503 g_source_remove (_check_tiles_id);
504+ if (_more_tile)
505+ _more_tile->UnReference ();
506 }
507
508 const void *
509@@ -117,6 +128,13 @@
510 }
511
512 void
513+PlacesGroupController::MoreTileClicked (PlacesTile *tile)
514+{
515+ if (!_check_tiles_id)
516+ _check_tiles_id = g_timeout_add (150, (GSourceFunc)CheckTilesTimeout, this);
517+}
518+
519+void
520 PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)
521 {
522 PlacesStyle *style = PlacesStyle::GetDefault ();
523@@ -178,6 +196,9 @@
524 else
525 n_to_show = style->GetDefaultNColumns ();
526
527+ if (_more_tile->GetParentObject ())
528+ _group->GetChildLayout ()->RemoveChildObject (_more_tile);
529+
530 if (_id_to_tile.size () == n_to_show)
531 {
532 // Hoorah
533@@ -185,6 +206,9 @@
534 else if (_id_to_tile.size () < n_to_show)
535 {
536 std::vector<const void *>::iterator it = _queue.begin ();
537+ int max_rows_to_add = style->GetDefaultNColumns () * 15;
538+ int max_rows_per_click = max_rows_to_add * 3;
539+ int n_tiles = _id_to_tile.size ();
540
541 if (_queue.size () >= n_to_show)
542 {
543@@ -194,6 +218,33 @@
544 {
545 _entry->GetResult ((*it), sigc::mem_fun (this, &PlacesGroupController::AddTile));
546 it++;
547+ n_tiles++;
548+
549+ if (n_tiles % max_rows_to_add == 0)
550+ {
551+ // What we do over here is add a "Load more results..." button which will then kick off
552+ // another fill cycle. Generally the user will never need to see this, but in the case
553+ // of large results sets, this gives us a chance of not blocking the entire WM for
554+ // 20 secs as we load in 2000+ results.
555+ if (n_tiles % max_rows_per_click == 0)
556+ {
557+ _group->GetChildLayout ()->AddView (_more_tile);
558+ }
559+ else
560+ {
561+ // The idea here is that we increase the timeouts of adding tiles in relation to
562+ // how big the view is getting. In theory it shouldn't be needed but in reality with
563+ // Nux having to do so many calculations it is needed. Ideally we'd be rendering
564+ // the entire results view as a scene with re-usable tiles but that would have been
565+ // too difficult to get right with a11y, so instead we need to just deal with this
566+ // the best way we can.
567+ if (!_check_tiles_id)
568+ _check_tiles_id = g_timeout_add (350 * n_tiles/max_rows_to_add,
569+ (GSourceFunc)CheckTilesTimeout,
570+ this);
571+ }
572+ return;
573+ }
574 }
575 }
576 }
577
578=== modified file 'src/PlacesGroupController.h'
579--- src/PlacesGroupController.h 2011-03-13 21:22:04 +0000
580+++ src/PlacesGroupController.h 2011-03-24 01:52:23 +0000
581@@ -54,6 +54,7 @@
582 void CheckTiles ();
583 static gboolean CheckTilesTimeout (PlacesGroupController *self);
584 void TileClicked (PlacesTile *tile);
585+ void MoreTileClicked (PlacesTile *tile);
586
587 private:
588 PlaceEntry *_entry;
589@@ -62,6 +63,7 @@
590 std::map<const void *, PlacesTile *> _id_to_tile;
591 guint _check_tiles_id;
592 std::vector<const void *> _queue;
593+ PlacesTile *_more_tile;
594 };
595
596 #endif // PLACES_GROUP_CONTROLLER_H
597
598=== modified file 'src/PlacesSearchBar.cpp'
599--- src/PlacesSearchBar.cpp 2011-03-23 15:44:45 +0000
600+++ src/PlacesSearchBar.cpp 2011-03-24 01:52:23 +0000
601@@ -60,12 +60,12 @@
602 _layout = new nux::HLayout (NUX_TRACKER_LOCATION);
603 _layout->SetHorizontalInternalMargin (12);
604
605- _search_icon = new nux::TextureArea (NUX_TRACKER_LOCATION);
606- _search_icon->SetTexture (icon);
607- _search_icon->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());
608- _layout->AddView (_search_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
609- _search_icon->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));
610- _search_icon->SetCanFocus (false);
611+ _spinner = new PlacesSearchBarSpinner ();
612+ _spinner->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());
613+ //_spinner->SetMaximumWidth (icon->GetWidth ());
614+ _layout->AddView (_spinner, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
615+ _spinner->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));
616+ _spinner->SetCanFocus (false);
617
618 _layered_layout = new nux::LayeredLayout ();
619
620@@ -243,8 +243,7 @@
621 void
622 PlacesSearchBar::OnSearchChanged (nux::TextEntry *text_entry)
623 {
624- PlacesStyle *style = PlacesStyle::GetDefault ();
625- bool is_empty;
626+ bool is_empty;
627
628 if (_live_search_timeout)
629 g_source_remove (_live_search_timeout);
630@@ -259,7 +258,7 @@
631
632 is_empty = g_strcmp0 (_pango_entry->GetText ().c_str (), "") == 0;
633 _hint->SetVisible (is_empty);
634- _search_icon->SetTexture (is_empty ? style->GetSearchReadyIcon () : style->GetSearchClearIcon ());
635+ _spinner->SetState (is_empty ? STATE_READY : STATE_SEARCHING);
636
637 _hint->QueueDraw ();
638 _pango_entry->QueueDraw ();
639@@ -292,7 +291,7 @@
640 if (_pango_entry->GetText () != "")
641 {
642 _pango_entry->SetText ("");
643- _search_icon->SetTexture (PlacesStyle::GetDefault ()->GetSearchReadyIcon ());
644+ _spinner->SetState (STATE_READY);
645 EmitLiveSearch ();
646 }
647 }
648@@ -310,6 +309,12 @@
649 }
650
651 void
652+PlacesSearchBar::OnSearchFinished ()
653+{
654+ _spinner->SetState (STATE_CLEAR);
655+}
656+
657+void
658 PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self)
659 {
660 #define HOW_LARGE 8
661
662=== modified file 'src/PlacesSearchBar.h'
663--- src/PlacesSearchBar.h 2011-03-15 14:23:03 +0000
664+++ src/PlacesSearchBar.h 2011-03-24 01:52:23 +0000
665@@ -32,6 +32,8 @@
666 #include "Nux/EditTextBox.h"
667 #include "Nux/TextEntry.h"
668
669+#include "PlacesSearchBarSpinner.h"
670+
671 #include "PlaceEntry.h"
672
673 class PlacesView;
674@@ -53,6 +55,7 @@
675 void SetActiveEntry (PlaceEntry *entry,
676 guint section_id,
677 const char *search_string);
678+ void OnSearchFinished ();
679
680 sigc::signal<void, const char *> search_changed;
681 sigc::signal<void> activated;
682@@ -89,7 +92,7 @@
683 guint _live_search_timeout;
684
685 friend class PlacesView;
686- nux::TextureArea *_search_icon;
687+ PlacesSearchBarSpinner *_spinner;
688 nux::ComboBoxSimple *_combo;
689 };
690
691
692=== added file 'src/PlacesSearchBarSpinner.cpp'
693--- src/PlacesSearchBarSpinner.cpp 1970-01-01 00:00:00 +0000
694+++ src/PlacesSearchBarSpinner.cpp 2011-03-24 01:52:23 +0000
695@@ -0,0 +1,183 @@
696+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
697+/*
698+ * Copyright (C) 2011 Canonical Ltd
699+ *
700+ * This program is free software: you can redistribute it and/or modify
701+ * it under the terms of the GNU General Public License version 3 as
702+ * published by the Free Software Foundation.
703+ *
704+ * This program is distributed in the hope that it will be useful,
705+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
706+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
707+ * GNU General Public License for more details.
708+ *
709+ * You should have received a copy of the GNU General Public License
710+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
711+ *
712+ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
713+ */
714+
715+#include "PlacesSearchBarSpinner.h"
716+
717+#include <Nux/VLayout.h>
718+
719+#include "PlacesStyle.h"
720+
721+NUX_IMPLEMENT_OBJECT_TYPE (PlacesSearchBarSpinner);
722+
723+PlacesSearchBarSpinner::PlacesSearchBarSpinner ()
724+: nux::View (NUX_TRACKER_LOCATION),
725+ _state (STATE_READY),
726+ _rotation (0.0f),
727+ _spinner_timeout (0)
728+{
729+ PlacesStyle *style = PlacesStyle::GetDefault ();
730+
731+ _search_ready = style->GetSearchReadyIcon ();
732+ _clear_full = style->GetSearchClearIcon ();
733+ _clear_alone = style->GetSearchClearAloneIcon ();
734+ _clear_spinner = style->GetSearchClearSpinnerIcon ();
735+
736+ _2d_rotate.Identity ();
737+ _2d_rotate.Rotate_z (0.0);
738+}
739+
740+PlacesSearchBarSpinner::~PlacesSearchBarSpinner ()
741+{
742+
743+}
744+
745+long
746+PlacesSearchBarSpinner::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
747+{
748+ return PostProcessEvent2 (ievent, TraverseInfo, ProcessEventInfo);
749+}
750+
751+void
752+PlacesSearchBarSpinner::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
753+{
754+ nux::Geometry geo = GetGeometry ();
755+ nux::TexCoordXForm texxform;
756+
757+ GfxContext.PushClippingRectangle (geo);
758+
759+ nux::GetPainter ().PaintBackground (GfxContext, geo);
760+
761+ texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
762+ texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
763+ texxform.min_filter = nux::TEXFILTER_LINEAR;
764+ texxform.mag_filter = nux::TEXFILTER_LINEAR;
765+
766+ if (_state == STATE_READY)
767+ {
768+ GfxContext.QRP_1Tex (geo.x + ((geo.width - _search_ready->GetWidth ())/2),
769+ geo.y + ((geo.height - _search_ready->GetHeight ())/2),
770+ _search_ready->GetWidth (),
771+ _search_ready->GetHeight (),
772+ _search_ready->GetDeviceTexture (),
773+ texxform,
774+ nux::Color::White);
775+ }
776+ else if (_state == STATE_SEARCHING)
777+ {
778+ nux::Geometry clear_geo (geo.x + ((geo.width - _clear_spinner->GetWidth ())/2),
779+ geo.y + ((geo.height - _clear_spinner->GetHeight ())/2),
780+ _clear_spinner->GetWidth (),
781+ _clear_spinner->GetHeight ());
782+
783+ GfxContext.PushModelViewMatrix (nux::Matrix4::TRANSLATE(-clear_geo.x - clear_geo.width / 2,
784+ -clear_geo.y - clear_geo.height / 2, 0));
785+ GfxContext.PushModelViewMatrix (_2d_rotate);
786+ GfxContext.PushModelViewMatrix (nux::Matrix4::TRANSLATE(clear_geo.x + clear_geo.width/ 2,
787+ clear_geo.y + clear_geo.height / 2, 0));
788+
789+ GfxContext.QRP_1Tex (clear_geo.x,
790+ clear_geo.y,
791+ clear_geo.width,
792+ clear_geo.height,
793+ _clear_spinner->GetDeviceTexture (),
794+ texxform,
795+ nux::Color::White);
796+
797+ GfxContext.PopModelViewMatrix ();
798+ GfxContext.PopModelViewMatrix ();
799+ GfxContext.PopModelViewMatrix ();
800+
801+ GfxContext.QRP_1Tex (geo.x + ((geo.width - _clear_alone->GetWidth ())/2),
802+ geo.y + ((geo.height - _clear_alone->GetHeight ())/2),
803+ _clear_alone->GetWidth (),
804+ _clear_alone->GetHeight (),
805+ _clear_alone->GetDeviceTexture (),
806+ texxform,
807+ nux::Color::White);
808+ }
809+ else
810+ {
811+ GfxContext.QRP_1Tex (geo.x + ((geo.width - _clear_full->GetWidth ())/2),
812+ geo.y + ((geo.height - _clear_full->GetHeight ())/2),
813+ _clear_full->GetWidth (),
814+ _clear_full->GetHeight (),
815+ _clear_full->GetDeviceTexture (),
816+ texxform,
817+ nux::Color::White);
818+ }
819+
820+ GfxContext.PopClippingRectangle ();
821+}
822+
823+void
824+PlacesSearchBarSpinner::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
825+{
826+}
827+
828+gboolean
829+PlacesSearchBarSpinner::OnFrame (PlacesSearchBarSpinner *self)
830+{
831+ self->_rotation += 0.1f;
832+
833+ if (self->_rotation >= 360.0f)
834+ self->_rotation = 0.0f;
835+
836+ self->_2d_rotate.Rotate_z (self->_rotation);
837+
838+ self->QueueDraw ();
839+
840+ return TRUE;
841+}
842+
843+void
844+PlacesSearchBarSpinner::SetState (SpinnerState state)
845+{
846+ if (_state == state)
847+ return;
848+
849+ _state = state;
850+
851+ if (_spinner_timeout)
852+ g_source_remove (_spinner_timeout);
853+ _2d_rotate.Rotate_z (0.0f);
854+ _rotation = 0.0f;
855+
856+ if (_state == STATE_SEARCHING)
857+ {
858+ _spinner_timeout = g_timeout_add (15, (GSourceFunc)PlacesSearchBarSpinner::OnFrame, this);
859+ }
860+
861+ QueueDraw ();
862+}
863+
864+const gchar*
865+PlacesSearchBarSpinner::GetName ()
866+{
867+ return "PlacesSearchBarSpinner";
868+}
869+
870+void PlacesSearchBarSpinner::AddProperties (GVariantBuilder *builder)
871+{
872+ nux::Geometry geo = GetGeometry ();
873+
874+ g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (geo.x));
875+ g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));
876+ g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
877+ g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
878+}
879
880=== added file 'src/PlacesSearchBarSpinner.h'
881--- src/PlacesSearchBarSpinner.h 1970-01-01 00:00:00 +0000
882+++ src/PlacesSearchBarSpinner.h 2011-03-24 01:52:23 +0000
883@@ -0,0 +1,72 @@
884+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
885+/*
886+ * Copyright (C) 2011 Canonical Ltd
887+ *
888+ * This program is free software: you can redistribute it and/or modify
889+ * it under the terms of the GNU General Public License version 3 as
890+ * published by the Free Software Foundation.
891+ *
892+ * This program is distributed in the hope that it will be useful,
893+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
894+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
895+ * GNU General Public License for more details.
896+ *
897+ * You should have received a copy of the GNU General Public License
898+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
899+ *
900+ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
901+ */
902+
903+#ifndef PLACES_SEARCH_BAR_SPINNER_H
904+#define PLACES_SEARCH_BAR_SPINNER_H
905+
906+#include <Nux/Nux.h>
907+#include <Nux/View.h>
908+#include <NuxGraphics/GraphicsEngine.h>
909+#include <Nux/TextureArea.h>
910+#include <NuxCore/Math/Matrix4.h>
911+#include "Introspectable.h"
912+
913+enum SpinnerState
914+{
915+ STATE_READY,
916+ STATE_SEARCHING,
917+ STATE_CLEAR
918+};
919+
920+class PlacesSearchBarSpinner : public Introspectable, public nux::View
921+{
922+ NUX_DECLARE_OBJECT_TYPE (PlacesSearchBarSpinner, nux::View);
923+public:
924+ PlacesSearchBarSpinner ();
925+ ~PlacesSearchBarSpinner ();
926+
927+ long ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
928+ void Draw (nux::GraphicsEngine& GfxContext, bool force_draw);
929+ void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
930+
931+ void SetState (SpinnerState state);
932+
933+protected:
934+ // Introspectable methods
935+ const gchar * GetName ();
936+ void AddProperties (GVariantBuilder *builder);
937+ static gboolean OnFrame (PlacesSearchBarSpinner *self);
938+
939+private:
940+
941+private:
942+ SpinnerState _state;
943+
944+ nux::BaseTexture *_search_ready;
945+ nux::BaseTexture *_clear_full;
946+ nux::BaseTexture *_clear_alone;
947+ nux::BaseTexture *_clear_spinner;
948+
949+ nux::Matrix4 _2d_rotate;
950+ float _rotation;
951+
952+ guint32 _spinner_timeout;
953+};
954+
955+#endif
956
957=== modified file 'src/PlacesSimpleTile.cpp'
958--- src/PlacesSimpleTile.cpp 2011-03-23 10:54:22 +0000
959+++ src/PlacesSimpleTile.cpp 2011-03-24 01:52:23 +0000
960@@ -40,10 +40,6 @@
961 _icon (NULL),
962 _uri (NULL)
963 {
964- //GtkSettings *settings = gtk_settings_get_default ();
965- //gchar *font = NULL;
966- //gchar *fontstring = NULL;
967-
968 nux::VLayout *layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
969
970 _label = g_strdup (label);
971@@ -57,10 +53,6 @@
972 _cairotext = new nux::StaticCairoText (_label);
973 _cairotext->SinkReference ();
974
975- //g_object_get (settings, "gtk-font-name", &font, NULL);
976- //fontstring = g_strdup_printf ("%s normal 10", font);
977-
978- //_cairotext->SetFont (fontstring);
979 _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_START);
980 _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
981 _cairotext->SetMaximumWidth (140);
982@@ -75,9 +67,6 @@
983 SetLayout (layout);
984
985 SetDndEnabled (true, false);
986-
987- //g_free (font);
988- //g_free (fontstring);
989 }
990
991
992
993=== modified file 'src/PlacesStyle.cpp'
994--- src/PlacesStyle.cpp 2011-02-28 15:56:44 +0000
995+++ src/PlacesStyle.cpp 2011-03-24 01:52:23 +0000
996@@ -40,6 +40,8 @@
997 _dash_fullscreen_icon (NULL),
998 _search_ready_texture (NULL),
999 _search_clear_texture (NULL),
1000+ _search_clear_alone_texture (NULL),
1001+ _search_clear_spinner_texture (NULL),
1002 _group_unexpand_texture (NULL),
1003 _group_expand_texture (NULL)
1004 {
1005@@ -65,6 +67,10 @@
1006 _search_ready_texture->UnReference ();
1007 if (_search_clear_texture)
1008 _search_clear_texture->UnReference ();
1009+ if (_search_clear_alone_texture)
1010+ _search_clear_alone_texture->UnReference ();
1011+ if (_search_clear_spinner_texture)
1012+ _search_clear_spinner_texture->UnReference ();
1013 if (_group_unexpand_texture)
1014 _group_unexpand_texture->UnReference ();
1015 if (_group_expand_texture)
1016@@ -186,6 +192,22 @@
1017 }
1018
1019 nux::BaseTexture *
1020+PlacesStyle::GetSearchClearAloneIcon ()
1021+{
1022+ if (!_search_clear_alone_texture)
1023+ _search_clear_alone_texture = TextureFromFilename (PKGDATADIR"/search_clear_alone.png");
1024+ return _search_clear_alone_texture;
1025+}
1026+
1027+nux::BaseTexture *
1028+PlacesStyle::GetSearchClearSpinnerIcon ()
1029+{
1030+ if (!_search_clear_spinner_texture)
1031+ _search_clear_spinner_texture = TextureFromFilename (PKGDATADIR"/search_clear_spinner.png");
1032+ return _search_clear_spinner_texture;
1033+}
1034+
1035+nux::BaseTexture *
1036 PlacesStyle::GetGroupUnexpandIcon ()
1037 {
1038 if (!_group_unexpand_texture)
1039
1040=== modified file 'src/PlacesStyle.h'
1041--- src/PlacesStyle.h 2011-02-28 15:56:44 +0000
1042+++ src/PlacesStyle.h 2011-03-24 01:52:23 +0000
1043@@ -52,6 +52,8 @@
1044
1045 nux::BaseTexture * GetSearchReadyIcon ();
1046 nux::BaseTexture * GetSearchClearIcon ();
1047+ nux::BaseTexture * GetSearchClearAloneIcon ();
1048+ nux::BaseTexture * GetSearchClearSpinnerIcon ();
1049
1050 nux::BaseTexture * GetGroupUnexpandIcon ();
1051 nux::BaseTexture * GetGroupExpandIcon ();
1052@@ -80,6 +82,8 @@
1053
1054 nux::BaseTexture *_search_ready_texture;
1055 nux::BaseTexture *_search_clear_texture;
1056+ nux::BaseTexture *_search_clear_alone_texture;
1057+ nux::BaseTexture *_search_clear_spinner_texture;
1058
1059 nux::BaseTexture *_group_unexpand_texture;
1060 nux::BaseTexture *_group_expand_texture;
1061
1062=== modified file 'src/PlacesView.cpp'
1063--- src/PlacesView.cpp 2011-03-24 01:09:42 +0000
1064+++ src/PlacesView.cpp 2011-03-24 01:52:23 +0000
1065@@ -14,11 +14,13 @@
1066 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1067 *
1068 * Authored by: Gordon Allott <gord.allott@canonical.com>
1069+ * Neil Jagdish Patel <neil.patel@canonical.com>
1070 */
1071
1072 #include "config.h"
1073
1074 #include "Nux/Nux.h"
1075+#include "Nux/ColorArea.h"
1076 #include "NuxGraphics/GLThread.h"
1077 #include "UBusMessages.h"
1078
1079@@ -46,7 +48,9 @@
1080 _target_height (1),
1081 _actual_height (1),
1082 _resize_id (0),
1083- _alt_f2_entry (NULL)
1084+ _alt_f2_entry (NULL),
1085+ _searching_timeout (0),
1086+ _pending_activation (false)
1087 {
1088 LoadPlaces ();
1089 _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded));
1090@@ -93,6 +97,9 @@
1091 _layered_layout->AddLayer (_results_view);
1092 _results_view->GetLayout ()->OnGeometryChanged.connect (sigc::mem_fun (this, &PlacesView::OnResultsViewGeometryChanged));
1093
1094+ _empty_view = new PlacesEmptyView ();
1095+ _layered_layout->AddLayer (_empty_view);
1096+
1097 _layered_layout->SetActiveLayer (_home_view);
1098
1099 SetLayout (_layout);
1100@@ -123,8 +130,6 @@
1101 _icon_loader = IconLoader::GetDefault ();
1102
1103 SetActiveEntry (_home_entry, 0, "");
1104-
1105- //_layout->SetFocused (true);
1106 }
1107
1108 PlacesView::~PlacesView ()
1109@@ -182,6 +187,7 @@
1110 nux::Geometry geo_absolute = GetAbsoluteGeometry ();
1111 PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType ();
1112 bool paint_blur = type != PlacesSettings::NO_BLUR;
1113+ nux::BaseTexture *corner = style->GetDashCorner ();
1114
1115 GfxContext.PushClippingRectangle (geo);
1116
1117@@ -190,7 +196,6 @@
1118 GfxContext.GetRenderStates ().SetBlend (true);
1119 GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
1120
1121- geo.height = _actual_height;
1122 _bg_blur_geo = geo;
1123
1124 if ((_size_mode == SIZE_MODE_HOVER))
1125@@ -237,17 +242,25 @@
1126 rop.SrcBlend = GL_ONE;
1127 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
1128
1129+ nux::Geometry bg_clip = geo;
1130+ bg_clip.width -= corner->GetWidth ();
1131+ bg_clip.height = _actual_height - corner->GetHeight ();
1132+
1133+ GfxContext.PushClippingRectangle (bg_clip);
1134+
1135 gPainter.PushDrawTextureLayer (GfxContext, _bg_blur_geo,
1136 _bg_blur_texture,
1137 texxform_blur__bg,
1138 nux::Color::White,
1139 true,
1140 rop);
1141+
1142+ GfxContext.PopClippingRectangle ();
1143 }
1144+ geo.height = _actual_height;
1145
1146 if (_size_mode == SIZE_MODE_HOVER)
1147 {
1148- nux::BaseTexture *corner = style->GetDashCorner ();
1149 nux::BaseTexture *bottom = style->GetDashBottomTile ();
1150 nux::BaseTexture *right = style->GetDashRightTile ();
1151 nux::BaseTexture *icon = style->GetDashFullscreenIcon ();
1152@@ -412,8 +425,11 @@
1153 _group_added_conn.disconnect ();
1154 _result_added_conn.disconnect ();
1155 _result_removed_conn.disconnect ();
1156+ _search_finished_conn.disconnect ();
1157
1158 _results_controller->Clear ();
1159+
1160+ _n_results = 0;
1161 }
1162
1163 _entry = entry;
1164@@ -427,6 +443,7 @@
1165 _group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded));
1166 _result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded));
1167 _result_removed_conn = _entry->result_removed.connect (sigc::mem_fun (this, &PlacesView::OnResultRemoved));
1168+ _search_finished_conn = _entry->search_finished.connect (sigc::mem_fun (this, &PlacesView::OnSearchFinished));
1169
1170 if (_entry == _home_entry && (g_strcmp0 (search_string, "") == 0))
1171 _layered_layout->SetActiveLayer (_home_view);
1172@@ -586,12 +603,32 @@
1173 void
1174 PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
1175 {
1176+ _n_results++;
1177+
1178+ if (_n_results <= 2
1179+ && (g_strcmp0 (group.GetRenderer (), "UnityEmptySearchRenderer") == 0
1180+ || g_strcmp0 (group.GetRenderer (), "UnityEmptySectionRenderer") == 0))
1181+ {
1182+ if (_n_results == 1)
1183+ _empty_view->SetText (result.GetName ());
1184+ _layered_layout->SetActiveLayerN (2);
1185+ }
1186+
1187 _results_controller->AddResult (entry, group, result);
1188 }
1189
1190 void
1191 PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
1192 {
1193+ _n_results--;
1194+
1195+ if (_n_results <= 1
1196+ && (g_strcmp0 (group.GetRenderer (), "UnityEmptySearchRenderer") == 0
1197+ || g_strcmp0 (group.GetRenderer (), "UnityEmptySectionRenderer") == 0))
1198+ {
1199+ _layered_layout->SetActiveLayerN (1);
1200+ }
1201+
1202 _results_controller->RemoveResult (entry, group, result);
1203 }
1204
1205@@ -694,6 +731,26 @@
1206 _layered_layout->QueueDraw ();
1207 QueueDraw ();
1208 }
1209+
1210+ if (_searching_timeout)
1211+ g_source_remove (_searching_timeout);
1212+ _searching_timeout = 0;
1213+
1214+ if (g_strcmp0 (search_string, ""))
1215+ {
1216+ _searching_timeout = g_timeout_add (5000, (GSourceFunc)PlacesView::OnSearchTimedOut, this);
1217+ }
1218+}
1219+
1220+gboolean
1221+PlacesView::OnSearchTimedOut (PlacesView *view)
1222+{
1223+ std::map <const char *, const char *> hints;
1224+
1225+ view->_searching_timeout = 0;
1226+ view->OnSearchFinished ( "", 0, hints);
1227+
1228+ return FALSE;
1229 }
1230
1231 //
1232@@ -759,8 +816,17 @@
1233 void
1234 PlacesView::OnEntryActivated ()
1235 {
1236- if (!_results_controller->ActivateFirst ())
1237- g_debug ("Cannot activate anything");
1238+ if (_searching_timeout && !_pending_activation)
1239+ {
1240+ _pending_activation = true;
1241+ }
1242+ else
1243+ {
1244+ if (!_results_controller->ActivateFirst ())
1245+ g_debug ("Cannot activate anything");
1246+
1247+ _pending_activation = false;
1248+ }
1249 }
1250
1251 void
1252@@ -818,6 +884,25 @@
1253 OnResultsViewGeometryChanged (_results_view, geo);
1254 }
1255
1256+void
1257+PlacesView::OnSearchFinished (const char *search_string,
1258+ guint32 section_id,
1259+ std::map<const char *, const char *>& hints)
1260+{
1261+ if (_pending_activation)
1262+ {
1263+ if (!_results_controller->ActivateFirst ())
1264+ g_debug ("Cannot activate anything");
1265+ }
1266+ _pending_activation = false;
1267+
1268+ if (_searching_timeout)
1269+ g_source_remove (_searching_timeout);
1270+ _searching_timeout = 0;
1271+
1272+ _search_bar->OnSearchFinished ();
1273+}
1274+
1275 //
1276 // Introspection
1277 //
1278
1279=== modified file 'src/PlacesView.h'
1280--- src/PlacesView.h 2011-03-13 14:52:14 +0000
1281+++ src/PlacesView.h 2011-03-24 01:52:23 +0000
1282@@ -14,6 +14,7 @@
1283 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1284 *
1285 * Authored by: Gordon Allott <gord.allott@canonical.com>
1286+ * Neil Jagdish Patel <neil.patel@canonical.com>
1287 */
1288
1289 #ifndef PLACES_VIEW_H
1290@@ -36,6 +37,7 @@
1291
1292 #include "PlacesSearchBar.h"
1293 #include "PlacesHomeView.h"
1294+#include "PlacesEmptyView.h"
1295
1296 #include "PlacesResultsController.h"
1297 #include "PlacesResultsView.h"
1298@@ -121,17 +123,25 @@
1299
1300 static gboolean OnResizeFrame (PlacesView *self);
1301
1302+ void OnSearchFinished (const char *search_string,
1303+ guint32 section_id,
1304+ std::map<const char *, const char *>& hints);
1305+
1306+ static gboolean OnSearchTimedOut (PlacesView *view);
1307+
1308 private:
1309 PlaceFactory *_factory;
1310 nux::HLayout *_layout;
1311 nux::LayeredLayout *_layered_layout;
1312 PlacesSearchBar *_search_bar;
1313 PlacesHomeView *_home_view;
1314+ PlacesEmptyView *_empty_view;
1315 PlaceEntryHome *_home_entry;
1316 PlaceEntry *_entry;
1317 sigc::connection _group_added_conn;
1318 sigc::connection _result_added_conn;
1319 sigc::connection _result_removed_conn;
1320+ sigc::connection _search_finished_conn;
1321
1322 PlacesResultsController *_results_controller;
1323 PlacesResultsView *_results_view;
1324@@ -154,6 +164,10 @@
1325 gint64 _resize_start_time;
1326
1327 PlaceEntry *_alt_f2_entry;
1328+
1329+ guint _n_results;
1330+ guint _searching_timeout;
1331+ bool _pending_activation;
1332 };
1333
1334 #endif // PANEL_HOME_BUTTON_H
1335
1336=== modified file 'src/StaticCairoText.cpp'
1337--- src/StaticCairoText.cpp 2011-03-21 10:20:57 +0000
1338+++ src/StaticCairoText.cpp 2011-03-24 01:52:23 +0000
1339@@ -49,6 +49,7 @@
1340 SetMinimumSize (1, 1);
1341 _ellipsize = NUX_ELLIPSIZE_END;
1342 _align = NUX_ALIGN_LEFT;
1343+ _valign = NUX_ALIGN_TOP;
1344 _fontstring = NULL;
1345 SetCanFocus (false);
1346 }
1347@@ -80,6 +81,13 @@
1348 NeedRedraw ();
1349 }
1350
1351+void
1352+StaticCairoText::SetTextVerticalAlignment (AlignState state)
1353+{
1354+ _valign = state;
1355+ QueueDraw ();
1356+}
1357+
1358 void StaticCairoText::PreLayoutManagement ()
1359 {
1360 int textWidth = 0;
1361@@ -169,10 +177,10 @@
1362 Color col = Color::Black;
1363 col.SetAlpha (0.0f);
1364 gfxContext.QRP_Color (base.x,
1365- base.y,
1366- base.width,
1367- base.height,
1368- col);
1369+ base.y,
1370+ base.width,
1371+ base.height,
1372+ col);
1373
1374 gfxContext.QRP_1Tex (base.x,
1375 base.y + ((base.height - _cached_extent_height)/2),
1376
1377=== modified file 'src/StaticCairoText.h'
1378--- src/StaticCairoText.h 2011-03-10 12:42:07 +0000
1379+++ src/StaticCairoText.h 2011-03-24 01:52:23 +0000
1380@@ -54,6 +54,8 @@
1381 NUX_ALIGN_LEFT,
1382 NUX_ALIGN_CENTRE,
1383 NUX_ALIGN_RIGHT,
1384+ NUX_ALIGN_TOP = NUX_ALIGN_LEFT,
1385+ NUX_ALIGN_BOTTOM = NUX_ALIGN_RIGHT
1386 } AlignState;
1387
1388 StaticCairoText (const TCHAR* text, NUX_FILE_LINE_PROTO);
1389@@ -82,6 +84,7 @@
1390 void SetTextColor (Color textColor);
1391 void SetTextEllipsize (EllipsizeState state);
1392 void SetTextAlignment (AlignState state);
1393+ void SetTextVerticalAlignment (AlignState state);
1394 void SetFont (const char *fontstring);
1395
1396 void GetTextExtents (int &width, int &height);
1397@@ -99,6 +102,7 @@
1398 Color _textColor;
1399 EllipsizeState _ellipsize;
1400 AlignState _align;
1401+ AlignState _valign;
1402 char* _fontstring;
1403
1404 CairoGraphics* _cairoGraphics;
1405
1406=== modified file 'tests/CMakeLists.txt'
1407--- tests/CMakeLists.txt 2011-03-24 00:35:26 +0000
1408+++ tests/CMakeLists.txt 2011-03-24 01:52:23 +0000
1409@@ -153,10 +153,19 @@
1410 add_executable (test-places
1411 TestPlaces.cpp
1412 ${PLACES_COMMON_SOURCE}
1413+<<<<<<< TREE
1414+=======
1415+ ../src/PlacesController.cpp
1416+ ../src/PlacesController.h
1417+ ../src/PlacesEmptyView.cpp
1418+ ../src/PlacesEmptyView.h
1419+>>>>>>> MERGE-SOURCE
1420 ../src/PlacesHomeView.cpp
1421 ../src/PlacesHomeView.h
1422 ../src/PlacesSearchBar.cpp
1423 ../src/PlacesSearchBar.h
1424+ ../src/PlacesSearchBarSpinner.cpp
1425+ ../src/PlacesSearchBarSpinner.h
1426 ../src/PlacesResultsController.cpp
1427 ../src/PlacesResultsController.h
1428 ../src/PlacesResultsView.h