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

Proposed by Neil J. Patel
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) Approve
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.
Revision history for this message
Jay Taoko (jaytaoko) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'resources/search_clear_alone.png'
0Binary 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 differ0Binary 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
=== added file 'resources/search_clear_spinner.png'
1Binary 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 differ1Binary 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
=== modified file 'src/IconLoader.cpp'
--- src/IconLoader.cpp 2011-02-09 20:44:45 +0000
+++ src/IconLoader.cpp 2011-03-24 01:52:23 +0000
@@ -109,23 +109,46 @@
109 guint size,109 guint size,
110 IconLoaderCallback slot)110 IconLoaderCallback slot)
111{111{
112 GFile *file;
113 gchar *uri;
114
115 g_return_if_fail (filename);
116 g_return_if_fail (size > 1);
117
118 if (_no_load)
119 return;
120
121 file = g_file_new_for_path (filename);
122 uri = g_file_get_uri (file);
123
124 LoadFromURI (uri, size, slot);
125
126 g_free (uri);
127 g_object_unref (file);
128}
129
130void
131IconLoader::LoadFromURI (const char *uri,
132 guint size,
133 IconLoaderCallback slot)
134{
112 char *key;135 char *key;
113136
114 g_return_if_fail (filename);137 g_return_if_fail (uri);
115 g_return_if_fail (size > 1);138 g_return_if_fail (size > 1);
116139
117 if (_no_load)140 if (_no_load)
118 return;141 return;
119142
120 key = Hash (filename, size);143 key = Hash (uri, size);
121144
122 if (CacheLookup (key, filename, size, slot))145 if (CacheLookup (key, uri, size, slot))
123 {146 {
124 g_free (key);147 g_free (key);
125 return;148 return;
126 }149 }
127150
128 QueueTask (key, filename, size, slot, REQUEST_TYPE_FILENAME);151 QueueTask (key, uri, size, slot, REQUEST_TYPE_URI);
129152
130 g_free (key);153 g_free (key);
131}154}
@@ -207,9 +230,9 @@
207 {230 {
208 task_complete = ProcessGIconTask (task);231 task_complete = ProcessGIconTask (task);
209 }232 }
210 else if (task->type == REQUEST_TYPE_FILENAME)233 else if (task->type == REQUEST_TYPE_URI)
211 {234 {
212 task_complete = ProcessFilenameTask (task);235 task_complete = ProcessURITask (task);
213 }236 }
214 else237 else
215 {238 {
@@ -285,9 +308,9 @@
285 file = g_file_icon_get_file (G_FILE_ICON (icon));308 file = g_file_icon_get_file (G_FILE_ICON (icon));
286309
287 g_free (task->data);310 g_free (task->data);
288 task->type = REQUEST_TYPE_FILENAME;311 task->type = REQUEST_TYPE_URI;
289 task->data = g_file_get_path (file);312 task->data = g_file_get_uri (file);
290 ret = ProcessFilenameTask (task);313 ret = ProcessURITask (task);
291314
292 g_object_unref (icon);315 g_object_unref (icon);
293316
@@ -362,11 +385,11 @@
362}385}
363386
364bool387bool
365IconLoader::ProcessFilenameTask (IconLoaderTask *task)388IconLoader::ProcessURITask (IconLoaderTask *task)
366{389{
367 GFile *file;390 GFile *file;
368391
369 file = g_file_new_for_path (task->data);392 file = g_file_new_for_uri (task->data);
370393
371 g_file_load_contents_async (file,394 g_file_load_contents_async (file,
372 NULL,395 NULL,
@@ -378,7 +401,7 @@
378}401}
379402
380void403void
381IconLoader::ProcessFilenameTaskReady (IconLoaderTask *task, char *contents, gsize length)404IconLoader::ProcessURITaskReady (IconLoaderTask *task, char *contents, gsize length)
382{405{
383 GdkPixbuf *pixbuf = NULL;406 GdkPixbuf *pixbuf = NULL;
384 GInputStream *stream;407 GInputStream *stream;
@@ -470,7 +493,7 @@
470493
471 if (g_file_load_contents_finish (G_FILE (obj), res, &contents, &length, NULL, &error))494 if (g_file_load_contents_finish (G_FILE (obj), res, &contents, &length, NULL, &error))
472 {495 {
473 task->self->ProcessFilenameTaskReady (task, contents, length);496 task->self->ProcessURITaskReady (task, contents, length);
474497
475 g_free (contents);498 g_free (contents);
476 }499 }
477500
=== modified file 'src/IconLoader.h'
--- src/IconLoader.h 2011-02-09 12:24:11 +0000
+++ src/IconLoader.h 2011-03-24 01:52:23 +0000
@@ -47,13 +47,17 @@
47 void LoadFromFilename (const char *filename,47 void LoadFromFilename (const char *filename,
48 guint size,48 guint size,
49 IconLoaderCallback slot);49 IconLoaderCallback slot);
50
51 void LoadFromURI (const char *uri,
52 guint size,
53 IconLoaderCallback slot);
50private:54private:
5155
52 enum IconLoaderRequestType56 enum IconLoaderRequestType
53 {57 {
54 REQUEST_TYPE_ICON_NAME=0,58 REQUEST_TYPE_ICON_NAME=0,
55 REQUEST_TYPE_GICON_STRING,59 REQUEST_TYPE_GICON_STRING,
56 REQUEST_TYPE_FILENAME60 REQUEST_TYPE_URI,
57 };61 };
5862
59 struct IconLoaderTask63 struct IconLoaderTask
@@ -80,8 +84,8 @@
80 bool ProcessTask (IconLoaderTask *task);84 bool ProcessTask (IconLoaderTask *task);
81 bool ProcessIconNameTask (IconLoaderTask *task);85 bool ProcessIconNameTask (IconLoaderTask *task);
82 bool ProcessGIconTask (IconLoaderTask *task);86 bool ProcessGIconTask (IconLoaderTask *task);
83 bool ProcessFilenameTask (IconLoaderTask *task);87 bool ProcessURITask (IconLoaderTask *task);
84 void ProcessFilenameTaskReady (IconLoaderTask *task, char *contents, gsize length);88 void ProcessURITaskReady (IconLoaderTask *task, char *contents, gsize length);
85 bool Iteration ();89 bool Iteration ();
86 void FreeTask (IconLoaderTask *task);90 void FreeTask (IconLoaderTask *task);
8791
8892
=== modified file 'src/IconTexture.cpp'
--- src/IconTexture.cpp 2011-03-13 19:01:59 +0000
+++ src/IconTexture.cpp 2011-03-24 01:52:23 +0000
@@ -113,6 +113,11 @@
113 sigc::mem_fun (this, &IconTexture::IconLoaded));113 sigc::mem_fun (this, &IconTexture::IconLoaded));
114 g_object_unref (icon);114 g_object_unref (icon);
115 }115 }
116 else if (g_str_has_prefix (_icon_name, "http://"))
117 {
118 IconLoader::GetDefault ()->LoadFromURI (_icon_name,
119 _size, sigc::mem_fun (this, &IconTexture::IconLoaded));
120 }
116 else121 else
117 {122 {
118 IconLoader::GetDefault ()->LoadFromIconName (_icon_name,123 IconLoader::GetDefault ()->LoadFromIconName (_icon_name,
119124
=== modified file 'src/PanelMenuView.cpp'
--- src/PanelMenuView.cpp 2011-03-23 16:43:07 +0000
+++ src/PanelMenuView.cpp 2011-03-24 01:52:23 +0000
@@ -458,6 +458,12 @@
458PanelMenuView::Refresh ()458PanelMenuView::Refresh ()
459{459{
460 nux::Geometry geo = GetGeometry ();460 nux::Geometry geo = GetGeometry ();
461
462 // We can get into a race that causes the geometry to be wrong as there hasn't been a layout
463 // cycle before the first callback. This is to protect from that.
464 if (geo.width > _monitor_geo.width)
465 return;
466
461 char *label = GetActiveViewName ();467 char *label = GetActiveViewName ();
462 PangoLayout *layout = NULL;468 PangoLayout *layout = NULL;
463 PangoFontDescription *desc = NULL;469 PangoFontDescription *desc = NULL;
@@ -1026,6 +1032,7 @@
1026PanelMenuView::SetMonitor (int monitor)1032PanelMenuView::SetMonitor (int monitor)
1027{1033{
1028 _monitor = monitor;1034 _monitor = monitor;
1035 _monitor_geo = UScreen::GetDefault ()->GetMonitorGeometry (_monitor);
1029}1036}
10301037
1031bool1038bool
10321039
=== modified file 'src/PanelMenuView.h'
--- src/PanelMenuView.h 2011-03-22 16:56:41 +0000
+++ src/PanelMenuView.h 2011-03-24 01:52:23 +0000
@@ -139,5 +139,6 @@
139 int _monitor;139 int _monitor;
140 guint32 _active_xid;140 guint32 _active_xid;
141 guint32 _active_moved_id;141 guint32 _active_moved_id;
142 nux::Geometry _monitor_geo;
142};143};
143#endif144#endif
144145
=== modified file 'src/PlaceEntry.h'
--- src/PlaceEntry.h 2011-03-15 10:39:09 +0000
+++ src/PlaceEntry.h 2011-03-24 01:52:23 +0000
@@ -162,6 +162,8 @@
162 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&> global_group_added;162 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&> global_group_added;
163 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_added;163 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_added;
164 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_removed;164 sigc::signal<void, PlaceEntry *, PlaceEntryGroup&, PlaceEntryResult&> global_result_removed;
165
166 sigc::signal<void, const char *, guint32, std::map<const char *, const char *>&> search_finished;
165};167};
166168
167#endif // PLACE_ENTRY_H169#endif // PLACE_ENTRY_H
168170
=== modified file 'src/PlaceEntryHome.cpp'
--- src/PlaceEntryHome.cpp 2011-03-17 13:56:52 +0000
+++ src/PlaceEntryHome.cpp 2011-03-24 01:52:23 +0000
@@ -62,7 +62,8 @@
6262
6363
64PlaceEntryHome::PlaceEntryHome (PlaceFactory *factory)64PlaceEntryHome::PlaceEntryHome (PlaceFactory *factory)
65: _factory (factory)65: _factory (factory),
66 _n_searches_done (0)
66{67{
67 LoadExistingEntries ();68 LoadExistingEntries ();
68 _factory->place_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnPlaceAdded));69 _factory->place_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnPlaceAdded));
@@ -117,10 +118,14 @@
117{118{
118 PlaceEntryGroupHome group (entry);119 PlaceEntryGroupHome group (entry);
119120
121 if (!entry->ShowInGlobal ())
122 return;
123
120 _entries.push_back (entry);124 _entries.push_back (entry);
121125
122 entry->global_result_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultAdded));126 entry->global_result_added.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultAdded));
123 entry->global_result_removed.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultRemoved));127 entry->global_result_removed.connect (sigc::mem_fun (this, &PlaceEntryHome::OnResultRemoved));
128 entry->search_finished.connect (sigc::mem_fun (this, &PlaceEntryHome::OnSearchFinished));
124129
125 group_added.emit (this, group);130 group_added.emit (this, group);
126}131}
@@ -241,6 +246,9 @@
241{246{
242 std::vector<PlaceEntry *>::iterator it, eit = _entries.end ();247 std::vector<PlaceEntry *>::iterator it, eit = _entries.end ();
243248
249 _n_searches_done = 0;
250 _last_search = search;
251
244 for (it = _entries.begin (); it != eit; ++it)252 for (it = _entries.begin (); it != eit; ++it)
245 {253 {
246 (*it)->SetGlobalSearch (search, hints);254 (*it)->SetGlobalSearch (search, hints);
@@ -313,3 +321,19 @@
313 entry->ActivateGlobalResult (id);321 entry->ActivateGlobalResult (id);
314 }322 }
315}323}
324
325void
326PlaceEntryHome::OnSearchFinished (const char *search_string,
327 guint32 section_id,
328 std::map<const char *, const char *>& hints)
329{
330 if (_last_search == search_string)
331 {
332 _n_searches_done++;
333 if (_n_searches_done == _entries.size ())
334 {
335 search_finished.emit (search_string, section_id, hints);
336 }
337 }
338}
339
316340
=== modified file 'src/PlaceEntryHome.h'
--- src/PlaceEntryHome.h 2011-03-17 13:56:52 +0000
+++ src/PlaceEntryHome.h 2011-03-24 01:52:23 +0000
@@ -85,6 +85,9 @@
85 void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);85 void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
86 void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);86 void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
87 void OnForeachResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);87 void OnForeachResult (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
88 void OnSearchFinished (const char *search_string,
89 guint32 section_id,
90 std::map<const char *, const char *>& hints);
8891
89public:92public:
90 PlaceFactory *_factory;93 PlaceFactory *_factory;
@@ -94,6 +97,9 @@
94 std::map<const void *, PlaceEntry *> _id_to_entry;97 std::map<const void *, PlaceEntry *> _id_to_entry;
9598
96 ResultForeachCallback _foreach_callback;99 ResultForeachCallback _foreach_callback;
100
101 guint _n_searches_done;
102 std::string _last_search;
97};103};
98104
99#endif // PLACE_ENTRY_HOME_H105#endif // PLACE_ENTRY_HOME_H
100106
=== modified file 'src/PlaceEntryRemote.cpp'
--- src/PlaceEntryRemote.cpp 2011-03-17 13:33:30 +0000
+++ src/PlaceEntryRemote.cpp 2011-03-24 01:52:23 +0000
@@ -1025,5 +1025,17 @@
1025{ 1025{
1026 PlaceEntryRemote *self = static_cast<PlaceEntryRemote *> (user_data); 1026 PlaceEntryRemote *self = static_cast<PlaceEntryRemote *> (user_data);
10271027
1028 g_debug ("%p: %s", self, sender_name);1028 if (g_strcmp0 (signal_name, "SearchFinished") == 0)
1029 {
1030 guint32 section = 0;
1031 gchar *search_string = NULL;
1032 GVariantIter *iter;
1033 std::map<const char *, const char*> hints;
1034
1035 g_variant_get (parameters, "(usa{ss})", &section, &search_string, &iter);
1036 self->search_finished.emit (search_string, section, hints);
1037
1038 g_free (search_string);
1039 g_variant_iter_free (iter);
1040 }
1029}1041}
10301042
=== added file 'src/PlacesEmptyView.cpp'
--- src/PlacesEmptyView.cpp 1970-01-01 00:00:00 +0000
+++ src/PlacesEmptyView.cpp 2011-03-24 01:52:23 +0000
@@ -0,0 +1,88 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#include "PlacesEmptyView.h"
20
21#include "PlacesStyle.h"
22
23NUX_IMPLEMENT_OBJECT_TYPE (PlacesEmptyView);
24
25PlacesEmptyView::PlacesEmptyView ()
26: nux::View (NUX_TRACKER_LOCATION)
27{
28 SetLayout (new nux::HLayout (NUX_TRACKER_LOCATION));
29
30 _text = new nux::StaticCairoText ("");
31 _text->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_END);
32 _text->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
33 _text->SetTextVerticalAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
34 _text->SetTextColor (nux::Color (1.0f, 1.0f, 1.0f, 0.8f));
35
36 GetCompositionLayout ()->AddSpace (1, 1);
37 GetCompositionLayout ()->AddView (_text, 1, nux::eCenter, nux::eFix);
38 GetCompositionLayout ()->AddSpace (1, 1);
39}
40
41PlacesEmptyView::~PlacesEmptyView ()
42{
43
44}
45
46long
47PlacesEmptyView::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
48{
49 return GetCompositionLayout ()->ProcessEvent (ievent, TraverseInfo, ProcessEventInfo);
50}
51
52void
53PlacesEmptyView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
54{
55}
56
57void
58PlacesEmptyView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
59{
60 GetCompositionLayout ()->ProcessDraw (GfxContext, force_draw);
61}
62
63void
64PlacesEmptyView::SetText (const char *text)
65{
66 char *clean;
67 char *markup;
68
69 clean = g_markup_escape_text (text, -1);
70 markup = g_strdup_printf ("<big>%s</big>", clean);
71
72 _text->SetText (markup);
73
74 g_free (clean);
75 g_free (markup);
76}
77
78const gchar*
79PlacesEmptyView::GetName ()
80{
81 return "PlacesEmptyView";
82}
83
84void
85PlacesEmptyView::AddProperties (GVariantBuilder *builder)
86{
87
88}
089
=== added file 'src/PlacesEmptyView.h'
--- src/PlacesEmptyView.h 1970-01-01 00:00:00 +0000
+++ src/PlacesEmptyView.h 2011-03-24 01:52:23 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright (C) 2010 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */
18
19#ifndef PLACES_EMPTY_VIEW_H
20#define PLACES_EMPTY_VIEW_H
21
22#include <Nux/Nux.h>
23#include <Nux/View.h>
24#include <NuxGraphics/GraphicsEngine.h>
25#include <Nux/HLayout.h>
26#include <Nux/VLayout.h>
27#include "Introspectable.h"
28#include "StaticCairoText.h"
29
30class PlacesEmptyView : public nux::View, public Introspectable
31{
32 NUX_DECLARE_OBJECT_TYPE (PlacesEmptyView, nux::View);
33public:
34
35 PlacesEmptyView ();
36 ~PlacesEmptyView ();
37
38 // nux::View overrides
39 long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
40 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
41 void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
42
43 void SetText (const char *text);
44
45protected:
46
47 const gchar* GetName ();
48 void AddProperties (GVariantBuilder *builder);
49
50private:
51
52 nux::StaticCairoText *_text;
53};
54
55#endif // PLACES_EMPTY_VIEW_H
056
=== modified file 'src/PlacesGroupController.cpp'
--- src/PlacesGroupController.cpp 2011-03-23 17:55:51 +0000
+++ src/PlacesGroupController.cpp 2011-03-24 01:52:23 +0000
@@ -19,6 +19,7 @@
19#include "PlacesGroupController.h"19#include "PlacesGroupController.h"
2020
21#include <Nux/GridHLayout.h>21#include <Nux/GridHLayout.h>
22#include <glib/gi18n-lib.h>
2223
23#include "PlacesStyle.h"24#include "PlacesStyle.h"
24#include "PlacesSimpleTile.h"25#include "PlacesSimpleTile.h"
@@ -55,12 +56,22 @@
5556
56 _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));57 _group->expanded.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
57 style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));58 style->columns_changed.connect (sigc::mem_fun (this, &PlacesGroupController::CheckTiles));
59
60 _more_tile = new PlacesSimpleTile ("gtk-add",
61 _("Load more results..."),
62 style->GetTileIconSize (),
63 false,
64 "more-tile");
65 _more_tile->Reference ();
66 _more_tile->sigClick.connect (sigc::mem_fun (this, &PlacesGroupController::MoreTileClicked));
58}67}
5968
60PlacesGroupController::~PlacesGroupController ()69PlacesGroupController::~PlacesGroupController ()
61{70{
62 if (_check_tiles_id)71 if (_check_tiles_id)
63 g_source_remove (_check_tiles_id);72 g_source_remove (_check_tiles_id);
73 if (_more_tile)
74 _more_tile->UnReference ();
64}75}
6576
66const void *77const void *
@@ -117,6 +128,13 @@
117}128}
118129
119void130void
131PlacesGroupController::MoreTileClicked (PlacesTile *tile)
132{
133 if (!_check_tiles_id)
134 _check_tiles_id = g_timeout_add (150, (GSourceFunc)CheckTilesTimeout, this);
135}
136
137void
120PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)138PlacesGroupController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)
121{139{
122 PlacesStyle *style = PlacesStyle::GetDefault ();140 PlacesStyle *style = PlacesStyle::GetDefault ();
@@ -178,6 +196,9 @@
178 else196 else
179 n_to_show = style->GetDefaultNColumns ();197 n_to_show = style->GetDefaultNColumns ();
180198
199 if (_more_tile->GetParentObject ())
200 _group->GetChildLayout ()->RemoveChildObject (_more_tile);
201
181 if (_id_to_tile.size () == n_to_show)202 if (_id_to_tile.size () == n_to_show)
182 {203 {
183 // Hoorah204 // Hoorah
@@ -185,6 +206,9 @@
185 else if (_id_to_tile.size () < n_to_show)206 else if (_id_to_tile.size () < n_to_show)
186 {207 {
187 std::vector<const void *>::iterator it = _queue.begin ();208 std::vector<const void *>::iterator it = _queue.begin ();
209 int max_rows_to_add = style->GetDefaultNColumns () * 15;
210 int max_rows_per_click = max_rows_to_add * 3;
211 int n_tiles = _id_to_tile.size ();
188212
189 if (_queue.size () >= n_to_show)213 if (_queue.size () >= n_to_show)
190 {214 {
@@ -194,6 +218,33 @@
194 {218 {
195 _entry->GetResult ((*it), sigc::mem_fun (this, &PlacesGroupController::AddTile));219 _entry->GetResult ((*it), sigc::mem_fun (this, &PlacesGroupController::AddTile));
196 it++;220 it++;
221 n_tiles++;
222
223 if (n_tiles % max_rows_to_add == 0)
224 {
225 // What we do over here is add a "Load more results..." button which will then kick off
226 // another fill cycle. Generally the user will never need to see this, but in the case
227 // of large results sets, this gives us a chance of not blocking the entire WM for
228 // 20 secs as we load in 2000+ results.
229 if (n_tiles % max_rows_per_click == 0)
230 {
231 _group->GetChildLayout ()->AddView (_more_tile);
232 }
233 else
234 {
235 // The idea here is that we increase the timeouts of adding tiles in relation to
236 // how big the view is getting. In theory it shouldn't be needed but in reality with
237 // Nux having to do so many calculations it is needed. Ideally we'd be rendering
238 // the entire results view as a scene with re-usable tiles but that would have been
239 // too difficult to get right with a11y, so instead we need to just deal with this
240 // the best way we can.
241 if (!_check_tiles_id)
242 _check_tiles_id = g_timeout_add (350 * n_tiles/max_rows_to_add,
243 (GSourceFunc)CheckTilesTimeout,
244 this);
245 }
246 return;
247 }
197 }248 }
198 }249 }
199 }250 }
200251
=== modified file 'src/PlacesGroupController.h'
--- src/PlacesGroupController.h 2011-03-13 21:22:04 +0000
+++ src/PlacesGroupController.h 2011-03-24 01:52:23 +0000
@@ -54,6 +54,7 @@
54 void CheckTiles ();54 void CheckTiles ();
55 static gboolean CheckTilesTimeout (PlacesGroupController *self);55 static gboolean CheckTilesTimeout (PlacesGroupController *self);
56 void TileClicked (PlacesTile *tile);56 void TileClicked (PlacesTile *tile);
57 void MoreTileClicked (PlacesTile *tile);
5758
58private:59private:
59 PlaceEntry *_entry;60 PlaceEntry *_entry;
@@ -62,6 +63,7 @@
62 std::map<const void *, PlacesTile *> _id_to_tile;63 std::map<const void *, PlacesTile *> _id_to_tile;
63 guint _check_tiles_id;64 guint _check_tiles_id;
64 std::vector<const void *> _queue;65 std::vector<const void *> _queue;
66 PlacesTile *_more_tile;
65};67};
6668
67#endif // PLACES_GROUP_CONTROLLER_H69#endif // PLACES_GROUP_CONTROLLER_H
6870
=== modified file 'src/PlacesSearchBar.cpp'
--- src/PlacesSearchBar.cpp 2011-03-23 15:44:45 +0000
+++ src/PlacesSearchBar.cpp 2011-03-24 01:52:23 +0000
@@ -60,12 +60,12 @@
60 _layout = new nux::HLayout (NUX_TRACKER_LOCATION);60 _layout = new nux::HLayout (NUX_TRACKER_LOCATION);
61 _layout->SetHorizontalInternalMargin (12);61 _layout->SetHorizontalInternalMargin (12);
6262
63 _search_icon = new nux::TextureArea (NUX_TRACKER_LOCATION);63 _spinner = new PlacesSearchBarSpinner ();
64 _search_icon->SetTexture (icon);64 _spinner->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());
65 _search_icon->SetMinMaxSize (icon->GetWidth (), icon->GetHeight ());65 //_spinner->SetMaximumWidth (icon->GetWidth ());
66 _layout->AddView (_search_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);66 _layout->AddView (_spinner, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
67 _search_icon->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));67 _spinner->OnMouseClick.connect (sigc::mem_fun (this, &PlacesSearchBar::OnClearClicked));
68 _search_icon->SetCanFocus (false);68 _spinner->SetCanFocus (false);
6969
70 _layered_layout = new nux::LayeredLayout ();70 _layered_layout = new nux::LayeredLayout ();
7171
@@ -243,8 +243,7 @@
243void243void
244PlacesSearchBar::OnSearchChanged (nux::TextEntry *text_entry)244PlacesSearchBar::OnSearchChanged (nux::TextEntry *text_entry)
245{245{
246 PlacesStyle *style = PlacesStyle::GetDefault ();246 bool is_empty;
247 bool is_empty;
248247
249 if (_live_search_timeout)248 if (_live_search_timeout)
250 g_source_remove (_live_search_timeout);249 g_source_remove (_live_search_timeout);
@@ -259,7 +258,7 @@
259258
260 is_empty = g_strcmp0 (_pango_entry->GetText ().c_str (), "") == 0;259 is_empty = g_strcmp0 (_pango_entry->GetText ().c_str (), "") == 0;
261 _hint->SetVisible (is_empty);260 _hint->SetVisible (is_empty);
262 _search_icon->SetTexture (is_empty ? style->GetSearchReadyIcon () : style->GetSearchClearIcon ());261 _spinner->SetState (is_empty ? STATE_READY : STATE_SEARCHING);
263262
264 _hint->QueueDraw ();263 _hint->QueueDraw ();
265 _pango_entry->QueueDraw ();264 _pango_entry->QueueDraw ();
@@ -292,7 +291,7 @@
292 if (_pango_entry->GetText () != "")291 if (_pango_entry->GetText () != "")
293 {292 {
294 _pango_entry->SetText ("");293 _pango_entry->SetText ("");
295 _search_icon->SetTexture (PlacesStyle::GetDefault ()->GetSearchReadyIcon ());294 _spinner->SetState (STATE_READY);
296 EmitLiveSearch ();295 EmitLiveSearch ();
297 }296 }
298}297}
@@ -310,6 +309,12 @@
310}309}
311310
312void311void
312PlacesSearchBar::OnSearchFinished ()
313{
314 _spinner->SetState (STATE_CLEAR);
315}
316
317void
313PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self)318PlacesSearchBar::OnFontChanged (GObject *object, GParamSpec *pspec, PlacesSearchBar *self)
314{319{
315#define HOW_LARGE 8320#define HOW_LARGE 8
316321
=== modified file 'src/PlacesSearchBar.h'
--- src/PlacesSearchBar.h 2011-03-15 14:23:03 +0000
+++ src/PlacesSearchBar.h 2011-03-24 01:52:23 +0000
@@ -32,6 +32,8 @@
32#include "Nux/EditTextBox.h"32#include "Nux/EditTextBox.h"
33#include "Nux/TextEntry.h"33#include "Nux/TextEntry.h"
3434
35#include "PlacesSearchBarSpinner.h"
36
35#include "PlaceEntry.h"37#include "PlaceEntry.h"
3638
37class PlacesView;39class PlacesView;
@@ -53,6 +55,7 @@
53 void SetActiveEntry (PlaceEntry *entry,55 void SetActiveEntry (PlaceEntry *entry,
54 guint section_id,56 guint section_id,
55 const char *search_string);57 const char *search_string);
58 void OnSearchFinished ();
5659
57 sigc::signal<void, const char *> search_changed;60 sigc::signal<void, const char *> search_changed;
58 sigc::signal<void> activated;61 sigc::signal<void> activated;
@@ -89,7 +92,7 @@
89 guint _live_search_timeout;92 guint _live_search_timeout;
9093
91 friend class PlacesView;94 friend class PlacesView;
92 nux::TextureArea *_search_icon;95 PlacesSearchBarSpinner *_spinner;
93 nux::ComboBoxSimple *_combo;96 nux::ComboBoxSimple *_combo;
94};97};
9598
9699
=== added file 'src/PlacesSearchBarSpinner.cpp'
--- src/PlacesSearchBarSpinner.cpp 1970-01-01 00:00:00 +0000
+++ src/PlacesSearchBarSpinner.cpp 2011-03-24 01:52:23 +0000
@@ -0,0 +1,183 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2011 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18 */
19
20#include "PlacesSearchBarSpinner.h"
21
22#include <Nux/VLayout.h>
23
24#include "PlacesStyle.h"
25
26NUX_IMPLEMENT_OBJECT_TYPE (PlacesSearchBarSpinner);
27
28PlacesSearchBarSpinner::PlacesSearchBarSpinner ()
29: nux::View (NUX_TRACKER_LOCATION),
30 _state (STATE_READY),
31 _rotation (0.0f),
32 _spinner_timeout (0)
33{
34 PlacesStyle *style = PlacesStyle::GetDefault ();
35
36 _search_ready = style->GetSearchReadyIcon ();
37 _clear_full = style->GetSearchClearIcon ();
38 _clear_alone = style->GetSearchClearAloneIcon ();
39 _clear_spinner = style->GetSearchClearSpinnerIcon ();
40
41 _2d_rotate.Identity ();
42 _2d_rotate.Rotate_z (0.0);
43}
44
45PlacesSearchBarSpinner::~PlacesSearchBarSpinner ()
46{
47
48}
49
50long
51PlacesSearchBarSpinner::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
52{
53 return PostProcessEvent2 (ievent, TraverseInfo, ProcessEventInfo);
54}
55
56void
57PlacesSearchBarSpinner::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
58{
59 nux::Geometry geo = GetGeometry ();
60 nux::TexCoordXForm texxform;
61
62 GfxContext.PushClippingRectangle (geo);
63
64 nux::GetPainter ().PaintBackground (GfxContext, geo);
65
66 texxform.SetTexCoordType (nux::TexCoordXForm::OFFSET_COORD);
67 texxform.SetWrap (nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
68 texxform.min_filter = nux::TEXFILTER_LINEAR;
69 texxform.mag_filter = nux::TEXFILTER_LINEAR;
70
71 if (_state == STATE_READY)
72 {
73 GfxContext.QRP_1Tex (geo.x + ((geo.width - _search_ready->GetWidth ())/2),
74 geo.y + ((geo.height - _search_ready->GetHeight ())/2),
75 _search_ready->GetWidth (),
76 _search_ready->GetHeight (),
77 _search_ready->GetDeviceTexture (),
78 texxform,
79 nux::Color::White);
80 }
81 else if (_state == STATE_SEARCHING)
82 {
83 nux::Geometry clear_geo (geo.x + ((geo.width - _clear_spinner->GetWidth ())/2),
84 geo.y + ((geo.height - _clear_spinner->GetHeight ())/2),
85 _clear_spinner->GetWidth (),
86 _clear_spinner->GetHeight ());
87
88 GfxContext.PushModelViewMatrix (nux::Matrix4::TRANSLATE(-clear_geo.x - clear_geo.width / 2,
89 -clear_geo.y - clear_geo.height / 2, 0));
90 GfxContext.PushModelViewMatrix (_2d_rotate);
91 GfxContext.PushModelViewMatrix (nux::Matrix4::TRANSLATE(clear_geo.x + clear_geo.width/ 2,
92 clear_geo.y + clear_geo.height / 2, 0));
93
94 GfxContext.QRP_1Tex (clear_geo.x,
95 clear_geo.y,
96 clear_geo.width,
97 clear_geo.height,
98 _clear_spinner->GetDeviceTexture (),
99 texxform,
100 nux::Color::White);
101
102 GfxContext.PopModelViewMatrix ();
103 GfxContext.PopModelViewMatrix ();
104 GfxContext.PopModelViewMatrix ();
105
106 GfxContext.QRP_1Tex (geo.x + ((geo.width - _clear_alone->GetWidth ())/2),
107 geo.y + ((geo.height - _clear_alone->GetHeight ())/2),
108 _clear_alone->GetWidth (),
109 _clear_alone->GetHeight (),
110 _clear_alone->GetDeviceTexture (),
111 texxform,
112 nux::Color::White);
113 }
114 else
115 {
116 GfxContext.QRP_1Tex (geo.x + ((geo.width - _clear_full->GetWidth ())/2),
117 geo.y + ((geo.height - _clear_full->GetHeight ())/2),
118 _clear_full->GetWidth (),
119 _clear_full->GetHeight (),
120 _clear_full->GetDeviceTexture (),
121 texxform,
122 nux::Color::White);
123 }
124
125 GfxContext.PopClippingRectangle ();
126}
127
128void
129PlacesSearchBarSpinner::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
130{
131}
132
133gboolean
134PlacesSearchBarSpinner::OnFrame (PlacesSearchBarSpinner *self)
135{
136 self->_rotation += 0.1f;
137
138 if (self->_rotation >= 360.0f)
139 self->_rotation = 0.0f;
140
141 self->_2d_rotate.Rotate_z (self->_rotation);
142
143 self->QueueDraw ();
144
145 return TRUE;
146}
147
148void
149PlacesSearchBarSpinner::SetState (SpinnerState state)
150{
151 if (_state == state)
152 return;
153
154 _state = state;
155
156 if (_spinner_timeout)
157 g_source_remove (_spinner_timeout);
158 _2d_rotate.Rotate_z (0.0f);
159 _rotation = 0.0f;
160
161 if (_state == STATE_SEARCHING)
162 {
163 _spinner_timeout = g_timeout_add (15, (GSourceFunc)PlacesSearchBarSpinner::OnFrame, this);
164 }
165
166 QueueDraw ();
167}
168
169const gchar*
170PlacesSearchBarSpinner::GetName ()
171{
172 return "PlacesSearchBarSpinner";
173}
174
175void PlacesSearchBarSpinner::AddProperties (GVariantBuilder *builder)
176{
177 nux::Geometry geo = GetGeometry ();
178
179 g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (geo.x));
180 g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));
181 g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
182 g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
183}
0184
=== added file 'src/PlacesSearchBarSpinner.h'
--- src/PlacesSearchBarSpinner.h 1970-01-01 00:00:00 +0000
+++ src/PlacesSearchBarSpinner.h 2011-03-24 01:52:23 +0000
@@ -0,0 +1,72 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2011 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18 */
19
20#ifndef PLACES_SEARCH_BAR_SPINNER_H
21#define PLACES_SEARCH_BAR_SPINNER_H
22
23#include <Nux/Nux.h>
24#include <Nux/View.h>
25#include <NuxGraphics/GraphicsEngine.h>
26#include <Nux/TextureArea.h>
27#include <NuxCore/Math/Matrix4.h>
28#include "Introspectable.h"
29
30enum SpinnerState
31{
32 STATE_READY,
33 STATE_SEARCHING,
34 STATE_CLEAR
35};
36
37class PlacesSearchBarSpinner : public Introspectable, public nux::View
38{
39 NUX_DECLARE_OBJECT_TYPE (PlacesSearchBarSpinner, nux::View);
40public:
41 PlacesSearchBarSpinner ();
42 ~PlacesSearchBarSpinner ();
43
44 long ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
45 void Draw (nux::GraphicsEngine& GfxContext, bool force_draw);
46 void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
47
48 void SetState (SpinnerState state);
49
50protected:
51 // Introspectable methods
52 const gchar * GetName ();
53 void AddProperties (GVariantBuilder *builder);
54 static gboolean OnFrame (PlacesSearchBarSpinner *self);
55
56private:
57
58private:
59 SpinnerState _state;
60
61 nux::BaseTexture *_search_ready;
62 nux::BaseTexture *_clear_full;
63 nux::BaseTexture *_clear_alone;
64 nux::BaseTexture *_clear_spinner;
65
66 nux::Matrix4 _2d_rotate;
67 float _rotation;
68
69 guint32 _spinner_timeout;
70};
71
72#endif
073
=== modified file 'src/PlacesSimpleTile.cpp'
--- src/PlacesSimpleTile.cpp 2011-03-23 10:54:22 +0000
+++ src/PlacesSimpleTile.cpp 2011-03-24 01:52:23 +0000
@@ -40,10 +40,6 @@
40 _icon (NULL),40 _icon (NULL),
41 _uri (NULL)41 _uri (NULL)
42{42{
43 //GtkSettings *settings = gtk_settings_get_default ();
44 //gchar *font = NULL;
45 //gchar *fontstring = NULL;
46
47 nux::VLayout *layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);43 nux::VLayout *layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
4844
49 _label = g_strdup (label);45 _label = g_strdup (label);
@@ -57,10 +53,6 @@
57 _cairotext = new nux::StaticCairoText (_label);53 _cairotext = new nux::StaticCairoText (_label);
58 _cairotext->SinkReference ();54 _cairotext->SinkReference ();
5955
60 //g_object_get (settings, "gtk-font-name", &font, NULL);
61 //fontstring = g_strdup_printf ("%s normal 10", font);
62
63 //_cairotext->SetFont (fontstring);
64 _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_START);56 _cairotext->SetTextEllipsize (nux::StaticCairoText::NUX_ELLIPSIZE_START);
65 _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);57 _cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
66 _cairotext->SetMaximumWidth (140);58 _cairotext->SetMaximumWidth (140);
@@ -75,9 +67,6 @@
75 SetLayout (layout);67 SetLayout (layout);
7668
77 SetDndEnabled (true, false);69 SetDndEnabled (true, false);
78
79 //g_free (font);
80 //g_free (fontstring);
81}70}
8271
8372
8473
=== modified file 'src/PlacesStyle.cpp'
--- src/PlacesStyle.cpp 2011-02-28 15:56:44 +0000
+++ src/PlacesStyle.cpp 2011-03-24 01:52:23 +0000
@@ -40,6 +40,8 @@
40 _dash_fullscreen_icon (NULL),40 _dash_fullscreen_icon (NULL),
41 _search_ready_texture (NULL),41 _search_ready_texture (NULL),
42 _search_clear_texture (NULL),42 _search_clear_texture (NULL),
43 _search_clear_alone_texture (NULL),
44 _search_clear_spinner_texture (NULL),
43 _group_unexpand_texture (NULL),45 _group_unexpand_texture (NULL),
44 _group_expand_texture (NULL)46 _group_expand_texture (NULL)
45{47{
@@ -65,6 +67,10 @@
65 _search_ready_texture->UnReference ();67 _search_ready_texture->UnReference ();
66 if (_search_clear_texture)68 if (_search_clear_texture)
67 _search_clear_texture->UnReference ();69 _search_clear_texture->UnReference ();
70 if (_search_clear_alone_texture)
71 _search_clear_alone_texture->UnReference ();
72 if (_search_clear_spinner_texture)
73 _search_clear_spinner_texture->UnReference ();
68 if (_group_unexpand_texture)74 if (_group_unexpand_texture)
69 _group_unexpand_texture->UnReference ();75 _group_unexpand_texture->UnReference ();
70 if (_group_expand_texture)76 if (_group_expand_texture)
@@ -186,6 +192,22 @@
186}192}
187193
188nux::BaseTexture *194nux::BaseTexture *
195PlacesStyle::GetSearchClearAloneIcon ()
196{
197 if (!_search_clear_alone_texture)
198 _search_clear_alone_texture = TextureFromFilename (PKGDATADIR"/search_clear_alone.png");
199 return _search_clear_alone_texture;
200}
201
202nux::BaseTexture *
203PlacesStyle::GetSearchClearSpinnerIcon ()
204{
205 if (!_search_clear_spinner_texture)
206 _search_clear_spinner_texture = TextureFromFilename (PKGDATADIR"/search_clear_spinner.png");
207 return _search_clear_spinner_texture;
208}
209
210nux::BaseTexture *
189PlacesStyle::GetGroupUnexpandIcon ()211PlacesStyle::GetGroupUnexpandIcon ()
190{212{
191 if (!_group_unexpand_texture)213 if (!_group_unexpand_texture)
192214
=== modified file 'src/PlacesStyle.h'
--- src/PlacesStyle.h 2011-02-28 15:56:44 +0000
+++ src/PlacesStyle.h 2011-03-24 01:52:23 +0000
@@ -52,6 +52,8 @@
5252
53 nux::BaseTexture * GetSearchReadyIcon ();53 nux::BaseTexture * GetSearchReadyIcon ();
54 nux::BaseTexture * GetSearchClearIcon ();54 nux::BaseTexture * GetSearchClearIcon ();
55 nux::BaseTexture * GetSearchClearAloneIcon ();
56 nux::BaseTexture * GetSearchClearSpinnerIcon ();
5557
56 nux::BaseTexture * GetGroupUnexpandIcon ();58 nux::BaseTexture * GetGroupUnexpandIcon ();
57 nux::BaseTexture * GetGroupExpandIcon ();59 nux::BaseTexture * GetGroupExpandIcon ();
@@ -80,6 +82,8 @@
8082
81 nux::BaseTexture *_search_ready_texture;83 nux::BaseTexture *_search_ready_texture;
82 nux::BaseTexture *_search_clear_texture;84 nux::BaseTexture *_search_clear_texture;
85 nux::BaseTexture *_search_clear_alone_texture;
86 nux::BaseTexture *_search_clear_spinner_texture;
8387
84 nux::BaseTexture *_group_unexpand_texture;88 nux::BaseTexture *_group_unexpand_texture;
85 nux::BaseTexture *_group_expand_texture;89 nux::BaseTexture *_group_expand_texture;
8690
=== modified file 'src/PlacesView.cpp'
--- src/PlacesView.cpp 2011-03-24 01:09:42 +0000
+++ src/PlacesView.cpp 2011-03-24 01:52:23 +0000
@@ -14,11 +14,13 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Gordon Allott <gord.allott@canonical.com>16 * Authored by: Gordon Allott <gord.allott@canonical.com>
17 * Neil Jagdish Patel <neil.patel@canonical.com>
17 */18 */
1819
19#include "config.h"20#include "config.h"
2021
21#include "Nux/Nux.h"22#include "Nux/Nux.h"
23#include "Nux/ColorArea.h"
22#include "NuxGraphics/GLThread.h"24#include "NuxGraphics/GLThread.h"
23#include "UBusMessages.h"25#include "UBusMessages.h"
2426
@@ -46,7 +48,9 @@
46 _target_height (1),48 _target_height (1),
47 _actual_height (1),49 _actual_height (1),
48 _resize_id (0),50 _resize_id (0),
49 _alt_f2_entry (NULL)51 _alt_f2_entry (NULL),
52 _searching_timeout (0),
53 _pending_activation (false)
50{54{
51 LoadPlaces ();55 LoadPlaces ();
52 _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded));56 _factory->place_added.connect (sigc::mem_fun (this, &PlacesView::OnPlaceAdded));
@@ -93,6 +97,9 @@
93 _layered_layout->AddLayer (_results_view);97 _layered_layout->AddLayer (_results_view);
94 _results_view->GetLayout ()->OnGeometryChanged.connect (sigc::mem_fun (this, &PlacesView::OnResultsViewGeometryChanged));98 _results_view->GetLayout ()->OnGeometryChanged.connect (sigc::mem_fun (this, &PlacesView::OnResultsViewGeometryChanged));
9599
100 _empty_view = new PlacesEmptyView ();
101 _layered_layout->AddLayer (_empty_view);
102
96 _layered_layout->SetActiveLayer (_home_view);103 _layered_layout->SetActiveLayer (_home_view);
97104
98 SetLayout (_layout);105 SetLayout (_layout);
@@ -123,8 +130,6 @@
123 _icon_loader = IconLoader::GetDefault ();130 _icon_loader = IconLoader::GetDefault ();
124131
125 SetActiveEntry (_home_entry, 0, "");132 SetActiveEntry (_home_entry, 0, "");
126
127 //_layout->SetFocused (true);
128}133}
129134
130PlacesView::~PlacesView ()135PlacesView::~PlacesView ()
@@ -182,6 +187,7 @@
182 nux::Geometry geo_absolute = GetAbsoluteGeometry ();187 nux::Geometry geo_absolute = GetAbsoluteGeometry ();
183 PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType ();188 PlacesSettings::DashBlurType type = PlacesSettings::GetDefault ()->GetDashBlurType ();
184 bool paint_blur = type != PlacesSettings::NO_BLUR;189 bool paint_blur = type != PlacesSettings::NO_BLUR;
190 nux::BaseTexture *corner = style->GetDashCorner ();
185191
186 GfxContext.PushClippingRectangle (geo);192 GfxContext.PushClippingRectangle (geo);
187193
@@ -190,7 +196,6 @@
190 GfxContext.GetRenderStates ().SetBlend (true);196 GfxContext.GetRenderStates ().SetBlend (true);
191 GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);197 GfxContext.GetRenderStates ().SetPremultipliedBlend (nux::SRC_OVER);
192198
193 geo.height = _actual_height;
194 _bg_blur_geo = geo;199 _bg_blur_geo = geo;
195200
196 if ((_size_mode == SIZE_MODE_HOVER))201 if ((_size_mode == SIZE_MODE_HOVER))
@@ -237,17 +242,25 @@
237 rop.SrcBlend = GL_ONE;242 rop.SrcBlend = GL_ONE;
238 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;243 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
239244
245 nux::Geometry bg_clip = geo;
246 bg_clip.width -= corner->GetWidth ();
247 bg_clip.height = _actual_height - corner->GetHeight ();
248
249 GfxContext.PushClippingRectangle (bg_clip);
250
240 gPainter.PushDrawTextureLayer (GfxContext, _bg_blur_geo,251 gPainter.PushDrawTextureLayer (GfxContext, _bg_blur_geo,
241 _bg_blur_texture,252 _bg_blur_texture,
242 texxform_blur__bg,253 texxform_blur__bg,
243 nux::Color::White,254 nux::Color::White,
244 true,255 true,
245 rop);256 rop);
257
258 GfxContext.PopClippingRectangle ();
246 }259 }
260 geo.height = _actual_height;
247261
248 if (_size_mode == SIZE_MODE_HOVER)262 if (_size_mode == SIZE_MODE_HOVER)
249 {263 {
250 nux::BaseTexture *corner = style->GetDashCorner ();
251 nux::BaseTexture *bottom = style->GetDashBottomTile ();264 nux::BaseTexture *bottom = style->GetDashBottomTile ();
252 nux::BaseTexture *right = style->GetDashRightTile ();265 nux::BaseTexture *right = style->GetDashRightTile ();
253 nux::BaseTexture *icon = style->GetDashFullscreenIcon ();266 nux::BaseTexture *icon = style->GetDashFullscreenIcon ();
@@ -412,8 +425,11 @@
412 _group_added_conn.disconnect ();425 _group_added_conn.disconnect ();
413 _result_added_conn.disconnect ();426 _result_added_conn.disconnect ();
414 _result_removed_conn.disconnect ();427 _result_removed_conn.disconnect ();
428 _search_finished_conn.disconnect ();
415429
416 _results_controller->Clear ();430 _results_controller->Clear ();
431
432 _n_results = 0;
417 }433 }
418434
419 _entry = entry;435 _entry = entry;
@@ -427,6 +443,7 @@
427 _group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded));443 _group_added_conn = _entry->group_added.connect (sigc::mem_fun (this, &PlacesView::OnGroupAdded));
428 _result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded));444 _result_added_conn = _entry->result_added.connect (sigc::mem_fun (this, &PlacesView::OnResultAdded));
429 _result_removed_conn = _entry->result_removed.connect (sigc::mem_fun (this, &PlacesView::OnResultRemoved));445 _result_removed_conn = _entry->result_removed.connect (sigc::mem_fun (this, &PlacesView::OnResultRemoved));
446 _search_finished_conn = _entry->search_finished.connect (sigc::mem_fun (this, &PlacesView::OnSearchFinished));
430 447
431 if (_entry == _home_entry && (g_strcmp0 (search_string, "") == 0))448 if (_entry == _home_entry && (g_strcmp0 (search_string, "") == 0))
432 _layered_layout->SetActiveLayer (_home_view);449 _layered_layout->SetActiveLayer (_home_view);
@@ -586,12 +603,32 @@
586void603void
587PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)604PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
588{605{
606 _n_results++;
607
608 if (_n_results <= 2
609 && (g_strcmp0 (group.GetRenderer (), "UnityEmptySearchRenderer") == 0
610 || g_strcmp0 (group.GetRenderer (), "UnityEmptySectionRenderer") == 0))
611 {
612 if (_n_results == 1)
613 _empty_view->SetText (result.GetName ());
614 _layered_layout->SetActiveLayerN (2);
615 }
616
589 _results_controller->AddResult (entry, group, result);617 _results_controller->AddResult (entry, group, result);
590}618}
591619
592void620void
593PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)621PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
594{622{
623 _n_results--;
624
625 if (_n_results <= 1
626 && (g_strcmp0 (group.GetRenderer (), "UnityEmptySearchRenderer") == 0
627 || g_strcmp0 (group.GetRenderer (), "UnityEmptySectionRenderer") == 0))
628 {
629 _layered_layout->SetActiveLayerN (1);
630 }
631
595 _results_controller->RemoveResult (entry, group, result);632 _results_controller->RemoveResult (entry, group, result);
596}633}
597634
@@ -694,6 +731,26 @@
694 _layered_layout->QueueDraw ();731 _layered_layout->QueueDraw ();
695 QueueDraw ();732 QueueDraw ();
696 }733 }
734
735 if (_searching_timeout)
736 g_source_remove (_searching_timeout);
737 _searching_timeout = 0;
738
739 if (g_strcmp0 (search_string, ""))
740 {
741 _searching_timeout = g_timeout_add (5000, (GSourceFunc)PlacesView::OnSearchTimedOut, this);
742 }
743}
744
745gboolean
746PlacesView::OnSearchTimedOut (PlacesView *view)
747{
748 std::map <const char *, const char *> hints;
749
750 view->_searching_timeout = 0;
751 view->OnSearchFinished ( "", 0, hints);
752
753 return FALSE;
697}754}
698755
699//756//
@@ -759,8 +816,17 @@
759void816void
760PlacesView::OnEntryActivated ()817PlacesView::OnEntryActivated ()
761{818{
762 if (!_results_controller->ActivateFirst ())819 if (_searching_timeout && !_pending_activation)
763 g_debug ("Cannot activate anything");820 {
821 _pending_activation = true;
822 }
823 else
824 {
825 if (!_results_controller->ActivateFirst ())
826 g_debug ("Cannot activate anything");
827
828 _pending_activation = false;
829 }
764}830}
765831
766void832void
@@ -818,6 +884,25 @@
818 OnResultsViewGeometryChanged (_results_view, geo);884 OnResultsViewGeometryChanged (_results_view, geo);
819}885}
820886
887void
888PlacesView::OnSearchFinished (const char *search_string,
889 guint32 section_id,
890 std::map<const char *, const char *>& hints)
891{
892 if (_pending_activation)
893 {
894 if (!_results_controller->ActivateFirst ())
895 g_debug ("Cannot activate anything");
896 }
897 _pending_activation = false;
898
899 if (_searching_timeout)
900 g_source_remove (_searching_timeout);
901 _searching_timeout = 0;
902
903 _search_bar->OnSearchFinished ();
904}
905
821//906//
822// Introspection907// Introspection
823//908//
824909
=== modified file 'src/PlacesView.h'
--- src/PlacesView.h 2011-03-13 14:52:14 +0000
+++ src/PlacesView.h 2011-03-24 01:52:23 +0000
@@ -14,6 +14,7 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *15 *
16 * Authored by: Gordon Allott <gord.allott@canonical.com>16 * Authored by: Gordon Allott <gord.allott@canonical.com>
17 * Neil Jagdish Patel <neil.patel@canonical.com>
17 */18 */
1819
19#ifndef PLACES_VIEW_H20#ifndef PLACES_VIEW_H
@@ -36,6 +37,7 @@
3637
37#include "PlacesSearchBar.h"38#include "PlacesSearchBar.h"
38#include "PlacesHomeView.h"39#include "PlacesHomeView.h"
40#include "PlacesEmptyView.h"
3941
40#include "PlacesResultsController.h"42#include "PlacesResultsController.h"
41#include "PlacesResultsView.h"43#include "PlacesResultsView.h"
@@ -121,17 +123,25 @@
121123
122 static gboolean OnResizeFrame (PlacesView *self);124 static gboolean OnResizeFrame (PlacesView *self);
123125
126 void OnSearchFinished (const char *search_string,
127 guint32 section_id,
128 std::map<const char *, const char *>& hints);
129
130 static gboolean OnSearchTimedOut (PlacesView *view);
131
124private:132private:
125 PlaceFactory *_factory;133 PlaceFactory *_factory;
126 nux::HLayout *_layout;134 nux::HLayout *_layout;
127 nux::LayeredLayout *_layered_layout;135 nux::LayeredLayout *_layered_layout;
128 PlacesSearchBar *_search_bar;136 PlacesSearchBar *_search_bar;
129 PlacesHomeView *_home_view;137 PlacesHomeView *_home_view;
138 PlacesEmptyView *_empty_view;
130 PlaceEntryHome *_home_entry;139 PlaceEntryHome *_home_entry;
131 PlaceEntry *_entry;140 PlaceEntry *_entry;
132 sigc::connection _group_added_conn;141 sigc::connection _group_added_conn;
133 sigc::connection _result_added_conn;142 sigc::connection _result_added_conn;
134 sigc::connection _result_removed_conn;143 sigc::connection _result_removed_conn;
144 sigc::connection _search_finished_conn;
135145
136 PlacesResultsController *_results_controller;146 PlacesResultsController *_results_controller;
137 PlacesResultsView *_results_view;147 PlacesResultsView *_results_view;
@@ -154,6 +164,10 @@
154 gint64 _resize_start_time;164 gint64 _resize_start_time;
155165
156 PlaceEntry *_alt_f2_entry;166 PlaceEntry *_alt_f2_entry;
167
168 guint _n_results;
169 guint _searching_timeout;
170 bool _pending_activation;
157};171};
158172
159#endif // PANEL_HOME_BUTTON_H173#endif // PANEL_HOME_BUTTON_H
160174
=== modified file 'src/StaticCairoText.cpp'
--- src/StaticCairoText.cpp 2011-03-21 10:20:57 +0000
+++ src/StaticCairoText.cpp 2011-03-24 01:52:23 +0000
@@ -49,6 +49,7 @@
49 SetMinimumSize (1, 1);49 SetMinimumSize (1, 1);
50 _ellipsize = NUX_ELLIPSIZE_END;50 _ellipsize = NUX_ELLIPSIZE_END;
51 _align = NUX_ALIGN_LEFT;51 _align = NUX_ALIGN_LEFT;
52 _valign = NUX_ALIGN_TOP;
52 _fontstring = NULL;53 _fontstring = NULL;
53 SetCanFocus (false);54 SetCanFocus (false);
54}55}
@@ -80,6 +81,13 @@
80 NeedRedraw ();81 NeedRedraw ();
81}82}
8283
84void
85StaticCairoText::SetTextVerticalAlignment (AlignState state)
86{
87 _valign = state;
88 QueueDraw ();
89}
90
83void StaticCairoText::PreLayoutManagement ()91void StaticCairoText::PreLayoutManagement ()
84{92{
85 int textWidth = 0;93 int textWidth = 0;
@@ -169,10 +177,10 @@
169 Color col = Color::Black;177 Color col = Color::Black;
170 col.SetAlpha (0.0f);178 col.SetAlpha (0.0f);
171 gfxContext.QRP_Color (base.x,179 gfxContext.QRP_Color (base.x,
172 base.y,180 base.y,
173 base.width,181 base.width,
174 base.height,182 base.height,
175 col);183 col);
176184
177 gfxContext.QRP_1Tex (base.x,185 gfxContext.QRP_1Tex (base.x,
178 base.y + ((base.height - _cached_extent_height)/2),186 base.y + ((base.height - _cached_extent_height)/2),
179187
=== modified file 'src/StaticCairoText.h'
--- src/StaticCairoText.h 2011-03-10 12:42:07 +0000
+++ src/StaticCairoText.h 2011-03-24 01:52:23 +0000
@@ -54,6 +54,8 @@
54 NUX_ALIGN_LEFT,54 NUX_ALIGN_LEFT,
55 NUX_ALIGN_CENTRE,55 NUX_ALIGN_CENTRE,
56 NUX_ALIGN_RIGHT,56 NUX_ALIGN_RIGHT,
57 NUX_ALIGN_TOP = NUX_ALIGN_LEFT,
58 NUX_ALIGN_BOTTOM = NUX_ALIGN_RIGHT
57 } AlignState;59 } AlignState;
5860
59 StaticCairoText (const TCHAR* text, NUX_FILE_LINE_PROTO);61 StaticCairoText (const TCHAR* text, NUX_FILE_LINE_PROTO);
@@ -82,6 +84,7 @@
82 void SetTextColor (Color textColor);84 void SetTextColor (Color textColor);
83 void SetTextEllipsize (EllipsizeState state);85 void SetTextEllipsize (EllipsizeState state);
84 void SetTextAlignment (AlignState state);86 void SetTextAlignment (AlignState state);
87 void SetTextVerticalAlignment (AlignState state);
85 void SetFont (const char *fontstring);88 void SetFont (const char *fontstring);
8689
87 void GetTextExtents (int &width, int &height);90 void GetTextExtents (int &width, int &height);
@@ -99,6 +102,7 @@
99 Color _textColor;102 Color _textColor;
100 EllipsizeState _ellipsize;103 EllipsizeState _ellipsize;
101 AlignState _align;104 AlignState _align;
105 AlignState _valign;
102 char* _fontstring;106 char* _fontstring;
103107
104 CairoGraphics* _cairoGraphics;108 CairoGraphics* _cairoGraphics;
105109
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2011-03-24 00:35:26 +0000
+++ tests/CMakeLists.txt 2011-03-24 01:52:23 +0000
@@ -153,10 +153,19 @@
153add_executable (test-places153add_executable (test-places
154 TestPlaces.cpp154 TestPlaces.cpp
155 ${PLACES_COMMON_SOURCE}155 ${PLACES_COMMON_SOURCE}
156<<<<<<< TREE
157=======
158 ../src/PlacesController.cpp
159 ../src/PlacesController.h
160 ../src/PlacesEmptyView.cpp
161 ../src/PlacesEmptyView.h
162>>>>>>> MERGE-SOURCE
156 ../src/PlacesHomeView.cpp163 ../src/PlacesHomeView.cpp
157 ../src/PlacesHomeView.h164 ../src/PlacesHomeView.h
158 ../src/PlacesSearchBar.cpp165 ../src/PlacesSearchBar.cpp
159 ../src/PlacesSearchBar.h166 ../src/PlacesSearchBar.h
167 ../src/PlacesSearchBarSpinner.cpp
168 ../src/PlacesSearchBarSpinner.h
160 ../src/PlacesResultsController.cpp169 ../src/PlacesResultsController.cpp
161 ../src/PlacesResultsController.h170 ../src/PlacesResultsController.h
162 ../src/PlacesResultsView.h171 ../src/PlacesResultsView.h