Merge lp:~charlesk/indicator-display/add-rotation-lock into lp:indicator-display/14.10
- add-rotation-lock
- Merge into trunk.14.10
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 16 |
Merged at revision: | 2 |
Proposed branch: | lp:~charlesk/indicator-display/add-rotation-lock |
Merge into: | lp:indicator-display/14.10 |
Diff against target: |
1576 lines (+1426/-0) 29 files modified
CMakeLists.txt (+72/-0) cmake/FindGMock.cmake (+10/-0) cmake/GCov.cmake (+51/-0) cmake/GdbusCodegen.cmake (+36/-0) cmake/Translations.cmake (+37/-0) data/CMakeLists.txt (+74/-0) data/com.canonical.indicator.rotation_lock (+11/-0) data/indicator-display.conf.in (+9/-0) data/indicator-display.desktop.in (+9/-0) data/indicator-display.upstart.desktop.in (+9/-0) debian/changelog (+6/-0) debian/compat (+1/-0) debian/control (+34/-0) debian/copyright (+21/-0) debian/rules (+10/-0) po/CMakeLists.txt (+3/-0) po/POTFILES.in (+1/-0) src/CMakeLists.txt (+29/-0) src/exporter.cpp (+217/-0) src/exporter.h (+40/-0) src/indicator.h (+88/-0) src/main.cpp (+62/-0) src/rotation-lock.cpp (+197/-0) src/rotation-lock.h (+42/-0) tests/CMakeLists.txt (+35/-0) tests/glib-fixture.h (+143/-0) tests/gtestdbus-fixture.h (+102/-0) tests/manual (+16/-0) tests/test-rotation-lock.cpp (+61/-0) |
To merge this branch: | bzr merge lp:~charlesk/indicator-display/add-rotation-lock |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+231663@code.launchpad.net |
Commit message
Add a rotation lock indicator.
Description of the change
Add a rotation lock indicator.
Note, for testing on the phone without unity-system-
$ gsettings set com.ubuntu.
$ gsettings set com.ubuntu.
Enabling/disabling lock with this method should have the same results as in the indicator-
PS Jenkins bot (ps-jenkins) wrote : | # |
- 9. By Charles Kerr
-
remove url-dispatcher dependency.
- 10. By Charles Kerr
-
add cmake/ directory
Charles Kerr (charlesk) wrote : | # |
aha, --split is the bzr-bd argument I was looking for to generate a local tarball since there's not one uploaded yet :)
output of dpkg -c:
./
./usr/
./usr/share/
./usr/
./usr/
./usr/
./usr/
./usr/
./usr/
./usr/share/doc/
./usr/
./usr/
./usr/
./usr/share/unity/
./usr/
./usr/
./usr/lib/
./usr/
./usr/
./usr/
./etc/
./etc/xdg/
./etc/
./etc/
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:9
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:8
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 11. By Charles Kerr
-
unit tests passing on desktop and phone, but not in jenkins -- adding gsettings-
ubuntu- schemas to build-depends.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:10
http://
Executed test runs:
FAILURE: http://
None: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:8
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:11
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Ted Gould (ted) wrote : | # |
A few cleanup things.
Charles Kerr (charlesk) wrote : | # |
Responded inline
- 12. By Charles Kerr
-
in debian/control, make the Description more informative
- 13. By Charles Kerr
-
fix copy-paste error
- 14. By Charles Kerr
-
in src/exporter.cpp, use G_DBUS_
NAME_OWNER_ FLAGS_NONE when owning the busname
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:14
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Ted Gould (ted) wrote : | # |
So, I swear that I'm not trying to be a jerk, but the description is too long now :-) From Lintian:
W: indicator-display: description-
E: indicator-display: extended-
Also if you add a default.conf to your .bzr-builddeb directory to enable split mode it'll build with "bzr bd" right out of the box.
- 15. By Charles Kerr
-
in control/debian, split Description into a shorter description plus an extended description.
- 16. By Charles Kerr
-
in debian/control, bump Standards-Version from 3.9.4 to 3.9.5 to make lintian happy
Charles Kerr (charlesk) wrote : | # |
:-)
I've revised the description and extended-
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:16
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Ted Gould (ted) : | # |
Preview Diff
1 | === added file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3 | +++ CMakeLists.txt 2014-08-22 00:07:37 +0000 | |||
4 | @@ -0,0 +1,72 @@ | |||
5 | 1 | project (indicator-display) | ||
6 | 2 | cmake_minimum_required (VERSION 2.8.9) | ||
7 | 3 | |||
8 | 4 | list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | ||
9 | 5 | |||
10 | 6 | set (PROJECT_VERSION "14.10.0") | ||
11 | 7 | set (PACKAGE ${CMAKE_PROJECT_NAME}) | ||
12 | 8 | set (GETTEXT_PACKAGE indicator-display) | ||
13 | 9 | add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" | ||
14 | 10 | -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}") | ||
15 | 11 | |||
16 | 12 | set (SERVICE_LIB ${PACKAGE}) | ||
17 | 13 | set (SERVICE_EXEC "${PACKAGE}-service") | ||
18 | 14 | |||
19 | 15 | option (enable_tests "Build the package's automatic tests." ON) | ||
20 | 16 | option (enable_lcov "Generate lcov code coverage reports." ON) | ||
21 | 17 | |||
22 | 18 | ## | ||
23 | 19 | ## GNU standard paths | ||
24 | 20 | ## | ||
25 | 21 | include (GNUInstallDirs) | ||
26 | 22 | if (EXISTS "/etc/debian_version") # Workaround for libexecdir on debian | ||
27 | 23 | set (CMAKE_INSTALL_LIBEXECDIR "${CMAKE_INSTALL_LIBDIR}") | ||
28 | 24 | set (CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_FULL_LIBDIR}") | ||
29 | 25 | endif () | ||
30 | 26 | set (CMAKE_INSTALL_PKGLIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}") | ||
31 | 27 | set (CMAKE_INSTALL_FULL_PKGLIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}") | ||
32 | 28 | |||
33 | 29 | ## | ||
34 | 30 | ## Check for prerequisites | ||
35 | 31 | ## | ||
36 | 32 | |||
37 | 33 | find_package (PkgConfig REQUIRED) | ||
38 | 34 | |||
39 | 35 | include (FindPkgConfig) | ||
40 | 36 | pkg_check_modules (SERVICE_DEPS REQUIRED | ||
41 | 37 | gio-unix-2.0>=2.36 | ||
42 | 38 | glib-2.0>=2.36) | ||
43 | 39 | include_directories (SYSTEM ${SERVICE_DEPS_INCLUDE_DIRS}) | ||
44 | 40 | |||
45 | 41 | ## | ||
46 | 42 | ## | ||
47 | 43 | ## | ||
48 | 44 | |||
49 | 45 | set (CMAKE_INCLUDE_CURRENT_DIR OFF) | ||
50 | 46 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}) | ||
51 | 47 | |||
52 | 48 | # set the compiler warnings | ||
53 | 49 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
54 | 50 | set (CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Weverything -Wno-c++98-compat") | ||
55 | 51 | else() | ||
56 | 52 | set (CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Wall -Wextra -Wpedantic") | ||
57 | 53 | endif() | ||
58 | 54 | set (CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Wno-missing-field-initializers") # GActionEntry | ||
59 | 55 | |||
60 | 56 | # testing & coverage | ||
61 | 57 | if (${enable_tests}) | ||
62 | 58 | set (GTEST_SOURCE_DIR /usr/src/gtest/src) | ||
63 | 59 | set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..) | ||
64 | 60 | set (GTEST_LIBS -lpthread) | ||
65 | 61 | enable_testing () | ||
66 | 62 | if (${enable_lcov}) | ||
67 | 63 | include(GCov) | ||
68 | 64 | endif () | ||
69 | 65 | endif () | ||
70 | 66 | |||
71 | 67 | add_subdirectory (src) | ||
72 | 68 | add_subdirectory (data) | ||
73 | 69 | add_subdirectory (po) | ||
74 | 70 | if (${enable_tests}) | ||
75 | 71 | add_subdirectory (tests) | ||
76 | 72 | endif () | ||
77 | 0 | 73 | ||
78 | === added directory 'cmake' | |||
79 | === added file 'cmake/FindGMock.cmake' | |||
80 | --- cmake/FindGMock.cmake 1970-01-01 00:00:00 +0000 | |||
81 | +++ cmake/FindGMock.cmake 2014-08-22 00:07:37 +0000 | |||
82 | @@ -0,0 +1,10 @@ | |||
83 | 1 | # Build with system gmock and embedded gtest | ||
84 | 2 | set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory") | ||
85 | 3 | set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") | ||
86 | 4 | set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") | ||
87 | 5 | |||
88 | 6 | add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") | ||
89 | 7 | |||
90 | 8 | set(GTEST_LIBRARIES gtest) | ||
91 | 9 | set(GTEST_MAIN_LIBRARIES gtest_main) | ||
92 | 10 | set(GMOCK_LIBRARIES gmock gmock_main) | ||
93 | 0 | 11 | ||
94 | === added file 'cmake/GCov.cmake' | |||
95 | --- cmake/GCov.cmake 1970-01-01 00:00:00 +0000 | |||
96 | +++ cmake/GCov.cmake 2014-08-22 00:07:37 +0000 | |||
97 | @@ -0,0 +1,51 @@ | |||
98 | 1 | if (CMAKE_BUILD_TYPE MATCHES coverage) | ||
99 | 2 | set(GCOV_FLAGS "${GCOV_FLAGS} --coverage") | ||
100 | 3 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCOV_FLAGS}") | ||
101 | 4 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GCOV_FLAGS}") | ||
102 | 5 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCOV_FLAGS}") | ||
103 | 6 | set(GCOV_LIBS ${GCOV_LIBS} gcov) | ||
104 | 7 | |||
105 | 8 | find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") | ||
106 | 9 | if (NOT GCOVR_EXECUTABLE) | ||
107 | 10 | message(STATUS "Gcovr binary was not found, can not generate XML coverage info.") | ||
108 | 11 | else () | ||
109 | 12 | message(STATUS "Gcovr found, can generate XML coverage info.") | ||
110 | 13 | add_custom_target (coverage-xml | ||
111 | 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
112 | 15 | COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" -x -r "${CMAKE_SOURCE_DIR}" | ||
113 | 16 | --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml) | ||
114 | 17 | endif() | ||
115 | 18 | |||
116 | 19 | find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin") | ||
117 | 20 | find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT}) | ||
118 | 21 | if (NOT LCOV_EXECUTABLE) | ||
119 | 22 | message(STATUS "Lcov binary was not found, can not generate HTML coverage info.") | ||
120 | 23 | else () | ||
121 | 24 | if(NOT GENHTML_EXECUTABLE) | ||
122 | 25 | message(STATUS "Genthml binary not found, can not generate HTML coverage info.") | ||
123 | 26 | else() | ||
124 | 27 | message(STATUS "Lcov and genhtml found, can generate HTML coverage info.") | ||
125 | 28 | add_custom_target (coverage-html | ||
126 | 29 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
127 | 30 | COMMAND "${CMAKE_CTEST_COMMAND}" --force-new-ctest-process --verbose | ||
128 | 31 | COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture | ${CMAKE_SOURCE_DIR}/trim-lcov.py > dconf-lcov.info | ||
129 | 32 | COMMAND "${LCOV_EXECUTABLE}" -r dconf-lcov.info /usr/include/\\* -o nosys-lcov.info | ||
130 | 33 | COMMAND LANG=C "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory lcov-html --legend --show-details nosys-lcov.info | ||
131 | 34 | COMMAND ${CMAKE_COMMAND} -E echo "" | ||
132 | 35 | COMMAND ${CMAKE_COMMAND} -E echo "file://${CMAKE_BINARY_DIR}/lcov-html/index.html" | ||
133 | 36 | COMMAND ${CMAKE_COMMAND} -E echo "") | ||
134 | 37 | #COMMAND "${LCOV_EXECUTABLE}" --directory ${CMAKE_BINARY_DIR} --capture --output-file coverage.info --no-checksum | ||
135 | 38 | #COMMAND "${GENHTML_EXECUTABLE}" --prefix ${CMAKE_BINARY_DIR} --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info | ||
136 | 39 | #COMMAND ${CMAKE_COMMAND} -E echo "\\#define foo \\\"bar\\\"" | ||
137 | 40 | #) | ||
138 | 41 | endif() | ||
139 | 42 | endif() | ||
140 | 43 | endif() | ||
141 | 44 | |||
142 | 45 | |||
143 | 46 | #$(MAKE) $(AM_MAKEFLAGS) check | ||
144 | 47 | #lcov --directory $(top_builddir) --capture --test-name dconf | $(top_srcdir)/trim-lcov.py > dconf-lcov.info | ||
145 | 48 | #LANG=C genhtml --prefix $(top_builddir) --output-directory lcov-html --legend --show-details dconf-lcov.info | ||
146 | 49 | #@echo | ||
147 | 50 | #@echo " file://$(abs_top_builddir)/lcov-html/index.html" | ||
148 | 51 | #@echo | ||
149 | 0 | 52 | ||
150 | === added file 'cmake/GdbusCodegen.cmake' | |||
151 | --- cmake/GdbusCodegen.cmake 1970-01-01 00:00:00 +0000 | |||
152 | +++ cmake/GdbusCodegen.cmake 2014-08-22 00:07:37 +0000 | |||
153 | @@ -0,0 +1,36 @@ | |||
154 | 1 | cmake_minimum_required(VERSION 2.6) | ||
155 | 2 | if(POLICY CMP0011) | ||
156 | 3 | cmake_policy(SET CMP0011 NEW) | ||
157 | 4 | endif(POLICY CMP0011) | ||
158 | 5 | |||
159 | 6 | find_program(GDBUS_CODEGEN NAMES gdbus-codegen DOC "gdbus-codegen executable") | ||
160 | 7 | if(NOT GDBUS_CODEGEN) | ||
161 | 8 | message(FATAL_ERROR "Excutable gdbus-codegen not found") | ||
162 | 9 | endif() | ||
163 | 10 | |||
164 | 11 | macro(add_gdbus_codegen outfiles name prefix service_xml) | ||
165 | 12 | add_custom_command( | ||
166 | 13 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" | ||
167 | 14 | COMMAND "${GDBUS_CODEGEN}" | ||
168 | 15 | --interface-prefix "${prefix}" | ||
169 | 16 | --generate-c-code "${name}" | ||
170 | 17 | "${service_xml}" | ||
171 | 18 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
172 | 19 | DEPENDS ${ARGN} "${service_xml}" | ||
173 | 20 | ) | ||
174 | 21 | list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c") | ||
175 | 22 | endmacro(add_gdbus_codegen) | ||
176 | 23 | |||
177 | 24 | macro(add_gdbus_codegen_with_namespace outfiles name prefix namespace service_xml) | ||
178 | 25 | add_custom_command( | ||
179 | 26 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h" "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" | ||
180 | 27 | COMMAND "${GDBUS_CODEGEN}" | ||
181 | 28 | --interface-prefix "${prefix}" | ||
182 | 29 | --generate-c-code "${name}" | ||
183 | 30 | --c-namespace "${namespace}" | ||
184 | 31 | "${service_xml}" | ||
185 | 32 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
186 | 33 | DEPENDS ${ARGN} "${service_xml}" | ||
187 | 34 | ) | ||
188 | 35 | list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c") | ||
189 | 36 | endmacro(add_gdbus_codegen_with_namespace) | ||
190 | 0 | 37 | ||
191 | === added file 'cmake/Translations.cmake' | |||
192 | --- cmake/Translations.cmake 1970-01-01 00:00:00 +0000 | |||
193 | +++ cmake/Translations.cmake 2014-08-22 00:07:37 +0000 | |||
194 | @@ -0,0 +1,37 @@ | |||
195 | 1 | # Translations.cmake, CMake macros written for Marlin, feel free to re-use them | ||
196 | 2 | |||
197 | 3 | macro(add_translations_directory NLS_PACKAGE) | ||
198 | 4 | add_custom_target (i18n ALL) | ||
199 | 5 | find_program (MSGFMT_EXECUTABLE msgfmt) | ||
200 | 6 | file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po) | ||
201 | 7 | foreach (PO_INPUT ${PO_FILES}) | ||
202 | 8 | get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE) | ||
203 | 9 | set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo) | ||
204 | 10 | add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT}) | ||
205 | 11 | |||
206 | 12 | install (FILES ${MO_OUTPUT} DESTINATION | ||
207 | 13 | ${CMAKE_INSTALL_LOCALEDIR}/${PO_INPUT_BASE}/LC_MESSAGES | ||
208 | 14 | RENAME ${NLS_PACKAGE}.mo) | ||
209 | 15 | endforeach (PO_INPUT ${PO_FILES}) | ||
210 | 16 | endmacro(add_translations_directory) | ||
211 | 17 | |||
212 | 18 | |||
213 | 19 | macro(add_translations_catalog NLS_PACKAGE) | ||
214 | 20 | add_custom_target (pot COMMENT “Building translation catalog.”) | ||
215 | 21 | find_program (XGETTEXT_EXECUTABLE xgettext) | ||
216 | 22 | |||
217 | 23 | # init this list, which will hold all the sources across all dirs | ||
218 | 24 | set(SOURCES "") | ||
219 | 25 | |||
220 | 26 | # add each directory's sources to the overall sources list | ||
221 | 27 | foreach(FILES_INPUT ${ARGN}) | ||
222 | 28 | set (DIR ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}) | ||
223 | 29 | file (GLOB_RECURSE DIR_SOURCES ${DIR}/*.c ${DIR}/*.cc ${DIR}/*.cpp ${DIR}/*.cxx ${DIR}/*.vala) | ||
224 | 30 | set (SOURCES ${SOURCES} ${DIR_SOURCES}) | ||
225 | 31 | endforeach() | ||
226 | 32 | |||
227 | 33 | add_custom_command (TARGET pot COMMAND | ||
228 | 34 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot | ||
229 | 35 | ${SOURCES} --keyword="_" --keyword="N_" --from-code=UTF-8 | ||
230 | 36 | ) | ||
231 | 37 | endmacro() | ||
232 | 0 | 38 | ||
233 | === added directory 'data' | |||
234 | === added file 'data/CMakeLists.txt' | |||
235 | --- data/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
236 | +++ data/CMakeLists.txt 2014-08-22 00:07:37 +0000 | |||
237 | @@ -0,0 +1,74 @@ | |||
238 | 1 | ## | ||
239 | 2 | ## Upstart Job File | ||
240 | 3 | ## | ||
241 | 4 | |||
242 | 5 | # where to install | ||
243 | 6 | set (UPSTART_JOBS_DIR "${CMAKE_INSTALL_FULL_DATADIR}/upstart/sessions") | ||
244 | 7 | message (STATUS "${UPSTART_JOBS_DIR} is the Upstart Jobs File install dir") | ||
245 | 8 | |||
246 | 9 | set (UPSTART_JOB_NAME "${CMAKE_PROJECT_NAME}.conf") | ||
247 | 10 | set (UPSTART_JOB_FILE "${CMAKE_CURRENT_BINARY_DIR}/${UPSTART_JOB_NAME}") | ||
248 | 11 | set (UPSTART_JOB_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${UPSTART_JOB_NAME}.in") | ||
249 | 12 | |||
250 | 13 | # build it | ||
251 | 14 | set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") | ||
252 | 15 | configure_file ("${UPSTART_JOB_FILE_IN}" "${UPSTART_JOB_FILE}") | ||
253 | 16 | |||
254 | 17 | # install it | ||
255 | 18 | install (FILES "${UPSTART_JOB_FILE}" | ||
256 | 19 | DESTINATION "${UPSTART_JOBS_DIR}") | ||
257 | 20 | |||
258 | 21 | ## | ||
259 | 22 | ## XDG Autostart File | ||
260 | 23 | ## | ||
261 | 24 | |||
262 | 25 | # where to install | ||
263 | 26 | set (XDG_AUTOSTART_DIR "/etc/xdg/autostart") | ||
264 | 27 | message (STATUS "${XDG_AUTOSTART_DIR} is the XDG Autostart install dir") | ||
265 | 28 | |||
266 | 29 | set (XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.desktop") | ||
267 | 30 | set (XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${XDG_AUTOSTART_NAME}") | ||
268 | 31 | set (XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${XDG_AUTOSTART_NAME}.in") | ||
269 | 32 | |||
270 | 33 | # build it | ||
271 | 34 | set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") | ||
272 | 35 | configure_file ("${XDG_AUTOSTART_FILE_IN}" "${XDG_AUTOSTART_FILE}") | ||
273 | 36 | |||
274 | 37 | # install it | ||
275 | 38 | install (FILES "${XDG_AUTOSTART_FILE}" | ||
276 | 39 | DESTINATION "${XDG_AUTOSTART_DIR}") | ||
277 | 40 | |||
278 | 41 | ## | ||
279 | 42 | ## Upstart XDG Autostart Override | ||
280 | 43 | ## | ||
281 | 44 | |||
282 | 45 | # where to install | ||
283 | 46 | set (UPSTART_XDG_AUTOSTART_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/upstart/xdg/autostart") | ||
284 | 47 | message (STATUS "${UPSTART_XDG_AUTOSTART_DIR} is the Upstart XDG autostart override dir") | ||
285 | 48 | |||
286 | 49 | set (UPSTART_XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.upstart.desktop") | ||
287 | 50 | set (UPSTART_XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${UPSTART_XDG_AUTOSTART_NAME}") | ||
288 | 51 | set (UPSTART_XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${UPSTART_XDG_AUTOSTART_NAME}.in") | ||
289 | 52 | |||
290 | 53 | # build it | ||
291 | 54 | set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") | ||
292 | 55 | configure_file ("${UPSTART_XDG_AUTOSTART_FILE_IN}" "${UPSTART_XDG_AUTOSTART_FILE}") | ||
293 | 56 | |||
294 | 57 | # install it | ||
295 | 58 | install (FILES "${UPSTART_XDG_AUTOSTART_FILE}" | ||
296 | 59 | DESTINATION "${UPSTART_XDG_AUTOSTART_DIR}" | ||
297 | 60 | RENAME "${XDG_AUTOSTART_NAME}") | ||
298 | 61 | |||
299 | 62 | ## | ||
300 | 63 | ## Unity Indicator File | ||
301 | 64 | ## | ||
302 | 65 | |||
303 | 66 | # where to install | ||
304 | 67 | set (UNITY_INDICATOR_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/unity/indicators") | ||
305 | 68 | message (STATUS "${UNITY_INDICATOR_DIR} is the Unity Indicator install dir") | ||
306 | 69 | |||
307 | 70 | set (UNITY_INDICATOR_NAME "com.canonical.indicator.rotation_lock") | ||
308 | 71 | set (UNITY_INDICATOR_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_INDICATOR_NAME}") | ||
309 | 72 | |||
310 | 73 | install (FILES "${UNITY_INDICATOR_FILE}" | ||
311 | 74 | DESTINATION "${UNITY_INDICATOR_DIR}") | ||
312 | 0 | 75 | ||
313 | === added file 'data/com.canonical.indicator.rotation_lock' | |||
314 | --- data/com.canonical.indicator.rotation_lock 1970-01-01 00:00:00 +0000 | |||
315 | +++ data/com.canonical.indicator.rotation_lock 2014-08-22 00:07:37 +0000 | |||
316 | @@ -0,0 +1,11 @@ | |||
317 | 1 | [Indicator Service] | ||
318 | 2 | Name=indicator-rotation-lock | ||
319 | 3 | ObjectPath=/com/canonical/indicator/rotation_lock | ||
320 | 4 | Position=90 | ||
321 | 5 | |||
322 | 6 | [phone] | ||
323 | 7 | ObjectPath=/com/canonical/indicator/rotation_lock/phone | ||
324 | 8 | |||
325 | 9 | [phone_greeter] | ||
326 | 10 | ObjectPath=/com/canonical/indicator/rotation_lock/phone | ||
327 | 11 | |||
328 | 0 | 12 | ||
329 | === added file 'data/indicator-display.conf.in' | |||
330 | --- data/indicator-display.conf.in 1970-01-01 00:00:00 +0000 | |||
331 | +++ data/indicator-display.conf.in 2014-08-22 00:07:37 +0000 | |||
332 | @@ -0,0 +1,9 @@ | |||
333 | 1 | description "Indicator Display Backend" | ||
334 | 2 | |||
335 | 3 | start on indicator-services-start | ||
336 | 4 | stop on desktop-end or indicator-services-end | ||
337 | 5 | |||
338 | 6 | respawn | ||
339 | 7 | respawn limit 2 10 | ||
340 | 8 | |||
341 | 9 | exec @pkglibexecdir@/indicator-display-service | ||
342 | 0 | 10 | ||
343 | === added file 'data/indicator-display.desktop.in' | |||
344 | --- data/indicator-display.desktop.in 1970-01-01 00:00:00 +0000 | |||
345 | +++ data/indicator-display.desktop.in 2014-08-22 00:07:37 +0000 | |||
346 | @@ -0,0 +1,9 @@ | |||
347 | 1 | [Desktop Entry] | ||
348 | 2 | Type=Application | ||
349 | 3 | Name=Indicator Display | ||
350 | 4 | Exec=@pkglibexecdir@/indicator-display-service | ||
351 | 5 | OnlyShowIn=Unity;GNOME; | ||
352 | 6 | NoDisplay=true | ||
353 | 7 | StartupNotify=false | ||
354 | 8 | Terminal=false | ||
355 | 9 | AutostartCondition=GNOME3 unless-session gnome | ||
356 | 0 | 10 | ||
357 | === added file 'data/indicator-display.upstart.desktop.in' | |||
358 | --- data/indicator-display.upstart.desktop.in 1970-01-01 00:00:00 +0000 | |||
359 | +++ data/indicator-display.upstart.desktop.in 2014-08-22 00:07:37 +0000 | |||
360 | @@ -0,0 +1,9 @@ | |||
361 | 1 | [Desktop Entry] | ||
362 | 2 | Type=Application | ||
363 | 3 | Name=Indicator Display | ||
364 | 4 | Exec=@pkglibexecdir@/indicator-display-service | ||
365 | 5 | OnlyShowIn=Unity; | ||
366 | 6 | NoDisplay=true | ||
367 | 7 | StartupNotify=false | ||
368 | 8 | Terminal=false | ||
369 | 9 | Hidden=true | ||
370 | 0 | 10 | ||
371 | === added directory 'debian' | |||
372 | === added file 'debian/changelog' | |||
373 | --- debian/changelog 1970-01-01 00:00:00 +0000 | |||
374 | +++ debian/changelog 2014-08-22 00:07:37 +0000 | |||
375 | @@ -0,0 +1,6 @@ | |||
376 | 1 | indicator-display (0.1-0ubuntu1) utopic; urgency=medium | ||
377 | 2 | |||
378 | 3 | * Initial release. | ||
379 | 4 | |||
380 | 5 | -- Charles Kerr <charles.kerr@canonical.com> Wed, 20 Aug 2014 15:29:27 -0500 | ||
381 | 6 | |||
382 | 0 | 7 | ||
383 | === added file 'debian/compat' | |||
384 | --- debian/compat 1970-01-01 00:00:00 +0000 | |||
385 | +++ debian/compat 2014-08-22 00:07:37 +0000 | |||
386 | @@ -0,0 +1,1 @@ | |||
387 | 1 | 9 | ||
388 | 0 | 2 | ||
389 | === added file 'debian/control' | |||
390 | --- debian/control 1970-01-01 00:00:00 +0000 | |||
391 | +++ debian/control 2014-08-22 00:07:37 +0000 | |||
392 | @@ -0,0 +1,34 @@ | |||
393 | 1 | Source: indicator-display | ||
394 | 2 | Section: misc | ||
395 | 3 | Priority: optional | ||
396 | 4 | Maintainer: Charles Kerr <charles.kerr@canonical.com> | ||
397 | 5 | Build-Depends: cmake, | ||
398 | 6 | dbus, | ||
399 | 7 | # make g++ version explicit for ABI safety <https://wiki.ubuntu.com/cpp-11> | ||
400 | 8 | g++-4.9, | ||
401 | 9 | libglib2.0-dev (>= 2.36), | ||
402 | 10 | libproperties-cpp-dev, | ||
403 | 11 | # for coverage reports | ||
404 | 12 | lcov, | ||
405 | 13 | # for tests | ||
406 | 14 | cppcheck, | ||
407 | 15 | libgtest-dev, | ||
408 | 16 | google-mock (>= 1.6.0+svn437), | ||
409 | 17 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140813), | ||
410 | 18 | # for packaging | ||
411 | 19 | debhelper (>= 9), | ||
412 | 20 | dh-translations, | ||
413 | 21 | Standards-Version: 3.9.5 | ||
414 | 22 | Homepage: http://launchpad.net/indicator-display/ | ||
415 | 23 | # If you aren't a member of ~indicator-applet-developers but need to upload | ||
416 | 24 | # packaging changes, just go ahead. ~indicator-applet-developers will notice and | ||
417 | 25 | # sync up the code again. | ||
418 | 26 | Vcs-Bzr: https://code.launchpad.net/~indicator-applet-developers/indicator-display/trunk.14.10 | ||
419 | 27 | |||
420 | 28 | Package: indicator-display | ||
421 | 29 | Architecture: any | ||
422 | 30 | Depends: ${shlibs:Depends}, | ||
423 | 31 | ${misc:Depends}, | ||
424 | 32 | gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140813), | ||
425 | 33 | Description: Collection of small indicators | ||
426 | 34 | Indicators too small to merit separate codebases, such as Rotation Lock | ||
427 | 0 | 35 | ||
428 | === added file 'debian/copyright' | |||
429 | --- debian/copyright 1970-01-01 00:00:00 +0000 | |||
430 | +++ debian/copyright 2014-08-22 00:07:37 +0000 | |||
431 | @@ -0,0 +1,21 @@ | |||
432 | 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
433 | 2 | Upstream-Name: indicator-display | ||
434 | 3 | Source: http://launchpad.net/indicator-display | ||
435 | 4 | |||
436 | 5 | Files: * | ||
437 | 6 | Copyright: 2014, Canonical Ltd. | ||
438 | 7 | License: GPL-3 | ||
439 | 8 | This package is free software; you can redistribute it and/or modify | ||
440 | 9 | it under the terms of the GNU General Public License as published by | ||
441 | 10 | the Free Software Foundation; version 3 of the License. | ||
442 | 11 | . | ||
443 | 12 | This package is distributed in the hope that it will be useful, | ||
444 | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
445 | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
446 | 15 | GNU General Public License for more details. | ||
447 | 16 | . | ||
448 | 17 | You should have received a copy of the GNU General Public License | ||
449 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/> | ||
450 | 19 | . | ||
451 | 20 | On Debian systems, the complete text of the GNU General | ||
452 | 21 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". | ||
453 | 0 | 22 | ||
454 | === added file 'debian/rules' | |||
455 | --- debian/rules 1970-01-01 00:00:00 +0000 | |||
456 | +++ debian/rules 2014-08-22 00:07:37 +0000 | |||
457 | @@ -0,0 +1,10 @@ | |||
458 | 1 | #!/usr/bin/make -f | ||
459 | 2 | |||
460 | 3 | # Explicitly selecting a G{CC,++}-version here to avoid ABI breaks | ||
461 | 4 | # introduced by toolchain updates. <https://wiki.ubuntu.com/cpp-11> | ||
462 | 5 | export CC=$(DEB_HOST_GNU_TYPE)-gcc-4.9 | ||
463 | 6 | export CXX=$(DEB_HOST_GNU_TYPE)-g++-4.9 | ||
464 | 7 | |||
465 | 8 | %: | ||
466 | 9 | dh $@ --with translations | ||
467 | 10 | |||
468 | 0 | 11 | ||
469 | === added directory 'po' | |||
470 | === added file 'po/CMakeLists.txt' | |||
471 | --- po/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
472 | +++ po/CMakeLists.txt 2014-08-22 00:07:37 +0000 | |||
473 | @@ -0,0 +1,3 @@ | |||
474 | 1 | include (Translations) | ||
475 | 2 | add_translations_directory("${GETTEXT_PACKAGE}") | ||
476 | 3 | add_translations_catalog("${GETTEXT_PACKAGE}" ../src/) | ||
477 | 0 | 4 | ||
478 | === added file 'po/POTFILES.in' | |||
479 | --- po/POTFILES.in 1970-01-01 00:00:00 +0000 | |||
480 | +++ po/POTFILES.in 2014-08-22 00:07:37 +0000 | |||
481 | @@ -0,0 +1,1 @@ | |||
482 | 1 | src/rotation-lock.cpp | ||
483 | 0 | 2 | ||
484 | === added directory 'src' | |||
485 | === added file 'src/CMakeLists.txt' | |||
486 | --- src/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
487 | +++ src/CMakeLists.txt 2014-08-22 00:07:37 +0000 | |||
488 | @@ -0,0 +1,29 @@ | |||
489 | 1 | set (SERVICE_LIB "indicatordisplayservice") | ||
490 | 2 | set (SERVICE_EXEC "indicator-display-service") | ||
491 | 3 | |||
492 | 4 | add_definitions (-DG_LOG_DOMAIN="${CMAKE_PROJECT_NAME}") | ||
493 | 5 | |||
494 | 6 | # handwritten source code... | ||
495 | 7 | set (SERVICE_LIB_HANDWRITTEN_SOURCES | ||
496 | 8 | exporter.cpp | ||
497 | 9 | rotation-lock.cpp) | ||
498 | 10 | |||
499 | 11 | add_library (${SERVICE_LIB} STATIC | ||
500 | 12 | ${SERVICE_LIB_HANDWRITTEN_SOURCES}) | ||
501 | 13 | |||
502 | 14 | # add the bin dir to the include path so that | ||
503 | 15 | # the compiler can find the generated header files | ||
504 | 16 | include_directories (${CMAKE_CURRENT_BINARY_DIR}) | ||
505 | 17 | |||
506 | 18 | link_directories (${SERVICE_DEPS_LIBRARY_DIRS}) | ||
507 | 19 | |||
508 | 20 | set (SERVICE_EXEC_HANDWRITTEN_SOURCES main.cpp) | ||
509 | 21 | add_executable (${SERVICE_EXEC} ${SERVICE_EXEC_HANDWRITTEN_SOURCES}) | ||
510 | 22 | target_link_libraries (${SERVICE_EXEC} ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} ${GCOV_LIBS}) | ||
511 | 23 | install (TARGETS ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}) | ||
512 | 24 | |||
513 | 25 | # add warnings/coverage info on handwritten files | ||
514 | 26 | # but not the generated ones... | ||
515 | 27 | set_property (SOURCE ${SERVICE_LIB_HANDWRITTEN_SOURCES} ${SERVICE_EXEC_HANDWRITTEN_SOURCES} | ||
516 | 28 | APPEND_STRING PROPERTY COMPILE_FLAGS " -std=c++11 -g ${CXX_WARNING_ARGS} ${GCOV_FLAGS}") | ||
517 | 29 | |||
518 | 0 | 30 | ||
519 | === added file 'src/exporter.cpp' | |||
520 | --- src/exporter.cpp 1970-01-01 00:00:00 +0000 | |||
521 | +++ src/exporter.cpp 2014-08-22 00:07:37 +0000 | |||
522 | @@ -0,0 +1,217 @@ | |||
523 | 1 | /* | ||
524 | 2 | * Copyright 2014 Canonical Ltd. | ||
525 | 3 | * | ||
526 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
527 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
528 | 6 | * by the Free Software Foundation. | ||
529 | 7 | * | ||
530 | 8 | * This program is distributed in the hope that it will be useful, but | ||
531 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
532 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
533 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
534 | 12 | * | ||
535 | 13 | * You should have received a copy of the GNU General Public License along | ||
536 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
537 | 15 | * | ||
538 | 16 | * Authors: | ||
539 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
540 | 18 | */ | ||
541 | 19 | |||
542 | 20 | #include <src/exporter.h> | ||
543 | 21 | |||
544 | 22 | class Exporter::Impl | ||
545 | 23 | { | ||
546 | 24 | public: | ||
547 | 25 | |||
548 | 26 | Impl(const std::shared_ptr<Indicator>& indicator): | ||
549 | 27 | m_indicator(indicator) | ||
550 | 28 | { | ||
551 | 29 | auto bus_name = g_strdup_printf("com.canonical.indicator.%s", indicator->name()); | ||
552 | 30 | m_own_id = g_bus_own_name(G_BUS_TYPE_SESSION, | ||
553 | 31 | bus_name, | ||
554 | 32 | G_BUS_NAME_OWNER_FLAGS_NONE, | ||
555 | 33 | on_bus_acquired, | ||
556 | 34 | nullptr, | ||
557 | 35 | on_name_lost, | ||
558 | 36 | this, | ||
559 | 37 | nullptr); | ||
560 | 38 | |||
561 | 39 | g_free(bus_name); | ||
562 | 40 | } | ||
563 | 41 | |||
564 | 42 | ~Impl() | ||
565 | 43 | { | ||
566 | 44 | if (m_bus != nullptr) | ||
567 | 45 | { | ||
568 | 46 | for(const auto& id : m_exported_menu_ids) | ||
569 | 47 | g_dbus_connection_unexport_menu_model(m_bus, id); | ||
570 | 48 | |||
571 | 49 | if (m_exported_actions_id) | ||
572 | 50 | g_dbus_connection_unexport_action_group(m_bus, m_exported_actions_id); | ||
573 | 51 | } | ||
574 | 52 | |||
575 | 53 | if (m_own_id) | ||
576 | 54 | g_bus_unown_name(m_own_id); | ||
577 | 55 | |||
578 | 56 | g_clear_object(&m_bus); | ||
579 | 57 | } | ||
580 | 58 | |||
581 | 59 | core::Signal<std::string>& name_lost() | ||
582 | 60 | { | ||
583 | 61 | return m_name_lost; | ||
584 | 62 | } | ||
585 | 63 | |||
586 | 64 | private: | ||
587 | 65 | |||
588 | 66 | void emit_name_lost(const char* bus_name) | ||
589 | 67 | { | ||
590 | 68 | m_name_lost(bus_name); | ||
591 | 69 | } | ||
592 | 70 | |||
593 | 71 | static void on_bus_acquired(GDBusConnection * connection, | ||
594 | 72 | const gchar * name, | ||
595 | 73 | gpointer gself) | ||
596 | 74 | { | ||
597 | 75 | static_cast<Impl*>(gself)->on_bus_acquired(connection, name); | ||
598 | 76 | } | ||
599 | 77 | |||
600 | 78 | void on_bus_acquired(GDBusConnection* connection, const gchar* /*name*/) | ||
601 | 79 | { | ||
602 | 80 | m_bus = G_DBUS_CONNECTION(g_object_ref(G_OBJECT(connection))); | ||
603 | 81 | |||
604 | 82 | export_actions(m_indicator); | ||
605 | 83 | |||
606 | 84 | for (auto& profile : m_indicator->profiles()) | ||
607 | 85 | export_profile(m_indicator, profile); | ||
608 | 86 | } | ||
609 | 87 | |||
610 | 88 | void export_actions(const std::shared_ptr<Indicator>& indicator) | ||
611 | 89 | { | ||
612 | 90 | GError* error; | ||
613 | 91 | char* object_path; | ||
614 | 92 | guint id; | ||
615 | 93 | |||
616 | 94 | // export the actions | ||
617 | 95 | |||
618 | 96 | error = nullptr; | ||
619 | 97 | object_path = g_strdup_printf("/com/canonical/indicator/%s", indicator->name()); | ||
620 | 98 | id = g_dbus_connection_export_action_group(m_bus, | ||
621 | 99 | object_path, | ||
622 | 100 | G_ACTION_GROUP(indicator->action_group()), | ||
623 | 101 | &error); | ||
624 | 102 | if (id) | ||
625 | 103 | m_exported_actions_id = id; | ||
626 | 104 | else | ||
627 | 105 | g_warning("Can't export action group to '%s': %s", object_path, error->message); | ||
628 | 106 | |||
629 | 107 | g_clear_error(&error); | ||
630 | 108 | g_free(object_path); | ||
631 | 109 | } | ||
632 | 110 | |||
633 | 111 | static GVariant* create_header_state(const Header& h) | ||
634 | 112 | { | ||
635 | 113 | GVariantBuilder b; | ||
636 | 114 | g_variant_builder_init(&b, G_VARIANT_TYPE_VARDICT); | ||
637 | 115 | |||
638 | 116 | g_variant_builder_add(&b, "{sv}", "visible", g_variant_new_boolean(h.is_visible)); | ||
639 | 117 | |||
640 | 118 | if (!h.title.empty()) | ||
641 | 119 | g_variant_builder_add(&b, "{sv}", "title", g_variant_new_string(h.title.c_str())); | ||
642 | 120 | |||
643 | 121 | if (!h.label.empty()) | ||
644 | 122 | g_variant_builder_add(&b, "{sv}", "label", g_variant_new_string(h.label.c_str())); | ||
645 | 123 | |||
646 | 124 | if (!h.title.empty() || !h.label.empty()) | ||
647 | 125 | g_variant_builder_add(&b, "{sv}", "accessible-desc", g_variant_new_string(!h.label.empty() ? h.label.c_str() : h.title.c_str())); | ||
648 | 126 | |||
649 | 127 | if (h.icon) | ||
650 | 128 | g_variant_builder_add(&b, "{sv}", "icon", g_icon_serialize(h.icon.get())); | ||
651 | 129 | |||
652 | 130 | return g_variant_builder_end (&b); | ||
653 | 131 | } | ||
654 | 132 | |||
655 | 133 | void export_profile(const std::shared_ptr<Indicator>& indicator, | ||
656 | 134 | const std::shared_ptr<Profile>& profile) | ||
657 | 135 | { | ||
658 | 136 | // build the header action | ||
659 | 137 | auto action_group = indicator->action_group(); | ||
660 | 138 | std::string action_name = profile->name() + "-header"; | ||
661 | 139 | auto a = g_simple_action_new_stateful(action_name.c_str(), nullptr, create_header_state(profile->header())); | ||
662 | 140 | g_action_map_add_action(G_ACTION_MAP(action_group), G_ACTION(a)); | ||
663 | 141 | profile->header().changed().connect([action_group,action_name](const Header& header){ | ||
664 | 142 | auto state = create_header_state(header); | ||
665 | 143 | auto tmp = g_variant_print(state, true); | ||
666 | 144 | g_message("header changed; updating action state to '%s'", tmp); | ||
667 | 145 | g_action_group_change_action_state(G_ACTION_GROUP(action_group), | ||
668 | 146 | action_name.c_str(), | ||
669 | 147 | create_header_state(header)); | ||
670 | 148 | g_free(tmp); | ||
671 | 149 | }); | ||
672 | 150 | |||
673 | 151 | // build the header menu | ||
674 | 152 | auto detailed_action = g_strdup_printf("indicator.%s", action_name.c_str()); | ||
675 | 153 | GMenuItem* header = g_menu_item_new(nullptr, detailed_action); | ||
676 | 154 | g_menu_item_set_attribute(header, "x-canonical-type", "s", "com.canonical.indicator.root"); | ||
677 | 155 | g_menu_item_set_submenu(header, profile->menu_model().get()); | ||
678 | 156 | g_free(detailed_action); | ||
679 | 157 | |||
680 | 158 | // build the menu | ||
681 | 159 | auto menu = g_menu_new(); | ||
682 | 160 | g_menu_append_item(menu, header); | ||
683 | 161 | g_object_unref(header); | ||
684 | 162 | |||
685 | 163 | // export the menu | ||
686 | 164 | auto object_path = g_strdup_printf("/com/canonical/indicator/%s/%s", | ||
687 | 165 | indicator->name(), | ||
688 | 166 | profile->name().c_str()); | ||
689 | 167 | GError* error = nullptr; | ||
690 | 168 | auto id = g_dbus_connection_export_menu_model(m_bus, object_path, G_MENU_MODEL(menu), &error); | ||
691 | 169 | if (id) | ||
692 | 170 | m_exported_menu_ids.insert(id); | ||
693 | 171 | else if (error != nullptr) | ||
694 | 172 | g_warning("cannot export '%s': %s", object_path, error->message); | ||
695 | 173 | |||
696 | 174 | g_free(object_path); | ||
697 | 175 | g_clear_error(&error); | ||
698 | 176 | //g_object_unref(menu); | ||
699 | 177 | } | ||
700 | 178 | |||
701 | 179 | static void on_name_lost(GDBusConnection * /*connection*/, | ||
702 | 180 | const gchar * name, | ||
703 | 181 | gpointer gthis) | ||
704 | 182 | { | ||
705 | 183 | static_cast<Impl*>(gthis)->emit_name_lost(name); | ||
706 | 184 | } | ||
707 | 185 | |||
708 | 186 | const std::string m_bus_name; | ||
709 | 187 | core::Signal<std::string> m_name_lost; | ||
710 | 188 | std::shared_ptr<Indicator> m_indicator; | ||
711 | 189 | std::set<guint> m_exported_menu_ids; | ||
712 | 190 | guint m_own_id = 0; | ||
713 | 191 | guint m_exported_actions_id = 0; | ||
714 | 192 | GDBusConnection * m_bus = nullptr; | ||
715 | 193 | }; | ||
716 | 194 | |||
717 | 195 | /*** | ||
718 | 196 | **** | ||
719 | 197 | ***/ | ||
720 | 198 | |||
721 | 199 | Exporter::Exporter(const std::shared_ptr<Indicator>& indicator): | ||
722 | 200 | impl(new Impl(indicator)) | ||
723 | 201 | { | ||
724 | 202 | } | ||
725 | 203 | |||
726 | 204 | Exporter::~Exporter() | ||
727 | 205 | { | ||
728 | 206 | } | ||
729 | 207 | |||
730 | 208 | core::Signal<std::string>& | ||
731 | 209 | Exporter::name_lost() | ||
732 | 210 | { | ||
733 | 211 | return impl->name_lost(); | ||
734 | 212 | } | ||
735 | 213 | |||
736 | 214 | /*** | ||
737 | 215 | **** | ||
738 | 216 | ***/ | ||
739 | 217 | |||
740 | 0 | 218 | ||
741 | === added file 'src/exporter.h' | |||
742 | --- src/exporter.h 1970-01-01 00:00:00 +0000 | |||
743 | +++ src/exporter.h 2014-08-22 00:07:37 +0000 | |||
744 | @@ -0,0 +1,40 @@ | |||
745 | 1 | /* | ||
746 | 2 | * Copyright 2014 Canonical Ltd. | ||
747 | 3 | * | ||
748 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
749 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
750 | 6 | * by the Free Software Foundation. | ||
751 | 7 | * | ||
752 | 8 | * This program is distributed in the hope that it will be useful, but | ||
753 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
754 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
755 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
756 | 12 | * | ||
757 | 13 | * You should have received a copy of the GNU General Public License along | ||
758 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
759 | 15 | * | ||
760 | 16 | * Authors: | ||
761 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
762 | 18 | */ | ||
763 | 19 | |||
764 | 20 | #include <src/indicator.h> | ||
765 | 21 | |||
766 | 22 | #include <core/signal.h> | ||
767 | 23 | |||
768 | 24 | #include <memory> | ||
769 | 25 | |||
770 | 26 | class Exporter | ||
771 | 27 | { | ||
772 | 28 | public: | ||
773 | 29 | Exporter(const std::shared_ptr<Indicator>& indicator); | ||
774 | 30 | ~Exporter(); | ||
775 | 31 | core::Signal<std::string>& name_lost(); | ||
776 | 32 | |||
777 | 33 | private: | ||
778 | 34 | class Impl; | ||
779 | 35 | std::unique_ptr<Impl> impl; | ||
780 | 36 | |||
781 | 37 | Exporter(const Exporter&) =delete; | ||
782 | 38 | Exporter& operator=(const Exporter&) =delete; | ||
783 | 39 | }; | ||
784 | 40 | |||
785 | 0 | 41 | ||
786 | === added file 'src/indicator.h' | |||
787 | --- src/indicator.h 1970-01-01 00:00:00 +0000 | |||
788 | +++ src/indicator.h 2014-08-22 00:07:37 +0000 | |||
789 | @@ -0,0 +1,88 @@ | |||
790 | 1 | /* | ||
791 | 2 | * Copyright 2014 Canonical Ltd. | ||
792 | 3 | * | ||
793 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
794 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
795 | 6 | * by the Free Software Foundation. | ||
796 | 7 | * | ||
797 | 8 | * This program is distributed in the hope that it will be useful, but | ||
798 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
799 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
800 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
801 | 12 | * | ||
802 | 13 | * You should have received a copy of the GNU General Public License along | ||
803 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
804 | 15 | * | ||
805 | 16 | * Authors: | ||
806 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
807 | 18 | */ | ||
808 | 19 | |||
809 | 20 | #ifndef INDICATOR_DISPLAY_INDICATOR_H | ||
810 | 21 | #define INDICATOR_DISPLAY_INDICATOR_H | ||
811 | 22 | |||
812 | 23 | #include <core/property.h> | ||
813 | 24 | |||
814 | 25 | #include <gio/gio.h> // GIcon | ||
815 | 26 | |||
816 | 27 | #include <string> | ||
817 | 28 | #include <vector> | ||
818 | 29 | |||
819 | 30 | struct Header | ||
820 | 31 | { | ||
821 | 32 | bool is_visible = false; | ||
822 | 33 | std::string title; | ||
823 | 34 | std::string label; | ||
824 | 35 | std::string a11y; | ||
825 | 36 | std::shared_ptr<GIcon> icon; | ||
826 | 37 | |||
827 | 38 | bool operator== (const Header& that) const { | ||
828 | 39 | return (is_visible == that.is_visible) && | ||
829 | 40 | (title == that.title) && | ||
830 | 41 | (label == that.label) && | ||
831 | 42 | (a11y == that.a11y) && | ||
832 | 43 | (icon == that.icon); | ||
833 | 44 | } | ||
834 | 45 | bool operator!= (const Header& that) const { return !(*this == that);} | ||
835 | 46 | }; | ||
836 | 47 | |||
837 | 48 | |||
838 | 49 | class Profile | ||
839 | 50 | { | ||
840 | 51 | public: | ||
841 | 52 | virtual std::string name() const =0; | ||
842 | 53 | virtual const core::Property<Header>& header() const =0; | ||
843 | 54 | virtual std::shared_ptr<GMenuModel> menu_model() const =0; | ||
844 | 55 | |||
845 | 56 | protected: | ||
846 | 57 | Profile() =default; | ||
847 | 58 | }; | ||
848 | 59 | |||
849 | 60 | |||
850 | 61 | class SimpleProfile: public Profile | ||
851 | 62 | { | ||
852 | 63 | public: | ||
853 | 64 | SimpleProfile(const char* name, const std::shared_ptr<GMenuModel>& menu): m_name(name), m_menu(menu) {} | ||
854 | 65 | |||
855 | 66 | std::string name() const {return m_name;} | ||
856 | 67 | core::Property<Header>& header() {return m_header;} | ||
857 | 68 | const core::Property<Header>& header() const {return m_header;} | ||
858 | 69 | std::shared_ptr<GMenuModel> menu_model() const {return m_menu;} | ||
859 | 70 | |||
860 | 71 | protected: | ||
861 | 72 | const std::string m_name; | ||
862 | 73 | core::Property<Header> m_header; | ||
863 | 74 | std::shared_ptr<GMenuModel> m_menu; | ||
864 | 75 | }; | ||
865 | 76 | |||
866 | 77 | |||
867 | 78 | class Indicator | ||
868 | 79 | { | ||
869 | 80 | public: | ||
870 | 81 | virtual ~Indicator() =default; | ||
871 | 82 | |||
872 | 83 | virtual const char* name() const =0; | ||
873 | 84 | virtual GSimpleActionGroup* action_group() const =0; | ||
874 | 85 | virtual std::vector<std::shared_ptr<Profile>> profiles() const =0; | ||
875 | 86 | }; | ||
876 | 87 | |||
877 | 88 | #endif | ||
878 | 0 | 89 | ||
879 | === added file 'src/main.cpp' | |||
880 | --- src/main.cpp 1970-01-01 00:00:00 +0000 | |||
881 | +++ src/main.cpp 2014-08-22 00:07:37 +0000 | |||
882 | @@ -0,0 +1,62 @@ | |||
883 | 1 | /* | ||
884 | 2 | * Copyright 2014 Canonical Ltd. | ||
885 | 3 | * | ||
886 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
887 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
888 | 6 | * by the Free Software Foundation. | ||
889 | 7 | * | ||
890 | 8 | * This program is distributed in the hope that it will be useful, but | ||
891 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
892 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
893 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
894 | 12 | * | ||
895 | 13 | * You should have received a copy of the GNU General Public License along | ||
896 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
897 | 15 | * | ||
898 | 16 | * Authors: | ||
899 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
900 | 18 | */ | ||
901 | 19 | |||
902 | 20 | #include <src/exporter.h> | ||
903 | 21 | #include <src/rotation-lock.h> | ||
904 | 22 | |||
905 | 23 | #include <glib/gi18n.h> // bindtextdomain() | ||
906 | 24 | #include <gio/gio.h> | ||
907 | 25 | |||
908 | 26 | #include <locale.h> | ||
909 | 27 | |||
910 | 28 | int | ||
911 | 29 | main(int /*argc*/, char** /*argv*/) | ||
912 | 30 | { | ||
913 | 31 | // Work around a deadlock in glib's type initialization. | ||
914 | 32 | // It can be removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is fixed. | ||
915 | 33 | g_type_ensure(G_TYPE_DBUS_CONNECTION); | ||
916 | 34 | |||
917 | 35 | // boilerplate i18n | ||
918 | 36 | setlocale(LC_ALL, ""); | ||
919 | 37 | bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); | ||
920 | 38 | textdomain(GETTEXT_PACKAGE); | ||
921 | 39 | |||
922 | 40 | auto loop = g_main_loop_new(nullptr, false); | ||
923 | 41 | auto on_name_lost = [loop](const std::string& name){ | ||
924 | 42 | g_warning("busname lost: '%s'", name.c_str()); | ||
925 | 43 | g_main_loop_quit(loop); | ||
926 | 44 | }; | ||
927 | 45 | |||
928 | 46 | // build all our indicators. | ||
929 | 47 | // Right now we've only got one -- rotation lock -- but hey, we can dream. | ||
930 | 48 | std::vector<std::shared_ptr<Indicator>> indicators; | ||
931 | 49 | std::vector<std::shared_ptr<Exporter>> exporters; | ||
932 | 50 | indicators.push_back(std::make_shared<RotationLockIndicator>()); | ||
933 | 51 | for (auto& indicator : indicators) { | ||
934 | 52 | auto exporter = std::make_shared<Exporter>(indicator); | ||
935 | 53 | exporter->name_lost().connect(on_name_lost); | ||
936 | 54 | exporters.push_back(exporter); | ||
937 | 55 | } | ||
938 | 56 | |||
939 | 57 | g_main_loop_run(loop); | ||
940 | 58 | |||
941 | 59 | // cleanup | ||
942 | 60 | g_main_loop_unref(loop); | ||
943 | 61 | return 0; | ||
944 | 62 | } | ||
945 | 0 | 63 | ||
946 | === added file 'src/rotation-lock.cpp' | |||
947 | --- src/rotation-lock.cpp 1970-01-01 00:00:00 +0000 | |||
948 | +++ src/rotation-lock.cpp 2014-08-22 00:07:37 +0000 | |||
949 | @@ -0,0 +1,197 @@ | |||
950 | 1 | /* | ||
951 | 2 | * Copyright 2014 Canonical Ltd. | ||
952 | 3 | * | ||
953 | 4 | * This program is free software; you can redistribute it and/or modify | ||
954 | 5 | * it under the terms of the GNU General Public License as published by | ||
955 | 6 | * the Free Software Foundation; version 3. | ||
956 | 7 | * | ||
957 | 8 | * This program is distributed in the hope that it will be useful, | ||
958 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
959 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
960 | 11 | * GNU Lesser General Public License for more details. | ||
961 | 12 | * | ||
962 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
963 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
964 | 15 | * | ||
965 | 16 | * Authors: | ||
966 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
967 | 18 | */ | ||
968 | 19 | |||
969 | 20 | #include <src/rotation-lock.h> | ||
970 | 21 | |||
971 | 22 | #include <glib/gi18n.h> | ||
972 | 23 | |||
973 | 24 | class RotationLockIndicator::Impl | ||
974 | 25 | { | ||
975 | 26 | public: | ||
976 | 27 | |||
977 | 28 | Impl(): | ||
978 | 29 | m_settings(g_settings_new(m_schema_name)), | ||
979 | 30 | m_action_group(create_action_group()) | ||
980 | 31 | { | ||
981 | 32 | // build the rotation lock icon | ||
982 | 33 | auto icon = g_themed_icon_new_with_default_fallbacks("orientation-lock"); | ||
983 | 34 | auto icon_deleter = [](GIcon* o){g_object_unref(G_OBJECT(o));}; | ||
984 | 35 | m_icon.reset(icon, icon_deleter); | ||
985 | 36 | |||
986 | 37 | // build the phone profile | ||
987 | 38 | auto menu_model_deleter = [](GMenuModel* o){g_object_unref(G_OBJECT(o));}; | ||
988 | 39 | std::shared_ptr<GMenuModel> phone_menu (create_phone_menu(), menu_model_deleter); | ||
989 | 40 | m_phone = std::make_shared<SimpleProfile>("phone", phone_menu); | ||
990 | 41 | update_phone_header(); | ||
991 | 42 | } | ||
992 | 43 | |||
993 | 44 | ~Impl() | ||
994 | 45 | { | ||
995 | 46 | g_clear_object(&m_action_group); | ||
996 | 47 | g_clear_object(&m_settings); | ||
997 | 48 | } | ||
998 | 49 | |||
999 | 50 | GSimpleActionGroup* action_group() const | ||
1000 | 51 | { | ||
1001 | 52 | return m_action_group; | ||
1002 | 53 | } | ||
1003 | 54 | |||
1004 | 55 | std::vector<std::shared_ptr<Profile>> profiles() | ||
1005 | 56 | { | ||
1006 | 57 | std::vector<std::shared_ptr<Profile>> ret; | ||
1007 | 58 | ret.push_back(m_phone); | ||
1008 | 59 | return ret; | ||
1009 | 60 | } | ||
1010 | 61 | |||
1011 | 62 | private: | ||
1012 | 63 | |||
1013 | 64 | /*** | ||
1014 | 65 | **** Actions | ||
1015 | 66 | ***/ | ||
1016 | 67 | |||
1017 | 68 | static gboolean settings_to_action_state(GValue *value, | ||
1018 | 69 | GVariant *variant, | ||
1019 | 70 | gpointer /*unused*/) | ||
1020 | 71 | { | ||
1021 | 72 | bool is_locked = g_strcmp0(g_variant_get_string(variant, nullptr), "none"); | ||
1022 | 73 | g_value_set_variant(value, g_variant_new_boolean(is_locked)); | ||
1023 | 74 | return TRUE; | ||
1024 | 75 | } | ||
1025 | 76 | |||
1026 | 77 | static GVariant* action_state_to_settings(const GValue *value, | ||
1027 | 78 | const GVariantType * /*expected_type*/, | ||
1028 | 79 | gpointer /*unused*/) | ||
1029 | 80 | { | ||
1030 | 81 | // Toggling to 'on' *should* lock to the screen's current orientation. | ||
1031 | 82 | // We don't have any way of knowing Screen.orientation in this service, | ||
1032 | 83 | // so just pick one at random to satisfy the binding's needs. | ||
1033 | 84 | // | ||
1034 | 85 | // In practice this doesn't matter since the indicator isn't visible | ||
1035 | 86 | // when the lock mode is 'none' so the end user won't ever be able | ||
1036 | 87 | // to toggle the menuitem from None to anything else. | ||
1037 | 88 | |||
1038 | 89 | auto state_is_true = g_variant_get_boolean(g_value_get_variant(value)); | ||
1039 | 90 | return g_variant_new_string(state_is_true ? "PrimaryOrientation" : "none"); | ||
1040 | 91 | } | ||
1041 | 92 | |||
1042 | 93 | GSimpleActionGroup* create_action_group() | ||
1043 | 94 | { | ||
1044 | 95 | GSimpleActionGroup* group; | ||
1045 | 96 | GSimpleAction* action; | ||
1046 | 97 | |||
1047 | 98 | group = g_simple_action_group_new(); | ||
1048 | 99 | action = g_simple_action_new_stateful("rotation-lock", | ||
1049 | 100 | nullptr, | ||
1050 | 101 | g_variant_new_boolean(false)); | ||
1051 | 102 | g_settings_bind_with_mapping(m_settings, "orientation-lock", | ||
1052 | 103 | action, "state", | ||
1053 | 104 | G_SETTINGS_BIND_DEFAULT, | ||
1054 | 105 | settings_to_action_state, | ||
1055 | 106 | action_state_to_settings, | ||
1056 | 107 | nullptr, | ||
1057 | 108 | nullptr); | ||
1058 | 109 | g_action_map_add_action(G_ACTION_MAP(group), G_ACTION(action)); | ||
1059 | 110 | g_object_unref(G_OBJECT(action)); | ||
1060 | 111 | g_signal_connect_swapped(m_settings, "changed::orientation-lock", | ||
1061 | 112 | G_CALLBACK(on_orientation_lock_setting_changed), this); | ||
1062 | 113 | |||
1063 | 114 | return group; | ||
1064 | 115 | } | ||
1065 | 116 | |||
1066 | 117 | /*** | ||
1067 | 118 | **** Phone profile | ||
1068 | 119 | ***/ | ||
1069 | 120 | |||
1070 | 121 | static void on_orientation_lock_setting_changed (gpointer gself) | ||
1071 | 122 | { | ||
1072 | 123 | static_cast<Impl*>(gself)->update_phone_header(); | ||
1073 | 124 | } | ||
1074 | 125 | |||
1075 | 126 | GMenuModel* create_phone_menu() | ||
1076 | 127 | { | ||
1077 | 128 | GMenu* menu; | ||
1078 | 129 | GMenuItem* menu_item; | ||
1079 | 130 | |||
1080 | 131 | menu = g_menu_new(); | ||
1081 | 132 | |||
1082 | 133 | menu_item = g_menu_item_new(_("Rotation Lock"), "indicator.rotation-lock"); | ||
1083 | 134 | g_menu_item_set_attribute(menu_item, "x-canonical-type", "s", "com.canonical.indicator.switch"); | ||
1084 | 135 | g_menu_append_item(menu, menu_item); | ||
1085 | 136 | g_object_unref(menu_item); | ||
1086 | 137 | |||
1087 | 138 | return G_MENU_MODEL(menu); | ||
1088 | 139 | } | ||
1089 | 140 | |||
1090 | 141 | void update_phone_header() | ||
1091 | 142 | { | ||
1092 | 143 | Header h; | ||
1093 | 144 | h.title = _("Rotation lock"); | ||
1094 | 145 | h.a11y = h.title; | ||
1095 | 146 | h.is_visible = g_settings_get_enum(m_settings, "orientation-lock") != 0; | ||
1096 | 147 | h.icon = m_icon; | ||
1097 | 148 | m_phone->header().set(h); | ||
1098 | 149 | } | ||
1099 | 150 | |||
1100 | 151 | /*** | ||
1101 | 152 | **** | ||
1102 | 153 | ***/ | ||
1103 | 154 | |||
1104 | 155 | static constexpr char const * m_schema_name {"com.ubuntu.touch.system"}; | ||
1105 | 156 | static constexpr char const * m_orientation_lock_icon_name {"orientation-lock"}; | ||
1106 | 157 | GSettings* m_settings = nullptr; | ||
1107 | 158 | GSimpleActionGroup* m_action_group = nullptr; | ||
1108 | 159 | std::shared_ptr<SimpleProfile> m_phone; | ||
1109 | 160 | std::shared_ptr<GIcon> m_icon; | ||
1110 | 161 | }; | ||
1111 | 162 | |||
1112 | 163 | /*** | ||
1113 | 164 | **** | ||
1114 | 165 | ***/ | ||
1115 | 166 | |||
1116 | 167 | RotationLockIndicator::RotationLockIndicator(): | ||
1117 | 168 | impl(new Impl()) | ||
1118 | 169 | { | ||
1119 | 170 | } | ||
1120 | 171 | |||
1121 | 172 | RotationLockIndicator::~RotationLockIndicator() | ||
1122 | 173 | { | ||
1123 | 174 | } | ||
1124 | 175 | |||
1125 | 176 | std::vector<std::shared_ptr<Profile>> | ||
1126 | 177 | RotationLockIndicator::profiles() const | ||
1127 | 178 | { | ||
1128 | 179 | return impl->profiles(); | ||
1129 | 180 | } | ||
1130 | 181 | |||
1131 | 182 | GSimpleActionGroup* | ||
1132 | 183 | RotationLockIndicator::action_group() const | ||
1133 | 184 | { | ||
1134 | 185 | return impl->action_group(); | ||
1135 | 186 | } | ||
1136 | 187 | |||
1137 | 188 | const char* | ||
1138 | 189 | RotationLockIndicator::name() const | ||
1139 | 190 | { | ||
1140 | 191 | return "rotation_lock"; | ||
1141 | 192 | } | ||
1142 | 193 | |||
1143 | 194 | /*** | ||
1144 | 195 | **** | ||
1145 | 196 | ***/ | ||
1146 | 197 | |||
1147 | 0 | 198 | ||
1148 | === added file 'src/rotation-lock.h' | |||
1149 | --- src/rotation-lock.h 1970-01-01 00:00:00 +0000 | |||
1150 | +++ src/rotation-lock.h 2014-08-22 00:07:37 +0000 | |||
1151 | @@ -0,0 +1,42 @@ | |||
1152 | 1 | /* | ||
1153 | 2 | * Copyright 2014 Canonical Ltd. | ||
1154 | 3 | * | ||
1155 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1156 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1157 | 6 | * by the Free Software Foundation. | ||
1158 | 7 | * | ||
1159 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1160 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1161 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1162 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1163 | 12 | * | ||
1164 | 13 | * You should have received a copy of the GNU General Public License along | ||
1165 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1166 | 15 | * | ||
1167 | 16 | * Authors: | ||
1168 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
1169 | 18 | */ | ||
1170 | 19 | |||
1171 | 20 | #ifndef INDICATOR_DISPLAY_ROTATION_LOCK_H | ||
1172 | 21 | #define INDICATOR_DISPLAY_ROTATION_LOCK_H | ||
1173 | 22 | |||
1174 | 23 | #include <src/indicator.h> | ||
1175 | 24 | |||
1176 | 25 | #include <memory> // std::unique_ptr | ||
1177 | 26 | |||
1178 | 27 | class RotationLockIndicator: public Indicator | ||
1179 | 28 | { | ||
1180 | 29 | public: | ||
1181 | 30 | RotationLockIndicator(); | ||
1182 | 31 | ~RotationLockIndicator(); | ||
1183 | 32 | |||
1184 | 33 | const char* name() const; | ||
1185 | 34 | GSimpleActionGroup* action_group() const; | ||
1186 | 35 | std::vector<std::shared_ptr<Profile>> profiles() const; | ||
1187 | 36 | |||
1188 | 37 | protected: | ||
1189 | 38 | class Impl; | ||
1190 | 39 | std::unique_ptr<Impl> impl; | ||
1191 | 40 | }; | ||
1192 | 41 | |||
1193 | 42 | #endif | ||
1194 | 0 | 43 | ||
1195 | === added directory 'tests' | |||
1196 | === added file 'tests/CMakeLists.txt' | |||
1197 | --- tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1198 | +++ tests/CMakeLists.txt 2014-08-22 00:07:37 +0000 | |||
1199 | @@ -0,0 +1,35 @@ | |||
1200 | 1 | include(FindGMock) | ||
1201 | 2 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
1202 | 3 | include_directories(${GMOCK_INCLUDE_DIRS}) | ||
1203 | 4 | include_directories(${GTEST_INCLUDE_DIRS}) | ||
1204 | 5 | |||
1205 | 6 | # build libgtest | ||
1206 | 7 | #add_library (gtest STATIC | ||
1207 | 8 | # ${GTEST_SOURCE_DIR}/gtest-all.cc | ||
1208 | 9 | # ${GTEST_SOURCE_DIR}/gtest_main.cc) | ||
1209 | 10 | #set_target_properties (gtest PROPERTIES INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${GTEST_INCLUDE_DIR}) | ||
1210 | 11 | #set_target_properties (gtest PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS} -w) | ||
1211 | 12 | |||
1212 | 13 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
1213 | 14 | # turn off the warnings that break Google Test | ||
1214 | 15 | set (CXX_WARNING_ARGS "${CXX_WARNING_ARGS} -Wno-global-constructors -Wno-weak-vtables -Wno-undef -Wno-c++98-compat-pedantic -Wno-missing-noreturn -Wno-used-but-marked-unused -Wno-padded -Wno-deprecated -Wno-sign-compare -Wno-shift-sign-overflow") | ||
1215 | 16 | endif() | ||
1216 | 17 | |||
1217 | 18 | SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g ${CXX_WARNING_ARGS}") | ||
1218 | 19 | |||
1219 | 20 | # look for headers in our src dir, and also in the directories where we autogenerate files... | ||
1220 | 21 | include_directories (${CMAKE_SOURCE_DIR}/src) | ||
1221 | 22 | include_directories (${CMAKE_CURRENT_BINARY_DIR}) | ||
1222 | 23 | include_directories (${DBUSTEST_INCLUDE_DIRS}) | ||
1223 | 24 | |||
1224 | 25 | function(add_test_by_name name) | ||
1225 | 26 | set (TEST_NAME ${name}) | ||
1226 | 27 | add_executable (${TEST_NAME} ${TEST_NAME}.cpp) | ||
1227 | 28 | add_test (${TEST_NAME} ${TEST_NAME}) | ||
1228 | 29 | add_dependencies (${TEST_NAME} libindicatordisplayservice) | ||
1229 | 30 | target_link_libraries (${TEST_NAME} indicatordisplayservice ${SERVICE_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES}) | ||
1230 | 31 | endfunction() | ||
1231 | 32 | add_test_by_name(test-rotation-lock) | ||
1232 | 33 | |||
1233 | 34 | add_test (cppcheck cppcheck --enable=all -q --error-exitcode=2 --inline-suppr -I${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests) | ||
1234 | 35 | |||
1235 | 0 | 36 | ||
1236 | === added file 'tests/glib-fixture.h' | |||
1237 | --- tests/glib-fixture.h 1970-01-01 00:00:00 +0000 | |||
1238 | +++ tests/glib-fixture.h 2014-08-22 00:07:37 +0000 | |||
1239 | @@ -0,0 +1,143 @@ | |||
1240 | 1 | /* | ||
1241 | 2 | * Copyright 2014 Canonical Ltd. | ||
1242 | 3 | * | ||
1243 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1244 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1245 | 6 | * by the Free Software Foundation. | ||
1246 | 7 | * | ||
1247 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1248 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1249 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1250 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1251 | 12 | * | ||
1252 | 13 | * You should have received a copy of the GNU General Public License along | ||
1253 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1254 | 15 | * | ||
1255 | 16 | * Authors: | ||
1256 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
1257 | 18 | */ | ||
1258 | 19 | |||
1259 | 20 | #include <map> | ||
1260 | 21 | |||
1261 | 22 | #include <glib.h> | ||
1262 | 23 | #include <glib/gstdio.h> | ||
1263 | 24 | #include <gio/gio.h> | ||
1264 | 25 | |||
1265 | 26 | #include <gtest/gtest.h> | ||
1266 | 27 | |||
1267 | 28 | #include <locale.h> // setlocale() | ||
1268 | 29 | |||
1269 | 30 | class GlibFixture : public ::testing::Test | ||
1270 | 31 | { | ||
1271 | 32 | private: | ||
1272 | 33 | |||
1273 | 34 | GLogFunc realLogHandler; | ||
1274 | 35 | |||
1275 | 36 | std::map<GLogLevelFlags,size_t> expected_log; | ||
1276 | 37 | std::map<GLogLevelFlags,std::vector<std::string>> log; | ||
1277 | 38 | |||
1278 | 39 | void test_log_counts() | ||
1279 | 40 | { | ||
1280 | 41 | const GLogLevelFlags levels_to_test[] = { G_LOG_LEVEL_ERROR, | ||
1281 | 42 | G_LOG_LEVEL_CRITICAL, | ||
1282 | 43 | G_LOG_LEVEL_MESSAGE, | ||
1283 | 44 | G_LOG_LEVEL_WARNING }; | ||
1284 | 45 | |||
1285 | 46 | for(const auto& level : levels_to_test) | ||
1286 | 47 | { | ||
1287 | 48 | const auto& v = log[level]; | ||
1288 | 49 | const auto n = v.size(); | ||
1289 | 50 | |||
1290 | 51 | EXPECT_EQ(expected_log[level], n); | ||
1291 | 52 | |||
1292 | 53 | if (expected_log[level] != n) | ||
1293 | 54 | for (size_t i=0; i<n; ++i) | ||
1294 | 55 | g_message("%d %s", (n+1), v[i].c_str()); | ||
1295 | 56 | } | ||
1296 | 57 | |||
1297 | 58 | expected_log.clear(); | ||
1298 | 59 | log.clear(); | ||
1299 | 60 | } | ||
1300 | 61 | |||
1301 | 62 | static void default_log_handler(const gchar * log_domain, | ||
1302 | 63 | GLogLevelFlags log_level, | ||
1303 | 64 | const gchar * message, | ||
1304 | 65 | gpointer self) | ||
1305 | 66 | { | ||
1306 | 67 | auto tmp = g_strdup_printf ("%s:%d \"%s\"", log_domain, (int)log_level, message); | ||
1307 | 68 | static_cast<GlibFixture*>(self)->log[log_level].push_back(tmp); | ||
1308 | 69 | g_free(tmp); | ||
1309 | 70 | } | ||
1310 | 71 | |||
1311 | 72 | protected: | ||
1312 | 73 | |||
1313 | 74 | void increment_expected_errors(GLogLevelFlags level, size_t n=1) | ||
1314 | 75 | { | ||
1315 | 76 | expected_log[level] += n; | ||
1316 | 77 | } | ||
1317 | 78 | |||
1318 | 79 | virtual void SetUp() | ||
1319 | 80 | { | ||
1320 | 81 | setlocale(LC_ALL, "C.UTF-8"); | ||
1321 | 82 | |||
1322 | 83 | loop = g_main_loop_new(nullptr, false); | ||
1323 | 84 | |||
1324 | 85 | g_log_set_default_handler(default_log_handler, this); | ||
1325 | 86 | |||
1326 | 87 | g_assert(g_setenv("GSETTINGS_BACKEND", "memory", true)); | ||
1327 | 88 | |||
1328 | 89 | g_unsetenv("DISPLAY"); | ||
1329 | 90 | } | ||
1330 | 91 | |||
1331 | 92 | virtual void TearDown() | ||
1332 | 93 | { | ||
1333 | 94 | test_log_counts(); | ||
1334 | 95 | |||
1335 | 96 | g_log_set_default_handler(realLogHandler, this); | ||
1336 | 97 | |||
1337 | 98 | g_clear_pointer(&loop, g_main_loop_unref); | ||
1338 | 99 | } | ||
1339 | 100 | |||
1340 | 101 | private: | ||
1341 | 102 | |||
1342 | 103 | static gboolean | ||
1343 | 104 | wait_for_signal__timeout(gpointer name) | ||
1344 | 105 | { | ||
1345 | 106 | g_error("%s: timed out waiting for signal '%s'", G_STRLOC, (char*)name); | ||
1346 | 107 | return G_SOURCE_REMOVE; | ||
1347 | 108 | } | ||
1348 | 109 | |||
1349 | 110 | static gboolean | ||
1350 | 111 | wait_msec__timeout(gpointer loop) | ||
1351 | 112 | { | ||
1352 | 113 | g_main_loop_quit(static_cast<GMainLoop*>(loop)); | ||
1353 | 114 | return G_SOURCE_CONTINUE; | ||
1354 | 115 | } | ||
1355 | 116 | |||
1356 | 117 | protected: | ||
1357 | 118 | |||
1358 | 119 | /* convenience func to loop while waiting for a GObject's signal */ | ||
1359 | 120 | void wait_for_signal(gpointer o, const gchar * signal, const guint timeout_seconds=5) | ||
1360 | 121 | { | ||
1361 | 122 | // wait for the signal or for timeout, whichever comes first | ||
1362 | 123 | const auto handler_id = g_signal_connect_swapped(o, signal, | ||
1363 | 124 | G_CALLBACK(g_main_loop_quit), | ||
1364 | 125 | loop); | ||
1365 | 126 | const auto timeout_id = g_timeout_add_seconds(timeout_seconds, | ||
1366 | 127 | wait_for_signal__timeout, | ||
1367 | 128 | loop); | ||
1368 | 129 | g_main_loop_run(loop); | ||
1369 | 130 | g_source_remove(timeout_id); | ||
1370 | 131 | g_signal_handler_disconnect(o, handler_id); | ||
1371 | 132 | } | ||
1372 | 133 | |||
1373 | 134 | /* convenience func to loop for N msec */ | ||
1374 | 135 | void wait_msec(guint msec=50) | ||
1375 | 136 | { | ||
1376 | 137 | const auto id = g_timeout_add(msec, wait_msec__timeout, loop); | ||
1377 | 138 | g_main_loop_run(loop); | ||
1378 | 139 | g_source_remove(id); | ||
1379 | 140 | } | ||
1380 | 141 | |||
1381 | 142 | GMainLoop * loop; | ||
1382 | 143 | }; | ||
1383 | 0 | 144 | ||
1384 | === added file 'tests/gtestdbus-fixture.h' | |||
1385 | --- tests/gtestdbus-fixture.h 1970-01-01 00:00:00 +0000 | |||
1386 | +++ tests/gtestdbus-fixture.h 2014-08-22 00:07:37 +0000 | |||
1387 | @@ -0,0 +1,102 @@ | |||
1388 | 1 | /* | ||
1389 | 2 | * Copyright 2013 Canonical Ltd. | ||
1390 | 3 | * | ||
1391 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1392 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1393 | 6 | * by the Free Software Foundation. | ||
1394 | 7 | * | ||
1395 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1396 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1397 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1398 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1399 | 12 | * | ||
1400 | 13 | * You should have received a copy of the GNU General Public License along | ||
1401 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1402 | 15 | * | ||
1403 | 16 | * Authors: | ||
1404 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
1405 | 18 | */ | ||
1406 | 19 | |||
1407 | 20 | #include "glib-fixture.h" | ||
1408 | 21 | |||
1409 | 22 | /*** | ||
1410 | 23 | **** | ||
1411 | 24 | ***/ | ||
1412 | 25 | |||
1413 | 26 | class GTestDBusFixture: public GlibFixture | ||
1414 | 27 | { | ||
1415 | 28 | public: | ||
1416 | 29 | |||
1417 | 30 | GTestDBusFixture() {} | ||
1418 | 31 | |||
1419 | 32 | GTestDBusFixture(const std::vector<std::string>& service_dirs_in): service_dirs(service_dirs_in) {} | ||
1420 | 33 | |||
1421 | 34 | private: | ||
1422 | 35 | |||
1423 | 36 | typedef GlibFixture super; | ||
1424 | 37 | |||
1425 | 38 | static void | ||
1426 | 39 | on_bus_opened (GObject* /*object*/, GAsyncResult * res, gpointer gself) | ||
1427 | 40 | { | ||
1428 | 41 | auto self = static_cast<GTestDBusFixture*>(gself); | ||
1429 | 42 | |||
1430 | 43 | GError * err = 0; | ||
1431 | 44 | self->bus = g_bus_get_finish (res, &err); | ||
1432 | 45 | g_assert_no_error (err); | ||
1433 | 46 | |||
1434 | 47 | g_main_loop_quit (self->loop); | ||
1435 | 48 | } | ||
1436 | 49 | |||
1437 | 50 | static void | ||
1438 | 51 | on_bus_closed (GObject* /*object*/, GAsyncResult * res, gpointer gself) | ||
1439 | 52 | { | ||
1440 | 53 | auto self = static_cast<GTestDBusFixture*>(gself); | ||
1441 | 54 | |||
1442 | 55 | GError * err = 0; | ||
1443 | 56 | g_dbus_connection_close_finish (self->bus, res, &err); | ||
1444 | 57 | g_assert_no_error (err); | ||
1445 | 58 | |||
1446 | 59 | g_main_loop_quit (self->loop); | ||
1447 | 60 | } | ||
1448 | 61 | |||
1449 | 62 | protected: | ||
1450 | 63 | |||
1451 | 64 | GTestDBus * test_dbus = nullptr; | ||
1452 | 65 | GDBusConnection * bus = nullptr; | ||
1453 | 66 | const std::vector<std::string> service_dirs; | ||
1454 | 67 | |||
1455 | 68 | virtual void SetUp () | ||
1456 | 69 | { | ||
1457 | 70 | super::SetUp (); | ||
1458 | 71 | |||
1459 | 72 | // pull up a test dbus | ||
1460 | 73 | test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); | ||
1461 | 74 | for (const auto& dir : service_dirs) | ||
1462 | 75 | g_test_dbus_add_service_dir (test_dbus, dir.c_str()); | ||
1463 | 76 | g_test_dbus_up (test_dbus); | ||
1464 | 77 | const char * address = g_test_dbus_get_bus_address (test_dbus); | ||
1465 | 78 | g_setenv ("DBUS_SYSTEM_BUS_ADDRESS", address, true); | ||
1466 | 79 | g_setenv ("DBUS_SESSION_BUS_ADDRESS", address, true); | ||
1467 | 80 | g_debug ("test_dbus's address is %s", address); | ||
1468 | 81 | |||
1469 | 82 | // wait for the GDBusConnection before returning | ||
1470 | 83 | g_bus_get (G_BUS_TYPE_SYSTEM, nullptr, on_bus_opened, this); | ||
1471 | 84 | g_main_loop_run (loop); | ||
1472 | 85 | } | ||
1473 | 86 | |||
1474 | 87 | virtual void TearDown () | ||
1475 | 88 | { | ||
1476 | 89 | wait_msec(); | ||
1477 | 90 | |||
1478 | 91 | // close the system bus | ||
1479 | 92 | g_dbus_connection_close(bus, nullptr, on_bus_closed, this); | ||
1480 | 93 | g_main_loop_run(loop); | ||
1481 | 94 | g_clear_object(&bus); | ||
1482 | 95 | |||
1483 | 96 | // tear down the test dbus | ||
1484 | 97 | g_test_dbus_down(test_dbus); | ||
1485 | 98 | g_clear_object(&test_dbus); | ||
1486 | 99 | |||
1487 | 100 | super::TearDown(); | ||
1488 | 101 | } | ||
1489 | 102 | }; | ||
1490 | 0 | 103 | ||
1491 | === added file 'tests/manual' | |||
1492 | --- tests/manual 1970-01-01 00:00:00 +0000 | |||
1493 | +++ tests/manual 2014-08-22 00:07:37 +0000 | |||
1494 | @@ -0,0 +1,16 @@ | |||
1495 | 1 | |||
1496 | 2 | Test-case indicator-display/rotation-indicator | ||
1497 | 3 | <dl> | ||
1498 | 4 | <dt>On the phone, enable the orientation lock in ubuntu-system-settings.</dt> | ||
1499 | 5 | <dd>The rotation lock indicator should appear, and its switch menuitem should be set to 'true'.</dd> | ||
1500 | 6 | |||
1501 | 7 | <dt>With the orientation locked, click on the indicator's switch menuitem to toggle from locked to unlocked.</dd> | ||
1502 | 8 | <dd>The rotation lock indicator should disappear</dd> | ||
1503 | 9 | <dd>In ubuntu-system-settings, the orientation lock control should change to 'none'.</dd> | ||
1504 | 10 | </dl> | ||
1505 | 11 | |||
1506 | 12 | |||
1507 | 13 | <strong> | ||
1508 | 14 | If all actions produce the expected results listed, please <a href="results#add_result">submit</a> a 'passed' result. | ||
1509 | 15 | If an action fails, or produces an unexpected result, please <a href="results#add_result">submit</a> a 'failed' result and <a href="../../buginstructions">file a bug</a>. Please be sure to include the bug number when you <a href="results#add_result">submit</a> your result</strong>. | ||
1510 | 16 | |||
1511 | 0 | 17 | ||
1512 | === added file 'tests/test-rotation-lock.cpp' | |||
1513 | --- tests/test-rotation-lock.cpp 1970-01-01 00:00:00 +0000 | |||
1514 | +++ tests/test-rotation-lock.cpp 2014-08-22 00:07:37 +0000 | |||
1515 | @@ -0,0 +1,61 @@ | |||
1516 | 1 | /* | ||
1517 | 2 | * Copyright 2014 Canonical Ltd. | ||
1518 | 3 | * | ||
1519 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1520 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1521 | 6 | * by the Free Software Foundation. | ||
1522 | 7 | * | ||
1523 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1524 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1525 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1526 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1527 | 12 | * | ||
1528 | 13 | * You should have received a copy of the GNU General Public License along | ||
1529 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1530 | 15 | * | ||
1531 | 16 | * Authors: | ||
1532 | 17 | * Charles Kerr <charles.kerr@canonical.com> | ||
1533 | 18 | */ | ||
1534 | 19 | |||
1535 | 20 | #include "gtestdbus-fixture.h" | ||
1536 | 21 | |||
1537 | 22 | #include <src/rotation-lock.h> | ||
1538 | 23 | |||
1539 | 24 | class RotationLockFixture: public GTestDBusFixture | ||
1540 | 25 | { | ||
1541 | 26 | private: | ||
1542 | 27 | typedef GTestDBusFixture super; | ||
1543 | 28 | |||
1544 | 29 | protected: | ||
1545 | 30 | |||
1546 | 31 | void SetUp() | ||
1547 | 32 | { | ||
1548 | 33 | super::SetUp(); | ||
1549 | 34 | } | ||
1550 | 35 | |||
1551 | 36 | void TearDown() | ||
1552 | 37 | { | ||
1553 | 38 | super::TearDown(); | ||
1554 | 39 | } | ||
1555 | 40 | }; | ||
1556 | 41 | |||
1557 | 42 | /*** | ||
1558 | 43 | **** | ||
1559 | 44 | ***/ | ||
1560 | 45 | |||
1561 | 46 | TEST_F(RotationLockFixture, CheckIndicator) | ||
1562 | 47 | { | ||
1563 | 48 | RotationLockIndicator indicator; | ||
1564 | 49 | |||
1565 | 50 | ASSERT_STREQ("rotation_lock", indicator.name()); | ||
1566 | 51 | auto actions = indicator.action_group(); | ||
1567 | 52 | ASSERT_TRUE(actions != nullptr); | ||
1568 | 53 | ASSERT_TRUE(g_action_group_has_action(G_ACTION_GROUP(actions), "rotation-lock")); | ||
1569 | 54 | |||
1570 | 55 | std::vector<std::shared_ptr<Profile>> profiles = indicator.profiles(); | ||
1571 | 56 | ASSERT_EQ(1, profiles.size()); | ||
1572 | 57 | std::shared_ptr<Profile> phone = profiles[0]; | ||
1573 | 58 | ASSERT_EQ(std::string("phone"), phone->name()); | ||
1574 | 59 | ASSERT_FALSE(phone->header()->is_visible); | ||
1575 | 60 | } | ||
1576 | 61 |
FAILED: Continuous integration, rev:8 jenkins. qa.ubuntu. com/job/ indicator- display- ci/1/ jenkins. qa.ubuntu. com/job/ indicator- display- utopic- amd64-ci/ 1/console jenkins. qa.ubuntu. com/job/ indicator- display- utopic- armhf-ci/ 1/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- display- ci/1/rebuild
http://