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 | 6 | ||
6 | 7 | project (slingshot) | 7 | project (slingshot) |
7 | 8 | 8 | ||
8 | 9 | set (APPNAME "${CMAKE_PROJECT_NAME}-launcher") | ||
9 | 9 | set (DATADIR "${CMAKE_INSTALL_PREFIX}/share") | 10 | set (DATADIR "${CMAKE_INSTALL_PREFIX}/share") |
12 | 10 | set (PKGDATADIR "${DATADIR}/slingshot") | 11 | set (PKGDATADIR "${DATADIR}/${CMAKE_PROJECT_NAME}") |
13 | 11 | set (GETTEXT_PACKAGE "slingshot") | 12 | set (GETTEXT_PACKAGE "${CMAKE_PROJECT_NAME}") |
14 | 12 | set (RELEASE_NAME "Donatello") | 13 | set (RELEASE_NAME "Donatello") |
15 | 13 | set (VERSION "0.7.6.1") | 14 | set (VERSION "0.7.6.1") |
16 | 14 | set (VERSION_INFO "Release") | 15 | set (VERSION_INFO "Release") |
17 | @@ -34,7 +35,7 @@ | |||
18 | 34 | # Slingshot | 35 | # Slingshot |
19 | 35 | 36 | ||
20 | 36 | 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;") | 37 | 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;") |
22 | 37 | set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-1.0;") | 38 | set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-2.0;") |
23 | 38 | 39 | ||
24 | 39 | find_package (PkgConfig) | 40 | find_package (PkgConfig) |
25 | 40 | pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0) | 41 | pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0) |
26 | @@ -44,7 +45,7 @@ | |||
27 | 44 | ensure_vala_version ("0.15.1" MINIMUM) | 45 | ensure_vala_version ("0.15.1" MINIMUM) |
28 | 45 | 46 | ||
29 | 46 | include (ValaPrecompile) | 47 | include (ValaPrecompile) |
31 | 47 | vala_precompile (VALA_C | 48 | vala_precompile (VALA_C ${APPNAME} |
32 | 48 | src/Slingshot.vala | 49 | src/Slingshot.vala |
33 | 49 | src/SlingshotView.vala | 50 | src/SlingshotView.vala |
34 | 50 | src/Settings.vala | 51 | src/Settings.vala |
35 | @@ -66,7 +67,7 @@ | |||
36 | 66 | CUSTOM_VAPIS | 67 | CUSTOM_VAPIS |
37 | 67 | vapi/config.vapi | 68 | vapi/config.vapi |
38 | 68 | OPTIONS | 69 | OPTIONS |
40 | 69 | --thread | 70 | --thread |
41 | 70 | -g | 71 | -g |
42 | 71 | ) | 72 | ) |
43 | 72 | 73 | ||
44 | @@ -77,11 +78,11 @@ | |||
45 | 77 | link_libraries (${DEPS_LIBRARIES}) | 78 | link_libraries (${DEPS_LIBRARIES}) |
46 | 78 | link_directories (${DEPS_LIBRARY_DIRS}) | 79 | link_directories (${DEPS_LIBRARY_DIRS}) |
47 | 79 | 80 | ||
50 | 80 | add_executable (slingshot-launcher ${VALA_C}) | 81 | add_executable (${APPNAME} ${VALA_C}) |
51 | 81 | target_link_libraries(slingshot-launcher m) | 82 | target_link_libraries(${APPNAME} m) |
52 | 82 | 83 | ||
53 | 83 | # Installation | 84 | # Installation |
55 | 84 | install (TARGETS slingshot-launcher RUNTIME DESTINATION bin) | 85 | install (TARGETS ${APPNAME} RUNTIME DESTINATION bin) |
56 | 85 | install (FILES ${applications_menu} DESTINATION /etc/xdg/menus) | 86 | install (FILES ${applications_menu} DESTINATION /etc/xdg/menus) |
57 | 86 | 87 | ||
58 | 87 | # | 88 | # |
59 | @@ -91,4 +92,4 @@ | |||
60 | 91 | add_schema ("org.pantheon.desktop.slingshot.gschema.xml") | 92 | add_schema ("org.pantheon.desktop.slingshot.gschema.xml") |
61 | 92 | 93 | ||
62 | 93 | # Translations | 94 | # Translations |
64 | 94 | add_subdirectory (po) | 95 | add_subdirectory (po) |
65 | 95 | \ No newline at end of file | 96 | \ No newline at end of file |
66 | 96 | 97 | ||
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 | 1 | ## | ||
72 | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | ||
73 | 3 | # | ||
74 | 4 | # Redistribution and use in source and binary forms, with or without | ||
75 | 5 | # modification, are permitted provided that the following conditions are met: | ||
76 | 6 | # | ||
77 | 7 | # 1. Redistributions of source code must retain the above copyright notice, | ||
78 | 8 | # this list of conditions and the following disclaimer. | ||
79 | 9 | # | ||
80 | 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
81 | 11 | # this list of conditions and the following disclaimer in the documentation | ||
82 | 12 | # and/or other materials provided with the distribution. | ||
83 | 13 | # | ||
84 | 14 | # THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR | ||
85 | 15 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
86 | 16 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
87 | 17 | # EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
88 | 18 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
89 | 19 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
90 | 20 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
91 | 21 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
92 | 22 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
93 | 23 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
94 | 24 | # | ||
95 | 25 | # The views and conclusions contained in the software and documentation are those | ||
96 | 26 | # of the authors and should not be interpreted as representing official policies, | ||
97 | 27 | # either expressed or implied, of Jakob Westhoff | ||
98 | 28 | ## | ||
99 | 29 | |||
100 | 30 | ## | ||
101 | 31 | # Find module for the Gir compiler (g-ir-compiler) | ||
102 | 32 | # | ||
103 | 33 | # This module determines wheter a Gir compiler is installed on the current | ||
104 | 34 | # system and where its executable is. | ||
105 | 35 | # | ||
106 | 36 | # Call the module using "find_package(GirCompiler) from within your CMakeLists.txt. | ||
107 | 37 | # | ||
108 | 38 | # The following variables will be set after an invocation: | ||
109 | 39 | # | ||
110 | 40 | # G_IR_COMPILER_FOUND Whether the g-ir-compiler compiler has been found or not | ||
111 | 41 | # G_IR_COMPILER_EXECUTABLE Full path to the g-ir-compiler executable if it has been found | ||
112 | 42 | ## | ||
113 | 43 | |||
114 | 44 | |||
115 | 45 | # Search for the g-ir-compiler executable in the usual system paths. | ||
116 | 46 | find_program (G_IR_COMPILER_EXECUTABLE | ||
117 | 47 | NAMES g-ir-compiler) | ||
118 | 48 | |||
119 | 49 | # Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. | ||
120 | 50 | # Furthermore set G_IR_COMPILER_FOUND to TRUE if the g-ir-compiler has been found (aka. | ||
121 | 51 | # G_IR_COMPILER_EXECUTABLE is set) | ||
122 | 52 | |||
123 | 53 | include (FindPackageHandleStandardArgs) | ||
124 | 54 | find_package_handle_standard_args (GirCompiler DEFAULT_MSG G_IR_COMPILER_EXECUTABLE) | ||
125 | 55 | |||
126 | 56 | mark_as_advanced (G_IR_COMPILER_EXECUTABLE) | ||
127 | 0 | 57 | ||
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 | 1 | # CMAKE generated file: DO NOT EDIT! | ||
133 | 2 | # Generated by "Unix Makefiles" Generator, CMake Version 2.8 | ||
134 | 3 | |||
135 | 4 | # Default target executed when no arguments are given to make. | ||
136 | 5 | default_target: all | ||
137 | 6 | .PHONY : default_target | ||
138 | 7 | |||
139 | 8 | #============================================================================= | ||
140 | 9 | # Special targets provided by cmake. | ||
141 | 10 | |||
142 | 11 | # Disable implicit rules so canoncical targets will work. | ||
143 | 12 | .SUFFIXES: | ||
144 | 13 | |||
145 | 14 | # Remove some rules from gmake that .SUFFIXES does not remove. | ||
146 | 15 | SUFFIXES = | ||
147 | 16 | |||
148 | 17 | .SUFFIXES: .hpux_make_needs_suffix_list | ||
149 | 18 | |||
150 | 19 | # Suppress display of executed commands. | ||
151 | 20 | $(VERBOSE).SILENT: | ||
152 | 21 | |||
153 | 22 | # A target that is always out of date. | ||
154 | 23 | cmake_force: | ||
155 | 24 | .PHONY : cmake_force | ||
156 | 25 | |||
157 | 26 | #============================================================================= | ||
158 | 27 | # Set environment variables for the build. | ||
159 | 28 | |||
160 | 29 | # The shell in which to execute make rules. | ||
161 | 30 | SHELL = /bin/sh | ||
162 | 31 | |||
163 | 32 | # The CMake executable. | ||
164 | 33 | CMAKE_COMMAND = /usr/bin/cmake | ||
165 | 34 | |||
166 | 35 | # The command to remove a file. | ||
167 | 36 | RM = /usr/bin/cmake -E remove -f | ||
168 | 37 | |||
169 | 38 | # The top-level source directory on which CMake was run. | ||
170 | 39 | CMAKE_SOURCE_DIR = /home/mefrio/Scrivania/cmake | ||
171 | 40 | |||
172 | 41 | # The top-level build directory on which CMake was run. | ||
173 | 42 | CMAKE_BINARY_DIR = /home/mefrio/Scrivania/cmake/cmake | ||
174 | 43 | |||
175 | 44 | #============================================================================= | ||
176 | 45 | # Targets provided globally by CMake. | ||
177 | 46 | |||
178 | 47 | # Special rule for the target edit_cache | ||
179 | 48 | edit_cache: | ||
180 | 49 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." | ||
181 | 50 | /usr/bin/cmake -i . | ||
182 | 51 | .PHONY : edit_cache | ||
183 | 52 | |||
184 | 53 | # Special rule for the target edit_cache | ||
185 | 54 | edit_cache/fast: edit_cache | ||
186 | 55 | .PHONY : edit_cache/fast | ||
187 | 56 | |||
188 | 57 | # Special rule for the target install | ||
189 | 58 | install: preinstall | ||
190 | 59 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
191 | 60 | /usr/bin/cmake -P cmake_install.cmake | ||
192 | 61 | .PHONY : install | ||
193 | 62 | |||
194 | 63 | # Special rule for the target install | ||
195 | 64 | install/fast: preinstall/fast | ||
196 | 65 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
197 | 66 | /usr/bin/cmake -P cmake_install.cmake | ||
198 | 67 | .PHONY : install/fast | ||
199 | 68 | |||
200 | 69 | # Special rule for the target install/local | ||
201 | 70 | install/local: preinstall | ||
202 | 71 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." | ||
203 | 72 | /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake | ||
204 | 73 | .PHONY : install/local | ||
205 | 74 | |||
206 | 75 | # Special rule for the target install/local | ||
207 | 76 | install/local/fast: install/local | ||
208 | 77 | .PHONY : install/local/fast | ||
209 | 78 | |||
210 | 79 | # Special rule for the target install/strip | ||
211 | 80 | install/strip: preinstall | ||
212 | 81 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." | ||
213 | 82 | /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake | ||
214 | 83 | .PHONY : install/strip | ||
215 | 84 | |||
216 | 85 | # Special rule for the target install/strip | ||
217 | 86 | install/strip/fast: install/strip | ||
218 | 87 | .PHONY : install/strip/fast | ||
219 | 88 | |||
220 | 89 | # Special rule for the target list_install_components | ||
221 | 90 | list_install_components: | ||
222 | 91 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" | ||
223 | 92 | .PHONY : list_install_components | ||
224 | 93 | |||
225 | 94 | # Special rule for the target list_install_components | ||
226 | 95 | list_install_components/fast: list_install_components | ||
227 | 96 | .PHONY : list_install_components/fast | ||
228 | 97 | |||
229 | 98 | # Special rule for the target rebuild_cache | ||
230 | 99 | rebuild_cache: | ||
231 | 100 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." | ||
232 | 101 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
233 | 102 | .PHONY : rebuild_cache | ||
234 | 103 | |||
235 | 104 | # Special rule for the target rebuild_cache | ||
236 | 105 | rebuild_cache/fast: rebuild_cache | ||
237 | 106 | .PHONY : rebuild_cache/fast | ||
238 | 107 | |||
239 | 108 | # The main all target | ||
240 | 109 | all: cmake_check_build_system | ||
241 | 110 | $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles /home/mefrio/Scrivania/cmake/cmake/CMakeFiles/progress.marks | ||
242 | 111 | $(MAKE) -f CMakeFiles/Makefile2 all | ||
243 | 112 | $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles 0 | ||
244 | 113 | .PHONY : all | ||
245 | 114 | |||
246 | 115 | # The main clean target | ||
247 | 116 | clean: | ||
248 | 117 | $(MAKE) -f CMakeFiles/Makefile2 clean | ||
249 | 118 | .PHONY : clean | ||
250 | 119 | |||
251 | 120 | # The main clean target | ||
252 | 121 | clean/fast: clean | ||
253 | 122 | .PHONY : clean/fast | ||
254 | 123 | |||
255 | 124 | # Prepare targets for installation. | ||
256 | 125 | preinstall: all | ||
257 | 126 | $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
258 | 127 | .PHONY : preinstall | ||
259 | 128 | |||
260 | 129 | # Prepare targets for installation. | ||
261 | 130 | preinstall/fast: | ||
262 | 131 | $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
263 | 132 | .PHONY : preinstall/fast | ||
264 | 133 | |||
265 | 134 | # clear depends | ||
266 | 135 | depend: | ||
267 | 136 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | ||
268 | 137 | .PHONY : depend | ||
269 | 138 | |||
270 | 139 | #============================================================================= | ||
271 | 140 | # Target rules for targets named scratch | ||
272 | 141 | |||
273 | 142 | # Build rule for target. | ||
274 | 143 | scratch: cmake_check_build_system | ||
275 | 144 | $(MAKE) -f CMakeFiles/Makefile2 scratch | ||
276 | 145 | .PHONY : scratch | ||
277 | 146 | |||
278 | 147 | # fast build rule for target. | ||
279 | 148 | scratch/fast: | ||
280 | 149 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/build | ||
281 | 150 | .PHONY : scratch/fast | ||
282 | 151 | |||
283 | 152 | src/entry.o: src/entry.c.o | ||
284 | 153 | .PHONY : src/entry.o | ||
285 | 154 | |||
286 | 155 | # target to build an object file | ||
287 | 156 | src/entry.c.o: | ||
288 | 157 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.o | ||
289 | 158 | .PHONY : src/entry.c.o | ||
290 | 159 | |||
291 | 160 | src/entry.i: src/entry.c.i | ||
292 | 161 | .PHONY : src/entry.i | ||
293 | 162 | |||
294 | 163 | # target to preprocess a source file | ||
295 | 164 | src/entry.c.i: | ||
296 | 165 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.i | ||
297 | 166 | .PHONY : src/entry.c.i | ||
298 | 167 | |||
299 | 168 | src/entry.s: src/entry.c.s | ||
300 | 169 | .PHONY : src/entry.s | ||
301 | 170 | |||
302 | 171 | # target to generate assembly for a file | ||
303 | 172 | src/entry.c.s: | ||
304 | 173 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.s | ||
305 | 174 | .PHONY : src/entry.c.s | ||
306 | 175 | |||
307 | 176 | src/main_window.o: src/main_window.c.o | ||
308 | 177 | .PHONY : src/main_window.o | ||
309 | 178 | |||
310 | 179 | # target to build an object file | ||
311 | 180 | src/main_window.c.o: | ||
312 | 181 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.o | ||
313 | 182 | .PHONY : src/main_window.c.o | ||
314 | 183 | |||
315 | 184 | src/main_window.i: src/main_window.c.i | ||
316 | 185 | .PHONY : src/main_window.i | ||
317 | 186 | |||
318 | 187 | # target to preprocess a source file | ||
319 | 188 | src/main_window.c.i: | ||
320 | 189 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.i | ||
321 | 190 | .PHONY : src/main_window.c.i | ||
322 | 191 | |||
323 | 192 | src/main_window.s: src/main_window.c.s | ||
324 | 193 | .PHONY : src/main_window.s | ||
325 | 194 | |||
326 | 195 | # target to generate assembly for a file | ||
327 | 196 | src/main_window.c.s: | ||
328 | 197 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.s | ||
329 | 198 | .PHONY : src/main_window.c.s | ||
330 | 199 | |||
331 | 200 | src/menu.o: src/menu.c.o | ||
332 | 201 | .PHONY : src/menu.o | ||
333 | 202 | |||
334 | 203 | # target to build an object file | ||
335 | 204 | src/menu.c.o: | ||
336 | 205 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.o | ||
337 | 206 | .PHONY : src/menu.c.o | ||
338 | 207 | |||
339 | 208 | src/menu.i: src/menu.c.i | ||
340 | 209 | .PHONY : src/menu.i | ||
341 | 210 | |||
342 | 211 | # target to preprocess a source file | ||
343 | 212 | src/menu.c.i: | ||
344 | 213 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.i | ||
345 | 214 | .PHONY : src/menu.c.i | ||
346 | 215 | |||
347 | 216 | src/menu.s: src/menu.c.s | ||
348 | 217 | .PHONY : src/menu.s | ||
349 | 218 | |||
350 | 219 | # target to generate assembly for a file | ||
351 | 220 | src/menu.c.s: | ||
352 | 221 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.s | ||
353 | 222 | .PHONY : src/menu.c.s | ||
354 | 223 | |||
355 | 224 | src/notebook.o: src/notebook.c.o | ||
356 | 225 | .PHONY : src/notebook.o | ||
357 | 226 | |||
358 | 227 | # target to build an object file | ||
359 | 228 | src/notebook.c.o: | ||
360 | 229 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.o | ||
361 | 230 | .PHONY : src/notebook.c.o | ||
362 | 231 | |||
363 | 232 | src/notebook.i: src/notebook.c.i | ||
364 | 233 | .PHONY : src/notebook.i | ||
365 | 234 | |||
366 | 235 | # target to preprocess a source file | ||
367 | 236 | src/notebook.c.i: | ||
368 | 237 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.i | ||
369 | 238 | .PHONY : src/notebook.c.i | ||
370 | 239 | |||
371 | 240 | src/notebook.s: src/notebook.c.s | ||
372 | 241 | .PHONY : src/notebook.s | ||
373 | 242 | |||
374 | 243 | # target to generate assembly for a file | ||
375 | 244 | src/notebook.c.s: | ||
376 | 245 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.s | ||
377 | 246 | .PHONY : src/notebook.c.s | ||
378 | 247 | |||
379 | 248 | # Help Target | ||
380 | 249 | help: | ||
381 | 250 | @echo "The following are some of the valid targets for this Makefile:" | ||
382 | 251 | @echo "... all (the default if no target is provided)" | ||
383 | 252 | @echo "... clean" | ||
384 | 253 | @echo "... depend" | ||
385 | 254 | @echo "... edit_cache" | ||
386 | 255 | @echo "... install" | ||
387 | 256 | @echo "... install/local" | ||
388 | 257 | @echo "... install/strip" | ||
389 | 258 | @echo "... list_install_components" | ||
390 | 259 | @echo "... rebuild_cache" | ||
391 | 260 | @echo "... scratch" | ||
392 | 261 | @echo "... src/entry.o" | ||
393 | 262 | @echo "... src/entry.i" | ||
394 | 263 | @echo "... src/entry.s" | ||
395 | 264 | @echo "... src/main_window.o" | ||
396 | 265 | @echo "... src/main_window.i" | ||
397 | 266 | @echo "... src/main_window.s" | ||
398 | 267 | @echo "... src/menu.o" | ||
399 | 268 | @echo "... src/menu.i" | ||
400 | 269 | @echo "... src/menu.s" | ||
401 | 270 | @echo "... src/notebook.o" | ||
402 | 271 | @echo "... src/notebook.i" | ||
403 | 272 | @echo "... src/notebook.s" | ||
404 | 273 | .PHONY : help | ||
405 | 274 | |||
406 | 275 | |||
407 | 276 | |||
408 | 277 | #============================================================================= | ||
409 | 278 | # Special targets to cleanup operation of make. | ||
410 | 279 | |||
411 | 280 | # Special rule to run CMake to check the build system integrity. | ||
412 | 281 | # No rule that depends on this can have commands that come from listfiles | ||
413 | 282 | # because they might be regenerated. | ||
414 | 283 | cmake_check_build_system: | ||
415 | 284 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | ||
416 | 285 | .PHONY : cmake_check_build_system | ||
417 | 286 | |||
418 | 287 | 0 | ||
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 | 1 | # Test macros for Marlin, feel free to re-use them. | ||
424 | 2 | |||
425 | 3 | macro(add_test_executable EXE_NAME) | ||
426 | 4 | add_test(${EXE_NAME} gtester ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}) | ||
427 | 5 | endmacro() | ||
428 | 0 | 6 | ||
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 | 36 | 36 | ||
434 | 37 | add_custom_command (TARGET pot COMMAND | 37 | add_custom_command (TARGET pot COMMAND |
435 | 38 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot | 38 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot |
437 | 39 | ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8 | 39 | ${VALA_SOURCE} ${C_SOURCE} --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2" |
438 | 40 | --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="N_" --keyword="Q_:1g" --from-code=UTF-8 | ||
439 | 40 | ) | 41 | ) |
440 | 41 | endmacro() | 42 | endmacro() |
441 | 42 | 43 | ||
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 | 1 | ## | 1 | ## |
447 | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
448 | 3 | # Copyright 2012 elementary. | ||
449 | 3 | # | 4 | # |
450 | 4 | # Redistribution and use in source and binary forms, with or without | 5 | # Redistribution and use in source and binary forms, with or without |
451 | 5 | # modification, are permitted provided that the following conditions are met: | 6 | # modification, are permitted provided that the following conditions are met: |
452 | @@ -74,10 +75,18 @@ | |||
453 | 74 | # be a header file as well as an internal header file being generated called | 75 | # be a header file as well as an internal header file being generated called |
454 | 75 | # <provided_name>.h and <provided_name>_internal.h | 76 | # <provided_name>.h and <provided_name>_internal.h |
455 | 76 | # | 77 | # |
456 | 78 | # GENERATE_GIR | ||
457 | 79 | # Have the compiler generate a GObject-Introspection repository file with | ||
458 | 80 | # name: <provided_name>.gir. This can be later used to create a binary typelib | ||
459 | 81 | # using the GI compiler. | ||
460 | 82 | # | ||
461 | 83 | # GENERATE_SYMBOLS | ||
462 | 84 | # Output a <provided_name>.symbols file containing all the exported symbols. | ||
463 | 85 | # | ||
464 | 77 | # The following call is a simple example to the vala_precompile macro showing | 86 | # The following call is a simple example to the vala_precompile macro showing |
465 | 78 | # an example to every of the optional sections: | 87 | # an example to every of the optional sections: |
466 | 79 | # | 88 | # |
468 | 80 | # vala_precompile(VALA_C | 89 | # vala_precompile(VALA_C mytargetname |
469 | 81 | # source1.vala | 90 | # source1.vala |
470 | 82 | # source2.vala | 91 | # source2.vala |
471 | 83 | # source3.vala | 92 | # source3.vala |
472 | @@ -95,14 +104,19 @@ | |||
473 | 95 | # myvapi | 104 | # myvapi |
474 | 96 | # GENERATE_HEADER | 105 | # GENERATE_HEADER |
475 | 97 | # myheader | 106 | # myheader |
476 | 107 | # GENERATE_GIR | ||
477 | 108 | # mygir | ||
478 | 109 | # GENERATE_SYMBOLS | ||
479 | 110 | # mysymbols | ||
480 | 98 | # ) | 111 | # ) |
481 | 99 | # | 112 | # |
482 | 100 | # Most important is the variable VALA_C which will contain all the generated c | 113 | # Most important is the variable VALA_C which will contain all the generated c |
483 | 101 | # file names after the call. | 114 | # file names after the call. |
484 | 102 | ## | 115 | ## |
485 | 103 | 116 | ||
488 | 104 | macro(vala_precompile output) | 117 | macro(vala_precompile output target_name) |
489 | 105 | parse_arguments(ARGS "PACKAGES;OPTIONS;DIRECTORY;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) | 118 | parse_arguments(ARGS "TARGET;PACKAGES;OPTIONS;DIRECTORY;GENERATE_GIR;GENERATE_SYMBOLS;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) |
490 | 119 | |||
491 | 106 | if(ARGS_DIRECTORY) | 120 | if(ARGS_DIRECTORY) |
492 | 107 | set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) | 121 | set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) |
493 | 108 | else(ARGS_DIRECTORY) | 122 | else(ARGS_DIRECTORY) |
494 | @@ -115,14 +129,29 @@ | |||
495 | 115 | endforeach(pkg ${ARGS_PACKAGES}) | 129 | endforeach(pkg ${ARGS_PACKAGES}) |
496 | 116 | set(in_files "") | 130 | set(in_files "") |
497 | 117 | set(out_files "") | 131 | set(out_files "") |
498 | 132 | set(out_files_display "") | ||
499 | 118 | set(${output} "") | 133 | set(${output} "") |
500 | 134 | |||
501 | 119 | foreach(src ${ARGS_DEFAULT_ARGS}) | 135 | foreach(src ${ARGS_DEFAULT_ARGS}) |
503 | 120 | list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") | 136 | string(REGEX MATCH "^/" IS_MATCHED ${src}) |
504 | 137 | if(${IS_MATCHED} MATCHES "/") | ||
505 | 138 | set(src_file_path ${src}) | ||
506 | 139 | else() | ||
507 | 140 | set(src_file_path ${CMAKE_CURRENT_SOURCE_DIR}/${src}) | ||
508 | 141 | endif() | ||
509 | 142 | list(APPEND in_files ${src_file_path}) | ||
510 | 121 | string(REPLACE ".vala" ".c" src ${src}) | 143 | string(REPLACE ".vala" ".c" src ${src}) |
511 | 122 | string(REPLACE ".gs" ".c" src ${src}) | 144 | string(REPLACE ".gs" ".c" src ${src}) |
514 | 123 | set(out_file "${DIRECTORY}/${src}") | 145 | if(${IS_MATCHED} MATCHES "/") |
515 | 124 | list(APPEND out_files "${DIRECTORY}/${src}") | 146 | get_filename_component(VALA_FILE_NAME ${src} NAME) |
516 | 147 | set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") | ||
517 | 148 | list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") | ||
518 | 149 | else() | ||
519 | 150 | set(out_file "${DIRECTORY}/${src}") | ||
520 | 151 | list(APPEND out_files "${DIRECTORY}/${src}") | ||
521 | 152 | endif() | ||
522 | 125 | list(APPEND ${output} ${out_file}) | 153 | list(APPEND ${output} ${out_file}) |
523 | 154 | list(APPEND out_files_display "${src}") | ||
524 | 126 | endforeach(src ${ARGS_DEFAULT_ARGS}) | 155 | endforeach(src ${ARGS_DEFAULT_ARGS}) |
525 | 127 | 156 | ||
526 | 128 | set(custom_vapi_arguments "") | 157 | set(custom_vapi_arguments "") |
527 | @@ -139,7 +168,8 @@ | |||
528 | 139 | set(vapi_arguments "") | 168 | set(vapi_arguments "") |
529 | 140 | if(ARGS_GENERATE_VAPI) | 169 | if(ARGS_GENERATE_VAPI) |
530 | 141 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") | 170 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") |
532 | 142 | set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi") | 171 | list(APPEND out_files_display "${ARGS_GENERATE_VAPI}.vapi") |
533 | 172 | set(vapi_arguments "--library=${ARGS_GENERATE_VAPI}" "--vapi=${ARGS_GENERATE_VAPI}.vapi") | ||
534 | 143 | 173 | ||
535 | 144 | # Header and internal header is needed to generate internal vapi | 174 | # Header and internal header is needed to generate internal vapi |
536 | 145 | if (NOT ARGS_GENERATE_HEADER) | 175 | if (NOT ARGS_GENERATE_HEADER) |
537 | @@ -150,26 +180,69 @@ | |||
538 | 150 | set(header_arguments "") | 180 | set(header_arguments "") |
539 | 151 | if(ARGS_GENERATE_HEADER) | 181 | if(ARGS_GENERATE_HEADER) |
540 | 152 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") | 182 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
544 | 153 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") | 183 | list(APPEND out_files_display "${ARGS_GENERATE_HEADER}.h") |
545 | 154 | list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") | 184 | list(APPEND header_arguments "--header=${ARGS_GENERATE_HEADER}.h") |
543 | 155 | list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") | ||
546 | 156 | endif(ARGS_GENERATE_HEADER) | 185 | endif(ARGS_GENERATE_HEADER) |
547 | 157 | 186 | ||
549 | 158 | add_custom_command(OUTPUT ${out_files} | 187 | set(gir_arguments "") |
550 | 188 | set(gircomp_command "") | ||
551 | 189 | if(ARGS_GENERATE_GIR) | ||
552 | 190 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir") | ||
553 | 191 | list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir") | ||
554 | 192 | set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir") | ||
555 | 193 | |||
556 | 194 | include (FindGirCompiler) | ||
557 | 195 | find_package(GirCompiler REQUIRED) | ||
558 | 196 | |||
559 | 197 | set(gircomp_command | ||
560 | 198 | COMMAND | ||
561 | 199 | ${G_IR_COMPILER_EXECUTABLE} | ||
562 | 200 | ARGS | ||
563 | 201 | "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir" | ||
564 | 202 | -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib") | ||
565 | 203 | endif(ARGS_GENERATE_GIR) | ||
566 | 204 | |||
567 | 205 | set(symbols_arguments "") | ||
568 | 206 | if(ARGS_GENERATE_SYMBOLS) | ||
569 | 207 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_SYMBOLS}.symbols") | ||
570 | 208 | list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols") | ||
571 | 209 | set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols") | ||
572 | 210 | endif(ARGS_GENERATE_SYMBOLS) | ||
573 | 211 | |||
574 | 212 | # Workaround for a bug that would make valac run twice. This file is written | ||
575 | 213 | # after the vala compiler generates C source code. | ||
576 | 214 | set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp) | ||
577 | 215 | |||
578 | 216 | add_custom_command( | ||
579 | 217 | OUTPUT | ||
580 | 218 | ${OUTPUT_STAMP} | ||
581 | 159 | COMMAND | 219 | COMMAND |
582 | 160 | ${VALA_EXECUTABLE} | 220 | ${VALA_EXECUTABLE} |
583 | 161 | ARGS | 221 | ARGS |
584 | 162 | "-C" | 222 | "-C" |
585 | 163 | ${header_arguments} | 223 | ${header_arguments} |
587 | 164 | ${vapi_arguments} | 224 | ${vapi_arguments} |
588 | 225 | ${gir_arguments} | ||
589 | 226 | ${symbols_arguments} | ||
590 | 165 | "-b" ${CMAKE_CURRENT_SOURCE_DIR} | 227 | "-b" ${CMAKE_CURRENT_SOURCE_DIR} |
591 | 166 | "-d" ${DIRECTORY} | 228 | "-d" ${DIRECTORY} |
592 | 167 | ${vala_pkg_opts} | 229 | ${vala_pkg_opts} |
593 | 168 | ${ARGS_OPTIONS} | 230 | ${ARGS_OPTIONS} |
594 | 169 | ${in_files} | 231 | ${in_files} |
595 | 170 | ${custom_vapi_arguments} | 232 | ${custom_vapi_arguments} |
596 | 233 | COMMAND | ||
597 | 234 | touch | ||
598 | 235 | ARGS | ||
599 | 236 | ${OUTPUT_STAMP} | ||
600 | 171 | DEPENDS | 237 | DEPENDS |
601 | 172 | ${in_files} | 238 | ${in_files} |
602 | 173 | ${ARGS_CUSTOM_VAPIS} | 239 | ${ARGS_CUSTOM_VAPIS} |
603 | 240 | COMMENT | ||
604 | 241 | "Generating ${out_files_display}" | ||
605 | 242 | ${gircomp_command} | ||
606 | 174 | ) | 243 | ) |
607 | 244 | |||
608 | 245 | # This command will be run twice for some reason (pass a non-empty string to COMMENT | ||
609 | 246 | # in order to see it). Since valac is not executed from here, this won't be a problem. | ||
610 | 247 | add_custom_command(OUTPUT ${out_files} DEPENDS ${OUTPUT_STAMP} COMMENT "") | ||
611 | 175 | endmacro(vala_precompile) | 248 | endmacro(vala_precompile) |
612 | 176 | 249 | ||
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 | 1 | # Translations | 1 | # Translations |
618 | 2 | include (Translations) | 2 | include (Translations) |
623 | 3 | add_translations_directory ("slingshot") | 3 | add_translations_directory (${GETTEXT_PACKAGE}) |
624 | 4 | add_translations_catalog ("slingshot" | 4 | add_translations_catalog (${GETTEXT_PACKAGE} |
621 | 5 | ../src/Widgets | ||
622 | 6 | ../src/Backend | ||
625 | 7 | ../src | 5 | ../src |
627 | 8 | ) | 6 | ) |
628 | 9 | \ No newline at end of file | 7 | \ No newline at end of file |
629 | 10 | 8 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
635 | 17 | // | 17 | // |
636 | 18 | 18 | ||
774 | 19 | namespace Slingshot.Backend { | 19 | public class Slingshot.Backend.App : Object { |
775 | 20 | 20 | ||
776 | 21 | public class App : Object { | 21 | public string name { get; construct set; } |
777 | 22 | 22 | public string description { get; private set; default = ""; } | |
778 | 23 | public string name { get; construct set; } | 23 | public string desktop_id { get; construct set; } |
779 | 24 | public string description { get; private set; default = ""; } | 24 | public string exec { get; private set; } |
780 | 25 | public string desktop_id { get; construct set; } | 25 | public string icon_name { get; private set; default = ""; } |
781 | 26 | public string exec { get; private set; } | 26 | public string[] keywords { get; private set;} |
782 | 27 | public string icon_name { get; private set; default = ""; } | 27 | public Gdk.Pixbuf icon { get; private set; } |
783 | 28 | public string[] keywords { get; private set;} | 28 | public double popularity { get; set; } |
784 | 29 | public Gdk.Pixbuf icon { get; private set; } | 29 | public double relevancy { get; set; } |
785 | 30 | public double popularity { get; set; } | 30 | public string desktop_path { get; private set; } |
786 | 31 | public double relevancy { get; set; } | 31 | public string generic_name { get; private set; default = ""; } |
787 | 32 | public string desktop_path { get; private set; } | 32 | |
788 | 33 | public string generic_name { get; private set; default = ""; } | 33 | private bool is_command = false; |
789 | 34 | 34 | ||
790 | 35 | private bool is_command = false; | 35 | public signal void icon_changed (); |
791 | 36 | 36 | public signal void launched (App app); | |
792 | 37 | public signal void icon_changed (); | 37 | |
793 | 38 | public signal void launched (App app); | 38 | public App (GMenu.TreeEntry entry) { |
794 | 39 | 39 | name = entry.get_display_name (); | |
795 | 40 | public App (GMenu.TreeEntry entry) { | 40 | description = entry.get_comment () ?? name; |
796 | 41 | name = entry.get_display_name (); | 41 | exec = entry.get_exec (); |
797 | 42 | description = entry.get_comment () ?? name; | 42 | desktop_id = entry.get_desktop_file_id (); |
798 | 43 | exec = entry.get_exec (); | 43 | icon_name = entry.get_icon () ?? "application-default-icon"; |
799 | 44 | desktop_id = entry.get_desktop_file_id (); | 44 | desktop_path = entry.get_desktop_file_path (); |
800 | 45 | icon_name = entry.get_icon () ?? "application-default-icon"; | 45 | keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id); |
801 | 46 | desktop_path = entry.get_desktop_file_path (); | 46 | generic_name = entry.get_generic_name (); |
802 | 47 | keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id); | 47 | |
803 | 48 | generic_name = entry.get_generic_name (); | 48 | update_icon (); |
804 | 49 | 49 | Slingshot.icon_theme.changed.connect (update_icon); | |
805 | 50 | update_icon (); | 50 | } |
806 | 51 | Slingshot.icon_theme.changed.connect (update_icon); | 51 | |
807 | 52 | } | 52 | public App.from_command (string command) { |
808 | 53 | 53 | ||
809 | 54 | public App.from_command (string command) { | 54 | name = command; |
810 | 55 | 55 | description = _("Run this command..."); | |
811 | 56 | name = command; | 56 | exec = command; |
812 | 57 | description = _("Run this command..."); | 57 | desktop_id = command; |
813 | 58 | exec = command; | 58 | icon_name = "system-run"; |
814 | 59 | desktop_id = command; | 59 | |
815 | 60 | icon_name = "system-run"; | 60 | is_command = true; |
816 | 61 | 61 | ||
817 | 62 | is_command = true; | 62 | update_icon (); |
818 | 63 | 63 | ||
819 | 64 | update_icon (); | 64 | } |
820 | 65 | 65 | ||
821 | 66 | } | 66 | public void update_icon () { |
822 | 67 | 67 | icon = load_icon (Slingshot.settings.icon_size); | |
823 | 68 | public void update_icon () { | 68 | icon_changed (); |
824 | 69 | icon = load_icon (Slingshot.settings.icon_size); | 69 | } |
825 | 70 | icon_changed (); | 70 | |
826 | 71 | } | 71 | private delegate void IconLoadFallback (); |
827 | 72 | 72 | ||
828 | 73 | private delegate void IconLoadFallback (); | 73 | private class IconLoadFallbackMethod { |
829 | 74 | 74 | public unowned IconLoadFallback load_icon; | |
830 | 75 | private class IconLoadFallbackMethod { | 75 | |
831 | 76 | public unowned IconLoadFallback load_icon; | 76 | public IconLoadFallbackMethod (IconLoadFallback fallback) { |
832 | 77 | 77 | load_icon = fallback; | |
833 | 78 | public IconLoadFallbackMethod (IconLoadFallback fallback) { | 78 | } |
834 | 79 | load_icon = fallback; | 79 | } |
835 | 80 | } | 80 | |
836 | 81 | } | 81 | public Gdk.Pixbuf load_icon (int size) { |
837 | 82 | 82 | Gdk.Pixbuf icon = null; | |
838 | 83 | public Gdk.Pixbuf load_icon (int size) { | 83 | var flags = Gtk.IconLookupFlags.FORCE_SIZE; |
839 | 84 | Gdk.Pixbuf icon = null; | 84 | |
840 | 85 | var flags = Gtk.IconLookupFlags.FORCE_SIZE; | 85 | IconLoadFallbackMethod[] fallbacks = { |
841 | 86 | 86 | new IconLoadFallbackMethod (() => { | |
842 | 87 | IconLoadFallbackMethod[] fallbacks = { | 87 | try { |
843 | 88 | new IconLoadFallbackMethod (() => { | 88 | icon = Slingshot.icon_theme.load_icon (icon_name, size, flags); |
844 | 89 | try { | 89 | } catch (Error e) { |
845 | 90 | icon = Slingshot.icon_theme.load_icon (icon_name, size, flags); | 90 | warning ("Could not load icon. Falling back to method 2"); |
846 | 91 | } catch (Error e) { | 91 | } |
847 | 92 | warning ("Could not load icon. Falling back to method 2"); | 92 | }), |
848 | 93 | } | 93 | |
849 | 94 | }), | 94 | new IconLoadFallbackMethod (() => { |
850 | 95 | 95 | try { | |
851 | 96 | new IconLoadFallbackMethod (() => { | 96 | if (icon_name.last_index_of (".") > 0) { |
852 | 97 | try { | 97 | var name = icon_name[0:icon_name.last_index_of (".")]; |
853 | 98 | if (icon_name.last_index_of (".") > 0) { | 98 | icon = Slingshot.icon_theme.load_icon (name, size, flags); |
854 | 99 | var name = icon_name[0:icon_name.last_index_of (".")]; | 99 | } |
855 | 100 | icon = Slingshot.icon_theme.load_icon (name, size, flags); | 100 | } catch (Error e) { |
856 | 101 | } | 101 | warning ("Could not load icon. Falling back to method 3"); |
857 | 102 | } catch (Error e) { | 102 | } |
858 | 103 | warning ("Could not load icon. Falling back to method 3"); | 103 | }), |
859 | 104 | } | 104 | |
860 | 105 | }), | 105 | new IconLoadFallbackMethod (() => { |
861 | 106 | 106 | try { | |
862 | 107 | new IconLoadFallbackMethod (() => { | 107 | icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false); |
863 | 108 | try { | 108 | } catch (Error e) { |
864 | 109 | icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false); | 109 | warning ("Could not load icon. Falling back to method 4"); |
865 | 110 | } catch (Error e) { | 110 | } |
866 | 111 | warning ("Could not load icon. Falling back to method 4"); | 111 | }), |
867 | 112 | } | 112 | |
868 | 113 | }), | 113 | new IconLoadFallbackMethod (() => { |
869 | 114 | 114 | try { | |
870 | 115 | new IconLoadFallbackMethod (() => { | 115 | icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags); |
871 | 116 | try { | 116 | } catch (Error e) { |
872 | 117 | icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags); | 117 | warning ("Could not load icon. Falling back to method 5"); |
873 | 118 | } catch (Error e) { | 118 | } |
874 | 119 | warning ("Could not load icon. Falling back to method 5"); | 119 | }), |
875 | 120 | } | 120 | |
876 | 121 | }), | 121 | new IconLoadFallbackMethod (() => { |
877 | 122 | 122 | try { | |
878 | 123 | new IconLoadFallbackMethod (() => { | 123 | icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags); |
879 | 124 | try { | 124 | } catch (Error e) { |
880 | 125 | icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags); | 125 | error ("Could not find a fallback icon to load"); |
881 | 126 | } catch (Error e) { | 126 | } |
882 | 127 | error ("Could not find a fallback icon to load"); | 127 | }) |
883 | 128 | } | 128 | }; |
884 | 129 | }) | 129 | |
885 | 130 | }; | 130 | foreach (IconLoadFallbackMethod fallback in fallbacks) { |
886 | 131 | 131 | fallback.load_icon (); | |
887 | 132 | foreach (IconLoadFallbackMethod fallback in fallbacks) { | 132 | if (icon != null) |
888 | 133 | fallback.load_icon (); | 133 | break; |
889 | 134 | if (icon != null) | 134 | } |
890 | 135 | break; | 135 | |
891 | 136 | } | 136 | return icon; |
892 | 137 | 137 | } | |
893 | 138 | return icon; | 138 | |
894 | 139 | } | 139 | public void launch () { |
895 | 140 | 140 | try { | |
896 | 141 | public void launch () { | 141 | if (is_command) { |
897 | 142 | try { | 142 | debug (@"Launching command: $name"); |
898 | 143 | if (is_command) { | 143 | Process.spawn_command_line_async (exec); |
899 | 144 | debug (@"Launching command: $name"); | 144 | } else { |
900 | 145 | Process.spawn_command_line_async (exec); | 145 | launched (this); // Emit launched signal |
901 | 146 | } else { | 146 | new DesktopAppInfo (desktop_id).launch (null, null); |
902 | 147 | launched (this); // Emit launched signal | 147 | debug (@"Launching application: $name"); |
903 | 148 | new DesktopAppInfo (desktop_id).launch (null, null); | 148 | } |
904 | 149 | debug (@"Launching application: $name"); | 149 | } catch (Error e) { |
905 | 150 | } | 150 | warning ("Failed to launch %s: %s", name, exec); |
906 | 151 | } catch (Error e) { | 151 | } |
770 | 152 | warning ("Failed to launch %s: %s", name, exec); | ||
771 | 153 | } | ||
772 | 154 | } | ||
773 | 155 | |||
907 | 156 | } | 152 | } |
908 | 157 | 153 | ||
909 | 158 | } | 154 | } |
910 | 159 | 155 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
916 | 17 | // | 17 | // |
917 | 18 | 18 | ||
951 | 19 | using GLib; | 19 | public class Slingshot.Backend.AppSystem : Object { |
952 | 20 | using GMenu; | 20 | |
953 | 21 | using Gee; | 21 | private Gee.ArrayList<GMenu.TreeDirectory> categories = null; |
954 | 22 | 22 | private Gee.HashMap<string, Gee.ArrayList<App>> apps = null; | |
955 | 23 | namespace Slingshot.Backend { | 23 | private GMenu.Tree apps_menu = null; |
956 | 24 | 24 | ||
957 | 25 | public class AppSystem : Object { | 25 | private RelevancyService rl_service; |
958 | 26 | 26 | ||
959 | 27 | private ArrayList<TreeDirectory> categories = null; | 27 | public signal void changed (); |
960 | 28 | private HashMap<string, ArrayList<App>> apps = null; | 28 | private bool index_changed = false; |
961 | 29 | private GMenu.Tree apps_menu = null; | 29 | |
962 | 30 | 30 | construct { | |
963 | 31 | private RelevancyService rl_service; | 31 | |
964 | 32 | 32 | rl_service = new RelevancyService (); | |
965 | 33 | public signal void changed (); | 33 | rl_service.update_complete.connect (update_popularity); |
966 | 34 | private bool index_changed = false; | 34 | |
967 | 35 | 35 | apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED); | |
968 | 36 | construct { | 36 | apps_menu.add_monitor ((menu) => { |
969 | 37 | 37 | ||
970 | 38 | rl_service = new RelevancyService (); | 38 | debug ("Apps menu tree changed. Updating…"); |
971 | 39 | rl_service.update_complete.connect (update_popularity); | 39 | index_changed = true; |
939 | 40 | |||
940 | 41 | apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", TreeFlags.INCLUDE_EXCLUDED); | ||
941 | 42 | apps_menu.add_monitor ((menu) => { | ||
942 | 43 | |||
943 | 44 | debug ("Apps menu tree changed. Updating…"); | ||
944 | 45 | index_changed = true; | ||
945 | 46 | update_app_system (); | ||
946 | 47 | changed (); | ||
947 | 48 | |||
948 | 49 | }); | ||
949 | 50 | |||
950 | 51 | apps_menu.set_sort_key (TreeSortKey.DISPLAY_NAME); | ||
972 | 52 | update_app_system (); | 40 | update_app_system (); |
1099 | 53 | 41 | changed (); | |
1100 | 54 | } | 42 | |
1101 | 55 | 43 | }); | |
1102 | 56 | private void update_app_system () { | 44 | |
1103 | 57 | 45 | apps_menu.set_sort_key (GMenu.TreeSortKey.DISPLAY_NAME); | |
1104 | 58 | rl_service.refresh_popularity (); | 46 | update_app_system (); |
1105 | 59 | 47 | ||
1106 | 60 | update_categories_index (); | 48 | } |
1107 | 61 | update_apps (); | 49 | |
1108 | 62 | 50 | private void update_app_system () { | |
1109 | 63 | } | 51 | |
1110 | 64 | 52 | rl_service.refresh_popularity (); | |
1111 | 65 | private void update_categories_index () { | 53 | |
1112 | 66 | 54 | update_categories_index (); | |
1113 | 67 | var root_tree = apps_menu.get_root_directory (); | 55 | update_apps (); |
1114 | 68 | 56 | ||
1115 | 69 | if (categories == null || index_changed) { | 57 | } |
1116 | 70 | categories = new ArrayList<TreeDirectory> (); | 58 | |
1117 | 71 | 59 | private void update_categories_index () { | |
1118 | 72 | foreach (TreeItem item in root_tree.get_contents ()) { | 60 | |
1119 | 73 | if (item.get_type () == TreeItemType.DIRECTORY) | 61 | var root_tree = apps_menu.get_root_directory (); |
1120 | 74 | if (((TreeDirectory) item).get_is_nodisplay () == false) | 62 | |
1121 | 75 | categories.add ((TreeDirectory) item); | 63 | if (categories == null || index_changed) { |
1122 | 76 | } | 64 | categories = new Gee.ArrayList<GMenu.TreeDirectory> (); |
1123 | 77 | } | 65 | |
1124 | 78 | 66 | foreach (GMenu.TreeItem item in root_tree.get_contents ()) { | |
1125 | 79 | } | 67 | if (item.get_type () == GMenu.TreeItemType.DIRECTORY) |
1126 | 80 | 68 | if (((GMenu.TreeDirectory) item).get_is_nodisplay () == false) | |
1127 | 81 | private void update_popularity () { | 69 | categories.add ((GMenu.TreeDirectory) item); |
1128 | 82 | 70 | } | |
1129 | 83 | foreach (ArrayList<App> category in apps.values) | 71 | } |
1130 | 84 | foreach (App app in category) | 72 | |
1131 | 85 | app.popularity = rl_service.get_app_popularity (app.desktop_id); | 73 | } |
1132 | 86 | } | 74 | |
1133 | 87 | 75 | private void update_popularity () { | |
1134 | 88 | private void update_apps () { | 76 | |
1135 | 89 | 77 | foreach (Gee.ArrayList<App> category in apps.values) | |
1136 | 90 | if (index_changed) { | 78 | foreach (App app in category) |
1137 | 91 | apps.clear (); | 79 | app.popularity = rl_service.get_app_popularity (app.desktop_id); |
1138 | 92 | apps = null; | 80 | } |
1139 | 93 | index_changed = false; | 81 | |
1140 | 94 | } | 82 | private void update_apps () { |
1141 | 95 | 83 | ||
1142 | 96 | if (apps == null) { | 84 | if (index_changed) { |
1143 | 97 | 85 | apps.clear (); | |
1144 | 98 | apps = new HashMap<string, ArrayList<App>> (); | 86 | apps = null; |
1145 | 99 | 87 | index_changed = false; | |
1146 | 100 | foreach (TreeDirectory cat in categories) { | 88 | } |
1147 | 101 | apps.set (cat.get_name (), get_apps_by_category (cat)); | 89 | |
1148 | 102 | } | 90 | if (apps == null) { |
1149 | 103 | 91 | ||
1150 | 104 | } | 92 | apps = new Gee.HashMap<string, Gee.ArrayList<App>> (); |
1151 | 105 | 93 | ||
1152 | 106 | } | 94 | foreach (GMenu.TreeDirectory cat in categories) { |
1153 | 107 | 95 | apps.set (cat.get_name (), get_apps_by_category (cat)); | |
1154 | 108 | public ArrayList<TreeDirectory> get_categories () { | 96 | } |
1155 | 109 | 97 | ||
1156 | 110 | return categories; | 98 | } |
1157 | 111 | 99 | ||
1158 | 112 | } | 100 | } |
1159 | 113 | 101 | ||
1160 | 114 | public ArrayList<App> get_apps_by_category (TreeDirectory category) { | 102 | public Gee.ArrayList<GMenu.TreeDirectory> get_categories () { |
1161 | 115 | 103 | ||
1162 | 116 | var app_list = new ArrayList<App> (); | 104 | return categories; |
1163 | 117 | 105 | ||
1164 | 118 | foreach (TreeItem item in category.get_contents ()) { | 106 | } |
1165 | 119 | App app; | 107 | |
1166 | 120 | switch (item.get_type ()) { | 108 | public Gee.ArrayList<App> get_apps_by_category (GMenu.TreeDirectory category) { |
1167 | 121 | case TreeItemType.DIRECTORY: | 109 | |
1168 | 122 | app_list.add_all (get_apps_by_category ((TreeDirectory) item)); | 110 | var app_list = new Gee.ArrayList<App> (); |
1169 | 123 | break; | 111 | |
1170 | 124 | case TreeItemType.ENTRY: | 112 | foreach (GMenu.TreeItem item in category.get_contents ()) { |
1171 | 125 | if (is_entry ((TreeEntry) item)) { | 113 | App app; |
1172 | 126 | app = new App ((TreeEntry) item); | 114 | switch (item.get_type ()) { |
1173 | 127 | app.launched.connect (rl_service.app_launched); | 115 | case GMenu.TreeItemType.DIRECTORY: |
1174 | 128 | app_list.add (app); | 116 | app_list.add_all (get_apps_by_category ((GMenu.TreeDirectory) item)); |
1175 | 129 | } | 117 | break; |
1176 | 130 | break; | 118 | case GMenu.TreeItemType.ENTRY: |
1177 | 131 | } | 119 | if (is_entry ((GMenu.TreeEntry) item)) { |
1178 | 132 | } | 120 | app = new App ((GMenu.TreeEntry) item); |
1179 | 133 | return app_list; | 121 | app.launched.connect (rl_service.app_launched); |
1180 | 134 | 122 | app_list.add (app); | |
1055 | 135 | } | ||
1056 | 136 | |||
1057 | 137 | private bool is_entry (TreeEntry entry) { | ||
1058 | 138 | |||
1059 | 139 | if (entry.get_launch_in_terminal () == false | ||
1060 | 140 | && entry.get_is_excluded () == false | ||
1061 | 141 | && entry.get_is_nodisplay () == false) { | ||
1062 | 142 | return true; | ||
1063 | 143 | } else { | ||
1064 | 144 | return false; | ||
1065 | 145 | } | ||
1066 | 146 | |||
1067 | 147 | } | ||
1068 | 148 | |||
1069 | 149 | public HashMap<string, ArrayList<App>> get_apps () { | ||
1070 | 150 | |||
1071 | 151 | return apps; | ||
1072 | 152 | |||
1073 | 153 | } | ||
1074 | 154 | |||
1075 | 155 | public SList<App> get_apps_by_popularity () { | ||
1076 | 156 | |||
1077 | 157 | var sorted_apps = new SList<App> (); | ||
1078 | 158 | |||
1079 | 159 | foreach (ArrayList<App> category in apps.values) { | ||
1080 | 160 | foreach (App app in category) { | ||
1081 | 161 | sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity); | ||
1082 | 162 | } | ||
1083 | 163 | } | ||
1084 | 164 | |||
1085 | 165 | return sorted_apps; | ||
1086 | 166 | |||
1087 | 167 | } | ||
1088 | 168 | |||
1089 | 169 | public SList<App> get_apps_by_name () { | ||
1090 | 170 | |||
1091 | 171 | var sorted_apps = new SList<App> (); | ||
1092 | 172 | string[] sorted_apps_execs = {}; | ||
1093 | 173 | |||
1094 | 174 | foreach (ArrayList<App> category in apps.values) { | ||
1095 | 175 | foreach (App app in category) { | ||
1096 | 176 | if (!(app.exec in sorted_apps_execs)) { | ||
1097 | 177 | sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name); | ||
1098 | 178 | sorted_apps_execs += app.exec; | ||
1181 | 179 | } | 123 | } |
1182 | 124 | break; | ||
1183 | 125 | } | ||
1184 | 126 | } | ||
1185 | 127 | return app_list; | ||
1186 | 128 | |||
1187 | 129 | } | ||
1188 | 130 | |||
1189 | 131 | private bool is_entry (GMenu.TreeEntry entry) { | ||
1190 | 132 | |||
1191 | 133 | if (entry.get_launch_in_terminal () == false | ||
1192 | 134 | && entry.get_is_excluded () == false | ||
1193 | 135 | && entry.get_is_nodisplay () == false) { | ||
1194 | 136 | return true; | ||
1195 | 137 | } else { | ||
1196 | 138 | return false; | ||
1197 | 139 | } | ||
1198 | 140 | |||
1199 | 141 | } | ||
1200 | 142 | |||
1201 | 143 | public Gee.HashMap<string, Gee.ArrayList<App>> get_apps () { | ||
1202 | 144 | |||
1203 | 145 | return apps; | ||
1204 | 146 | |||
1205 | 147 | } | ||
1206 | 148 | |||
1207 | 149 | public SList<App> get_apps_by_popularity () { | ||
1208 | 150 | |||
1209 | 151 | var sorted_apps = new SList<App> (); | ||
1210 | 152 | |||
1211 | 153 | foreach (Gee.ArrayList<App> category in apps.values) { | ||
1212 | 154 | foreach (App app in category) { | ||
1213 | 155 | sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity); | ||
1214 | 156 | } | ||
1215 | 157 | } | ||
1216 | 158 | |||
1217 | 159 | return sorted_apps; | ||
1218 | 160 | |||
1219 | 161 | } | ||
1220 | 162 | |||
1221 | 163 | public SList<App> get_apps_by_name () { | ||
1222 | 164 | |||
1223 | 165 | var sorted_apps = new SList<App> (); | ||
1224 | 166 | string[] sorted_apps_execs = {}; | ||
1225 | 167 | |||
1226 | 168 | foreach (Gee.ArrayList<App> category in apps.values) { | ||
1227 | 169 | foreach (App app in category) { | ||
1228 | 170 | if (!(app.exec in sorted_apps_execs)) { | ||
1229 | 171 | sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name); | ||
1230 | 172 | sorted_apps_execs += app.exec; | ||
1231 | 180 | } | 173 | } |
1232 | 181 | } | 174 | } |
1233 | 182 | |||
1234 | 183 | return sorted_apps; | ||
1235 | 184 | |||
1236 | 185 | } | 175 | } |
1237 | 186 | 176 | ||
1281 | 187 | public async ArrayList<App> search_results (string search) { | 177 | return sorted_apps; |
1282 | 188 | 178 | ||
1283 | 189 | Idle.add (search_results.callback, Priority.HIGH); | 179 | } |
1284 | 190 | yield; | 180 | |
1285 | 191 | 181 | public async Gee.ArrayList<App> search_results (string search) { | |
1286 | 192 | var filtered = new ArrayList<App> (); | 182 | |
1287 | 193 | 183 | Idle.add (search_results.callback, Priority.HIGH); | |
1288 | 194 | /** It's a bit stupid algorithm, simply check if the char is present | 184 | yield; |
1289 | 195 | * some of the App values, then assign it a double. This is very simple: | 185 | |
1290 | 196 | * if an App name coincide with the search string they have obvious the | 186 | var filtered = new Gee.ArrayList<App> (); |
1291 | 197 | * same length, then the fraction will be 1.0. | 187 | |
1292 | 198 | * I've added a small multiplier when matching to a exec name, to give | 188 | /** It's a bit stupid algorithm, simply check if the char is present |
1293 | 199 | * more priority to app.name | 189 | * some of the App values, then assign it a double. This is very simple: |
1294 | 200 | **/ | 190 | * if an App name coincide with the search string they have obvious the |
1295 | 201 | string[] sorted_apps_execs = {}; | 191 | * same length, then the fraction will be 1.0. |
1296 | 202 | 192 | * I've added a small multiplier when matching to a exec name, to give | |
1297 | 203 | foreach (ArrayList<App> category in apps.values) { | 193 | * more priority to app.name |
1298 | 204 | foreach (App app in category) { | 194 | **/ |
1299 | 205 | if (!(app.exec in sorted_apps_execs)) { | 195 | string[] sorted_apps_execs = {}; |
1300 | 206 | sorted_apps_execs += app.exec; | 196 | |
1301 | 207 | if (search in app.name.down ()) { | 197 | foreach (Gee.ArrayList<App> category in apps.values) { |
1302 | 208 | if (search == app.name.down ()[0:search.length]) | 198 | foreach (App app in category) { |
1303 | 209 | app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0 | 199 | if (!(app.exec in sorted_apps_execs)) { |
1304 | 210 | else | 200 | sorted_apps_execs += app.exec; |
1305 | 211 | app.relevancy = app.name.length / search.length - app.popularity; | 201 | if (search in app.name.down ()) { |
1306 | 212 | filtered.add (app); | 202 | if (search == app.name.down ()[0:search.length]) |
1307 | 213 | } else if (search in app.exec.down ()) { | 203 | app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0 |
1308 | 214 | app.relevancy = app.exec.length / search.length * 10.0 - app.popularity; | 204 | else |
1309 | 215 | filtered.add (app); | 205 | app.relevancy = app.name.length / search.length - app.popularity; |
1310 | 216 | } else if (search in app.description.down ()) { | 206 | filtered.add (app); |
1311 | 217 | app.relevancy = app.description.length / search.length - app.popularity; | 207 | } else if (search in app.exec.down ()) { |
1312 | 218 | filtered.add (app); | 208 | app.relevancy = app.exec.length / search.length * 10.0 - app.popularity; |
1313 | 219 | } else if (search in app.generic_name.down ()) { | 209 | filtered.add (app); |
1314 | 220 | app.relevancy = app.generic_name.length / search.length - app.popularity; | 210 | } else if (search in app.description.down ()) { |
1315 | 221 | filtered.add (app); | 211 | app.relevancy = app.description.length / search.length - app.popularity; |
1316 | 222 | } else if (app.keywords != null) { | 212 | filtered.add (app); |
1317 | 223 | app.relevancy = 0; | 213 | } else if (search in app.generic_name.down ()) { |
1318 | 224 | foreach (string keyword in app.keywords) { | 214 | app.relevancy = app.generic_name.length / search.length - app.popularity; |
1319 | 225 | foreach (string search_word in search.split (" ")) { | 215 | filtered.add (app); |
1320 | 226 | if (search_word in keyword.down ()) { | 216 | } else if (app.keywords != null) { |
1321 | 227 | app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity; | 217 | app.relevancy = 0; |
1322 | 228 | filtered.add (app); | 218 | foreach (string keyword in app.keywords) { |
1323 | 229 | } | 219 | foreach (string search_word in search.split (" ")) { |
1324 | 220 | if (search_word in keyword.down ()) { | ||
1325 | 221 | app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity; | ||
1326 | 222 | filtered.add (app); | ||
1327 | 230 | } | 223 | } |
1328 | 231 | } | 224 | } |
1329 | 232 | } | 225 | } |
1330 | 233 | } | 226 | } |
1331 | 234 | } | 227 | } |
1332 | 235 | } | 228 | } |
1342 | 236 | 229 | } | |
1343 | 237 | filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b)); | 230 | |
1344 | 238 | 231 | filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b)); | |
1345 | 239 | if (filtered.size > 20) { | 232 | |
1346 | 240 | return (ArrayList<App>) filtered[0:20]; | 233 | if (filtered.size > 20) { |
1347 | 241 | } else { | 234 | return (Gee.ArrayList<App>) filtered[0:20]; |
1348 | 242 | return filtered; | 235 | } else { |
1349 | 243 | } | 236 | return filtered; |
1341 | 244 | |||
1350 | 245 | } | 237 | } |
1351 | 246 | 238 | ||
1352 | 247 | } | 239 | } |
1353 | 248 | 240 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1359 | 17 | 17 | ||
1360 | 18 | 18 | ||
1415 | 19 | namespace Slingshot { | 19 | public class Slingshot.DBusService : Object { |
1416 | 20 | 20 | ||
1417 | 21 | public class DBusService : Object { | 21 | [DBus (name = "org.pantheon.desktop.AppLauncherService")] |
1418 | 22 | 22 | private class Service : Object { | |
1419 | 23 | [DBus (name = "org.pantheon.desktop.AppLauncherService")] | 23 | public signal void visibility_changed (bool launcher_visible); |
1420 | 24 | private class Service : Object { | 24 | private Gtk.Widget? view = null; |
1421 | 25 | public signal void visibility_changed (bool launcher_visible); | 25 | |
1422 | 26 | private Gtk.Widget? view = null; | 26 | public Service (Gtk.Widget view) { |
1423 | 27 | 27 | this.view = view; | |
1424 | 28 | public Service (Gtk.Widget view) { | 28 | view.show.connect (on_view_visibility_change); |
1425 | 29 | this.view = view; | 29 | view.hide.connect (on_view_visibility_change); |
1426 | 30 | view.show.connect (on_view_visibility_change); | 30 | } |
1427 | 31 | view.hide.connect (on_view_visibility_change); | 31 | |
1428 | 32 | } | 32 | internal void on_view_visibility_change () { |
1429 | 33 | 33 | debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ()); | |
1430 | 34 | internal void on_view_visibility_change () { | 34 | this.visibility_changed (view.visible); |
1431 | 35 | debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ()); | 35 | } |
1432 | 36 | this.visibility_changed (view.visible); | 36 | } |
1433 | 37 | } | 37 | |
1434 | 38 | } | 38 | private Service? service = null; |
1435 | 39 | 39 | ||
1436 | 40 | private Service? service = null; | 40 | public DBusService (SlingshotView view) { |
1437 | 41 | 41 | // Own bus name | |
1438 | 42 | public DBusService (SlingshotView view) { | 42 | // try to register service name in session bus |
1439 | 43 | // Own bus name | 43 | Bus.own_name (BusType.SESSION, |
1440 | 44 | // try to register service name in session bus | 44 | "org.pantheon.desktop.AppLauncherService", |
1441 | 45 | Bus.own_name (BusType.SESSION, | 45 | BusNameOwnerFlags.NONE, |
1442 | 46 | "org.pantheon.desktop.AppLauncherService", | 46 | (conn) => { on_bus_aquired (conn, view); }, |
1443 | 47 | BusNameOwnerFlags.NONE, | 47 | name_acquired_handler, |
1444 | 48 | (conn) => { on_bus_aquired (conn, view); }, | 48 | () => { critical ("Could not aquire service name"); }); |
1445 | 49 | name_acquired_handler, | 49 | |
1446 | 50 | () => { critical ("Could not aquire service name"); }); | 50 | } |
1447 | 51 | 51 | ||
1448 | 52 | } | 52 | private void on_bus_aquired (DBusConnection connection, SlingshotView view) { |
1449 | 53 | 53 | try { | |
1450 | 54 | private void on_bus_aquired (DBusConnection connection, SlingshotView view) { | 54 | // start service and register it as dbus object |
1451 | 55 | try { | 55 | service = new Service (view); |
1452 | 56 | // start service and register it as dbus object | 56 | connection.register_object ("/org/pantheon/desktop/AppLauncherService", service); |
1453 | 57 | service = new Service (view); | 57 | } catch (IOError e) { |
1454 | 58 | connection.register_object ("/org/pantheon/desktop/AppLauncherService", service); | 58 | critical ("Could not register service: %s", e.message); |
1455 | 59 | } catch (IOError e) { | 59 | return_if_reached (); |
1456 | 60 | critical ("Could not register service: %s", e.message); | 60 | } |
1457 | 61 | return_if_reached (); | 61 | } |
1458 | 62 | } | 62 | |
1459 | 63 | } | 63 | private void name_acquired_handler (DBusConnection connection, string name) { |
1460 | 64 | 64 | message ("Service registration suceeded"); | |
1461 | 65 | private void name_acquired_handler (DBusConnection connection, string name) { | 65 | return_if_fail (service != null); |
1462 | 66 | message ("Service registration suceeded"); | 66 | // Emit initial state |
1463 | 67 | return_if_fail (service != null); | 67 | service.on_view_visibility_change (); |
1464 | 68 | // Emit initial state | 68 | } |
1465 | 69 | service.on_view_visibility_change (); | 69 | } |
1412 | 70 | } | ||
1413 | 71 | } | ||
1414 | 72 | } | ||
1466 | 73 | \ No newline at end of file | 70 | \ No newline at end of file |
1467 | 74 | 71 | ||
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 | 17 | // | 17 | // |
1473 | 18 | // Thanks to Synapse Developers for this class | 18 | // Thanks to Synapse Developers for this class |
1474 | 19 | 19 | ||
1505 | 20 | using Zeitgeist; | 20 | public class Slingshot.Backend.RelevancyService : Object { |
1506 | 21 | 21 | ||
1507 | 22 | namespace Slingshot.Backend { | 22 | private Zeitgeist.Log zg_log; |
1508 | 23 | 23 | private Zeitgeist.DataSourceRegistry zg_dsr; | |
1509 | 24 | public class RelevancyService : Object { | 24 | private Gee.HashMap<string, int> app_popularity; |
1510 | 25 | 25 | private bool has_datahub_gio_module = false; | |
1511 | 26 | private Zeitgeist.Log zg_log; | 26 | |
1512 | 27 | private Zeitgeist.DataSourceRegistry zg_dsr; | 27 | private const float MULTIPLIER = 65535.0f; |
1513 | 28 | private Gee.HashMap<string, int> app_popularity; | 28 | |
1514 | 29 | private bool has_datahub_gio_module = false; | 29 | public signal void update_complete (); |
1515 | 30 | 30 | ||
1516 | 31 | private const float MULTIPLIER = 65535.0f; | 31 | public RelevancyService () { |
1517 | 32 | 32 | ||
1518 | 33 | public signal void update_complete (); | 33 | zg_log = new Zeitgeist.Log (); |
1519 | 34 | 34 | app_popularity = new Gee.HashMap<string, int> (); | |
1520 | 35 | public RelevancyService () { | 35 | |
1521 | 36 | 36 | refresh_popularity (); | |
1522 | 37 | zg_log = new Zeitgeist.Log (); | 37 | check_data_sources.begin (); |
1523 | 38 | app_popularity = new Gee.HashMap<string, int> (); | 38 | |
1524 | 39 | 39 | Timeout.add_seconds (60*30, refresh_popularity); | |
1525 | 40 | refresh_popularity (); | 40 | |
1526 | 41 | check_data_sources.begin (); | 41 | } |
1527 | 42 | 42 | ||
1528 | 43 | Timeout.add_seconds (60*30, refresh_popularity); | 43 | private async void check_data_sources () { |
1529 | 44 | 44 | ||
1530 | 45 | } | 45 | zg_dsr = new Zeitgeist.DataSourceRegistry (); |
1531 | 46 | 46 | try { | |
1502 | 47 | private async void check_data_sources () { | ||
1503 | 48 | |||
1504 | 49 | zg_dsr = new Zeitgeist.DataSourceRegistry (); | ||
1532 | 50 | var ptr_arr = yield zg_dsr.get_data_sources (null); | 47 | var ptr_arr = yield zg_dsr.get_data_sources (null); |
1533 | 51 | 48 | ||
1535 | 52 | for (uint i=0; i < ptr_arr.len; i++) { | 49 | for (uint i=0; i < ptr_arr.length; i++) { |
1536 | 53 | 50 | ||
1537 | 54 | unowned Zeitgeist.DataSource ds; | 51 | unowned Zeitgeist.DataSource ds; |
1541 | 55 | ds = (Zeitgeist.DataSource) ptr_arr.index (i); | 52 | ds = (Zeitgeist.DataSource) ptr_arr.get (i); |
1542 | 56 | if (ds.get_unique_id () == "com.zeitgeist-project,datahub,gio-launch-listener" | 53 | if (ds.unique_id == "com.zeitgeist-project,datahub,gio-launch-listener" |
1543 | 57 | && ds.is_enabled ()) { | 54 | && ds.enabled == true) { |
1544 | 58 | 55 | ||
1545 | 59 | has_datahub_gio_module = true; | 56 | has_datahub_gio_module = true; |
1546 | 60 | break; | 57 | break; |
1547 | 61 | } | 58 | } |
1548 | 62 | } | 59 | } |
1549 | 60 | } catch (Error e) { | ||
1550 | 61 | critical (e.message); | ||
1551 | 63 | } | 62 | } |
1555 | 64 | 63 | } | |
1556 | 65 | public bool refresh_popularity () { | 64 | |
1557 | 66 | 65 | public bool refresh_popularity () { | |
1558 | 66 | |||
1559 | 67 | load_application_relevancies.begin (); | ||
1560 | 68 | return true; | ||
1561 | 69 | |||
1562 | 70 | } | ||
1563 | 71 | private void reload_relevancies () { | ||
1564 | 72 | |||
1565 | 73 | Idle.add_full (Priority.LOW, () => { | ||
1566 | 67 | load_application_relevancies.begin (); | 74 | load_application_relevancies.begin (); |
1675 | 68 | return true; | 75 | return false; |
1676 | 69 | 76 | }); | |
1677 | 70 | } | 77 | } |
1678 | 71 | private void reload_relevancies () { | 78 | |
1679 | 72 | 79 | private async void load_application_relevancies () { | |
1680 | 73 | Idle.add_full (Priority.LOW, () => { | 80 | |
1681 | 74 | load_application_relevancies.begin (); | 81 | Idle.add (load_application_relevancies.callback, Priority.HIGH); |
1682 | 75 | return false; | 82 | yield; |
1683 | 76 | }); | 83 | |
1684 | 77 | } | 84 | int64 end = Zeitgeist.Timestamp.from_now (); |
1685 | 78 | 85 | int64 start = end - Zeitgeist.Timestamp.WEEK * 4; | |
1686 | 79 | private async void load_application_relevancies () { | 86 | Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end); |
1687 | 80 | 87 | ||
1688 | 81 | Idle.add (load_application_relevancies.callback, Priority.HIGH); | 88 | var event = new Zeitgeist.Event (); |
1689 | 82 | yield; | 89 | event.interpretation = "!" + Zeitgeist.ZG.LEAVE_EVENT; |
1690 | 83 | 90 | var subject = new Zeitgeist.Subject (); | |
1691 | 84 | int64 end = Zeitgeist.Timestamp.now (); | 91 | subject.interpretation = Zeitgeist.NFO.SOFTWARE; |
1692 | 85 | int64 start = end - Zeitgeist.Timestamp.WEEK * 4; | 92 | subject.uri = "application://*"; |
1693 | 86 | Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end); | 93 | event.add_subject (subject); |
1694 | 87 | 94 | ||
1695 | 88 | var event = new Zeitgeist.Event (); | 95 | var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> (); |
1696 | 89 | event.set_interpretation ("!" + ZG_LEAVE_EVENT); | 96 | ptr_arr.add (event); |
1697 | 90 | var subject = new Zeitgeist.Subject (); | 97 | |
1698 | 91 | subject.set_interpretation (NFO_SOFTWARE); | 98 | Zeitgeist.ResultSet rs; |
1699 | 92 | subject.set_uri ("application://*"); | 99 | |
1700 | 93 | event.add_subject (subject); | 100 | try { |
1701 | 94 | 101 | ||
1702 | 95 | var ptr_arr = new PtrArray (); | 102 | rs = yield zg_log.find_events (tr, (owned) ptr_arr, |
1703 | 96 | ptr_arr.add (event); | 103 | Zeitgeist.StorageState.ANY, |
1704 | 97 | 104 | 256, | |
1705 | 98 | Zeitgeist.ResultSet rs; | 105 | Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, |
1706 | 99 | 106 | null); | |
1707 | 100 | try { | 107 | |
1708 | 101 | 108 | app_popularity.clear (); | |
1709 | 102 | rs = yield zg_log.find_events (tr, (owned) ptr_arr, | 109 | uint size = rs.size (); |
1710 | 103 | Zeitgeist.StorageState.ANY, | 110 | uint index = 0; |
1711 | 104 | 256, | 111 | |
1712 | 105 | Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS, | 112 | // Zeitgeist (0.6) doesn't have any stats API, so let's approximate |
1713 | 106 | null); | 113 | |
1714 | 107 | 114 | foreach (Zeitgeist.Event e in rs) { | |
1715 | 108 | app_popularity.clear (); | 115 | |
1716 | 109 | uint size = rs.size (); | 116 | if (e.num_subjects () <= 0) continue; |
1717 | 110 | uint index = 0; | 117 | Zeitgeist.Subject s = e.get_subject (0); |
1718 | 111 | 118 | ||
1719 | 112 | // Zeitgeist (0.6) doesn't have any stats API, so let's approximate | 119 | float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0> |
1720 | 113 | 120 | float relevancy = 1.0f / Math.powf (index + 1, power); | |
1721 | 114 | foreach (Zeitgeist.Event e in rs) { | 121 | app_popularity[s.uri] = (int)(relevancy * MULTIPLIER); |
1722 | 115 | 122 | index++; | |
1723 | 116 | if (e.num_subjects () <= 0) continue; | 123 | } |
1724 | 117 | Zeitgeist.Subject s = e.get_subject (0); | 124 | update_complete (); |
1725 | 118 | 125 | } catch (Error err) { | |
1726 | 119 | float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0> | 126 | warning ("%s", err.message); |
1727 | 120 | float relevancy = 1.0f / Math.powf (index + 1, power); | 127 | return; |
1728 | 121 | app_popularity[s.get_uri ()] = (int)(relevancy * MULTIPLIER); | 128 | } |
1729 | 122 | index++; | 129 | } |
1730 | 123 | } | 130 | |
1731 | 124 | update_complete (); | 131 | public float get_app_popularity (string desktop_id) { |
1732 | 125 | } catch (Error err) { | 132 | |
1733 | 126 | warning ("%s", err.message); | 133 | var id = "application://" + desktop_id; |
1734 | 127 | return; | 134 | |
1735 | 128 | } | 135 | if (app_popularity.has_key(id)) { |
1736 | 129 | } | 136 | return app_popularity[id] / MULTIPLIER; |
1737 | 130 | 137 | } | |
1738 | 131 | public float get_app_popularity (string desktop_id) { | 138 | |
1739 | 132 | 139 | return 0.0f; | |
1740 | 133 | var id = "application://" + desktop_id; | 140 | } |
1741 | 134 | 141 | ||
1742 | 135 | if (app_popularity.has_key(id)) { | 142 | public void app_launched (App app) { |
1743 | 136 | return app_popularity[id] / MULTIPLIER; | 143 | |
1744 | 137 | } | 144 | string app_uri = null; |
1745 | 138 | 145 | if (app.desktop_id != null) { | |
1746 | 139 | return 0.0f; | 146 | app_uri = "application://" + app.desktop_id; |
1747 | 140 | } | 147 | } |
1748 | 141 | 148 | ||
1749 | 142 | public void app_launched (App app) { | 149 | push_app_launch (app_uri, app.name); |
1750 | 143 | 150 | ||
1751 | 144 | string app_uri = null; | 151 | // and refresh |
1752 | 145 | if (app.desktop_id != null) { | 152 | reload_relevancies (); |
1753 | 146 | app_uri = "application://" + app.desktop_id; | 153 | } |
1754 | 147 | } | 154 | |
1755 | 148 | 155 | private void push_app_launch (string app_uri, string? display_name) { | |
1756 | 149 | push_app_launch (app_uri, app.name); | 156 | |
1757 | 150 | 157 | message ("Pushing launch event: %s [%s]", app_uri, display_name); | |
1758 | 151 | // and refresh | 158 | var event = new Zeitgeist.Event (); |
1759 | 152 | reload_relevancies (); | 159 | var subject = new Zeitgeist.Subject (); |
1760 | 153 | } | 160 | |
1761 | 154 | 161 | event.actor = "application://synapse.desktop"; | |
1762 | 155 | private void push_app_launch (string app_uri, string? display_name) { | 162 | event.interpretation = Zeitgeist.ZG.ACCESS_EVENT; |
1763 | 156 | 163 | event.manifestation = Zeitgeist.ZG.USER_ACTIVITY; | |
1764 | 157 | message ("Pushing launch event: %s [%s]", app_uri, display_name); | 164 | event.add_subject (subject); |
1765 | 158 | var event = new Zeitgeist.Event (); | 165 | |
1766 | 159 | var subject = new Zeitgeist.Subject (); | 166 | subject.uri = app_uri; |
1767 | 160 | 167 | subject.interpretation = Zeitgeist.NFO.SOFTWARE; | |
1768 | 161 | event.set_actor ("application://synapse.desktop"); | 168 | subject.manifestation = Zeitgeist.NFO.SOFTWARE_ITEM; |
1769 | 162 | event.set_interpretation (Zeitgeist.ZG_ACCESS_EVENT); | 169 | subject.mimetype = "application/x-desktop"; |
1770 | 163 | event.set_manifestation (Zeitgeist.ZG_USER_ACTIVITY); | 170 | subject.text = display_name; |
1771 | 164 | event.add_subject (subject); | 171 | var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> (); |
1772 | 165 | 172 | ptr_arr.add (event); | |
1773 | 166 | subject.set_uri (app_uri); | 173 | |
1774 | 167 | subject.set_interpretation (Zeitgeist.NFO_SOFTWARE); | 174 | try { |
1775 | 168 | subject.set_manifestation (Zeitgeist.NFO_SOFTWARE_ITEM); | 175 | zg_log.insert_events_no_reply (ptr_arr); |
1776 | 169 | subject.set_mimetype ("application/x-desktop"); | 176 | } catch (Error e) { |
1777 | 170 | subject.set_text (display_name); | 177 | critical (e.message); |
1778 | 171 | 178 | } | |
1779 | 172 | zg_log.insert_events_no_reply (event, null); | 179 | } |
1780 | 173 | } | 180 | } |
1673 | 174 | } | ||
1674 | 175 | } | ||
1781 | 176 | \ No newline at end of file | 181 | \ No newline at end of file |
1782 | 177 | 182 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1788 | 17 | // | 17 | // |
1789 | 18 | 18 | ||
1818 | 19 | using Granite.Services; | 19 | public class Slingshot.Settings : Granite.Services.Settings { |
1819 | 20 | 20 | ||
1820 | 21 | namespace Slingshot { | 21 | protected class GalaSettings : Granite.Services.Settings { |
1821 | 22 | 22 | ||
1822 | 23 | public class Settings : Granite.Services.Settings { | 23 | public string hotcorner_topleft { get; set; } |
1823 | 24 | 24 | ||
1824 | 25 | protected class GalaSettings : Granite.Services.Settings { | 25 | public GalaSettings () { |
1825 | 26 | 26 | base ("org.pantheon.desktop.gala.behavior"); | |
1826 | 27 | public string hotcorner_topleft { get; set; } | 27 | } |
1827 | 28 | 28 | } | |
1828 | 29 | public GalaSettings () { | 29 | |
1829 | 30 | base ("org.pantheon.desktop.gala.behavior"); | 30 | public int columns { get; set; } |
1830 | 31 | } | 31 | public int rows { get; set; } |
1831 | 32 | } | 32 | public int icon_size { get; set; } |
1832 | 33 | 33 | public bool show_category_filter { get; set; } | |
1833 | 34 | public int columns { get; set; } | 34 | public bool use_category { get; set; } |
1834 | 35 | public int rows { get; set; } | 35 | public string screen_resolution { get; set; } |
1835 | 36 | public int icon_size { get; set; } | 36 | public GalaSettings gala_settings; |
1836 | 37 | public bool show_category_filter { get; set; } | 37 | |
1837 | 38 | public bool use_category { get; set; } | 38 | public Settings () { |
1838 | 39 | public string screen_resolution { get; set; } | 39 | base ("org.pantheon.desktop.slingshot"); |
1839 | 40 | public GalaSettings gala_settings; | 40 | gala_settings = new GalaSettings (); |
1812 | 41 | |||
1813 | 42 | public Settings () { | ||
1814 | 43 | base ("org.pantheon.desktop.slingshot"); | ||
1815 | 44 | gala_settings = new GalaSettings (); | ||
1816 | 45 | } | ||
1817 | 46 | |||
1840 | 47 | } | 41 | } |
1841 | 48 | 42 | ||
1842 | 49 | } | 43 | } |
1843 | 50 | 44 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
1849 | 17 | // | 17 | // |
1850 | 18 | 18 | ||
1939 | 19 | using Gtk; | 19 | public class Slingshot.Slingshot : Granite.Application { |
1940 | 20 | using Granite; | 20 | |
1941 | 21 | 21 | private SlingshotView view = null; | |
1942 | 22 | namespace Slingshot { | 22 | public static bool silent = false; |
1943 | 23 | 23 | public static bool command_mode = false; | |
1944 | 24 | public class Slingshot : Granite.Application { | 24 | |
1945 | 25 | 25 | public static Settings settings { get; private set; default = null; } | |
1946 | 26 | private SlingshotView view = null; | 26 | //public static CssProvider style_provider { get; private set; default = null; } |
1947 | 27 | public static bool silent = false; | 27 | public static Gtk.IconTheme icon_theme { get; set; default = null; } |
1948 | 28 | public static bool command_mode = false; | 28 | private DBusService? dbus_service = null; |
1949 | 29 | 29 | ||
1950 | 30 | public static Settings settings { get; private set; default = null; } | 30 | construct { |
1951 | 31 | //public static CssProvider style_provider { get; private set; default = null; } | 31 | |
1952 | 32 | public static IconTheme icon_theme { get; set; default = null; } | 32 | build_data_dir = Build.DATADIR; |
1953 | 33 | private DBusService? dbus_service = null; | 33 | build_pkg_data_dir = Build.PKGDATADIR; |
1954 | 34 | 34 | build_release_name = Build.RELEASE_NAME; | |
1955 | 35 | construct { | 35 | build_version = Build.VERSION; |
1956 | 36 | 36 | build_version_info = Build.VERSION_INFO; | |
1957 | 37 | build_data_dir = Build.DATADIR; | 37 | |
1958 | 38 | build_pkg_data_dir = Build.PKGDATADIR; | 38 | program_name = "Slingshot"; |
1959 | 39 | build_release_name = Build.RELEASE_NAME; | 39 | exec_name = "slingshot-launcher"; |
1960 | 40 | build_version = Build.VERSION; | 40 | app_copyright = "GPLv3"; |
1961 | 41 | build_version_info = Build.VERSION_INFO; | 41 | app_icon = ""; |
1962 | 42 | 42 | app_launcher = ""; | |
1963 | 43 | program_name = "Slingshot"; | 43 | app_years = "2011-2012"; |
1964 | 44 | exec_name = "slingshot-launcher"; | 44 | application_id = "net.launchpad.slingshot"; |
1965 | 45 | app_copyright = "GPLv3"; | 45 | main_url = "https://launchpad.net/slingshot"; |
1966 | 46 | app_icon = ""; | 46 | bug_url = "https://bugs.launchpad.net/slingshot"; |
1967 | 47 | app_launcher = ""; | 47 | help_url = "https://answers.launchpad.net/slingshot"; |
1968 | 48 | app_years = "2011-2012"; | 48 | translate_url = "https://translations.launchpad.net/slingshot"; |
1969 | 49 | application_id = "net.launchpad.slingshot"; | 49 | |
1970 | 50 | main_url = "https://launchpad.net/slingshot"; | 50 | about_authors = {"Giulio Collura <random.cpp@gmail.com>", |
1971 | 51 | bug_url = "https://bugs.launchpad.net/slingshot"; | 51 | "Andrea Basso <andrea@elementaryos.org"}; |
1972 | 52 | help_url = "https://answers.launchpad.net/slingshot"; | 52 | about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>", |
1973 | 53 | translate_url = "https://translations.launchpad.net/slingshot"; | 53 | "Daniel Foré <bunny@go-docky.com>"}; |
1974 | 54 | 54 | about_translators = "Launchpad Translators"; | |
1975 | 55 | about_authors = {"Giulio Collura <random.cpp@gmail.com>", | 55 | about_license_type = Gtk.License.GPL_3_0; |
1976 | 56 | "Andrea Basso <andrea@elementaryos.org"}; | 56 | |
1977 | 57 | about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>", | 57 | } |
1978 | 58 | "Daniel Foré <bunny@go-docky.com>"}; | 58 | |
1979 | 59 | about_translators = "Launchpad Translators"; | 59 | public Slingshot () { |
1980 | 60 | about_license_type = License.GPL_3_0; | 60 | settings = new Settings (); |
1981 | 61 | 61 | } | |
1982 | 62 | } | 62 | |
1983 | 63 | 63 | protected override void activate () { | |
1984 | 64 | public Slingshot () { | 64 | if (get_windows () == null) { |
1985 | 65 | settings = new Settings (); | 65 | view = new SlingshotView (); |
1986 | 66 | } | 66 | view.set_application (this); |
1987 | 67 | 67 | ||
1988 | 68 | protected override void activate () { | 68 | if (dbus_service == null) |
1989 | 69 | if (get_windows () == null) { | 69 | dbus_service = new DBusService (view); |
1990 | 70 | view = new SlingshotView (); | 70 | |
1991 | 71 | view.set_application (this); | 71 | if (!silent) { |
1992 | 72 | 72 | //view.move_to_coords (0, 0); | |
1993 | 73 | if (dbus_service == null) | 73 | view.show_slingshot (); |
1994 | 74 | dbus_service = new DBusService (view); | 74 | } |
1995 | 75 | 75 | } else { | |
1996 | 76 | if (!silent) { | 76 | if (view.visible && !silent) |
1997 | 77 | //view.move_to_coords (0, 0); | 77 | view.hide (); |
1998 | 78 | view.show_slingshot (); | 78 | else |
1999 | 79 | } | 79 | view.show_slingshot (); |
2000 | 80 | } else { | 80 | } |
2001 | 81 | if (view.visible && !silent) | 81 | silent = false; |
2002 | 82 | view.hide (); | 82 | } |
2003 | 83 | else | 83 | |
2004 | 84 | view.show_slingshot (); | 84 | static const OptionEntry[] entries = { |
2005 | 85 | } | 85 | { "silent", 's', 0, OptionArg.NONE, ref silent, "Launch Slingshot as a background process without it appearing visually.", null }, |
2006 | 86 | silent = false; | 86 | { "command-mode", 'c', 0, OptionArg.NONE, ref command_mode, "This feature is not implemented yet. When it is, description will be changed.", null }, |
2007 | 87 | } | 87 | { null } |
2008 | 88 | 88 | }; | |
2009 | 89 | static const OptionEntry[] entries = { | 89 | |
2010 | 90 | { "silent", 's', 0, OptionArg.NONE, ref silent, "Launch Slingshot as a background process without it appearing visually.", null }, | 90 | public static int main (string[] args) { |
2011 | 91 | { "command-mode", 'c', 0, OptionArg.NONE, ref command_mode, "This feature is not implemented yet. When it is, description will be changed.", null }, | 91 | if (args.length > 1) { |
2012 | 92 | { null } | 92 | var context = new OptionContext (""); |
2013 | 93 | }; | 93 | context.add_main_entries (entries, "slingshot"); |
2014 | 94 | 94 | context.add_group (Gtk.get_option_group (true)); | |
1927 | 95 | public static int main (string[] args) { | ||
1928 | 96 | if (args.length > 1) { | ||
1929 | 97 | var context = new OptionContext (""); | ||
1930 | 98 | context.add_main_entries (entries, "slingshot"); | ||
1931 | 99 | context.add_group (Gtk.get_option_group (true)); | ||
1932 | 100 | |||
1933 | 101 | try { | ||
1934 | 102 | context.parse (ref args); | ||
1935 | 103 | } catch (Error e) { | ||
1936 | 104 | print (e.message + "\n"); | ||
1937 | 105 | } | ||
1938 | 106 | } | ||
2015 | 107 | 95 | ||
2019 | 108 | var app = new Slingshot (); | 96 | try { |
2020 | 109 | 97 | context.parse (ref args); | |
2021 | 110 | return app.run (args); | 98 | } catch (Error e) { |
2022 | 99 | print (e.message + "\n"); | ||
2023 | 100 | } | ||
2024 | 111 | } | 101 | } |
2025 | 102 | |||
2026 | 103 | var app = new Slingshot (); | ||
2027 | 112 | 104 | ||
2028 | 105 | return app.run (args); | ||
2029 | 113 | } | 106 | } |
2030 | 114 | 107 | ||
2031 | 115 | } | 108 | } |
2032 | 116 | 109 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2038 | 17 | // | 17 | // |
2039 | 18 | 18 | ||
2040 | 19 | using Gtk; | ||
2041 | 20 | using Gdk; | ||
2042 | 21 | using Gee; | ||
2043 | 22 | using Cairo; | ||
2044 | 23 | using Granite.Widgets; | ||
2045 | 24 | using GMenu; | ||
2046 | 25 | |||
2047 | 26 | using Slingshot.Widgets; | ||
2048 | 27 | using Slingshot.Backend; | ||
2049 | 28 | |||
2050 | 29 | namespace Slingshot { | 19 | namespace Slingshot { |
2051 | 30 | 20 | ||
2052 | 31 | public enum Modality { | 21 | public enum Modality { |
2053 | @@ -34,18 +24,18 @@ | |||
2054 | 34 | SEARCH_VIEW | 24 | SEARCH_VIEW |
2055 | 35 | } | 25 | } |
2056 | 36 | 26 | ||
2058 | 37 | public class SlingshotView : PopOver { | 27 | public class SlingshotView : Granite.Widgets.PopOver { |
2059 | 38 | 28 | ||
2060 | 39 | // Widgets | 29 | // Widgets |
2061 | 40 | public Granite.Widgets.SearchBar searchbar; | 30 | public Granite.Widgets.SearchBar searchbar; |
2065 | 41 | public Layout view_manager; | 31 | public Gtk.Layout view_manager; |
2066 | 42 | public Switcher page_switcher; | 32 | public Widgets.Switcher page_switcher; |
2067 | 43 | public ModeButton view_selector; | 33 | public Granite.Widgets.ModeButton view_selector; |
2068 | 44 | 34 | ||
2069 | 45 | // Views | 35 | // Views |
2070 | 46 | private Widgets.Grid grid_view; | 36 | private Widgets.Grid grid_view; |
2073 | 47 | private SearchView search_view; | 37 | private Widgets.SearchView search_view; |
2074 | 48 | private CategoryView category_view; | 38 | private Widgets.CategoryView category_view; |
2075 | 49 | 39 | ||
2076 | 50 | public Gtk.Grid top; | 40 | public Gtk.Grid top; |
2077 | 51 | public Gtk.Grid center; | 41 | public Gtk.Grid center; |
2078 | @@ -54,9 +44,9 @@ | |||
2079 | 54 | public Gtk.Box content_area; | 44 | public Gtk.Box content_area; |
2080 | 55 | private Gtk.EventBox event_box; | 45 | private Gtk.EventBox event_box; |
2081 | 56 | 46 | ||
2085 | 57 | public AppSystem app_system; | 47 | public Backend.AppSystem app_system; |
2086 | 58 | private ArrayList<TreeDirectory> categories; | 48 | private Gee.ArrayList<GMenu.TreeDirectory> categories; |
2087 | 59 | public HashMap<string, ArrayList<App>> apps; | 49 | public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps; |
2088 | 60 | 50 | ||
2089 | 61 | private int current_position = 0; | 51 | private int current_position = 0; |
2090 | 62 | private int search_view_position = 0; | 52 | private int search_view_position = 0; |
2091 | @@ -100,9 +90,9 @@ | |||
2092 | 100 | // Have the window in the right place | 90 | // Have the window in the right place |
2093 | 101 | read_settings (true); | 91 | read_settings (true); |
2094 | 102 | 92 | ||
2096 | 103 | Slingshot.icon_theme = IconTheme.get_default (); | 93 | Slingshot.icon_theme = Gtk.IconTheme.get_default (); |
2097 | 104 | 94 | ||
2099 | 105 | app_system = new AppSystem (); | 95 | app_system = new Backend.AppSystem (); |
2100 | 106 | 96 | ||
2101 | 107 | categories = app_system.get_categories (); | 97 | categories = app_system.get_categories (); |
2102 | 108 | apps = app_system.get_apps (); | 98 | apps = app_system.get_apps (); |
2103 | @@ -148,16 +138,16 @@ | |||
2104 | 148 | // Add top bar | 138 | // Add top bar |
2105 | 149 | top = new Gtk.Grid (); | 139 | top = new Gtk.Grid (); |
2106 | 150 | 140 | ||
2108 | 151 | var top_separator = new Label (""); // A fake label | 141 | var top_separator = new Gtk.Label (""); // A fake label |
2109 | 152 | top_separator.set_hexpand(true); | 142 | top_separator.set_hexpand(true); |
2110 | 153 | 143 | ||
2112 | 154 | view_selector = new ModeButton (); | 144 | view_selector = new Granite.Widgets.ModeButton (); |
2113 | 155 | 145 | ||
2115 | 156 | var image = new Image.from_icon_name ("view-grid-symbolic", IconSize.MENU); | 146 | var image = new Gtk.Image.from_icon_name ("view-grid-symbolic", Gtk.IconSize.MENU); |
2116 | 157 | image.tooltip_text = _("View as Grid"); | 147 | image.tooltip_text = _("View as Grid"); |
2117 | 158 | view_selector.append (image); | 148 | view_selector.append (image); |
2118 | 159 | 149 | ||
2120 | 160 | image = new Image.from_icon_name ("view-filter-symbolic", IconSize.MENU); | 150 | image = new Gtk.Image.from_icon_name ("view-filter-symbolic", Gtk.IconSize.MENU); |
2121 | 161 | image.tooltip_text = _("View by Category"); | 151 | image.tooltip_text = _("View by Category"); |
2122 | 162 | view_selector.append (image); | 152 | view_selector.append (image); |
2123 | 163 | 153 | ||
2124 | @@ -179,7 +169,7 @@ | |||
2125 | 179 | 169 | ||
2126 | 180 | center = new Gtk.Grid (); | 170 | center = new Gtk.Grid (); |
2127 | 181 | // Create the layout which works like view_manager | 171 | // Create the layout which works like view_manager |
2129 | 182 | view_manager = new Layout (null, null); | 172 | view_manager = new Gtk.Layout (null, null); |
2130 | 183 | view_manager.set_size_request (default_columns * 130, default_rows * 145); | 173 | view_manager.set_size_request (default_columns * 130, default_rows * 145); |
2131 | 184 | center.attach (view_manager, 0, 0, 1, 1); | 174 | center.attach (view_manager, 0, 0, 1, 1); |
2132 | 185 | 175 | ||
2133 | @@ -188,26 +178,26 @@ | |||
2134 | 188 | view_manager.put (grid_view, 0, 0); | 178 | view_manager.put (grid_view, 0, 0); |
2135 | 189 | 179 | ||
2136 | 190 | // Create the "SEARCH_VIEW" | 180 | // Create the "SEARCH_VIEW" |
2139 | 191 | search_view = new SearchView (this); | 181 | search_view = new Widgets.SearchView (this); |
2140 | 192 | foreach (ArrayList<App> app_list in apps.values) { | 182 | foreach (Gee.ArrayList<Backend.App> app_list in apps.values) { |
2141 | 193 | search_view.add_apps (app_list); | 183 | search_view.add_apps (app_list); |
2142 | 194 | } | 184 | } |
2143 | 195 | view_manager.put (search_view, -columns * 130, 0); | 185 | view_manager.put (search_view, -columns * 130, 0); |
2144 | 196 | 186 | ||
2145 | 197 | // Create the "CATEGORY_VIEW" | 187 | // Create the "CATEGORY_VIEW" |
2147 | 198 | category_view = new CategoryView (this); | 188 | category_view = new Widgets.CategoryView (this); |
2148 | 199 | view_manager.put (category_view, -columns * 130, 0); | 189 | view_manager.put (category_view, -columns * 130, 0); |
2149 | 200 | 190 | ||
2150 | 201 | // Create the page switcher | 191 | // Create the page switcher |
2152 | 202 | page_switcher = new Switcher (); | 192 | page_switcher = new Widgets.Switcher (); |
2153 | 203 | 193 | ||
2154 | 204 | // A bottom widget to keep the page switcher center | 194 | // A bottom widget to keep the page switcher center |
2155 | 205 | bottom = new Gtk.Grid (); | 195 | bottom = new Gtk.Grid (); |
2156 | 206 | 196 | ||
2157 | 207 | 197 | ||
2159 | 208 | var bottom_separator1 = new Label (""); // A fake label | 198 | var bottom_separator1 = new Gtk.Label (""); // A fake label |
2160 | 209 | bottom_separator1.set_hexpand (true); | 199 | bottom_separator1.set_hexpand (true); |
2162 | 210 | var bottom_separator2 = new Label (""); // A fake label | 200 | var bottom_separator2 = new Gtk.Label (""); // A fake label |
2163 | 211 | bottom_separator2.set_hexpand (true); | 201 | bottom_separator2.set_hexpand (true); |
2164 | 212 | bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label | 202 | bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label |
2165 | 213 | bottom.attach (page_switcher, 1, 0, 1, 1); | 203 | bottom.attach (page_switcher, 1, 0, 1, 1); |
2166 | @@ -220,7 +210,7 @@ | |||
2167 | 220 | event_box = new Gtk.EventBox (); | 210 | event_box = new Gtk.EventBox (); |
2168 | 221 | event_box.add (container); | 211 | event_box.add (container); |
2169 | 222 | // Add the container to the dialog's content area | 212 | // Add the container to the dialog's content area |
2171 | 223 | content_area = get_content_area () as Box; | 213 | content_area = get_content_area () as Gtk.Box; |
2172 | 224 | content_area.pack_start (event_box); | 214 | content_area.pack_start (event_box); |
2173 | 225 | 215 | ||
2174 | 226 | if (Slingshot.settings.use_category) | 216 | if (Slingshot.settings.use_category) |
2175 | @@ -294,7 +284,7 @@ | |||
2176 | 294 | //view_manager.draw.connect (this.draw_background); | 284 | //view_manager.draw.connect (this.draw_background); |
2177 | 295 | 285 | ||
2178 | 296 | event_box.key_press_event.connect (on_key_press); | 286 | event_box.key_press_event.connect (on_key_press); |
2180 | 297 | searchbar.text_changed_pause.connect ((text) => this.search (text)); | 287 | searchbar.text_changed_pause.connect ((text) => this.search.begin (text)); |
2181 | 298 | searchbar.grab_focus (); | 288 | searchbar.grab_focus (); |
2182 | 299 | 289 | ||
2183 | 300 | searchbar.activate.connect (() => { | 290 | searchbar.activate.connect (() => { |
2184 | @@ -302,8 +292,8 @@ | |||
2185 | 302 | search_view.launch_selected (); | 292 | search_view.launch_selected (); |
2186 | 303 | hide (); | 293 | hide (); |
2187 | 304 | } else { | 294 | } else { |
2190 | 305 | if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry | 295 | if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry |
2191 | 306 | ((AppEntry) get_focus ()).launch_app (); | 296 | ((Widgets.AppEntry) get_focus ()).launch_app (); |
2192 | 307 | } | 297 | } |
2193 | 308 | }); | 298 | }); |
2194 | 309 | 299 | ||
2195 | @@ -433,8 +423,8 @@ | |||
2196 | 433 | search_view.launch_selected (); | 423 | search_view.launch_selected (); |
2197 | 434 | hide (); | 424 | hide (); |
2198 | 435 | } else { | 425 | } else { |
2201 | 436 | if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry | 426 | if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry |
2202 | 437 | ((AppEntry)get_focus ()).launch_app (); | 427 | ((Widgets.AppEntry)get_focus ()).launch_app (); |
2203 | 438 | } | 428 | } |
2204 | 439 | return true; | 429 | return true; |
2205 | 440 | 430 | ||
2206 | @@ -596,7 +586,7 @@ | |||
2207 | 596 | break; | 586 | break; |
2208 | 597 | 587 | ||
2209 | 598 | case "Home": | 588 | case "Home": |
2211 | 599 | if (searchbar.text.size () > 0) { | 589 | if (searchbar.text.length > 0) { |
2212 | 600 | return false; | 590 | return false; |
2213 | 601 | } | 591 | } |
2214 | 602 | 592 | ||
2215 | @@ -609,7 +599,7 @@ | |||
2216 | 609 | break; | 599 | break; |
2217 | 610 | 600 | ||
2218 | 611 | case "End": | 601 | case "End": |
2220 | 612 | if (searchbar.text.size () > 0) { | 602 | if (searchbar.text.length > 0) { |
2221 | 613 | return false; | 603 | return false; |
2222 | 614 | } | 604 | } |
2223 | 615 | 605 | ||
2224 | @@ -641,7 +631,7 @@ | |||
2225 | 641 | 631 | ||
2226 | 642 | } | 632 | } |
2227 | 643 | 633 | ||
2229 | 644 | public override bool scroll_event (EventScroll event) { | 634 | public override bool scroll_event (Gdk.EventScroll event) { |
2230 | 645 | 635 | ||
2231 | 646 | switch (event.direction.to_string ()) { | 636 | switch (event.direction.to_string ()) { |
2232 | 647 | case "GDK_SCROLL_UP": | 637 | case "GDK_SCROLL_UP": |
2233 | @@ -820,7 +810,7 @@ | |||
2234 | 820 | 810 | ||
2235 | 821 | var filtered = yield app_system.search_results (stripped); | 811 | var filtered = yield app_system.search_results (stripped); |
2236 | 822 | 812 | ||
2238 | 823 | foreach (App app in filtered) { | 813 | foreach (Backend.App app in filtered) { |
2239 | 824 | search_view.show_app (app); | 814 | search_view.show_app (app); |
2240 | 825 | } | 815 | } |
2241 | 826 | 816 | ||
2242 | @@ -836,9 +826,9 @@ | |||
2243 | 836 | page_switcher.append ("1"); | 826 | page_switcher.append ("1"); |
2244 | 837 | page_switcher.set_active (0); | 827 | page_switcher.set_active (0); |
2245 | 838 | 828 | ||
2247 | 839 | foreach (App app in app_system.get_apps_by_name ()) { | 829 | foreach (Backend.App app in app_system.get_apps_by_name ()) { |
2248 | 840 | 830 | ||
2250 | 841 | var app_entry = new AppEntry (app); | 831 | var app_entry = new Widgets.AppEntry (app); |
2251 | 842 | app_entry.app_launched.connect (() => hide ()); | 832 | app_entry.app_launched.connect (() => hide ()); |
2252 | 843 | grid_view.append (app_entry); | 833 | grid_view.append (app_entry); |
2253 | 844 | app_entry.show_all (); | 834 | app_entry.show_all (); |
2254 | @@ -878,7 +868,7 @@ | |||
2255 | 878 | } | 868 | } |
2256 | 879 | 869 | ||
2257 | 880 | private void normal_move_focus (int delta_column, int delta_row) { | 870 | private void normal_move_focus (int delta_column, int delta_row) { |
2259 | 881 | if (get_focus () as AppEntry != null) { // we check if any AppEntry has focus. If it does, we move | 871 | if (get_focus () as Widgets.AppEntry != null) { // we check if any AppEntry has focus. If it does, we move |
2260 | 882 | var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists | 872 | var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists |
2261 | 883 | if (new_focus == null) { | 873 | if (new_focus == null) { |
2262 | 884 | if (delta_column <= 0) | 874 | if (delta_column <= 0) |
2263 | @@ -960,4 +950,4 @@ | |||
2264 | 960 | } | 950 | } |
2265 | 961 | } | 951 | } |
2266 | 962 | 952 | ||
2268 | 963 | } | 953 | } |
2269 | 964 | \ No newline at end of file | 954 | \ No newline at end of file |
2270 | 965 | 955 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2276 | 17 | // | 17 | // |
2277 | 18 | 18 | ||
2410 | 19 | using Gtk; | 19 | public class Slingshot.Widgets.AppEntry : Gtk.Button { |
2411 | 20 | using Gdk; | 20 | |
2412 | 21 | using Cairo; | 21 | public Gtk.Label app_label; |
2413 | 22 | 22 | private Gdk.Pixbuf icon; | |
2414 | 23 | namespace Slingshot.Widgets { | 23 | private Gtk.Box layout; |
2415 | 24 | 24 | ||
2416 | 25 | public class AppEntry : Button { | 25 | public string exec_name; |
2417 | 26 | 26 | public string app_name; | |
2418 | 27 | public Label app_label; | 27 | public string desktop_id; |
2419 | 28 | private Pixbuf icon; | 28 | public int icon_size; |
2420 | 29 | private Box layout; | 29 | public string desktop_path; |
2421 | 30 | 30 | ||
2422 | 31 | public string exec_name; | 31 | public signal void app_launched (); |
2423 | 32 | public string app_name; | 32 | |
2424 | 33 | public string desktop_id; | 33 | private double alpha = 1.0; |
2425 | 34 | public int icon_size; | 34 | private bool dragging = false; //prevent launching |
2426 | 35 | public string desktop_path; | 35 | |
2427 | 36 | 36 | private Backend.App application; | |
2428 | 37 | public signal void app_launched (); | 37 | |
2429 | 38 | 38 | public AppEntry (Backend.App app) { | |
2430 | 39 | private double alpha = 1.0; | 39 | Gtk.TargetEntry dnd = {"text/uri-list", 0, 0}; |
2431 | 40 | private bool dragging = false; //prevent launching | 40 | Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, |
2432 | 41 | 41 | Gdk.DragAction.COPY); | |
2433 | 42 | private Backend.App application; | 42 | |
2434 | 43 | 43 | app_paintable = true; | |
2435 | 44 | public AppEntry (Backend.App app) { | 44 | set_visual (get_screen ().get_rgba_visual()); |
2436 | 45 | TargetEntry dnd = {"text/uri-list", 0, 0}; | 45 | set_size_request (130, 130); |
2437 | 46 | Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd}, | 46 | desktop_id = app.desktop_id; |
2438 | 47 | Gdk.DragAction.COPY); | 47 | desktop_path = app.desktop_path; |
2439 | 48 | 48 | ||
2440 | 49 | app_paintable = true; | 49 | application = app; |
2441 | 50 | set_visual (get_screen ().get_rgba_visual()); | 50 | app_name = app.name; |
2442 | 51 | set_size_request (130, 130); | 51 | tooltip_text = app.description; |
2443 | 52 | desktop_id = app.desktop_id; | 52 | exec_name = app.exec; |
2444 | 53 | desktop_path = app.desktop_path; | 53 | icon_size = Slingshot.settings.icon_size; |
2445 | 54 | 54 | icon = app.icon; | |
2446 | 55 | application = app; | 55 | |
2447 | 56 | app_name = app.name; | 56 | get_style_context ().add_class ("app"); |
2448 | 57 | tooltip_text = app.description; | 57 | |
2449 | 58 | exec_name = app.exec; | 58 | app_label = new Gtk.Label (app_name); |
2450 | 59 | icon_size = Slingshot.settings.icon_size; | 59 | app_label.halign = Gtk.Align.CENTER; |
2451 | 60 | icon = app.icon; | 60 | app_label.justify = Gtk.Justification.CENTER; |
2452 | 61 | 61 | app_label.set_line_wrap (true); // Need a smarter way | |
2453 | 62 | get_style_context ().add_class ("app"); | 62 | app_label.set_single_line_mode (false); |
2454 | 63 | 63 | app_label.set_ellipsize (Pango.EllipsizeMode.END); | |
2455 | 64 | app_label = new Label (app_name); | 64 | |
2456 | 65 | app_label.halign = Align.CENTER; | 65 | layout = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
2457 | 66 | app_label.justify = Justification.CENTER; | 66 | layout.homogeneous = false; |
2458 | 67 | app_label.set_line_wrap (true); // Need a smarter way | 67 | |
2459 | 68 | app_label.set_single_line_mode (false); | 68 | layout.pack_start (app_label, false, true, 0); |
2460 | 69 | app_label.set_ellipsize (Pango.EllipsizeMode.END); | 69 | |
2461 | 70 | 70 | add (Utils.set_padding (layout, 78, 5, 5, 5)); | |
2462 | 71 | layout = new Box (Orientation.VERTICAL, 0); | 71 | |
2463 | 72 | layout.homogeneous = false; | 72 | this.clicked.connect (launch_app); |
2464 | 73 | 73 | ||
2465 | 74 | layout.pack_start (app_label, false, true, 0); | 74 | this.button_press_event.connect ((e) => {return e.button == 3;}); |
2466 | 75 | 75 | ||
2467 | 76 | add (Utils.set_padding (layout, 78, 5, 5, 5)); | 76 | this.drag_begin.connect ( (ctx) => { |
2468 | 77 | 77 | this.dragging = true; | |
2469 | 78 | this.clicked.connect (launch_app); | 78 | Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0); |
2470 | 79 | 79 | }); | |
2471 | 80 | this.button_press_event.connect ((e) => {return e.button == 3;}); | 80 | this.drag_end.connect ( () => { |
2472 | 81 | 81 | this.dragging = false; | |
2473 | 82 | this.drag_begin.connect ( (ctx) => { | 82 | }); |
2474 | 83 | this.dragging = true; | 83 | this.drag_data_get.connect ( (ctx, sel, info, time) => { |
2475 | 84 | Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0); | 84 | sel.set_uris ({File.new_for_path (desktop_path).get_uri ()}); |
2476 | 85 | }); | 85 | }); |
2477 | 86 | this.drag_end.connect ( () => { | 86 | |
2478 | 87 | this.dragging = false; | 87 | app.icon_changed.connect (queue_draw); |
2479 | 88 | }); | 88 | |
2480 | 89 | this.drag_data_get.connect ( (ctx, sel, info, time) => { | 89 | } |
2481 | 90 | sel.set_uris ({File.new_for_path (desktop_path).get_uri ()}); | 90 | |
2482 | 91 | }); | 91 | protected override bool draw (Cairo.Context cr) { |
2483 | 92 | 92 | ||
2484 | 93 | app.icon_changed.connect (queue_draw); | 93 | |
2485 | 94 | 94 | Gtk.Allocation size; | |
2486 | 95 | } | 95 | get_allocation (out size); |
2487 | 96 | 96 | ||
2488 | 97 | protected override bool draw (Context cr) { | 97 | base.draw (cr); |
2489 | 98 | 98 | ||
2490 | 99 | 99 | // Draw icon | |
2491 | 100 | Allocation size; | 100 | Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10); |
2492 | 101 | get_allocation (out size); | 101 | cr.paint_with_alpha (alpha); |
2493 | 102 | 102 | ||
2494 | 103 | base.draw (cr); | 103 | return true; |
2495 | 104 | 104 | ||
2496 | 105 | // Draw icon | 105 | } |
2497 | 106 | Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10); | 106 | |
2498 | 107 | cr.paint_with_alpha (alpha); | 107 | public void fade_out () { |
2499 | 108 | 108 | ||
2500 | 109 | return true; | 109 | Timeout.add (20, () => { |
2501 | 110 | 110 | ||
2502 | 111 | } | 111 | if (alpha <= 0.3) { |
2503 | 112 | 112 | queue_draw (); | |
2504 | 113 | public void fade_out () { | 113 | return false; |
2505 | 114 | 114 | } | |
2506 | 115 | Timeout.add (20, () => { | 115 | |
2507 | 116 | 116 | alpha -= 0.05; | |
2508 | 117 | if (alpha <= 0.3) { | 117 | queue_draw (); |
2509 | 118 | queue_draw (); | 118 | return true; |
2510 | 119 | return false; | 119 | |
2511 | 120 | } | 120 | }); |
2512 | 121 | 121 | ||
2513 | 122 | alpha -= 0.05; | 122 | } |
2514 | 123 | queue_draw (); | 123 | |
2515 | 124 | return true; | 124 | public void fade_in () { |
2516 | 125 | 125 | ||
2517 | 126 | }); | 126 | Timeout.add (20, () => { |
2518 | 127 | 127 | ||
2519 | 128 | } | 128 | if (alpha == 1.0) { |
2520 | 129 | 129 | queue_draw (); | |
2521 | 130 | public void fade_in () { | 130 | return false; |
2522 | 131 | 131 | } | |
2523 | 132 | Timeout.add (20, () => { | 132 | |
2524 | 133 | 133 | alpha += 0.05; | |
2525 | 134 | if (alpha == 1.0) { | 134 | queue_draw (); |
2526 | 135 | queue_draw (); | 135 | return true; |
2527 | 136 | return false; | 136 | |
2528 | 137 | } | 137 | }); |
2529 | 138 | 138 | ||
2530 | 139 | alpha += 0.05; | 139 | } |
2531 | 140 | queue_draw (); | 140 | |
2532 | 141 | return true; | 141 | public void launch_app () { |
2533 | 142 | 142 | application.launch (); | |
2534 | 143 | }); | 143 | app_launched (); |
2403 | 144 | |||
2404 | 145 | } | ||
2405 | 146 | |||
2406 | 147 | public void launch_app () { | ||
2407 | 148 | application.launch (); | ||
2408 | 149 | app_launched (); | ||
2409 | 150 | } | ||
2535 | 151 | } | 144 | } |
2536 | 152 | } | 145 | } |
2537 | 153 | 146 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2543 | 17 | // | 17 | // |
2544 | 18 | 18 | ||
2659 | 19 | using Gtk; | 19 | public class Slingshot.Widgets.CategoryView : Gtk.EventBox { |
2660 | 20 | using Gee; | 20 | |
2661 | 21 | 21 | private Gtk.Grid container; | |
2662 | 22 | using Slingshot.Backend; | 22 | public Sidebar category_switcher; |
2663 | 23 | 23 | public Gtk.Separator separator; | |
2664 | 24 | namespace Slingshot.Widgets { | 24 | public Widgets.Grid app_view; |
2665 | 25 | 25 | private Gtk.Layout layout; | |
2666 | 26 | public class CategoryView : EventBox { | 26 | public Switcher switcher; |
2667 | 27 | 27 | private SlingshotView view; | |
2668 | 28 | private Gtk.Grid container; | 28 | private Gtk.Label empty_cat_label; |
2669 | 29 | public Sidebar category_switcher; | 29 | |
2670 | 30 | public VSeparator separator; | 30 | private Gtk.Grid page_switcher; |
2671 | 31 | public Widgets.Grid app_view; | 31 | |
2672 | 32 | private Layout layout; | 32 | private const string ALL_APPLICATIONS = _("All Applications"); |
2673 | 33 | public Switcher switcher; | 33 | private const string NEW_FILTER = _("Create a new Filter"); |
2674 | 34 | private SlingshotView view; | 34 | private int current_position = 0; |
2675 | 35 | private Label empty_cat_label; | 35 | private bool from_category = false; |
2676 | 36 | 36 | ||
2677 | 37 | private Gtk.Grid page_switcher; | 37 | public Gee.HashMap<int, string> category_ids = new Gee.HashMap<int, string> (); |
2678 | 38 | 38 | ||
2679 | 39 | private const string ALL_APPLICATIONS = _("All Applications"); | 39 | public CategoryView (SlingshotView parent) { |
2680 | 40 | private const string NEW_FILTER = _("Create a new Filter"); | 40 | |
2681 | 41 | private int current_position = 0; | 41 | view = parent; |
2682 | 42 | private bool from_category = false; | 42 | |
2683 | 43 | 43 | set_visible_window (false); | |
2684 | 44 | public HashMap<int, string> category_ids = new HashMap<int, string> (); | 44 | setup_ui (); |
2685 | 45 | 45 | setup_sidebar (); | |
2686 | 46 | public CategoryView (SlingshotView parent) { | 46 | connect_events (); |
2687 | 47 | 47 | ||
2688 | 48 | view = parent; | 48 | set_size_request (view.columns*130 + 17, view.view_height); |
2689 | 49 | 49 | ||
2690 | 50 | set_visible_window (false); | 50 | } |
2691 | 51 | setup_ui (); | 51 | |
2692 | 52 | setup_sidebar (); | 52 | private void setup_ui () { |
2693 | 53 | connect_events (); | 53 | container = new Gtk.Grid (); |
2694 | 54 | 54 | separator = new Gtk.Separator (Gtk.Orientation.VERTICAL); | |
2695 | 55 | set_size_request (view.columns*130 + 17, view.view_height); | 55 | |
2696 | 56 | 56 | layout = new Gtk.Layout (null, null); | |
2697 | 57 | } | 57 | |
2698 | 58 | 58 | app_view = new Widgets.Grid (view.rows, view.columns - 1); | |
2699 | 59 | private void setup_ui () { | 59 | layout.put (app_view, 0, 0); |
2700 | 60 | container = new Gtk.Grid (); | 60 | empty_cat_label = new Gtk.Label (""); |
2701 | 61 | separator = new VSeparator (); | 61 | layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2); |
2702 | 62 | 62 | layout.set_hexpand (true); | |
2703 | 63 | layout = new Layout (null, null); | 63 | layout.set_vexpand (true); |
2704 | 64 | 64 | ||
2705 | 65 | app_view = new Widgets.Grid (view.rows, view.columns - 1); | 65 | // Create the page switcher |
2706 | 66 | layout.put (app_view, 0, 0); | 66 | switcher = new Switcher (); |
2707 | 67 | empty_cat_label = new Gtk.Label (""); | 67 | |
2708 | 68 | layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2); | 68 | // A bottom widget to keep the page switcher center |
2709 | 69 | layout.set_hexpand (true); | 69 | page_switcher = new Gtk.Grid (); |
2710 | 70 | layout.set_vexpand (true); | 70 | var bottom_separator1 = new Gtk.Label (""); // A fake label |
2711 | 71 | 71 | bottom_separator1.set_hexpand(true); | |
2712 | 72 | // Create the page switcher | 72 | var bottom_separator2 = new Gtk.Label (""); // A fake label |
2713 | 73 | switcher = new Switcher (); | 73 | bottom_separator2.set_hexpand(true); |
2714 | 74 | 74 | page_switcher.attach (bottom_separator1, 0, 0, 1, 1); | |
2715 | 75 | // A bottom widget to keep the page switcher center | 75 | page_switcher.attach (switcher, 1, 0, 1, 1); |
2716 | 76 | page_switcher = new Gtk.Grid (); | 76 | page_switcher.attach (bottom_separator2, 2, 0, 1, 1); |
2717 | 77 | var bottom_separator1 = new Label (""); // A fake label | 77 | |
2718 | 78 | bottom_separator1.set_hexpand(true); | 78 | container.attach (separator, 1, 0, 1, 2); |
2719 | 79 | var bottom_separator2 = new Label (""); // A fake label | 79 | container.attach (layout, 2, 0, 1, 1); |
2720 | 80 | bottom_separator2.set_hexpand(true); | 80 | |
2721 | 81 | page_switcher.attach (bottom_separator1, 0, 0, 1, 1); | 81 | add (container); |
2722 | 82 | page_switcher.attach (switcher, 1, 0, 1, 1); | 82 | |
2723 | 83 | page_switcher.attach (bottom_separator2, 2, 0, 1, 1); | 83 | } |
2724 | 84 | 84 | ||
2725 | 85 | container.attach (separator, 1, 0, 1, 2); | 85 | public void setup_sidebar () { |
2726 | 86 | container.attach (layout, 2, 0, 1, 1); | 86 | |
2727 | 87 | 87 | if (category_switcher != null) | |
2728 | 88 | add (container); | 88 | category_switcher.destroy (); |
2729 | 89 | 89 | ||
2730 | 90 | } | 90 | category_switcher = new Sidebar (); |
2731 | 91 | 91 | category_switcher.can_focus = false; | |
2732 | 92 | public void setup_sidebar () { | 92 | |
2733 | 93 | 93 | // Fill the sidebar | |
2734 | 94 | if (category_switcher != null) | 94 | int n = 0; |
2735 | 95 | category_switcher.destroy (); | 95 | |
2736 | 96 | 96 | foreach (string cat_name in view.apps.keys) { | |
2737 | 97 | category_switcher = new Sidebar (); | 97 | category_ids.set (n, cat_name); |
2738 | 98 | category_switcher.can_focus = false; | 98 | category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ()); |
2739 | 99 | 99 | n++; | |
2740 | 100 | // Fill the sidebar | 100 | } |
2741 | 101 | int n = 0; | 101 | |
2742 | 102 | 102 | container.attach (category_switcher, 0, 0, 1, 2); | |
2743 | 103 | foreach (string cat_name in view.apps.keys) { | 103 | category_switcher.selection_changed.connect ((name, nth) => { |
2744 | 104 | category_ids.set (n, cat_name); | 104 | |
2745 | 105 | category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ()); | 105 | view.reset_category_focus (); |
2746 | 106 | n++; | 106 | string category = category_ids.get (nth); |
2747 | 107 | } | 107 | show_filtered_apps (category); |
2748 | 108 | 108 | }); | |
2749 | 109 | container.attach (category_switcher, 0, 0, 1, 2); | 109 | |
2750 | 110 | category_switcher.selection_changed.connect ((name, nth) => { | 110 | category_switcher.show_all (); |
2751 | 111 | 111 | } | |
2752 | 112 | view.reset_category_focus (); | 112 | |
2753 | 113 | string category = category_ids.get (nth); | 113 | private void connect_events () { |
2754 | 114 | show_filtered_apps (category); | 114 | |
2755 | 115 | }); | 115 | layout.scroll_event.connect ((event) => { |
2756 | 116 | 116 | switch (event.direction.to_string ()) { | |
2757 | 117 | category_switcher.show_all (); | 117 | case "GDK_SCROLL_UP": |
2758 | 118 | } | 118 | case "GDK_SCROLL_LEFT": |
2759 | 119 | 119 | switcher.set_active (switcher.active - 1); | |
2760 | 120 | private void connect_events () { | 120 | break; |
2761 | 121 | 121 | case "GDK_SCROLL_DOWN": | |
2762 | 122 | layout.scroll_event.connect ((event) => { | 122 | case "GDK_SCROLL_RIGHT": |
2763 | 123 | switch (event.direction.to_string ()) { | 123 | switcher.set_active (switcher.active + 1); |
2764 | 124 | case "GDK_SCROLL_UP": | 124 | break; |
2765 | 125 | case "GDK_SCROLL_LEFT": | 125 | } |
2766 | 126 | switcher.set_active (switcher.active - 1); | 126 | return false; |
2767 | 127 | break; | 127 | }); |
2768 | 128 | case "GDK_SCROLL_DOWN": | 128 | |
2769 | 129 | case "GDK_SCROLL_RIGHT": | 129 | app_view.new_page.connect ((page) => { |
2770 | 130 | switcher.set_active (switcher.active + 1); | 130 | |
2771 | 131 | break; | 131 | if (switcher.size == 0) |
2772 | 132 | } | 132 | switcher.append ("1"); |
2773 | 133 | switcher.append (page); | ||
2774 | 134 | |||
2775 | 135 | /* Prevents pages from changing */ | ||
2776 | 136 | from_category = true; | ||
2777 | 137 | }); | ||
2778 | 138 | |||
2779 | 139 | switcher.active_changed.connect (() => { | ||
2780 | 140 | if (from_category || switcher.active - switcher.old_active == 0) { | ||
2781 | 141 | from_category = false; | ||
2782 | 142 | return; | ||
2783 | 143 | } | ||
2784 | 144 | |||
2785 | 145 | move_page (switcher.active - switcher.old_active); | ||
2786 | 146 | view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page | ||
2787 | 147 | }); | ||
2788 | 148 | |||
2789 | 149 | category_switcher.selected = 0; //Must be after everything else | ||
2790 | 150 | } | ||
2791 | 151 | |||
2792 | 152 | private void add_app (Backend.App app) { | ||
2793 | 153 | |||
2794 | 154 | var app_entry = new AppEntry (app); | ||
2795 | 155 | app_entry.app_launched.connect (() => view.hide ()); | ||
2796 | 156 | app_view.append (app_entry); | ||
2797 | 157 | app_entry.show_all (); | ||
2798 | 158 | |||
2799 | 159 | } | ||
2800 | 160 | |||
2801 | 161 | public void show_filtered_apps (string category) { | ||
2802 | 162 | |||
2803 | 163 | switcher.clear_children (); | ||
2804 | 164 | app_view.clear (); | ||
2805 | 165 | |||
2806 | 166 | layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2); | ||
2807 | 167 | foreach (Backend.App app in view.apps[category]) | ||
2808 | 168 | add_app (app); | ||
2809 | 169 | |||
2810 | 170 | switcher.set_active (0); | ||
2811 | 171 | |||
2812 | 172 | layout.move (app_view, 0, 0); | ||
2813 | 173 | current_position = 0; | ||
2814 | 174 | |||
2815 | 175 | } | ||
2816 | 176 | |||
2817 | 177 | public void move_page (int step) { | ||
2818 | 178 | |||
2819 | 179 | debug ("Moving: step = " + step.to_string ()); | ||
2820 | 180 | |||
2821 | 181 | if (step == 0) | ||
2822 | 182 | return; | ||
2823 | 183 | if (step < 0 && current_position >= 0) //Left border | ||
2824 | 184 | return; | ||
2825 | 185 | if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border | ||
2826 | 186 | return; | ||
2827 | 187 | |||
2828 | 188 | int count = 0; | ||
2829 | 189 | int increment = -step*130*(view.columns-1)/10; | ||
2830 | 190 | Timeout.add (30/(view.columns-1), () => { | ||
2831 | 191 | |||
2832 | 192 | if (count >= 10) { | ||
2833 | 193 | current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page | ||
2834 | 194 | layout.move (app_view, current_position, 0); | ||
2835 | 133 | return false; | 195 | return false; |
2836 | 134 | }); | ||
2837 | 135 | |||
2838 | 136 | app_view.new_page.connect ((page) => { | ||
2839 | 137 | |||
2840 | 138 | if (switcher.size == 0) | ||
2841 | 139 | switcher.append ("1"); | ||
2842 | 140 | switcher.append (page); | ||
2843 | 141 | |||
2844 | 142 | /* Prevents pages from changing */ | ||
2845 | 143 | from_category = true; | ||
2846 | 144 | }); | ||
2847 | 145 | |||
2848 | 146 | switcher.active_changed.connect (() => { | ||
2849 | 147 | if (from_category || switcher.active - switcher.old_active == 0) { | ||
2850 | 148 | from_category = false; | ||
2851 | 149 | return; | ||
2852 | 150 | } | ||
2853 | 151 | |||
2854 | 152 | move_page (switcher.active - switcher.old_active); | ||
2855 | 153 | view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page | ||
2856 | 154 | }); | ||
2857 | 155 | |||
2858 | 156 | category_switcher.selected = 0; //Must be after everything else | ||
2859 | 157 | } | ||
2860 | 158 | |||
2861 | 159 | private void add_app (App app) { | ||
2862 | 160 | |||
2863 | 161 | var app_entry = new AppEntry (app); | ||
2864 | 162 | app_entry.app_launched.connect (() => view.hide ()); | ||
2865 | 163 | app_view.append (app_entry); | ||
2866 | 164 | app_entry.show_all (); | ||
2867 | 165 | |||
2868 | 166 | } | ||
2869 | 167 | |||
2870 | 168 | public void show_filtered_apps (string category) { | ||
2871 | 169 | |||
2872 | 170 | switcher.clear_children (); | ||
2873 | 171 | app_view.clear (); | ||
2874 | 172 | |||
2875 | 173 | layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2); | ||
2876 | 174 | foreach (App app in view.apps[category]) | ||
2877 | 175 | add_app (app); | ||
2878 | 176 | |||
2879 | 177 | switcher.set_active (0); | ||
2880 | 178 | |||
2881 | 179 | layout.move (app_view, 0, 0); | ||
2882 | 180 | current_position = 0; | ||
2883 | 181 | |||
2884 | 182 | } | ||
2885 | 183 | |||
2886 | 184 | public void move_page (int step) { | ||
2887 | 185 | |||
2888 | 186 | debug ("Moving: step = " + step.to_string ()); | ||
2889 | 187 | |||
2890 | 188 | if (step == 0) | ||
2891 | 189 | return; | ||
2892 | 190 | if (step < 0 && current_position >= 0) //Left border | ||
2893 | 191 | return; | ||
2894 | 192 | if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border | ||
2895 | 193 | return; | ||
2896 | 194 | |||
2897 | 195 | int count = 0; | ||
2898 | 196 | int increment = -step*130*(view.columns-1)/10; | ||
2899 | 197 | Timeout.add (30/(view.columns-1), () => { | ||
2900 | 198 | |||
2901 | 199 | if (count >= 10) { | ||
2902 | 200 | current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page | ||
2903 | 201 | layout.move (app_view, current_position, 0); | ||
2904 | 202 | return false; | ||
2905 | 203 | } | ||
2906 | 204 | |||
2907 | 205 | current_position += increment; | ||
2908 | 206 | layout.move (app_view, current_position, 0); | ||
2909 | 207 | count++; | ||
2910 | 208 | return true; | ||
2911 | 209 | |||
2912 | 210 | }, Priority.DEFAULT_IDLE); | ||
2913 | 211 | } | ||
2914 | 212 | |||
2915 | 213 | public void show_page_switcher (bool show) { | ||
2916 | 214 | |||
2917 | 215 | if (page_switcher.get_parent () == null) | ||
2918 | 216 | container.attach (page_switcher, 2, 1, 1, 1); | ||
2919 | 217 | |||
2920 | 218 | if (show) { | ||
2921 | 219 | page_switcher.show_all (); | ||
2922 | 220 | view.bottom.hide (); | ||
2923 | 221 | } | 196 | } |
2929 | 222 | else | 197 | |
2930 | 223 | page_switcher.hide (); | 198 | current_position += increment; |
2931 | 224 | 199 | layout.move (app_view, current_position, 0); | |
2932 | 225 | view.searchbar.grab_focus (); | 200 | count++; |
2933 | 226 | 201 | return true; | |
2934 | 202 | |||
2935 | 203 | }, Priority.DEFAULT_IDLE); | ||
2936 | 204 | } | ||
2937 | 205 | |||
2938 | 206 | public void show_page_switcher (bool show) { | ||
2939 | 207 | |||
2940 | 208 | if (page_switcher.get_parent () == null) | ||
2941 | 209 | container.attach (page_switcher, 2, 1, 1, 1); | ||
2942 | 210 | |||
2943 | 211 | if (show) { | ||
2944 | 212 | page_switcher.show_all (); | ||
2945 | 213 | view.bottom.hide (); | ||
2946 | 227 | } | 214 | } |
2947 | 215 | else | ||
2948 | 216 | page_switcher.hide (); | ||
2949 | 217 | |||
2950 | 218 | view.searchbar.grab_focus (); | ||
2951 | 228 | 219 | ||
2952 | 229 | } | 220 | } |
2953 | 230 | 221 | ||
2954 | 231 | 222 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
2960 | 17 | // | 17 | // |
2961 | 18 | 18 | ||
2962 | 19 | using Gtk; | ||
2963 | 20 | |||
2964 | 21 | namespace Slingshot.Widgets { | 19 | namespace Slingshot.Widgets { |
2965 | 22 | 20 | ||
2966 | 23 | struct Page { | 21 | struct Page { |
2967 | @@ -49,7 +47,7 @@ | |||
2968 | 49 | 47 | ||
2969 | 50 | } | 48 | } |
2970 | 51 | 49 | ||
2972 | 52 | public void append (Widget widget) { | 50 | public void append (Gtk.Widget widget) { |
2973 | 53 | 51 | ||
2974 | 54 | update_position (); | 52 | update_position (); |
2975 | 55 | 53 | ||
2976 | @@ -76,7 +74,7 @@ | |||
2977 | 76 | 74 | ||
2978 | 77 | public void clear () { | 75 | public void clear () { |
2979 | 78 | 76 | ||
2981 | 79 | foreach (Widget widget in get_children ()) { | 77 | foreach (Gtk.Widget widget in get_children ()) { |
2982 | 80 | if (widget.get_parent () != null) | 78 | if (widget.get_parent () != null) |
2983 | 81 | remove (widget); | 79 | remove (widget); |
2984 | 82 | widget.destroy (); | 80 | widget.destroy (); |
2985 | @@ -108,7 +106,7 @@ | |||
2986 | 108 | 106 | ||
2987 | 109 | public void fade_all_out () { | 107 | public void fade_all_out () { |
2988 | 110 | 108 | ||
2990 | 111 | foreach (Widget widget in get_children ()) { | 109 | foreach (Gtk.Widget widget in get_children ()) { |
2991 | 112 | ((AppEntry) widget).fade_out (); | 110 | ((AppEntry) widget).fade_out (); |
2992 | 113 | } | 111 | } |
2993 | 114 | 112 | ||
2994 | @@ -116,7 +114,7 @@ | |||
2995 | 116 | 114 | ||
2996 | 117 | public void fade_all_in () { | 115 | public void fade_all_in () { |
2997 | 118 | 116 | ||
2999 | 119 | foreach (Widget widget in get_children ()) { | 117 | foreach (Gtk.Widget widget in get_children ()) { |
3000 | 120 | ((AppEntry) widget).fade_in (); | 118 | ((AppEntry) widget).fade_in (); |
3001 | 121 | } | 119 | } |
3002 | 122 | 120 | ||
3003 | @@ -133,4 +131,4 @@ | |||
3004 | 133 | 131 | ||
3005 | 134 | } | 132 | } |
3006 | 135 | 133 | ||
3008 | 136 | } | 134 | } |
3009 | 137 | \ No newline at end of file | 135 | \ No newline at end of file |
3010 | 138 | 136 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3016 | 17 | // | 17 | // |
3017 | 18 | 18 | ||
3018 | 19 | using Gtk; | ||
3019 | 20 | using Gdk; | ||
3020 | 21 | |||
3021 | 22 | namespace Slingshot.Widgets { | 19 | namespace Slingshot.Widgets { |
3022 | 23 | 20 | ||
3024 | 24 | public class SearchItem : Button { | 21 | public class SearchItem : Gtk.Button { |
3025 | 25 | 22 | ||
3026 | 26 | private Backend.App app; | 23 | private Backend.App app; |
3028 | 27 | private Pixbuf icon; | 24 | private Gdk.Pixbuf icon; |
3029 | 28 | private string icon_name; | 25 | private string icon_name; |
3032 | 29 | private Label name_label; | 26 | private Gtk.Label name_label; |
3033 | 30 | private Label desc_label; | 27 | private Gtk.Label desc_label; |
3034 | 31 | 28 | ||
3035 | 32 | public bool in_box = false; | 29 | public bool in_box = false; |
3036 | 33 | public int icon_size = 64; | 30 | public int icon_size = 64; |
3037 | @@ -40,16 +37,16 @@ | |||
3038 | 40 | icon = app.icon; | 37 | icon = app.icon; |
3039 | 41 | icon_name = app.icon_name; | 38 | icon_name = app.icon_name; |
3040 | 42 | 39 | ||
3042 | 43 | name_label = new Label ("<b><span size=\"larger\">" + fix (app.name) + "</span></b>"); | 40 | name_label = new Gtk.Label ("<b><span size=\"larger\">" + fix (app.name) + "</span></b>"); |
3043 | 44 | name_label.set_ellipsize (Pango.EllipsizeMode.END); | 41 | name_label.set_ellipsize (Pango.EllipsizeMode.END); |
3044 | 45 | name_label.use_markup = true; | 42 | name_label.use_markup = true; |
3045 | 46 | name_label.xalign = 0.0f; | 43 | name_label.xalign = 0.0f; |
3046 | 47 | 44 | ||
3048 | 48 | desc_label = new Label (fix (app.description)); | 45 | desc_label = new Gtk.Label (fix (app.description)); |
3049 | 49 | desc_label.set_ellipsize (Pango.EllipsizeMode.END); | 46 | desc_label.set_ellipsize (Pango.EllipsizeMode.END); |
3050 | 50 | desc_label.xalign = 0.0f; | 47 | desc_label.xalign = 0.0f; |
3051 | 51 | 48 | ||
3053 | 52 | var vbox = new Box (Orientation.VERTICAL, 0); | 49 | var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
3054 | 53 | vbox.homogeneous = false; | 50 | vbox.homogeneous = false; |
3055 | 54 | vbox.pack_start (name_label, false, true, 0); | 51 | vbox.pack_start (name_label, false, true, 0); |
3056 | 55 | vbox.pack_start (desc_label, false, true, 0); | 52 | vbox.pack_start (desc_label, false, true, 0); |
3057 | @@ -60,17 +57,17 @@ | |||
3058 | 60 | } | 57 | } |
3059 | 61 | 58 | ||
3060 | 62 | protected override bool draw (Cairo.Context cr) { | 59 | protected override bool draw (Cairo.Context cr) { |
3062 | 63 | Allocation size; | 60 | Gtk.Allocation size; |
3063 | 64 | get_allocation (out size); | 61 | get_allocation (out size); |
3064 | 65 | 62 | ||
3065 | 66 | base.draw (cr); | 63 | base.draw (cr); |
3066 | 67 | 64 | ||
3068 | 68 | Pixbuf scaled_icon = app.load_icon (icon_size); | 65 | Gdk.Pixbuf scaled_icon = app.load_icon (icon_size); |
3069 | 69 | 66 | ||
3070 | 70 | height_request = icon_size + 10; | 67 | height_request = icon_size + 10; |
3071 | 71 | 68 | ||
3072 | 72 | // Draw icon | 69 | // Draw icon |
3074 | 73 | cairo_set_source_pixbuf (cr, scaled_icon, 74 - icon_size, 5); | 70 | Gdk.cairo_set_source_pixbuf (cr, scaled_icon, 74 - icon_size, 5); |
3075 | 74 | cr.paint (); | 71 | cr.paint (); |
3076 | 75 | 72 | ||
3077 | 76 | return true; | 73 | return true; |
3078 | @@ -81,4 +78,4 @@ | |||
3079 | 81 | } | 78 | } |
3080 | 82 | } | 79 | } |
3081 | 83 | 80 | ||
3083 | 84 | } | 81 | } |
3084 | 85 | \ No newline at end of file | 82 | \ No newline at end of file |
3085 | 86 | 83 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3091 | 17 | // | 17 | // |
3092 | 18 | 18 | ||
3093 | 19 | using Gtk; | ||
3094 | 20 | using Slingshot.Backend; | ||
3095 | 21 | |||
3096 | 22 | namespace Slingshot.Widgets { | 19 | namespace Slingshot.Widgets { |
3097 | 23 | 20 | ||
3099 | 24 | private class SeparatorItem : HSeparator { | 21 | private class SeparatorItem : Gtk.Separator { |
3100 | 22 | public SeparatorItem () { | ||
3101 | 23 | orientation = Gtk.Orientation.HORIZONTAL; | ||
3102 | 24 | } | ||
3103 | 25 | 25 | ||
3104 | 26 | public bool in_box; | 26 | public bool in_box; |
3105 | 27 | 27 | ||
3106 | 28 | } | 28 | } |
3107 | 29 | 29 | ||
3109 | 30 | public class SearchView : VBox { | 30 | public class SearchView : Gtk.Box { |
3110 | 31 | 31 | ||
3112 | 32 | private Gee.HashMap<App, SearchItem> items; | 32 | private Gee.HashMap<Backend.App, SearchItem> items; |
3113 | 33 | private SeparatorItem separator; | 33 | private SeparatorItem separator; |
3114 | 34 | private SearchItem selected_app = null; | 34 | private SearchItem selected_app = null; |
3115 | 35 | 35 | ||
3116 | @@ -63,6 +63,7 @@ | |||
3117 | 63 | private SlingshotView view; | 63 | private SlingshotView view; |
3118 | 64 | 64 | ||
3119 | 65 | public SearchView (SlingshotView parent) { | 65 | public SearchView (SlingshotView parent) { |
3120 | 66 | orientation = Gtk.Orientation.VERTICAL; | ||
3121 | 66 | 67 | ||
3122 | 67 | can_focus = true; | 68 | can_focus = true; |
3123 | 68 | homogeneous = false; | 69 | homogeneous = false; |
3124 | @@ -70,14 +71,14 @@ | |||
3125 | 70 | this.view = parent; | 71 | this.view = parent; |
3126 | 71 | width_request = view.columns * 130; | 72 | width_request = view.columns * 130; |
3127 | 72 | 73 | ||
3129 | 73 | items = new Gee.HashMap<App, SearchItem> (); | 74 | items = new Gee.HashMap<Backend.App, SearchItem> (); |
3130 | 74 | separator = new SeparatorItem (); | 75 | separator = new SeparatorItem (); |
3131 | 75 | 76 | ||
3132 | 76 | } | 77 | } |
3133 | 77 | 78 | ||
3135 | 78 | public void add_apps (Gee.ArrayList<App> apps) { | 79 | public void add_apps (Gee.ArrayList<Backend.App> apps) { |
3136 | 79 | 80 | ||
3138 | 80 | foreach (App app in apps) { | 81 | foreach (Backend.App app in apps) { |
3139 | 81 | var search_item = new SearchItem (app); | 82 | var search_item = new SearchItem (app); |
3140 | 82 | 83 | ||
3141 | 83 | append_app (app, search_item); | 84 | append_app (app, search_item); |
3142 | @@ -86,7 +87,7 @@ | |||
3143 | 86 | 87 | ||
3144 | 87 | } | 88 | } |
3145 | 88 | 89 | ||
3147 | 89 | public void append_app (App app, SearchItem search_item) { | 90 | public void append_app (Backend.App app, SearchItem search_item) { |
3148 | 90 | 91 | ||
3149 | 91 | search_item.button_release_event.connect (() => { | 92 | search_item.button_release_event.connect (() => { |
3150 | 92 | app.launch (); | 93 | app.launch (); |
3151 | @@ -98,7 +99,7 @@ | |||
3152 | 98 | 99 | ||
3153 | 99 | } | 100 | } |
3154 | 100 | 101 | ||
3156 | 101 | public void show_app (App app) { | 102 | public void show_app (Backend.App app) { |
3157 | 102 | 103 | ||
3158 | 103 | if (!(app in items.keys)) { | 104 | if (!(app in items.keys)) { |
3159 | 104 | var search_item = new SearchItem (app); | 105 | var search_item = new SearchItem (app); |
3160 | @@ -128,7 +129,7 @@ | |||
3161 | 128 | 129 | ||
3162 | 129 | } | 130 | } |
3163 | 130 | 131 | ||
3165 | 131 | public void hide_app (App app) { | 132 | public void hide_app (Backend.App app) { |
3166 | 132 | 133 | ||
3167 | 133 | items[app].hide (); | 134 | items[app].hide (); |
3168 | 134 | apps_showed--; | 135 | apps_showed--; |
3169 | @@ -151,7 +152,7 @@ | |||
3170 | 151 | 152 | ||
3171 | 152 | public void add_command (string command) { | 153 | public void add_command (string command) { |
3172 | 153 | 154 | ||
3174 | 154 | var app = new App.from_command (command); | 155 | var app = new Backend.App.from_command (command); |
3175 | 155 | var item = new SearchItem (app); | 156 | var item = new SearchItem (app); |
3176 | 156 | 157 | ||
3177 | 157 | append_app (app, item); | 158 | append_app (app, item); |
3178 | @@ -182,10 +183,10 @@ | |||
3179 | 182 | private void select_nth (int index) { | 183 | private void select_nth (int index) { |
3180 | 183 | 184 | ||
3181 | 184 | if (selected_app != null) | 185 | if (selected_app != null) |
3183 | 185 | selected_app.unset_state_flags (StateFlags.PRELIGHT); | 186 | selected_app.unset_state_flags (Gtk.StateFlags.PRELIGHT); |
3184 | 186 | 187 | ||
3185 | 187 | selected_app = (SearchItem) get_children ().nth_data (index); | 188 | selected_app = (SearchItem) get_children ().nth_data (index); |
3187 | 188 | selected_app.set_state_flags (StateFlags.PRELIGHT, false); | 189 | selected_app.set_state_flags (Gtk.StateFlags.PRELIGHT, false); |
3188 | 189 | 190 | ||
3189 | 190 | } | 191 | } |
3190 | 191 | 192 | ||
3191 | @@ -197,4 +198,4 @@ | |||
3192 | 197 | 198 | ||
3193 | 198 | } | 199 | } |
3194 | 199 | 200 | ||
3196 | 200 | } | 201 | } |
3197 | 201 | \ No newline at end of file | 202 | \ No newline at end of file |
3198 | 202 | 203 | ||
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 | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
3204 | 17 | // | 17 | // |
3205 | 18 | 18 | ||
3320 | 19 | using Gtk; | 19 | public class Slingshot.Widgets.Sidebar : Gtk.TreeView { |
3321 | 20 | 20 | ||
3322 | 21 | namespace Slingshot.Widgets { | 21 | private Gtk.TreeStore store; |
3323 | 22 | 22 | ||
3324 | 23 | public class Sidebar : TreeView { | 23 | private Gtk.TreeIter entry_iter; |
3325 | 24 | 24 | ||
3326 | 25 | private TreeStore store; | 25 | public int cat_size { |
3327 | 26 | 26 | get { | |
3328 | 27 | private TreeIter entry_iter; | 27 | return store.iter_n_children (null); |
3329 | 28 | 28 | } | |
3330 | 29 | public int cat_size { | 29 | } |
3331 | 30 | get { | 30 | |
3332 | 31 | return store.iter_n_children (null); | 31 | private int _selected; |
3333 | 32 | } | 32 | public int selected { |
3334 | 33 | } | 33 | get { |
3335 | 34 | 34 | return _selected; | |
3336 | 35 | private int _selected; | 35 | } |
3337 | 36 | public int selected { | 36 | set { |
3338 | 37 | get { | 37 | if (value >= 0 && value < cat_size) { |
3339 | 38 | return _selected; | 38 | select_nth (value); |
3340 | 39 | } | 39 | _selected = value; |
3341 | 40 | set { | 40 | } |
3342 | 41 | if (value >= 0 && value < cat_size) { | 41 | } |
3343 | 42 | select_nth (value); | 42 | } |
3344 | 43 | _selected = value; | 43 | |
3345 | 44 | } | 44 | private enum Columns { |
3346 | 45 | } | 45 | INT, |
3347 | 46 | } | 46 | TEXT, |
3348 | 47 | 47 | N_COLUMNS | |
3349 | 48 | private enum Columns { | 48 | } |
3350 | 49 | INT, | 49 | |
3351 | 50 | TEXT, | 50 | public signal void selection_changed (string entry_name, int nth); |
3352 | 51 | N_COLUMNS | 51 | |
3353 | 52 | } | 52 | public Sidebar () { |
3354 | 53 | 53 | ||
3355 | 54 | public signal void selection_changed (string entry_name, int nth); | 54 | store = new Gtk.TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string)); |
3356 | 55 | 55 | store.set_sort_column_id (1, Gtk.SortType.ASCENDING); | |
3357 | 56 | public Sidebar () { | 56 | set_model (store); |
3358 | 57 | 57 | ||
3359 | 58 | store = new TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string)); | 58 | set_headers_visible (false); |
3360 | 59 | store.set_sort_column_id (1, Gtk.SortType.ASCENDING); | 59 | set_show_expanders (false); |
3361 | 60 | set_model (store); | 60 | set_level_indentation (8); |
3362 | 61 | 61 | ||
3363 | 62 | set_headers_visible (false); | 62 | set_size_request (145, -1); |
3364 | 63 | set_show_expanders (false); | 63 | get_style_context ().add_class ("sidebar"); |
3365 | 64 | set_level_indentation (8); | 64 | |
3366 | 65 | 65 | var cell = new Gtk.CellRendererText (); | |
3367 | 66 | set_size_request (145, -1); | 66 | cell.wrap_mode = Pango.WrapMode.WORD; |
3368 | 67 | get_style_context ().add_class ("sidebar"); | 67 | cell.wrap_width = 110; |
3369 | 68 | 68 | cell.xpad = 17; | |
3370 | 69 | var cell = new CellRendererText (); | 69 | |
3371 | 70 | cell.wrap_mode = Pango.WrapMode.WORD; | 70 | insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT); |
3372 | 71 | cell.wrap_width = 110; | 71 | |
3373 | 72 | cell.xpad = 17; | 72 | get_selection ().set_mode (Gtk.SelectionMode.SINGLE); |
3374 | 73 | 73 | get_selection ().changed.connect (selection_change); | |
3375 | 74 | insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT); | 74 | |
3376 | 75 | 75 | } | |
3377 | 76 | get_selection ().set_mode (SelectionMode.SINGLE); | 76 | |
3378 | 77 | get_selection ().changed.connect (selection_change); | 77 | public void add_category (string entry_name) { |
3379 | 78 | 78 | ||
3380 | 79 | } | 79 | store.append (out entry_iter, null); |
3381 | 80 | 80 | store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1); | |
3382 | 81 | public void add_category (string entry_name) { | 81 | |
3383 | 82 | 82 | expand_all (); | |
3384 | 83 | store.append (out entry_iter, null); | 83 | |
3385 | 84 | store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1); | 84 | } |
3386 | 85 | 85 | ||
3387 | 86 | expand_all (); | 86 | public void selection_change () { |
3388 | 87 | 87 | ||
3389 | 88 | } | 88 | Gtk.TreeModel model; |
3390 | 89 | 89 | Gtk.TreeIter sel_iter; | |
3391 | 90 | public void selection_change () { | 90 | string name; |
3392 | 91 | 91 | int nth; | |
3393 | 92 | TreeModel model; | 92 | |
3394 | 93 | TreeIter sel_iter; | 93 | if (get_selection ().get_selected (out model, out sel_iter)) { |
3395 | 94 | string name; | 94 | store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name); |
3396 | 95 | int nth; | 95 | _selected = nth; |
3397 | 96 | 96 | selection_changed (name, nth); | |
3398 | 97 | if (get_selection ().get_selected (out model, out sel_iter)) { | 97 | } |
3399 | 98 | store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name); | 98 | |
3400 | 99 | _selected = nth; | 99 | } |
3401 | 100 | selection_changed (name, nth); | 100 | |
3402 | 101 | } | 101 | public bool select_nth (int nth) { |
3403 | 102 | 102 | ||
3404 | 103 | } | 103 | Gtk.TreeIter iter; |
3405 | 104 | 104 | ||
3406 | 105 | public bool select_nth (int nth) { | 105 | if (nth < cat_size) |
3407 | 106 | 106 | store.iter_nth_child (out iter, null, nth); | |
3408 | 107 | TreeIter iter; | 107 | else |
3295 | 108 | |||
3296 | 109 | if (nth < cat_size) | ||
3297 | 110 | store.iter_nth_child (out iter, null, nth); | ||
3298 | 111 | else | ||
3299 | 112 | return false; | ||
3300 | 113 | |||
3301 | 114 | get_selection ().select_iter (iter); | ||
3302 | 115 | return true; | ||
3303 | 116 | |||
3304 | 117 | } | ||
3305 | 118 | |||
3306 | 119 | protected override bool scroll_event (Gdk.EventScroll event) { | ||
3307 | 120 | |||
3308 | 121 | switch (event.direction.to_string ()) { | ||
3309 | 122 | case "GDK_SCROLL_UP": | ||
3310 | 123 | case "GDK_SCROLL_LEFT": | ||
3311 | 124 | selected--; | ||
3312 | 125 | break; | ||
3313 | 126 | case "GDK_SCROLL_DOWN": | ||
3314 | 127 | case "GDK_SCROLL_RIGHT": | ||
3315 | 128 | selected++; | ||
3316 | 129 | break; | ||
3317 | 130 | |||
3318 | 131 | } | ||
3319 | 132 | |||
3409 | 133 | return false; | 108 | return false; |
3410 | 134 | 109 | ||
3411 | 110 | get_selection ().select_iter (iter); | ||
3412 | 111 | return true; | ||
3413 | 112 | |||
3414 | 113 | } | ||
3415 | 114 | |||
3416 | 115 | protected override bool scroll_event (Gdk.EventScroll event) { | ||
3417 | 116 | |||
3418 | 117 | switch (event.direction.to_string ()) { | ||
3419 | 118 | case "GDK_SCROLL_UP": | ||
3420 | 119 | case "GDK_SCROLL_LEFT": | ||
3421 | 120 | selected--; | ||
3422 | 121 | break; | ||
3423 | 122 | case "GDK_SCROLL_DOWN": | ||
3424 | 123 | case "GDK_SCROLL_RIGHT": | ||
3425 | 124 | selected++; | ||
3426 | 125 | break; | ||
3427 | 126 | |||
3428 | 135 | } | 127 | } |
3429 | 136 | 128 | ||
3430 | 129 | return false; | ||
3431 | 130 | |||
3432 | 137 | } | 131 | } |
3433 | 138 | 132 | ||
3434 | 139 | } | 133 | } |