Merge lp:~njpatel/unity-lens-applications/unity-lens-applications into lp:unity-lens-applications
- unity-lens-applications
- Merge into trunk
Proposed by
Neil J. Patel
Status: | Merged |
---|---|
Approved by: | Alex Launi |
Approved revision: | 218 |
Merged at revision: | 213 |
Proposed branch: | lp:~njpatel/unity-lens-applications/unity-lens-applications |
Merge into: | lp:unity-lens-applications |
Diff against target: |
1684 lines (+361/-562) 14 files modified
.bzrignore (+11/-0) Makefile.am (+11/-7) applications.lens.in.in (+4/-19) commands.lens.in.in (+10/-0) configure.ac (+12/-11) data/Makefile.am (+3/-3) data/unity-lens-applications.service.in (+1/-1) po/POTFILES.in (+2/-1) src/Makefile.am (+2/-2) src/daemon.vala (+192/-352) src/main.vala (+3/-3) src/runner.vala (+97/-119) src/schemas.vala (+3/-34) src/utils.vala (+10/-10) |
To merge this branch: | bzr merge lp:~njpatel/unity-lens-applications/unity-lens-applications |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Launi (community) | Approve | ||
Review via email: mp+70408@code.launchpad.net |
Commit message
Description of the change
This ports the application place to the new infrastructure. The only way to test it is over d-feet and it requires lp:~njpatel/libunity/lenses-extras to compile.
This also s/place/lens, which means we need new packaging and we need to ask LP guys to rename this project.
To post a comment you must log in.
- 218. By Neil J. Patel
-
update version
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-01-27 13:08:27 +0000 | |||
3 | +++ .bzrignore 2011-08-04 08:16:52 +0000 | |||
4 | @@ -60,3 +60,14 @@ | |||
5 | 60 | ABOUT-NLS | 60 | ABOUT-NLS |
6 | 61 | config.rpath | 61 | config.rpath |
7 | 62 | po/unity-place-applications.pot | 62 | po/unity-place-applications.pot |
8 | 63 | applications.place | ||
9 | 64 | applications.place.in | ||
10 | 65 | data/X-Unity-All-Applications.directory | ||
11 | 66 | data/unity-place-applications.menu | ||
12 | 67 | po/da.gmo | ||
13 | 68 | src/config.c | ||
14 | 69 | src/config.vala | ||
15 | 70 | src/daemon.c | ||
16 | 71 | src/schemas.c | ||
17 | 72 | src/unity-applications-daemon | ||
18 | 73 | src/unity_applications_daemon.vala.stamp | ||
19 | 63 | 74 | ||
20 | === modified file 'Makefile.am' | |||
21 | --- Makefile.am 2011-02-11 12:35:12 +0000 | |||
22 | +++ Makefile.am 2011-08-04 08:16:52 +0000 | |||
23 | @@ -1,16 +1,20 @@ | |||
24 | 1 | SUBDIRS = src data po | 1 | SUBDIRS = src data po |
25 | 2 | 2 | ||
26 | 3 | # | 3 | # |
28 | 4 | # Install the applications.place file | 4 | # Install the applications.lens file |
29 | 5 | # | 5 | # |
33 | 6 | place_in_files = applications.place.in | 6 | lens_in_files = applications.lens.in |
34 | 7 | placedir = $(datadir)/unity/places | 7 | lensdir = $(datadir)/unity/lenses/applications |
35 | 8 | place_DATA = $(place_in_files:.place.in=.place) | 8 | lens_DATA = $(lens_in_files:.lens.in=.lens) |
36 | 9 | |||
37 | 10 | cmdlens_in_files = commands.lens.in | ||
38 | 11 | cmdlensdir = $(datadir)/unity/lenses/commands | ||
39 | 12 | cmdlens_DATA = $(cmdlens_in_files:.lens.in=.lens) | ||
40 | 9 | 13 | ||
41 | 10 | icondir = $(datadir)/unity/themes | 14 | icondir = $(datadir)/unity/themes |
42 | 11 | icon_DATA = applications.png | 15 | icon_DATA = applications.png |
43 | 12 | 16 | ||
45 | 13 | @INTLTOOL_PLACE_RULE@ | 17 | @INTLTOOL_LENS_RULE@ |
46 | 14 | 18 | ||
47 | 15 | DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall | 19 | DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall |
48 | 16 | 20 | ||
49 | @@ -32,7 +36,7 @@ | |||
50 | 32 | EXTRA_DIST = \ | 36 | EXTRA_DIST = \ |
51 | 33 | applications.png \ | 37 | applications.png \ |
52 | 34 | autogen.sh \ | 38 | autogen.sh \ |
54 | 35 | $(place_in_files) \ | 39 | $(lens_in_files) \ |
55 | 36 | AUTHORS \ | 40 | AUTHORS \ |
56 | 37 | COPYING \ | 41 | COPYING \ |
57 | 38 | HACKING \ | 42 | HACKING \ |
58 | @@ -42,5 +46,5 @@ | |||
59 | 42 | vapi/unity-package-search.deps | 46 | vapi/unity-package-search.deps |
60 | 43 | 47 | ||
61 | 44 | CLEANFILES = \ | 48 | CLEANFILES = \ |
63 | 45 | $(place_DATA) | 49 | $(lens_DATA) |
64 | 46 | 50 | ||
65 | 47 | 51 | ||
66 | === renamed file 'applications.place.in.in' => 'applications.lens.in.in' | |||
67 | --- applications.place.in.in 2011-04-01 14:54:26 +0000 | |||
68 | +++ applications.lens.in.in 2011-08-04 08:16:52 +0000 | |||
69 | @@ -1,27 +1,12 @@ | |||
76 | 1 | [Place] | 1 | [Lens] |
77 | 2 | DBusName=com.canonical.Unity.ApplicationsPlace | 2 | DBusName=com.canonical.Unity.Lens.Applications |
78 | 3 | DBusObjectPath=/com/canonical/unity/applicationsplace | 3 | DBusObjectPath=/com/canonical/unity/lens/applications |
73 | 4 | |||
74 | 5 | [Entry:Files] | ||
75 | 6 | DBusObjectPath=/com/canonical/unity/applicationsplace/applications | ||
79 | 7 | Icon=@prefix@/share/unity/themes/applications.png | 4 | Icon=@prefix@/share/unity/themes/applications.png |
80 | 8 | _Name=Applications | 5 | _Name=Applications |
81 | 9 | Description= | 6 | Description= |
82 | 10 | _SearchHint=Search Applications | 7 | _SearchHint=Search Applications |
83 | 11 | Shortcut=a | 8 | Shortcut=a |
84 | 12 | 9 | ||
85 | 13 | [Entry:Runner] | ||
86 | 14 | DBusObjectPath=/com/canonical/unity/applicationsplace/runner | ||
87 | 15 | _Name=Commands | ||
88 | 16 | _SearchHint=Run a command | ||
89 | 17 | ShowGlobal=false | ||
90 | 18 | ShowEntry=false | ||
91 | 19 | |||
92 | 20 | [Activation] | ||
93 | 21 | URIPattern=unity-(install|runner)://.+ | ||
94 | 22 | MimetypePattern=application/x-unity-available-application | ||
95 | 23 | Priority=0 | ||
96 | 24 | |||
97 | 25 | [Desktop Entry] | 10 | [Desktop Entry] |
99 | 26 | X-Ubuntu-Gettext-Domain=unity-place-applications | 11 | X-Ubuntu-Gettext-Domain=unity-lens-applications |
100 | 27 | 12 | ||
101 | 28 | 13 | ||
102 | === added file 'commands.lens.in.in' | |||
103 | --- commands.lens.in.in 1970-01-01 00:00:00 +0000 | |||
104 | +++ commands.lens.in.in 2011-08-04 08:16:52 +0000 | |||
105 | @@ -0,0 +1,10 @@ | |||
106 | 1 | [Lens] | ||
107 | 2 | DBusName=com.canonical.Unity.Lens.Applications | ||
108 | 3 | DBusObjectPath=/com/canonical/unity/lens/commands | ||
109 | 4 | Icon=@prefix@/share/unity/themes/applications.png | ||
110 | 5 | _Name=Commands | ||
111 | 6 | _SearchHint=Run a command | ||
112 | 7 | Visible=false | ||
113 | 8 | |||
114 | 9 | [Desktop Entry] | ||
115 | 10 | X-Ubuntu-Gettext-Domain=unity-lens-applications | ||
116 | 0 | 11 | ||
117 | === modified file 'configure.ac' | |||
118 | --- configure.ac 2011-04-07 10:51:45 +0000 | |||
119 | +++ configure.ac 2011-08-04 08:16:52 +0000 | |||
120 | @@ -1,4 +1,4 @@ | |||
122 | 1 | AC_INIT(unity-place-applications, 0.2.47, https://launchpad.net/unity-place-applications) | 1 | AC_INIT(unity-lens-applications, 0.3.0, https://launchpad.net/unity-lens-applications) |
123 | 2 | AC_COPYRIGHT([Copyright 2010 Canonical]) | 2 | AC_COPYRIGHT([Copyright 2010 Canonical]) |
124 | 3 | 3 | ||
125 | 4 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) | 4 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) |
126 | @@ -46,16 +46,16 @@ | |||
127 | 46 | AC_DEFINE_UNQUOTED(PREFIXDIR, "${PREFIX}",[Prefix directory]) | 46 | AC_DEFINE_UNQUOTED(PREFIXDIR, "${PREFIX}",[Prefix directory]) |
128 | 47 | 47 | ||
129 | 48 | ###################################################### | 48 | ###################################################### |
131 | 49 | # intltool rule for generating translated .place file | 49 | # intltool rule for generating translated .lens file |
132 | 50 | ###################################################### | 50 | ###################################################### |
135 | 51 | INTLTOOL_PLACE_RULE='%.place: %.place.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' | 51 | INTLTOOL_LENS_RULE='%.lens: %.lens.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' |
136 | 52 | AC_SUBST(INTLTOOL_PLACE_RULE) | 52 | AC_SUBST(INTLTOOL_LENS_RULE) |
137 | 53 | 53 | ||
138 | 54 | ############################################# | 54 | ############################################# |
139 | 55 | # Check for module and library dependancies | 55 | # Check for module and library dependancies |
140 | 56 | ############################################# | 56 | ############################################# |
141 | 57 | GLIB_REQUIRED=2.27 | 57 | GLIB_REQUIRED=2.27 |
143 | 58 | PKG_CHECK_MODULES(PLACE_DAEMON, | 58 | PKG_CHECK_MODULES(LENS_DAEMON, |
144 | 59 | glib-2.0 >= $GLIB_REQUIRED | 59 | glib-2.0 >= $GLIB_REQUIRED |
145 | 60 | gobject-2.0 >= $GLIB_REQUIRED | 60 | gobject-2.0 >= $GLIB_REQUIRED |
146 | 61 | gio-2.0 >= $GLIB_REQUIRED | 61 | gio-2.0 >= $GLIB_REQUIRED |
147 | @@ -64,11 +64,11 @@ | |||
148 | 64 | gee-1.0 | 64 | gee-1.0 |
149 | 65 | dee-1.0 >= 0.5.16 | 65 | dee-1.0 >= 0.5.16 |
150 | 66 | zeitgeist-1.0 >= 0.3.8 | 66 | zeitgeist-1.0 >= 0.3.8 |
152 | 67 | unity >= 3.6.3 | 67 | unity >= 4.0 |
153 | 68 | libgnome-menu) | 68 | libgnome-menu) |
154 | 69 | 69 | ||
157 | 70 | AC_SUBST(PLACE_DAEMON_CFLAGS) | 70 | AC_SUBST(LENS_DAEMON_CFLAGS) |
158 | 71 | AC_SUBST(PLACE_DAEMON_LIBS) | 71 | AC_SUBST(LENS_DAEMON_LIBS) |
159 | 72 | 72 | ||
160 | 73 | ############################################# | 73 | ############################################# |
161 | 74 | # local install for distcheck and stand-alone running | 74 | # local install for distcheck and stand-alone running |
162 | @@ -106,10 +106,11 @@ | |||
163 | 106 | ############################################# | 106 | ############################################# |
164 | 107 | AC_CONFIG_FILES([ | 107 | AC_CONFIG_FILES([ |
165 | 108 | Makefile | 108 | Makefile |
167 | 109 | applications.place.in | 109 | applications.lens.in |
168 | 110 | commands.lens.in | ||
169 | 110 | data/Makefile | 111 | data/Makefile |
170 | 111 | data/X-Unity-All-Applications.directory | 112 | data/X-Unity-All-Applications.directory |
172 | 112 | data/unity-place-applications.menu | 113 | data/unity-lens-applications.menu |
173 | 113 | src/Makefile | 114 | src/Makefile |
174 | 114 | src/config.vala | 115 | src/config.vala |
175 | 115 | po/Makefile.in | 116 | po/Makefile.in |
176 | @@ -119,7 +120,7 @@ | |||
177 | 119 | dnl Output the results | 120 | dnl Output the results |
178 | 120 | AC_MSG_NOTICE([ | 121 | AC_MSG_NOTICE([ |
179 | 121 | 122 | ||
181 | 122 | Unity Applications Place Daemon $VERSION | 123 | Unity Applications Lens Daemon $VERSION |
182 | 123 | ------------------------------------ | 124 | ------------------------------------ |
183 | 124 | 125 | ||
184 | 125 | Prefix : ${prefix} | 126 | Prefix : ${prefix} |
185 | 126 | 127 | ||
186 | === modified file 'data/Makefile.am' | |||
187 | --- data/Makefile.am 2011-03-10 10:56:46 +0000 | |||
188 | +++ data/Makefile.am 2011-08-04 08:16:52 +0000 | |||
189 | @@ -1,5 +1,5 @@ | |||
190 | 1 | dbus_servicesdir = $(DBUSSERVICEDIR) | 1 | dbus_servicesdir = $(DBUSSERVICEDIR) |
192 | 2 | service_in_files = unity-place-applications.service.in | 2 | service_in_files = unity-lens-applications.service.in |
193 | 3 | dbus_services_DATA = $(service_in_files:.service.in=.service) | 3 | dbus_services_DATA = $(service_in_files:.service.in=.service) |
194 | 4 | 4 | ||
195 | 5 | %.service: %.service.in | 5 | %.service: %.service.in |
196 | @@ -14,7 +14,7 @@ | |||
197 | 14 | 14 | ||
198 | 15 | menudir = $(sysconfdir)/xdg/menus | 15 | menudir = $(sysconfdir)/xdg/menus |
199 | 16 | menu_in_files = \ | 16 | menu_in_files = \ |
201 | 17 | unity-place-applications.menu.in | 17 | unity-lens-applications.menu.in |
202 | 18 | menu_DATA = $(menu_in_files:.menu.in=.menu) | 18 | menu_DATA = $(menu_in_files:.menu.in=.menu) |
203 | 19 | 19 | ||
204 | 20 | 20 | ||
205 | @@ -24,4 +24,4 @@ | |||
206 | 24 | $(menu_in_files) | 24 | $(menu_in_files) |
207 | 25 | 25 | ||
208 | 26 | CLEANFILES = \ | 26 | CLEANFILES = \ |
210 | 27 | unity-place-applications.service | 27 | unity-lens-applications.service |
211 | 28 | 28 | ||
212 | === renamed file 'data/unity-place-applications.menu.in' => 'data/unity-lens-applications.menu.in' | |||
213 | === renamed file 'data/unity-place-applications.service.in' => 'data/unity-lens-applications.service.in' | |||
214 | --- data/unity-place-applications.service.in 2010-06-24 18:02:29 +0000 | |||
215 | +++ data/unity-lens-applications.service.in 2011-08-04 08:16:52 +0000 | |||
216 | @@ -1,3 +1,3 @@ | |||
217 | 1 | [D-BUS Service] | 1 | [D-BUS Service] |
219 | 2 | Name=com.canonical.Unity.ApplicationsPlace | 2 | Name=com.canonical.Unity.Lens.Applications |
220 | 3 | Exec=@libexecdir@/unity-applications-daemon | 3 | Exec=@libexecdir@/unity-applications-daemon |
221 | 4 | 4 | ||
222 | === modified file 'po/POTFILES.in' | |||
223 | --- po/POTFILES.in 2011-03-10 13:25:55 +0000 | |||
224 | +++ po/POTFILES.in 2011-08-04 08:16:52 +0000 | |||
225 | @@ -4,4 +4,5 @@ | |||
226 | 4 | src/utils.vala | 4 | src/utils.vala |
227 | 5 | src/main.vala | 5 | src/main.vala |
228 | 6 | data/X-Unity-All-Applications.directory.in | 6 | data/X-Unity-All-Applications.directory.in |
230 | 7 | [type: gettext/ini]applications.place.in.in | 7 | [type: gettext/ini]applications.lens.in.in |
231 | 8 | [type: gettext/ini]commands.lens.in.in | ||
232 | 8 | 9 | ||
233 | === modified file 'src/Makefile.am' | |||
234 | --- src/Makefile.am 2011-03-30 01:29:07 +0000 | |||
235 | +++ src/Makefile.am 2011-08-04 08:16:52 +0000 | |||
236 | @@ -14,7 +14,7 @@ | |||
237 | 14 | -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ | 14 | -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ |
238 | 15 | -DG_LOG_DOMAIN=\"unity-applications-daemon\" \ | 15 | -DG_LOG_DOMAIN=\"unity-applications-daemon\" \ |
239 | 16 | -DGMENU_I_KNOW_THIS_IS_UNSTABLE \ | 16 | -DGMENU_I_KNOW_THIS_IS_UNSTABLE \ |
241 | 17 | $(PLACE_DAEMON_CFLAGS) \ | 17 | $(LENS_DAEMON_CFLAGS) \ |
242 | 18 | $(MAINTAINER_CFLAGS) \ | 18 | $(MAINTAINER_CFLAGS) \ |
243 | 19 | -I$(srcdir) \ | 19 | -I$(srcdir) \ |
244 | 20 | -g | 20 | -g |
245 | @@ -40,7 +40,7 @@ | |||
246 | 40 | unity_package_search_libs = -lxapian -lstdc++ | 40 | unity_package_search_libs = -lxapian -lstdc++ |
247 | 41 | 41 | ||
248 | 42 | unity_applications_daemon_LDADD = \ | 42 | unity_applications_daemon_LDADD = \ |
250 | 43 | $(PLACE_DAEMON_LIBS) \ | 43 | $(LENS_DAEMON_LIBS) \ |
251 | 44 | $(unity_package_search_libs) \ | 44 | $(unity_package_search_libs) \ |
252 | 45 | unity-package-search.o \ | 45 | unity-package-search.o \ |
253 | 46 | $(NULL) | 46 | $(NULL) |
254 | 47 | 47 | ||
255 | === modified file 'src/daemon.vala' | |||
256 | --- src/daemon.vala 2011-05-04 13:20:43 +0000 | |||
257 | +++ src/daemon.vala 2011-08-04 08:16:52 +0000 | |||
258 | @@ -14,6 +14,7 @@ | |||
259 | 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/>. |
260 | 15 | * | 15 | * |
261 | 16 | * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> | 16 | * Authored by Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> |
262 | 17 | * Neil Jagdish Patel <neil.patel@canonical.com> | ||
263 | 17 | * | 18 | * |
264 | 18 | */ | 19 | */ |
265 | 19 | using Dee; | 20 | using Dee; |
266 | @@ -23,11 +24,11 @@ | |||
267 | 23 | using Gee; | 24 | using Gee; |
268 | 24 | using GMenu; | 25 | using GMenu; |
269 | 25 | 26 | ||
275 | 26 | namespace Unity.ApplicationsPlace { | 27 | namespace Unity.ApplicationsLens { |
276 | 27 | 28 | ||
277 | 28 | const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/"; | 29 | const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/lenss/svg/"; |
278 | 29 | 30 | ||
279 | 30 | public class Daemon : GLib.Object, Unity.Activation | 31 | public class Daemon : GLib.Object |
280 | 31 | { | 32 | { |
281 | 32 | private Zeitgeist.Log log; | 33 | private Zeitgeist.Log log; |
282 | 33 | private Zeitgeist.Index zg_index; | 34 | private Zeitgeist.Index zg_index; |
283 | @@ -37,67 +38,36 @@ | |||
284 | 37 | private Unity.Package.Searcher? pkgsearcher; | 38 | private Unity.Package.Searcher? pkgsearcher; |
285 | 38 | public Unity.Package.Searcher appsearcher; | 39 | public Unity.Package.Searcher appsearcher; |
286 | 39 | 40 | ||
289 | 40 | private Unity.PlaceController control; | 41 | private Unity.Lens lens; |
290 | 41 | private Unity.PlaceEntryInfo applications; | 42 | private Unity.Scope scope; |
291 | 42 | 43 | ||
293 | 43 | private Unity.ApplicationsPlace.Runner runner; | 44 | private Unity.ApplicationsLens.Runner runner; |
294 | 44 | 45 | ||
295 | 45 | /* For each section we have a set filtering query we use to restrict | 46 | /* For each section we have a set filtering query we use to restrict |
298 | 46 | * Xapian queries to that section */ | 47 | * Xapian queries to that type */ |
299 | 47 | private Gee.List<string> section_queries; | 48 | private HashTable<string, string> type_queries; |
300 | 48 | 49 | ||
301 | 49 | private Gee.List<string> image_extensions; | 50 | private Gee.List<string> image_extensions; |
302 | 50 | private HashTable<string,Icon> file_icon_cache; | 51 | private HashTable<string,Icon> file_icon_cache; |
303 | 51 | 52 | ||
304 | 52 | /* We remember the previous search so we can figure out if we should do | 53 | /* We remember the previous search so we can figure out if we should do |
305 | 53 | * incremental filtering of the result models */ | 54 | * incremental filtering of the result models */ |
313 | 54 | private PlaceSearch? previous_search; | 55 | private Unity.LensSearch? previous_search; |
314 | 55 | private PlaceSearch? previous_global_search; | 56 | private Unity.LensSearch? previous_global_search; |
315 | 56 | 57 | ||
309 | 57 | /* To make sure we don't fire of unnecessary queries if the active section | ||
310 | 58 | * is in fact not changed */ | ||
311 | 59 | private uint previous_active_section; | ||
312 | 60 | |||
316 | 61 | private PtrArray zg_templates; | 58 | private PtrArray zg_templates; |
317 | 62 | 59 | ||
318 | 63 | /* Gnome menu structure - also used to check whether apps are installed */ | 60 | /* Gnome menu structure - also used to check whether apps are installed */ |
319 | 64 | private uint app_menu_changed_reindex_timeout = 0; | 61 | private uint app_menu_changed_reindex_timeout = 0; |
320 | 65 | private GMenu.Tree app_menu = null; | 62 | private GMenu.Tree app_menu = null; |
321 | 66 | 63 | ||
322 | 67 | private bool all_models_synced; | ||
323 | 68 | |||
324 | 69 | private Regex? uri_regex; | 64 | private Regex? uri_regex; |
325 | 70 | 65 | ||
326 | 71 | construct | 66 | construct |
327 | 72 | { | 67 | { |
345 | 73 | var sections_model = new Dee.SharedModel("com.canonical.Unity.ApplicationsPlace.SectionsModel"); | 68 | populate_type_queries (); |
329 | 74 | sections_model.set_schema ("s", "s"); | ||
330 | 75 | |||
331 | 76 | var groups_model = new Dee.SharedModel("com.canonical.Unity.ApplicationsPlace.GroupsModel"); | ||
332 | 77 | groups_model.set_schema ("s", "s", "s"); | ||
333 | 78 | |||
334 | 79 | var global_groups_model = new Dee.SharedModel("com.canonical.Unity.ApplicationsPlace.GlobalGroupsModel"); | ||
335 | 80 | global_groups_model.set_schema ("s", "s", "s"); | ||
336 | 81 | |||
337 | 82 | var results_model = new Dee.SharedModel("com.canonical.Unity.ApplicationsPlace.ResultsModel"); | ||
338 | 83 | results_model.set_schema ("s", "s", "u", "s", "s", "s"); | ||
339 | 84 | |||
340 | 85 | var global_results_model = new Dee.SharedModel("com.canonical.Unity.ApplicationsPlace.GlobalResultsModel"); | ||
341 | 86 | global_results_model.set_schema ("s", "s", "u", "s", "s", "s"); | ||
342 | 87 | |||
343 | 88 | section_queries = new Gee.ArrayList<string> (); | ||
344 | 89 | populate_section_queries(); | ||
346 | 90 | populate_zg_templates (); | 69 | populate_zg_templates (); |
347 | 91 | 70 | ||
348 | 92 | applications = new PlaceEntryInfo ("/com/canonical/unity/applicationsplace/applications"); | ||
349 | 93 | applications.sections_model = sections_model; | ||
350 | 94 | applications.entry_renderer_info.groups_model = groups_model; | ||
351 | 95 | applications.entry_renderer_info.results_model = results_model; | ||
352 | 96 | applications.global_renderer_info.groups_model = global_groups_model; | ||
353 | 97 | applications.global_renderer_info.results_model = global_results_model; | ||
354 | 98 | |||
355 | 99 | applications.icon = @"$(Config.PREFIX)/share/unity/themes/applications.png"; | ||
356 | 100 | |||
357 | 101 | log = new Zeitgeist.Log(); | 71 | log = new Zeitgeist.Log(); |
358 | 102 | zg_index = new Zeitgeist.Index(); | 72 | zg_index = new Zeitgeist.Index(); |
359 | 103 | 73 | ||
360 | @@ -119,68 +89,60 @@ | |||
361 | 119 | 89 | ||
362 | 120 | previous_search = null; | 90 | previous_search = null; |
363 | 121 | previous_global_search = null; | 91 | previous_global_search = null; |
366 | 122 | previous_active_section = Section.LAST_SECTION; /* Must be an invalid section! */ | 92 | |
365 | 123 | |||
367 | 124 | build_app_menu_index (); | 93 | build_app_menu_index (); |
368 | 125 | 94 | ||
369 | 126 | file_icon_cache = new HashTable<string,Icon>(str_hash, str_equal); | 95 | file_icon_cache = new HashTable<string,Icon>(str_hash, str_equal); |
370 | 96 | |||
371 | 97 | scope = new Unity.Scope ("/com/canonical/unity/scope/applications"); | ||
372 | 98 | //scope.icon = @"$(Config.PREFIX)/share/unity/themes/applications.png"; | ||
373 | 127 | 99 | ||
401 | 128 | /* Listen for section changes */ | 100 | /* Listen for changes to the lens scope search */ |
402 | 129 | applications.notify["active-section"].connect ( | 101 | scope.notify["active-search"].connect ( |
403 | 130 | (obj, pspec) => { | 102 | (obj, pspec) => { |
404 | 131 | if (!all_models_synced) | 103 | var search = scope.active_search; |
405 | 132 | return; | 104 | |
379 | 133 | |||
380 | 134 | if (previous_active_section == applications.active_section) | ||
381 | 135 | return; | ||
382 | 136 | |||
383 | 137 | var search = applications.active_search; | ||
384 | 138 | var section = (Section) applications.active_section; | ||
385 | 139 | update_entry_search.begin (search, section); | ||
386 | 140 | |||
387 | 141 | previous_search = search; | ||
388 | 142 | previous_active_section = applications.active_section; | ||
389 | 143 | } | ||
390 | 144 | ); | ||
391 | 145 | |||
392 | 146 | /* Listen for changes to the place entry search */ | ||
393 | 147 | applications.notify["active-search"].connect ( | ||
394 | 148 | (obj, pspec) => { | ||
395 | 149 | if (!all_models_synced) | ||
396 | 150 | return; | ||
397 | 151 | |||
398 | 152 | var search = applications.active_search; | ||
399 | 153 | Section section = (Section) applications.active_section; | ||
400 | 154 | |||
406 | 155 | if (!Utils.search_has_really_changed (previous_search, search)) | 105 | if (!Utils.search_has_really_changed (previous_search, search)) |
407 | 156 | return; | 106 | return; |
408 | 107 | |||
409 | 108 | update_scope_search.begin (search); | ||
410 | 109 | previous_search = search; | ||
411 | 110 | } | ||
412 | 111 | ); | ||
413 | 112 | |||
414 | 113 | /* Re-do the search if the filters changed */ | ||
415 | 114 | scope.filters_changed.connect ( | ||
416 | 115 | () => { | ||
417 | 116 | var search = scope.active_search; | ||
418 | 117 | if (search.search_string == null) | ||
419 | 118 | return; | ||
420 | 119 | |||
421 | 120 | update_scope_search.begin (search); | ||
422 | 121 | previous_search = search; | ||
423 | 157 | 122 | ||
424 | 158 | update_entry_search.begin (search, section); | ||
425 | 159 | previous_search = search; | ||
426 | 160 | } | 123 | } |
427 | 161 | ); | 124 | ); |
428 | 162 | 125 | ||
429 | 163 | /* Listen for changes to the global search aka Dash search */ | 126 | /* Listen for changes to the global search aka Dash search */ |
431 | 164 | applications.notify["active-global-search"].connect ( | 127 | scope.notify["active-global-search"].connect ( |
432 | 165 | (obj, pspec) => { | 128 | (obj, pspec) => { |
435 | 166 | if (!all_models_synced) | 129 | var search = scope.active_global_search; |
434 | 167 | return; | ||
436 | 168 | 130 | ||
437 | 169 | var search = applications.active_global_search; | ||
438 | 170 | |||
439 | 171 | if (!Utils.search_has_really_changed (previous_global_search, search)) | 131 | if (!Utils.search_has_really_changed (previous_global_search, search)) |
440 | 172 | return; | 132 | return; |
441 | 173 | 133 | ||
443 | 174 | update_global_search.begin(search); | 134 | update_global_search.begin (search); |
444 | 175 | previous_global_search = search; | 135 | previous_global_search = search; |
445 | 176 | } | 136 | } |
446 | 177 | ); | 137 | ); |
447 | 178 | 138 | ||
448 | 139 | scope.activate_uri.connect (activate); | ||
449 | 140 | |||
450 | 179 | /* Listen for changes in the installed applications */ | 141 | /* Listen for changes in the installed applications */ |
451 | 180 | AppInfoManager.get_instance().changed.connect (on_appinfo_changed); | 142 | AppInfoManager.get_instance().changed.connect (on_appinfo_changed); |
452 | 181 | 143 | ||
453 | 182 | /* Now start the RunEntry */ | 144 | /* Now start the RunEntry */ |
455 | 183 | runner = new Unity.ApplicationsPlace.Runner (this); | 145 | runner = new Unity.ApplicationsLens.Runner (this); |
456 | 184 | 146 | ||
457 | 185 | try { | 147 | try { |
458 | 186 | uri_regex = new Regex ("^[a-z]+:.+$"); | 148 | uri_regex = new Regex ("^[a-z]+:.+$"); |
459 | @@ -189,131 +151,89 @@ | |||
460 | 189 | critical ("Failed to compile URI regex. URL launching will be disabled"); | 151 | critical ("Failed to compile URI regex. URL launching will be disabled"); |
461 | 190 | } | 152 | } |
462 | 191 | 153 | ||
588 | 192 | 154 | lens = new Unity.Lens ("/com/canonical/unity/lens/applications", "applications"); | |
589 | 193 | /* The last thing we do is export the controller. Once that is up, | 155 | lens.search_hint = _("Search Applications"); |
590 | 194 | * clients will expect the SharedModels to work */ | 156 | lens.visible = true; |
591 | 195 | control = new Unity.PlaceController ("/com/canonical/unity/applicationsplace"); | 157 | lens.search_in_global = true; |
592 | 196 | control.add_entry (applications); | 158 | populate_categories (); |
593 | 197 | control.add_entry (runner.place_entry); | 159 | populate_filters(); |
594 | 198 | control.activation = this; | 160 | lens.add_local_scope (scope); |
595 | 199 | try { | 161 | lens.export (); |
596 | 200 | control.export (); | 162 | } |
597 | 201 | } catch (IOError error) { | 163 | |
598 | 202 | critical ("Failed to export DBus service for '%s': %s", | 164 | /* Pre-populates the type queries so it's easier/faster to build our search */ |
599 | 203 | control.dbus_path, error.message); | 165 | private void populate_type_queries () |
600 | 204 | } | 166 | { |
601 | 205 | 167 | type_queries = new HashTable<string, string> (null, null); | |
602 | 206 | /* We should not start manipulating any of our models before they are | 168 | type_queries.insert ("all", "NOT category:XYZ"); |
603 | 207 | * all synchronized. When they are we set all_models_synced = true */ | 169 | |
604 | 208 | sections_model.notify["synchronized"].connect (check_models_synced); | 170 | type_queries.insert ("accessories", "(category:Utility AND NOT category:Accessibility)"); |
605 | 209 | groups_model.notify["synchronized"].connect (check_models_synced); | 171 | type_queries.insert ("education", "(category:Education AND NOT category:Science)"); |
606 | 210 | global_groups_model.notify["synchronized"].connect (check_models_synced); | 172 | type_queries.insert ("game", "category:Game"); |
607 | 211 | results_model.notify["synchronized"].connect (check_models_synced); | 173 | type_queries.insert ("graphics", "category:Graphics"); |
608 | 212 | global_results_model.notify["synchronized"].connect (check_models_synced); | 174 | type_queries.insert ("internet", "category:Network"); |
609 | 213 | all_models_synced = false; | 175 | type_queries.insert ("fonts", "category:Fonts"); // FIXME: wtf? |
610 | 214 | } | 176 | type_queries.insert ("office", "category:Office"); |
611 | 215 | 177 | type_queries.insert ("media", "category:AudioVideo"); | |
612 | 216 | /* The check_models_synced() method acts like a latch - once all models | 178 | type_queries.insert ("customization", "category:Settings"); |
613 | 217 | * have reported themselves to be synchronized we set | 179 | type_queries.insert ("accessibility", "(category:Accessibility AND NOT category:Settings)"); |
614 | 218 | * all_models_synced = true and tell the searches to re-check their state | 180 | type_queries.insert ("developer", "category:Development"); // FIXME emacs.desktop should be added |
615 | 219 | * as they should refuse to run when all_models_synced == false */ | 181 | type_queries.insert ("science-and-engineering", "(category:Science OR category:Engineering)"); |
616 | 220 | private void check_models_synced (Object obj, ParamSpec pspec) | 182 | type_queries.insert ("system", "(category:System OR category:Security)"); |
617 | 221 | { | 183 | } |
618 | 222 | if ((applications.sections_model as Dee.SharedModel).synchronized && | 184 | |
619 | 223 | (applications.entry_renderer_info.groups_model as Dee.SharedModel).synchronized && | 185 | private void populate_categories () |
620 | 224 | (applications.entry_renderer_info.results_model as Dee.SharedModel).synchronized && | 186 | { |
621 | 225 | (applications.global_renderer_info.groups_model as Dee.SharedModel).synchronized && | 187 | Unity.Category[] categories = {}; |
622 | 226 | (applications.global_renderer_info.results_model as Dee.SharedModel).synchronized) { | 188 | |
623 | 227 | if (all_models_synced == false) | 189 | var cat = new Unity.Category (_("Most Frequently Used"), |
624 | 228 | { | 190 | ICON_PATH + "category-mostused.svg"); |
625 | 229 | all_models_synced = true; | 191 | categories += cat; |
626 | 230 | 192 | ||
627 | 231 | populate_sections (); | 193 | cat = new Unity.Category (_("Installed"), |
628 | 232 | populate_groups (applications.entry_renderer_info.groups_model); | 194 | ICON_PATH + "category-installed.svg"); |
629 | 233 | populate_groups (applications.global_renderer_info.groups_model); | 195 | categories += cat; |
630 | 234 | 196 | ||
631 | 235 | /* Emitting notify here will make us recheck if the search results | 197 | cat = new Unity.Category (_("Apps Available for Download"), |
632 | 236 | * need update. In the negative case this is a noop */ | 198 | ICON_PATH + "category-available.svg"); |
633 | 237 | applications.notify_property ("active-search"); | 199 | categories += cat; |
634 | 238 | applications.notify_property ("active-global-search"); | 200 | |
635 | 239 | } | 201 | lens.categories = categories; |
636 | 240 | } | 202 | } |
637 | 241 | } | 203 | |
638 | 242 | 204 | private void populate_filters() | |
639 | 243 | private void populate_sections () | 205 | { |
640 | 244 | { | 206 | Unity.Filter[] filters = {}; |
641 | 245 | var sections = applications.sections_model; | 207 | |
642 | 246 | 208 | /* Type filter */ | |
643 | 247 | if (sections.get_n_rows() != 0) | 209 | { |
644 | 248 | { | 210 | var filter = new RadioOptionFilter ("type", _("Type")); |
645 | 249 | debug ("Sections model already populated. We probably cloned it off Unity. Rebuilding."); | 211 | filter.add_option ("accessories", _("Accessories")); |
646 | 250 | sections.clear (); | 212 | filter.add_option ("education", _("Education")); |
647 | 251 | } | 213 | filter.add_option ("games", _("Games")); |
648 | 252 | 214 | filter.add_option ("graphics", _("Graphics")); | |
649 | 253 | sections.append (_("All Applications"), ""); | 215 | filter.add_option ("internet", _("Internet")); |
650 | 254 | sections.append (_("Accessories"), ""); | 216 | filter.add_option ("fonts", _("Fonts")); |
651 | 255 | sections.append (_("Universal Access"), ""); | 217 | filter.add_option ("office", _("Office")); |
652 | 256 | sections.append (_("Developer Tools"), ""); | 218 | filter.add_option ("media", _("Media")); |
653 | 257 | sections.append (_("Education"), ""); | 219 | filter.add_option ("customization", _("Customization")); |
654 | 258 | sections.append (_("Science & Engineering"), ""); | 220 | filter.add_option ("accessibility", _("Accessibility")); |
655 | 259 | sections.append (_("Games"), ""); | 221 | filter.add_option ("developer", _("Developer")); |
656 | 260 | sections.append (_("Graphics"), ""); | 222 | filter.add_option ("science-and-engineering", _("Science & Engineering")); |
657 | 261 | sections.append (_("Internet"), ""); | 223 | filter.add_option ("system", _("System")); |
658 | 262 | sections.append (_("Multimedia"), ""); | 224 | |
659 | 263 | sections.append (_("Office"), ""); | 225 | filters += filter; |
660 | 264 | sections.append (_("Themes & Tweaks"), ""); | 226 | } |
661 | 265 | sections.append (_("System"), ""); | 227 | |
662 | 266 | } | 228 | /* Rating filter */ |
663 | 267 | 229 | { | |
664 | 268 | private void populate_groups (Dee.Model groups) | 230 | var filter = new RatingsFilter("rating", _("Rating")); |
665 | 269 | { | 231 | filters += filter; |
666 | 270 | if (groups.get_n_rows() != 0) | 232 | } |
667 | 271 | { | 233 | |
668 | 272 | debug ("The groups model already populated. We probably cloned it off Unity. Rebuilding."); | 234 | lens.filters = filters; |
669 | 273 | groups.clear (); | 235 | } |
670 | 274 | } | 236 | |
546 | 275 | |||
547 | 276 | groups.append ("UnityShowcaseRenderer", | ||
548 | 277 | _("Most Frequently Used"), | ||
549 | 278 | ICON_PATH + "group-mostused.svg"); | ||
550 | 279 | groups.append ("UnityDefaultRenderer", | ||
551 | 280 | _("Installed"), | ||
552 | 281 | ICON_PATH + "group-installed.svg"); | ||
553 | 282 | groups.append ("UnityDefaultRenderer", | ||
554 | 283 | _("Apps Available for Download"), | ||
555 | 284 | ICON_PATH + "group-available.svg"); | ||
556 | 285 | groups.append ("UnityEmptySearchRenderer", | ||
557 | 286 | "No search results", // No i18n, should never be rendered | ||
558 | 287 | ""); | ||
559 | 288 | groups.append ("UnityEmptySectionRenderer", | ||
560 | 289 | "Empty section", // No i18n, should never be rendered | ||
561 | 290 | ""); | ||
562 | 291 | |||
563 | 292 | /* Always expand the Installed group */ | ||
564 | 293 | applications.entry_renderer_info.set_hint ("ExpandedGroups", | ||
565 | 294 | @"$((uint)Group.INSTALLED)"); | ||
566 | 295 | } | ||
567 | 296 | |||
568 | 297 | private void populate_section_queries () | ||
569 | 298 | { | ||
570 | 299 | /* XDG category names. Not for translation. */ | ||
571 | 300 | /* We need the hack for ALL_APPLICATIONS below because Xapian doesn't | ||
572 | 301 | * like '' or '*' queries */ | ||
573 | 302 | section_queries.add ("NOT category:XYZ"); //ALL_APPLICATIONS | ||
574 | 303 | section_queries.add ("(category:Utility AND NOT category:Accessibility)"); //ACCESSORIES | ||
575 | 304 | section_queries.add ("(category:Accessibility AND NOT category:Settings)"); //UNIVERSAL_ACCESS | ||
576 | 305 | section_queries.add ("category:Development"); //DEVELOPER_TOOLS FIXME emacs.desktop should be added | ||
577 | 306 | section_queries.add ("(category:Education AND NOT category:Science)"); // EDUCATION | ||
578 | 307 | section_queries.add ("(category:Science OR category:Engineering)"); // SCIENCE | ||
579 | 308 | section_queries.add ("category:Game"); // GAMES | ||
580 | 309 | section_queries.add ("category:Graphics"); // GRAPHICS | ||
581 | 310 | section_queries.add ("category:Network"); // INTERNET | ||
582 | 311 | section_queries.add ("category:AudioVideo"); // MULTIMEDIA | ||
583 | 312 | section_queries.add ("category:Office"); // OFFICE | ||
584 | 313 | section_queries.add ("category:Settings"); // THEMES | ||
585 | 314 | section_queries.add ("(category:System OR category:Security)"); // SYSTEM | ||
586 | 315 | } | ||
587 | 316 | |||
671 | 317 | /* Load xdg menu info and build a Xapian index over it. | 237 | /* Load xdg menu info and build a Xapian index over it. |
672 | 318 | * Do throttled re-index if the menu changes */ | 238 | * Do throttled re-index if the menu changes */ |
673 | 319 | private bool build_app_menu_index () | 239 | private bool build_app_menu_index () |
674 | @@ -323,10 +243,10 @@ | |||
675 | 323 | debug ("Building initial application menu"); | 243 | debug ("Building initial application menu"); |
676 | 324 | 244 | ||
677 | 325 | /* We need INCLUDE_NODISPLAY to employ proper de-duping between | 245 | /* We need INCLUDE_NODISPLAY to employ proper de-duping between |
679 | 326 | * the Installed and Availabale groups. If a NoDisplay app is installed, | 246 | * the Installed and Availabale categorys. If a NoDisplay app is installed, |
680 | 327 | * eg. Evince, it wont otherwise be in the menu index, only in the | 247 | * eg. Evince, it wont otherwise be in the menu index, only in the |
683 | 328 | * S-C index - thus show up in the Available group */ | 248 | * S-C index - thus show up in the Available category */ |
684 | 329 | app_menu = GMenu.Tree.lookup ("unity-place-applications.menu", | 249 | app_menu = GMenu.Tree.lookup ("unity-lens-applications.menu", |
685 | 330 | GMenu.TreeFlags.INCLUDE_NODISPLAY); | 250 | GMenu.TreeFlags.INCLUDE_NODISPLAY); |
686 | 331 | 251 | ||
687 | 332 | app_menu.add_monitor ((menu) => { | 252 | app_menu.add_monitor ((menu) => { |
688 | @@ -350,7 +270,7 @@ | |||
689 | 350 | 270 | ||
690 | 351 | /* Called when our app_menu structure changes - probably because something | 271 | /* Called when our app_menu structure changes - probably because something |
691 | 352 | * has been installed or removed. We rebuild the index and update the | 272 | * has been installed or removed. We rebuild the index and update the |
693 | 353 | * result models for global and entry. We need to update both because | 273 | * result models for global and scope. We need to update both because |
694 | 354 | * we can't know exactly what Unity may be showing */ | 274 | * we can't know exactly what Unity may be showing */ |
695 | 355 | private bool build_app_menu_index_and_result_models () | 275 | private bool build_app_menu_index_and_result_models () |
696 | 356 | { | 276 | { |
697 | @@ -359,8 +279,8 @@ | |||
698 | 359 | debug ("Updating result models"); | 279 | debug ("Updating result models"); |
699 | 360 | previous_search = null; | 280 | previous_search = null; |
700 | 361 | previous_global_search = null; | 281 | previous_global_search = null; |
703 | 362 | applications.notify_property ("active-search"); | 282 | scope.notify_property ("active-search"); |
704 | 363 | applications.notify_property ("active-global-search"); | 283 | scope.notify_property ("active-global-search"); |
705 | 364 | 284 | ||
706 | 365 | return false; | 285 | return false; |
707 | 366 | } | 286 | } |
708 | @@ -377,12 +297,13 @@ | |||
709 | 377 | zg_templates.add ((ev as GLib.Object).ref()); | 297 | zg_templates.add ((ev as GLib.Object).ref()); |
710 | 378 | } | 298 | } |
711 | 379 | 299 | ||
713 | 380 | private string prepare_zg_search_string (PlaceSearch? search, Section section) | 300 | private string prepare_zg_search_string (Unity.LensSearch? search, |
714 | 301 | string type_id="all") | ||
715 | 381 | { | 302 | { |
716 | 382 | 303 | ||
717 | 383 | string s; | 304 | string s; |
718 | 384 | if (search != null) | 305 | if (search != null) |
720 | 385 | s = search.get_search_string (); | 306 | s = search.search_string; |
721 | 386 | else | 307 | else |
722 | 387 | s = ""; | 308 | s = ""; |
723 | 388 | 309 | ||
724 | @@ -394,26 +315,30 @@ | |||
725 | 394 | if (s != "") | 315 | if (s != "") |
726 | 395 | s = @"app:($s)"; | 316 | s = @"app:($s)"; |
727 | 396 | else | 317 | else |
729 | 397 | return section_queries.get(section); | 318 | return type_queries.lookup(type_id); |
730 | 398 | 319 | ||
732 | 399 | if (section == Section.ALL_APPLICATIONS) | 320 | if (type_id == "all") |
733 | 400 | return s; | 321 | return s; |
734 | 401 | else | 322 | else |
736 | 402 | return s + @" AND $(section_queries.get(section))"; | 323 | return s + @" AND $(type_queries.lookup(type_id))"; |
737 | 403 | } | 324 | } |
738 | 404 | 325 | ||
741 | 405 | private async void update_entry_search (PlaceSearch? search, | 326 | private async void update_scope_search (Unity.LensSearch? search) |
740 | 406 | Section section) | ||
742 | 407 | { | 327 | { |
743 | 408 | /* Prevent concurrent searches and concurrent updates of our models, | 328 | /* Prevent concurrent searches and concurrent updates of our models, |
744 | 409 | * by preventing any notify signals from propagating to us. | 329 | * by preventing any notify signals from propagating to us. |
745 | 410 | * Important: Remeber to thaw the notifys again! */ | 330 | * Important: Remeber to thaw the notifys again! */ |
747 | 411 | applications.freeze_notify (); | 331 | scope.freeze_notify (); |
748 | 412 | 332 | ||
750 | 413 | var model = applications.entry_renderer_info.results_model; | 333 | var model = scope.results_model; |
751 | 414 | model.clear (); | 334 | model.clear (); |
752 | 415 | 335 | ||
754 | 416 | string pkg_search_string = prepare_pkg_search_string (search, section); | 336 | var filter = scope.get_filter ("type") as RadioOptionFilter; |
755 | 337 | Unity.FilterOption? option = filter.get_active_option (); | ||
756 | 338 | string type_id = option == null ? "all" : option.id; | ||
757 | 339 | |||
758 | 340 | string pkg_search_string = prepare_pkg_search_string (search, type_id); | ||
759 | 341 | |||
760 | 417 | bool has_search = !Utils.search_is_invalid (search); | 342 | bool has_search = !Utils.search_is_invalid (search); |
761 | 418 | 343 | ||
762 | 419 | Timer timer = new Timer (); | 344 | Timer timer = new Timer (); |
763 | @@ -425,7 +350,7 @@ | |||
764 | 425 | Unity.Package.Sort.BY_RELEVANCY : | 350 | Unity.Package.Sort.BY_RELEVANCY : |
765 | 426 | Unity.Package.Sort.BY_NAME); | 351 | Unity.Package.Sort.BY_NAME); |
766 | 427 | add_pkg_search_result (appresults, installed_uris, available_uris, model, | 352 | add_pkg_search_result (appresults, installed_uris, available_uris, model, |
768 | 428 | Group.INSTALLED); | 353 | Category.INSTALLED); |
769 | 429 | 354 | ||
770 | 430 | timer.stop (); | 355 | timer.stop (); |
771 | 431 | debug ("Entry search listed %i Installed apps in %fms for query: %s", | 356 | debug ("Entry search listed %i Installed apps in %fms for query: %s", |
772 | @@ -437,7 +362,7 @@ | |||
773 | 437 | * So we can update the UI quicker */ | 362 | * So we can update the UI quicker */ |
774 | 438 | (model as Dee.SharedModel).flush_revision_queue (); | 363 | (model as Dee.SharedModel).flush_revision_queue (); |
775 | 439 | 364 | ||
777 | 440 | var zg_search_string = prepare_zg_search_string (search, section); | 365 | var zg_search_string = prepare_zg_search_string (search, type_id); |
778 | 441 | 366 | ||
779 | 442 | try { | 367 | try { |
780 | 443 | timer.start (); | 368 | timer.start (); |
781 | @@ -449,7 +374,7 @@ | |||
782 | 449 | Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, | 374 | Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, |
783 | 450 | null); | 375 | null); |
784 | 451 | 376 | ||
786 | 452 | append_events_with_group (results, model, Group.MOST_USED, section); | 377 | append_events_with_category (results, model, Category.MOST_USED); |
787 | 453 | 378 | ||
788 | 454 | timer.stop (); | 379 | timer.stop (); |
789 | 455 | debug ("Entry search found %u/%u Most Used apps in %fms for query '%s'", | 380 | debug ("Entry search found %u/%u Most Used apps in %fms for query '%s'", |
790 | @@ -458,7 +383,7 @@ | |||
791 | 458 | 383 | ||
792 | 459 | } catch (GLib.Error e) { | 384 | } catch (GLib.Error e) { |
793 | 460 | warning ("Error performing search '%s': %s", | 385 | warning ("Error performing search '%s': %s", |
795 | 461 | search.get_search_string (), e.message); | 386 | search.search_string, e.message); |
796 | 462 | } | 387 | } |
797 | 463 | 388 | ||
798 | 464 | /* We force a flush of the shared model's revision queue here because | 389 | /* We force a flush of the shared model's revision queue here because |
799 | @@ -475,7 +400,7 @@ | |||
800 | 475 | Unity.Package.SearchType.PREFIX, | 400 | Unity.Package.SearchType.PREFIX, |
801 | 476 | Unity.Package.Sort.BY_RELEVANCY); | 401 | Unity.Package.Sort.BY_RELEVANCY); |
802 | 477 | add_pkg_search_result (pkgresults, installed_uris, available_uris, | 402 | add_pkg_search_result (pkgresults, installed_uris, available_uris, |
804 | 478 | model, Group.AVAILABLE); | 403 | model, Category.AVAILABLE); |
805 | 479 | timer.stop (); | 404 | timer.stop (); |
806 | 480 | debug ("Entry search listed %i Available apps in %fms for query: %s", | 405 | debug ("Entry search listed %i Available apps in %fms for query: %s", |
807 | 481 | pkgresults.num_hits, timer.elapsed ()*1000, pkg_search_string); | 406 | pkgresults.num_hits, timer.elapsed ()*1000, pkg_search_string); |
808 | @@ -483,27 +408,21 @@ | |||
809 | 483 | else if (pkgsearcher != null) | 408 | else if (pkgsearcher != null) |
810 | 484 | { | 409 | { |
811 | 485 | timer.start (); | 410 | timer.start (); |
814 | 486 | string? category = (section == Section.ALL_APPLICATIONS ? | 411 | string? category = null; |
813 | 487 | null : section_queries.get(section)); | ||
815 | 488 | var random_pkgresults = pkgsearcher.get_random_apps (category, 12); | 412 | var random_pkgresults = pkgsearcher.get_random_apps (category, 12); |
816 | 489 | add_pkg_search_result (random_pkgresults, installed_uris, available_uris, | 413 | add_pkg_search_result (random_pkgresults, installed_uris, available_uris, |
818 | 490 | model, Group.AVAILABLE, 6); | 414 | model, Category.AVAILABLE, 6); |
819 | 491 | timer.stop (); | 415 | timer.stop (); |
820 | 492 | debug ("Entry search listed %i random Available apps in %fms", | 416 | debug ("Entry search listed %i random Available apps in %fms", |
821 | 493 | random_pkgresults.num_hits, timer.elapsed ()*1000); | 417 | random_pkgresults.num_hits, timer.elapsed ()*1000); |
822 | 494 | } | 418 | } |
823 | 495 | 419 | ||
824 | 496 | if (has_search) | ||
825 | 497 | check_empty_search (search, model); | ||
826 | 498 | else | ||
827 | 499 | check_empty_section (section, model); | ||
828 | 500 | |||
829 | 501 | /* Allow new searches once we enter an idle again. | 420 | /* Allow new searches once we enter an idle again. |
830 | 502 | * We don't do it directly from here as that could mean we start | 421 | * We don't do it directly from here as that could mean we start |
831 | 503 | * changing the model even before we had flushed out current changes | 422 | * changing the model even before we had flushed out current changes |
832 | 504 | */ | 423 | */ |
833 | 505 | Idle.add (() => { | 424 | Idle.add (() => { |
835 | 506 | applications.thaw_notify (); | 425 | scope.thaw_notify (); |
836 | 507 | return false; | 426 | return false; |
837 | 508 | }); | 427 | }); |
838 | 509 | 428 | ||
839 | @@ -511,9 +430,9 @@ | |||
840 | 511 | search.finished (); | 430 | search.finished (); |
841 | 512 | } | 431 | } |
842 | 513 | 432 | ||
844 | 514 | private async void update_global_search (PlaceSearch? search) | 433 | private async void update_global_search (Unity.LensSearch? search) |
845 | 515 | { | 434 | { |
847 | 516 | var model = applications.global_renderer_info.results_model; | 435 | var model = scope.global_results_model; |
848 | 517 | 436 | ||
849 | 518 | model.clear (); | 437 | model.clear (); |
850 | 519 | 438 | ||
851 | @@ -525,10 +444,9 @@ | |||
852 | 525 | /* Prevent concurrent searches and concurrent updates of our models, | 444 | /* Prevent concurrent searches and concurrent updates of our models, |
853 | 526 | * by preventing any notify signals from propagating to us. | 445 | * by preventing any notify signals from propagating to us. |
854 | 527 | * Important: Remember to thaw the notifys again! */ | 446 | * Important: Remember to thaw the notifys again! */ |
856 | 528 | applications.freeze_notify (); | 447 | scope.freeze_notify (); |
857 | 529 | 448 | ||
860 | 530 | var search_string = prepare_pkg_search_string (search, | 449 | var search_string = prepare_pkg_search_string (search, "all"); |
859 | 531 | Section.ALL_APPLICATIONS); | ||
861 | 532 | Set<string> installed_uris = new HashSet<string> (); | 450 | Set<string> installed_uris = new HashSet<string> (); |
862 | 533 | Set<string> available_uris = new HashSet<string> (); | 451 | Set<string> available_uris = new HashSet<string> (); |
863 | 534 | var timer = new Timer (); | 452 | var timer = new Timer (); |
864 | @@ -536,14 +454,14 @@ | |||
865 | 536 | Unity.Package.SearchType.PREFIX, | 454 | Unity.Package.SearchType.PREFIX, |
866 | 537 | Unity.Package.Sort.BY_RELEVANCY); | 455 | Unity.Package.Sort.BY_RELEVANCY); |
867 | 538 | add_pkg_search_result (appresults, installed_uris, available_uris, model, | 456 | add_pkg_search_result (appresults, installed_uris, available_uris, model, |
869 | 539 | Group.INSTALLED); | 457 | Category.INSTALLED); |
870 | 540 | 458 | ||
871 | 541 | timer.stop (); | 459 | timer.stop (); |
872 | 542 | debug ("Global search listed %i Installed apps in %fms for query: %s", | 460 | debug ("Global search listed %i Installed apps in %fms for query: %s", |
873 | 543 | appresults.num_hits, timer.elapsed ()*1000, search_string); | 461 | appresults.num_hits, timer.elapsed ()*1000, search_string); |
874 | 544 | 462 | ||
875 | 545 | // Dowloadable Apps search disabled from global search | 463 | // Dowloadable Apps search disabled from global search |
877 | 546 | // See https://bugs.launchpad.net/unity-place-applications/+bug/733669 | 464 | // See https://bugs.launchpad.net/unity-lens-applications/+bug/733669 |
878 | 547 | /* | 465 | /* |
879 | 548 | if (pkgsearcher != null) | 466 | if (pkgsearcher != null) |
880 | 549 | { | 467 | { |
881 | @@ -558,7 +476,7 @@ | |||
882 | 558 | Unity.Package.SearchType.PREFIX, | 476 | Unity.Package.SearchType.PREFIX, |
883 | 559 | Unity.Package.Sort.BY_RELEVANCY); | 477 | Unity.Package.Sort.BY_RELEVANCY); |
884 | 560 | add_pkg_search_result (pkgresults, installed_uris, available_uris, | 478 | add_pkg_search_result (pkgresults, installed_uris, available_uris, |
886 | 561 | model, Group.AVAILABLE); | 479 | model, Category.AVAILABLE); |
887 | 562 | timer.stop (); | 480 | timer.stop (); |
888 | 563 | debug ("Global search listed %i Available apps in %fms for query: %s", | 481 | debug ("Global search listed %i Available apps in %fms for query: %s", |
889 | 564 | pkgresults.num_hits, timer.elapsed ()*1000, search_string); | 482 | pkgresults.num_hits, timer.elapsed ()*1000, search_string); |
890 | @@ -570,7 +488,7 @@ | |||
891 | 570 | * changing the model even before we had flushed out current changes | 488 | * changing the model even before we had flushed out current changes |
892 | 571 | */ | 489 | */ |
893 | 572 | Idle.add (() => { | 490 | Idle.add (() => { |
895 | 573 | applications.thaw_notify (); | 491 | scope.thaw_notify (); |
896 | 574 | return false; | 492 | return false; |
897 | 575 | }); | 493 | }); |
898 | 576 | 494 | ||
899 | @@ -578,18 +496,18 @@ | |||
900 | 578 | search.finished (); | 496 | search.finished (); |
901 | 579 | } | 497 | } |
902 | 580 | 498 | ||
904 | 581 | private string prepare_pkg_search_string (PlaceSearch? search, Section section) | 499 | private string prepare_pkg_search_string (Unity.LensSearch? search, string type_id="all") |
905 | 582 | { | 500 | { |
906 | 583 | if (Utils.search_is_invalid (search)) | 501 | if (Utils.search_is_invalid (search)) |
907 | 584 | { | 502 | { |
909 | 585 | if (section == Section.ALL_APPLICATIONS) | 503 | if (type_id == "all") |
910 | 586 | return "type:Application"; | 504 | return "type:Application"; |
911 | 587 | else | 505 | else |
913 | 588 | return @"type:Application AND $(section_queries.get(section))"; | 506 | return @"type:Application AND $(type_queries.lookup(type_id))"; |
914 | 589 | } | 507 | } |
915 | 590 | else | 508 | else |
916 | 591 | { | 509 | { |
918 | 592 | var s = search.get_search_string (); | 510 | var s = search.search_string; |
919 | 593 | 511 | ||
920 | 594 | s = s.strip (); | 512 | s = s.strip (); |
921 | 595 | 513 | ||
922 | @@ -600,10 +518,10 @@ | |||
923 | 600 | * match 'd-feet' etc. */ | 518 | * match 'd-feet' etc. */ |
924 | 601 | s = s.delimit ("-", ' '); | 519 | s = s.delimit ("-", ' '); |
925 | 602 | 520 | ||
927 | 603 | if (section == Section.ALL_APPLICATIONS) | 521 | if (type_id == "all") |
928 | 604 | return @"type:Application AND $s"; | 522 | return @"type:Application AND $s"; |
929 | 605 | else | 523 | else |
931 | 606 | return @"type:Application AND $(section_queries.get(section)) AND $s"; | 524 | return @"type:Application AND $(type_queries.lookup(type_id)) AND $s"; |
932 | 607 | } | 525 | } |
933 | 608 | } | 526 | } |
934 | 609 | 527 | ||
935 | @@ -668,14 +586,14 @@ | |||
936 | 668 | private void on_appinfo_changed (string id, AppInfo? appinfo) | 586 | private void on_appinfo_changed (string id, AppInfo? appinfo) |
937 | 669 | { | 587 | { |
938 | 670 | debug ("Application changed: %s", id); | 588 | debug ("Application changed: %s", id); |
940 | 671 | //update_entry_results_model.begin (); | 589 | //update_scope_results_model.begin (); |
941 | 672 | } | 590 | } |
942 | 673 | 591 | ||
943 | 674 | private void add_pkg_search_result (Unity.Package.SearchResult results, | 592 | private void add_pkg_search_result (Unity.Package.SearchResult results, |
944 | 675 | Set<string> installed_uris, | 593 | Set<string> installed_uris, |
945 | 676 | Set<string> available_uris, | 594 | Set<string> available_uris, |
946 | 677 | Dee.Model model, | 595 | Dee.Model model, |
948 | 678 | Group group, | 596 | Category category, |
949 | 679 | uint max_add=0) | 597 | uint max_add=0) |
950 | 680 | { | 598 | { |
951 | 681 | var appmanager = AppInfoManager.get_instance(); | 599 | var appmanager = AppInfoManager.get_instance(); |
952 | @@ -699,20 +617,20 @@ | |||
953 | 699 | /* Extract basic metadata and register de-dupe keys */ | 617 | /* Extract basic metadata and register de-dupe keys */ |
954 | 700 | string display_name; | 618 | string display_name; |
955 | 701 | string comment; | 619 | string comment; |
957 | 702 | switch (group) | 620 | switch (category) |
958 | 703 | { | 621 | { |
960 | 704 | case Group.INSTALLED: | 622 | case Category.INSTALLED: |
961 | 705 | installed_uris.add (uri); | 623 | installed_uris.add (uri); |
962 | 706 | display_name = app.get_display_name (); | 624 | display_name = app.get_display_name (); |
963 | 707 | comment = app.get_description (); | 625 | comment = app.get_description (); |
964 | 708 | break; | 626 | break; |
966 | 709 | case Group.AVAILABLE: | 627 | case Category.AVAILABLE: |
967 | 710 | available_uris.add (uri); | 628 | available_uris.add (uri); |
968 | 711 | display_name = pkginfo.application_name; | 629 | display_name = pkginfo.application_name; |
969 | 712 | comment = ""; | 630 | comment = ""; |
970 | 713 | break; | 631 | break; |
971 | 714 | default: | 632 | default: |
973 | 715 | warning (@"Illegal group for package search $(group)"); | 633 | warning (@"Illegal category for package search $(category)"); |
974 | 716 | continue; | 634 | continue; |
975 | 717 | } | 635 | } |
976 | 718 | 636 | ||
977 | @@ -722,7 +640,7 @@ | |||
978 | 722 | if (app != null && !app.should_show ()) | 640 | if (app != null && !app.should_show ()) |
979 | 723 | continue; | 641 | continue; |
980 | 724 | 642 | ||
982 | 725 | if (group == Group.AVAILABLE) | 643 | if (category == Category.AVAILABLE) |
983 | 726 | { | 644 | { |
984 | 727 | /* If we have an available item, which is not a dupe, but is | 645 | /* If we have an available item, which is not a dupe, but is |
985 | 728 | * installed anyway, we weed it out here, because it's probably | 646 | * installed anyway, we weed it out here, because it's probably |
986 | @@ -731,7 +649,7 @@ | |||
987 | 731 | if (app != null) | 649 | if (app != null) |
988 | 732 | continue; | 650 | continue; |
989 | 733 | 651 | ||
991 | 734 | /* Apps that are not installed, ie. in the Available group | 652 | /* Apps that are not installed, ie. in the Available category |
992 | 735 | * use the 'unity-install://pkgname/Full App Name' URI scheme, | 653 | * use the 'unity-install://pkgname/Full App Name' URI scheme, |
993 | 736 | * but only use that after we've de-duped the results. | 654 | * but only use that after we've de-duped the results. |
994 | 737 | * But only change the URI *after* we've de-duped the results! */ | 655 | * But only change the URI *after* we've de-duped the results! */ |
995 | @@ -742,7 +660,7 @@ | |||
996 | 742 | Icon icon = find_pkg_icon (pkginfo); | 660 | Icon icon = find_pkg_icon (pkginfo); |
997 | 743 | 661 | ||
998 | 744 | model.append (uri, icon.to_string (), | 662 | model.append (uri, icon.to_string (), |
1000 | 745 | group,"application/x-desktop", | 663 | category,"application/x-desktop", |
1001 | 746 | display_name != null ? display_name : "", | 664 | display_name != null ? display_name : "", |
1002 | 747 | comment != null ? comment : ""); | 665 | comment != null ? comment : ""); |
1003 | 748 | 666 | ||
1004 | @@ -754,10 +672,10 @@ | |||
1005 | 754 | } | 672 | } |
1006 | 755 | 673 | ||
1007 | 756 | /** | 674 | /** |
1009 | 757 | * Override of the default activation handler. The apps place daemon | 675 | * Override of the default activation handler. The apps lens daemon |
1010 | 758 | * can handle activation of installable apps using the Software Center | 676 | * can handle activation of installable apps using the Software Center |
1011 | 759 | */ | 677 | */ |
1013 | 760 | public async uint32 activate (string uri) | 678 | public Unity.ActivationResponse activate (string uri) |
1014 | 761 | { | 679 | { |
1015 | 762 | string[] args; | 680 | string[] args; |
1016 | 763 | string exec_or_dir = null; | 681 | string exec_or_dir = null; |
1017 | @@ -778,9 +696,10 @@ | |||
1018 | 778 | AppInfo.launch_default_for_uri (orig, null); | 696 | AppInfo.launch_default_for_uri (orig, null); |
1019 | 779 | } catch (GLib.Error error) { | 697 | } catch (GLib.Error error) { |
1020 | 780 | warning ("Failed to launch URI %s", orig); | 698 | warning ("Failed to launch URI %s", orig); |
1022 | 781 | return ActivationStatus.NOT_ACTIVATED; | 699 | return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); |
1023 | 782 | } | 700 | } |
1025 | 783 | return ActivationStatus.ACTIVATED_HIDE_DASH; | 701 | return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); |
1026 | 702 | |||
1027 | 784 | } else { | 703 | } else { |
1028 | 785 | exec_or_dir = Utils.subst_tilde (orig); | 704 | exec_or_dir = Utils.subst_tilde (orig); |
1029 | 786 | args = exec_or_dir.split (" ", 0); | 705 | args = exec_or_dir.split (" ", 0); |
1030 | @@ -792,7 +711,7 @@ | |||
1031 | 792 | else | 711 | else |
1032 | 793 | { | 712 | { |
1033 | 794 | debug ("Declined activation of URI '%s': Expected URI scheme unity-install:// or unity-runner://", uri); | 713 | debug ("Declined activation of URI '%s': Expected URI scheme unity-install:// or unity-runner://", uri); |
1035 | 795 | return ActivationStatus.NOT_ACTIVATED; | 714 | return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); |
1036 | 796 | } | 715 | } |
1037 | 797 | 716 | ||
1038 | 798 | if ((exec_or_dir != null) && FileUtils.test (exec_or_dir, FileTest.IS_DIR)) | 717 | if ((exec_or_dir != null) && FileUtils.test (exec_or_dir, FileTest.IS_DIR)) |
1039 | @@ -802,7 +721,7 @@ | |||
1040 | 802 | } catch (GLib.Error err) { | 721 | } catch (GLib.Error err) { |
1041 | 803 | warning ("Failed to open current folder '%s' in file manager: %s", | 722 | warning ("Failed to open current folder '%s' in file manager: %s", |
1042 | 804 | exec_or_dir, err.message); | 723 | exec_or_dir, err.message); |
1044 | 805 | return ActivationStatus.NOT_ACTIVATED; | 724 | return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); |
1045 | 806 | } | 725 | } |
1046 | 807 | } | 726 | } |
1047 | 808 | else | 727 | else |
1048 | @@ -813,20 +732,19 @@ | |||
1049 | 813 | } catch (SpawnError e) { | 732 | } catch (SpawnError e) { |
1050 | 814 | warning ("Failed to spawn software-center or direct URI activation '%s': %s", | 733 | warning ("Failed to spawn software-center or direct URI activation '%s': %s", |
1051 | 815 | uri, e.message); | 734 | uri, e.message); |
1053 | 816 | return ActivationStatus.NOT_ACTIVATED; | 735 | return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); |
1054 | 817 | } | 736 | } |
1055 | 818 | } | 737 | } |
1056 | 819 | 738 | ||
1058 | 820 | return ActivationStatus.ACTIVATED_HIDE_DASH; | 739 | return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); |
1059 | 821 | 740 | ||
1060 | 822 | } | 741 | } |
1061 | 823 | 742 | ||
1062 | 824 | /* Appends the subject URIs from a set of Zeitgeist.Events to our Dee.Model | 743 | /* Appends the subject URIs from a set of Zeitgeist.Events to our Dee.Model |
1063 | 825 | * assuming that these events are already sorted */ | 744 | * assuming that these events are already sorted */ |
1065 | 826 | public void append_events_with_group (Zeitgeist.ResultSet events, | 745 | public void append_events_with_category (Zeitgeist.ResultSet events, |
1066 | 827 | Dee.Model results, | 746 | Dee.Model results, |
1069 | 828 | uint group_id, | 747 | uint category_id) |
1068 | 829 | int section_filter = -1) | ||
1070 | 830 | { | 748 | { |
1071 | 831 | foreach (var ev in events) | 749 | foreach (var ev in events) |
1072 | 832 | { | 750 | { |
1073 | @@ -848,90 +766,12 @@ | |||
1074 | 848 | if (!app.should_show ()) | 766 | if (!app.should_show ()) |
1075 | 849 | continue; | 767 | continue; |
1076 | 850 | 768 | ||
1078 | 851 | results.append (app_uri, app.get_icon().to_string(), group_id, | 769 | results.append (app_uri, app.get_icon().to_string(), category_id, |
1079 | 852 | "application/x-desktop", app.get_display_name (), | 770 | "application/x-desktop", app.get_display_name (), |
1080 | 853 | app.get_description ()); | 771 | app.get_description ()); |
1081 | 854 | } | 772 | } |
1082 | 855 | } | 773 | } |
1083 | 856 | 774 | ||
1084 | 857 | public void check_empty_search (PlaceSearch? search, | ||
1085 | 858 | Dee.Model results_model) | ||
1086 | 859 | { | ||
1087 | 860 | if (results_model.get_n_rows () > 0) | ||
1088 | 861 | return; | ||
1089 | 862 | |||
1090 | 863 | if (Utils.search_is_invalid (search)) | ||
1091 | 864 | return; | ||
1092 | 865 | |||
1093 | 866 | results_model.append ("", "", Group.EMPTY_SEARCH, "", | ||
1094 | 867 | _("Your search did not match any applications"), | ||
1095 | 868 | ""); | ||
1096 | 869 | |||
1097 | 870 | // FIXME: Use prefered browser | ||
1098 | 871 | // FIXME: URL escape search string | ||
1099 | 872 | results_model.append (@"http://google.com/#q=$(search.get_search_string())", | ||
1100 | 873 | "", Group.EMPTY_SEARCH, "", | ||
1101 | 874 | _("Search the web"), ""); | ||
1102 | 875 | } | ||
1103 | 876 | |||
1104 | 877 | public void check_empty_section (Section section, | ||
1105 | 878 | Dee.Model results_model) | ||
1106 | 879 | { | ||
1107 | 880 | if (results_model.get_n_rows () > 0) | ||
1108 | 881 | return; | ||
1109 | 882 | |||
1110 | 883 | string msg; | ||
1111 | 884 | |||
1112 | 885 | switch (section) | ||
1113 | 886 | { | ||
1114 | 887 | case Section.ALL_APPLICATIONS: | ||
1115 | 888 | msg = _("There are no applications installed on this computer"); | ||
1116 | 889 | break; | ||
1117 | 890 | case Section.ACCESSORIES: | ||
1118 | 891 | msg = _("There are no accessories installed on this computer"); | ||
1119 | 892 | break; | ||
1120 | 893 | case Section.UNIVERSAL_ACCESS: | ||
1121 | 894 | msg = _("There are no universal access applications installed on this computer"); | ||
1122 | 895 | break; | ||
1123 | 896 | case Section.DEVELOPER_TOOLS: | ||
1124 | 897 | msg = _("There are no developer tools installed on this computer"); | ||
1125 | 898 | break; | ||
1126 | 899 | case Section.EDUCATION: | ||
1127 | 900 | msg = _("There are no educational applications installed on this computer"); | ||
1128 | 901 | break; | ||
1129 | 902 | case Section.SCIENCE: | ||
1130 | 903 | msg = _("There are no scientific or engineering applications installed on this computer"); | ||
1131 | 904 | break; | ||
1132 | 905 | case Section.GAMES: | ||
1133 | 906 | msg = _("There are no games installed on this computer"); | ||
1134 | 907 | break; | ||
1135 | 908 | case Section.GRAPHICS: | ||
1136 | 909 | msg = _("There are no graphics applications installed on this computer"); | ||
1137 | 910 | break; | ||
1138 | 911 | case Section.INTERNET: | ||
1139 | 912 | msg = _("There are no internet applications installed on this computer"); | ||
1140 | 913 | break; | ||
1141 | 914 | case Section.MULTIMEDIA: | ||
1142 | 915 | msg = _("There are no multimedia applications installed on this computer"); | ||
1143 | 916 | break; | ||
1144 | 917 | case Section.OFFICE: | ||
1145 | 918 | msg = _("There are no office applications installed on this computer"); | ||
1146 | 919 | break; | ||
1147 | 920 | case Section.THEMES: | ||
1148 | 921 | msg = _("There are no theming or tweaking applications installed on this computer"); | ||
1149 | 922 | break; | ||
1150 | 923 | case Section.SYSTEM: | ||
1151 | 924 | msg = _("There are no system applications installed on this computer"); | ||
1152 | 925 | break; | ||
1153 | 926 | default: | ||
1154 | 927 | msg = _("There are no applications installed on this computer"); | ||
1155 | 928 | warning ("Unknown section: %u", section); | ||
1156 | 929 | break; | ||
1157 | 930 | } | ||
1158 | 931 | |||
1159 | 932 | results_model.append ("", "", Group.EMPTY_SECTION, "", msg, ""); | ||
1160 | 933 | } | ||
1161 | 934 | |||
1162 | 935 | } /* END: class Daemon */ | 775 | } /* END: class Daemon */ |
1163 | 936 | 776 | ||
1164 | 937 | } /* namespace */ | 777 | } /* namespace */ |
1165 | 938 | 778 | ||
1166 | === modified file 'src/main.vala' | |||
1167 | --- src/main.vala 2011-01-31 10:37:41 +0000 | |||
1168 | +++ src/main.vala 2011-08-04 08:16:52 +0000 | |||
1169 | @@ -20,7 +20,7 @@ | |||
1170 | 20 | using GLib; | 20 | using GLib; |
1171 | 21 | using Config; | 21 | using Config; |
1172 | 22 | 22 | ||
1174 | 23 | namespace Unity.ApplicationsPlace { | 23 | namespace Unity.ApplicationsLens { |
1175 | 24 | 24 | ||
1176 | 25 | static Application? app = null; | 25 | static Application? app = null; |
1177 | 26 | static Daemon? daemon = null; | 26 | static Daemon? daemon = null; |
1178 | @@ -66,7 +66,7 @@ | |||
1179 | 66 | * making it race against GDBus' worker thread to export our | 66 | * making it race against GDBus' worker thread to export our |
1180 | 67 | * objects on the bus before/after owning our name and receiving | 67 | * objects on the bus before/after owning our name and receiving |
1181 | 68 | * method calls on our objects (which may not yet be up!)*/ | 68 | * method calls on our objects (which may not yet be up!)*/ |
1183 | 69 | if (dbus_name_has_owner ("com.canonical.Unity.ApplicationsPlace")) | 69 | if (dbus_name_has_owner ("com.canonical.Unity.Lens.Applications")) |
1184 | 70 | { | 70 | { |
1185 | 71 | print ("Another instance of the Unity Applications Daemon " + | 71 | print ("Another instance of the Unity Applications Daemon " + |
1186 | 72 | "already appears to be running.\nBailing out.\n"); | 72 | "already appears to be running.\nBailing out.\n"); |
1187 | @@ -78,7 +78,7 @@ | |||
1188 | 78 | daemon = new Daemon (); | 78 | daemon = new Daemon (); |
1189 | 79 | 79 | ||
1190 | 80 | /* Use GApplication directly for single instance app functionality */ | 80 | /* Use GApplication directly for single instance app functionality */ |
1192 | 81 | app = new Application ("com.canonical.Unity.ApplicationsPlace", | 81 | app = new Application ("com.canonical.Unity.Lens.Applications", |
1193 | 82 | ApplicationFlags.IS_SERVICE); | 82 | ApplicationFlags.IS_SERVICE); |
1194 | 83 | try { | 83 | try { |
1195 | 84 | app.register (); | 84 | app.register (); |
1196 | 85 | 85 | ||
1197 | === modified file 'src/runner.vala' | |||
1198 | --- src/runner.vala 2011-07-20 06:43:25 +0000 | |||
1199 | +++ src/runner.vala 2011-08-04 08:16:52 +0000 | |||
1200 | @@ -21,7 +21,7 @@ | |||
1201 | 21 | using Gee; | 21 | using Gee; |
1202 | 22 | 22 | ||
1203 | 23 | 23 | ||
1205 | 24 | namespace Unity.ApplicationsPlace { | 24 | namespace Unity.ApplicationsLens { |
1206 | 25 | 25 | ||
1207 | 26 | private class AboutEntry { | 26 | private class AboutEntry { |
1208 | 27 | public string name; | 27 | public string name; |
1209 | @@ -39,20 +39,21 @@ | |||
1210 | 39 | public class Runner: GLib.Object | 39 | public class Runner: GLib.Object |
1211 | 40 | { | 40 | { |
1212 | 41 | 41 | ||
1215 | 42 | private Unity.ApplicationsPlace.Daemon daemon; | 42 | private Unity.ApplicationsLens.Daemon daemon; |
1216 | 43 | private const string BUS_NAME_PREFIX = "com.canonical.Unity.ApplicationsPlace.Runner"; | 43 | private const string BUS_NAME_PREFIX = "com.canonical.Unity.ApplicationsLens.Runner"; |
1217 | 44 | 44 | ||
1218 | 45 | /* for now, load the same keys as gnome-panel */ | 45 | /* for now, load the same keys as gnome-panel */ |
1219 | 46 | private const string HISTORY_KEY = "history"; | 46 | private const string HISTORY_KEY = "history"; |
1220 | 47 | private const int MAX_HISTORY = 10; | 47 | private const int MAX_HISTORY = 10; |
1221 | 48 | 48 | ||
1223 | 49 | public Unity.PlaceEntryInfo place_entry; | 49 | public Unity.Lens lens; |
1224 | 50 | public Unity.Scope scope; | ||
1225 | 50 | 51 | ||
1226 | 51 | private bool all_models_synced; | 52 | private bool all_models_synced; |
1227 | 52 | 53 | ||
1228 | 53 | /* We remember the previous search so we can figure out if we should do | 54 | /* We remember the previous search so we can figure out if we should do |
1229 | 54 | * incremental filtering of the result models */ | 55 | * incremental filtering of the result models */ |
1231 | 55 | private PlaceSearch? previous_search; | 56 | private LensSearch? previous_search; |
1232 | 56 | 57 | ||
1233 | 57 | private Gee.HashMap<string,AboutEntry> about_entries; | 58 | private Gee.HashMap<string,AboutEntry> about_entries; |
1234 | 58 | private Gee.List<string> executables; | 59 | private Gee.List<string> executables; |
1235 | @@ -60,22 +61,61 @@ | |||
1236 | 60 | 61 | ||
1237 | 61 | private Settings gp_settings; | 62 | private Settings gp_settings; |
1238 | 62 | 63 | ||
1240 | 63 | public Runner (Unity.ApplicationsPlace.Daemon daemon) | 64 | public Runner (Unity.ApplicationsLens.Daemon daemon) |
1241 | 64 | { | 65 | { |
1256 | 65 | var sections_model = new Dee.SharedModel(BUS_NAME_PREFIX + "SectionsModel"); | 66 | /* First create scope */ |
1257 | 66 | sections_model.set_schema ("s", "s"); | 67 | scope = new Unity.Scope ("/com/canonical/unity/scope/commands"); |
1258 | 67 | 68 | scope.search_in_global = false; | |
1259 | 68 | var groups_model = new Dee.SharedModel(BUS_NAME_PREFIX + "GroupsModel"); | 69 | |
1260 | 69 | groups_model.set_schema ("s", "s", "s"); | 70 | /* Listen for changes to the lens scope search */ |
1261 | 70 | 71 | scope.notify["active-search"].connect ( | |
1262 | 71 | var results_model = new Dee.SharedModel(BUS_NAME_PREFIX + "ResultsModel"); | 72 | (obj, pspec) => { |
1263 | 72 | results_model.set_schema ("s", "s", "u", "s", "s", "s"); | 73 | var search = scope.active_search; |
1264 | 73 | 74 | ||
1265 | 74 | place_entry = new PlaceEntryInfo ("/com/canonical/unity/applicationsplace/runner"); | 75 | if (!Utils.search_has_really_changed (previous_search, search)) |
1266 | 75 | place_entry.sections_model = sections_model; | 76 | return; |
1267 | 76 | place_entry.entry_renderer_info.groups_model = groups_model; | 77 | |
1268 | 77 | place_entry.entry_renderer_info.results_model = results_model; | 78 | update_search.begin(search); |
1269 | 78 | 79 | previous_search = search; | |
1270 | 80 | } | ||
1271 | 81 | ); | ||
1272 | 82 | |||
1273 | 83 | /* Re-do the search if the filters changed */ | ||
1274 | 84 | scope.filters_changed.connect ( | ||
1275 | 85 | () => { | ||
1276 | 86 | var search = scope.active_search; | ||
1277 | 87 | if (search.search_string == null) | ||
1278 | 88 | return; | ||
1279 | 89 | |||
1280 | 90 | update_search.begin(search); | ||
1281 | 91 | previous_search = search; | ||
1282 | 92 | |||
1283 | 93 | } | ||
1284 | 94 | ); | ||
1285 | 95 | |||
1286 | 96 | // Listen for when the lens is hidden/shown by the Unity Shell | ||
1287 | 97 | scope.notify["active"].connect( | ||
1288 | 98 | (obj, pspec) => { | ||
1289 | 99 | if (scope.active) | ||
1290 | 100 | { | ||
1291 | 101 | var search = scope.active_search; | ||
1292 | 102 | update_search.begin(search); | ||
1293 | 103 | previous_search = search; | ||
1294 | 104 | } | ||
1295 | 105 | } | ||
1296 | 106 | ); | ||
1297 | 107 | |||
1298 | 108 | scope.activate_uri.connect (daemon.activate); | ||
1299 | 109 | |||
1300 | 110 | /* Now create Lens */ | ||
1301 | 111 | lens = new Unity.Lens ("/com/canonical/unity/lens/commands", "commands"); | ||
1302 | 112 | lens.search_hint = _("Run a command"); | ||
1303 | 113 | lens.visible = false; | ||
1304 | 114 | lens.search_in_global = false; | ||
1305 | 115 | populate_categories (); | ||
1306 | 116 | //populate_filters(); | ||
1307 | 117 | lens.add_local_scope (scope); | ||
1308 | 118 | lens.export (); | ||
1309 | 79 | previous_search = null; | 119 | previous_search = null; |
1310 | 80 | 120 | ||
1311 | 81 | /* create the private about entries */ | 121 | /* create the private about entries */ |
1312 | @@ -89,78 +129,59 @@ | |||
1313 | 89 | history = new Gee.ArrayList<string> (); | 129 | history = new Gee.ArrayList<string> (); |
1314 | 90 | load_history (); | 130 | load_history (); |
1315 | 91 | 131 | ||
1316 | 92 | /* Listen for changes to the place entry search */ | ||
1317 | 93 | place_entry.notify["active-search"].connect ( | ||
1318 | 94 | (obj, pspec) => { | ||
1319 | 95 | if (!all_models_synced) | ||
1320 | 96 | return; | ||
1321 | 97 | |||
1322 | 98 | var search = place_entry.active_search; | ||
1323 | 99 | |||
1324 | 100 | if (!Utils.search_has_really_changed (previous_search, search)) | ||
1325 | 101 | return; | ||
1326 | 102 | |||
1327 | 103 | update_search.begin(search); | ||
1328 | 104 | previous_search = search; | ||
1329 | 105 | } | ||
1330 | 106 | ); | ||
1331 | 107 | |||
1332 | 108 | // Listen for when the place is hidden/shown by the Unity Shell | ||
1333 | 109 | place_entry.notify["active"].connect( | ||
1334 | 110 | (obj, pspec) => { | ||
1335 | 111 | if (place_entry.active) | ||
1336 | 112 | { | ||
1337 | 113 | var search = place_entry.active_search; | ||
1338 | 114 | update_search.begin(search); | ||
1339 | 115 | previous_search = search; | ||
1340 | 116 | } | ||
1341 | 117 | } | ||
1342 | 118 | ); | ||
1343 | 119 | |||
1344 | 120 | /* We should not start manipulating any of our models before they are | ||
1345 | 121 | * all synchronized. When they are we set all_models_synced = true */ | ||
1346 | 122 | sections_model.notify["synchronized"].connect (check_models_synced); | ||
1347 | 123 | groups_model.notify["synchronized"].connect (check_models_synced); | ||
1348 | 124 | results_model.notify["synchronized"].connect (check_models_synced); | ||
1349 | 125 | all_models_synced = false; | ||
1350 | 126 | |||
1351 | 127 | this.daemon = daemon; | 132 | this.daemon = daemon; |
1352 | 128 | 133 | ||
1353 | 129 | } | 134 | } |
1354 | 130 | 135 | ||
1358 | 131 | private async void update_search (PlaceSearch? search) | 136 | private void populate_categories () |
1359 | 132 | { | 137 | { |
1360 | 133 | var model = place_entry.entry_renderer_info.results_model; | 138 | Unity.Category[] categories = {}; |
1361 | 139 | |||
1362 | 140 | var cat = new Unity.Category (_("Results"), | ||
1363 | 141 | ICON_PATH + "category-installed.svg"); | ||
1364 | 142 | categories += cat; | ||
1365 | 143 | |||
1366 | 144 | cat = new Unity.Category (_("History"), | ||
1367 | 145 | ICON_PATH + "category-available.svg"); | ||
1368 | 146 | |||
1369 | 147 | categories += cat; | ||
1370 | 148 | |||
1371 | 149 | lens.categories = categories; | ||
1372 | 150 | } | ||
1373 | 151 | |||
1374 | 152 | private async void update_search (LensSearch? search) | ||
1375 | 153 | { | ||
1376 | 154 | var model = scope.results_model; | ||
1377 | 134 | var executables_match = new Gee.ArrayList<string> (); | 155 | var executables_match = new Gee.ArrayList<string> (); |
1378 | 135 | var dirs_match = new Gee.ArrayList<string> (); | 156 | var dirs_match = new Gee.ArrayList<string> (); |
1379 | 136 | model.clear (); | 157 | model.clear (); |
1380 | 137 | 158 | ||
1382 | 138 | var search_string = search.get_search_string (); | 159 | var search_string = search.search_string; |
1383 | 139 | bool has_search = !Utils.search_is_invalid (search); | 160 | bool has_search = !Utils.search_is_invalid (search); |
1384 | 140 | 161 | ||
1385 | 141 | string uri; | 162 | string uri; |
1386 | 142 | Icon icon; | 163 | Icon icon; |
1387 | 143 | string mimetype; | 164 | string mimetype; |
1388 | 144 | string display_name; | 165 | string display_name; |
1390 | 145 | var group_id = RunnerGroup.HISTORY; | 166 | var category_id = RunnerCategory.HISTORY; |
1391 | 146 | 167 | ||
1392 | 147 | foreach (var command in this.history) | 168 | foreach (var command in this.history) |
1393 | 148 | { | 169 | { |
1394 | 149 | display_name = get_icon_uri_and_mimetype (command, out icon, out uri, out mimetype); | 170 | display_name = get_icon_uri_and_mimetype (command, out icon, out uri, out mimetype); |
1395 | 150 | model.append (uri, icon.to_string (), | 171 | model.append (uri, icon.to_string (), |
1397 | 151 | group_id, mimetype, | 172 | category_id, mimetype, |
1398 | 152 | display_name, | 173 | display_name, |
1399 | 153 | null); | 174 | null); |
1400 | 154 | } | 175 | } |
1401 | 155 | 176 | ||
1402 | 156 | /* Prevent concurrent searches and concurrent updates of our models, | 177 | /* Prevent concurrent searches and concurrent updates of our models, |
1403 | 157 | * by preventing any notify signals from propagating to us. | 178 | * by preventing any notify signals from propagating to us. |
1406 | 158 | * Important: Remember to thaw the notifys with release_entrylock()! */ | 179 | * Important: Remember to thaw the notifys with release_scopelock()! */ |
1407 | 159 | place_entry.freeze_notify (); | 180 | scope.freeze_notify (); |
1408 | 160 | 181 | ||
1409 | 161 | if (!has_search) | 182 | if (!has_search) |
1410 | 162 | { | 183 | { |
1412 | 163 | release_entrylock (); | 184 | release_scopelock (); |
1413 | 164 | search.finished (); | 185 | search.finished (); |
1414 | 165 | return; | 186 | return; |
1415 | 166 | } | 187 | } |
1416 | @@ -177,7 +198,7 @@ | |||
1417 | 177 | 0, "no-mime", | 198 | 0, "no-mime", |
1418 | 178 | commenteaster, | 199 | commenteaster, |
1419 | 179 | null); | 200 | null); |
1421 | 180 | release_entrylock (); | 201 | release_scopelock (); |
1422 | 181 | search.finished (); | 202 | search.finished (); |
1423 | 182 | return; | 203 | return; |
1424 | 183 | } | 204 | } |
1425 | @@ -190,7 +211,7 @@ | |||
1426 | 190 | 0, "no-mime", | 211 | 0, "no-mime", |
1427 | 191 | commentnoeaster, | 212 | commentnoeaster, |
1428 | 192 | null); | 213 | null); |
1430 | 193 | release_entrylock (); | 214 | release_scopelock (); |
1431 | 194 | search.finished (); | 215 | search.finished (); |
1432 | 195 | return; | 216 | return; |
1433 | 196 | 217 | ||
1434 | @@ -261,13 +282,13 @@ | |||
1435 | 261 | executables_match.sort (); | 282 | executables_match.sort (); |
1436 | 262 | dirs_match.sort (); | 283 | dirs_match.sort (); |
1437 | 263 | 284 | ||
1439 | 264 | group_id = RunnerGroup.RESULTS; | 285 | category_id = RunnerCategory.RESULTS; |
1440 | 265 | 286 | ||
1441 | 266 | // populate results | 287 | // populate results |
1442 | 267 | // 1. enable launching the exact search string | 288 | // 1. enable launching the exact search string |
1443 | 268 | display_name = get_icon_uri_and_mimetype (search_string, out icon, out uri, out mimetype); | 289 | display_name = get_icon_uri_and_mimetype (search_string, out icon, out uri, out mimetype); |
1444 | 269 | model.append (uri.strip (), icon.to_string (), | 290 | model.append (uri.strip (), icon.to_string (), |
1446 | 270 | group_id, mimetype, | 291 | category_id, mimetype, |
1447 | 271 | display_name, | 292 | display_name, |
1448 | 272 | null); | 293 | null); |
1449 | 273 | 294 | ||
1450 | @@ -278,7 +299,7 @@ | |||
1451 | 278 | { | 299 | { |
1452 | 279 | uri = @"unity-runner://$(dir)"; | 300 | uri = @"unity-runner://$(dir)"; |
1453 | 280 | model.append (uri, icon.to_string (), | 301 | model.append (uri, icon.to_string (), |
1455 | 281 | group_id, mimetype, | 302 | category_id, mimetype, |
1456 | 282 | dir, | 303 | dir, |
1457 | 283 | null); | 304 | null); |
1458 | 284 | } | 305 | } |
1459 | @@ -291,7 +312,7 @@ | |||
1460 | 291 | display_name = get_icon_uri_and_mimetype (final_exec, out icon, out uri, out mimetype); | 312 | display_name = get_icon_uri_and_mimetype (final_exec, out icon, out uri, out mimetype); |
1461 | 292 | 313 | ||
1462 | 293 | model.append (uri, icon.to_string (), | 314 | model.append (uri, icon.to_string (), |
1464 | 294 | group_id, mimetype, | 315 | category_id, mimetype, |
1465 | 295 | display_name, | 316 | display_name, |
1466 | 296 | null); | 317 | null); |
1467 | 297 | } | 318 | } |
1468 | @@ -301,18 +322,18 @@ | |||
1469 | 301 | dirs_match.size, executables_match.size, timer.elapsed ()*1000, search_string); | 322 | dirs_match.size, executables_match.size, timer.elapsed ()*1000, search_string); |
1470 | 302 | 323 | ||
1471 | 303 | 324 | ||
1473 | 304 | release_entrylock (); | 325 | release_scopelock (); |
1474 | 305 | search.finished (); | 326 | search.finished (); |
1475 | 306 | } | 327 | } |
1476 | 307 | 328 | ||
1478 | 308 | private void release_entrylock () | 329 | private void release_scopelock () |
1479 | 309 | { | 330 | { |
1480 | 310 | /* Allow new searches once we enter an idle again. | 331 | /* Allow new searches once we enter an idle again. |
1481 | 311 | * We don't do it directly from here as that could mean we start | 332 | * We don't do it directly from here as that could mean we start |
1482 | 312 | * changing the model even before we had flushed out current changes | 333 | * changing the model even before we had flushed out current changes |
1483 | 313 | */ | 334 | */ |
1484 | 314 | Idle.add (() => { | 335 | Idle.add (() => { |
1486 | 315 | place_entry.thaw_notify (); | 336 | scope.thaw_notify (); |
1487 | 316 | return false; | 337 | return false; |
1488 | 317 | }); | 338 | }); |
1489 | 318 | } | 339 | } |
1490 | @@ -395,51 +416,8 @@ | |||
1491 | 395 | return exec_string; | 416 | return exec_string; |
1492 | 396 | 417 | ||
1493 | 397 | } | 418 | } |
1539 | 398 | 419 | ||
1540 | 399 | 420 | ||
1496 | 400 | /* The check_models_synced() method acts like a latch - once all models | ||
1497 | 401 | * have reported themselves to be synchronized we set | ||
1498 | 402 | * all_models_synced = true and tell the searches to re-check their state | ||
1499 | 403 | * as they should refuse to run when all_models_synced == false */ | ||
1500 | 404 | private void check_models_synced (Object obj, ParamSpec pspec) | ||
1501 | 405 | { | ||
1502 | 406 | if ((place_entry.sections_model as Dee.SharedModel).synchronized && | ||
1503 | 407 | (place_entry.entry_renderer_info.groups_model as Dee.SharedModel).synchronized && | ||
1504 | 408 | (place_entry.entry_renderer_info.results_model as Dee.SharedModel).synchronized) { | ||
1505 | 409 | if (all_models_synced == false) | ||
1506 | 410 | { | ||
1507 | 411 | all_models_synced = true; | ||
1508 | 412 | |||
1509 | 413 | populate_groups (place_entry.entry_renderer_info.groups_model); | ||
1510 | 414 | |||
1511 | 415 | /* Emitting notify here will make us recheck if the search results | ||
1512 | 416 | * need update. In the negative case this is a noop */ | ||
1513 | 417 | place_entry.notify_property ("active-search"); | ||
1514 | 418 | } | ||
1515 | 419 | } | ||
1516 | 420 | } | ||
1517 | 421 | |||
1518 | 422 | private void populate_groups (Dee.Model groups) | ||
1519 | 423 | { | ||
1520 | 424 | if (groups.get_n_rows() != 0) | ||
1521 | 425 | { | ||
1522 | 426 | debug ("The groups model already populated. We probably cloned it off Unity. Rebuilding."); | ||
1523 | 427 | groups.clear (); | ||
1524 | 428 | } | ||
1525 | 429 | |||
1526 | 430 | // TODO: needs asset | ||
1527 | 431 | groups.append ("UnityDefaultRenderer", | ||
1528 | 432 | _("Results"), | ||
1529 | 433 | ICON_PATH + "group-installed.svg"); | ||
1530 | 434 | groups.append ("UnityDefaultRenderer", | ||
1531 | 435 | _("History"), | ||
1532 | 436 | ICON_PATH + "group-available.svg"); | ||
1533 | 437 | |||
1534 | 438 | /* expand the history */ | ||
1535 | 439 | place_entry.entry_renderer_info.set_hint ("ExpandedGroups", | ||
1536 | 440 | @"$((uint)RunnerGroup.HISTORY)"); | ||
1537 | 441 | } | ||
1538 | 442 | |||
1541 | 443 | public void add_history (string last_command) | 421 | public void add_history (string last_command) |
1542 | 444 | { | 422 | { |
1543 | 445 | 423 | ||
1544 | @@ -472,7 +450,7 @@ | |||
1545 | 472 | } | 450 | } |
1546 | 473 | 451 | ||
1547 | 474 | // force a search to refresh history order (TODO: be more clever in the future) | 452 | // force a search to refresh history order (TODO: be more clever in the future) |
1549 | 475 | update_search.begin(place_entry.active_search); | 453 | update_search.begin(scope.active_search); |
1550 | 476 | } | 454 | } |
1551 | 477 | 455 | ||
1552 | 478 | private void load_history () | 456 | private void load_history () |
1553 | 479 | 457 | ||
1554 | === modified file 'src/schemas.vala' | |||
1555 | --- src/schemas.vala 2011-03-10 10:56:46 +0000 | |||
1556 | +++ src/schemas.vala 2011-08-04 08:16:52 +0000 | |||
1557 | @@ -17,7 +17,7 @@ | |||
1558 | 17 | * | 17 | * |
1559 | 18 | */ | 18 | */ |
1560 | 19 | 19 | ||
1562 | 20 | namespace Unity.ApplicationsPlace { | 20 | namespace Unity.ApplicationsLens { |
1563 | 21 | 21 | ||
1564 | 22 | public enum ResultsColumn | 22 | public enum ResultsColumn |
1565 | 23 | { | 23 | { |
1566 | @@ -29,38 +29,7 @@ | |||
1567 | 29 | COMMENT | 29 | COMMENT |
1568 | 30 | } | 30 | } |
1569 | 31 | 31 | ||
1602 | 32 | public enum SectionsColumn | 32 | public enum Category |
1571 | 33 | { | ||
1572 | 34 | DISPLAY_NAME = 0, | ||
1573 | 35 | ICON_HINT | ||
1574 | 36 | } | ||
1575 | 37 | |||
1576 | 38 | public enum Section | ||
1577 | 39 | { | ||
1578 | 40 | ALL_APPLICATIONS = 0, | ||
1579 | 41 | ACCESSORIES, | ||
1580 | 42 | UNIVERSAL_ACCESS, | ||
1581 | 43 | DEVELOPER_TOOLS, | ||
1582 | 44 | EDUCATION, | ||
1583 | 45 | SCIENCE, | ||
1584 | 46 | GAMES, | ||
1585 | 47 | GRAPHICS, | ||
1586 | 48 | INTERNET, | ||
1587 | 49 | MULTIMEDIA, | ||
1588 | 50 | OFFICE, | ||
1589 | 51 | THEMES, | ||
1590 | 52 | SYSTEM, | ||
1591 | 53 | LAST_SECTION | ||
1592 | 54 | } | ||
1593 | 55 | |||
1594 | 56 | public enum GroupsColumn | ||
1595 | 57 | { | ||
1596 | 58 | RENDERER = 0, | ||
1597 | 59 | DISPLAY_NAME, | ||
1598 | 60 | ICON_HINT | ||
1599 | 61 | } | ||
1600 | 62 | |||
1601 | 63 | public enum Group | ||
1603 | 64 | { | 33 | { |
1604 | 65 | MOST_USED, | 34 | MOST_USED, |
1605 | 66 | INSTALLED, | 35 | INSTALLED, |
1606 | @@ -69,7 +38,7 @@ | |||
1607 | 69 | EMPTY_SECTION | 38 | EMPTY_SECTION |
1608 | 70 | } | 39 | } |
1609 | 71 | 40 | ||
1611 | 72 | public enum RunnerGroup | 41 | public enum RunnerCategory |
1612 | 73 | { | 42 | { |
1613 | 74 | RESULTS, | 43 | RESULTS, |
1614 | 75 | HISTORY | 44 | HISTORY |
1615 | 76 | 45 | ||
1616 | === modified file 'src/utils.vala' | |||
1617 | --- src/utils.vala 2011-03-31 01:30:09 +0000 | |||
1618 | +++ src/utils.vala 2011-08-04 08:16:52 +0000 | |||
1619 | @@ -20,7 +20,7 @@ | |||
1620 | 20 | using Unity; | 20 | using Unity; |
1621 | 21 | using Gee; | 21 | using Gee; |
1622 | 22 | 22 | ||
1624 | 23 | namespace Unity.ApplicationsPlace.Utils | 23 | namespace Unity.ApplicationsLens.Utils |
1625 | 24 | { | 24 | { |
1626 | 25 | 25 | ||
1627 | 26 | public AppInfo? get_app_info_for_actor (string actor) | 26 | public AppInfo? get_app_info_for_actor (string actor) |
1628 | @@ -71,22 +71,22 @@ | |||
1629 | 71 | return actor; | 71 | return actor; |
1630 | 72 | } | 72 | } |
1631 | 73 | 73 | ||
1633 | 74 | public bool search_is_invalid (PlaceSearch? search) | 74 | public bool search_is_invalid (Unity.LensSearch? search) |
1634 | 75 | { | 75 | { |
1635 | 76 | /* This boolean expression is unfolded as we seem to get | 76 | /* This boolean expression is unfolded as we seem to get |
1636 | 77 | * some null dereference if we join them in a big || expression */ | 77 | * some null dereference if we join them in a big || expression */ |
1637 | 78 | if (search == null) | 78 | if (search == null) |
1638 | 79 | return true; | 79 | return true; |
1640 | 80 | else if (search.get_search_string () == null) | 80 | else if (search.search_string == null) |
1641 | 81 | return true; | 81 | return true; |
1642 | 82 | 82 | ||
1644 | 83 | return search.get_search_string () == ""; | 83 | return search.search_string == ""; |
1645 | 84 | } | 84 | } |
1646 | 85 | 85 | ||
1647 | 86 | /* Sloppy and null-safe equality checking. null == "" and strings | 86 | /* Sloppy and null-safe equality checking. null == "" and strings |
1648 | 87 | * are stripped of whitespace before comparison */ | 87 | * are stripped of whitespace before comparison */ |
1651 | 88 | private bool search_has_really_changed (PlaceSearch? old_search, | 88 | private bool search_has_really_changed (Unity.LensSearch? old_search, |
1652 | 89 | PlaceSearch? new_search) | 89 | Unity.LensSearch? new_search) |
1653 | 90 | { | 90 | { |
1654 | 91 | if (old_search == null && new_search == null) | 91 | if (old_search == null && new_search == null) |
1655 | 92 | return false; | 92 | return false; |
1656 | @@ -95,7 +95,7 @@ | |||
1657 | 95 | 95 | ||
1658 | 96 | if (old_search == null) | 96 | if (old_search == null) |
1659 | 97 | { | 97 | { |
1661 | 98 | s1 = new_search.get_search_string (); | 98 | s1 = new_search.search_string; |
1662 | 99 | if (s1 == null || s1.strip() == "") | 99 | if (s1 == null || s1.strip() == "") |
1663 | 100 | return false; | 100 | return false; |
1664 | 101 | else | 101 | else |
1665 | @@ -103,7 +103,7 @@ | |||
1666 | 103 | } | 103 | } |
1667 | 104 | else if (new_search == null) | 104 | else if (new_search == null) |
1668 | 105 | { | 105 | { |
1670 | 106 | s2 = old_search.get_search_string (); | 106 | s2 = old_search.search_string; |
1671 | 107 | if (s2 == null || s2.strip() == "") | 107 | if (s2 == null || s2.strip() == "") |
1672 | 108 | return false; | 108 | return false; |
1673 | 109 | else | 109 | else |
1674 | @@ -111,8 +111,8 @@ | |||
1675 | 111 | } | 111 | } |
1676 | 112 | else | 112 | else |
1677 | 113 | { | 113 | { |
1680 | 114 | s1 = new_search.get_search_string (); | 114 | s1 = new_search.search_string; |
1681 | 115 | s2 = old_search.get_search_string (); | 115 | s2 = old_search.search_string; |
1682 | 116 | if (s1 == null) | 116 | if (s1 == null) |
1683 | 117 | { | 117 | { |
1684 | 118 | if (s2 == null || s2.strip() == "") | 118 | if (s2 == null || s2.strip() == "") |
Looks pretty much like a port from the new api to the old. Looks good to me.