Merge lp:~tintou/slingshot/elementarize into lp:~elementary-pantheon/slingshot/trunk
- elementarize
- Merge into trunk
Proposed by
Corentin Noël
Status: | Merged |
---|---|
Approved by: | Cody Garver |
Approved revision: | 397 |
Merged at revision: | 399 |
Proposed branch: | lp:~tintou/slingshot/elementarize |
Merge into: | lp:~elementary-pantheon/slingshot/trunk |
Diff against target: |
3434 lines (+1306/-1517) 20 files modified
CMakeLists.txt (+10/-9) cmake/FindGirCompiler.cmake (+56/-0) cmake/Makefile (+0/-286) cmake/Tests.cmake (+5/-0) cmake/Translations.cmake (+2/-1) cmake/ValaPrecompile.cmake (+85/-12) po/CMakeLists.txt (+3/-5) src/Backend/App.vala (+133/-137) src/Backend/AppSystem.vala (+206/-214) src/Backend/DBusService.vala (+51/-54) src/Backend/RelevancyService.vala (+150/-145) src/Settings.vala (+22/-28) src/Slingshot.vala (+84/-91) src/SlingshotView.vala (+36/-46) src/Widgets/AppEntry.vala (+125/-132) src/Widgets/CategoryView.vala (+197/-206) src/Widgets/Grid.vala (+5/-7) src/Widgets/SearchItem.vala (+11/-14) src/Widgets/SearchView.vala (+17/-16) src/Widgets/Sidebar.vala (+108/-114) |
To merge this branch: | bzr merge lp:~tintou/slingshot/elementarize |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
elementary Pantheon team | Pending | ||
Review via email: mp+200043@code.launchpad.net |
Commit message
* Removed every using statement
* Changed VWidgets and HWidgets to Widgets with the corresponding orientation (Gtk deprecation)
* Ported Zeitgeist parts to version 2.0
Description of the change
* Removed every using statement
* changed VWidgets and HWidgets to Widgets with the corresponding orientation (Gtk deprecation)
* ported Zeitgeist parts to version 2.0 (requires new deb-packaging)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-12-07 08:28:42 +0000 |
3 | +++ CMakeLists.txt 2013-12-26 00:13:32 +0000 |
4 | @@ -6,9 +6,10 @@ |
5 | |
6 | project (slingshot) |
7 | |
8 | +set (APPNAME "${CMAKE_PROJECT_NAME}-launcher") |
9 | set (DATADIR "${CMAKE_INSTALL_PREFIX}/share") |
10 | -set (PKGDATADIR "${DATADIR}/slingshot") |
11 | -set (GETTEXT_PACKAGE "slingshot") |
12 | +set (PKGDATADIR "${DATADIR}/${CMAKE_PROJECT_NAME}") |
13 | +set (GETTEXT_PACKAGE "${CMAKE_PROJECT_NAME}") |
14 | set (RELEASE_NAME "Donatello") |
15 | set (VERSION "0.7.6.1") |
16 | set (VERSION_INFO "Release") |
17 | @@ -34,7 +35,7 @@ |
18 | # Slingshot |
19 | |
20 | set (CORE_DEPS "gobject-2.0;glib-2.0;gio-2.0;gio-unix-2.0;gee-1.0;libgnome-menu;libwnck-3.0;gdk-x11-3.0;unity;") |
21 | -set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-1.0;") |
22 | +set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-2.0;") |
23 | |
24 | find_package (PkgConfig) |
25 | pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0) |
26 | @@ -44,7 +45,7 @@ |
27 | ensure_vala_version ("0.15.1" MINIMUM) |
28 | |
29 | include (ValaPrecompile) |
30 | -vala_precompile (VALA_C |
31 | +vala_precompile (VALA_C ${APPNAME} |
32 | src/Slingshot.vala |
33 | src/SlingshotView.vala |
34 | src/Settings.vala |
35 | @@ -66,7 +67,7 @@ |
36 | CUSTOM_VAPIS |
37 | vapi/config.vapi |
38 | OPTIONS |
39 | - --thread |
40 | + --thread |
41 | -g |
42 | ) |
43 | |
44 | @@ -77,11 +78,11 @@ |
45 | link_libraries (${DEPS_LIBRARIES}) |
46 | link_directories (${DEPS_LIBRARY_DIRS}) |
47 | |
48 | -add_executable (slingshot-launcher ${VALA_C}) |
49 | -target_link_libraries(slingshot-launcher m) |
50 | +add_executable (${APPNAME} ${VALA_C}) |
51 | +target_link_libraries(${APPNAME} m) |
52 | |
53 | # Installation |
54 | -install (TARGETS slingshot-launcher RUNTIME DESTINATION bin) |
55 | +install (TARGETS ${APPNAME} RUNTIME DESTINATION bin) |
56 | install (FILES ${applications_menu} DESTINATION /etc/xdg/menus) |
57 | |
58 | # |
59 | @@ -91,4 +92,4 @@ |
60 | add_schema ("org.pantheon.desktop.slingshot.gschema.xml") |
61 | |
62 | # Translations |
63 | -add_subdirectory (po) |
64 | +add_subdirectory (po) |
65 | \ No newline at end of file |
66 | |
67 | === added file 'cmake/FindGirCompiler.cmake' |
68 | --- cmake/FindGirCompiler.cmake 1970-01-01 00:00:00 +0000 |
69 | +++ cmake/FindGirCompiler.cmake 2013-12-26 00:13:32 +0000 |
70 | @@ -0,0 +1,56 @@ |
71 | +## |
72 | +# Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
73 | +# |
74 | +# Redistribution and use in source and binary forms, with or without |
75 | +# modification, are permitted provided that the following conditions are met: |
76 | +# |
77 | +# 1. Redistributions of source code must retain the above copyright notice, |
78 | +# this list of conditions and the following disclaimer. |
79 | +# |
80 | +# 2. Redistributions in binary form must reproduce the above copyright notice, |
81 | +# this list of conditions and the following disclaimer in the documentation |
82 | +# and/or other materials provided with the distribution. |
83 | +# |
84 | +# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR |
85 | +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
86 | +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
87 | +# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
88 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
89 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
90 | +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
91 | +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
92 | +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
93 | +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
94 | +# |
95 | +# The views and conclusions contained in the software and documentation are those |
96 | +# of the authors and should not be interpreted as representing official policies, |
97 | +# either expressed or implied, of Jakob Westhoff |
98 | +## |
99 | + |
100 | +## |
101 | +# Find module for the Gir compiler (g-ir-compiler) |
102 | +# |
103 | +# This module determines wheter a Gir compiler is installed on the current |
104 | +# system and where its executable is. |
105 | +# |
106 | +# Call the module using "find_package(GirCompiler) from within your CMakeLists.txt. |
107 | +# |
108 | +# The following variables will be set after an invocation: |
109 | +# |
110 | +# G_IR_COMPILER_FOUND Whether the g-ir-compiler compiler has been found or not |
111 | +# G_IR_COMPILER_EXECUTABLE Full path to the g-ir-compiler executable if it has been found |
112 | +## |
113 | + |
114 | + |
115 | +# Search for the g-ir-compiler executable in the usual system paths. |
116 | +find_program (G_IR_COMPILER_EXECUTABLE |
117 | + NAMES g-ir-compiler) |
118 | + |
119 | +# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. |
120 | +# Furthermore set G_IR_COMPILER_FOUND to TRUE if the g-ir-compiler has been found (aka. |
121 | +# G_IR_COMPILER_EXECUTABLE is set) |
122 | + |
123 | +include (FindPackageHandleStandardArgs) |
124 | +find_package_handle_standard_args (GirCompiler DEFAULT_MSG G_IR_COMPILER_EXECUTABLE) |
125 | + |
126 | +mark_as_advanced (G_IR_COMPILER_EXECUTABLE) |
127 | |
128 | === removed file 'cmake/Makefile' |
129 | --- cmake/Makefile 2011-09-07 10:52:19 +0000 |
130 | +++ cmake/Makefile 1970-01-01 00:00:00 +0000 |
131 | @@ -1,286 +0,0 @@ |
132 | -# CMAKE generated file: DO NOT EDIT! |
133 | -# Generated by "Unix Makefiles" Generator, CMake Version 2.8 |
134 | - |
135 | -# Default target executed when no arguments are given to make. |
136 | -default_target: all |
137 | -.PHONY : default_target |
138 | - |
139 | -#============================================================================= |
140 | -# Special targets provided by cmake. |
141 | - |
142 | -# Disable implicit rules so canoncical targets will work. |
143 | -.SUFFIXES: |
144 | - |
145 | -# Remove some rules from gmake that .SUFFIXES does not remove. |
146 | -SUFFIXES = |
147 | - |
148 | -.SUFFIXES: .hpux_make_needs_suffix_list |
149 | - |
150 | -# Suppress display of executed commands. |
151 | -$(VERBOSE).SILENT: |
152 | - |
153 | -# A target that is always out of date. |
154 | -cmake_force: |
155 | -.PHONY : cmake_force |
156 | - |
157 | -#============================================================================= |
158 | -# Set environment variables for the build. |
159 | - |
160 | -# The shell in which to execute make rules. |
161 | -SHELL = /bin/sh |
162 | - |
163 | -# The CMake executable. |
164 | -CMAKE_COMMAND = /usr/bin/cmake |
165 | - |
166 | -# The command to remove a file. |
167 | -RM = /usr/bin/cmake -E remove -f |
168 | - |
169 | -# The top-level source directory on which CMake was run. |
170 | -CMAKE_SOURCE_DIR = /home/mefrio/Scrivania/cmake |
171 | - |
172 | -# The top-level build directory on which CMake was run. |
173 | -CMAKE_BINARY_DIR = /home/mefrio/Scrivania/cmake/cmake |
174 | - |
175 | -#============================================================================= |
176 | -# Targets provided globally by CMake. |
177 | - |
178 | -# Special rule for the target edit_cache |
179 | -edit_cache: |
180 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." |
181 | - /usr/bin/cmake -i . |
182 | -.PHONY : edit_cache |
183 | - |
184 | -# Special rule for the target edit_cache |
185 | -edit_cache/fast: edit_cache |
186 | -.PHONY : edit_cache/fast |
187 | - |
188 | -# Special rule for the target install |
189 | -install: preinstall |
190 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." |
191 | - /usr/bin/cmake -P cmake_install.cmake |
192 | -.PHONY : install |
193 | - |
194 | -# Special rule for the target install |
195 | -install/fast: preinstall/fast |
196 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." |
197 | - /usr/bin/cmake -P cmake_install.cmake |
198 | -.PHONY : install/fast |
199 | - |
200 | -# Special rule for the target install/local |
201 | -install/local: preinstall |
202 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." |
203 | - /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake |
204 | -.PHONY : install/local |
205 | - |
206 | -# Special rule for the target install/local |
207 | -install/local/fast: install/local |
208 | -.PHONY : install/local/fast |
209 | - |
210 | -# Special rule for the target install/strip |
211 | -install/strip: preinstall |
212 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." |
213 | - /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake |
214 | -.PHONY : install/strip |
215 | - |
216 | -# Special rule for the target install/strip |
217 | -install/strip/fast: install/strip |
218 | -.PHONY : install/strip/fast |
219 | - |
220 | -# Special rule for the target list_install_components |
221 | -list_install_components: |
222 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" |
223 | -.PHONY : list_install_components |
224 | - |
225 | -# Special rule for the target list_install_components |
226 | -list_install_components/fast: list_install_components |
227 | -.PHONY : list_install_components/fast |
228 | - |
229 | -# Special rule for the target rebuild_cache |
230 | -rebuild_cache: |
231 | - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." |
232 | - /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) |
233 | -.PHONY : rebuild_cache |
234 | - |
235 | -# Special rule for the target rebuild_cache |
236 | -rebuild_cache/fast: rebuild_cache |
237 | -.PHONY : rebuild_cache/fast |
238 | - |
239 | -# The main all target |
240 | -all: cmake_check_build_system |
241 | - $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles /home/mefrio/Scrivania/cmake/cmake/CMakeFiles/progress.marks |
242 | - $(MAKE) -f CMakeFiles/Makefile2 all |
243 | - $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles 0 |
244 | -.PHONY : all |
245 | - |
246 | -# The main clean target |
247 | -clean: |
248 | - $(MAKE) -f CMakeFiles/Makefile2 clean |
249 | -.PHONY : clean |
250 | - |
251 | -# The main clean target |
252 | -clean/fast: clean |
253 | -.PHONY : clean/fast |
254 | - |
255 | -# Prepare targets for installation. |
256 | -preinstall: all |
257 | - $(MAKE) -f CMakeFiles/Makefile2 preinstall |
258 | -.PHONY : preinstall |
259 | - |
260 | -# Prepare targets for installation. |
261 | -preinstall/fast: |
262 | - $(MAKE) -f CMakeFiles/Makefile2 preinstall |
263 | -.PHONY : preinstall/fast |
264 | - |
265 | -# clear depends |
266 | -depend: |
267 | - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 |
268 | -.PHONY : depend |
269 | - |
270 | -#============================================================================= |
271 | -# Target rules for targets named scratch |
272 | - |
273 | -# Build rule for target. |
274 | -scratch: cmake_check_build_system |
275 | - $(MAKE) -f CMakeFiles/Makefile2 scratch |
276 | -.PHONY : scratch |
277 | - |
278 | -# fast build rule for target. |
279 | -scratch/fast: |
280 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/build |
281 | -.PHONY : scratch/fast |
282 | - |
283 | -src/entry.o: src/entry.c.o |
284 | -.PHONY : src/entry.o |
285 | - |
286 | -# target to build an object file |
287 | -src/entry.c.o: |
288 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.o |
289 | -.PHONY : src/entry.c.o |
290 | - |
291 | -src/entry.i: src/entry.c.i |
292 | -.PHONY : src/entry.i |
293 | - |
294 | -# target to preprocess a source file |
295 | -src/entry.c.i: |
296 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.i |
297 | -.PHONY : src/entry.c.i |
298 | - |
299 | -src/entry.s: src/entry.c.s |
300 | -.PHONY : src/entry.s |
301 | - |
302 | -# target to generate assembly for a file |
303 | -src/entry.c.s: |
304 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.s |
305 | -.PHONY : src/entry.c.s |
306 | - |
307 | -src/main_window.o: src/main_window.c.o |
308 | -.PHONY : src/main_window.o |
309 | - |
310 | -# target to build an object file |
311 | -src/main_window.c.o: |
312 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.o |
313 | -.PHONY : src/main_window.c.o |
314 | - |
315 | -src/main_window.i: src/main_window.c.i |
316 | -.PHONY : src/main_window.i |
317 | - |
318 | -# target to preprocess a source file |
319 | -src/main_window.c.i: |
320 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.i |
321 | -.PHONY : src/main_window.c.i |
322 | - |
323 | -src/main_window.s: src/main_window.c.s |
324 | -.PHONY : src/main_window.s |
325 | - |
326 | -# target to generate assembly for a file |
327 | -src/main_window.c.s: |
328 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.s |
329 | -.PHONY : src/main_window.c.s |
330 | - |
331 | -src/menu.o: src/menu.c.o |
332 | -.PHONY : src/menu.o |
333 | - |
334 | -# target to build an object file |
335 | -src/menu.c.o: |
336 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.o |
337 | -.PHONY : src/menu.c.o |
338 | - |
339 | -src/menu.i: src/menu.c.i |
340 | -.PHONY : src/menu.i |
341 | - |
342 | -# target to preprocess a source file |
343 | -src/menu.c.i: |
344 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.i |
345 | -.PHONY : src/menu.c.i |
346 | - |
347 | -src/menu.s: src/menu.c.s |
348 | -.PHONY : src/menu.s |
349 | - |
350 | -# target to generate assembly for a file |
351 | -src/menu.c.s: |
352 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.s |
353 | -.PHONY : src/menu.c.s |
354 | - |
355 | -src/notebook.o: src/notebook.c.o |
356 | -.PHONY : src/notebook.o |
357 | - |
358 | -# target to build an object file |
359 | -src/notebook.c.o: |
360 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.o |
361 | -.PHONY : src/notebook.c.o |
362 | - |
363 | -src/notebook.i: src/notebook.c.i |
364 | -.PHONY : src/notebook.i |
365 | - |
366 | -# target to preprocess a source file |
367 | -src/notebook.c.i: |
368 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.i |
369 | -.PHONY : src/notebook.c.i |
370 | - |
371 | -src/notebook.s: src/notebook.c.s |
372 | -.PHONY : src/notebook.s |
373 | - |
374 | -# target to generate assembly for a file |
375 | -src/notebook.c.s: |
376 | - $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.s |
377 | -.PHONY : src/notebook.c.s |
378 | - |
379 | -# Help Target |
380 | -help: |
381 | - @echo "The following are some of the valid targets for this Makefile:" |
382 | - @echo "... all (the default if no target is provided)" |
383 | - @echo "... clean" |
384 | - @echo "... depend" |
385 | - @echo "... edit_cache" |
386 | - @echo "... install" |
387 | - @echo "... install/local" |
388 | - @echo "... install/strip" |
389 | - @echo "... list_install_components" |
390 | - @echo "... rebuild_cache" |
391 | - @echo "... scratch" |
392 | - @echo "... src/entry.o" |
393 | - @echo "... src/entry.i" |
394 | - @echo "... src/entry.s" |
395 | - @echo "... src/main_window.o" |
396 | - @echo "... src/main_window.i" |
397 | - @echo "... src/main_window.s" |
398 | - @echo "... src/menu.o" |
399 | - @echo "... src/menu.i" |
400 | - @echo "... src/menu.s" |
401 | - @echo "... src/notebook.o" |
402 | - @echo "... src/notebook.i" |
403 | - @echo "... src/notebook.s" |
404 | -.PHONY : help |
405 | - |
406 | - |
407 | - |
408 | -#============================================================================= |
409 | -# Special targets to cleanup operation of make. |
410 | - |
411 | -# Special rule to run CMake to check the build system integrity. |
412 | -# No rule that depends on this can have commands that come from listfiles |
413 | -# because they might be regenerated. |
414 | -cmake_check_build_system: |
415 | - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 |
416 | -.PHONY : cmake_check_build_system |
417 | - |
418 | |
419 | === added file 'cmake/Tests.cmake' |
420 | --- cmake/Tests.cmake 1970-01-01 00:00:00 +0000 |
421 | +++ cmake/Tests.cmake 2013-12-26 00:13:32 +0000 |
422 | @@ -0,0 +1,5 @@ |
423 | +# Test macros for Marlin, feel free to re-use them. |
424 | + |
425 | +macro(add_test_executable EXE_NAME) |
426 | + add_test(${EXE_NAME} gtester ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}) |
427 | +endmacro() |
428 | |
429 | === modified file 'cmake/Translations.cmake' (properties changed: -x to +x) |
430 | --- cmake/Translations.cmake 2012-06-06 07:24:11 +0000 |
431 | +++ cmake/Translations.cmake 2013-12-26 00:13:32 +0000 |
432 | @@ -36,6 +36,7 @@ |
433 | |
434 | add_custom_command (TARGET pot COMMAND |
435 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot |
436 | - ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8 |
437 | + ${VALA_SOURCE} ${C_SOURCE} --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2" |
438 | + --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="N_" --keyword="Q_:1g" --from-code=UTF-8 |
439 | ) |
440 | endmacro() |
441 | |
442 | === modified file 'cmake/ValaPrecompile.cmake' |
443 | --- cmake/ValaPrecompile.cmake 2011-09-07 10:52:19 +0000 |
444 | +++ cmake/ValaPrecompile.cmake 2013-12-26 00:13:32 +0000 |
445 | @@ -1,5 +1,6 @@ |
446 | ## |
447 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
448 | +# Copyright 2012 elementary. |
449 | # |
450 | # Redistribution and use in source and binary forms, with or without |
451 | # modification, are permitted provided that the following conditions are met: |
452 | @@ -74,10 +75,18 @@ |
453 | # be a header file as well as an internal header file being generated called |
454 | # <provided_name>.h and <provided_name>_internal.h |
455 | # |
456 | +# GENERATE_GIR |
457 | +# Have the compiler generate a GObject-Introspection repository file with |
458 | +# name: <provided_name>.gir. This can be later used to create a binary typelib |
459 | +# using the GI compiler. |
460 | +# |
461 | +# GENERATE_SYMBOLS |
462 | +# Output a <provided_name>.symbols file containing all the exported symbols. |
463 | +# |
464 | # The following call is a simple example to the vala_precompile macro showing |
465 | # an example to every of the optional sections: |
466 | # |
467 | -# vala_precompile(VALA_C |
468 | +# vala_precompile(VALA_C mytargetname |
469 | # source1.vala |
470 | # source2.vala |
471 | # source3.vala |
472 | @@ -95,14 +104,19 @@ |
473 | # myvapi |
474 | # GENERATE_HEADER |
475 | # myheader |
476 | +# GENERATE_GIR |
477 | +# mygir |
478 | +# GENERATE_SYMBOLS |
479 | +# mysymbols |
480 | # ) |
481 | # |
482 | # Most important is the variable VALA_C which will contain all the generated c |
483 | # file names after the call. |
484 | ## |
485 | |
486 | -macro(vala_precompile output) |
487 | - parse_arguments(ARGS "PACKAGES;OPTIONS;DIRECTORY;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) |
488 | +macro(vala_precompile output target_name) |
489 | + parse_arguments(ARGS "TARGET;PACKAGES;OPTIONS;DIRECTORY;GENERATE_GIR;GENERATE_SYMBOLS;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) |
490 | + |
491 | if(ARGS_DIRECTORY) |
492 | set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) |
493 | else(ARGS_DIRECTORY) |
494 | @@ -115,14 +129,29 @@ |
495 | endforeach(pkg ${ARGS_PACKAGES}) |
496 | set(in_files "") |
497 | set(out_files "") |
498 | + set(out_files_display "") |
499 | set(${output} "") |
500 | + |
501 | foreach(src ${ARGS_DEFAULT_ARGS}) |
502 | - list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") |
503 | + string(REGEX MATCH "^/" IS_MATCHED ${src}) |
504 | + if(${IS_MATCHED} MATCHES "/") |
505 | + set(src_file_path ${src}) |
506 | + else() |
507 | + set(src_file_path ${CMAKE_CURRENT_SOURCE_DIR}/${src}) |
508 | + endif() |
509 | + list(APPEND in_files ${src_file_path}) |
510 | string(REPLACE ".vala" ".c" src ${src}) |
511 | string(REPLACE ".gs" ".c" src ${src}) |
512 | - set(out_file "${DIRECTORY}/${src}") |
513 | - list(APPEND out_files "${DIRECTORY}/${src}") |
514 | + if(${IS_MATCHED} MATCHES "/") |
515 | + get_filename_component(VALA_FILE_NAME ${src} NAME) |
516 | + set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") |
517 | + list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") |
518 | + else() |
519 | + set(out_file "${DIRECTORY}/${src}") |
520 | + list(APPEND out_files "${DIRECTORY}/${src}") |
521 | + endif() |
522 | list(APPEND ${output} ${out_file}) |
523 | + list(APPEND out_files_display "${src}") |
524 | endforeach(src ${ARGS_DEFAULT_ARGS}) |
525 | |
526 | set(custom_vapi_arguments "") |
527 | @@ -139,7 +168,8 @@ |
528 | set(vapi_arguments "") |
529 | if(ARGS_GENERATE_VAPI) |
530 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") |
531 | - set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi") |
532 | + list(APPEND out_files_display "${ARGS_GENERATE_VAPI}.vapi") |
533 | + set(vapi_arguments "--library=${ARGS_GENERATE_VAPI}" "--vapi=${ARGS_GENERATE_VAPI}.vapi") |
534 | |
535 | # Header and internal header is needed to generate internal vapi |
536 | if (NOT ARGS_GENERATE_HEADER) |
537 | @@ -150,26 +180,69 @@ |
538 | set(header_arguments "") |
539 | if(ARGS_GENERATE_HEADER) |
540 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
541 | - list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") |
542 | - list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
543 | - list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") |
544 | + list(APPEND out_files_display "${ARGS_GENERATE_HEADER}.h") |
545 | + list(APPEND header_arguments "--header=${ARGS_GENERATE_HEADER}.h") |
546 | endif(ARGS_GENERATE_HEADER) |
547 | |
548 | - add_custom_command(OUTPUT ${out_files} |
549 | + set(gir_arguments "") |
550 | + set(gircomp_command "") |
551 | + if(ARGS_GENERATE_GIR) |
552 | + list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir") |
553 | + list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir") |
554 | + set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir") |
555 | + |
556 | + include (FindGirCompiler) |
557 | + find_package(GirCompiler REQUIRED) |
558 | + |
559 | + set(gircomp_command |
560 | + COMMAND |
561 | + ${G_IR_COMPILER_EXECUTABLE} |
562 | + ARGS |
563 | + "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir" |
564 | + -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib") |
565 | + endif(ARGS_GENERATE_GIR) |
566 | + |
567 | + set(symbols_arguments "") |
568 | + if(ARGS_GENERATE_SYMBOLS) |
569 | + list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_SYMBOLS}.symbols") |
570 | + list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols") |
571 | + set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols") |
572 | + endif(ARGS_GENERATE_SYMBOLS) |
573 | + |
574 | + # Workaround for a bug that would make valac run twice. This file is written |
575 | + # after the vala compiler generates C source code. |
576 | + set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp) |
577 | + |
578 | + add_custom_command( |
579 | + OUTPUT |
580 | + ${OUTPUT_STAMP} |
581 | COMMAND |
582 | ${VALA_EXECUTABLE} |
583 | ARGS |
584 | "-C" |
585 | ${header_arguments} |
586 | - ${vapi_arguments} |
587 | + ${vapi_arguments} |
588 | + ${gir_arguments} |
589 | + ${symbols_arguments} |
590 | "-b" ${CMAKE_CURRENT_SOURCE_DIR} |
591 | "-d" ${DIRECTORY} |
592 | ${vala_pkg_opts} |
593 | ${ARGS_OPTIONS} |
594 | ${in_files} |
595 | ${custom_vapi_arguments} |
596 | + COMMAND |
597 | + touch |
598 | + ARGS |
599 | + ${OUTPUT_STAMP} |
600 | DEPENDS |
601 | ${in_files} |
602 | ${ARGS_CUSTOM_VAPIS} |
603 | + COMMENT |
604 | + "Generating ${out_files_display}" |
605 | + ${gircomp_command} |
606 | ) |
607 | + |
608 | + # This command will be run twice for some reason (pass a non-empty string to COMMENT |
609 | + # in order to see it). Since valac is not executed from here, this won't be a problem. |
610 | + add_custom_command(OUTPUT ${out_files} DEPENDS ${OUTPUT_STAMP} COMMENT "") |
611 | endmacro(vala_precompile) |
612 | |
613 | === modified file 'po/CMakeLists.txt' |
614 | --- po/CMakeLists.txt 2011-09-12 14:23:59 +0000 |
615 | +++ po/CMakeLists.txt 2013-12-26 00:13:32 +0000 |
616 | @@ -1,8 +1,6 @@ |
617 | # Translations |
618 | include (Translations) |
619 | -add_translations_directory ("slingshot") |
620 | -add_translations_catalog ("slingshot" |
621 | - ../src/Widgets |
622 | - ../src/Backend |
623 | +add_translations_directory (${GETTEXT_PACKAGE}) |
624 | +add_translations_catalog (${GETTEXT_PACKAGE} |
625 | ../src |
626 | -) |
627 | +) |
628 | \ No newline at end of file |
629 | |
630 | === modified file 'src/Backend/App.vala' |
631 | --- src/Backend/App.vala 2013-08-26 17:11:46 +0000 |
632 | +++ src/Backend/App.vala 2013-12-26 00:13:32 +0000 |
633 | @@ -16,143 +16,139 @@ |
634 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
635 | // |
636 | |
637 | -namespace Slingshot.Backend { |
638 | - |
639 | - public class App : Object { |
640 | - |
641 | - public string name { get; construct set; } |
642 | - public string description { get; private set; default = ""; } |
643 | - public string desktop_id { get; construct set; } |
644 | - public string exec { get; private set; } |
645 | - public string icon_name { get; private set; default = ""; } |
646 | - public string[] keywords { get; private set;} |
647 | - public Gdk.Pixbuf icon { get; private set; } |
648 | - public double popularity { get; set; } |
649 | - public double relevancy { get; set; } |
650 | - public string desktop_path { get; private set; } |
651 | - public string generic_name { get; private set; default = ""; } |
652 | - |
653 | - private bool is_command = false; |
654 | - |
655 | - public signal void icon_changed (); |
656 | - public signal void launched (App app); |
657 | - |
658 | - public App (GMenu.TreeEntry entry) { |
659 | - name = entry.get_display_name (); |
660 | - description = entry.get_comment () ?? name; |
661 | - exec = entry.get_exec (); |
662 | - desktop_id = entry.get_desktop_file_id (); |
663 | - icon_name = entry.get_icon () ?? "application-default-icon"; |
664 | - desktop_path = entry.get_desktop_file_path (); |
665 | - keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id); |
666 | - generic_name = entry.get_generic_name (); |
667 | - |
668 | - update_icon (); |
669 | - Slingshot.icon_theme.changed.connect (update_icon); |
670 | - } |
671 | - |
672 | - public App.from_command (string command) { |
673 | - |
674 | - name = command; |
675 | - description = _("Run this command..."); |
676 | - exec = command; |
677 | - desktop_id = command; |
678 | - icon_name = "system-run"; |
679 | - |
680 | - is_command = true; |
681 | - |
682 | - update_icon (); |
683 | - |
684 | - } |
685 | - |
686 | - public void update_icon () { |
687 | - icon = load_icon (Slingshot.settings.icon_size); |
688 | - icon_changed (); |
689 | - } |
690 | - |
691 | - private delegate void IconLoadFallback (); |
692 | - |
693 | - private class IconLoadFallbackMethod { |
694 | - public unowned IconLoadFallback load_icon; |
695 | - |
696 | - public IconLoadFallbackMethod (IconLoadFallback fallback) { |
697 | - load_icon = fallback; |
698 | - } |
699 | - } |
700 | - |
701 | - public Gdk.Pixbuf load_icon (int size) { |
702 | - Gdk.Pixbuf icon = null; |
703 | - var flags = Gtk.IconLookupFlags.FORCE_SIZE; |
704 | - |
705 | - IconLoadFallbackMethod[] fallbacks = { |
706 | - new IconLoadFallbackMethod (() => { |
707 | - try { |
708 | - icon = Slingshot.icon_theme.load_icon (icon_name, size, flags); |
709 | - } catch (Error e) { |
710 | - warning ("Could not load icon. Falling back to method 2"); |
711 | - } |
712 | - }), |
713 | - |
714 | - new IconLoadFallbackMethod (() => { |
715 | - try { |
716 | - if (icon_name.last_index_of (".") > 0) { |
717 | - var name = icon_name[0:icon_name.last_index_of (".")]; |
718 | - icon = Slingshot.icon_theme.load_icon (name, size, flags); |
719 | - } |
720 | - } catch (Error e) { |
721 | - warning ("Could not load icon. Falling back to method 3"); |
722 | - } |
723 | - }), |
724 | - |
725 | - new IconLoadFallbackMethod (() => { |
726 | - try { |
727 | - icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false); |
728 | - } catch (Error e) { |
729 | - warning ("Could not load icon. Falling back to method 4"); |
730 | - } |
731 | - }), |
732 | - |
733 | - new IconLoadFallbackMethod (() => { |
734 | - try { |
735 | - icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags); |
736 | - } catch (Error e) { |
737 | - warning ("Could not load icon. Falling back to method 5"); |
738 | - } |
739 | - }), |
740 | - |
741 | - new IconLoadFallbackMethod (() => { |
742 | - try { |
743 | - icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags); |
744 | - } catch (Error e) { |
745 | - error ("Could not find a fallback icon to load"); |
746 | - } |
747 | - }) |
748 | - }; |
749 | - |
750 | - foreach (IconLoadFallbackMethod fallback in fallbacks) { |
751 | - fallback.load_icon (); |
752 | - if (icon != null) |
753 | - break; |
754 | - } |
755 | - |
756 | - return icon; |
757 | - } |
758 | - |
759 | - public void launch () { |
760 | - try { |
761 | - if (is_command) { |
762 | - debug (@"Launching command: $name"); |
763 | - Process.spawn_command_line_async (exec); |
764 | - } else { |
765 | - launched (this); // Emit launched signal |
766 | - new DesktopAppInfo (desktop_id).launch (null, null); |
767 | - debug (@"Launching application: $name"); |
768 | - } |
769 | - } catch (Error e) { |
770 | - warning ("Failed to launch %s: %s", name, exec); |
771 | - } |
772 | - } |
773 | - |
774 | +public class Slingshot.Backend.App : Object { |
775 | + |
776 | + public string name { get; construct set; } |
777 | + public string description { get; private set; default = ""; } |
778 | + public string desktop_id { get; construct set; } |
779 | + public string exec { get; private set; } |
780 | + public string icon_name { get; private set; default = ""; } |
781 | + public string[] keywords { get; private set;} |
782 | + public Gdk.Pixbuf icon { get; private set; } |
783 | + public double popularity { get; set; } |
784 | + public double relevancy { get; set; } |
785 | + public string desktop_path { get; private set; } |
786 | + public string generic_name { get; private set; default = ""; } |
787 | + |
788 | + private bool is_command = false; |
789 | + |
790 | + public signal void icon_changed (); |
791 | + public signal void launched (App app); |
792 | + |
793 | + public App (GMenu.TreeEntry entry) { |
794 | + name = entry.get_display_name (); |
795 | + description = entry.get_comment () ?? name; |
796 | + exec = entry.get_exec (); |
797 | + desktop_id = entry.get_desktop_file_id (); |
798 | + icon_name = entry.get_icon () ?? "application-default-icon"; |
799 | + desktop_path = entry.get_desktop_file_path (); |
800 | + keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id); |
801 | + generic_name = entry.get_generic_name (); |
802 | + |
803 | + update_icon (); |
804 | + Slingshot.icon_theme.changed.connect (update_icon); |
805 | + } |
806 | + |
807 | + public App.from_command (string command) { |
808 | + |
809 | + name = command; |
810 | + description = _("Run this command..."); |
811 | + exec = command; |
812 | + desktop_id = command; |
813 | + icon_name = "system-run"; |
814 | + |
815 | + is_command = true; |
816 | + |
817 | + update_icon (); |
818 | + |
819 | + } |
820 | + |
821 | + public void update_icon () { |
822 | + icon = load_icon (Slingshot.settings.icon_size); |
823 | + icon_changed (); |
824 | + } |
825 | + |
826 | + private delegate void IconLoadFallback (); |
827 | + |
828 | + private class IconLoadFallbackMethod { |
829 | + public unowned IconLoadFallback load_icon; |
830 | + |
831 | + public IconLoadFallbackMethod (IconLoadFallback fallback) { |
832 | + load_icon = fallback; |
833 | + } |
834 | + } |
835 | + |
836 | + public Gdk.Pixbuf load_icon (int size) { |
837 | + Gdk.Pixbuf icon = null; |
838 | + var flags = Gtk.IconLookupFlags.FORCE_SIZE; |
839 | + |
840 | + IconLoadFallbackMethod[] fallbacks = { |
841 | + new IconLoadFallbackMethod (() => { |
842 | + try { |
843 | + icon = Slingshot.icon_theme.load_icon (icon_name, size, flags); |
844 | + } catch (Error e) { |
845 | + warning ("Could not load icon. Falling back to method 2"); |
846 | + } |
847 | + }), |
848 | + |
849 | + new IconLoadFallbackMethod (() => { |
850 | + try { |
851 | + if (icon_name.last_index_of (".") > 0) { |
852 | + var name = icon_name[0:icon_name.last_index_of (".")]; |
853 | + icon = Slingshot.icon_theme.load_icon (name, size, flags); |
854 | + } |
855 | + } catch (Error e) { |
856 | + warning ("Could not load icon. Falling back to method 3"); |
857 | + } |
858 | + }), |
859 | + |
860 | + new IconLoadFallbackMethod (() => { |
861 | + try { |
862 | + icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false); |
863 | + } catch (Error e) { |
864 | + warning ("Could not load icon. Falling back to method 4"); |
865 | + } |
866 | + }), |
867 | + |
868 | + new IconLoadFallbackMethod (() => { |
869 | + try { |
870 | + icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags); |
871 | + } catch (Error e) { |
872 | + warning ("Could not load icon. Falling back to method 5"); |
873 | + } |
874 | + }), |
875 | + |
876 | + new IconLoadFallbackMethod (() => { |
877 | + try { |
878 | + icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags); |
879 | + } catch (Error e) { |
880 | + error ("Could not find a fallback icon to load"); |
881 | + } |
882 | + }) |
883 | + }; |
884 | + |
885 | + foreach (IconLoadFallbackMethod fallback in fallbacks) { |
886 | + fallback.load_icon (); |
887 | + if (icon != null) |
888 | + break; |
889 | + } |
890 | + |
891 | + return icon; |
892 | + } |
893 | + |
894 | + public void launch () { |
895 | + try { |
896 | + if (is_command) { |
897 | + debug (@"Launching command: $name"); |
898 | + Process.spawn_command_line_async (exec); |
899 | + } else { |
900 | + launched (this); // Emit launched signal |
901 | + new DesktopAppInfo (desktop_id).launch (null, null); |
902 | + debug (@"Launching application: $name"); |
903 | + } |
904 | + } catch (Error e) { |
905 | + warning ("Failed to launch %s: %s", name, exec); |
906 | + } |
907 | } |
908 | |
909 | } |
910 | |
911 | === modified file 'src/Backend/AppSystem.vala' |
912 | --- src/Backend/AppSystem.vala 2013-08-26 08:45:09 +0000 |
913 | +++ src/Backend/AppSystem.vala 2013-12-26 00:13:32 +0000 |
914 | @@ -16,232 +16,224 @@ |
915 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
916 | // |
917 | |
918 | -using GLib; |
919 | -using GMenu; |
920 | -using Gee; |
921 | - |
922 | -namespace Slingshot.Backend { |
923 | - |
924 | - public class AppSystem : Object { |
925 | - |
926 | - private ArrayList<TreeDirectory> categories = null; |
927 | - private HashMap<string, ArrayList<App>> apps = null; |
928 | - private GMenu.Tree apps_menu = null; |
929 | - |
930 | - private RelevancyService rl_service; |
931 | - |
932 | - public signal void changed (); |
933 | - private bool index_changed = false; |
934 | - |
935 | - construct { |
936 | - |
937 | - rl_service = new RelevancyService (); |
938 | - rl_service.update_complete.connect (update_popularity); |
939 | - |
940 | - apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", TreeFlags.INCLUDE_EXCLUDED); |
941 | - apps_menu.add_monitor ((menu) => { |
942 | - |
943 | - debug ("Apps menu tree changed. Updating…"); |
944 | - index_changed = true; |
945 | - update_app_system (); |
946 | - changed (); |
947 | - |
948 | - }); |
949 | - |
950 | - apps_menu.set_sort_key (TreeSortKey.DISPLAY_NAME); |
951 | +public class Slingshot.Backend.AppSystem : Object { |
952 | + |
953 | + private Gee.ArrayList<GMenu.TreeDirectory> categories = null; |
954 | + private Gee.HashMap<string, Gee.ArrayList<App>> apps = null; |
955 | + private GMenu.Tree apps_menu = null; |
956 | + |
957 | + private RelevancyService rl_service; |
958 | + |
959 | + public signal void changed (); |
960 | + private bool index_changed = false; |
961 | + |
962 | + construct { |
963 | + |
964 | + rl_service = new RelevancyService (); |
965 | + rl_service.update_complete.connect (update_popularity); |
966 | + |
967 | + apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED); |
968 | + apps_menu.add_monitor ((menu) => { |
969 | + |
970 | + debug ("Apps menu tree changed. Updating…"); |
971 | + index_changed = true; |
972 | update_app_system (); |
973 | - |
974 | - } |
975 | - |
976 | - private void update_app_system () { |
977 | - |
978 | - rl_service.refresh_popularity (); |
979 | - |
980 | - update_categories_index (); |
981 | - update_apps (); |
982 | - |
983 | - } |
984 | - |
985 | - private void update_categories_index () { |
986 | - |
987 | - var root_tree = apps_menu.get_root_directory (); |
988 | - |
989 | - if (categories == null || index_changed) { |
990 | - categories = new ArrayList<TreeDirectory> (); |
991 | - |
992 | - foreach (TreeItem item in root_tree.get_contents ()) { |
993 | - if (item.get_type () == TreeItemType.DIRECTORY) |
994 | - if (((TreeDirectory) item).get_is_nodisplay () == false) |
995 | - categories.add ((TreeDirectory) item); |
996 | - } |
997 | - } |
998 | - |
999 | - } |
1000 | - |
1001 | - private void update_popularity () { |
1002 | - |
1003 | - foreach (ArrayList<App> category in apps.values) |
1004 | - foreach (App app in category) |
1005 | - app.popularity = rl_service.get_app_popularity (app.desktop_id); |
1006 | - } |
1007 | - |
1008 | - private void update_apps () { |
1009 | - |
1010 | - if (index_changed) { |
1011 | - apps.clear (); |
1012 | - apps = null; |
1013 | - index_changed = false; |
1014 | - } |
1015 | - |
1016 | - if (apps == null) { |
1017 | - |
1018 | - apps = new HashMap<string, ArrayList<App>> (); |
1019 | - |
1020 | - foreach (TreeDirectory cat in categories) { |
1021 | - apps.set (cat.get_name (), get_apps_by_category (cat)); |
1022 | - } |
1023 | - |
1024 | - } |
1025 | - |
1026 | - } |
1027 | - |
1028 | - public ArrayList<TreeDirectory> get_categories () { |
1029 | - |
1030 | - return categories; |
1031 | - |
1032 | - } |
1033 | - |
1034 | - public ArrayList<App> get_apps_by_category (TreeDirectory category) { |
1035 | - |
1036 | - var app_list = new ArrayList<App> (); |
1037 | - |
1038 | - foreach (TreeItem item in category.get_contents ()) { |
1039 | - App app; |
1040 | - switch (item.get_type ()) { |
1041 | - case TreeItemType.DIRECTORY: |
1042 | - app_list.add_all (get_apps_by_category ((TreeDirectory) item)); |
1043 | - break; |
1044 | - case TreeItemType.ENTRY: |
1045 | - if (is_entry ((TreeEntry) item)) { |
1046 | - app = new App ((TreeEntry) item); |
1047 | - app.launched.connect (rl_service.app_launched); |
1048 | - app_list.add (app); |
1049 | - } |
1050 | - break; |
1051 | - } |
1052 | - } |
1053 | - return app_list; |
1054 | - |
1055 | - } |
1056 | - |
1057 | - private bool is_entry (TreeEntry entry) { |
1058 | - |
1059 | - if (entry.get_launch_in_terminal () == false |
1060 | - && entry.get_is_excluded () == false |
1061 | - && entry.get_is_nodisplay () == false) { |
1062 | - return true; |
1063 | - } else { |
1064 | - return false; |
1065 | - } |
1066 | - |
1067 | - } |
1068 | - |
1069 | - public HashMap<string, ArrayList<App>> get_apps () { |
1070 | - |
1071 | - return apps; |
1072 | - |
1073 | - } |
1074 | - |
1075 | - public SList<App> get_apps_by_popularity () { |
1076 | - |
1077 | - var sorted_apps = new SList<App> (); |
1078 | - |
1079 | - foreach (ArrayList<App> category in apps.values) { |
1080 | - foreach (App app in category) { |
1081 | - sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity); |
1082 | - } |
1083 | - } |
1084 | - |
1085 | - return sorted_apps; |
1086 | - |
1087 | - } |
1088 | - |
1089 | - public SList<App> get_apps_by_name () { |
1090 | - |
1091 | - var sorted_apps = new SList<App> (); |
1092 | - string[] sorted_apps_execs = {}; |
1093 | - |
1094 | - foreach (ArrayList<App> category in apps.values) { |
1095 | - foreach (App app in category) { |
1096 | - if (!(app.exec in sorted_apps_execs)) { |
1097 | - sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name); |
1098 | - sorted_apps_execs += app.exec; |
1099 | + changed (); |
1100 | + |
1101 | + }); |
1102 | + |
1103 | + apps_menu.set_sort_key (GMenu.TreeSortKey.DISPLAY_NAME); |
1104 | + update_app_system (); |
1105 | + |
1106 | + } |
1107 | + |
1108 | + private void update_app_system () { |
1109 | + |
1110 | + rl_service.refresh_popularity (); |
1111 | + |
1112 | + update_categories_index (); |
1113 | + update_apps (); |
1114 | + |
1115 | + } |
1116 | + |
1117 | + private void update_categories_index () { |
1118 | + |
1119 | + var root_tree = apps_menu.get_root_directory (); |
1120 | + |
1121 | + if (categories == null || index_changed) { |
1122 | + categories = new Gee.ArrayList<GMenu.TreeDirectory> (); |
1123 | + |
1124 | + foreach (GMenu.TreeItem item in root_tree.get_contents ()) { |
1125 | + if (item.get_type () == GMenu.TreeItemType.DIRECTORY) |
1126 | + if (((GMenu.TreeDirectory) item).get_is_nodisplay () == false) |
1127 | + categories.add ((GMenu.TreeDirectory) item); |
1128 | + } |
1129 | + } |
1130 | + |
1131 | + } |
1132 | + |
1133 | + private void update_popularity () { |
1134 | + |
1135 | + foreach (Gee.ArrayList<App> category in apps.values) |
1136 | + foreach (App app in category) |
1137 | + app.popularity = rl_service.get_app_popularity (app.desktop_id); |
1138 | + } |
1139 | + |
1140 | + private void update_apps () { |
1141 | + |
1142 | + if (index_changed) { |
1143 | + apps.clear (); |
1144 | + apps = null; |
1145 | + index_changed = false; |
1146 | + } |
1147 | + |
1148 | + if (apps == null) { |
1149 | + |
1150 | + apps = new Gee.HashMap<string, Gee.ArrayList<App>> (); |
1151 | + |
1152 | + foreach (GMenu.TreeDirectory cat in categories) { |
1153 | + apps.set (cat.get_name (), get_apps_by_category (cat)); |
1154 | + } |
1155 | + |
1156 | + } |
1157 | + |
1158 | + } |
1159 | + |
1160 | + public Gee.ArrayList<GMenu.TreeDirectory> get_categories () { |
1161 | + |
1162 | + return categories; |
1163 | + |
1164 | + } |
1165 | + |
1166 | + public Gee.ArrayList<App> get_apps_by_category (GMenu.TreeDirectory category) { |
1167 | + |
1168 | + var app_list = new Gee.ArrayList<App> (); |
1169 | + |
1170 | + foreach (GMenu.TreeItem item in category.get_contents ()) { |
1171 | + App app; |
1172 | + switch (item.get_type ()) { |
1173 | + case GMenu.TreeItemType.DIRECTORY: |
1174 | + app_list.add_all (get_apps_by_category ((GMenu.TreeDirectory) item)); |
1175 | + break; |
1176 | + case GMenu.TreeItemType.ENTRY: |
1177 | + if (is_entry ((GMenu.TreeEntry) item)) { |
1178 | + app = new App ((GMenu.TreeEntry) item); |
1179 | + app.launched.connect (rl_service.app_launched); |
1180 | + app_list.add (app); |
1181 | } |
1182 | + break; |
1183 | + } |
1184 | + } |
1185 | + return app_list; |
1186 | + |
1187 | + } |
1188 | + |
1189 | + private bool is_entry (GMenu.TreeEntry entry) { |
1190 | + |
1191 | + if (entry.get_launch_in_terminal () == false |
1192 | + && entry.get_is_excluded () == false |
1193 | + && entry.get_is_nodisplay () == false) { |
1194 | + return true; |
1195 | + } else { |
1196 | + return false; |
1197 | + } |
1198 | + |
1199 | + } |
1200 | + |
1201 | + public Gee.HashMap<string, Gee.ArrayList<App>> get_apps () { |
1202 | + |
1203 | + return apps; |
1204 | + |
1205 | + } |
1206 | + |
1207 | + public SList<App> get_apps_by_popularity () { |
1208 | + |
1209 | + var sorted_apps = new SList<App> (); |
1210 | + |
1211 | + foreach (Gee.ArrayList<App> category in apps.values) { |
1212 | + foreach (App app in category) { |
1213 | + sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity); |
1214 | + } |
1215 | + } |
1216 | + |
1217 | + return sorted_apps; |
1218 | + |
1219 | + } |
1220 | + |
1221 | + public SList<App> get_apps_by_name () { |
1222 | + |
1223 | + var sorted_apps = new SList<App> (); |
1224 | + string[] sorted_apps_execs = {}; |
1225 | + |
1226 | + foreach (Gee.ArrayList<App> category in apps.values) { |
1227 | + foreach (App app in category) { |
1228 | + if (!(app.exec in sorted_apps_execs)) { |
1229 | + sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name); |
1230 | + sorted_apps_execs += app.exec; |
1231 | } |
1232 | } |
1233 | - |
1234 | - return sorted_apps; |
1235 | - |
1236 | } |
1237 | |
1238 | - public async ArrayList<App> search_results (string search) { |
1239 | - |
1240 | - Idle.add (search_results.callback, Priority.HIGH); |
1241 | - yield; |
1242 | - |
1243 | - var filtered = new ArrayList<App> (); |
1244 | - |
1245 | - /** It's a bit stupid algorithm, simply check if the char is present |
1246 | - * some of the App values, then assign it a double. This is very simple: |
1247 | - * if an App name coincide with the search string they have obvious the |
1248 | - * same length, then the fraction will be 1.0. |
1249 | - * I've added a small multiplier when matching to a exec name, to give |
1250 | - * more priority to app.name |
1251 | - **/ |
1252 | - string[] sorted_apps_execs = {}; |
1253 | - |
1254 | - foreach (ArrayList<App> category in apps.values) { |
1255 | - foreach (App app in category) { |
1256 | - if (!(app.exec in sorted_apps_execs)) { |
1257 | - sorted_apps_execs += app.exec; |
1258 | - if (search in app.name.down ()) { |
1259 | - if (search == app.name.down ()[0:search.length]) |
1260 | - app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0 |
1261 | - else |
1262 | - app.relevancy = app.name.length / search.length - app.popularity; |
1263 | - filtered.add (app); |
1264 | - } else if (search in app.exec.down ()) { |
1265 | - app.relevancy = app.exec.length / search.length * 10.0 - app.popularity; |
1266 | - filtered.add (app); |
1267 | - } else if (search in app.description.down ()) { |
1268 | - app.relevancy = app.description.length / search.length - app.popularity; |
1269 | - filtered.add (app); |
1270 | - } else if (search in app.generic_name.down ()) { |
1271 | - app.relevancy = app.generic_name.length / search.length - app.popularity; |
1272 | - filtered.add (app); |
1273 | - } else if (app.keywords != null) { |
1274 | - app.relevancy = 0; |
1275 | - foreach (string keyword in app.keywords) { |
1276 | - foreach (string search_word in search.split (" ")) { |
1277 | - if (search_word in keyword.down ()) { |
1278 | - app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity; |
1279 | - filtered.add (app); |
1280 | - } |
1281 | + return sorted_apps; |
1282 | + |
1283 | + } |
1284 | + |
1285 | + public async Gee.ArrayList<App> search_results (string search) { |
1286 | + |
1287 | + Idle.add (search_results.callback, Priority.HIGH); |
1288 | + yield; |
1289 | + |
1290 | + var filtered = new Gee.ArrayList<App> (); |
1291 | + |
1292 | + /** It's a bit stupid algorithm, simply check if the char is present |
1293 | + * some of the App values, then assign it a double. This is very simple: |
1294 | + * if an App name coincide with the search string they have obvious the |
1295 | + * same length, then the fraction will be 1.0. |
1296 | + * I've added a small multiplier when matching to a exec name, to give |
1297 | + * more priority to app.name |
1298 | + **/ |
1299 | + string[] sorted_apps_execs = {}; |
1300 | + |
1301 | + foreach (Gee.ArrayList<App> category in apps.values) { |
1302 | + foreach (App app in category) { |
1303 | + if (!(app.exec in sorted_apps_execs)) { |
1304 | + sorted_apps_execs += app.exec; |
1305 | + if (search in app.name.down ()) { |
1306 | + if (search == app.name.down ()[0:search.length]) |
1307 | + app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0 |
1308 | + else |
1309 | + app.relevancy = app.name.length / search.length - app.popularity; |
1310 | + filtered.add (app); |
1311 | + } else if (search in app.exec.down ()) { |
1312 | + app.relevancy = app.exec.length / search.length * 10.0 - app.popularity; |
1313 | + filtered.add (app); |
1314 | + } else if (search in app.description.down ()) { |
1315 | + app.relevancy = app.description.length / search.length - app.popularity; |
1316 | + filtered.add (app); |
1317 | + } else if (search in app.generic_name.down ()) { |
1318 | + app.relevancy = app.generic_name.length / search.length - app.popularity; |
1319 | + filtered.add (app); |
1320 | + } else if (app.keywords != null) { |
1321 | + app.relevancy = 0; |
1322 | + foreach (string keyword in app.keywords) { |
1323 | + foreach (string search_word in search.split (" ")) { |
1324 | + if (search_word in keyword.down ()) { |
1325 | + app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity; |
1326 | + filtered.add (app); |
1327 | } |
1328 | } |
1329 | } |
1330 | } |
1331 | } |
1332 | } |
1333 | - |
1334 | - filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b)); |
1335 | - |
1336 | - if (filtered.size > 20) { |
1337 | - return (ArrayList<App>) filtered[0:20]; |
1338 | - } else { |
1339 | - return filtered; |
1340 | - } |
1341 | - |
1342 | + } |
1343 | + |
1344 | + filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b)); |
1345 | + |
1346 | + if (filtered.size > 20) { |
1347 | + return (Gee.ArrayList<App>) filtered[0:20]; |
1348 | + } else { |
1349 | + return filtered; |
1350 | } |
1351 | |
1352 | } |
1353 | |
1354 | === modified file 'src/Backend/DBusService.vala' |
1355 | --- src/Backend/DBusService.vala 2013-02-11 22:48:50 +0000 |
1356 | +++ src/Backend/DBusService.vala 2013-12-26 00:13:32 +0000 |
1357 | @@ -16,57 +16,54 @@ |
1358 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1359 | |
1360 | |
1361 | -namespace Slingshot { |
1362 | - |
1363 | - public class DBusService : Object { |
1364 | - |
1365 | - [DBus (name = "org.pantheon.desktop.AppLauncherService")] |
1366 | - private class Service : Object { |
1367 | - public signal void visibility_changed (bool launcher_visible); |
1368 | - private Gtk.Widget? view = null; |
1369 | - |
1370 | - public Service (Gtk.Widget view) { |
1371 | - this.view = view; |
1372 | - view.show.connect (on_view_visibility_change); |
1373 | - view.hide.connect (on_view_visibility_change); |
1374 | - } |
1375 | - |
1376 | - internal void on_view_visibility_change () { |
1377 | - debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ()); |
1378 | - this.visibility_changed (view.visible); |
1379 | - } |
1380 | - } |
1381 | - |
1382 | - private Service? service = null; |
1383 | - |
1384 | - public DBusService (SlingshotView view) { |
1385 | - // Own bus name |
1386 | - // try to register service name in session bus |
1387 | - Bus.own_name (BusType.SESSION, |
1388 | - "org.pantheon.desktop.AppLauncherService", |
1389 | - BusNameOwnerFlags.NONE, |
1390 | - (conn) => { on_bus_aquired (conn, view); }, |
1391 | - name_acquired_handler, |
1392 | - () => { critical ("Could not aquire service name"); }); |
1393 | - |
1394 | - } |
1395 | - |
1396 | - private void on_bus_aquired (DBusConnection connection, SlingshotView view) { |
1397 | - try { |
1398 | - // start service and register it as dbus object |
1399 | - service = new Service (view); |
1400 | - connection.register_object ("/org/pantheon/desktop/AppLauncherService", service); |
1401 | - } catch (IOError e) { |
1402 | - critical ("Could not register service: %s", e.message); |
1403 | - return_if_reached (); |
1404 | - } |
1405 | - } |
1406 | - |
1407 | - private void name_acquired_handler (DBusConnection connection, string name) { |
1408 | - message ("Service registration suceeded"); |
1409 | - return_if_fail (service != null); |
1410 | - // Emit initial state |
1411 | - service.on_view_visibility_change (); |
1412 | - } |
1413 | - } |
1414 | -} |
1415 | +public class Slingshot.DBusService : Object { |
1416 | + |
1417 | + [DBus (name = "org.pantheon.desktop.AppLauncherService")] |
1418 | + private class Service : Object { |
1419 | + public signal void visibility_changed (bool launcher_visible); |
1420 | + private Gtk.Widget? view = null; |
1421 | + |
1422 | + public Service (Gtk.Widget view) { |
1423 | + this.view = view; |
1424 | + view.show.connect (on_view_visibility_change); |
1425 | + view.hide.connect (on_view_visibility_change); |
1426 | + } |
1427 | + |
1428 | + internal void on_view_visibility_change () { |
1429 | + debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ()); |
1430 | + this.visibility_changed (view.visible); |
1431 | + } |
1432 | + } |
1433 | + |
1434 | + private Service? service = null; |
1435 | + |
1436 | + public DBusService (SlingshotView view) { |
1437 | + // Own bus name |
1438 | + // try to register service name in session bus |
1439 | + Bus.own_name (BusType.SESSION, |
1440 | + "org.pantheon.desktop.AppLauncherService", |
1441 | + BusNameOwnerFlags.NONE, |
1442 | + (conn) => { on_bus_aquired (conn, view); }, |
1443 | + name_acquired_handler, |
1444 | + () => { critical ("Could not aquire service name"); }); |
1445 | + |
1446 | + } |
1447 | + |
1448 | + private void on_bus_aquired (DBusConnection connection, SlingshotView view) { |
1449 | + try { |
1450 | + // start service and register it as dbus object |
1451 | + service = new Service (view); |
1452 | + connection.register_object ("/org/pantheon/desktop/AppLauncherService", service); |
1453 | + } catch (IOError e) { |
1454 | + critical ("Could not register service: %s", e.message); |
1455 | + return_if_reached (); |
1456 | + } |
1457 | + } |
1458 | + |
1459 | + private void name_acquired_handler (DBusConnection connection, string name) { |
1460 | + message ("Service registration suceeded"); |
1461 | + return_if_fail (service != null); |
1462 | + // Emit initial state |
1463 | + service.on_view_visibility_change (); |
1464 | + } |
1465 | +} |
1466 | \ No newline at end of file |
1467 | |
1468 | === modified file 'src/Backend/RelevancyService.vala' |
1469 | --- src/Backend/RelevancyService.vala 2013-01-13 16:41:55 +0000 |
1470 | +++ src/Backend/RelevancyService.vala 2013-12-26 00:13:32 +0000 |
1471 | @@ -17,159 +17,164 @@ |
1472 | // |
1473 | // Thanks to Synapse Developers for this class |
1474 | |
1475 | -using Zeitgeist; |
1476 | - |
1477 | -namespace Slingshot.Backend { |
1478 | - |
1479 | - public class RelevancyService : Object { |
1480 | - |
1481 | - private Zeitgeist.Log zg_log; |
1482 | - private Zeitgeist.DataSourceRegistry zg_dsr; |
1483 | - private Gee.HashMap<string, int> app_popularity; |
1484 | - private bool has_datahub_gio_module = false; |
1485 | - |
1486 | - private const float MULTIPLIER = 65535.0f; |
1487 | - |
1488 | - public signal void update_complete (); |
1489 | - |
1490 | - public RelevancyService () { |
1491 | - |
1492 | - zg_log = new Zeitgeist.Log (); |
1493 | - app_popularity = new Gee.HashMap<string, int> (); |
1494 | - |
1495 | - refresh_popularity (); |
1496 | - check_data_sources.begin (); |
1497 | - |
1498 | - Timeout.add_seconds (60*30, refresh_popularity); |
1499 | - |
1500 | - } |
1501 | - |
1502 | - private async void check_data_sources () { |
1503 | - |
1504 | - zg_dsr = new Zeitgeist.DataSourceRegistry (); |
1505 | +public class Slingshot.Backend.RelevancyService : Object { |
1506 | + |
1507 | + private Zeitgeist.Log zg_log; |
1508 | + private Zeitgeist.DataSourceRegistry zg_dsr; |
1509 | + private Gee.HashMap<string, int> app_popularity; |
1510 | + private bool has_datahub_gio_module = false; |
1511 | + |
1512 | + private const float MULTIPLIER = 65535.0f; |
1513 | + |
1514 | + public signal void update_complete (); |
1515 | + |
1516 | + public RelevancyService () { |
1517 | + |
1518 | + zg_log = new Zeitgeist.Log (); |
1519 | + app_popularity = new Gee.HashMap<string, int> (); |
1520 | + |
1521 | + refresh_popularity (); |
1522 | + check_data_sources.begin (); |
1523 | + |
1524 | + Timeout.add_seconds (60*30, refresh_popularity); |
1525 | + |
1526 | + } |
1527 | + |
1528 | + private async void check_data_sources () { |
1529 | + |
1530 | + zg_dsr = new Zeitgeist.DataSourceRegistry (); |
1531 | + try { |
1532 | var ptr_arr = yield zg_dsr.get_data_sources (null); |
1533 | |
1534 | - for (uint i=0; i < ptr_arr.len; i++) { |
1535 | + for (uint i=0; i < ptr_arr.length; i++) { |
1536 | |
1537 | unowned Zeitgeist.DataSource ds; |
1538 | - ds = (Zeitgeist.DataSource) ptr_arr.index (i); |
1539 | - if (ds.get_unique_id () == "com.zeitgeist-project,datahub,gio-launch-listener" |
1540 | - && ds.is_enabled ()) { |
1541 | + ds = (Zeitgeist.DataSource) ptr_arr.get (i); |
1542 | + if (ds.unique_id == "com.zeitgeist-project,datahub,gio-launch-listener" |
1543 | + && ds.enabled == true) { |
1544 | |
1545 | has_datahub_gio_module = true; |
1546 | break; |
1547 | } |
1548 | } |
1549 | + } catch (Error e) { |
1550 | + critical (e.message); |
1551 | } |
1552 | - |
1553 | - public bool refresh_popularity () { |
1554 | - |
1555 | + } |
1556 | + |
1557 | + public bool refresh_popularity () { |
1558 | + |
1559 | + load_application_relevancies.begin (); |
1560 | + return true; |
1561 | + |
1562 | + } |
1563 | + private void reload_relevancies () { |
1564 | + |
1565 | + Idle.add_full (Priority.LOW, () => { |
1566 | load_application_relevancies.begin (); |
1567 | - return true; |
1568 | - |
1569 | - } |
1570 | - private void reload_relevancies () { |
1571 | - |
1572 | - Idle.add_full (Priority.LOW, () => { |
1573 | - load_application_relevancies.begin (); |
1574 | - return false; |
1575 | - }); |
1576 | - } |
1577 | - |
1578 | - private async void load_application_relevancies () { |
1579 | - |
1580 | - Idle.add (load_application_relevancies.callback, Priority.HIGH); |
1581 | - yield; |
1582 | - |
1583 | - int64 end = Zeitgeist.Timestamp.now (); |
1584 | - int64 start = end - Zeitgeist.Timestamp.WEEK * 4; |
1585 | - Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end); |
1586 | - |
1587 | - var event = new Zeitgeist.Event (); |
1588 | - event.set_interpretation ("!" + ZG_LEAVE_EVENT); |
1589 | - var subject = new Zeitgeist.Subject (); |
1590 | - subject.set_interpretation (NFO_SOFTWARE); |
1591 | - subject.set_uri ("application://*"); |
1592 | - event.add_subject (subject); |
1593 | - |
1594 | - var ptr_arr = new PtrArray (); |
1595 | - ptr_arr.add (event); |
1596 | - |
1597 | - Zeitgeist.ResultSet rs; |
1598 | - |
1599 | - try { |
1600 | - |
1601 | - rs = yield zg_log.find_events (tr, (owned) ptr_arr, |
1602 | - Zeitgeist.StorageState.ANY, |
1603 | - 256, |
1604 | - Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, |
1605 | - null); |
1606 | - |
1607 | - app_popularity.clear (); |
1608 | - uint size = rs.size (); |
1609 | - uint index = 0; |
1610 | - |
1611 | - // Zeitgeist (0.6) doesn't have any stats API, so let's approximate |
1612 | - |
1613 | - foreach (Zeitgeist.Event e in rs) { |
1614 | - |
1615 | - if (e.num_subjects () <= 0) continue; |
1616 | - Zeitgeist.Subject s = e.get_subject (0); |
1617 | - |
1618 | - float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0> |
1619 | - float relevancy = 1.0f / Math.powf (index + 1, power); |
1620 | - app_popularity[s.get_uri ()] = (int)(relevancy * MULTIPLIER); |
1621 | - index++; |
1622 | - } |
1623 | - update_complete (); |
1624 | - } catch (Error err) { |
1625 | - warning ("%s", err.message); |
1626 | - return; |
1627 | - } |
1628 | - } |
1629 | - |
1630 | - public float get_app_popularity (string desktop_id) { |
1631 | - |
1632 | - var id = "application://" + desktop_id; |
1633 | - |
1634 | - if (app_popularity.has_key(id)) { |
1635 | - return app_popularity[id] / MULTIPLIER; |
1636 | - } |
1637 | - |
1638 | - return 0.0f; |
1639 | - } |
1640 | - |
1641 | - public void app_launched (App app) { |
1642 | - |
1643 | - string app_uri = null; |
1644 | - if (app.desktop_id != null) { |
1645 | - app_uri = "application://" + app.desktop_id; |
1646 | - } |
1647 | - |
1648 | - push_app_launch (app_uri, app.name); |
1649 | - |
1650 | - // and refresh |
1651 | - reload_relevancies (); |
1652 | - } |
1653 | - |
1654 | - private void push_app_launch (string app_uri, string? display_name) { |
1655 | - |
1656 | - message ("Pushing launch event: %s [%s]", app_uri, display_name); |
1657 | - var event = new Zeitgeist.Event (); |
1658 | - var subject = new Zeitgeist.Subject (); |
1659 | - |
1660 | - event.set_actor ("application://synapse.desktop"); |
1661 | - event.set_interpretation (Zeitgeist.ZG_ACCESS_EVENT); |
1662 | - event.set_manifestation (Zeitgeist.ZG_USER_ACTIVITY); |
1663 | - event.add_subject (subject); |
1664 | - |
1665 | - subject.set_uri (app_uri); |
1666 | - subject.set_interpretation (Zeitgeist.NFO_SOFTWARE); |
1667 | - subject.set_manifestation (Zeitgeist.NFO_SOFTWARE_ITEM); |
1668 | - subject.set_mimetype ("application/x-desktop"); |
1669 | - subject.set_text (display_name); |
1670 | - |
1671 | - zg_log.insert_events_no_reply (event, null); |
1672 | - } |
1673 | - } |
1674 | -} |
1675 | + return false; |
1676 | + }); |
1677 | + } |
1678 | + |
1679 | + private async void load_application_relevancies () { |
1680 | + |
1681 | + Idle.add (load_application_relevancies.callback, Priority.HIGH); |
1682 | + yield; |
1683 | + |
1684 | + int64 end = Zeitgeist.Timestamp.from_now (); |
1685 | + int64 start = end - Zeitgeist.Timestamp.WEEK * 4; |
1686 | + Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end); |
1687 | + |
1688 | + var event = new Zeitgeist.Event (); |
1689 | + event.interpretation = "!" + Zeitgeist.ZG.LEAVE_EVENT; |
1690 | + var subject = new Zeitgeist.Subject (); |
1691 | + subject.interpretation = Zeitgeist.NFO.SOFTWARE; |
1692 | + subject.uri = "application://*"; |
1693 | + event.add_subject (subject); |
1694 | + |
1695 | + var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> (); |
1696 | + ptr_arr.add (event); |
1697 | + |
1698 | + Zeitgeist.ResultSet rs; |
1699 | + |
1700 | + try { |
1701 | + |
1702 | + rs = yield zg_log.find_events (tr, (owned) ptr_arr, |
1703 | + Zeitgeist.StorageState.ANY, |
1704 | + 256, |
1705 | + Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, |
1706 | + null); |
1707 | + |
1708 | + app_popularity.clear (); |
1709 | + uint size = rs.size (); |
1710 | + uint index = 0; |
1711 | + |
1712 | + // Zeitgeist (0.6) doesn't have any stats API, so let's approximate |
1713 | + |
1714 | + foreach (Zeitgeist.Event e in rs) { |
1715 | + |
1716 | + if (e.num_subjects () <= 0) continue; |
1717 | + Zeitgeist.Subject s = e.get_subject (0); |
1718 | + |
1719 | + float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0> |
1720 | + float relevancy = 1.0f / Math.powf (index + 1, power); |
1721 | + app_popularity[s.uri] = (int)(relevancy * MULTIPLIER); |
1722 | + index++; |
1723 | + } |
1724 | + update_complete (); |
1725 | + } catch (Error err) { |
1726 | + warning ("%s", err.message); |
1727 | + return; |
1728 | + } |
1729 | + } |
1730 | + |
1731 | + public float get_app_popularity (string desktop_id) { |
1732 | + |
1733 | + var id = "application://" + desktop_id; |
1734 | + |
1735 | + if (app_popularity.has_key(id)) { |
1736 | + return app_popularity[id] / MULTIPLIER; |
1737 | + } |
1738 | + |
1739 | + return 0.0f; |
1740 | + } |
1741 | + |
1742 | + public void app_launched (App app) { |
1743 | + |
1744 | + string app_uri = null; |
1745 | + if (app.desktop_id != null) { |
1746 | + app_uri = "application://" + app.desktop_id; |
1747 | + } |
1748 | + |
1749 | + push_app_launch (app_uri, app.name); |
1750 | + |
1751 | + // and refresh |
1752 | + reload_relevancies (); |
1753 | + } |
1754 | + |
1755 | + private void push_app_launch (string app_uri, string? display_name) { |
1756 | + |
1757 | + message ("Pushing launch event: %s [%s]", app_uri, display_name); |
1758 | + var event = new Zeitgeist.Event (); |
1759 | + var subject = new Zeitgeist.Subject (); |
1760 | + |
1761 | + event.actor = "application://synapse.desktop"; |
1762 | + event.interpretation = Zeitgeist.ZG.ACCESS_EVENT; |
1763 | + event.manifestation = Zeitgeist.ZG.USER_ACTIVITY; |
1764 | + event.add_subject (subject); |
1765 | + |
1766 | + subject.uri = app_uri; |
1767 | + subject.interpretation = Zeitgeist.NFO.SOFTWARE; |
1768 | + subject.manifestation = Zeitgeist.NFO.SOFTWARE_ITEM; |
1769 | + subject.mimetype = "application/x-desktop"; |
1770 | + subject.text = display_name; |
1771 | + var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> (); |
1772 | + ptr_arr.add (event); |
1773 | + |
1774 | + try { |
1775 | + zg_log.insert_events_no_reply (ptr_arr); |
1776 | + } catch (Error e) { |
1777 | + critical (e.message); |
1778 | + } |
1779 | + } |
1780 | +} |
1781 | \ No newline at end of file |
1782 | |
1783 | === modified file 'src/Settings.vala' |
1784 | --- src/Settings.vala 2013-09-03 21:34:05 +0000 |
1785 | +++ src/Settings.vala 2013-12-26 00:13:32 +0000 |
1786 | @@ -16,34 +16,28 @@ |
1787 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1788 | // |
1789 | |
1790 | -using Granite.Services; |
1791 | - |
1792 | -namespace Slingshot { |
1793 | - |
1794 | - public class Settings : Granite.Services.Settings { |
1795 | - |
1796 | - protected class GalaSettings : Granite.Services.Settings { |
1797 | - |
1798 | - public string hotcorner_topleft { get; set; } |
1799 | - |
1800 | - public GalaSettings () { |
1801 | - base ("org.pantheon.desktop.gala.behavior"); |
1802 | - } |
1803 | - } |
1804 | - |
1805 | - public int columns { get; set; } |
1806 | - public int rows { get; set; } |
1807 | - public int icon_size { get; set; } |
1808 | - public bool show_category_filter { get; set; } |
1809 | - public bool use_category { get; set; } |
1810 | - public string screen_resolution { get; set; } |
1811 | - public GalaSettings gala_settings; |
1812 | - |
1813 | - public Settings () { |
1814 | - base ("org.pantheon.desktop.slingshot"); |
1815 | - gala_settings = new GalaSettings (); |
1816 | - } |
1817 | - |
1818 | +public class Slingshot.Settings : Granite.Services.Settings { |
1819 | + |
1820 | + protected class GalaSettings : Granite.Services.Settings { |
1821 | + |
1822 | + public string hotcorner_topleft { get; set; } |
1823 | + |
1824 | + public GalaSettings () { |
1825 | + base ("org.pantheon.desktop.gala.behavior"); |
1826 | + } |
1827 | + } |
1828 | + |
1829 | + public int columns { get; set; } |
1830 | + public int rows { get; set; } |
1831 | + public int icon_size { get; set; } |
1832 | + public bool show_category_filter { get; set; } |
1833 | + public bool use_category { get; set; } |
1834 | + public string screen_resolution { get; set; } |
1835 | + public GalaSettings gala_settings; |
1836 | + |
1837 | + public Settings () { |
1838 | + base ("org.pantheon.desktop.slingshot"); |
1839 | + gala_settings = new GalaSettings (); |
1840 | } |
1841 | |
1842 | } |
1843 | |
1844 | === modified file 'src/Slingshot.vala' |
1845 | --- src/Slingshot.vala 2013-08-12 22:47:17 +0000 |
1846 | +++ src/Slingshot.vala 2013-12-26 00:13:32 +0000 |
1847 | @@ -16,100 +16,93 @@ |
1848 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1849 | // |
1850 | |
1851 | -using Gtk; |
1852 | -using Granite; |
1853 | - |
1854 | -namespace Slingshot { |
1855 | - |
1856 | - public class Slingshot : Granite.Application { |
1857 | - |
1858 | - private SlingshotView view = null; |
1859 | - public static bool silent = false; |
1860 | - public static bool command_mode = false; |
1861 | - |
1862 | - public static Settings settings { get; private set; default = null; } |
1863 | - //public static CssProvider style_provider { get; private set; default = null; } |
1864 | - public static IconTheme icon_theme { get; set; default = null; } |
1865 | - private DBusService? dbus_service = null; |
1866 | - |
1867 | - construct { |
1868 | - |
1869 | - build_data_dir = Build.DATADIR; |
1870 | - build_pkg_data_dir = Build.PKGDATADIR; |
1871 | - build_release_name = Build.RELEASE_NAME; |
1872 | - build_version = Build.VERSION; |
1873 | - build_version_info = Build.VERSION_INFO; |
1874 | - |
1875 | - program_name = "Slingshot"; |
1876 | - exec_name = "slingshot-launcher"; |
1877 | - app_copyright = "GPLv3"; |
1878 | - app_icon = ""; |
1879 | - app_launcher = ""; |
1880 | - app_years = "2011-2012"; |
1881 | - application_id = "net.launchpad.slingshot"; |
1882 | - main_url = "https://launchpad.net/slingshot"; |
1883 | - bug_url = "https://bugs.launchpad.net/slingshot"; |
1884 | - help_url = "https://answers.launchpad.net/slingshot"; |
1885 | - translate_url = "https://translations.launchpad.net/slingshot"; |
1886 | - |
1887 | - about_authors = {"Giulio Collura <random.cpp@gmail.com>", |
1888 | - "Andrea Basso <andrea@elementaryos.org"}; |
1889 | - about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>", |
1890 | - "Daniel Foré <bunny@go-docky.com>"}; |
1891 | - about_translators = "Launchpad Translators"; |
1892 | - about_license_type = License.GPL_3_0; |
1893 | - |
1894 | - } |
1895 | - |
1896 | - public Slingshot () { |
1897 | - settings = new Settings (); |
1898 | - } |
1899 | - |
1900 | - protected override void activate () { |
1901 | - if (get_windows () == null) { |
1902 | - view = new SlingshotView (); |
1903 | - view.set_application (this); |
1904 | - |
1905 | - if (dbus_service == null) |
1906 | - dbus_service = new DBusService (view); |
1907 | - |
1908 | - if (!silent) { |
1909 | - //view.move_to_coords (0, 0); |
1910 | - view.show_slingshot (); |
1911 | - } |
1912 | - } else { |
1913 | - if (view.visible && !silent) |
1914 | - view.hide (); |
1915 | - else |
1916 | - view.show_slingshot (); |
1917 | - } |
1918 | - silent = false; |
1919 | - } |
1920 | - |
1921 | - static const OptionEntry[] entries = { |
1922 | - { "silent", 's', 0, OptionArg.NONE, ref silent, "Launch Slingshot as a background process without it appearing visually.", null }, |
1923 | - { "command-mode", 'c', 0, OptionArg.NONE, ref command_mode, "This feature is not implemented yet. When it is, description will be changed.", null }, |
1924 | - { null } |
1925 | - }; |
1926 | - |
1927 | - public static int main (string[] args) { |
1928 | - if (args.length > 1) { |
1929 | - var context = new OptionContext (""); |
1930 | - context.add_main_entries (entries, "slingshot"); |
1931 | - context.add_group (Gtk.get_option_group (true)); |
1932 | - |
1933 | - try { |
1934 | - context.parse (ref args); |
1935 | - } catch (Error e) { |
1936 | - print (e.message + "\n"); |
1937 | - } |
1938 | - } |
1939 | +public class Slingshot.Slingshot : Granite.Application { |
1940 | + |
1941 | + private SlingshotView view = null; |
1942 | + public static bool silent = false; |
1943 | + public static bool command_mode = false; |
1944 | + |
1945 | + public static Settings settings { get; private set; default = null; } |
1946 | + //public static CssProvider style_provider { get; private set; default = null; } |
1947 | + public static Gtk.IconTheme icon_theme { get; set; default = null; } |
1948 | + private DBusService? dbus_service = null; |
1949 | + |
1950 | + construct { |
1951 | + |
1952 | + build_data_dir = Build.DATADIR; |
1953 | + build_pkg_data_dir = Build.PKGDATADIR; |
1954 | + build_release_name = Build.RELEASE_NAME; |
1955 | + build_version = Build.VERSION; |
1956 | + build_version_info = Build.VERSION_INFO; |
1957 | + |
1958 | + program_name = "Slingshot"; |
1959 | + exec_name = "slingshot-launcher"; |
1960 | + app_copyright = "GPLv3"; |
1961 | + app_icon = ""; |
1962 | + app_launcher = ""; |
1963 | + app_years = "2011-2012"; |
1964 | + application_id = "net.launchpad.slingshot"; |
1965 | + main_url = "https://launchpad.net/slingshot"; |
1966 | + bug_url = "https://bugs.launchpad.net/slingshot"; |
1967 | + help_url = "https://answers.launchpad.net/slingshot"; |
1968 | + translate_url = "https://translations.launchpad.net/slingshot"; |
1969 | + |
1970 | + about_authors = {"Giulio Collura <random.cpp@gmail.com>", |
1971 | + "Andrea Basso <andrea@elementaryos.org"}; |
1972 | + about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>", |
1973 | + "Daniel Foré <bunny@go-docky.com>"}; |
1974 | + about_translators = "Launchpad Translators"; |
1975 | + about_license_type = Gtk.License.GPL_3_0; |
1976 | + |
1977 | + } |
1978 | + |
1979 | + public Slingshot () { |
1980 | + settings = new Settings (); |
1981 | + } |
1982 | + |
1983 | + protected override void activate () { |
1984 | + if (get_windows () == null) { |
1985 | + view = new SlingshotView (); |
1986 | + view.set_application (this); |
1987 | + |
1988 | + if (dbus_service == null) |
1989 | + dbus_service = new DBusService (view); |
1990 | + |
1991 | + if (!silent) { |
1992 | + //view.move_to_coords (0, 0); |
1993 | + view.show_slingshot (); |
1994 | + } |
1995 | + } else { |
1996 | + if (view.visible && !silent) |
1997 | + view.hide (); |
1998 | + else |
1999 | + view.show_slingshot (); |
2000 | + } |
2001 | + silent = false; |
2002 | + } |
2003 | + |
2004 | + static const OptionEntry[] entries = { |
2005 | + { "silent", 's', 0, OptionArg.NONE, ref silent, "Launch Slingshot as a background process without it appearing visually.", null }, |
2006 | + { "command-mode", 'c', 0, OptionArg.NONE, ref command_mode, "This feature is not implemented yet. When it is, description will be changed.", null }, |
2007 | + { null } |
2008 | + }; |
2009 | + |
2010 | + public static int main (string[] args) { |
2011 | + if (args.length > 1) { |
2012 | + var context = new OptionContext (""); |
2013 | + context.add_main_entries (entries, "slingshot"); |
2014 | + context.add_group (Gtk.get_option_group (true)); |
2015 | |
2016 | - var app = new Slingshot (); |
2017 | - |
2018 | - return app.run (args); |
2019 | + try { |
2020 | + context.parse (ref args); |
2021 | + } catch (Error e) { |
2022 | + print (e.message + "\n"); |
2023 | + } |
2024 | } |
2025 | + |
2026 | + var app = new Slingshot (); |
2027 | |
2028 | + return app.run (args); |
2029 | } |
2030 | |
2031 | } |
2032 | |
2033 | === modified file 'src/SlingshotView.vala' |
2034 | --- src/SlingshotView.vala 2013-10-24 10:20:42 +0000 |
2035 | +++ src/SlingshotView.vala 2013-12-26 00:13:32 +0000 |
2036 | @@ -16,16 +16,6 @@ |
2037 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2038 | // |
2039 | |
2040 | -using Gtk; |
2041 | -using Gdk; |
2042 | -using Gee; |
2043 | -using Cairo; |
2044 | -using Granite.Widgets; |
2045 | -using GMenu; |
2046 | - |
2047 | -using Slingshot.Widgets; |
2048 | -using Slingshot.Backend; |
2049 | - |
2050 | namespace Slingshot { |
2051 | |
2052 | public enum Modality { |
2053 | @@ -34,18 +24,18 @@ |
2054 | SEARCH_VIEW |
2055 | } |
2056 | |
2057 | - public class SlingshotView : PopOver { |
2058 | + public class SlingshotView : Granite.Widgets.PopOver { |
2059 | |
2060 | // Widgets |
2061 | public Granite.Widgets.SearchBar searchbar; |
2062 | - public Layout view_manager; |
2063 | - public Switcher page_switcher; |
2064 | - public ModeButton view_selector; |
2065 | + public Gtk.Layout view_manager; |
2066 | + public Widgets.Switcher page_switcher; |
2067 | + public Granite.Widgets.ModeButton view_selector; |
2068 | |
2069 | // Views |
2070 | private Widgets.Grid grid_view; |
2071 | - private SearchView search_view; |
2072 | - private CategoryView category_view; |
2073 | + private Widgets.SearchView search_view; |
2074 | + private Widgets.CategoryView category_view; |
2075 | |
2076 | public Gtk.Grid top; |
2077 | public Gtk.Grid center; |
2078 | @@ -54,9 +44,9 @@ |
2079 | public Gtk.Box content_area; |
2080 | private Gtk.EventBox event_box; |
2081 | |
2082 | - public AppSystem app_system; |
2083 | - private ArrayList<TreeDirectory> categories; |
2084 | - public HashMap<string, ArrayList<App>> apps; |
2085 | + public Backend.AppSystem app_system; |
2086 | + private Gee.ArrayList<GMenu.TreeDirectory> categories; |
2087 | + public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps; |
2088 | |
2089 | private int current_position = 0; |
2090 | private int search_view_position = 0; |
2091 | @@ -100,9 +90,9 @@ |
2092 | // Have the window in the right place |
2093 | read_settings (true); |
2094 | |
2095 | - Slingshot.icon_theme = IconTheme.get_default (); |
2096 | + Slingshot.icon_theme = Gtk.IconTheme.get_default (); |
2097 | |
2098 | - app_system = new AppSystem (); |
2099 | + app_system = new Backend.AppSystem (); |
2100 | |
2101 | categories = app_system.get_categories (); |
2102 | apps = app_system.get_apps (); |
2103 | @@ -148,16 +138,16 @@ |
2104 | // Add top bar |
2105 | top = new Gtk.Grid (); |
2106 | |
2107 | - var top_separator = new Label (""); // A fake label |
2108 | + var top_separator = new Gtk.Label (""); // A fake label |
2109 | top_separator.set_hexpand(true); |
2110 | |
2111 | - view_selector = new ModeButton (); |
2112 | + view_selector = new Granite.Widgets.ModeButton (); |
2113 | |
2114 | - var image = new Image.from_icon_name ("view-grid-symbolic", IconSize.MENU); |
2115 | + var image = new Gtk.Image.from_icon_name ("view-grid-symbolic", Gtk.IconSize.MENU); |
2116 | image.tooltip_text = _("View as Grid"); |
2117 | view_selector.append (image); |
2118 | |
2119 | - image = new Image.from_icon_name ("view-filter-symbolic", IconSize.MENU); |
2120 | + image = new Gtk.Image.from_icon_name ("view-filter-symbolic", Gtk.IconSize.MENU); |
2121 | image.tooltip_text = _("View by Category"); |
2122 | view_selector.append (image); |
2123 | |
2124 | @@ -179,7 +169,7 @@ |
2125 | |
2126 | center = new Gtk.Grid (); |
2127 | // Create the layout which works like view_manager |
2128 | - view_manager = new Layout (null, null); |
2129 | + view_manager = new Gtk.Layout (null, null); |
2130 | view_manager.set_size_request (default_columns * 130, default_rows * 145); |
2131 | center.attach (view_manager, 0, 0, 1, 1); |
2132 | |
2133 | @@ -188,26 +178,26 @@ |
2134 | view_manager.put (grid_view, 0, 0); |
2135 | |
2136 | // Create the "SEARCH_VIEW" |
2137 | - search_view = new SearchView (this); |
2138 | - foreach (ArrayList<App> app_list in apps.values) { |
2139 | + search_view = new Widgets.SearchView (this); |
2140 | + foreach (Gee.ArrayList<Backend.App> app_list in apps.values) { |
2141 | search_view.add_apps (app_list); |
2142 | } |
2143 | view_manager.put (search_view, -columns * 130, 0); |
2144 | |
2145 | // Create the "CATEGORY_VIEW" |
2146 | - category_view = new CategoryView (this); |
2147 | + category_view = new Widgets.CategoryView (this); |
2148 | view_manager.put (category_view, -columns * 130, 0); |
2149 | |
2150 | // Create the page switcher |
2151 | - page_switcher = new Switcher (); |
2152 | + page_switcher = new Widgets.Switcher (); |
2153 | |
2154 | // A bottom widget to keep the page switcher center |
2155 | bottom = new Gtk.Grid (); |
2156 | |
2157 | |
2158 | - var bottom_separator1 = new Label (""); // A fake label |
2159 | + var bottom_separator1 = new Gtk.Label (""); // A fake label |
2160 | bottom_separator1.set_hexpand (true); |
2161 | - var bottom_separator2 = new Label (""); // A fake label |
2162 | + var bottom_separator2 = new Gtk.Label (""); // A fake label |
2163 | bottom_separator2.set_hexpand (true); |
2164 | bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label |
2165 | bottom.attach (page_switcher, 1, 0, 1, 1); |
2166 | @@ -220,7 +210,7 @@ |
2167 | event_box = new Gtk.EventBox (); |
2168 | event_box.add (container); |
2169 | // Add the container to the dialog's content area |
2170 | - content_area = get_content_area () as Box; |
2171 | + content_area = get_content_area () as Gtk.Box; |
2172 | content_area.pack_start (event_box); |
2173 | |
2174 | if (Slingshot.settings.use_category) |
2175 | @@ -294,7 +284,7 @@ |
2176 | //view_manager.draw.connect (this.draw_background); |
2177 | |
2178 | event_box.key_press_event.connect (on_key_press); |
2179 | - searchbar.text_changed_pause.connect ((text) => this.search (text)); |
2180 | + searchbar.text_changed_pause.connect ((text) => this.search.begin (text)); |
2181 | searchbar.grab_focus (); |
2182 | |
2183 | searchbar.activate.connect (() => { |
2184 | @@ -302,8 +292,8 @@ |
2185 | search_view.launch_selected (); |
2186 | hide (); |
2187 | } else { |
2188 | - if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry |
2189 | - ((AppEntry) get_focus ()).launch_app (); |
2190 | + if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry |
2191 | + ((Widgets.AppEntry) get_focus ()).launch_app (); |
2192 | } |
2193 | }); |
2194 | |
2195 | @@ -433,8 +423,8 @@ |
2196 | search_view.launch_selected (); |
2197 | hide (); |
2198 | } else { |
2199 | - if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry |
2200 | - ((AppEntry)get_focus ()).launch_app (); |
2201 | + if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry |
2202 | + ((Widgets.AppEntry)get_focus ()).launch_app (); |
2203 | } |
2204 | return true; |
2205 | |
2206 | @@ -596,7 +586,7 @@ |
2207 | break; |
2208 | |
2209 | case "Home": |
2210 | - if (searchbar.text.size () > 0) { |
2211 | + if (searchbar.text.length > 0) { |
2212 | return false; |
2213 | } |
2214 | |
2215 | @@ -609,7 +599,7 @@ |
2216 | break; |
2217 | |
2218 | case "End": |
2219 | - if (searchbar.text.size () > 0) { |
2220 | + if (searchbar.text.length > 0) { |
2221 | return false; |
2222 | } |
2223 | |
2224 | @@ -641,7 +631,7 @@ |
2225 | |
2226 | } |
2227 | |
2228 | - public override bool scroll_event (EventScroll event) { |
2229 | + public override bool scroll_event (Gdk.EventScroll event) { |
2230 | |
2231 | switch (event.direction.to_string ()) { |
2232 | case "GDK_SCROLL_UP": |
2233 | @@ -820,7 +810,7 @@ |
2234 | |
2235 | var filtered = yield app_system.search_results (stripped); |
2236 | |
2237 | - foreach (App app in filtered) { |
2238 | + foreach (Backend.App app in filtered) { |
2239 | search_view.show_app (app); |
2240 | } |
2241 | |
2242 | @@ -836,9 +826,9 @@ |
2243 | page_switcher.append ("1"); |
2244 | page_switcher.set_active (0); |
2245 | |
2246 | - foreach (App app in app_system.get_apps_by_name ()) { |
2247 | + foreach (Backend.App app in app_system.get_apps_by_name ()) { |
2248 | |
2249 | - var app_entry = new AppEntry (app); |
2250 | + var app_entry = new Widgets.AppEntry (app); |
2251 | app_entry.app_launched.connect (() => hide ()); |
2252 | grid_view.append (app_entry); |
2253 | app_entry.show_all (); |
2254 | @@ -878,7 +868,7 @@ |
2255 | } |
2256 | |
2257 | private void normal_move_focus (int delta_column, int delta_row) { |
2258 | - if (get_focus () as AppEntry != null) { // we check if any AppEntry has focus. If it does, we move |
2259 | + if (get_focus () as Widgets.AppEntry != null) { // we check if any AppEntry has focus. If it does, we move |
2260 | var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists |
2261 | if (new_focus == null) { |
2262 | if (delta_column <= 0) |
2263 | @@ -960,4 +950,4 @@ |
2264 | } |
2265 | } |
2266 | |
2267 | -} |
2268 | +} |
2269 | \ No newline at end of file |
2270 | |
2271 | === modified file 'src/Widgets/AppEntry.vala' |
2272 | --- src/Widgets/AppEntry.vala 2013-02-16 11:56:18 +0000 |
2273 | +++ src/Widgets/AppEntry.vala 2013-12-26 00:13:32 +0000 |
2274 | @@ -16,137 +16,130 @@ |
2275 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2276 | // |
2277 | |
2278 | -using Gtk; |
2279 | -using Gdk; |
2280 | -using Cairo; |
2281 | - |
2282 | -namespace Slingshot.Widgets { |
2283 | - |
2284 | - public class AppEntry : Button { |
2285 | - |
2286 | - public Label app_label; |
2287 | - private Pixbuf icon; |
2288 | - private Box layout; |
2289 | - |
2290 | - public string exec_name; |
2291 | - public string app_name; |
2292 | - public string desktop_id; |
2293 | - public int icon_size; |
2294 | - public string desktop_path; |
2295 | - |
2296 | - public signal void app_launched (); |
2297 | - |
2298 | - private double alpha = 1.0; |
2299 | - private bool dragging = false; //prevent launching |
2300 | - |
2301 | - private Backend.App application; |
2302 | - |
2303 | - public AppEntry (Backend.App app) { |
2304 | - TargetEntry dnd = {"text/uri-list", 0, 0}; |
2305 | - Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, |
2306 | - Gdk.DragAction.COPY); |
2307 | - |
2308 | - app_paintable = true; |
2309 | - set_visual (get_screen ().get_rgba_visual()); |
2310 | - set_size_request (130, 130); |
2311 | - desktop_id = app.desktop_id; |
2312 | - desktop_path = app.desktop_path; |
2313 | - |
2314 | - application = app; |
2315 | - app_name = app.name; |
2316 | - tooltip_text = app.description; |
2317 | - exec_name = app.exec; |
2318 | - icon_size = Slingshot.settings.icon_size; |
2319 | - icon = app.icon; |
2320 | - |
2321 | - get_style_context ().add_class ("app"); |
2322 | - |
2323 | - app_label = new Label (app_name); |
2324 | - app_label.halign = Align.CENTER; |
2325 | - app_label.justify = Justification.CENTER; |
2326 | - app_label.set_line_wrap (true); // Need a smarter way |
2327 | - app_label.set_single_line_mode (false); |
2328 | - app_label.set_ellipsize (Pango.EllipsizeMode.END); |
2329 | - |
2330 | - layout = new Box (Orientation.VERTICAL, 0); |
2331 | - layout.homogeneous = false; |
2332 | - |
2333 | - layout.pack_start (app_label, false, true, 0); |
2334 | - |
2335 | - add (Utils.set_padding (layout, 78, 5, 5, 5)); |
2336 | - |
2337 | - this.clicked.connect (launch_app); |
2338 | - |
2339 | - this.button_press_event.connect ((e) => {return e.button == 3;}); |
2340 | - |
2341 | - this.drag_begin.connect ( (ctx) => { |
2342 | - this.dragging = true; |
2343 | - Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0); |
2344 | - }); |
2345 | - this.drag_end.connect ( () => { |
2346 | - this.dragging = false; |
2347 | - }); |
2348 | - this.drag_data_get.connect ( (ctx, sel, info, time) => { |
2349 | - sel.set_uris ({File.new_for_path (desktop_path).get_uri ()}); |
2350 | - }); |
2351 | - |
2352 | - app.icon_changed.connect (queue_draw); |
2353 | - |
2354 | - } |
2355 | - |
2356 | - protected override bool draw (Context cr) { |
2357 | - |
2358 | - |
2359 | - Allocation size; |
2360 | - get_allocation (out size); |
2361 | - |
2362 | - base.draw (cr); |
2363 | - |
2364 | - // Draw icon |
2365 | - Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10); |
2366 | - cr.paint_with_alpha (alpha); |
2367 | - |
2368 | - return true; |
2369 | - |
2370 | - } |
2371 | - |
2372 | - public void fade_out () { |
2373 | - |
2374 | - Timeout.add (20, () => { |
2375 | - |
2376 | - if (alpha <= 0.3) { |
2377 | - queue_draw (); |
2378 | - return false; |
2379 | - } |
2380 | - |
2381 | - alpha -= 0.05; |
2382 | - queue_draw (); |
2383 | - return true; |
2384 | - |
2385 | - }); |
2386 | - |
2387 | - } |
2388 | - |
2389 | - public void fade_in () { |
2390 | - |
2391 | - Timeout.add (20, () => { |
2392 | - |
2393 | - if (alpha == 1.0) { |
2394 | - queue_draw (); |
2395 | - return false; |
2396 | - } |
2397 | - |
2398 | - alpha += 0.05; |
2399 | - queue_draw (); |
2400 | - return true; |
2401 | - |
2402 | - }); |
2403 | - |
2404 | - } |
2405 | - |
2406 | - public void launch_app () { |
2407 | - application.launch (); |
2408 | - app_launched (); |
2409 | - } |
2410 | +public class Slingshot.Widgets.AppEntry : Gtk.Button { |
2411 | + |
2412 | + public Gtk.Label app_label; |
2413 | + private Gdk.Pixbuf icon; |
2414 | + private Gtk.Box layout; |
2415 | + |
2416 | + public string exec_name; |
2417 | + public string app_name; |
2418 | + public string desktop_id; |
2419 | + public int icon_size; |
2420 | + public string desktop_path; |
2421 | + |
2422 | + public signal void app_launched (); |
2423 | + |
2424 | + private double alpha = 1.0; |
2425 | + private bool dragging = false; //prevent launching |
2426 | + |
2427 | + private Backend.App application; |
2428 | + |
2429 | + public AppEntry (Backend.App app) { |
2430 | + Gtk.TargetEntry dnd = {"text/uri-list", 0, 0}; |
2431 | + Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, |
2432 | + Gdk.DragAction.COPY); |
2433 | + |
2434 | + app_paintable = true; |
2435 | + set_visual (get_screen ().get_rgba_visual()); |
2436 | + set_size_request (130, 130); |
2437 | + desktop_id = app.desktop_id; |
2438 | + desktop_path = app.desktop_path; |
2439 | + |
2440 | + application = app; |
2441 | + app_name = app.name; |
2442 | + tooltip_text = app.description; |
2443 | + exec_name = app.exec; |
2444 | + icon_size = Slingshot.settings.icon_size; |
2445 | + icon = app.icon; |
2446 | + |
2447 | + get_style_context ().add_class ("app"); |
2448 | + |
2449 | + app_label = new Gtk.Label (app_name); |
2450 | + app_label.halign = Gtk.Align.CENTER; |
2451 | + app_label.justify = Gtk.Justification.CENTER; |
2452 | + app_label.set_line_wrap (true); // Need a smarter way |
2453 | + app_label.set_single_line_mode (false); |
2454 | + app_label.set_ellipsize (Pango.EllipsizeMode.END); |
2455 | + |
2456 | + layout = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
2457 | + layout.homogeneous = false; |
2458 | + |
2459 | + layout.pack_start (app_label, false, true, 0); |
2460 | + |
2461 | + add (Utils.set_padding (layout, 78, 5, 5, 5)); |
2462 | + |
2463 | + this.clicked.connect (launch_app); |
2464 | + |
2465 | + this.button_press_event.connect ((e) => {return e.button == 3;}); |
2466 | + |
2467 | + this.drag_begin.connect ( (ctx) => { |
2468 | + this.dragging = true; |
2469 | + Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0); |
2470 | + }); |
2471 | + this.drag_end.connect ( () => { |
2472 | + this.dragging = false; |
2473 | + }); |
2474 | + this.drag_data_get.connect ( (ctx, sel, info, time) => { |
2475 | + sel.set_uris ({File.new_for_path (desktop_path).get_uri ()}); |
2476 | + }); |
2477 | + |
2478 | + app.icon_changed.connect (queue_draw); |
2479 | + |
2480 | + } |
2481 | + |
2482 | + protected override bool draw (Cairo.Context cr) { |
2483 | + |
2484 | + |
2485 | + Gtk.Allocation size; |
2486 | + get_allocation (out size); |
2487 | + |
2488 | + base.draw (cr); |
2489 | + |
2490 | + // Draw icon |
2491 | + Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10); |
2492 | + cr.paint_with_alpha (alpha); |
2493 | + |
2494 | + return true; |
2495 | + |
2496 | + } |
2497 | + |
2498 | + public void fade_out () { |
2499 | + |
2500 | + Timeout.add (20, () => { |
2501 | + |
2502 | + if (alpha <= 0.3) { |
2503 | + queue_draw (); |
2504 | + return false; |
2505 | + } |
2506 | + |
2507 | + alpha -= 0.05; |
2508 | + queue_draw (); |
2509 | + return true; |
2510 | + |
2511 | + }); |
2512 | + |
2513 | + } |
2514 | + |
2515 | + public void fade_in () { |
2516 | + |
2517 | + Timeout.add (20, () => { |
2518 | + |
2519 | + if (alpha == 1.0) { |
2520 | + queue_draw (); |
2521 | + return false; |
2522 | + } |
2523 | + |
2524 | + alpha += 0.05; |
2525 | + queue_draw (); |
2526 | + return true; |
2527 | + |
2528 | + }); |
2529 | + |
2530 | + } |
2531 | + |
2532 | + public void launch_app () { |
2533 | + application.launch (); |
2534 | + app_launched (); |
2535 | } |
2536 | } |
2537 | |
2538 | === modified file 'src/Widgets/CategoryView.vala' |
2539 | --- src/Widgets/CategoryView.vala 2013-08-26 08:45:09 +0000 |
2540 | +++ src/Widgets/CategoryView.vala 2013-12-26 00:13:32 +0000 |
2541 | @@ -16,215 +16,206 @@ |
2542 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2543 | // |
2544 | |
2545 | -using Gtk; |
2546 | -using Gee; |
2547 | - |
2548 | -using Slingshot.Backend; |
2549 | - |
2550 | -namespace Slingshot.Widgets { |
2551 | - |
2552 | - public class CategoryView : EventBox { |
2553 | - |
2554 | - private Gtk.Grid container; |
2555 | - public Sidebar category_switcher; |
2556 | - public VSeparator separator; |
2557 | - public Widgets.Grid app_view; |
2558 | - private Layout layout; |
2559 | - public Switcher switcher; |
2560 | - private SlingshotView view; |
2561 | - private Label empty_cat_label; |
2562 | - |
2563 | - private Gtk.Grid page_switcher; |
2564 | - |
2565 | - private const string ALL_APPLICATIONS = _("All Applications"); |
2566 | - private const string NEW_FILTER = _("Create a new Filter"); |
2567 | - private int current_position = 0; |
2568 | - private bool from_category = false; |
2569 | - |
2570 | - public HashMap<int, string> category_ids = new HashMap<int, string> (); |
2571 | - |
2572 | - public CategoryView (SlingshotView parent) { |
2573 | - |
2574 | - view = parent; |
2575 | - |
2576 | - set_visible_window (false); |
2577 | - setup_ui (); |
2578 | - setup_sidebar (); |
2579 | - connect_events (); |
2580 | - |
2581 | - set_size_request (view.columns*130 + 17, view.view_height); |
2582 | - |
2583 | - } |
2584 | - |
2585 | - private void setup_ui () { |
2586 | - container = new Gtk.Grid (); |
2587 | - separator = new VSeparator (); |
2588 | - |
2589 | - layout = new Layout (null, null); |
2590 | - |
2591 | - app_view = new Widgets.Grid (view.rows, view.columns - 1); |
2592 | - layout.put (app_view, 0, 0); |
2593 | - empty_cat_label = new Gtk.Label (""); |
2594 | - layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2); |
2595 | - layout.set_hexpand (true); |
2596 | - layout.set_vexpand (true); |
2597 | - |
2598 | - // Create the page switcher |
2599 | - switcher = new Switcher (); |
2600 | - |
2601 | - // A bottom widget to keep the page switcher center |
2602 | - page_switcher = new Gtk.Grid (); |
2603 | - var bottom_separator1 = new Label (""); // A fake label |
2604 | - bottom_separator1.set_hexpand(true); |
2605 | - var bottom_separator2 = new Label (""); // A fake label |
2606 | - bottom_separator2.set_hexpand(true); |
2607 | - page_switcher.attach (bottom_separator1, 0, 0, 1, 1); |
2608 | - page_switcher.attach (switcher, 1, 0, 1, 1); |
2609 | - page_switcher.attach (bottom_separator2, 2, 0, 1, 1); |
2610 | - |
2611 | - container.attach (separator, 1, 0, 1, 2); |
2612 | - container.attach (layout, 2, 0, 1, 1); |
2613 | - |
2614 | - add (container); |
2615 | - |
2616 | - } |
2617 | - |
2618 | - public void setup_sidebar () { |
2619 | - |
2620 | - if (category_switcher != null) |
2621 | - category_switcher.destroy (); |
2622 | - |
2623 | - category_switcher = new Sidebar (); |
2624 | - category_switcher.can_focus = false; |
2625 | - |
2626 | - // Fill the sidebar |
2627 | - int n = 0; |
2628 | - |
2629 | - foreach (string cat_name in view.apps.keys) { |
2630 | - category_ids.set (n, cat_name); |
2631 | - category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ()); |
2632 | - n++; |
2633 | - } |
2634 | - |
2635 | - container.attach (category_switcher, 0, 0, 1, 2); |
2636 | - category_switcher.selection_changed.connect ((name, nth) => { |
2637 | - |
2638 | - view.reset_category_focus (); |
2639 | - string category = category_ids.get (nth); |
2640 | - show_filtered_apps (category); |
2641 | - }); |
2642 | - |
2643 | - category_switcher.show_all (); |
2644 | - } |
2645 | - |
2646 | - private void connect_events () { |
2647 | - |
2648 | - layout.scroll_event.connect ((event) => { |
2649 | - switch (event.direction.to_string ()) { |
2650 | - case "GDK_SCROLL_UP": |
2651 | - case "GDK_SCROLL_LEFT": |
2652 | - switcher.set_active (switcher.active - 1); |
2653 | - break; |
2654 | - case "GDK_SCROLL_DOWN": |
2655 | - case "GDK_SCROLL_RIGHT": |
2656 | - switcher.set_active (switcher.active + 1); |
2657 | - break; |
2658 | - } |
2659 | +public class Slingshot.Widgets.CategoryView : Gtk.EventBox { |
2660 | + |
2661 | + private Gtk.Grid container; |
2662 | + public Sidebar category_switcher; |
2663 | + public Gtk.Separator separator; |
2664 | + public Widgets.Grid app_view; |
2665 | + private Gtk.Layout layout; |
2666 | + public Switcher switcher; |
2667 | + private SlingshotView view; |
2668 | + private Gtk.Label empty_cat_label; |
2669 | + |
2670 | + private Gtk.Grid page_switcher; |
2671 | + |
2672 | + private const string ALL_APPLICATIONS = _("All Applications"); |
2673 | + private const string NEW_FILTER = _("Create a new Filter"); |
2674 | + private int current_position = 0; |
2675 | + private bool from_category = false; |
2676 | + |
2677 | + public Gee.HashMap<int, string> category_ids = new Gee.HashMap<int, string> (); |
2678 | + |
2679 | + public CategoryView (SlingshotView parent) { |
2680 | + |
2681 | + view = parent; |
2682 | + |
2683 | + set_visible_window (false); |
2684 | + setup_ui (); |
2685 | + setup_sidebar (); |
2686 | + connect_events (); |
2687 | + |
2688 | + set_size_request (view.columns*130 + 17, view.view_height); |
2689 | + |
2690 | + } |
2691 | + |
2692 | + private void setup_ui () { |
2693 | + container = new Gtk.Grid (); |
2694 | + separator = new Gtk.Separator (Gtk.Orientation.VERTICAL); |
2695 | + |
2696 | + layout = new Gtk.Layout (null, null); |
2697 | + |
2698 | + app_view = new Widgets.Grid (view.rows, view.columns - 1); |
2699 | + layout.put (app_view, 0, 0); |
2700 | + empty_cat_label = new Gtk.Label (""); |
2701 | + layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2); |
2702 | + layout.set_hexpand (true); |
2703 | + layout.set_vexpand (true); |
2704 | + |
2705 | + // Create the page switcher |
2706 | + switcher = new Switcher (); |
2707 | + |
2708 | + // A bottom widget to keep the page switcher center |
2709 | + page_switcher = new Gtk.Grid (); |
2710 | + var bottom_separator1 = new Gtk.Label (""); // A fake label |
2711 | + bottom_separator1.set_hexpand(true); |
2712 | + var bottom_separator2 = new Gtk.Label (""); // A fake label |
2713 | + bottom_separator2.set_hexpand(true); |
2714 | + page_switcher.attach (bottom_separator1, 0, 0, 1, 1); |
2715 | + page_switcher.attach (switcher, 1, 0, 1, 1); |
2716 | + page_switcher.attach (bottom_separator2, 2, 0, 1, 1); |
2717 | + |
2718 | + container.attach (separator, 1, 0, 1, 2); |
2719 | + container.attach (layout, 2, 0, 1, 1); |
2720 | + |
2721 | + add (container); |
2722 | + |
2723 | + } |
2724 | + |
2725 | + public void setup_sidebar () { |
2726 | + |
2727 | + if (category_switcher != null) |
2728 | + category_switcher.destroy (); |
2729 | + |
2730 | + category_switcher = new Sidebar (); |
2731 | + category_switcher.can_focus = false; |
2732 | + |
2733 | + // Fill the sidebar |
2734 | + int n = 0; |
2735 | + |
2736 | + foreach (string cat_name in view.apps.keys) { |
2737 | + category_ids.set (n, cat_name); |
2738 | + category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ()); |
2739 | + n++; |
2740 | + } |
2741 | + |
2742 | + container.attach (category_switcher, 0, 0, 1, 2); |
2743 | + category_switcher.selection_changed.connect ((name, nth) => { |
2744 | + |
2745 | + view.reset_category_focus (); |
2746 | + string category = category_ids.get (nth); |
2747 | + show_filtered_apps (category); |
2748 | + }); |
2749 | + |
2750 | + category_switcher.show_all (); |
2751 | + } |
2752 | + |
2753 | + private void connect_events () { |
2754 | + |
2755 | + layout.scroll_event.connect ((event) => { |
2756 | + switch (event.direction.to_string ()) { |
2757 | + case "GDK_SCROLL_UP": |
2758 | + case "GDK_SCROLL_LEFT": |
2759 | + switcher.set_active (switcher.active - 1); |
2760 | + break; |
2761 | + case "GDK_SCROLL_DOWN": |
2762 | + case "GDK_SCROLL_RIGHT": |
2763 | + switcher.set_active (switcher.active + 1); |
2764 | + break; |
2765 | + } |
2766 | + return false; |
2767 | + }); |
2768 | + |
2769 | + app_view.new_page.connect ((page) => { |
2770 | + |
2771 | + if (switcher.size == 0) |
2772 | + switcher.append ("1"); |
2773 | + switcher.append (page); |
2774 | + |
2775 | + /* Prevents pages from changing */ |
2776 | + from_category = true; |
2777 | + }); |
2778 | + |
2779 | + switcher.active_changed.connect (() => { |
2780 | + if (from_category || switcher.active - switcher.old_active == 0) { |
2781 | + from_category = false; |
2782 | + return; |
2783 | + } |
2784 | + |
2785 | + move_page (switcher.active - switcher.old_active); |
2786 | + view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page |
2787 | + }); |
2788 | + |
2789 | + category_switcher.selected = 0; //Must be after everything else |
2790 | + } |
2791 | + |
2792 | + private void add_app (Backend.App app) { |
2793 | + |
2794 | + var app_entry = new AppEntry (app); |
2795 | + app_entry.app_launched.connect (() => view.hide ()); |
2796 | + app_view.append (app_entry); |
2797 | + app_entry.show_all (); |
2798 | + |
2799 | + } |
2800 | + |
2801 | + public void show_filtered_apps (string category) { |
2802 | + |
2803 | + switcher.clear_children (); |
2804 | + app_view.clear (); |
2805 | + |
2806 | + layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2); |
2807 | + foreach (Backend.App app in view.apps[category]) |
2808 | + add_app (app); |
2809 | + |
2810 | + switcher.set_active (0); |
2811 | + |
2812 | + layout.move (app_view, 0, 0); |
2813 | + current_position = 0; |
2814 | + |
2815 | + } |
2816 | + |
2817 | + public void move_page (int step) { |
2818 | + |
2819 | + debug ("Moving: step = " + step.to_string ()); |
2820 | + |
2821 | + if (step == 0) |
2822 | + return; |
2823 | + if (step < 0 && current_position >= 0) //Left border |
2824 | + return; |
2825 | + if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border |
2826 | + return; |
2827 | + |
2828 | + int count = 0; |
2829 | + int increment = -step*130*(view.columns-1)/10; |
2830 | + Timeout.add (30/(view.columns-1), () => { |
2831 | + |
2832 | + if (count >= 10) { |
2833 | + current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page |
2834 | + layout.move (app_view, current_position, 0); |
2835 | return false; |
2836 | - }); |
2837 | - |
2838 | - app_view.new_page.connect ((page) => { |
2839 | - |
2840 | - if (switcher.size == 0) |
2841 | - switcher.append ("1"); |
2842 | - switcher.append (page); |
2843 | - |
2844 | - /* Prevents pages from changing */ |
2845 | - from_category = true; |
2846 | - }); |
2847 | - |
2848 | - switcher.active_changed.connect (() => { |
2849 | - if (from_category || switcher.active - switcher.old_active == 0) { |
2850 | - from_category = false; |
2851 | - return; |
2852 | - } |
2853 | - |
2854 | - move_page (switcher.active - switcher.old_active); |
2855 | - view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page |
2856 | - }); |
2857 | - |
2858 | - category_switcher.selected = 0; //Must be after everything else |
2859 | - } |
2860 | - |
2861 | - private void add_app (App app) { |
2862 | - |
2863 | - var app_entry = new AppEntry (app); |
2864 | - app_entry.app_launched.connect (() => view.hide ()); |
2865 | - app_view.append (app_entry); |
2866 | - app_entry.show_all (); |
2867 | - |
2868 | - } |
2869 | - |
2870 | - public void show_filtered_apps (string category) { |
2871 | - |
2872 | - switcher.clear_children (); |
2873 | - app_view.clear (); |
2874 | - |
2875 | - layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2); |
2876 | - foreach (App app in view.apps[category]) |
2877 | - add_app (app); |
2878 | - |
2879 | - switcher.set_active (0); |
2880 | - |
2881 | - layout.move (app_view, 0, 0); |
2882 | - current_position = 0; |
2883 | - |
2884 | - } |
2885 | - |
2886 | - public void move_page (int step) { |
2887 | - |
2888 | - debug ("Moving: step = " + step.to_string ()); |
2889 | - |
2890 | - if (step == 0) |
2891 | - return; |
2892 | - if (step < 0 && current_position >= 0) //Left border |
2893 | - return; |
2894 | - if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border |
2895 | - return; |
2896 | - |
2897 | - int count = 0; |
2898 | - int increment = -step*130*(view.columns-1)/10; |
2899 | - Timeout.add (30/(view.columns-1), () => { |
2900 | - |
2901 | - if (count >= 10) { |
2902 | - current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page |
2903 | - layout.move (app_view, current_position, 0); |
2904 | - return false; |
2905 | - } |
2906 | - |
2907 | - current_position += increment; |
2908 | - layout.move (app_view, current_position, 0); |
2909 | - count++; |
2910 | - return true; |
2911 | - |
2912 | - }, Priority.DEFAULT_IDLE); |
2913 | - } |
2914 | - |
2915 | - public void show_page_switcher (bool show) { |
2916 | - |
2917 | - if (page_switcher.get_parent () == null) |
2918 | - container.attach (page_switcher, 2, 1, 1, 1); |
2919 | - |
2920 | - if (show) { |
2921 | - page_switcher.show_all (); |
2922 | - view.bottom.hide (); |
2923 | } |
2924 | - else |
2925 | - page_switcher.hide (); |
2926 | - |
2927 | - view.searchbar.grab_focus (); |
2928 | - |
2929 | + |
2930 | + current_position += increment; |
2931 | + layout.move (app_view, current_position, 0); |
2932 | + count++; |
2933 | + return true; |
2934 | + |
2935 | + }, Priority.DEFAULT_IDLE); |
2936 | + } |
2937 | + |
2938 | + public void show_page_switcher (bool show) { |
2939 | + |
2940 | + if (page_switcher.get_parent () == null) |
2941 | + container.attach (page_switcher, 2, 1, 1, 1); |
2942 | + |
2943 | + if (show) { |
2944 | + page_switcher.show_all (); |
2945 | + view.bottom.hide (); |
2946 | } |
2947 | + else |
2948 | + page_switcher.hide (); |
2949 | + |
2950 | + view.searchbar.grab_focus (); |
2951 | |
2952 | } |
2953 | |
2954 | |
2955 | === modified file 'src/Widgets/Grid.vala' |
2956 | --- src/Widgets/Grid.vala 2012-08-21 17:02:33 +0000 |
2957 | +++ src/Widgets/Grid.vala 2013-12-26 00:13:32 +0000 |
2958 | @@ -16,8 +16,6 @@ |
2959 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2960 | // |
2961 | |
2962 | -using Gtk; |
2963 | - |
2964 | namespace Slingshot.Widgets { |
2965 | |
2966 | struct Page { |
2967 | @@ -49,7 +47,7 @@ |
2968 | |
2969 | } |
2970 | |
2971 | - public void append (Widget widget) { |
2972 | + public void append (Gtk.Widget widget) { |
2973 | |
2974 | update_position (); |
2975 | |
2976 | @@ -76,7 +74,7 @@ |
2977 | |
2978 | public void clear () { |
2979 | |
2980 | - foreach (Widget widget in get_children ()) { |
2981 | + foreach (Gtk.Widget widget in get_children ()) { |
2982 | if (widget.get_parent () != null) |
2983 | remove (widget); |
2984 | widget.destroy (); |
2985 | @@ -108,7 +106,7 @@ |
2986 | |
2987 | public void fade_all_out () { |
2988 | |
2989 | - foreach (Widget widget in get_children ()) { |
2990 | + foreach (Gtk.Widget widget in get_children ()) { |
2991 | ((AppEntry) widget).fade_out (); |
2992 | } |
2993 | |
2994 | @@ -116,7 +114,7 @@ |
2995 | |
2996 | public void fade_all_in () { |
2997 | |
2998 | - foreach (Widget widget in get_children ()) { |
2999 | + foreach (Gtk.Widget widget in get_children ()) { |
3000 | ((AppEntry) widget).fade_in (); |
3001 | } |
3002 | |
3003 | @@ -133,4 +131,4 @@ |
3004 | |
3005 | } |
3006 | |
3007 | -} |
3008 | +} |
3009 | \ No newline at end of file |
3010 | |
3011 | === modified file 'src/Widgets/SearchItem.vala' |
3012 | --- src/Widgets/SearchItem.vala 2013-08-21 07:34:53 +0000 |
3013 | +++ src/Widgets/SearchItem.vala 2013-12-26 00:13:32 +0000 |
3014 | @@ -16,18 +16,15 @@ |
3015 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3016 | // |
3017 | |
3018 | -using Gtk; |
3019 | -using Gdk; |
3020 | - |
3021 | namespace Slingshot.Widgets { |
3022 | |
3023 | - public class SearchItem : Button { |
3024 | + public class SearchItem : Gtk.Button { |
3025 | |
3026 | private Backend.App app; |
3027 | - private Pixbuf icon; |
3028 | + private Gdk.Pixbuf icon; |
3029 | private string icon_name; |
3030 | - private Label name_label; |
3031 | - private Label desc_label; |
3032 | + private Gtk.Label name_label; |
3033 | + private Gtk.Label desc_label; |
3034 | |
3035 | public bool in_box = false; |
3036 | public int icon_size = 64; |
3037 | @@ -40,16 +37,16 @@ |
3038 | icon = app.icon; |
3039 | icon_name = app.icon_name; |
3040 | |
3041 | - name_label = new Label ("<b><span size=\"larger\">" + fix (app.name) + "</span></b>"); |
3042 | + name_label = new Gtk.Label ("<b><span size=\"larger\">" + fix (app.name) + "</span></b>"); |
3043 | name_label.set_ellipsize (Pango.EllipsizeMode.END); |
3044 | name_label.use_markup = true; |
3045 | name_label.xalign = 0.0f; |
3046 | |
3047 | - desc_label = new Label (fix (app.description)); |
3048 | + desc_label = new Gtk.Label (fix (app.description)); |
3049 | desc_label.set_ellipsize (Pango.EllipsizeMode.END); |
3050 | desc_label.xalign = 0.0f; |
3051 | |
3052 | - var vbox = new Box (Orientation.VERTICAL, 0); |
3053 | + var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
3054 | vbox.homogeneous = false; |
3055 | vbox.pack_start (name_label, false, true, 0); |
3056 | vbox.pack_start (desc_label, false, true, 0); |
3057 | @@ -60,17 +57,17 @@ |
3058 | } |
3059 | |
3060 | protected override bool draw (Cairo.Context cr) { |
3061 | - Allocation size; |
3062 | + Gtk.Allocation size; |
3063 | get_allocation (out size); |
3064 | |
3065 | base.draw (cr); |
3066 | |
3067 | - Pixbuf scaled_icon = app.load_icon (icon_size); |
3068 | + Gdk.Pixbuf scaled_icon = app.load_icon (icon_size); |
3069 | |
3070 | height_request = icon_size + 10; |
3071 | |
3072 | // Draw icon |
3073 | - cairo_set_source_pixbuf (cr, scaled_icon, 74 - icon_size, 5); |
3074 | + Gdk.cairo_set_source_pixbuf (cr, scaled_icon, 74 - icon_size, 5); |
3075 | cr.paint (); |
3076 | |
3077 | return true; |
3078 | @@ -81,4 +78,4 @@ |
3079 | } |
3080 | } |
3081 | |
3082 | -} |
3083 | +} |
3084 | \ No newline at end of file |
3085 | |
3086 | === modified file 'src/Widgets/SearchView.vala' |
3087 | --- src/Widgets/SearchView.vala 2012-09-09 18:14:52 +0000 |
3088 | +++ src/Widgets/SearchView.vala 2013-12-26 00:13:32 +0000 |
3089 | @@ -16,20 +16,20 @@ |
3090 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3091 | // |
3092 | |
3093 | -using Gtk; |
3094 | -using Slingshot.Backend; |
3095 | - |
3096 | namespace Slingshot.Widgets { |
3097 | |
3098 | - private class SeparatorItem : HSeparator { |
3099 | + private class SeparatorItem : Gtk.Separator { |
3100 | + public SeparatorItem () { |
3101 | + orientation = Gtk.Orientation.HORIZONTAL; |
3102 | + } |
3103 | |
3104 | public bool in_box; |
3105 | |
3106 | } |
3107 | |
3108 | - public class SearchView : VBox { |
3109 | + public class SearchView : Gtk.Box { |
3110 | |
3111 | - private Gee.HashMap<App, SearchItem> items; |
3112 | + private Gee.HashMap<Backend.App, SearchItem> items; |
3113 | private SeparatorItem separator; |
3114 | private SearchItem selected_app = null; |
3115 | |
3116 | @@ -63,6 +63,7 @@ |
3117 | private SlingshotView view; |
3118 | |
3119 | public SearchView (SlingshotView parent) { |
3120 | + orientation = Gtk.Orientation.VERTICAL; |
3121 | |
3122 | can_focus = true; |
3123 | homogeneous = false; |
3124 | @@ -70,14 +71,14 @@ |
3125 | this.view = parent; |
3126 | width_request = view.columns * 130; |
3127 | |
3128 | - items = new Gee.HashMap<App, SearchItem> (); |
3129 | + items = new Gee.HashMap<Backend.App, SearchItem> (); |
3130 | separator = new SeparatorItem (); |
3131 | |
3132 | } |
3133 | |
3134 | - public void add_apps (Gee.ArrayList<App> apps) { |
3135 | + public void add_apps (Gee.ArrayList<Backend.App> apps) { |
3136 | |
3137 | - foreach (App app in apps) { |
3138 | + foreach (Backend.App app in apps) { |
3139 | var search_item = new SearchItem (app); |
3140 | |
3141 | append_app (app, search_item); |
3142 | @@ -86,7 +87,7 @@ |
3143 | |
3144 | } |
3145 | |
3146 | - public void append_app (App app, SearchItem search_item) { |
3147 | + public void append_app (Backend.App app, SearchItem search_item) { |
3148 | |
3149 | search_item.button_release_event.connect (() => { |
3150 | app.launch (); |
3151 | @@ -98,7 +99,7 @@ |
3152 | |
3153 | } |
3154 | |
3155 | - public void show_app (App app) { |
3156 | + public void show_app (Backend.App app) { |
3157 | |
3158 | if (!(app in items.keys)) { |
3159 | var search_item = new SearchItem (app); |
3160 | @@ -128,7 +129,7 @@ |
3161 | |
3162 | } |
3163 | |
3164 | - public void hide_app (App app) { |
3165 | + public void hide_app (Backend.App app) { |
3166 | |
3167 | items[app].hide (); |
3168 | apps_showed--; |
3169 | @@ -151,7 +152,7 @@ |
3170 | |
3171 | public void add_command (string command) { |
3172 | |
3173 | - var app = new App.from_command (command); |
3174 | + var app = new Backend.App.from_command (command); |
3175 | var item = new SearchItem (app); |
3176 | |
3177 | append_app (app, item); |
3178 | @@ -182,10 +183,10 @@ |
3179 | private void select_nth (int index) { |
3180 | |
3181 | if (selected_app != null) |
3182 | - selected_app.unset_state_flags (StateFlags.PRELIGHT); |
3183 | + selected_app.unset_state_flags (Gtk.StateFlags.PRELIGHT); |
3184 | |
3185 | selected_app = (SearchItem) get_children ().nth_data (index); |
3186 | - selected_app.set_state_flags (StateFlags.PRELIGHT, false); |
3187 | + selected_app.set_state_flags (Gtk.StateFlags.PRELIGHT, false); |
3188 | |
3189 | } |
3190 | |
3191 | @@ -197,4 +198,4 @@ |
3192 | |
3193 | } |
3194 | |
3195 | -} |
3196 | +} |
3197 | \ No newline at end of file |
3198 | |
3199 | === modified file 'src/Widgets/Sidebar.vala' |
3200 | --- src/Widgets/Sidebar.vala 2012-09-15 15:14:52 +0000 |
3201 | +++ src/Widgets/Sidebar.vala 2013-12-26 00:13:32 +0000 |
3202 | @@ -16,124 +16,118 @@ |
3203 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3204 | // |
3205 | |
3206 | -using Gtk; |
3207 | - |
3208 | -namespace Slingshot.Widgets { |
3209 | - |
3210 | - public class Sidebar : TreeView { |
3211 | - |
3212 | - private TreeStore store; |
3213 | - |
3214 | - private TreeIter entry_iter; |
3215 | - |
3216 | - public int cat_size { |
3217 | - get { |
3218 | - return store.iter_n_children (null); |
3219 | - } |
3220 | - } |
3221 | - |
3222 | - private int _selected; |
3223 | - public int selected { |
3224 | - get { |
3225 | - return _selected; |
3226 | - } |
3227 | - set { |
3228 | - if (value >= 0 && value < cat_size) { |
3229 | - select_nth (value); |
3230 | - _selected = value; |
3231 | - } |
3232 | - } |
3233 | - } |
3234 | - |
3235 | - private enum Columns { |
3236 | - INT, |
3237 | - TEXT, |
3238 | - N_COLUMNS |
3239 | - } |
3240 | - |
3241 | - public signal void selection_changed (string entry_name, int nth); |
3242 | - |
3243 | - public Sidebar () { |
3244 | - |
3245 | - store = new TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string)); |
3246 | - store.set_sort_column_id (1, Gtk.SortType.ASCENDING); |
3247 | - set_model (store); |
3248 | - |
3249 | - set_headers_visible (false); |
3250 | - set_show_expanders (false); |
3251 | - set_level_indentation (8); |
3252 | - |
3253 | - set_size_request (145, -1); |
3254 | - get_style_context ().add_class ("sidebar"); |
3255 | - |
3256 | - var cell = new CellRendererText (); |
3257 | - cell.wrap_mode = Pango.WrapMode.WORD; |
3258 | - cell.wrap_width = 110; |
3259 | - cell.xpad = 17; |
3260 | - |
3261 | - insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT); |
3262 | - |
3263 | - get_selection ().set_mode (SelectionMode.SINGLE); |
3264 | - get_selection ().changed.connect (selection_change); |
3265 | - |
3266 | - } |
3267 | - |
3268 | - public void add_category (string entry_name) { |
3269 | - |
3270 | - store.append (out entry_iter, null); |
3271 | - store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1); |
3272 | - |
3273 | - expand_all (); |
3274 | - |
3275 | - } |
3276 | - |
3277 | - public void selection_change () { |
3278 | - |
3279 | - TreeModel model; |
3280 | - TreeIter sel_iter; |
3281 | - string name; |
3282 | - int nth; |
3283 | - |
3284 | - if (get_selection ().get_selected (out model, out sel_iter)) { |
3285 | - store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name); |
3286 | - _selected = nth; |
3287 | - selection_changed (name, nth); |
3288 | - } |
3289 | - |
3290 | - } |
3291 | - |
3292 | - public bool select_nth (int nth) { |
3293 | - |
3294 | - TreeIter iter; |
3295 | - |
3296 | - if (nth < cat_size) |
3297 | - store.iter_nth_child (out iter, null, nth); |
3298 | - else |
3299 | - return false; |
3300 | - |
3301 | - get_selection ().select_iter (iter); |
3302 | - return true; |
3303 | - |
3304 | - } |
3305 | - |
3306 | - protected override bool scroll_event (Gdk.EventScroll event) { |
3307 | - |
3308 | - switch (event.direction.to_string ()) { |
3309 | - case "GDK_SCROLL_UP": |
3310 | - case "GDK_SCROLL_LEFT": |
3311 | - selected--; |
3312 | - break; |
3313 | - case "GDK_SCROLL_DOWN": |
3314 | - case "GDK_SCROLL_RIGHT": |
3315 | - selected++; |
3316 | - break; |
3317 | - |
3318 | - } |
3319 | - |
3320 | +public class Slingshot.Widgets.Sidebar : Gtk.TreeView { |
3321 | + |
3322 | + private Gtk.TreeStore store; |
3323 | + |
3324 | + private Gtk.TreeIter entry_iter; |
3325 | + |
3326 | + public int cat_size { |
3327 | + get { |
3328 | + return store.iter_n_children (null); |
3329 | + } |
3330 | + } |
3331 | + |
3332 | + private int _selected; |
3333 | + public int selected { |
3334 | + get { |
3335 | + return _selected; |
3336 | + } |
3337 | + set { |
3338 | + if (value >= 0 && value < cat_size) { |
3339 | + select_nth (value); |
3340 | + _selected = value; |
3341 | + } |
3342 | + } |
3343 | + } |
3344 | + |
3345 | + private enum Columns { |
3346 | + INT, |
3347 | + TEXT, |
3348 | + N_COLUMNS |
3349 | + } |
3350 | + |
3351 | + public signal void selection_changed (string entry_name, int nth); |
3352 | + |
3353 | + public Sidebar () { |
3354 | + |
3355 | + store = new Gtk.TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string)); |
3356 | + store.set_sort_column_id (1, Gtk.SortType.ASCENDING); |
3357 | + set_model (store); |
3358 | + |
3359 | + set_headers_visible (false); |
3360 | + set_show_expanders (false); |
3361 | + set_level_indentation (8); |
3362 | + |
3363 | + set_size_request (145, -1); |
3364 | + get_style_context ().add_class ("sidebar"); |
3365 | + |
3366 | + var cell = new Gtk.CellRendererText (); |
3367 | + cell.wrap_mode = Pango.WrapMode.WORD; |
3368 | + cell.wrap_width = 110; |
3369 | + cell.xpad = 17; |
3370 | + |
3371 | + insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT); |
3372 | + |
3373 | + get_selection ().set_mode (Gtk.SelectionMode.SINGLE); |
3374 | + get_selection ().changed.connect (selection_change); |
3375 | + |
3376 | + } |
3377 | + |
3378 | + public void add_category (string entry_name) { |
3379 | + |
3380 | + store.append (out entry_iter, null); |
3381 | + store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1); |
3382 | + |
3383 | + expand_all (); |
3384 | + |
3385 | + } |
3386 | + |
3387 | + public void selection_change () { |
3388 | + |
3389 | + Gtk.TreeModel model; |
3390 | + Gtk.TreeIter sel_iter; |
3391 | + string name; |
3392 | + int nth; |
3393 | + |
3394 | + if (get_selection ().get_selected (out model, out sel_iter)) { |
3395 | + store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name); |
3396 | + _selected = nth; |
3397 | + selection_changed (name, nth); |
3398 | + } |
3399 | + |
3400 | + } |
3401 | + |
3402 | + public bool select_nth (int nth) { |
3403 | + |
3404 | + Gtk.TreeIter iter; |
3405 | + |
3406 | + if (nth < cat_size) |
3407 | + store.iter_nth_child (out iter, null, nth); |
3408 | + else |
3409 | return false; |
3410 | |
3411 | + get_selection ().select_iter (iter); |
3412 | + return true; |
3413 | + |
3414 | + } |
3415 | + |
3416 | + protected override bool scroll_event (Gdk.EventScroll event) { |
3417 | + |
3418 | + switch (event.direction.to_string ()) { |
3419 | + case "GDK_SCROLL_UP": |
3420 | + case "GDK_SCROLL_LEFT": |
3421 | + selected--; |
3422 | + break; |
3423 | + case "GDK_SCROLL_DOWN": |
3424 | + case "GDK_SCROLL_RIGHT": |
3425 | + selected++; |
3426 | + break; |
3427 | + |
3428 | } |
3429 | |
3430 | + return false; |
3431 | + |
3432 | } |
3433 | |
3434 | } |