Merge lp:~tintou/slingshot/elementarize into lp:~elementary-pantheon/slingshot/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
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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-12-07 08:28:42 +0000
+++ CMakeLists.txt 2013-12-26 00:13:32 +0000
@@ -6,9 +6,10 @@
66
7project (slingshot)7project (slingshot)
88
9set (APPNAME "${CMAKE_PROJECT_NAME}-launcher")
9set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")10set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
10set (PKGDATADIR "${DATADIR}/slingshot")11set (PKGDATADIR "${DATADIR}/${CMAKE_PROJECT_NAME}")
11set (GETTEXT_PACKAGE "slingshot")12set (GETTEXT_PACKAGE "${CMAKE_PROJECT_NAME}")
12set (RELEASE_NAME "Donatello")13set (RELEASE_NAME "Donatello")
13set (VERSION "0.7.6.1")14set (VERSION "0.7.6.1")
14set (VERSION_INFO "Release")15set (VERSION_INFO "Release")
@@ -34,7 +35,7 @@
34# Slingshot35# Slingshot
3536
36set (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;")37set (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;")
37set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-1.0;")38set (UI_DEPS "gtk+-3.0>=3.2.0;granite;zeitgeist-2.0;")
3839
39find_package (PkgConfig)40find_package (PkgConfig)
40pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)41pkg_check_modules (DEPS REQUIRED "${CORE_DEPS}${UI_DEPS}" gthread-2.0)
@@ -44,7 +45,7 @@
44ensure_vala_version ("0.15.1" MINIMUM)45ensure_vala_version ("0.15.1" MINIMUM)
4546
46include (ValaPrecompile)47include (ValaPrecompile)
47vala_precompile (VALA_C48vala_precompile (VALA_C ${APPNAME}
48 src/Slingshot.vala49 src/Slingshot.vala
49 src/SlingshotView.vala50 src/SlingshotView.vala
50 src/Settings.vala51 src/Settings.vala
@@ -66,7 +67,7 @@
66CUSTOM_VAPIS67CUSTOM_VAPIS
67 vapi/config.vapi68 vapi/config.vapi
68OPTIONS69OPTIONS
69 --thread70 --thread
70 -g71 -g
71)72)
7273
@@ -77,11 +78,11 @@
77link_libraries (${DEPS_LIBRARIES})78link_libraries (${DEPS_LIBRARIES})
78link_directories (${DEPS_LIBRARY_DIRS})79link_directories (${DEPS_LIBRARY_DIRS})
7980
80add_executable (slingshot-launcher ${VALA_C})81add_executable (${APPNAME} ${VALA_C})
81target_link_libraries(slingshot-launcher m)82target_link_libraries(${APPNAME} m)
8283
83# Installation84# Installation
84install (TARGETS slingshot-launcher RUNTIME DESTINATION bin)85install (TARGETS ${APPNAME} RUNTIME DESTINATION bin)
85install (FILES ${applications_menu} DESTINATION /etc/xdg/menus)86install (FILES ${applications_menu} DESTINATION /etc/xdg/menus)
8687
87#88#
@@ -91,4 +92,4 @@
91add_schema ("org.pantheon.desktop.slingshot.gschema.xml")92add_schema ("org.pantheon.desktop.slingshot.gschema.xml")
9293
93# Translations94# Translations
94add_subdirectory (po)95add_subdirectory (po)
95\ No newline at end of file96\ No newline at end of file
9697
=== added file 'cmake/FindGirCompiler.cmake'
--- cmake/FindGirCompiler.cmake 1970-01-01 00:00:00 +0000
+++ cmake/FindGirCompiler.cmake 2013-12-26 00:13:32 +0000
@@ -0,0 +1,56 @@
1##
2# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9#
10# 2. Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR
15# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17# EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24#
25# The views and conclusions contained in the software and documentation are those
26# of the authors and should not be interpreted as representing official policies,
27# either expressed or implied, of Jakob Westhoff
28##
29
30##
31# Find module for the Gir compiler (g-ir-compiler)
32#
33# This module determines wheter a Gir compiler is installed on the current
34# system and where its executable is.
35#
36# Call the module using "find_package(GirCompiler) from within your CMakeLists.txt.
37#
38# The following variables will be set after an invocation:
39#
40# G_IR_COMPILER_FOUND Whether the g-ir-compiler compiler has been found or not
41# G_IR_COMPILER_EXECUTABLE Full path to the g-ir-compiler executable if it has been found
42##
43
44
45# Search for the g-ir-compiler executable in the usual system paths.
46find_program (G_IR_COMPILER_EXECUTABLE
47 NAMES g-ir-compiler)
48
49# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call.
50# Furthermore set G_IR_COMPILER_FOUND to TRUE if the g-ir-compiler has been found (aka.
51# G_IR_COMPILER_EXECUTABLE is set)
52
53include (FindPackageHandleStandardArgs)
54find_package_handle_standard_args (GirCompiler DEFAULT_MSG G_IR_COMPILER_EXECUTABLE)
55
56mark_as_advanced (G_IR_COMPILER_EXECUTABLE)
057
=== removed file 'cmake/Makefile'
--- cmake/Makefile 2011-09-07 10:52:19 +0000
+++ cmake/Makefile 1970-01-01 00:00:00 +0000
@@ -1,286 +0,0 @@
1# CMAKE generated file: DO NOT EDIT!
2# Generated by "Unix Makefiles" Generator, CMake Version 2.8
3
4# Default target executed when no arguments are given to make.
5default_target: all
6.PHONY : default_target
7
8#=============================================================================
9# Special targets provided by cmake.
10
11# Disable implicit rules so canoncical targets will work.
12.SUFFIXES:
13
14# Remove some rules from gmake that .SUFFIXES does not remove.
15SUFFIXES =
16
17.SUFFIXES: .hpux_make_needs_suffix_list
18
19# Suppress display of executed commands.
20$(VERBOSE).SILENT:
21
22# A target that is always out of date.
23cmake_force:
24.PHONY : cmake_force
25
26#=============================================================================
27# Set environment variables for the build.
28
29# The shell in which to execute make rules.
30SHELL = /bin/sh
31
32# The CMake executable.
33CMAKE_COMMAND = /usr/bin/cmake
34
35# The command to remove a file.
36RM = /usr/bin/cmake -E remove -f
37
38# The top-level source directory on which CMake was run.
39CMAKE_SOURCE_DIR = /home/mefrio/Scrivania/cmake
40
41# The top-level build directory on which CMake was run.
42CMAKE_BINARY_DIR = /home/mefrio/Scrivania/cmake/cmake
43
44#=============================================================================
45# Targets provided globally by CMake.
46
47# Special rule for the target edit_cache
48edit_cache:
49 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..."
50 /usr/bin/cmake -i .
51.PHONY : edit_cache
52
53# Special rule for the target edit_cache
54edit_cache/fast: edit_cache
55.PHONY : edit_cache/fast
56
57# Special rule for the target install
58install: preinstall
59 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
60 /usr/bin/cmake -P cmake_install.cmake
61.PHONY : install
62
63# Special rule for the target install
64install/fast: preinstall/fast
65 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
66 /usr/bin/cmake -P cmake_install.cmake
67.PHONY : install/fast
68
69# Special rule for the target install/local
70install/local: preinstall
71 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
72 /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
73.PHONY : install/local
74
75# Special rule for the target install/local
76install/local/fast: install/local
77.PHONY : install/local/fast
78
79# Special rule for the target install/strip
80install/strip: preinstall
81 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
82 /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
83.PHONY : install/strip
84
85# Special rule for the target install/strip
86install/strip/fast: install/strip
87.PHONY : install/strip/fast
88
89# Special rule for the target list_install_components
90list_install_components:
91 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
92.PHONY : list_install_components
93
94# Special rule for the target list_install_components
95list_install_components/fast: list_install_components
96.PHONY : list_install_components/fast
97
98# Special rule for the target rebuild_cache
99rebuild_cache:
100 @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
101 /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
102.PHONY : rebuild_cache
103
104# Special rule for the target rebuild_cache
105rebuild_cache/fast: rebuild_cache
106.PHONY : rebuild_cache/fast
107
108# The main all target
109all: cmake_check_build_system
110 $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles /home/mefrio/Scrivania/cmake/cmake/CMakeFiles/progress.marks
111 $(MAKE) -f CMakeFiles/Makefile2 all
112 $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles 0
113.PHONY : all
114
115# The main clean target
116clean:
117 $(MAKE) -f CMakeFiles/Makefile2 clean
118.PHONY : clean
119
120# The main clean target
121clean/fast: clean
122.PHONY : clean/fast
123
124# Prepare targets for installation.
125preinstall: all
126 $(MAKE) -f CMakeFiles/Makefile2 preinstall
127.PHONY : preinstall
128
129# Prepare targets for installation.
130preinstall/fast:
131 $(MAKE) -f CMakeFiles/Makefile2 preinstall
132.PHONY : preinstall/fast
133
134# clear depends
135depend:
136 $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
137.PHONY : depend
138
139#=============================================================================
140# Target rules for targets named scratch
141
142# Build rule for target.
143scratch: cmake_check_build_system
144 $(MAKE) -f CMakeFiles/Makefile2 scratch
145.PHONY : scratch
146
147# fast build rule for target.
148scratch/fast:
149 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/build
150.PHONY : scratch/fast
151
152src/entry.o: src/entry.c.o
153.PHONY : src/entry.o
154
155# target to build an object file
156src/entry.c.o:
157 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.o
158.PHONY : src/entry.c.o
159
160src/entry.i: src/entry.c.i
161.PHONY : src/entry.i
162
163# target to preprocess a source file
164src/entry.c.i:
165 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.i
166.PHONY : src/entry.c.i
167
168src/entry.s: src/entry.c.s
169.PHONY : src/entry.s
170
171# target to generate assembly for a file
172src/entry.c.s:
173 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.s
174.PHONY : src/entry.c.s
175
176src/main_window.o: src/main_window.c.o
177.PHONY : src/main_window.o
178
179# target to build an object file
180src/main_window.c.o:
181 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.o
182.PHONY : src/main_window.c.o
183
184src/main_window.i: src/main_window.c.i
185.PHONY : src/main_window.i
186
187# target to preprocess a source file
188src/main_window.c.i:
189 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.i
190.PHONY : src/main_window.c.i
191
192src/main_window.s: src/main_window.c.s
193.PHONY : src/main_window.s
194
195# target to generate assembly for a file
196src/main_window.c.s:
197 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.s
198.PHONY : src/main_window.c.s
199
200src/menu.o: src/menu.c.o
201.PHONY : src/menu.o
202
203# target to build an object file
204src/menu.c.o:
205 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.o
206.PHONY : src/menu.c.o
207
208src/menu.i: src/menu.c.i
209.PHONY : src/menu.i
210
211# target to preprocess a source file
212src/menu.c.i:
213 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.i
214.PHONY : src/menu.c.i
215
216src/menu.s: src/menu.c.s
217.PHONY : src/menu.s
218
219# target to generate assembly for a file
220src/menu.c.s:
221 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.s
222.PHONY : src/menu.c.s
223
224src/notebook.o: src/notebook.c.o
225.PHONY : src/notebook.o
226
227# target to build an object file
228src/notebook.c.o:
229 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.o
230.PHONY : src/notebook.c.o
231
232src/notebook.i: src/notebook.c.i
233.PHONY : src/notebook.i
234
235# target to preprocess a source file
236src/notebook.c.i:
237 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.i
238.PHONY : src/notebook.c.i
239
240src/notebook.s: src/notebook.c.s
241.PHONY : src/notebook.s
242
243# target to generate assembly for a file
244src/notebook.c.s:
245 $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.s
246.PHONY : src/notebook.c.s
247
248# Help Target
249help:
250 @echo "The following are some of the valid targets for this Makefile:"
251 @echo "... all (the default if no target is provided)"
252 @echo "... clean"
253 @echo "... depend"
254 @echo "... edit_cache"
255 @echo "... install"
256 @echo "... install/local"
257 @echo "... install/strip"
258 @echo "... list_install_components"
259 @echo "... rebuild_cache"
260 @echo "... scratch"
261 @echo "... src/entry.o"
262 @echo "... src/entry.i"
263 @echo "... src/entry.s"
264 @echo "... src/main_window.o"
265 @echo "... src/main_window.i"
266 @echo "... src/main_window.s"
267 @echo "... src/menu.o"
268 @echo "... src/menu.i"
269 @echo "... src/menu.s"
270 @echo "... src/notebook.o"
271 @echo "... src/notebook.i"
272 @echo "... src/notebook.s"
273.PHONY : help
274
275
276
277#=============================================================================
278# Special targets to cleanup operation of make.
279
280# Special rule to run CMake to check the build system integrity.
281# No rule that depends on this can have commands that come from listfiles
282# because they might be regenerated.
283cmake_check_build_system:
284 $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
285.PHONY : cmake_check_build_system
286
2870
=== added file 'cmake/Tests.cmake'
--- cmake/Tests.cmake 1970-01-01 00:00:00 +0000
+++ cmake/Tests.cmake 2013-12-26 00:13:32 +0000
@@ -0,0 +1,5 @@
1# Test macros for Marlin, feel free to re-use them.
2
3macro(add_test_executable EXE_NAME)
4 add_test(${EXE_NAME} gtester ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME})
5endmacro()
06
=== modified file 'cmake/Translations.cmake' (properties changed: -x to +x)
--- cmake/Translations.cmake 2012-06-06 07:24:11 +0000
+++ cmake/Translations.cmake 2013-12-26 00:13:32 +0000
@@ -36,6 +36,7 @@
3636
37 add_custom_command (TARGET pot COMMAND37 add_custom_command (TARGET pot COMMAND
38 ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot38 ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
39 ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-839 ${VALA_SOURCE} ${C_SOURCE} --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2"
40 --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="N_" --keyword="Q_:1g" --from-code=UTF-8
40 )41 )
41endmacro()42endmacro()
4243
=== modified file 'cmake/ValaPrecompile.cmake'
--- cmake/ValaPrecompile.cmake 2011-09-07 10:52:19 +0000
+++ cmake/ValaPrecompile.cmake 2013-12-26 00:13:32 +0000
@@ -1,5 +1,6 @@
1##1##
2# Copyright 2009-2010 Jakob Westhoff. All rights reserved.2# Copyright 2009-2010 Jakob Westhoff. All rights reserved.
3# Copyright 2012 elementary.
3# 4#
4# Redistribution and use in source and binary forms, with or without5# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:6# modification, are permitted provided that the following conditions are met:
@@ -74,10 +75,18 @@
74# be a header file as well as an internal header file being generated called75# be a header file as well as an internal header file being generated called
75# <provided_name>.h and <provided_name>_internal.h76# <provided_name>.h and <provided_name>_internal.h
76#77#
78# GENERATE_GIR
79# Have the compiler generate a GObject-Introspection repository file with
80# name: <provided_name>.gir. This can be later used to create a binary typelib
81# using the GI compiler.
82#
83# GENERATE_SYMBOLS
84# Output a <provided_name>.symbols file containing all the exported symbols.
85#
77# The following call is a simple example to the vala_precompile macro showing86# The following call is a simple example to the vala_precompile macro showing
78# an example to every of the optional sections:87# an example to every of the optional sections:
79#88#
80# vala_precompile(VALA_C89# vala_precompile(VALA_C mytargetname
81# source1.vala90# source1.vala
82# source2.vala91# source2.vala
83# source3.vala92# source3.vala
@@ -95,14 +104,19 @@
95# myvapi104# myvapi
96# GENERATE_HEADER105# GENERATE_HEADER
97# myheader106# myheader
107# GENERATE_GIR
108# mygir
109# GENERATE_SYMBOLS
110# mysymbols
98# )111# )
99#112#
100# Most important is the variable VALA_C which will contain all the generated c113# Most important is the variable VALA_C which will contain all the generated c
101# file names after the call.114# file names after the call.
102##115##
103116
104macro(vala_precompile output)117macro(vala_precompile output target_name)
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})
119
106 if(ARGS_DIRECTORY)120 if(ARGS_DIRECTORY)
107 set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY})121 set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY})
108 else(ARGS_DIRECTORY)122 else(ARGS_DIRECTORY)
@@ -115,14 +129,29 @@
115 endforeach(pkg ${ARGS_PACKAGES})129 endforeach(pkg ${ARGS_PACKAGES})
116 set(in_files "")130 set(in_files "")
117 set(out_files "")131 set(out_files "")
132 set(out_files_display "")
118 set(${output} "")133 set(${output} "")
134
119 foreach(src ${ARGS_DEFAULT_ARGS})135 foreach(src ${ARGS_DEFAULT_ARGS})
120 list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}")136 string(REGEX MATCH "^/" IS_MATCHED ${src})
137 if(${IS_MATCHED} MATCHES "/")
138 set(src_file_path ${src})
139 else()
140 set(src_file_path ${CMAKE_CURRENT_SOURCE_DIR}/${src})
141 endif()
142 list(APPEND in_files ${src_file_path})
121 string(REPLACE ".vala" ".c" src ${src})143 string(REPLACE ".vala" ".c" src ${src})
122 string(REPLACE ".gs" ".c" src ${src})144 string(REPLACE ".gs" ".c" src ${src})
123 set(out_file "${DIRECTORY}/${src}")145 if(${IS_MATCHED} MATCHES "/")
124 list(APPEND out_files "${DIRECTORY}/${src}")146 get_filename_component(VALA_FILE_NAME ${src} NAME)
147 set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}")
148 list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}")
149 else()
150 set(out_file "${DIRECTORY}/${src}")
151 list(APPEND out_files "${DIRECTORY}/${src}")
152 endif()
125 list(APPEND ${output} ${out_file})153 list(APPEND ${output} ${out_file})
154 list(APPEND out_files_display "${src}")
126 endforeach(src ${ARGS_DEFAULT_ARGS})155 endforeach(src ${ARGS_DEFAULT_ARGS})
127156
128 set(custom_vapi_arguments "")157 set(custom_vapi_arguments "")
@@ -139,7 +168,8 @@
139 set(vapi_arguments "")168 set(vapi_arguments "")
140 if(ARGS_GENERATE_VAPI)169 if(ARGS_GENERATE_VAPI)
141 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi")170 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi")
142 set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi")171 list(APPEND out_files_display "${ARGS_GENERATE_VAPI}.vapi")
172 set(vapi_arguments "--library=${ARGS_GENERATE_VAPI}" "--vapi=${ARGS_GENERATE_VAPI}.vapi")
143173
144 # Header and internal header is needed to generate internal vapi174 # Header and internal header is needed to generate internal vapi
145 if (NOT ARGS_GENERATE_HEADER)175 if (NOT ARGS_GENERATE_HEADER)
@@ -150,26 +180,69 @@
150 set(header_arguments "")180 set(header_arguments "")
151 if(ARGS_GENERATE_HEADER)181 if(ARGS_GENERATE_HEADER)
152 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h")182 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h")
153 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h")183 list(APPEND out_files_display "${ARGS_GENERATE_HEADER}.h")
154 list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h")184 list(APPEND header_arguments "--header=${ARGS_GENERATE_HEADER}.h")
155 list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h")
156 endif(ARGS_GENERATE_HEADER)185 endif(ARGS_GENERATE_HEADER)
157186
158 add_custom_command(OUTPUT ${out_files} 187 set(gir_arguments "")
188 set(gircomp_command "")
189 if(ARGS_GENERATE_GIR)
190 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir")
191 list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir")
192 set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir")
193
194 include (FindGirCompiler)
195 find_package(GirCompiler REQUIRED)
196
197 set(gircomp_command
198 COMMAND
199 ${G_IR_COMPILER_EXECUTABLE}
200 ARGS
201 "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir"
202 -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib")
203 endif(ARGS_GENERATE_GIR)
204
205 set(symbols_arguments "")
206 if(ARGS_GENERATE_SYMBOLS)
207 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_SYMBOLS}.symbols")
208 list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols")
209 set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols")
210 endif(ARGS_GENERATE_SYMBOLS)
211
212 # Workaround for a bug that would make valac run twice. This file is written
213 # after the vala compiler generates C source code.
214 set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp)
215
216 add_custom_command(
217 OUTPUT
218 ${OUTPUT_STAMP}
159 COMMAND 219 COMMAND
160 ${VALA_EXECUTABLE} 220 ${VALA_EXECUTABLE}
161 ARGS 221 ARGS
162 "-C" 222 "-C"
163 ${header_arguments} 223 ${header_arguments}
164 ${vapi_arguments}224 ${vapi_arguments}
225 ${gir_arguments}
226 ${symbols_arguments}
165 "-b" ${CMAKE_CURRENT_SOURCE_DIR} 227 "-b" ${CMAKE_CURRENT_SOURCE_DIR}
166 "-d" ${DIRECTORY} 228 "-d" ${DIRECTORY}
167 ${vala_pkg_opts} 229 ${vala_pkg_opts}
168 ${ARGS_OPTIONS} 230 ${ARGS_OPTIONS}
169 ${in_files} 231 ${in_files}
170 ${custom_vapi_arguments}232 ${custom_vapi_arguments}
233 COMMAND
234 touch
235 ARGS
236 ${OUTPUT_STAMP}
171 DEPENDS 237 DEPENDS
172 ${in_files} 238 ${in_files}
173 ${ARGS_CUSTOM_VAPIS}239 ${ARGS_CUSTOM_VAPIS}
240 COMMENT
241 "Generating ${out_files_display}"
242 ${gircomp_command}
174 )243 )
244
245 # This command will be run twice for some reason (pass a non-empty string to COMMENT
246 # in order to see it). Since valac is not executed from here, this won't be a problem.
247 add_custom_command(OUTPUT ${out_files} DEPENDS ${OUTPUT_STAMP} COMMENT "")
175endmacro(vala_precompile)248endmacro(vala_precompile)
176249
=== modified file 'po/CMakeLists.txt'
--- po/CMakeLists.txt 2011-09-12 14:23:59 +0000
+++ po/CMakeLists.txt 2013-12-26 00:13:32 +0000
@@ -1,8 +1,6 @@
1# Translations1# Translations
2include (Translations)2include (Translations)
3add_translations_directory ("slingshot")3add_translations_directory (${GETTEXT_PACKAGE})
4add_translations_catalog ("slingshot"4add_translations_catalog (${GETTEXT_PACKAGE}
5 ../src/Widgets
6 ../src/Backend
7 ../src5 ../src
8)6)
9\ No newline at end of file7\ No newline at end of file
108
=== modified file 'src/Backend/App.vala'
--- src/Backend/App.vala 2013-08-26 17:11:46 +0000
+++ src/Backend/App.vala 2013-12-26 00:13:32 +0000
@@ -16,143 +16,139 @@
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/>.
17//17//
1818
19namespace Slingshot.Backend {19public class Slingshot.Backend.App : Object {
2020
21 public class App : Object {21 public string name { get; construct set; }
2222 public string description { get; private set; default = ""; }
23 public string name { get; construct set; }23 public string desktop_id { get; construct set; }
24 public string description { get; private set; default = ""; }24 public string exec { get; private set; }
25 public string desktop_id { get; construct set; }25 public string icon_name { get; private set; default = ""; }
26 public string exec { get; private set; }26 public string[] keywords { get; private set;}
27 public string icon_name { get; private set; default = ""; }27 public Gdk.Pixbuf icon { get; private set; }
28 public string[] keywords { get; private set;}28 public double popularity { get; set; }
29 public Gdk.Pixbuf icon { get; private set; }29 public double relevancy { get; set; }
30 public double popularity { get; set; }30 public string desktop_path { get; private set; }
31 public double relevancy { get; set; }31 public string generic_name { get; private set; default = ""; }
32 public string desktop_path { get; private set; }32
33 public string generic_name { get; private set; default = ""; }33 private bool is_command = false;
3434
35 private bool is_command = false;35 public signal void icon_changed ();
3636 public signal void launched (App app);
37 public signal void icon_changed ();37
38 public signal void launched (App app);38 public App (GMenu.TreeEntry entry) {
3939 name = entry.get_display_name ();
40 public App (GMenu.TreeEntry entry) {40 description = entry.get_comment () ?? name;
41 name = entry.get_display_name ();41 exec = entry.get_exec ();
42 description = entry.get_comment () ?? name;42 desktop_id = entry.get_desktop_file_id ();
43 exec = entry.get_exec ();43 icon_name = entry.get_icon () ?? "application-default-icon";
44 desktop_id = entry.get_desktop_file_id ();44 desktop_path = entry.get_desktop_file_path ();
45 icon_name = entry.get_icon () ?? "application-default-icon";45 keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id);
46 desktop_path = entry.get_desktop_file_path ();46 generic_name = entry.get_generic_name ();
47 keywords = Unity.AppInfoManager.get_default ().get_keywords (desktop_id);47
48 generic_name = entry.get_generic_name ();48 update_icon ();
4949 Slingshot.icon_theme.changed.connect (update_icon);
50 update_icon ();50 }
51 Slingshot.icon_theme.changed.connect (update_icon);51
52 }52 public App.from_command (string command) {
5353
54 public App.from_command (string command) {54 name = command;
5555 description = _("Run this command...");
56 name = command;56 exec = command;
57 description = _("Run this command...");57 desktop_id = command;
58 exec = command;58 icon_name = "system-run";
59 desktop_id = command;59
60 icon_name = "system-run";60 is_command = true;
6161
62 is_command = true;62 update_icon ();
6363
64 update_icon ();64 }
6565
66 }66 public void update_icon () {
6767 icon = load_icon (Slingshot.settings.icon_size);
68 public void update_icon () {68 icon_changed ();
69 icon = load_icon (Slingshot.settings.icon_size);69 }
70 icon_changed ();70
71 }71 private delegate void IconLoadFallback ();
7272
73 private delegate void IconLoadFallback ();73 private class IconLoadFallbackMethod {
7474 public unowned IconLoadFallback load_icon;
75 private class IconLoadFallbackMethod {75
76 public unowned IconLoadFallback load_icon;76 public IconLoadFallbackMethod (IconLoadFallback fallback) {
7777 load_icon = fallback;
78 public IconLoadFallbackMethod (IconLoadFallback fallback) {78 }
79 load_icon = fallback;79 }
80 }80
81 }81 public Gdk.Pixbuf load_icon (int size) {
8282 Gdk.Pixbuf icon = null;
83 public Gdk.Pixbuf load_icon (int size) {83 var flags = Gtk.IconLookupFlags.FORCE_SIZE;
84 Gdk.Pixbuf icon = null;84
85 var flags = Gtk.IconLookupFlags.FORCE_SIZE;85 IconLoadFallbackMethod[] fallbacks = {
8686 new IconLoadFallbackMethod (() => {
87 IconLoadFallbackMethod[] fallbacks = {87 try {
88 new IconLoadFallbackMethod (() => {88 icon = Slingshot.icon_theme.load_icon (icon_name, size, flags);
89 try {89 } catch (Error e) {
90 icon = Slingshot.icon_theme.load_icon (icon_name, size, flags);90 warning ("Could not load icon. Falling back to method 2");
91 } catch (Error e) {91 }
92 warning ("Could not load icon. Falling back to method 2");92 }),
93 }93
94 }),94 new IconLoadFallbackMethod (() => {
9595 try {
96 new IconLoadFallbackMethod (() => {96 if (icon_name.last_index_of (".") > 0) {
97 try {97 var name = icon_name[0:icon_name.last_index_of (".")];
98 if (icon_name.last_index_of (".") > 0) {98 icon = Slingshot.icon_theme.load_icon (name, size, flags);
99 var name = icon_name[0:icon_name.last_index_of (".")];99 }
100 icon = Slingshot.icon_theme.load_icon (name, size, flags);100 } catch (Error e) {
101 }101 warning ("Could not load icon. Falling back to method 3");
102 } catch (Error e) {102 }
103 warning ("Could not load icon. Falling back to method 3");103 }),
104 }104
105 }),105 new IconLoadFallbackMethod (() => {
106106 try {
107 new IconLoadFallbackMethod (() => {107 icon = new Gdk.Pixbuf.from_file_at_scale (icon_name, size, size, false);
108 try {108 } catch (Error e) {
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");
110 } catch (Error e) {110 }
111 warning ("Could not load icon. Falling back to method 4");111 }),
112 }112
113 }),113 new IconLoadFallbackMethod (() => {
114114 try {
115 new IconLoadFallbackMethod (() => {115 icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags);
116 try {116 } catch (Error e) {
117 icon = Slingshot.icon_theme.load_icon ("application-default-icon", size, flags);117 warning ("Could not load icon. Falling back to method 5");
118 } catch (Error e) {118 }
119 warning ("Could not load icon. Falling back to method 5");119 }),
120 }120
121 }),121 new IconLoadFallbackMethod (() => {
122122 try {
123 new IconLoadFallbackMethod (() => {123 icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags);
124 try {124 } catch (Error e) {
125 icon = Slingshot.icon_theme.load_icon ("gtk-missing-image", size, flags);125 error ("Could not find a fallback icon to load");
126 } catch (Error e) {126 }
127 error ("Could not find a fallback icon to load");127 })
128 }128 };
129 })129
130 };130 foreach (IconLoadFallbackMethod fallback in fallbacks) {
131131 fallback.load_icon ();
132 foreach (IconLoadFallbackMethod fallback in fallbacks) {132 if (icon != null)
133 fallback.load_icon ();133 break;
134 if (icon != null)134 }
135 break;135
136 }136 return icon;
137137 }
138 return icon;138
139 }139 public void launch () {
140140 try {
141 public void launch () {141 if (is_command) {
142 try {142 debug (@"Launching command: $name");
143 if (is_command) {143 Process.spawn_command_line_async (exec);
144 debug (@"Launching command: $name");144 } else {
145 Process.spawn_command_line_async (exec);145 launched (this); // Emit launched signal
146 } else {146 new DesktopAppInfo (desktop_id).launch (null, null);
147 launched (this); // Emit launched signal147 debug (@"Launching application: $name");
148 new DesktopAppInfo (desktop_id).launch (null, null);148 }
149 debug (@"Launching application: $name");149 } catch (Error e) {
150 }150 warning ("Failed to launch %s: %s", name, exec);
151 } catch (Error e) {151 }
152 warning ("Failed to launch %s: %s", name, exec);
153 }
154 }
155
156 }152 }
157153
158}154}
159155
=== modified file 'src/Backend/AppSystem.vala'
--- src/Backend/AppSystem.vala 2013-08-26 08:45:09 +0000
+++ src/Backend/AppSystem.vala 2013-12-26 00:13:32 +0000
@@ -16,232 +16,224 @@
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/>.
17//17//
1818
19using GLib;19public class Slingshot.Backend.AppSystem : Object {
20using GMenu;20
21using Gee;21 private Gee.ArrayList<GMenu.TreeDirectory> categories = null;
2222 private Gee.HashMap<string, Gee.ArrayList<App>> apps = null;
23namespace Slingshot.Backend {23 private GMenu.Tree apps_menu = null;
2424
25 public class AppSystem : Object {25 private RelevancyService rl_service;
2626
27 private ArrayList<TreeDirectory> categories = null;27 public signal void changed ();
28 private HashMap<string, ArrayList<App>> apps = null;28 private bool index_changed = false;
29 private GMenu.Tree apps_menu = null;29
3030 construct {
31 private RelevancyService rl_service;31
3232 rl_service = new RelevancyService ();
33 public signal void changed ();33 rl_service.update_complete.connect (update_popularity);
34 private bool index_changed = false;34
3535 apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", GMenu.TreeFlags.INCLUDE_EXCLUDED);
36 construct {36 apps_menu.add_monitor ((menu) => {
3737
38 rl_service = new RelevancyService ();38 debug ("Apps menu tree changed. Updating…");
39 rl_service.update_complete.connect (update_popularity);39 index_changed = true;
40
41 apps_menu = GMenu.Tree.lookup ("pantheon-applications.menu", TreeFlags.INCLUDE_EXCLUDED);
42 apps_menu.add_monitor ((menu) => {
43
44 debug ("Apps menu tree changed. Updating…");
45 index_changed = true;
46 update_app_system ();
47 changed ();
48
49 });
50
51 apps_menu.set_sort_key (TreeSortKey.DISPLAY_NAME);
52 update_app_system ();40 update_app_system ();
5341 changed ();
54 }42
5543 });
56 private void update_app_system () {44
5745 apps_menu.set_sort_key (GMenu.TreeSortKey.DISPLAY_NAME);
58 rl_service.refresh_popularity ();46 update_app_system ();
5947
60 update_categories_index ();48 }
61 update_apps ();49
6250 private void update_app_system () {
63 }51
6452 rl_service.refresh_popularity ();
65 private void update_categories_index () {53
6654 update_categories_index ();
67 var root_tree = apps_menu.get_root_directory ();55 update_apps ();
6856
69 if (categories == null || index_changed) {57 }
70 categories = new ArrayList<TreeDirectory> ();58
7159 private void update_categories_index () {
72 foreach (TreeItem item in root_tree.get_contents ()) {60
73 if (item.get_type () == TreeItemType.DIRECTORY)61 var root_tree = apps_menu.get_root_directory ();
74 if (((TreeDirectory) item).get_is_nodisplay () == false)62
75 categories.add ((TreeDirectory) item);63 if (categories == null || index_changed) {
76 }64 categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
77 }65
7866 foreach (GMenu.TreeItem item in root_tree.get_contents ()) {
79 }67 if (item.get_type () == GMenu.TreeItemType.DIRECTORY)
8068 if (((GMenu.TreeDirectory) item).get_is_nodisplay () == false)
81 private void update_popularity () {69 categories.add ((GMenu.TreeDirectory) item);
8270 }
83 foreach (ArrayList<App> category in apps.values)71 }
84 foreach (App app in category)72
85 app.popularity = rl_service.get_app_popularity (app.desktop_id);73 }
86 }74
8775 private void update_popularity () {
88 private void update_apps () {76
8977 foreach (Gee.ArrayList<App> category in apps.values)
90 if (index_changed) {78 foreach (App app in category)
91 apps.clear ();79 app.popularity = rl_service.get_app_popularity (app.desktop_id);
92 apps = null;80 }
93 index_changed = false;81
94 }82 private void update_apps () {
9583
96 if (apps == null) {84 if (index_changed) {
9785 apps.clear ();
98 apps = new HashMap<string, ArrayList<App>> ();86 apps = null;
9987 index_changed = false;
100 foreach (TreeDirectory cat in categories) {88 }
101 apps.set (cat.get_name (), get_apps_by_category (cat));89
102 }90 if (apps == null) {
10391
104 }92 apps = new Gee.HashMap<string, Gee.ArrayList<App>> ();
10593
106 }94 foreach (GMenu.TreeDirectory cat in categories) {
10795 apps.set (cat.get_name (), get_apps_by_category (cat));
108 public ArrayList<TreeDirectory> get_categories () {96 }
10997
110 return categories;98 }
11199
112 }100 }
113101
114 public ArrayList<App> get_apps_by_category (TreeDirectory category) {102 public Gee.ArrayList<GMenu.TreeDirectory> get_categories () {
115103
116 var app_list = new ArrayList<App> ();104 return categories;
117105
118 foreach (TreeItem item in category.get_contents ()) {106 }
119 App app;107
120 switch (item.get_type ()) {108 public Gee.ArrayList<App> get_apps_by_category (GMenu.TreeDirectory category) {
121 case TreeItemType.DIRECTORY:109
122 app_list.add_all (get_apps_by_category ((TreeDirectory) item));110 var app_list = new Gee.ArrayList<App> ();
123 break;111
124 case TreeItemType.ENTRY:112 foreach (GMenu.TreeItem item in category.get_contents ()) {
125 if (is_entry ((TreeEntry) item)) {113 App app;
126 app = new App ((TreeEntry) item);114 switch (item.get_type ()) {
127 app.launched.connect (rl_service.app_launched);115 case GMenu.TreeItemType.DIRECTORY:
128 app_list.add (app);116 app_list.add_all (get_apps_by_category ((GMenu.TreeDirectory) item));
129 }117 break;
130 break;118 case GMenu.TreeItemType.ENTRY:
131 }119 if (is_entry ((GMenu.TreeEntry) item)) {
132 }120 app = new App ((GMenu.TreeEntry) item);
133 return app_list;121 app.launched.connect (rl_service.app_launched);
134122 app_list.add (app);
135 }
136
137 private bool is_entry (TreeEntry entry) {
138
139 if (entry.get_launch_in_terminal () == false
140 && entry.get_is_excluded () == false
141 && entry.get_is_nodisplay () == false) {
142 return true;
143 } else {
144 return false;
145 }
146
147 }
148
149 public HashMap<string, ArrayList<App>> get_apps () {
150
151 return apps;
152
153 }
154
155 public SList<App> get_apps_by_popularity () {
156
157 var sorted_apps = new SList<App> ();
158
159 foreach (ArrayList<App> category in apps.values) {
160 foreach (App app in category) {
161 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity);
162 }
163 }
164
165 return sorted_apps;
166
167 }
168
169 public SList<App> get_apps_by_name () {
170
171 var sorted_apps = new SList<App> ();
172 string[] sorted_apps_execs = {};
173
174 foreach (ArrayList<App> category in apps.values) {
175 foreach (App app in category) {
176 if (!(app.exec in sorted_apps_execs)) {
177 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
178 sorted_apps_execs += app.exec;
179 }123 }
124 break;
125 }
126 }
127 return app_list;
128
129 }
130
131 private bool is_entry (GMenu.TreeEntry entry) {
132
133 if (entry.get_launch_in_terminal () == false
134 && entry.get_is_excluded () == false
135 && entry.get_is_nodisplay () == false) {
136 return true;
137 } else {
138 return false;
139 }
140
141 }
142
143 public Gee.HashMap<string, Gee.ArrayList<App>> get_apps () {
144
145 return apps;
146
147 }
148
149 public SList<App> get_apps_by_popularity () {
150
151 var sorted_apps = new SList<App> ();
152
153 foreach (Gee.ArrayList<App> category in apps.values) {
154 foreach (App app in category) {
155 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity);
156 }
157 }
158
159 return sorted_apps;
160
161 }
162
163 public SList<App> get_apps_by_name () {
164
165 var sorted_apps = new SList<App> ();
166 string[] sorted_apps_execs = {};
167
168 foreach (Gee.ArrayList<App> category in apps.values) {
169 foreach (App app in category) {
170 if (!(app.exec in sorted_apps_execs)) {
171 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
172 sorted_apps_execs += app.exec;
180 }173 }
181 }174 }
182
183 return sorted_apps;
184
185 }175 }
186176
187 public async ArrayList<App> search_results (string search) {177 return sorted_apps;
188178
189 Idle.add (search_results.callback, Priority.HIGH);179 }
190 yield;180
191181 public async Gee.ArrayList<App> search_results (string search) {
192 var filtered = new ArrayList<App> ();182
193183 Idle.add (search_results.callback, Priority.HIGH);
194 /** It's a bit stupid algorithm, simply check if the char is present184 yield;
195 * some of the App values, then assign it a double. This is very simple:185
196 * if an App name coincide with the search string they have obvious the186 var filtered = new Gee.ArrayList<App> ();
197 * same length, then the fraction will be 1.0.187
198 * I've added a small multiplier when matching to a exec name, to give188 /** It's a bit stupid algorithm, simply check if the char is present
199 * more priority to app.name189 * some of the App values, then assign it a double. This is very simple:
200 **/190 * if an App name coincide with the search string they have obvious the
201 string[] sorted_apps_execs = {};191 * same length, then the fraction will be 1.0.
202192 * I've added a small multiplier when matching to a exec name, to give
203 foreach (ArrayList<App> category in apps.values) {193 * more priority to app.name
204 foreach (App app in category) {194 **/
205 if (!(app.exec in sorted_apps_execs)) {195 string[] sorted_apps_execs = {};
206 sorted_apps_execs += app.exec;196
207 if (search in app.name.down ()) {197 foreach (Gee.ArrayList<App> category in apps.values) {
208 if (search == app.name.down ()[0:search.length])198 foreach (App app in category) {
209 app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0199 if (!(app.exec in sorted_apps_execs)) {
210 else200 sorted_apps_execs += app.exec;
211 app.relevancy = app.name.length / search.length - app.popularity;201 if (search in app.name.down ()) {
212 filtered.add (app);202 if (search == app.name.down ()[0:search.length])
213 } else if (search in app.exec.down ()) {203 app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0
214 app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;204 else
215 filtered.add (app);205 app.relevancy = app.name.length / search.length - app.popularity;
216 } else if (search in app.description.down ()) {206 filtered.add (app);
217 app.relevancy = app.description.length / search.length - app.popularity;207 } else if (search in app.exec.down ()) {
218 filtered.add (app);208 app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;
219 } else if (search in app.generic_name.down ()) {209 filtered.add (app);
220 app.relevancy = app.generic_name.length / search.length - app.popularity;210 } else if (search in app.description.down ()) {
221 filtered.add (app);211 app.relevancy = app.description.length / search.length - app.popularity;
222 } else if (app.keywords != null) {212 filtered.add (app);
223 app.relevancy = 0;213 } else if (search in app.generic_name.down ()) {
224 foreach (string keyword in app.keywords) {214 app.relevancy = app.generic_name.length / search.length - app.popularity;
225 foreach (string search_word in search.split (" ")) {215 filtered.add (app);
226 if (search_word in keyword.down ()) {216 } else if (app.keywords != null) {
227 app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity;217 app.relevancy = 0;
228 filtered.add (app);218 foreach (string keyword in app.keywords) {
229 }219 foreach (string search_word in search.split (" ")) {
220 if (search_word in keyword.down ()) {
221 app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity;
222 filtered.add (app);
230 }223 }
231 }224 }
232 }225 }
233 }226 }
234 }227 }
235 }228 }
236229 }
237 filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b));230
238231 filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b));
239 if (filtered.size > 20) {232
240 return (ArrayList<App>) filtered[0:20];233 if (filtered.size > 20) {
241 } else {234 return (Gee.ArrayList<App>) filtered[0:20];
242 return filtered;235 } else {
243 }236 return filtered;
244
245 }237 }
246238
247 }239 }
248240
=== modified file 'src/Backend/DBusService.vala'
--- src/Backend/DBusService.vala 2013-02-11 22:48:50 +0000
+++ src/Backend/DBusService.vala 2013-12-26 00:13:32 +0000
@@ -16,57 +16,54 @@
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/>.
1717
1818
19namespace Slingshot {19public class Slingshot.DBusService : Object {
2020
21 public class DBusService : Object {21 [DBus (name = "org.pantheon.desktop.AppLauncherService")]
2222 private class Service : Object {
23 [DBus (name = "org.pantheon.desktop.AppLauncherService")]23 public signal void visibility_changed (bool launcher_visible);
24 private class Service : Object {24 private Gtk.Widget? view = null;
25 public signal void visibility_changed (bool launcher_visible);25
26 private Gtk.Widget? view = null;26 public Service (Gtk.Widget view) {
2727 this.view = view;
28 public Service (Gtk.Widget view) {28 view.show.connect (on_view_visibility_change);
29 this.view = view;29 view.hide.connect (on_view_visibility_change);
30 view.show.connect (on_view_visibility_change);30 }
31 view.hide.connect (on_view_visibility_change);31
32 }32 internal void on_view_visibility_change () {
3333 debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ());
34 internal void on_view_visibility_change () {34 this.visibility_changed (view.visible);
35 debug ("Visibility changed. Sending visible = %s over DBus", view.visible.to_string ());35 }
36 this.visibility_changed (view.visible);36 }
37 }37
38 }38 private Service? service = null;
3939
40 private Service? service = null;40 public DBusService (SlingshotView view) {
4141 // Own bus name
42 public DBusService (SlingshotView view) {42 // try to register service name in session bus
43 // Own bus name43 Bus.own_name (BusType.SESSION,
44 // try to register service name in session bus44 "org.pantheon.desktop.AppLauncherService",
45 Bus.own_name (BusType.SESSION,45 BusNameOwnerFlags.NONE,
46 "org.pantheon.desktop.AppLauncherService",46 (conn) => { on_bus_aquired (conn, view); },
47 BusNameOwnerFlags.NONE,47 name_acquired_handler,
48 (conn) => { on_bus_aquired (conn, view); },48 () => { critical ("Could not aquire service name"); });
49 name_acquired_handler,49
50 () => { critical ("Could not aquire service name"); });50 }
5151
52 }52 private void on_bus_aquired (DBusConnection connection, SlingshotView view) {
5353 try {
54 private void on_bus_aquired (DBusConnection connection, SlingshotView view) {54 // start service and register it as dbus object
55 try {55 service = new Service (view);
56 // start service and register it as dbus object56 connection.register_object ("/org/pantheon/desktop/AppLauncherService", service);
57 service = new Service (view);57 } catch (IOError e) {
58 connection.register_object ("/org/pantheon/desktop/AppLauncherService", service);58 critical ("Could not register service: %s", e.message);
59 } catch (IOError e) {59 return_if_reached ();
60 critical ("Could not register service: %s", e.message);60 }
61 return_if_reached ();61 }
62 }62
63 }63 private void name_acquired_handler (DBusConnection connection, string name) {
6464 message ("Service registration suceeded");
65 private void name_acquired_handler (DBusConnection connection, string name) {65 return_if_fail (service != null);
66 message ("Service registration suceeded");66 // Emit initial state
67 return_if_fail (service != null);67 service.on_view_visibility_change ();
68 // Emit initial state68 }
69 service.on_view_visibility_change ();69}
70 }
71 }
72}
73\ No newline at end of file70\ No newline at end of file
7471
=== modified file 'src/Backend/RelevancyService.vala'
--- src/Backend/RelevancyService.vala 2013-01-13 16:41:55 +0000
+++ src/Backend/RelevancyService.vala 2013-12-26 00:13:32 +0000
@@ -17,159 +17,164 @@
17//17//
18// Thanks to Synapse Developers for this class18// Thanks to Synapse Developers for this class
1919
20using Zeitgeist;20public class Slingshot.Backend.RelevancyService : Object {
2121
22namespace Slingshot.Backend {22 private Zeitgeist.Log zg_log;
2323 private Zeitgeist.DataSourceRegistry zg_dsr;
24 public class RelevancyService : Object {24 private Gee.HashMap<string, int> app_popularity;
2525 private bool has_datahub_gio_module = false;
26 private Zeitgeist.Log zg_log;26
27 private Zeitgeist.DataSourceRegistry zg_dsr;27 private const float MULTIPLIER = 65535.0f;
28 private Gee.HashMap<string, int> app_popularity;28
29 private bool has_datahub_gio_module = false;29 public signal void update_complete ();
3030
31 private const float MULTIPLIER = 65535.0f;31 public RelevancyService () {
32 32
33 public signal void update_complete ();33 zg_log = new Zeitgeist.Log ();
3434 app_popularity = new Gee.HashMap<string, int> ();
35 public RelevancyService () {35
3636 refresh_popularity ();
37 zg_log = new Zeitgeist.Log ();37 check_data_sources.begin ();
38 app_popularity = new Gee.HashMap<string, int> ();38
3939 Timeout.add_seconds (60*30, refresh_popularity);
40 refresh_popularity ();40
41 check_data_sources.begin ();41 }
4242
43 Timeout.add_seconds (60*30, refresh_popularity);43 private async void check_data_sources () {
4444
45 }45 zg_dsr = new Zeitgeist.DataSourceRegistry ();
4646 try {
47 private async void check_data_sources () {
48
49 zg_dsr = new Zeitgeist.DataSourceRegistry ();
50 var ptr_arr = yield zg_dsr.get_data_sources (null);47 var ptr_arr = yield zg_dsr.get_data_sources (null);
5148
52 for (uint i=0; i < ptr_arr.len; i++) {49 for (uint i=0; i < ptr_arr.length; i++) {
5350
54 unowned Zeitgeist.DataSource ds;51 unowned Zeitgeist.DataSource ds;
55 ds = (Zeitgeist.DataSource) ptr_arr.index (i);52 ds = (Zeitgeist.DataSource) ptr_arr.get (i);
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"
57 && ds.is_enabled ()) {54 && ds.enabled == true) {
5855
59 has_datahub_gio_module = true;56 has_datahub_gio_module = true;
60 break;57 break;
61 }58 }
62 }59 }
60 } catch (Error e) {
61 critical (e.message);
63 }62 }
6463 }
65 public bool refresh_popularity () {64
6665 public bool refresh_popularity () {
66
67 load_application_relevancies.begin ();
68 return true;
69
70 }
71 private void reload_relevancies () {
72
73 Idle.add_full (Priority.LOW, () => {
67 load_application_relevancies.begin ();74 load_application_relevancies.begin ();
68 return true;75 return false;
6976 });
70 }77 }
71 private void reload_relevancies () {78
7279 private async void load_application_relevancies () {
73 Idle.add_full (Priority.LOW, () => {80
74 load_application_relevancies.begin ();81 Idle.add (load_application_relevancies.callback, Priority.HIGH);
75 return false;82 yield;
76 });83
77 }84 int64 end = Zeitgeist.Timestamp.from_now ();
7885 int64 start = end - Zeitgeist.Timestamp.WEEK * 4;
79 private async void load_application_relevancies () {86 Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end);
8087
81 Idle.add (load_application_relevancies.callback, Priority.HIGH);88 var event = new Zeitgeist.Event ();
82 yield;89 event.interpretation = "!" + Zeitgeist.ZG.LEAVE_EVENT;
8390 var subject = new Zeitgeist.Subject ();
84 int64 end = Zeitgeist.Timestamp.now ();91 subject.interpretation = Zeitgeist.NFO.SOFTWARE;
85 int64 start = end - Zeitgeist.Timestamp.WEEK * 4;92 subject.uri = "application://*";
86 Zeitgeist.TimeRange tr = new Zeitgeist.TimeRange (start, end);93 event.add_subject (subject);
8794
88 var event = new Zeitgeist.Event ();95 var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> ();
89 event.set_interpretation ("!" + ZG_LEAVE_EVENT);96 ptr_arr.add (event);
90 var subject = new Zeitgeist.Subject ();97
91 subject.set_interpretation (NFO_SOFTWARE);98 Zeitgeist.ResultSet rs;
92 subject.set_uri ("application://*");99
93 event.add_subject (subject);100 try {
94101
95 var ptr_arr = new PtrArray ();102 rs = yield zg_log.find_events (tr, (owned) ptr_arr,
96 ptr_arr.add (event);103 Zeitgeist.StorageState.ANY,
97104 256,
98 Zeitgeist.ResultSet rs;105 Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS,
99106 null);
100 try {107
101108 app_popularity.clear ();
102 rs = yield zg_log.find_events (tr, (owned) ptr_arr,109 uint size = rs.size ();
103 Zeitgeist.StorageState.ANY,110 uint index = 0;
104 256,111
105 Zeitgeist.ResultType.MOST_POPULAR_SUBJECTS,112 // Zeitgeist (0.6) doesn't have any stats API, so let's approximate
106 null);113
107114 foreach (Zeitgeist.Event e in rs) {
108 app_popularity.clear ();115
109 uint size = rs.size ();116 if (e.num_subjects () <= 0) continue;
110 uint index = 0;117 Zeitgeist.Subject s = e.get_subject (0);
111118
112 // Zeitgeist (0.6) doesn't have any stats API, so let's approximate119 float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0>
113120 float relevancy = 1.0f / Math.powf (index + 1, power);
114 foreach (Zeitgeist.Event e in rs) {121 app_popularity[s.uri] = (int)(relevancy * MULTIPLIER);
115122 index++;
116 if (e.num_subjects () <= 0) continue;123 }
117 Zeitgeist.Subject s = e.get_subject (0);124 update_complete ();
118125 } catch (Error err) {
119 float power = index / (size * 2) + 0.5f; // linearly <0.5, 1.0>126 warning ("%s", err.message);
120 float relevancy = 1.0f / Math.powf (index + 1, power);127 return;
121 app_popularity[s.get_uri ()] = (int)(relevancy * MULTIPLIER);128 }
122 index++;129 }
123 }130
124 update_complete ();131 public float get_app_popularity (string desktop_id) {
125 } catch (Error err) {132
126 warning ("%s", err.message);133 var id = "application://" + desktop_id;
127 return;134
128 }135 if (app_popularity.has_key(id)) {
129 }136 return app_popularity[id] / MULTIPLIER;
130137 }
131 public float get_app_popularity (string desktop_id) {138
132139 return 0.0f;
133 var id = "application://" + desktop_id;140 }
134141
135 if (app_popularity.has_key(id)) {142 public void app_launched (App app) {
136 return app_popularity[id] / MULTIPLIER;143
137 }144 string app_uri = null;
138145 if (app.desktop_id != null) {
139 return 0.0f;146 app_uri = "application://" + app.desktop_id;
140 }147 }
141148
142 public void app_launched (App app) {149 push_app_launch (app_uri, app.name);
143150
144 string app_uri = null;151 // and refresh
145 if (app.desktop_id != null) {152 reload_relevancies ();
146 app_uri = "application://" + app.desktop_id;153 }
147 }154
148155 private void push_app_launch (string app_uri, string? display_name) {
149 push_app_launch (app_uri, app.name);156
150157 message ("Pushing launch event: %s [%s]", app_uri, display_name);
151 // and refresh158 var event = new Zeitgeist.Event ();
152 reload_relevancies ();159 var subject = new Zeitgeist.Subject ();
153 }160
154161 event.actor = "application://synapse.desktop";
155 private void push_app_launch (string app_uri, string? display_name) {162 event.interpretation = Zeitgeist.ZG.ACCESS_EVENT;
156163 event.manifestation = Zeitgeist.ZG.USER_ACTIVITY;
157 message ("Pushing launch event: %s [%s]", app_uri, display_name);164 event.add_subject (subject);
158 var event = new Zeitgeist.Event ();165
159 var subject = new Zeitgeist.Subject ();166 subject.uri = app_uri;
160167 subject.interpretation = Zeitgeist.NFO.SOFTWARE;
161 event.set_actor ("application://synapse.desktop");168 subject.manifestation = Zeitgeist.NFO.SOFTWARE_ITEM;
162 event.set_interpretation (Zeitgeist.ZG_ACCESS_EVENT);169 subject.mimetype = "application/x-desktop";
163 event.set_manifestation (Zeitgeist.ZG_USER_ACTIVITY);170 subject.text = display_name;
164 event.add_subject (subject);171 var ptr_arr = new GLib.GenericArray<Zeitgeist.Event> ();
165172 ptr_arr.add (event);
166 subject.set_uri (app_uri);173
167 subject.set_interpretation (Zeitgeist.NFO_SOFTWARE);174 try {
168 subject.set_manifestation (Zeitgeist.NFO_SOFTWARE_ITEM);175 zg_log.insert_events_no_reply (ptr_arr);
169 subject.set_mimetype ("application/x-desktop");176 } catch (Error e) {
170 subject.set_text (display_name);177 critical (e.message);
171178 }
172 zg_log.insert_events_no_reply (event, null);179 }
173 }180}
174 }
175}
176\ No newline at end of file181\ No newline at end of file
177182
=== modified file 'src/Settings.vala'
--- src/Settings.vala 2013-09-03 21:34:05 +0000
+++ src/Settings.vala 2013-12-26 00:13:32 +0000
@@ -16,34 +16,28 @@
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/>.
17//17//
1818
19using Granite.Services;19public class Slingshot.Settings : Granite.Services.Settings {
2020
21namespace Slingshot {21 protected class GalaSettings : Granite.Services.Settings {
2222
23 public class Settings : Granite.Services.Settings {23 public string hotcorner_topleft { get; set; }
2424
25 protected class GalaSettings : Granite.Services.Settings {25 public GalaSettings () {
2626 base ("org.pantheon.desktop.gala.behavior");
27 public string hotcorner_topleft { get; set; }27 }
2828 }
29 public GalaSettings () {29
30 base ("org.pantheon.desktop.gala.behavior");30 public int columns { get; set; }
31 }31 public int rows { get; set; }
32 }32 public int icon_size { get; set; }
3333 public bool show_category_filter { get; set; }
34 public int columns { get; set; }34 public bool use_category { get; set; }
35 public int rows { get; set; }35 public string screen_resolution { get; set; }
36 public int icon_size { get; set; }36 public GalaSettings gala_settings;
37 public bool show_category_filter { get; set; }37
38 public bool use_category { get; set; }38 public Settings () {
39 public string screen_resolution { get; set; }39 base ("org.pantheon.desktop.slingshot");
40 public GalaSettings gala_settings;40 gala_settings = new GalaSettings ();
41
42 public Settings () {
43 base ("org.pantheon.desktop.slingshot");
44 gala_settings = new GalaSettings ();
45 }
46
47 }41 }
4842
49}43}
5044
=== modified file 'src/Slingshot.vala'
--- src/Slingshot.vala 2013-08-12 22:47:17 +0000
+++ src/Slingshot.vala 2013-12-26 00:13:32 +0000
@@ -16,100 +16,93 @@
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/>.
17//17//
1818
19using Gtk;19public class Slingshot.Slingshot : Granite.Application {
20using Granite;20
2121 private SlingshotView view = null;
22namespace Slingshot {22 public static bool silent = false;
2323 public static bool command_mode = false;
24 public class Slingshot : Granite.Application {24
2525 public static Settings settings { get; private set; default = null; }
26 private SlingshotView view = null;26 //public static CssProvider style_provider { get; private set; default = null; }
27 public static bool silent = false;27 public static Gtk.IconTheme icon_theme { get; set; default = null; }
28 public static bool command_mode = false;28 private DBusService? dbus_service = null;
2929
30 public static Settings settings { get; private set; default = null; }30 construct {
31 //public static CssProvider style_provider { get; private set; default = null; }31
32 public static IconTheme icon_theme { get; set; default = null; }32 build_data_dir = Build.DATADIR;
33 private DBusService? dbus_service = null;33 build_pkg_data_dir = Build.PKGDATADIR;
3434 build_release_name = Build.RELEASE_NAME;
35 construct {35 build_version = Build.VERSION;
3636 build_version_info = Build.VERSION_INFO;
37 build_data_dir = Build.DATADIR;37
38 build_pkg_data_dir = Build.PKGDATADIR;38 program_name = "Slingshot";
39 build_release_name = Build.RELEASE_NAME;39 exec_name = "slingshot-launcher";
40 build_version = Build.VERSION;40 app_copyright = "GPLv3";
41 build_version_info = Build.VERSION_INFO;41 app_icon = "";
4242 app_launcher = "";
43 program_name = "Slingshot";43 app_years = "2011-2012";
44 exec_name = "slingshot-launcher";44 application_id = "net.launchpad.slingshot";
45 app_copyright = "GPLv3";45 main_url = "https://launchpad.net/slingshot";
46 app_icon = "";46 bug_url = "https://bugs.launchpad.net/slingshot";
47 app_launcher = "";47 help_url = "https://answers.launchpad.net/slingshot";
48 app_years = "2011-2012";48 translate_url = "https://translations.launchpad.net/slingshot";
49 application_id = "net.launchpad.slingshot";49
50 main_url = "https://launchpad.net/slingshot";50 about_authors = {"Giulio Collura <random.cpp@gmail.com>",
51 bug_url = "https://bugs.launchpad.net/slingshot";51 "Andrea Basso <andrea@elementaryos.org"};
52 help_url = "https://answers.launchpad.net/slingshot";52 about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>",
53 translate_url = "https://translations.launchpad.net/slingshot";53 "Daniel Foré <bunny@go-docky.com>"};
5454 about_translators = "Launchpad Translators";
55 about_authors = {"Giulio Collura <random.cpp@gmail.com>",55 about_license_type = Gtk.License.GPL_3_0;
56 "Andrea Basso <andrea@elementaryos.org"};56
57 about_artists = {"Harvey Cabaguio 'BassUltra' <harveycabaguio@gmail.com>",57 }
58 "Daniel Foré <bunny@go-docky.com>"};58
59 about_translators = "Launchpad Translators";59 public Slingshot () {
60 about_license_type = License.GPL_3_0;60 settings = new Settings ();
6161 }
62 }62
6363 protected override void activate () {
64 public Slingshot () {64 if (get_windows () == null) {
65 settings = new Settings ();65 view = new SlingshotView ();
66 }66 view.set_application (this);
6767
68 protected override void activate () {68 if (dbus_service == null)
69 if (get_windows () == null) {69 dbus_service = new DBusService (view);
70 view = new SlingshotView ();70
71 view.set_application (this);71 if (!silent) {
7272 //view.move_to_coords (0, 0);
73 if (dbus_service == null)73 view.show_slingshot ();
74 dbus_service = new DBusService (view);74 }
7575 } else {
76 if (!silent) {76 if (view.visible && !silent)
77 //view.move_to_coords (0, 0);77 view.hide ();
78 view.show_slingshot ();78 else
79 }79 view.show_slingshot ();
80 } else {80 }
81 if (view.visible && !silent)81 silent = false;
82 view.hide (); 82 }
83 else83
84 view.show_slingshot ();84 static const OptionEntry[] entries = {
85 }85 { "silent", 's', 0, OptionArg.NONE, ref silent, "Launch Slingshot as a background process without it appearing visually.", null },
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 },
87 }87 { null }
8888 };
89 static const OptionEntry[] entries = {89
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) {
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) {
92 { null }92 var context = new OptionContext ("");
93 };93 context.add_main_entries (entries, "slingshot");
9494 context.add_group (Gtk.get_option_group (true));
95 public static int main (string[] args) {
96 if (args.length > 1) {
97 var context = new OptionContext ("");
98 context.add_main_entries (entries, "slingshot");
99 context.add_group (Gtk.get_option_group (true));
100
101 try {
102 context.parse (ref args);
103 } catch (Error e) {
104 print (e.message + "\n");
105 }
106 }
107 95
108 var app = new Slingshot ();96 try {
10997 context.parse (ref args);
110 return app.run (args);98 } catch (Error e) {
99 print (e.message + "\n");
100 }
111 }101 }
102
103 var app = new Slingshot ();
112104
105 return app.run (args);
113 }106 }
114107
115}108}
116109
=== modified file 'src/SlingshotView.vala'
--- src/SlingshotView.vala 2013-10-24 10:20:42 +0000
+++ src/SlingshotView.vala 2013-12-26 00:13:32 +0000
@@ -16,16 +16,6 @@
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/>.
17//17//
1818
19using Gtk;
20using Gdk;
21using Gee;
22using Cairo;
23using Granite.Widgets;
24using GMenu;
25
26using Slingshot.Widgets;
27using Slingshot.Backend;
28
29namespace Slingshot {19namespace Slingshot {
3020
31 public enum Modality {21 public enum Modality {
@@ -34,18 +24,18 @@
34 SEARCH_VIEW24 SEARCH_VIEW
35 }25 }
3626
37 public class SlingshotView : PopOver {27 public class SlingshotView : Granite.Widgets.PopOver {
3828
39 // Widgets29 // Widgets
40 public Granite.Widgets.SearchBar searchbar;30 public Granite.Widgets.SearchBar searchbar;
41 public Layout view_manager;31 public Gtk.Layout view_manager;
42 public Switcher page_switcher;32 public Widgets.Switcher page_switcher;
43 public ModeButton view_selector;33 public Granite.Widgets.ModeButton view_selector;
4434
45 // Views35 // Views
46 private Widgets.Grid grid_view;36 private Widgets.Grid grid_view;
47 private SearchView search_view;37 private Widgets.SearchView search_view;
48 private CategoryView category_view;38 private Widgets.CategoryView category_view;
4939
50 public Gtk.Grid top;40 public Gtk.Grid top;
51 public Gtk.Grid center;41 public Gtk.Grid center;
@@ -54,9 +44,9 @@
54 public Gtk.Box content_area;44 public Gtk.Box content_area;
55 private Gtk.EventBox event_box;45 private Gtk.EventBox event_box;
5646
57 public AppSystem app_system;47 public Backend.AppSystem app_system;
58 private ArrayList<TreeDirectory> categories;48 private Gee.ArrayList<GMenu.TreeDirectory> categories;
59 public HashMap<string, ArrayList<App>> apps;49 public Gee.HashMap<string, Gee.ArrayList<Backend.App>> apps;
6050
61 private int current_position = 0;51 private int current_position = 0;
62 private int search_view_position = 0;52 private int search_view_position = 0;
@@ -100,9 +90,9 @@
100 // Have the window in the right place90 // Have the window in the right place
101 read_settings (true);91 read_settings (true);
10292
103 Slingshot.icon_theme = IconTheme.get_default ();93 Slingshot.icon_theme = Gtk.IconTheme.get_default ();
10494
105 app_system = new AppSystem ();95 app_system = new Backend.AppSystem ();
10696
107 categories = app_system.get_categories ();97 categories = app_system.get_categories ();
108 apps = app_system.get_apps ();98 apps = app_system.get_apps ();
@@ -148,16 +138,16 @@
148 // Add top bar138 // Add top bar
149 top = new Gtk.Grid ();139 top = new Gtk.Grid ();
150140
151 var top_separator = new Label (""); // A fake label141 var top_separator = new Gtk.Label (""); // A fake label
152 top_separator.set_hexpand(true);142 top_separator.set_hexpand(true);
153143
154 view_selector = new ModeButton ();144 view_selector = new Granite.Widgets.ModeButton ();
155145
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);
157 image.tooltip_text = _("View as Grid");147 image.tooltip_text = _("View as Grid");
158 view_selector.append (image);148 view_selector.append (image);
159149
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);
161 image.tooltip_text = _("View by Category");151 image.tooltip_text = _("View by Category");
162 view_selector.append (image);152 view_selector.append (image);
163153
@@ -179,7 +169,7 @@
179169
180 center = new Gtk.Grid ();170 center = new Gtk.Grid ();
181 // Create the layout which works like view_manager171 // Create the layout which works like view_manager
182 view_manager = new Layout (null, null);172 view_manager = new Gtk.Layout (null, null);
183 view_manager.set_size_request (default_columns * 130, default_rows * 145);173 view_manager.set_size_request (default_columns * 130, default_rows * 145);
184 center.attach (view_manager, 0, 0, 1, 1);174 center.attach (view_manager, 0, 0, 1, 1);
185175
@@ -188,26 +178,26 @@
188 view_manager.put (grid_view, 0, 0);178 view_manager.put (grid_view, 0, 0);
189179
190 // Create the "SEARCH_VIEW"180 // Create the "SEARCH_VIEW"
191 search_view = new SearchView (this);181 search_view = new Widgets.SearchView (this);
192 foreach (ArrayList<App> app_list in apps.values) {182 foreach (Gee.ArrayList<Backend.App> app_list in apps.values) {
193 search_view.add_apps (app_list);183 search_view.add_apps (app_list);
194 }184 }
195 view_manager.put (search_view, -columns * 130, 0);185 view_manager.put (search_view, -columns * 130, 0);
196186
197 // Create the "CATEGORY_VIEW"187 // Create the "CATEGORY_VIEW"
198 category_view = new CategoryView (this);188 category_view = new Widgets.CategoryView (this);
199 view_manager.put (category_view, -columns * 130, 0);189 view_manager.put (category_view, -columns * 130, 0);
200190
201 // Create the page switcher191 // Create the page switcher
202 page_switcher = new Switcher ();192 page_switcher = new Widgets.Switcher ();
203193
204 // A bottom widget to keep the page switcher center194 // A bottom widget to keep the page switcher center
205 bottom = new Gtk.Grid ();195 bottom = new Gtk.Grid ();
206196
207197
208 var bottom_separator1 = new Label (""); // A fake label198 var bottom_separator1 = new Gtk.Label (""); // A fake label
209 bottom_separator1.set_hexpand (true);199 bottom_separator1.set_hexpand (true);
210 var bottom_separator2 = new Label (""); // A fake label200 var bottom_separator2 = new Gtk.Label (""); // A fake label
211 bottom_separator2.set_hexpand (true);201 bottom_separator2.set_hexpand (true);
212 bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label202 bottom.attach (bottom_separator1, 0, 0, 1, 1); // A fake label
213 bottom.attach (page_switcher, 1, 0, 1, 1);203 bottom.attach (page_switcher, 1, 0, 1, 1);
@@ -220,7 +210,7 @@
220 event_box = new Gtk.EventBox ();210 event_box = new Gtk.EventBox ();
221 event_box.add (container);211 event_box.add (container);
222 // Add the container to the dialog's content area212 // Add the container to the dialog's content area
223 content_area = get_content_area () as Box;213 content_area = get_content_area () as Gtk.Box;
224 content_area.pack_start (event_box);214 content_area.pack_start (event_box);
225215
226 if (Slingshot.settings.use_category)216 if (Slingshot.settings.use_category)
@@ -294,7 +284,7 @@
294 //view_manager.draw.connect (this.draw_background);284 //view_manager.draw.connect (this.draw_background);
295285
296 event_box.key_press_event.connect (on_key_press);286 event_box.key_press_event.connect (on_key_press);
297 searchbar.text_changed_pause.connect ((text) => this.search (text));287 searchbar.text_changed_pause.connect ((text) => this.search.begin (text));
298 searchbar.grab_focus ();288 searchbar.grab_focus ();
299289
300 searchbar.activate.connect (() => {290 searchbar.activate.connect (() => {
@@ -302,8 +292,8 @@
302 search_view.launch_selected ();292 search_view.launch_selected ();
303 hide ();293 hide ();
304 } else {294 } else {
305 if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry295 if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry
306 ((AppEntry) get_focus ()).launch_app ();296 ((Widgets.AppEntry) get_focus ()).launch_app ();
307 }297 }
308 });298 });
309299
@@ -433,8 +423,8 @@
433 search_view.launch_selected ();423 search_view.launch_selected ();
434 hide ();424 hide ();
435 } else {425 } else {
436 if (get_focus () as AppEntry != null) // checking the selected widget is an AppEntry426 if (get_focus () as Widgets.AppEntry != null) // checking the selected widget is an AppEntry
437 ((AppEntry)get_focus ()).launch_app ();427 ((Widgets.AppEntry)get_focus ()).launch_app ();
438 }428 }
439 return true;429 return true;
440430
@@ -596,7 +586,7 @@
596 break;586 break;
597587
598 case "Home":588 case "Home":
599 if (searchbar.text.size () > 0) {589 if (searchbar.text.length > 0) {
600 return false;590 return false;
601 }591 }
602592
@@ -609,7 +599,7 @@
609 break;599 break;
610600
611 case "End":601 case "End":
612 if (searchbar.text.size () > 0) {602 if (searchbar.text.length > 0) {
613 return false;603 return false;
614 }604 }
615605
@@ -641,7 +631,7 @@
641631
642 }632 }
643633
644 public override bool scroll_event (EventScroll event) {634 public override bool scroll_event (Gdk.EventScroll event) {
645635
646 switch (event.direction.to_string ()) {636 switch (event.direction.to_string ()) {
647 case "GDK_SCROLL_UP":637 case "GDK_SCROLL_UP":
@@ -820,7 +810,7 @@
820810
821 var filtered = yield app_system.search_results (stripped);811 var filtered = yield app_system.search_results (stripped);
822812
823 foreach (App app in filtered) {813 foreach (Backend.App app in filtered) {
824 search_view.show_app (app);814 search_view.show_app (app);
825 }815 }
826816
@@ -836,9 +826,9 @@
836 page_switcher.append ("1");826 page_switcher.append ("1");
837 page_switcher.set_active (0);827 page_switcher.set_active (0);
838828
839 foreach (App app in app_system.get_apps_by_name ()) {829 foreach (Backend.App app in app_system.get_apps_by_name ()) {
840830
841 var app_entry = new AppEntry (app);831 var app_entry = new Widgets.AppEntry (app);
842 app_entry.app_launched.connect (() => hide ());832 app_entry.app_launched.connect (() => hide ());
843 grid_view.append (app_entry);833 grid_view.append (app_entry);
844 app_entry.show_all ();834 app_entry.show_all ();
@@ -878,7 +868,7 @@
878 }868 }
879869
880 private void normal_move_focus (int delta_column, int delta_row) {870 private void normal_move_focus (int delta_column, int delta_row) {
881 if (get_focus () as AppEntry != null) { // we check if any AppEntry has focus. If it does, we move871 if (get_focus () as Widgets.AppEntry != null) { // we check if any AppEntry has focus. If it does, we move
882 var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists872 var new_focus = grid_view.get_child_at (column_focus + delta_column, row_focus + delta_row); // we check if the new widget exists
883 if (new_focus == null) {873 if (new_focus == null) {
884 if (delta_column <= 0)874 if (delta_column <= 0)
@@ -960,4 +950,4 @@
960 }950 }
961 }951 }
962952
963}953}
964\ No newline at end of file954\ No newline at end of file
965955
=== modified file 'src/Widgets/AppEntry.vala'
--- src/Widgets/AppEntry.vala 2013-02-16 11:56:18 +0000
+++ src/Widgets/AppEntry.vala 2013-12-26 00:13:32 +0000
@@ -16,137 +16,130 @@
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/>.
17//17//
1818
19using Gtk;19public class Slingshot.Widgets.AppEntry : Gtk.Button {
20using Gdk;20
21using Cairo;21 public Gtk.Label app_label;
2222 private Gdk.Pixbuf icon;
23namespace Slingshot.Widgets {23 private Gtk.Box layout;
2424
25 public class AppEntry : Button {25 public string exec_name;
2626 public string app_name;
27 public Label app_label;27 public string desktop_id;
28 private Pixbuf icon;28 public int icon_size;
29 private Box layout;29 public string desktop_path;
3030
31 public string exec_name;31 public signal void app_launched ();
32 public string app_name;32
33 public string desktop_id;33 private double alpha = 1.0;
34 public int icon_size;34 private bool dragging = false; //prevent launching
35 public string desktop_path;35
3636 private Backend.App application;
37 public signal void app_launched ();37
3838 public AppEntry (Backend.App app) {
39 private double alpha = 1.0;39 Gtk.TargetEntry dnd = {"text/uri-list", 0, 0};
40 private bool dragging = false; //prevent launching40 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},
4141 Gdk.DragAction.COPY);
42 private Backend.App application;42
4343 app_paintable = true;
44 public AppEntry (Backend.App app) {44 set_visual (get_screen ().get_rgba_visual());
45 TargetEntry dnd = {"text/uri-list", 0, 0};45 set_size_request (130, 130);
46 Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {dnd},46 desktop_id = app.desktop_id;
47 Gdk.DragAction.COPY);47 desktop_path = app.desktop_path;
4848
49 app_paintable = true;49 application = app;
50 set_visual (get_screen ().get_rgba_visual());50 app_name = app.name;
51 set_size_request (130, 130);51 tooltip_text = app.description;
52 desktop_id = app.desktop_id;52 exec_name = app.exec;
53 desktop_path = app.desktop_path;53 icon_size = Slingshot.settings.icon_size;
5454 icon = app.icon;
55 application = app;55
56 app_name = app.name;56 get_style_context ().add_class ("app");
57 tooltip_text = app.description;57
58 exec_name = app.exec;58 app_label = new Gtk.Label (app_name);
59 icon_size = Slingshot.settings.icon_size;59 app_label.halign = Gtk.Align.CENTER;
60 icon = app.icon;60 app_label.justify = Gtk.Justification.CENTER;
6161 app_label.set_line_wrap (true); // Need a smarter way
62 get_style_context ().add_class ("app");62 app_label.set_single_line_mode (false);
6363 app_label.set_ellipsize (Pango.EllipsizeMode.END);
64 app_label = new Label (app_name);64
65 app_label.halign = Align.CENTER;65 layout = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
66 app_label.justify = Justification.CENTER;66 layout.homogeneous = false;
67 app_label.set_line_wrap (true); // Need a smarter way67
68 app_label.set_single_line_mode (false);68 layout.pack_start (app_label, false, true, 0);
69 app_label.set_ellipsize (Pango.EllipsizeMode.END);69
7070 add (Utils.set_padding (layout, 78, 5, 5, 5));
71 layout = new Box (Orientation.VERTICAL, 0);71
72 layout.homogeneous = false;72 this.clicked.connect (launch_app);
7373
74 layout.pack_start (app_label, false, true, 0);74 this.button_press_event.connect ((e) => {return e.button == 3;});
7575
76 add (Utils.set_padding (layout, 78, 5, 5, 5));76 this.drag_begin.connect ( (ctx) => {
7777 this.dragging = true;
78 this.clicked.connect (launch_app);78 Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0);
7979 });
80 this.button_press_event.connect ((e) => {return e.button == 3;});80 this.drag_end.connect ( () => {
8181 this.dragging = false;
82 this.drag_begin.connect ( (ctx) => {82 });
83 this.dragging = true;83 this.drag_data_get.connect ( (ctx, sel, info, time) => {
84 Gtk.drag_set_icon_pixbuf (ctx, icon, 0, 0);84 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});
85 });85 });
86 this.drag_end.connect ( () => {86
87 this.dragging = false;87 app.icon_changed.connect (queue_draw);
88 });88
89 this.drag_data_get.connect ( (ctx, sel, info, time) => {89 }
90 sel.set_uris ({File.new_for_path (desktop_path).get_uri ()});90
91 });91 protected override bool draw (Cairo.Context cr) {
9292
93 app.icon_changed.connect (queue_draw);93
9494 Gtk.Allocation size;
95 }95 get_allocation (out size);
9696
97 protected override bool draw (Context cr) {97 base.draw (cr);
9898
9999 // Draw icon
100 Allocation size;100 Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10);
101 get_allocation (out size);101 cr.paint_with_alpha (alpha);
102102
103 base.draw (cr);103 return true;
104104
105 // Draw icon105 }
106 Gdk.cairo_set_source_pixbuf (cr, icon, (icon.width - size.width) / -2.0, 10);106
107 cr.paint_with_alpha (alpha);107 public void fade_out () {
108108
109 return true;109 Timeout.add (20, () => {
110110
111 }111 if (alpha <= 0.3) {
112112 queue_draw ();
113 public void fade_out () {113 return false;
114114 }
115 Timeout.add (20, () => {115
116116 alpha -= 0.05;
117 if (alpha <= 0.3) {117 queue_draw ();
118 queue_draw ();118 return true;
119 return false;119
120 }120 });
121121
122 alpha -= 0.05;122 }
123 queue_draw ();123
124 return true;124 public void fade_in () {
125125
126 });126 Timeout.add (20, () => {
127127
128 }128 if (alpha == 1.0) {
129129 queue_draw ();
130 public void fade_in () {130 return false;
131131 }
132 Timeout.add (20, () => {132
133133 alpha += 0.05;
134 if (alpha == 1.0) {134 queue_draw ();
135 queue_draw ();135 return true;
136 return false;136
137 }137 });
138138
139 alpha += 0.05;139 }
140 queue_draw ();140
141 return true;141 public void launch_app () {
142142 application.launch ();
143 });143 app_launched ();
144
145 }
146
147 public void launch_app () {
148 application.launch ();
149 app_launched ();
150 }
151 }144 }
152}145}
153146
=== modified file 'src/Widgets/CategoryView.vala'
--- src/Widgets/CategoryView.vala 2013-08-26 08:45:09 +0000
+++ src/Widgets/CategoryView.vala 2013-12-26 00:13:32 +0000
@@ -16,215 +16,206 @@
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/>.
17//17//
1818
19using Gtk;19public class Slingshot.Widgets.CategoryView : Gtk.EventBox {
20using Gee;20
2121 private Gtk.Grid container;
22using Slingshot.Backend;22 public Sidebar category_switcher;
2323 public Gtk.Separator separator;
24namespace Slingshot.Widgets {24 public Widgets.Grid app_view;
2525 private Gtk.Layout layout;
26 public class CategoryView : EventBox {26 public Switcher switcher;
2727 private SlingshotView view;
28 private Gtk.Grid container;28 private Gtk.Label empty_cat_label;
29 public Sidebar category_switcher;29
30 public VSeparator separator;30 private Gtk.Grid page_switcher;
31 public Widgets.Grid app_view;31
32 private Layout layout;32 private const string ALL_APPLICATIONS = _("All Applications");
33 public Switcher switcher;33 private const string NEW_FILTER = _("Create a new Filter");
34 private SlingshotView view;34 private int current_position = 0;
35 private Label empty_cat_label;35 private bool from_category = false;
3636
37 private Gtk.Grid page_switcher;37 public Gee.HashMap<int, string> category_ids = new Gee.HashMap<int, string> ();
3838
39 private const string ALL_APPLICATIONS = _("All Applications");39 public CategoryView (SlingshotView parent) {
40 private const string NEW_FILTER = _("Create a new Filter");40
41 private int current_position = 0;41 view = parent;
42 private bool from_category = false;42
4343 set_visible_window (false);
44 public HashMap<int, string> category_ids = new HashMap<int, string> ();44 setup_ui ();
4545 setup_sidebar ();
46 public CategoryView (SlingshotView parent) {46 connect_events ();
4747
48 view = parent;48 set_size_request (view.columns*130 + 17, view.view_height);
4949
50 set_visible_window (false);50 }
51 setup_ui ();51
52 setup_sidebar ();52 private void setup_ui () {
53 connect_events ();53 container = new Gtk.Grid ();
5454 separator = new Gtk.Separator (Gtk.Orientation.VERTICAL);
55 set_size_request (view.columns*130 + 17, view.view_height);55
5656 layout = new Gtk.Layout (null, null);
57 }57
5858 app_view = new Widgets.Grid (view.rows, view.columns - 1);
59 private void setup_ui () {59 layout.put (app_view, 0, 0);
60 container = new Gtk.Grid ();60 empty_cat_label = new Gtk.Label ("");
61 separator = new VSeparator ();61 layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2);
6262 layout.set_hexpand (true);
63 layout = new Layout (null, null);63 layout.set_vexpand (true);
6464
65 app_view = new Widgets.Grid (view.rows, view.columns - 1);65 // Create the page switcher
66 layout.put (app_view, 0, 0);66 switcher = new Switcher ();
67 empty_cat_label = new Gtk.Label ("");67
68 layout.put (empty_cat_label, view.columns*130, view.rows * 130 / 2);68 // A bottom widget to keep the page switcher center
69 layout.set_hexpand (true);69 page_switcher = new Gtk.Grid ();
70 layout.set_vexpand (true);70 var bottom_separator1 = new Gtk.Label (""); // A fake label
7171 bottom_separator1.set_hexpand(true);
72 // Create the page switcher72 var bottom_separator2 = new Gtk.Label (""); // A fake label
73 switcher = new Switcher ();73 bottom_separator2.set_hexpand(true);
7474 page_switcher.attach (bottom_separator1, 0, 0, 1, 1);
75 // A bottom widget to keep the page switcher center75 page_switcher.attach (switcher, 1, 0, 1, 1);
76 page_switcher = new Gtk.Grid ();76 page_switcher.attach (bottom_separator2, 2, 0, 1, 1);
77 var bottom_separator1 = new Label (""); // A fake label77
78 bottom_separator1.set_hexpand(true);78 container.attach (separator, 1, 0, 1, 2);
79 var bottom_separator2 = new Label (""); // A fake label79 container.attach (layout, 2, 0, 1, 1);
80 bottom_separator2.set_hexpand(true);80
81 page_switcher.attach (bottom_separator1, 0, 0, 1, 1);81 add (container);
82 page_switcher.attach (switcher, 1, 0, 1, 1);82
83 page_switcher.attach (bottom_separator2, 2, 0, 1, 1);83 }
8484
85 container.attach (separator, 1, 0, 1, 2);85 public void setup_sidebar () {
86 container.attach (layout, 2, 0, 1, 1);86
8787 if (category_switcher != null)
88 add (container);88 category_switcher.destroy ();
8989
90 }90 category_switcher = new Sidebar ();
9191 category_switcher.can_focus = false;
92 public void setup_sidebar () {92
9393 // Fill the sidebar
94 if (category_switcher != null)94 int n = 0;
95 category_switcher.destroy ();95
9696 foreach (string cat_name in view.apps.keys) {
97 category_switcher = new Sidebar ();97 category_ids.set (n, cat_name);
98 category_switcher.can_focus = false;98 category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ());
9999 n++;
100 // Fill the sidebar100 }
101 int n = 0;101
102102 container.attach (category_switcher, 0, 0, 1, 2);
103 foreach (string cat_name in view.apps.keys) {103 category_switcher.selection_changed.connect ((name, nth) => {
104 category_ids.set (n, cat_name);104
105 category_switcher.add_category (GLib.dgettext ("gnome-menus-3.0", cat_name).dup ());105 view.reset_category_focus ();
106 n++;106 string category = category_ids.get (nth);
107 }107 show_filtered_apps (category);
108108 });
109 container.attach (category_switcher, 0, 0, 1, 2);109
110 category_switcher.selection_changed.connect ((name, nth) => {110 category_switcher.show_all ();
111111 }
112 view.reset_category_focus ();112
113 string category = category_ids.get (nth);113 private void connect_events () {
114 show_filtered_apps (category);114
115 });115 layout.scroll_event.connect ((event) => {
116116 switch (event.direction.to_string ()) {
117 category_switcher.show_all ();117 case "GDK_SCROLL_UP":
118 }118 case "GDK_SCROLL_LEFT":
119119 switcher.set_active (switcher.active - 1);
120 private void connect_events () {120 break;
121121 case "GDK_SCROLL_DOWN":
122 layout.scroll_event.connect ((event) => {122 case "GDK_SCROLL_RIGHT":
123 switch (event.direction.to_string ()) {123 switcher.set_active (switcher.active + 1);
124 case "GDK_SCROLL_UP":124 break;
125 case "GDK_SCROLL_LEFT":125 }
126 switcher.set_active (switcher.active - 1);126 return false;
127 break;127 });
128 case "GDK_SCROLL_DOWN":128
129 case "GDK_SCROLL_RIGHT":129 app_view.new_page.connect ((page) => {
130 switcher.set_active (switcher.active + 1);130
131 break;131 if (switcher.size == 0)
132 }132 switcher.append ("1");
133 switcher.append (page);
134
135 /* Prevents pages from changing */
136 from_category = true;
137 });
138
139 switcher.active_changed.connect (() => {
140 if (from_category || switcher.active - switcher.old_active == 0) {
141 from_category = false;
142 return;
143 }
144
145 move_page (switcher.active - switcher.old_active);
146 view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page
147 });
148
149 category_switcher.selected = 0; //Must be after everything else
150 }
151
152 private void add_app (Backend.App app) {
153
154 var app_entry = new AppEntry (app);
155 app_entry.app_launched.connect (() => view.hide ());
156 app_view.append (app_entry);
157 app_entry.show_all ();
158
159 }
160
161 public void show_filtered_apps (string category) {
162
163 switcher.clear_children ();
164 app_view.clear ();
165
166 layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2);
167 foreach (Backend.App app in view.apps[category])
168 add_app (app);
169
170 switcher.set_active (0);
171
172 layout.move (app_view, 0, 0);
173 current_position = 0;
174
175 }
176
177 public void move_page (int step) {
178
179 debug ("Moving: step = " + step.to_string ());
180
181 if (step == 0)
182 return;
183 if (step < 0 && current_position >= 0) //Left border
184 return;
185 if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border
186 return;
187
188 int count = 0;
189 int increment = -step*130*(view.columns-1)/10;
190 Timeout.add (30/(view.columns-1), () => {
191
192 if (count >= 10) {
193 current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page
194 layout.move (app_view, current_position, 0);
133 return false;195 return false;
134 });
135
136 app_view.new_page.connect ((page) => {
137
138 if (switcher.size == 0)
139 switcher.append ("1");
140 switcher.append (page);
141
142 /* Prevents pages from changing */
143 from_category = true;
144 });
145
146 switcher.active_changed.connect (() => {
147 if (from_category || switcher.active - switcher.old_active == 0) {
148 from_category = false;
149 return;
150 }
151
152 move_page (switcher.active - switcher.old_active);
153 view.searchbar.grab_focus (); // this is because otherwise focus isn't the current page
154 });
155
156 category_switcher.selected = 0; //Must be after everything else
157 }
158
159 private void add_app (App app) {
160
161 var app_entry = new AppEntry (app);
162 app_entry.app_launched.connect (() => view.hide ());
163 app_view.append (app_entry);
164 app_entry.show_all ();
165
166 }
167
168 public void show_filtered_apps (string category) {
169
170 switcher.clear_children ();
171 app_view.clear ();
172
173 layout.move (empty_cat_label, view.columns*130, view.rows*130 / 2);
174 foreach (App app in view.apps[category])
175 add_app (app);
176
177 switcher.set_active (0);
178
179 layout.move (app_view, 0, 0);
180 current_position = 0;
181
182 }
183
184 public void move_page (int step) {
185
186 debug ("Moving: step = " + step.to_string ());
187
188 if (step == 0)
189 return;
190 if (step < 0 && current_position >= 0) //Left border
191 return;
192 if (step > 0 && (-current_position) >= ((app_view.get_n_pages () - 1) * app_view.get_page_columns () * 130)) //Right border
193 return;
194
195 int count = 0;
196 int increment = -step*130*(view.columns-1)/10;
197 Timeout.add (30/(view.columns-1), () => {
198
199 if (count >= 10) {
200 current_position += -step*130*(view.columns-1) - 10*increment; //We adjust to end of the page
201 layout.move (app_view, current_position, 0);
202 return false;
203 }
204
205 current_position += increment;
206 layout.move (app_view, current_position, 0);
207 count++;
208 return true;
209
210 }, Priority.DEFAULT_IDLE);
211 }
212
213 public void show_page_switcher (bool show) {
214
215 if (page_switcher.get_parent () == null)
216 container.attach (page_switcher, 2, 1, 1, 1);
217
218 if (show) {
219 page_switcher.show_all ();
220 view.bottom.hide ();
221 }196 }
222 else197
223 page_switcher.hide ();198 current_position += increment;
224199 layout.move (app_view, current_position, 0);
225 view.searchbar.grab_focus ();200 count++;
226201 return true;
202
203 }, Priority.DEFAULT_IDLE);
204 }
205
206 public void show_page_switcher (bool show) {
207
208 if (page_switcher.get_parent () == null)
209 container.attach (page_switcher, 2, 1, 1, 1);
210
211 if (show) {
212 page_switcher.show_all ();
213 view.bottom.hide ();
227 }214 }
215 else
216 page_switcher.hide ();
217
218 view.searchbar.grab_focus ();
228219
229 }220 }
230221
231222
=== modified file 'src/Widgets/Grid.vala'
--- src/Widgets/Grid.vala 2012-08-21 17:02:33 +0000
+++ src/Widgets/Grid.vala 2013-12-26 00:13:32 +0000
@@ -16,8 +16,6 @@
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/>.
17//17//
1818
19using Gtk;
20
21namespace Slingshot.Widgets {19namespace Slingshot.Widgets {
2220
23 struct Page {21 struct Page {
@@ -49,7 +47,7 @@
4947
50 }48 }
5149
52 public void append (Widget widget) {50 public void append (Gtk.Widget widget) {
5351
54 update_position ();52 update_position ();
5553
@@ -76,7 +74,7 @@
7674
77 public void clear () {75 public void clear () {
7876
79 foreach (Widget widget in get_children ()) {77 foreach (Gtk.Widget widget in get_children ()) {
80 if (widget.get_parent () != null)78 if (widget.get_parent () != null)
81 remove (widget);79 remove (widget);
82 widget.destroy ();80 widget.destroy ();
@@ -108,7 +106,7 @@
108106
109 public void fade_all_out () {107 public void fade_all_out () {
110108
111 foreach (Widget widget in get_children ()) {109 foreach (Gtk.Widget widget in get_children ()) {
112 ((AppEntry) widget).fade_out ();110 ((AppEntry) widget).fade_out ();
113 }111 }
114112
@@ -116,7 +114,7 @@
116114
117 public void fade_all_in () {115 public void fade_all_in () {
118116
119 foreach (Widget widget in get_children ()) {117 foreach (Gtk.Widget widget in get_children ()) {
120 ((AppEntry) widget).fade_in ();118 ((AppEntry) widget).fade_in ();
121 }119 }
122120
@@ -133,4 +131,4 @@
133131
134 }132 }
135133
136}134}
137\ No newline at end of file135\ No newline at end of file
138136
=== modified file 'src/Widgets/SearchItem.vala'
--- src/Widgets/SearchItem.vala 2013-08-21 07:34:53 +0000
+++ src/Widgets/SearchItem.vala 2013-12-26 00:13:32 +0000
@@ -16,18 +16,15 @@
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/>.
17//17//
1818
19using Gtk;
20using Gdk;
21
22namespace Slingshot.Widgets {19namespace Slingshot.Widgets {
2320
24 public class SearchItem : Button {21 public class SearchItem : Gtk.Button {
2522
26 private Backend.App app;23 private Backend.App app;
27 private Pixbuf icon;24 private Gdk.Pixbuf icon;
28 private string icon_name;25 private string icon_name;
29 private Label name_label;26 private Gtk.Label name_label;
30 private Label desc_label;27 private Gtk.Label desc_label;
3128
32 public bool in_box = false;29 public bool in_box = false;
33 public int icon_size = 64;30 public int icon_size = 64;
@@ -40,16 +37,16 @@
40 icon = app.icon;37 icon = app.icon;
41 icon_name = app.icon_name;38 icon_name = app.icon_name;
4239
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>");
44 name_label.set_ellipsize (Pango.EllipsizeMode.END);41 name_label.set_ellipsize (Pango.EllipsizeMode.END);
45 name_label.use_markup = true;42 name_label.use_markup = true;
46 name_label.xalign = 0.0f;43 name_label.xalign = 0.0f;
4744
48 desc_label = new Label (fix (app.description));45 desc_label = new Gtk.Label (fix (app.description));
49 desc_label.set_ellipsize (Pango.EllipsizeMode.END);46 desc_label.set_ellipsize (Pango.EllipsizeMode.END);
50 desc_label.xalign = 0.0f;47 desc_label.xalign = 0.0f;
5148
52 var vbox = new Box (Orientation.VERTICAL, 0);49 var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
53 vbox.homogeneous = false;50 vbox.homogeneous = false;
54 vbox.pack_start (name_label, false, true, 0);51 vbox.pack_start (name_label, false, true, 0);
55 vbox.pack_start (desc_label, false, true, 0);52 vbox.pack_start (desc_label, false, true, 0);
@@ -60,17 +57,17 @@
60 }57 }
6158
62 protected override bool draw (Cairo.Context cr) {59 protected override bool draw (Cairo.Context cr) {
63 Allocation size;60 Gtk.Allocation size;
64 get_allocation (out size);61 get_allocation (out size);
6562
66 base.draw (cr);63 base.draw (cr);
6764
68 Pixbuf scaled_icon = app.load_icon (icon_size);65 Gdk.Pixbuf scaled_icon = app.load_icon (icon_size);
6966
70 height_request = icon_size + 10;67 height_request = icon_size + 10;
7168
72 // Draw icon69 // Draw icon
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);
74 cr.paint ();71 cr.paint ();
7572
76 return true;73 return true;
@@ -81,4 +78,4 @@
81 }78 }
82 }79 }
8380
84}81}
85\ No newline at end of file82\ No newline at end of file
8683
=== modified file 'src/Widgets/SearchView.vala'
--- src/Widgets/SearchView.vala 2012-09-09 18:14:52 +0000
+++ src/Widgets/SearchView.vala 2013-12-26 00:13:32 +0000
@@ -16,20 +16,20 @@
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/>.
17//17//
1818
19using Gtk;
20using Slingshot.Backend;
21
22namespace Slingshot.Widgets {19namespace Slingshot.Widgets {
2320
24 private class SeparatorItem : HSeparator {21 private class SeparatorItem : Gtk.Separator {
22 public SeparatorItem () {
23 orientation = Gtk.Orientation.HORIZONTAL;
24 }
2525
26 public bool in_box;26 public bool in_box;
2727
28 }28 }
2929
30 public class SearchView : VBox {30 public class SearchView : Gtk.Box {
3131
32 private Gee.HashMap<App, SearchItem> items;32 private Gee.HashMap<Backend.App, SearchItem> items;
33 private SeparatorItem separator;33 private SeparatorItem separator;
34 private SearchItem selected_app = null;34 private SearchItem selected_app = null;
3535
@@ -63,6 +63,7 @@
63 private SlingshotView view;63 private SlingshotView view;
6464
65 public SearchView (SlingshotView parent) {65 public SearchView (SlingshotView parent) {
66 orientation = Gtk.Orientation.VERTICAL;
6667
67 can_focus = true;68 can_focus = true;
68 homogeneous = false;69 homogeneous = false;
@@ -70,14 +71,14 @@
70 this.view = parent;71 this.view = parent;
71 width_request = view.columns * 130;72 width_request = view.columns * 130;
7273
73 items = new Gee.HashMap<App, SearchItem> ();74 items = new Gee.HashMap<Backend.App, SearchItem> ();
74 separator = new SeparatorItem ();75 separator = new SeparatorItem ();
7576
76 }77 }
7778
78 public void add_apps (Gee.ArrayList<App> apps) {79 public void add_apps (Gee.ArrayList<Backend.App> apps) {
7980
80 foreach (App app in apps) {81 foreach (Backend.App app in apps) {
81 var search_item = new SearchItem (app);82 var search_item = new SearchItem (app);
8283
83 append_app (app, search_item);84 append_app (app, search_item);
@@ -86,7 +87,7 @@
8687
87 }88 }
8889
89 public void append_app (App app, SearchItem search_item) {90 public void append_app (Backend.App app, SearchItem search_item) {
9091
91 search_item.button_release_event.connect (() => {92 search_item.button_release_event.connect (() => {
92 app.launch ();93 app.launch ();
@@ -98,7 +99,7 @@
9899
99 }100 }
100101
101 public void show_app (App app) {102 public void show_app (Backend.App app) {
102103
103 if (!(app in items.keys)) {104 if (!(app in items.keys)) {
104 var search_item = new SearchItem (app);105 var search_item = new SearchItem (app);
@@ -128,7 +129,7 @@
128129
129 }130 }
130131
131 public void hide_app (App app) {132 public void hide_app (Backend.App app) {
132133
133 items[app].hide ();134 items[app].hide ();
134 apps_showed--;135 apps_showed--;
@@ -151,7 +152,7 @@
151152
152 public void add_command (string command) {153 public void add_command (string command) {
153154
154 var app = new App.from_command (command);155 var app = new Backend.App.from_command (command);
155 var item = new SearchItem (app);156 var item = new SearchItem (app);
156157
157 append_app (app, item);158 append_app (app, item);
@@ -182,10 +183,10 @@
182 private void select_nth (int index) {183 private void select_nth (int index) {
183184
184 if (selected_app != null)185 if (selected_app != null)
185 selected_app.unset_state_flags (StateFlags.PRELIGHT);186 selected_app.unset_state_flags (Gtk.StateFlags.PRELIGHT);
186187
187 selected_app = (SearchItem) get_children ().nth_data (index);188 selected_app = (SearchItem) get_children ().nth_data (index);
188 selected_app.set_state_flags (StateFlags.PRELIGHT, false);189 selected_app.set_state_flags (Gtk.StateFlags.PRELIGHT, false);
189190
190 }191 }
191192
@@ -197,4 +198,4 @@
197198
198 }199 }
199200
200}201}
201\ No newline at end of file202\ No newline at end of file
202203
=== modified file 'src/Widgets/Sidebar.vala'
--- src/Widgets/Sidebar.vala 2012-09-15 15:14:52 +0000
+++ src/Widgets/Sidebar.vala 2013-12-26 00:13:32 +0000
@@ -16,124 +16,118 @@
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/>.
17//17//
1818
19using Gtk;19public class Slingshot.Widgets.Sidebar : Gtk.TreeView {
2020
21namespace Slingshot.Widgets {21 private Gtk.TreeStore store;
2222
23 public class Sidebar : TreeView {23 private Gtk.TreeIter entry_iter;
2424
25 private TreeStore store;25 public int cat_size {
2626 get {
27 private TreeIter entry_iter;27 return store.iter_n_children (null);
2828 }
29 public int cat_size {29 }
30 get {30
31 return store.iter_n_children (null);31 private int _selected;
32 }32 public int selected {
33 }33 get {
3434 return _selected;
35 private int _selected;35 }
36 public int selected {36 set {
37 get {37 if (value >= 0 && value < cat_size) {
38 return _selected;38 select_nth (value);
39 }39 _selected = value;
40 set {40 }
41 if (value >= 0 && value < cat_size) {41 }
42 select_nth (value);42 }
43 _selected = value;43
44 }44 private enum Columns {
45 }45 INT,
46 }46 TEXT,
4747 N_COLUMNS
48 private enum Columns {48 }
49 INT,49
50 TEXT,50 public signal void selection_changed (string entry_name, int nth);
51 N_COLUMNS51
52 }52 public Sidebar () {
5353
54 public signal void selection_changed (string entry_name, int nth);54 store = new Gtk.TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string));
5555 store.set_sort_column_id (1, Gtk.SortType.ASCENDING);
56 public Sidebar () {56 set_model (store);
5757
58 store = new TreeStore (Columns.N_COLUMNS, typeof (int), typeof (string));58 set_headers_visible (false);
59 store.set_sort_column_id (1, Gtk.SortType.ASCENDING);59 set_show_expanders (false);
60 set_model (store);60 set_level_indentation (8);
6161
62 set_headers_visible (false);62 set_size_request (145, -1);
63 set_show_expanders (false);63 get_style_context ().add_class ("sidebar");
64 set_level_indentation (8);64
6565 var cell = new Gtk.CellRendererText ();
66 set_size_request (145, -1);66 cell.wrap_mode = Pango.WrapMode.WORD;
67 get_style_context ().add_class ("sidebar");67 cell.wrap_width = 110;
6868 cell.xpad = 17;
69 var cell = new CellRendererText ();69
70 cell.wrap_mode = Pango.WrapMode.WORD;70 insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT);
71 cell.wrap_width = 110;71
72 cell.xpad = 17;72 get_selection ().set_mode (Gtk.SelectionMode.SINGLE);
7373 get_selection ().changed.connect (selection_change);
74 insert_column_with_attributes (-1, "Filters", cell, "markup", Columns.TEXT);74
7575 }
76 get_selection ().set_mode (SelectionMode.SINGLE);76
77 get_selection ().changed.connect (selection_change);77 public void add_category (string entry_name) {
7878
79 }79 store.append (out entry_iter, null);
8080 store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1);
81 public void add_category (string entry_name) {81
8282 expand_all ();
83 store.append (out entry_iter, null);83
84 store.set (entry_iter, Columns.INT, cat_size - 1, Columns.TEXT, Markup.escape_text (entry_name), -1);84 }
8585
86 expand_all ();86 public void selection_change () {
8787
88 }88 Gtk.TreeModel model;
8989 Gtk.TreeIter sel_iter;
90 public void selection_change () {90 string name;
9191 int nth;
92 TreeModel model;92
93 TreeIter sel_iter;93 if (get_selection ().get_selected (out model, out sel_iter)) {
94 string name;94 store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name);
95 int nth;95 _selected = nth;
9696 selection_changed (name, nth);
97 if (get_selection ().get_selected (out model, out sel_iter)) {97 }
98 store.get (sel_iter, Columns.INT, out nth, Columns.TEXT, out name);98
99 _selected = nth;99 }
100 selection_changed (name, nth);100
101 }101 public bool select_nth (int nth) {
102102
103 }103 Gtk.TreeIter iter;
104104
105 public bool select_nth (int nth) {105 if (nth < cat_size)
106106 store.iter_nth_child (out iter, null, nth);
107 TreeIter iter;107 else
108
109 if (nth < cat_size)
110 store.iter_nth_child (out iter, null, nth);
111 else
112 return false;
113
114 get_selection ().select_iter (iter);
115 return true;
116
117 }
118
119 protected override bool scroll_event (Gdk.EventScroll event) {
120
121 switch (event.direction.to_string ()) {
122 case "GDK_SCROLL_UP":
123 case "GDK_SCROLL_LEFT":
124 selected--;
125 break;
126 case "GDK_SCROLL_DOWN":
127 case "GDK_SCROLL_RIGHT":
128 selected++;
129 break;
130
131 }
132
133 return false;108 return false;
134109
110 get_selection ().select_iter (iter);
111 return true;
112
113 }
114
115 protected override bool scroll_event (Gdk.EventScroll event) {
116
117 switch (event.direction.to_string ()) {
118 case "GDK_SCROLL_UP":
119 case "GDK_SCROLL_LEFT":
120 selected--;
121 break;
122 case "GDK_SCROLL_DOWN":
123 case "GDK_SCROLL_RIGHT":
124 selected++;
125 break;
126
135 }127 }
136128
129 return false;
130
137 }131 }
138132
139}133}

Subscribers

People subscribed via source and target branches