Merge lp:~audience-members/audience/gtk-3.12 into lp:~audience-members/audience/trunk
- gtk-3.12
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Cody Garver | ||||||||
Approved revision: | 355 | ||||||||
Merged at revision: | 351 | ||||||||
Proposed branch: | lp:~audience-members/audience/gtk-3.12 | ||||||||
Merge into: | lp:~audience-members/audience/trunk | ||||||||
Diff against target: |
4734 lines (+1792/-2173) 27 files modified
CMakeLists.txt (+3/-59) cmake/FindGirCompiler.cmake (+56/-0) cmake/GObjectIntrospectionMacros.cmake (+34/-0) cmake/Makefile (+0/-286) cmake/Translations.cmake (+37/-12) cmake/ValaPrecompile.cmake (+75/-12) data/CMakeLists.txt (+12/-0) data/org.pantheon.audience.gschema.xml (+10/-5) src/Audience.vala (+467/-473) src/CMakeLists.txt (+57/-0) src/Consts.vala (+3/-2) src/DiskManager.vala (+98/-0) src/Settings.vala (+35/-18) src/Utils.vala (+56/-202) src/Widgets/BottomBar.vala (+160/-0) src/Widgets/Button.vala (+0/-53) src/Widgets/ControlsBar.vala (+0/-137) src/Widgets/LLabel.vala (+0/-27) src/Widgets/MediaSlider.vala (+0/-238) src/Widgets/Playlist.vala (+92/-57) src/Widgets/PlaylistPopover.vala (+116/-0) src/Widgets/PreviewPopover.vala (+90/-0) src/Widgets/SettingsPopover.vala (+166/-0) src/Widgets/TagView.vala (+0/-253) src/Widgets/TimeWidget.vala (+127/-0) src/Widgets/TopPanel.vala (+0/-87) src/Widgets/VideoPlayer.vala (+98/-252) |
||||||||
To merge this branch: | bzr merge lp:~audience-members/audience/gtk-3.12 | ||||||||
Related bugs: |
|
||||||||
Related blueprints: |
Update to Gtk 3.12
(Medium)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cody Garver | Needs Fixing | ||
Robert Roth (community) | Abstain | ||
Review via email: mp+223919@code.launchpad.net |
Commit message
Ported all UI widgets to pure Gtk 3.12
Description of the change
Ported all UI widgets to pure Gtk.
- 348. By Corentin Noël
-
Synchronized with trunk.
David Gomes (davidgomes) wrote : | # |
Agreed with Robert here. Corentin, can you explain us if any of these changes included in this branch (mentioned by Robert) have anything to do with GTK+ 3.12?
Corentin Noël (tintou) wrote : | # |
They are not Gtk3.12 related but they are a full part of the project
reorganization (if you look at the changes, a lot of code has been removed).
Le 21 juin 2014 14:45, "David Gomes" <email address hidden> a écrit :
> Agreed with Robert here. Corentin, can you explain us if any of these
> changes included in this branch (mentioned by Robert) have anything to do
> with GTK+ 3.12?
> --
>
> https:/
> You proposed lp:~audience-members/audience/gtk-3.12 for merging.
>
Cody Garver (codygarver) wrote : | # |
- Each video in the playlist is duplicated 01.mkv 01.mkv 02.mkv 02.mkv
- This video doesn't show the controls for me unless I fullscreen then unfullscreen:
https:/
- More than 1 video in the playlist requires a scrollbar even if there's available space above
- This video has black bars on the left and right when played windowed:
https:/
Cody Garver (codygarver) wrote : | # |
Also doesn't properly detect/display the Audio and Subtitle of the video with black bars I linked
- 349. By Corentin Noël
-
Multiple Fixes to the interface.
- 350. By Corentin Noël
-
Fix Aspect not replacing the bottombar.
Corentin Noël (tintou) wrote : | # |
Cody: I've pushed a fix for the problems you pointed out.
- 351. By Cody Garver
-
Add a couple spaces in CMakeLists.txt
- 352. By Cody Garver
-
Merge in trunk
Cody Garver (codygarver) wrote : | # |
I'm still getting black bars on left/right of this video in windowed mode https:/
Cody Garver (codygarver) wrote : | # |
- Welcome screen does no longer offers to resume last played video
- Welcome screen always offers to play a DVD
- 353. By Cody Garver
-
Restore comment about C warnings
Cody Garver (codygarver) wrote : | # |
private void on_destroy () has a block of commented out code
Corentin Noël (tintou) wrote : | # |
I only have black bars on left/right black bars because the video size>screen size. You maybe have an higher resolution as me.
- 354. By Corentin Noël
-
Check if the media is a DVD or BlueRay.
- 355. By Corentin Noël
-
Fixed saving videos when closing the application.
Cody Garver (codygarver) wrote : | # |
Every video has black bars on the side, my display resolution is 1080p
Robert Roth (evfool) wrote : | # |
@Cody Garver: Do you get the black bars only in windowed mode? For FullHD movies (e.g. one MKV anime you've shared on slack) for me the black bars only appear in windowed mode, fullscreen is true fullscreen without black bars.
Danielle Foré (danrabbit) wrote : | # |
I can confirm that the black bars on the side show up in windowed, but not fullscreen
Cody Garver (codygarver) wrote : | # |
Well black bars are happening for me with trunk now too. The problem is outside of this branch?
Robert Roth (evfool) wrote : | # |
It looks that the headerbar is the thing to blame on this branch, commenting the set_titlebar line out fixes the issue.
In case of an 1280x720 video the window size is set to 1280x720 (+decorations) in case there is no headerbar, and with headerbar the size is also set to 1280x720, but that includes the CSD size, so the size allocated to the clutterembed is only 1174x572. The headerbar height for me is 42px, so strangely, that's not the only difference.
Corentin Noël (tintou) wrote : | # |
For CSD windows, the size also contains shadows so it's maybe linked. In all cases i don't think it's a merge-blocker…
Cody Garver (codygarver) wrote : | # |
It is indeed export GTK_CSD=1 that causes the bug, not your fault tintou
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-05-02 13:04:44 +0000 | |||
3 | +++ CMakeLists.txt 2014-07-06 11:18:29 +0000 | |||
4 | @@ -4,7 +4,7 @@ | |||
5 | 4 | enable_testing () | 4 | enable_testing () |
6 | 5 | list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | 5 | list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) |
7 | 6 | 6 | ||
9 | 7 | project (audience) | 7 | project (audience C) |
10 | 8 | 8 | ||
11 | 9 | set (DATADIR ${CMAKE_INSTALL_PREFIX}/share) | 9 | set (DATADIR ${CMAKE_INSTALL_PREFIX}/share) |
12 | 10 | set (PKGDATADIR ${DATADIR}/${CMAKE_PROJECT_NAME}) | 10 | set (PKGDATADIR ${DATADIR}/${CMAKE_PROJECT_NAME}) |
13 | @@ -18,17 +18,6 @@ | |||
14 | 18 | # Comment this out to enable C compiler warnings | 18 | # Comment this out to enable C compiler warnings |
15 | 19 | add_definitions (-w) | 19 | add_definitions (-w) |
16 | 20 | 20 | ||
17 | 21 | # Data | ||
18 | 22 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/16/audience.svg DESTINATION ${DATADIR}/icons/hicolor/16x16/apps/) | ||
19 | 23 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/24/audience.svg DESTINATION ${DATADIR}/icons/hicolor/24x24/apps/) | ||
20 | 24 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/32/audience.svg DESTINATION ${DATADIR}/icons/hicolor/32x32/apps/) | ||
21 | 25 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/48/audience.svg DESTINATION ${DATADIR}/icons/hicolor/48x48/apps/) | ||
22 | 26 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/64/audience.svg DESTINATION ${DATADIR}/icons/hicolor/64x64/apps/) | ||
23 | 27 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/icons/128/audience.svg DESTINATION ${DATADIR}/icons/hicolor/128x128/apps/) | ||
24 | 28 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/audience.desktop DESTINATION ${DATADIR}/applications/) | ||
25 | 29 | |||
26 | 30 | # Configure file | ||
27 | 31 | configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.cmake ${CMAKE_BINARY_DIR}/src/Config.vala) | ||
28 | 32 | 21 | ||
29 | 33 | set (CPACK_PACKAGE_VERSION ${VERSION}) | 22 | set (CPACK_PACKAGE_VERSION ${VERSION}) |
30 | 34 | set (CPACK_SOURCE_GENERATOR "TGZ") | 23 | set (CPACK_SOURCE_GENERATOR "TGZ") |
31 | @@ -38,54 +27,9 @@ | |||
32 | 38 | include (CPack) | 27 | include (CPack) |
33 | 39 | add_custom_target (dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) | 28 | add_custom_target (dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) |
34 | 40 | 29 | ||
80 | 41 | find_package (PkgConfig) | 30 | add_subdirectory (src) |
81 | 42 | pkg_check_modules (DEPS REQUIRED granite clutter-gtk-1.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-tag-1.0) | 31 | add_subdirectory (data) |
37 | 43 | |||
38 | 44 | add_definitions (${DEPS_CFLAGS}) | ||
39 | 45 | link_libraries (${DEPS_LIBRARIES}) | ||
40 | 46 | link_directories (${DEPS_LIBRARY_DIRS}) | ||
41 | 47 | find_package (Vala REQUIRED) | ||
42 | 48 | include (ValaVersion) | ||
43 | 49 | |||
44 | 50 | ensure_vala_version ("0.16.1" MINIMUM) | ||
45 | 51 | |||
46 | 52 | include (ValaPrecompile) | ||
47 | 53 | vala_precompile (VALA_C | ||
48 | 54 | ${CMAKE_BINARY_DIR}/src/Config.vala | ||
49 | 55 | src/Audience.vala | ||
50 | 56 | src/Consts.vala | ||
51 | 57 | src/desktop-launcher.vala | ||
52 | 58 | src/Settings.vala | ||
53 | 59 | src/Utils.vala | ||
54 | 60 | src/Widgets/Button.vala | ||
55 | 61 | src/Widgets/ControlsBar.vala | ||
56 | 62 | src/Widgets/LLabel.vala | ||
57 | 63 | src/Widgets/MediaSlider.vala | ||
58 | 64 | src/Widgets/Playlist.vala | ||
59 | 65 | src/Widgets/TagView.vala | ||
60 | 66 | src/Widgets/TopPanel.vala | ||
61 | 67 | src/Widgets/VideoPlayer.vala | ||
62 | 68 | PACKAGES | ||
63 | 69 | clutter-gtk-1.0 | ||
64 | 70 | granite | ||
65 | 71 | gdk-x11-3.0 | ||
66 | 72 | gstreamer-1.0 | ||
67 | 73 | gstreamer-pbutils-1.0 | ||
68 | 74 | gstreamer-tag-1.0 | ||
69 | 75 | OPTIONS | ||
70 | 76 | --enable-experimental | ||
71 | 77 | --target-glib=2.32 | ||
72 | 78 | --thread | ||
73 | 79 | -g | ||
74 | 80 | ) | ||
75 | 81 | |||
76 | 82 | |||
77 | 83 | include (GSettings) | ||
78 | 84 | add_schema ("data/org.pantheon.audience.gschema.xml") | ||
79 | 85 | |||
82 | 86 | add_subdirectory (po) | 32 | add_subdirectory (po) |
83 | 87 | add_executable (${CMAKE_PROJECT_NAME} ${VALA_C}) | ||
84 | 88 | install (TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin) | ||
85 | 89 | 33 | ||
86 | 90 | # uninstall target | 34 | # uninstall target |
87 | 91 | configure_file ( | 35 | configure_file ( |
88 | 92 | 36 | ||
89 | === added file 'cmake/FindGirCompiler.cmake' | |||
90 | --- cmake/FindGirCompiler.cmake 1970-01-01 00:00:00 +0000 | |||
91 | +++ cmake/FindGirCompiler.cmake 2014-07-06 11:18:29 +0000 | |||
92 | @@ -0,0 +1,56 @@ | |||
93 | 1 | ## | ||
94 | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | ||
95 | 3 | # | ||
96 | 4 | # Redistribution and use in source and binary forms, with or without | ||
97 | 5 | # modification, are permitted provided that the following conditions are met: | ||
98 | 6 | # | ||
99 | 7 | # 1. Redistributions of source code must retain the above copyright notice, | ||
100 | 8 | # this list of conditions and the following disclaimer. | ||
101 | 9 | # | ||
102 | 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
103 | 11 | # this list of conditions and the following disclaimer in the documentation | ||
104 | 12 | # and/or other materials provided with the distribution. | ||
105 | 13 | # | ||
106 | 14 | # THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR | ||
107 | 15 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
108 | 16 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
109 | 17 | # EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
110 | 18 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
111 | 19 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
112 | 20 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
113 | 21 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
114 | 22 | # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
115 | 23 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
116 | 24 | # | ||
117 | 25 | # The views and conclusions contained in the software and documentation are those | ||
118 | 26 | # of the authors and should not be interpreted as representing official policies, | ||
119 | 27 | # either expressed or implied, of Jakob Westhoff | ||
120 | 28 | ## | ||
121 | 29 | |||
122 | 30 | ## | ||
123 | 31 | # Find module for the Gir compiler (g-ir-compiler) | ||
124 | 32 | # | ||
125 | 33 | # This module determines wheter a Gir compiler is installed on the current | ||
126 | 34 | # system and where its executable is. | ||
127 | 35 | # | ||
128 | 36 | # Call the module using "find_package(GirCompiler) from within your CMakeLists.txt. | ||
129 | 37 | # | ||
130 | 38 | # The following variables will be set after an invocation: | ||
131 | 39 | # | ||
132 | 40 | # G_IR_COMPILER_FOUND Whether the g-ir-compiler compiler has been found or not | ||
133 | 41 | # G_IR_COMPILER_EXECUTABLE Full path to the g-ir-compiler executable if it has been found | ||
134 | 42 | ## | ||
135 | 43 | |||
136 | 44 | |||
137 | 45 | # Search for the g-ir-compiler executable in the usual system paths. | ||
138 | 46 | find_program (G_IR_COMPILER_EXECUTABLE | ||
139 | 47 | NAMES g-ir-compiler) | ||
140 | 48 | |||
141 | 49 | # Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. | ||
142 | 50 | # Furthermore set G_IR_COMPILER_FOUND to TRUE if the g-ir-compiler has been found (aka. | ||
143 | 51 | # G_IR_COMPILER_EXECUTABLE is set) | ||
144 | 52 | |||
145 | 53 | include (FindPackageHandleStandardArgs) | ||
146 | 54 | find_package_handle_standard_args (GirCompiler DEFAULT_MSG G_IR_COMPILER_EXECUTABLE) | ||
147 | 55 | |||
148 | 56 | mark_as_advanced (G_IR_COMPILER_EXECUTABLE) | ||
149 | 0 | 57 | ||
150 | === added file 'cmake/GObjectIntrospectionMacros.cmake' | |||
151 | --- cmake/GObjectIntrospectionMacros.cmake 1970-01-01 00:00:00 +0000 | |||
152 | +++ cmake/GObjectIntrospectionMacros.cmake 2014-07-06 11:18:29 +0000 | |||
153 | @@ -0,0 +1,34 @@ | |||
154 | 1 | macro(add_target_gir TARGET_NAME GIR_NAME HEADER CFLAGS GRANITE_VERSION) | ||
155 | 2 | set(PACKAGES "") | ||
156 | 3 | foreach(PKG ${ARGN}) | ||
157 | 4 | set(PACKAGES ${PACKAGES} --include=${PKG}) | ||
158 | 5 | endforeach() | ||
159 | 6 | install(CODE "set(ENV{LD_LIBRARY_PATH} \"${CMAKE_CURRENT_BINARY_DIR}:\$ENV{LD_LIBRARY_PATH}\") | ||
160 | 7 | execute_process(COMMAND g-ir-scanner ${CFLAGS} -n ${GIR_NAME} | ||
161 | 8 | --quiet | ||
162 | 9 | --library ${TARGET_NAME} ${PACKAGES} | ||
163 | 10 | -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir | ||
164 | 11 | -L${CMAKE_CURRENT_BINARY_DIR} | ||
165 | 12 | --nsversion=${GRANITE_VERSION} ${HEADER})") | ||
166 | 13 | install(CODE "execute_process(COMMAND g-ir-compiler ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib)") | ||
167 | 14 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir DESTINATION share/gir-1.0/) | ||
168 | 15 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib DESTINATION lib/girepository-1.0/) | ||
169 | 16 | endmacro() | ||
170 | 17 | |||
171 | 18 | macro(add_target_gir_with_executable TARGET_NAME EXE_NAME GIR_NAME HEADER EXE_HEADER CFLAGS GRANITE_VERSION) | ||
172 | 19 | set(PACKAGES "") | ||
173 | 20 | foreach(PKG ${ARGN}) | ||
174 | 21 | set(PACKAGES ${PACKAGES} --include=${PKG}) | ||
175 | 22 | endforeach() | ||
176 | 23 | install(CODE "set(ENV{LD_LIBRARY_PATH} \"${CMAKE_CURRENT_BINARY_DIR}:\$ENV{LD_LIBRARY_PATH}\") | ||
177 | 24 | execute_process(COMMAND g-ir-scanner ${CFLAGS} -n ${GIR_NAME} | ||
178 | 25 | --quiet | ||
179 | 26 | --library ${TARGET_NAME} --program ${EXE_NAME} ${PACKAGES} | ||
180 | 27 | -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir | ||
181 | 28 | -L${CMAKE_CURRENT_BINARY_DIR} | ||
182 | 29 | -I${CMAKE_CURRENT_BINARY_DIR} | ||
183 | 30 | --nsversion=${GRANITE_VERSION} ${HEADER} ${EXE_HEADER})") | ||
184 | 31 | install(CODE "execute_process(COMMAND g-ir-compiler ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir -o ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib)") | ||
185 | 32 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.gir DESTINATION share/gir-1.0/) | ||
186 | 33 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GIR_NAME}-${GRANITE_VERSION}.typelib DESTINATION lib/girepository-1.0/) | ||
187 | 34 | endmacro() | ||
188 | 0 | 35 | ||
189 | === removed file 'cmake/Makefile' | |||
190 | --- cmake/Makefile 2011-12-13 18:08:48 +0000 | |||
191 | +++ cmake/Makefile 1970-01-01 00:00:00 +0000 | |||
192 | @@ -1,286 +0,0 @@ | |||
193 | 1 | # CMAKE generated file: DO NOT EDIT! | ||
194 | 2 | # Generated by "Unix Makefiles" Generator, CMake Version 2.8 | ||
195 | 3 | |||
196 | 4 | # Default target executed when no arguments are given to make. | ||
197 | 5 | default_target: all | ||
198 | 6 | .PHONY : default_target | ||
199 | 7 | |||
200 | 8 | #============================================================================= | ||
201 | 9 | # Special targets provided by cmake. | ||
202 | 10 | |||
203 | 11 | # Disable implicit rules so canoncical targets will work. | ||
204 | 12 | .SUFFIXES: | ||
205 | 13 | |||
206 | 14 | # Remove some rules from gmake that .SUFFIXES does not remove. | ||
207 | 15 | SUFFIXES = | ||
208 | 16 | |||
209 | 17 | .SUFFIXES: .hpux_make_needs_suffix_list | ||
210 | 18 | |||
211 | 19 | # Suppress display of executed commands. | ||
212 | 20 | $(VERBOSE).SILENT: | ||
213 | 21 | |||
214 | 22 | # A target that is always out of date. | ||
215 | 23 | cmake_force: | ||
216 | 24 | .PHONY : cmake_force | ||
217 | 25 | |||
218 | 26 | #============================================================================= | ||
219 | 27 | # Set environment variables for the build. | ||
220 | 28 | |||
221 | 29 | # The shell in which to execute make rules. | ||
222 | 30 | SHELL = /bin/sh | ||
223 | 31 | |||
224 | 32 | # The CMake executable. | ||
225 | 33 | CMAKE_COMMAND = /usr/bin/cmake | ||
226 | 34 | |||
227 | 35 | # The command to remove a file. | ||
228 | 36 | RM = /usr/bin/cmake -E remove -f | ||
229 | 37 | |||
230 | 38 | # The top-level source directory on which CMake was run. | ||
231 | 39 | CMAKE_SOURCE_DIR = /home/mefrio/Scrivania/cmake | ||
232 | 40 | |||
233 | 41 | # The top-level build directory on which CMake was run. | ||
234 | 42 | CMAKE_BINARY_DIR = /home/mefrio/Scrivania/cmake/cmake | ||
235 | 43 | |||
236 | 44 | #============================================================================= | ||
237 | 45 | # Targets provided globally by CMake. | ||
238 | 46 | |||
239 | 47 | # Special rule for the target edit_cache | ||
240 | 48 | edit_cache: | ||
241 | 49 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." | ||
242 | 50 | /usr/bin/cmake -i . | ||
243 | 51 | .PHONY : edit_cache | ||
244 | 52 | |||
245 | 53 | # Special rule for the target edit_cache | ||
246 | 54 | edit_cache/fast: edit_cache | ||
247 | 55 | .PHONY : edit_cache/fast | ||
248 | 56 | |||
249 | 57 | # Special rule for the target install | ||
250 | 58 | install: preinstall | ||
251 | 59 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
252 | 60 | /usr/bin/cmake -P cmake_install.cmake | ||
253 | 61 | .PHONY : install | ||
254 | 62 | |||
255 | 63 | # Special rule for the target install | ||
256 | 64 | install/fast: preinstall/fast | ||
257 | 65 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
258 | 66 | /usr/bin/cmake -P cmake_install.cmake | ||
259 | 67 | .PHONY : install/fast | ||
260 | 68 | |||
261 | 69 | # Special rule for the target install/local | ||
262 | 70 | install/local: preinstall | ||
263 | 71 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." | ||
264 | 72 | /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake | ||
265 | 73 | .PHONY : install/local | ||
266 | 74 | |||
267 | 75 | # Special rule for the target install/local | ||
268 | 76 | install/local/fast: install/local | ||
269 | 77 | .PHONY : install/local/fast | ||
270 | 78 | |||
271 | 79 | # Special rule for the target install/strip | ||
272 | 80 | install/strip: preinstall | ||
273 | 81 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." | ||
274 | 82 | /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake | ||
275 | 83 | .PHONY : install/strip | ||
276 | 84 | |||
277 | 85 | # Special rule for the target install/strip | ||
278 | 86 | install/strip/fast: install/strip | ||
279 | 87 | .PHONY : install/strip/fast | ||
280 | 88 | |||
281 | 89 | # Special rule for the target list_install_components | ||
282 | 90 | list_install_components: | ||
283 | 91 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" | ||
284 | 92 | .PHONY : list_install_components | ||
285 | 93 | |||
286 | 94 | # Special rule for the target list_install_components | ||
287 | 95 | list_install_components/fast: list_install_components | ||
288 | 96 | .PHONY : list_install_components/fast | ||
289 | 97 | |||
290 | 98 | # Special rule for the target rebuild_cache | ||
291 | 99 | rebuild_cache: | ||
292 | 100 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." | ||
293 | 101 | /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
294 | 102 | .PHONY : rebuild_cache | ||
295 | 103 | |||
296 | 104 | # Special rule for the target rebuild_cache | ||
297 | 105 | rebuild_cache/fast: rebuild_cache | ||
298 | 106 | .PHONY : rebuild_cache/fast | ||
299 | 107 | |||
300 | 108 | # The main all target | ||
301 | 109 | all: cmake_check_build_system | ||
302 | 110 | $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles /home/mefrio/Scrivania/cmake/cmake/CMakeFiles/progress.marks | ||
303 | 111 | $(MAKE) -f CMakeFiles/Makefile2 all | ||
304 | 112 | $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles 0 | ||
305 | 113 | .PHONY : all | ||
306 | 114 | |||
307 | 115 | # The main clean target | ||
308 | 116 | clean: | ||
309 | 117 | $(MAKE) -f CMakeFiles/Makefile2 clean | ||
310 | 118 | .PHONY : clean | ||
311 | 119 | |||
312 | 120 | # The main clean target | ||
313 | 121 | clean/fast: clean | ||
314 | 122 | .PHONY : clean/fast | ||
315 | 123 | |||
316 | 124 | # Prepare targets for installation. | ||
317 | 125 | preinstall: all | ||
318 | 126 | $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
319 | 127 | .PHONY : preinstall | ||
320 | 128 | |||
321 | 129 | # Prepare targets for installation. | ||
322 | 130 | preinstall/fast: | ||
323 | 131 | $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
324 | 132 | .PHONY : preinstall/fast | ||
325 | 133 | |||
326 | 134 | # clear depends | ||
327 | 135 | depend: | ||
328 | 136 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | ||
329 | 137 | .PHONY : depend | ||
330 | 138 | |||
331 | 139 | #============================================================================= | ||
332 | 140 | # Target rules for targets named scratch | ||
333 | 141 | |||
334 | 142 | # Build rule for target. | ||
335 | 143 | scratch: cmake_check_build_system | ||
336 | 144 | $(MAKE) -f CMakeFiles/Makefile2 scratch | ||
337 | 145 | .PHONY : scratch | ||
338 | 146 | |||
339 | 147 | # fast build rule for target. | ||
340 | 148 | scratch/fast: | ||
341 | 149 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/build | ||
342 | 150 | .PHONY : scratch/fast | ||
343 | 151 | |||
344 | 152 | src/entry.o: src/entry.c.o | ||
345 | 153 | .PHONY : src/entry.o | ||
346 | 154 | |||
347 | 155 | # target to build an object file | ||
348 | 156 | src/entry.c.o: | ||
349 | 157 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.o | ||
350 | 158 | .PHONY : src/entry.c.o | ||
351 | 159 | |||
352 | 160 | src/entry.i: src/entry.c.i | ||
353 | 161 | .PHONY : src/entry.i | ||
354 | 162 | |||
355 | 163 | # target to preprocess a source file | ||
356 | 164 | src/entry.c.i: | ||
357 | 165 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.i | ||
358 | 166 | .PHONY : src/entry.c.i | ||
359 | 167 | |||
360 | 168 | src/entry.s: src/entry.c.s | ||
361 | 169 | .PHONY : src/entry.s | ||
362 | 170 | |||
363 | 171 | # target to generate assembly for a file | ||
364 | 172 | src/entry.c.s: | ||
365 | 173 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.s | ||
366 | 174 | .PHONY : src/entry.c.s | ||
367 | 175 | |||
368 | 176 | src/main_window.o: src/main_window.c.o | ||
369 | 177 | .PHONY : src/main_window.o | ||
370 | 178 | |||
371 | 179 | # target to build an object file | ||
372 | 180 | src/main_window.c.o: | ||
373 | 181 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.o | ||
374 | 182 | .PHONY : src/main_window.c.o | ||
375 | 183 | |||
376 | 184 | src/main_window.i: src/main_window.c.i | ||
377 | 185 | .PHONY : src/main_window.i | ||
378 | 186 | |||
379 | 187 | # target to preprocess a source file | ||
380 | 188 | src/main_window.c.i: | ||
381 | 189 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.i | ||
382 | 190 | .PHONY : src/main_window.c.i | ||
383 | 191 | |||
384 | 192 | src/main_window.s: src/main_window.c.s | ||
385 | 193 | .PHONY : src/main_window.s | ||
386 | 194 | |||
387 | 195 | # target to generate assembly for a file | ||
388 | 196 | src/main_window.c.s: | ||
389 | 197 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.s | ||
390 | 198 | .PHONY : src/main_window.c.s | ||
391 | 199 | |||
392 | 200 | src/menu.o: src/menu.c.o | ||
393 | 201 | .PHONY : src/menu.o | ||
394 | 202 | |||
395 | 203 | # target to build an object file | ||
396 | 204 | src/menu.c.o: | ||
397 | 205 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.o | ||
398 | 206 | .PHONY : src/menu.c.o | ||
399 | 207 | |||
400 | 208 | src/menu.i: src/menu.c.i | ||
401 | 209 | .PHONY : src/menu.i | ||
402 | 210 | |||
403 | 211 | # target to preprocess a source file | ||
404 | 212 | src/menu.c.i: | ||
405 | 213 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.i | ||
406 | 214 | .PHONY : src/menu.c.i | ||
407 | 215 | |||
408 | 216 | src/menu.s: src/menu.c.s | ||
409 | 217 | .PHONY : src/menu.s | ||
410 | 218 | |||
411 | 219 | # target to generate assembly for a file | ||
412 | 220 | src/menu.c.s: | ||
413 | 221 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.s | ||
414 | 222 | .PHONY : src/menu.c.s | ||
415 | 223 | |||
416 | 224 | src/notebook.o: src/notebook.c.o | ||
417 | 225 | .PHONY : src/notebook.o | ||
418 | 226 | |||
419 | 227 | # target to build an object file | ||
420 | 228 | src/notebook.c.o: | ||
421 | 229 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.o | ||
422 | 230 | .PHONY : src/notebook.c.o | ||
423 | 231 | |||
424 | 232 | src/notebook.i: src/notebook.c.i | ||
425 | 233 | .PHONY : src/notebook.i | ||
426 | 234 | |||
427 | 235 | # target to preprocess a source file | ||
428 | 236 | src/notebook.c.i: | ||
429 | 237 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.i | ||
430 | 238 | .PHONY : src/notebook.c.i | ||
431 | 239 | |||
432 | 240 | src/notebook.s: src/notebook.c.s | ||
433 | 241 | .PHONY : src/notebook.s | ||
434 | 242 | |||
435 | 243 | # target to generate assembly for a file | ||
436 | 244 | src/notebook.c.s: | ||
437 | 245 | $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.s | ||
438 | 246 | .PHONY : src/notebook.c.s | ||
439 | 247 | |||
440 | 248 | # Help Target | ||
441 | 249 | help: | ||
442 | 250 | @echo "The following are some of the valid targets for this Makefile:" | ||
443 | 251 | @echo "... all (the default if no target is provided)" | ||
444 | 252 | @echo "... clean" | ||
445 | 253 | @echo "... depend" | ||
446 | 254 | @echo "... edit_cache" | ||
447 | 255 | @echo "... install" | ||
448 | 256 | @echo "... install/local" | ||
449 | 257 | @echo "... install/strip" | ||
450 | 258 | @echo "... list_install_components" | ||
451 | 259 | @echo "... rebuild_cache" | ||
452 | 260 | @echo "... scratch" | ||
453 | 261 | @echo "... src/entry.o" | ||
454 | 262 | @echo "... src/entry.i" | ||
455 | 263 | @echo "... src/entry.s" | ||
456 | 264 | @echo "... src/main_window.o" | ||
457 | 265 | @echo "... src/main_window.i" | ||
458 | 266 | @echo "... src/main_window.s" | ||
459 | 267 | @echo "... src/menu.o" | ||
460 | 268 | @echo "... src/menu.i" | ||
461 | 269 | @echo "... src/menu.s" | ||
462 | 270 | @echo "... src/notebook.o" | ||
463 | 271 | @echo "... src/notebook.i" | ||
464 | 272 | @echo "... src/notebook.s" | ||
465 | 273 | .PHONY : help | ||
466 | 274 | |||
467 | 275 | |||
468 | 276 | |||
469 | 277 | #============================================================================= | ||
470 | 278 | # Special targets to cleanup operation of make. | ||
471 | 279 | |||
472 | 280 | # Special rule to run CMake to check the build system integrity. | ||
473 | 281 | # No rule that depends on this can have commands that come from listfiles | ||
474 | 282 | # because they might be regenerated. | ||
475 | 283 | cmake_check_build_system: | ||
476 | 284 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | ||
477 | 285 | .PHONY : cmake_check_build_system | ||
478 | 286 | |||
479 | 287 | 0 | ||
480 | === modified file 'cmake/Translations.cmake' | |||
481 | --- cmake/Translations.cmake 2012-06-07 15:38:06 +0000 | |||
482 | +++ cmake/Translations.cmake 2014-07-06 11:18:29 +0000 | |||
483 | @@ -20,22 +20,47 @@ | |||
484 | 20 | add_custom_target (pot COMMENT “Building translation catalog.”) | 20 | add_custom_target (pot COMMENT “Building translation catalog.”) |
485 | 21 | find_program (XGETTEXT_EXECUTABLE xgettext) | 21 | find_program (XGETTEXT_EXECUTABLE xgettext) |
486 | 22 | 22 | ||
487 | 23 | |||
488 | 24 | set(C_SOURCE "") | 23 | set(C_SOURCE "") |
489 | 24 | set(VALA_SOURCE "") | ||
490 | 25 | set(GLADE_SOURCE "") | ||
491 | 25 | 26 | ||
492 | 26 | foreach(FILES_INPUT ${ARGN}) | 27 | foreach(FILES_INPUT ${ARGN}) |
500 | 27 | file (GLOB SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c) | 28 | set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}) |
501 | 28 | foreach(C_FILE ${SOURCE_FILES}) | 29 | |
502 | 29 | set(C_SOURCE ${C_SOURCE} ${C_FILE}) | 30 | file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.c) |
503 | 30 | endforeach() | 31 | foreach(C_FILE ${SOURCE_FILES}) |
504 | 31 | file (GLOB SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala) | 32 | set(C_SOURCE ${C_SOURCE} ${C_FILE}) |
505 | 32 | foreach(C_FILE ${SOURCE_FILES}) | 33 | endforeach() |
506 | 33 | set(C_SOURCE ${C_SOURCE} ${C_FILE}) | 34 | |
507 | 35 | file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.vala) | ||
508 | 36 | foreach(VALA_C_FILE ${SOURCE_FILES}) | ||
509 | 37 | set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE}) | ||
510 | 38 | endforeach() | ||
511 | 39 | |||
512 | 40 | file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.ui) | ||
513 | 41 | foreach(GLADE_C_FILE ${SOURCE_FILES}) | ||
514 | 42 | set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE}) | ||
515 | 34 | endforeach() | 43 | endforeach() |
516 | 35 | endforeach() | 44 | endforeach() |
517 | 36 | 45 | ||
522 | 37 | add_custom_command (TARGET pot COMMAND | 46 | set(BASE_XGETTEXT_COMMAND |
523 | 38 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot | 47 | ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} |
524 | 39 | ${VALA_SOURCE} ${C_SOURCE} --keyword="_" --keyword="N_" --from-code=UTF-8 | 48 | -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot |
525 | 40 | ) | 49 | --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2" --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="Q_:1g" --from-code=UTF-8) |
526 | 50 | |||
527 | 51 | set(CONTINUE_FLAG "") | ||
528 | 52 | |||
529 | 53 | IF(NOT "${C_SOURCE}" STREQUAL "") | ||
530 | 54 | add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE}) | ||
531 | 55 | set(CONTINUE_FLAG "-j") | ||
532 | 56 | ENDIF() | ||
533 | 57 | |||
534 | 58 | IF(NOT "${VALA_SOURCE}" STREQUAL "") | ||
535 | 59 | add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE}) | ||
536 | 60 | set(CONTINUE_FLAG "-j") | ||
537 | 61 | ENDIF() | ||
538 | 62 | |||
539 | 63 | IF(NOT "${GLADE_SOURCE}" STREQUAL "") | ||
540 | 64 | add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE}) | ||
541 | 65 | ENDIF() | ||
542 | 41 | endmacro() | 66 | endmacro() |
543 | 42 | 67 | ||
544 | === modified file 'cmake/ValaPrecompile.cmake' | |||
545 | --- cmake/ValaPrecompile.cmake 2012-02-23 20:42:55 +0000 | |||
546 | +++ cmake/ValaPrecompile.cmake 2014-07-06 11:18:29 +0000 | |||
547 | @@ -1,5 +1,6 @@ | |||
548 | 1 | ## | 1 | ## |
549 | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | 2 | # Copyright 2009-2010 Jakob Westhoff. All rights reserved. |
550 | 3 | # Copyright 2012 elementary. | ||
551 | 3 | # | 4 | # |
552 | 4 | # Redistribution and use in source and binary forms, with or without | 5 | # Redistribution and use in source and binary forms, with or without |
553 | 5 | # modification, are permitted provided that the following conditions are met: | 6 | # modification, are permitted provided that the following conditions are met: |
554 | @@ -74,10 +75,18 @@ | |||
555 | 74 | # be a header file as well as an internal header file being generated called | 75 | # be a header file as well as an internal header file being generated called |
556 | 75 | # <provided_name>.h and <provided_name>_internal.h | 76 | # <provided_name>.h and <provided_name>_internal.h |
557 | 76 | # | 77 | # |
558 | 78 | # GENERATE_GIR | ||
559 | 79 | # Have the compiler generate a GObject-Introspection repository file with | ||
560 | 80 | # name: <provided_name>.gir. This can be later used to create a binary typelib | ||
561 | 81 | # using the GI compiler. | ||
562 | 82 | # | ||
563 | 83 | # GENERATE_SYMBOLS | ||
564 | 84 | # Output a <provided_name>.symbols file containing all the exported symbols. | ||
565 | 85 | # | ||
566 | 77 | # The following call is a simple example to the vala_precompile macro showing | 86 | # The following call is a simple example to the vala_precompile macro showing |
567 | 78 | # an example to every of the optional sections: | 87 | # an example to every of the optional sections: |
568 | 79 | # | 88 | # |
570 | 80 | # vala_precompile(VALA_C | 89 | # vala_precompile(VALA_C mytargetname |
571 | 81 | # source1.vala | 90 | # source1.vala |
572 | 82 | # source2.vala | 91 | # source2.vala |
573 | 83 | # source3.vala | 92 | # source3.vala |
574 | @@ -95,14 +104,19 @@ | |||
575 | 95 | # myvapi | 104 | # myvapi |
576 | 96 | # GENERATE_HEADER | 105 | # GENERATE_HEADER |
577 | 97 | # myheader | 106 | # myheader |
578 | 107 | # GENERATE_GIR | ||
579 | 108 | # mygir | ||
580 | 109 | # GENERATE_SYMBOLS | ||
581 | 110 | # mysymbols | ||
582 | 98 | # ) | 111 | # ) |
583 | 99 | # | 112 | # |
584 | 100 | # Most important is the variable VALA_C which will contain all the generated c | 113 | # Most important is the variable VALA_C which will contain all the generated c |
585 | 101 | # file names after the call. | 114 | # file names after the call. |
586 | 102 | ## | 115 | ## |
587 | 103 | 116 | ||
590 | 104 | macro(vala_precompile output) | 117 | macro(vala_precompile output target_name) |
591 | 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}) |
592 | 119 | |||
593 | 106 | if(ARGS_DIRECTORY) | 120 | if(ARGS_DIRECTORY) |
594 | 107 | set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) | 121 | set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) |
595 | 108 | else(ARGS_DIRECTORY) | 122 | else(ARGS_DIRECTORY) |
596 | @@ -115,15 +129,17 @@ | |||
597 | 115 | endforeach(pkg ${ARGS_PACKAGES}) | 129 | endforeach(pkg ${ARGS_PACKAGES}) |
598 | 116 | set(in_files "") | 130 | set(in_files "") |
599 | 117 | set(out_files "") | 131 | set(out_files "") |
600 | 132 | set(out_files_display "") | ||
601 | 118 | set(${output} "") | 133 | set(${output} "") |
602 | 134 | |||
603 | 119 | foreach(src ${ARGS_DEFAULT_ARGS}) | 135 | foreach(src ${ARGS_DEFAULT_ARGS}) |
604 | 120 | string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" src ${src}) | ||
605 | 121 | string(REGEX MATCH "^/" IS_MATCHED ${src}) | 136 | string(REGEX MATCH "^/" IS_MATCHED ${src}) |
606 | 122 | if(${IS_MATCHED} MATCHES "/") | 137 | if(${IS_MATCHED} MATCHES "/") |
608 | 123 | list(APPEND in_files "${src}") | 138 | set(src_file_path ${src}) |
609 | 124 | else() | 139 | else() |
611 | 125 | list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") | 140 | set(src_file_path ${CMAKE_CURRENT_SOURCE_DIR}/${src}) |
612 | 126 | endif() | 141 | endif() |
613 | 142 | list(APPEND in_files ${src_file_path}) | ||
614 | 127 | string(REPLACE ".vala" ".c" src ${src}) | 143 | string(REPLACE ".vala" ".c" src ${src}) |
615 | 128 | string(REPLACE ".gs" ".c" src ${src}) | 144 | string(REPLACE ".gs" ".c" src ${src}) |
616 | 129 | if(${IS_MATCHED} MATCHES "/") | 145 | if(${IS_MATCHED} MATCHES "/") |
617 | @@ -135,6 +151,7 @@ | |||
618 | 135 | list(APPEND out_files "${DIRECTORY}/${src}") | 151 | list(APPEND out_files "${DIRECTORY}/${src}") |
619 | 136 | endif() | 152 | endif() |
620 | 137 | list(APPEND ${output} ${out_file}) | 153 | list(APPEND ${output} ${out_file}) |
621 | 154 | list(APPEND out_files_display "${src}") | ||
622 | 138 | endforeach(src ${ARGS_DEFAULT_ARGS}) | 155 | endforeach(src ${ARGS_DEFAULT_ARGS}) |
623 | 139 | 156 | ||
624 | 140 | set(custom_vapi_arguments "") | 157 | set(custom_vapi_arguments "") |
625 | @@ -151,7 +168,8 @@ | |||
626 | 151 | set(vapi_arguments "") | 168 | set(vapi_arguments "") |
627 | 152 | if(ARGS_GENERATE_VAPI) | 169 | if(ARGS_GENERATE_VAPI) |
628 | 153 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") | 170 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") |
630 | 154 | set(vapi_arguments "--internal-vapi=${ARGS_GENERATE_VAPI}.vapi") | 171 | list(APPEND out_files_display "${ARGS_GENERATE_VAPI}.vapi") |
631 | 172 | set(vapi_arguments "--library=${ARGS_GENERATE_VAPI}" "--vapi=${ARGS_GENERATE_VAPI}.vapi") | ||
632 | 155 | 173 | ||
633 | 156 | # Header and internal header is needed to generate internal vapi | 174 | # Header and internal header is needed to generate internal vapi |
634 | 157 | if (NOT ARGS_GENERATE_HEADER) | 175 | if (NOT ARGS_GENERATE_HEADER) |
635 | @@ -162,26 +180,71 @@ | |||
636 | 162 | set(header_arguments "") | 180 | set(header_arguments "") |
637 | 163 | if(ARGS_GENERATE_HEADER) | 181 | if(ARGS_GENERATE_HEADER) |
638 | 164 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") | 182 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") |
642 | 165 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") | 183 | list(APPEND out_files_display "${ARGS_GENERATE_HEADER}.h") |
643 | 166 | list(APPEND header_arguments "--header=${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") | 184 | list(APPEND header_arguments "--header=${ARGS_GENERATE_HEADER}.h") |
641 | 167 | list(APPEND header_arguments "--internal-header=${DIRECTORY}/${ARGS_GENERATE_HEADER}_internal.h") | ||
644 | 168 | endif(ARGS_GENERATE_HEADER) | 185 | endif(ARGS_GENERATE_HEADER) |
645 | 169 | 186 | ||
647 | 170 | add_custom_command(OUTPUT ${out_files} | 187 | set(gir_arguments "") |
648 | 188 | set(gircomp_command "") | ||
649 | 189 | if(ARGS_GENERATE_GIR) | ||
650 | 190 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir") | ||
651 | 191 | list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir") | ||
652 | 192 | set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir") | ||
653 | 193 | |||
654 | 194 | include (FindGirCompiler) | ||
655 | 195 | find_package(GirCompiler REQUIRED) | ||
656 | 196 | |||
657 | 197 | set(gircomp_command | ||
658 | 198 | COMMAND | ||
659 | 199 | ${G_IR_COMPILER_EXECUTABLE} | ||
660 | 200 | ARGS | ||
661 | 201 | "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir" | ||
662 | 202 | -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib") | ||
663 | 203 | endif(ARGS_GENERATE_GIR) | ||
664 | 204 | |||
665 | 205 | set(symbols_arguments "") | ||
666 | 206 | if(ARGS_GENERATE_SYMBOLS) | ||
667 | 207 | list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_SYMBOLS}.symbols") | ||
668 | 208 | list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols") | ||
669 | 209 | set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols") | ||
670 | 210 | endif(ARGS_GENERATE_SYMBOLS) | ||
671 | 211 | |||
672 | 212 | # Workaround for a bug that would make valac run twice. This file is written | ||
673 | 213 | # after the vala compiler generates C source code. | ||
674 | 214 | set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp) | ||
675 | 215 | |||
676 | 216 | add_custom_command( | ||
677 | 217 | OUTPUT | ||
678 | 218 | ${OUTPUT_STAMP} | ||
679 | 171 | COMMAND | 219 | COMMAND |
680 | 172 | ${VALA_EXECUTABLE} | 220 | ${VALA_EXECUTABLE} |
681 | 173 | ARGS | 221 | ARGS |
682 | 174 | "-C" | 222 | "-C" |
683 | 175 | ${header_arguments} | 223 | ${header_arguments} |
685 | 176 | ${vapi_arguments} | 224 | ${vapi_arguments} |
686 | 225 | ${gir_arguments} | ||
687 | 226 | ${symbols_arguments} | ||
688 | 177 | "-b" ${CMAKE_CURRENT_SOURCE_DIR} | 227 | "-b" ${CMAKE_CURRENT_SOURCE_DIR} |
689 | 178 | "-d" ${DIRECTORY} | 228 | "-d" ${DIRECTORY} |
690 | 179 | ${vala_pkg_opts} | 229 | ${vala_pkg_opts} |
691 | 180 | ${ARGS_OPTIONS} | 230 | ${ARGS_OPTIONS} |
692 | 231 | "-g" | ||
693 | 232 | "--save-temps" | ||
694 | 181 | ${in_files} | 233 | ${in_files} |
695 | 182 | ${custom_vapi_arguments} | 234 | ${custom_vapi_arguments} |
696 | 235 | COMMAND | ||
697 | 236 | touch | ||
698 | 237 | ARGS | ||
699 | 238 | ${OUTPUT_STAMP} | ||
700 | 183 | DEPENDS | 239 | DEPENDS |
701 | 184 | ${in_files} | 240 | ${in_files} |
702 | 185 | ${ARGS_CUSTOM_VAPIS} | 241 | ${ARGS_CUSTOM_VAPIS} |
703 | 242 | COMMENT | ||
704 | 243 | "Generating ${out_files_display}" | ||
705 | 244 | ${gircomp_command} | ||
706 | 186 | ) | 245 | ) |
707 | 246 | |||
708 | 247 | # This command will be run twice for some reason (pass a non-empty string to COMMENT | ||
709 | 248 | # in order to see it). Since valac is not executed from here, this won't be a problem. | ||
710 | 249 | add_custom_command(OUTPUT ${out_files} DEPENDS ${OUTPUT_STAMP} COMMENT "") | ||
711 | 187 | endmacro(vala_precompile) | 250 | endmacro(vala_precompile) |
712 | 188 | 251 | ||
713 | === added file 'data/CMakeLists.txt' | |||
714 | --- data/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
715 | +++ data/CMakeLists.txt 2014-07-06 11:18:29 +0000 | |||
716 | @@ -0,0 +1,12 @@ | |||
717 | 1 | set (HICOLOR_DIR ${DATADIR}/icons/hicolor) | ||
718 | 2 | # Data | ||
719 | 3 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/16/audience.svg DESTINATION ${HICOLOR_DIR}/16x16/apps/) | ||
720 | 4 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/24/audience.svg DESTINATION ${HICOLOR_DIR}/24x24/apps/) | ||
721 | 5 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/32/audience.svg DESTINATION ${HICOLOR_DIR}/32x32/apps/) | ||
722 | 6 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/48/audience.svg DESTINATION ${HICOLOR_DIR}/48x48/apps/) | ||
723 | 7 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/64/audience.svg DESTINATION ${HICOLOR_DIR}/64x64/apps/) | ||
724 | 8 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/icons/128/audience.svg DESTINATION ${HICOLOR_DIR}/128x128/apps/) | ||
725 | 9 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/audience.desktop DESTINATION ${DATADIR}/applications/) | ||
726 | 10 | |||
727 | 11 | include(GSettings) | ||
728 | 12 | add_schema (org.pantheon.audience.gschema.xml) | ||
729 | 0 | 13 | ||
730 | === modified file 'data/org.pantheon.audience.gschema.xml' | |||
731 | --- data/org.pantheon.audience.gschema.xml 2013-03-31 21:46:37 +0000 | |||
732 | +++ data/org.pantheon.audience.gschema.xml 2014-07-06 11:18:29 +0000 | |||
733 | @@ -15,10 +15,15 @@ | |||
734 | 15 | <summary>Resume videos</summary> | 15 | <summary>Resume videos</summary> |
735 | 16 | <description>Resume video at the point they were stopped when audience was closed</description> | 16 | <description>Resume video at the point they were stopped when audience was closed</description> |
736 | 17 | </key> | 17 | </key> |
741 | 18 | <key name="last-played-videos" type="s"> | 18 | <key name="last-played-videos" type="as"> |
742 | 19 | <default>""</default> | 19 | <default>[]</default> |
743 | 20 | <summary>List of last played videos and the time they stopped</summary> | 20 | <summary>List of last played videos</summary> |
744 | 21 | <description>A list of the last played and the time they were stopped</description> | 21 | <description>A list of the last played</description> |
745 | 22 | </key> | ||
746 | 23 | <key name="last-stopped" type="d"> | ||
747 | 24 | <default>0</default> | ||
748 | 25 | <summary>Last stopped time of last played video</summary> | ||
749 | 26 | <description>Last stopped time of last played video</description> | ||
750 | 22 | </key> | 27 | </key> |
751 | 23 | <key name="last-folder" type="s"> | 28 | <key name="last-folder" type="s"> |
752 | 24 | <default>"-1"</default> | 29 | <default>"-1"</default> |
753 | @@ -41,4 +46,4 @@ | |||
754 | 41 | <description>Hide the window decorations. You can close the window with escape</description> | 46 | <description>Hide the window decorations. You can close the window with escape</description> |
755 | 42 | </key> | 47 | </key> |
756 | 43 | </schema> | 48 | </schema> |
758 | 44 | </schemalist> | 49 | </schemalist> |
759 | 45 | \ No newline at end of file | 50 | \ No newline at end of file |
760 | 46 | 51 | ||
761 | === modified file 'src/Audience.vala' | |||
762 | --- src/Audience.vala 2014-05-25 13:34:00 +0000 | |||
763 | +++ src/Audience.vala 2014-07-06 11:18:29 +0000 | |||
764 | @@ -1,3 +1,23 @@ | |||
765 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
766 | 2 | /*- | ||
767 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
768 | 4 | * | ||
769 | 5 | * This program is free software: you can redistribute it and/or modify | ||
770 | 6 | * it under the terms of the GNU General Public License as published by | ||
771 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
772 | 8 | * (at your option) any later version. | ||
773 | 9 | |||
774 | 10 | * This program is distributed in the hope that it will be useful, | ||
775 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
776 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
777 | 13 | * GNU General Public License for more details. | ||
778 | 14 | |||
779 | 15 | * You should have received a copy of the GNU General Public License | ||
780 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
781 | 17 | * | ||
782 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
783 | 19 | * Cody Garver <cody@elementaryos.org> | ||
784 | 20 | */ | ||
785 | 1 | 21 | ||
786 | 2 | /* | 22 | /* |
787 | 3 | [CCode (cname="gst_navigation_query_parse_commands_length")] | 23 | [CCode (cname="gst_navigation_query_parse_commands_length")] |
788 | @@ -21,7 +41,7 @@ | |||
789 | 21 | build_version = Constants.VERSION; | 41 | build_version = Constants.VERSION; |
790 | 22 | build_version_info = Constants.VERSION_INFO; | 42 | build_version_info = Constants.VERSION_INFO; |
791 | 23 | 43 | ||
793 | 24 | app_years = "2011-2013"; | 44 | app_years = "2011-2014"; |
794 | 25 | app_icon = "audience"; | 45 | app_icon = "audience"; |
795 | 26 | app_launcher = "audience.desktop"; | 46 | app_launcher = "audience.desktop"; |
796 | 27 | application_id = "net.launchpad.audience"; | 47 | application_id = "net.launchpad.audience"; |
797 | @@ -40,27 +60,32 @@ | |||
798 | 40 | } | 60 | } |
799 | 41 | 61 | ||
800 | 42 | public Gtk.Window mainwindow; | 62 | public Gtk.Window mainwindow; |
801 | 43 | public Audience.Widgets.TagView tagview; | ||
802 | 44 | public GnomeMediaKeys mediakeys; | 63 | public GnomeMediaKeys mediakeys; |
803 | 45 | public Audience.Widgets.Playlist playlist; | 64 | public Audience.Widgets.Playlist playlist; |
804 | 46 | public GtkClutter.Embed clutter; | 65 | public GtkClutter.Embed clutter; |
805 | 47 | public Granite.Widgets.Welcome welcome; | 66 | public Granite.Widgets.Welcome welcome; |
811 | 48 | public Audience.Widgets.VideoPlayer video_player; | 67 | |
812 | 49 | 68 | public bool fullscreened { get; set; } | |
813 | 50 | public bool has_dvd; | 69 | |
814 | 51 | 70 | private Audience.Widgets.VideoPlayer video_player; | |
815 | 52 | public List<string> last_played_videos; //taken from settings, but splitted | 71 | private Audience.Widgets.BottomBar bottom_bar; |
816 | 72 | private Clutter.Stage stage; | ||
817 | 73 | private Gtk.Revealer unfullscreen_bar; | ||
818 | 74 | private GtkClutter.Actor bottom_actor; | ||
819 | 75 | private GtkClutter.Actor unfullscreen_actor; | ||
820 | 76 | private bool mouse_primary_down = false; | ||
821 | 77 | private int bottom_bar_size = 0; | ||
822 | 53 | 78 | ||
823 | 54 | public GLib.VolumeMonitor monitor; | 79 | public GLib.VolumeMonitor monitor; |
825 | 55 | 80 | ||
826 | 56 | private const string[] SUBTITLE_EXTENSIONS = { | 81 | private const string[] SUBTITLE_EXTENSIONS = { |
834 | 57 | "sub", | 82 | "sub", |
835 | 58 | "srt", | 83 | "srt", |
836 | 59 | "smi", | 84 | "smi", |
837 | 60 | "ssa", | 85 | "ssa", |
838 | 61 | "ass", | 86 | "ass", |
839 | 62 | "asc" | 87 | "asc" |
840 | 63 | }; | 88 | }; |
841 | 64 | 89 | ||
842 | 65 | public App () { | 90 | public App () { |
843 | 66 | Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; | 91 | Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.DEBUG; |
844 | @@ -69,148 +94,77 @@ | |||
845 | 69 | this.flags |= GLib.ApplicationFlags.HANDLES_OPEN; | 94 | this.flags |= GLib.ApplicationFlags.HANDLES_OPEN; |
846 | 70 | } | 95 | } |
847 | 71 | 96 | ||
850 | 72 | void build () | 97 | void build () { |
849 | 73 | { | ||
851 | 74 | playlist = new Widgets.Playlist (); | 98 | playlist = new Widgets.Playlist (); |
852 | 75 | settings = new Settings (); | 99 | settings = new Settings (); |
853 | 76 | mainwindow = new Gtk.Window (); | 100 | mainwindow = new Gtk.Window (); |
860 | 77 | video_player = new Widgets.VideoPlayer (); | 101 | video_player = Widgets.VideoPlayer.get_default (); |
861 | 78 | tagview = new Widgets.TagView (this); | 102 | video_player.notify["playing"].connect (() => {bottom_bar.toggle_play_pause ();}); |
862 | 79 | 103 | ||
857 | 80 | tagview.select_external_subtitle.connect (video_player.set_subtitle_uri); | ||
858 | 81 | |||
859 | 82 | var mainbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
863 | 83 | clutter = new GtkClutter.Embed (); | 104 | clutter = new GtkClutter.Embed (); |
864 | 84 | 105 | ||
865 | 85 | //prepare last played videos | ||
866 | 86 | last_played_videos = new List<string> (); | ||
867 | 87 | var split = settings.last_played_videos.split (",");; | ||
868 | 88 | for (var i=0;i<split.length;i++){ | ||
869 | 89 | last_played_videos.append (split[i]); | ||
870 | 90 | } | ||
871 | 91 | |||
872 | 92 | has_dvd = Audience.has_dvd (); | ||
873 | 93 | |||
874 | 94 | if (settings.last_folder == "-1") | 106 | if (settings.last_folder == "-1") |
875 | 95 | settings.last_folder = Environment.get_home_dir (); | 107 | settings.last_folder = Environment.get_home_dir (); |
876 | 96 | 108 | ||
893 | 97 | welcome = new Granite.Widgets.Welcome (_("No Videos Open"), _("Select a source to begin playing.")); | 109 | stage = (Clutter.Stage)clutter.get_stage (); |
894 | 98 | var open_file_welcome_index = welcome.append ("document-open", _("Open file"), _("Open a saved file.")); | 110 | stage.background_color = {0, 0, 0, 0}; |
895 | 99 | 111 | stage.use_alpha = true; | |
880 | 100 | var filename = last_played_videos.length () > 0 ? last_played_videos.nth_data (0) : ""; | ||
881 | 101 | var last_file = File.new_for_uri (filename); | ||
882 | 102 | |||
883 | 103 | var last_video_welcome_index = -1; | ||
884 | 104 | if (last_file.query_exists ()) { | ||
885 | 105 | last_video_welcome_index = welcome.append ("media-playback-start", _("Resume last video"), get_title (last_file.get_basename ())); | ||
886 | 106 | welcome.set_item_visible (last_video_welcome_index, last_played_videos.length () > 0); | ||
887 | 107 | } | ||
888 | 108 | |||
889 | 109 | var dvd_welcome_index = welcome.append ("media-cdrom", _("Play from Disc"), _("Watch a DVD or open a file from disc")); | ||
890 | 110 | welcome.set_item_visible (dvd_welcome_index, has_dvd); | ||
891 | 111 | |||
892 | 112 | var stage = clutter.get_stage (); | ||
896 | 113 | 112 | ||
897 | 114 | video_player.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.WIDTH, 0)); | 113 | video_player.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.WIDTH, 0)); |
898 | 115 | video_player.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, 0)); | 114 | video_player.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, 0)); |
899 | 116 | 115 | ||
900 | 117 | stage.add_child (video_player); | 116 | stage.add_child (video_player); |
908 | 118 | stage.add_child (tagview); | 117 | |
909 | 119 | stage.background_color = {0, 0, 0}; | 118 | bottom_bar = new Widgets.BottomBar (); |
910 | 120 | 119 | bottom_bar.set_valign (Gtk.Align.END); | |
911 | 121 | this.tagview.y = -10; | 120 | bottom_bar.play_toggled.connect (() => {video_player.playing = !video_player.playing;}); |
912 | 122 | this.tagview.x = stage.width; | 121 | bottom_bar.seeked.connect ((val) => {video_player.progress = val;}); |
913 | 123 | this.tagview.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, -20)); | 122 | bottom_bar.unfullscreen.connect (() => {toggle_fullscreen ();}); |
914 | 124 | 123 | ||
915 | 124 | //tagview.select_external_subtitle.connect (video_player.set_subtitle_uri); | ||
916 | 125 | |||
917 | 126 | unfullscreen_bar = bottom_bar.get_unfullscreen_button (); | ||
918 | 127 | |||
919 | 128 | bottom_actor = new GtkClutter.Actor.with_contents (bottom_bar); | ||
920 | 129 | bottom_actor.opacity = GLOBAL_OPACITY; | ||
921 | 130 | stage.add_child (bottom_actor); | ||
922 | 131 | |||
923 | 132 | unfullscreen_actor = new GtkClutter.Actor.with_contents (unfullscreen_bar); | ||
924 | 133 | unfullscreen_actor.opacity = GLOBAL_OPACITY; | ||
925 | 134 | stage.add_child (unfullscreen_actor); | ||
926 | 135 | |||
927 | 136 | setup_welcome_screen (); | ||
928 | 137 | |||
929 | 138 | var mainbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
930 | 139 | mainbox.pack_start (clutter); | ||
931 | 125 | mainbox.pack_start (welcome); | 140 | mainbox.pack_start (welcome); |
940 | 126 | mainbox.pack_start (clutter); | 141 | |
941 | 127 | 142 | var header = new Gtk.HeaderBar (); | |
942 | 128 | this.mainwindow.title = program_name; | 143 | header.set_show_close_button (true); |
943 | 129 | this.mainwindow.window_position = Gtk.WindowPosition.CENTER; | 144 | header.get_style_context ().remove_class ("header-bar"); |
944 | 130 | this.mainwindow.set_application (this); | 145 | |
945 | 131 | this.mainwindow.add (mainbox); | 146 | mainwindow.set_titlebar (header); |
946 | 132 | this.mainwindow.set_default_size (624, 352); | 147 | |
947 | 133 | this.mainwindow.show_all (); | 148 | mainwindow.events |= Gdk.EventMask.POINTER_MOTION_MASK; |
948 | 149 | mainwindow.events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; | ||
949 | 150 | mainwindow.events |= Gdk.EventMask.BUTTON_PRESS_MASK; | ||
950 | 151 | mainwindow.title = program_name; | ||
951 | 152 | mainwindow.window_position = Gtk.WindowPosition.CENTER; | ||
952 | 153 | mainwindow.set_application (this); | ||
953 | 154 | mainwindow.add (mainbox); | ||
954 | 155 | mainwindow.set_default_size (624, 352); | ||
955 | 156 | mainwindow.set_size_request (350, 300); | ||
956 | 157 | mainwindow.show_all (); | ||
957 | 134 | if (!settings.show_window_decoration) | 158 | if (!settings.show_window_decoration) |
959 | 135 | this.mainwindow.decorated = false; | 159 | mainwindow.decorated = false; |
960 | 136 | 160 | ||
961 | 137 | clutter.hide (); | 161 | clutter.hide (); |
962 | 138 | 162 | ||
963 | 139 | /*events*/ | ||
964 | 140 | video_player.text_tags_changed.connect (tagview.setup_text_setup); | ||
965 | 141 | video_player.audio_tags_changed.connect (tagview.setup_audio_setup); | ||
966 | 142 | |||
967 | 143 | //look for dvd | ||
968 | 144 | this.monitor = GLib.VolumeMonitor.get (); | ||
969 | 145 | monitor.drive_connected.connect ( (drive) => { | ||
970 | 146 | this.has_dvd = Audience.has_dvd (); | ||
971 | 147 | welcome.set_item_visible (dvd_welcome_index, this.has_dvd); | ||
972 | 148 | }); | ||
973 | 149 | monitor.drive_disconnected.connect ( () => { | ||
974 | 150 | this.has_dvd = Audience.has_dvd (); | ||
975 | 151 | welcome.set_item_visible (dvd_welcome_index, this.has_dvd); | ||
976 | 152 | }); | ||
977 | 153 | //playlist wants us to open a file | ||
978 | 154 | playlist.play.connect ( (file) => { | ||
979 | 155 | this.play_file (file.get_uri ()); | ||
980 | 156 | }); | ||
981 | 157 | |||
982 | 158 | //handle welcome | ||
983 | 159 | welcome.activated.connect ( (index) => { | ||
984 | 160 | if (index == open_file_welcome_index) { | ||
985 | 161 | run_open_file (); | ||
986 | 162 | } else if (index == last_video_welcome_index) { | ||
987 | 163 | welcome.hide (); | ||
988 | 164 | clutter.show_all (); | ||
989 | 165 | |||
990 | 166 | open_file (filename); | ||
991 | 167 | |||
992 | 168 | video_player.playing = false; | ||
993 | 169 | video_player.progress = double.parse (last_played_videos.nth_data (1)); | ||
994 | 170 | video_player.playing = true; | ||
995 | 171 | } else if (index == dvd_welcome_index) { | ||
996 | 172 | run_open_dvd (); | ||
997 | 173 | } else { | ||
998 | 174 | var d = new Gtk.Dialog.with_buttons (_("Open location"), | ||
999 | 175 | this.mainwindow, Gtk.DialogFlags.MODAL, | ||
1000 | 176 | Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, | ||
1001 | 177 | Gtk.Stock.OK, Gtk.ResponseType.OK); | ||
1002 | 178 | |||
1003 | 179 | var grid = new Gtk.Grid (); | ||
1004 | 180 | var entry = new Gtk.Entry (); | ||
1005 | 181 | |||
1006 | 182 | grid.attach (new Gtk.Image.from_icon_name ("internet-web-browser", | ||
1007 | 183 | Gtk.IconSize.DIALOG), 0, 0, 1, 2); | ||
1008 | 184 | grid.attach (new Gtk.Label (_("Choose location")), 1, 0, 1, 1); | ||
1009 | 185 | grid.attach (entry, 1, 1, 1, 1); | ||
1010 | 186 | |||
1011 | 187 | ((Gtk.Container)d.get_content_area ()).add (grid); | ||
1012 | 188 | grid.show_all (); | ||
1013 | 189 | |||
1014 | 190 | if (d.run () == Gtk.ResponseType.OK) { | ||
1015 | 191 | open_file (entry.text, true); | ||
1016 | 192 | video_player.playing = true; | ||
1017 | 193 | welcome.hide (); | ||
1018 | 194 | clutter.show_all (); | ||
1019 | 195 | } | ||
1020 | 196 | d.destroy (); | ||
1021 | 197 | } | ||
1022 | 198 | |||
1023 | 199 | int current_state = mainwindow.get_window ().get_state (); | ||
1024 | 200 | bool currently_maximized = (current_state & Gdk.WindowState.MAXIMIZED) != 0; | ||
1025 | 201 | |||
1026 | 202 | // video is playing and we are maximized, go fullscreen | ||
1027 | 203 | if (video_player.playing && currently_maximized) { | ||
1028 | 204 | mainwindow.fullscreen (); | ||
1029 | 205 | video_player.fullscreened = true; | ||
1030 | 206 | } | ||
1031 | 207 | }); | ||
1032 | 208 | |||
1033 | 209 | //media keys | 163 | //media keys |
1034 | 210 | try { | 164 | try { |
1035 | 211 | mediakeys = Bus.get_proxy_sync (BusType.SESSION, | 165 | mediakeys = Bus.get_proxy_sync (BusType.SESSION, |
1036 | 212 | "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys"); | 166 | "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys"); |
1038 | 213 | mediakeys.MediaPlayerKeyPressed.connect ( (bus, app, key) => { | 167 | mediakeys.MediaPlayerKeyPressed.connect ((bus, app, key) => { |
1039 | 214 | if (app != "audience") | 168 | if (app != "audience") |
1040 | 215 | return; | 169 | return; |
1041 | 216 | switch (key) { | 170 | switch (key) { |
1042 | @@ -229,138 +183,25 @@ | |||
1043 | 229 | }); | 183 | }); |
1044 | 230 | 184 | ||
1045 | 231 | mediakeys.GrabMediaPlayerKeys("audience", 0); | 185 | mediakeys.GrabMediaPlayerKeys("audience", 0); |
1091 | 232 | } catch (Error e) { warning (e.message); } | 186 | } catch (Error e) { |
1092 | 233 | 187 | warning (e.message); | |
1093 | 234 | //shortcuts | 188 | } |
1094 | 235 | this.mainwindow.key_press_event.connect ( (e) => { | 189 | |
1095 | 236 | switch (e.keyval) { | 190 | /*events*/ |
1096 | 237 | case Gdk.Key.p: | 191 | video_player.text_tags_changed.connect (bottom_bar.preferences_popover.setup_text); |
1097 | 238 | case Gdk.Key.space: | 192 | video_player.audio_tags_changed.connect (bottom_bar.preferences_popover.setup_audio); |
1098 | 239 | video_player.playing = !video_player.playing; | 193 | video_player.progression_changed.connect ((current_time, total_time) => { |
1099 | 240 | break; | 194 | bottom_bar.set_progression_time (current_time, total_time); |
1055 | 241 | case Gdk.Key.Escape: | ||
1056 | 242 | if (video_player.fullscreened) | ||
1057 | 243 | toggle_fullscreen (); | ||
1058 | 244 | else | ||
1059 | 245 | mainwindow.destroy (); | ||
1060 | 246 | break; | ||
1061 | 247 | case Gdk.Key.o: | ||
1062 | 248 | run_open_file (); | ||
1063 | 249 | break; | ||
1064 | 250 | case Gdk.Key.f: | ||
1065 | 251 | case Gdk.Key.F11: | ||
1066 | 252 | toggle_fullscreen (); | ||
1067 | 253 | break; | ||
1068 | 254 | case Gdk.Key.q: | ||
1069 | 255 | mainwindow.destroy (); | ||
1070 | 256 | break; | ||
1071 | 257 | case Gdk.Key.Left: | ||
1072 | 258 | if ((video_player.progress - 0.05) < 0) | ||
1073 | 259 | video_player.progress = 0.0; | ||
1074 | 260 | else | ||
1075 | 261 | video_player.progress -= 0.05; | ||
1076 | 262 | break; | ||
1077 | 263 | case Gdk.Key.Right: | ||
1078 | 264 | video_player.progress += 0.05; | ||
1079 | 265 | break; | ||
1080 | 266 | case Gdk.Key.a: | ||
1081 | 267 | next_audio (); | ||
1082 | 268 | break; | ||
1083 | 269 | case Gdk.Key.s: | ||
1084 | 270 | next_text (); | ||
1085 | 271 | break; | ||
1086 | 272 | default: | ||
1087 | 273 | break; | ||
1088 | 274 | } | ||
1089 | 275 | |||
1090 | 276 | return true; | ||
1100 | 277 | }); | 195 | }); |
1101 | 278 | 196 | ||
1102 | 279 | //end | 197 | //end |
1105 | 280 | video_player.ended.connect ( () => { | 198 | video_player.ended.connect (() => { |
1106 | 281 | Idle.add (()=>{ | 199 | Idle.add (() => { |
1107 | 282 | playlist.next (); | 200 | playlist.next (); |
1108 | 283 | return false; | 201 | return false; |
1109 | 284 | }); | 202 | }); |
1110 | 285 | }); | 203 | }); |
1111 | 286 | 204 | ||
1112 | 287 | /*open location popover*/ | ||
1113 | 288 | video_player.show_open_context.connect ( () => { | ||
1114 | 289 | var has_been_stopped = video_player.playing; | ||
1115 | 290 | |||
1116 | 291 | video_player.playing = false; | ||
1117 | 292 | |||
1118 | 293 | if (!has_dvd) { //just one source, so open that one | ||
1119 | 294 | Timeout.add (300, () => { | ||
1120 | 295 | run_open_file (); | ||
1121 | 296 | return false; | ||
1122 | 297 | }); | ||
1123 | 298 | return; | ||
1124 | 299 | } | ||
1125 | 300 | |||
1126 | 301 | var pop = new Granite.Widgets.PopOver (); | ||
1127 | 302 | var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
1128 | 303 | ((Gtk.Box)pop.get_content_area ()).add (box); | ||
1129 | 304 | |||
1130 | 305 | var fil = new Gtk.Button.with_label (_("Add from Harddrive")); | ||
1131 | 306 | fil.image = new Gtk.Image.from_icon_name ("document-open", Gtk.IconSize.DIALOG); | ||
1132 | 307 | var dvd = new Gtk.Button.with_label (_("Play a DVD")); | ||
1133 | 308 | dvd.image = new Gtk.Image.from_icon_name ("media-cdrom", Gtk.IconSize.DIALOG); | ||
1134 | 309 | var net = new Gtk.Button.with_label (_("Network File")); | ||
1135 | 310 | net.image = new Gtk.Image.from_icon_name ("internet-web-browser", Gtk.IconSize.DIALOG); | ||
1136 | 311 | |||
1137 | 312 | fil.clicked.connect ( () => { | ||
1138 | 313 | pop.destroy (); | ||
1139 | 314 | run_open_file (); | ||
1140 | 315 | }); | ||
1141 | 316 | dvd.clicked.connect ( () => { | ||
1142 | 317 | run_open_dvd (); | ||
1143 | 318 | pop.destroy (); | ||
1144 | 319 | }); | ||
1145 | 320 | net.clicked.connect ( () => { | ||
1146 | 321 | var entry = new Gtk.Entry (); | ||
1147 | 322 | entry.secondary_icon_stock = Gtk.Stock.OPEN; | ||
1148 | 323 | entry.icon_release.connect ( (pos, e) => { | ||
1149 | 324 | open_file (entry.text); | ||
1150 | 325 | video_player.playing = true; | ||
1151 | 326 | pop.destroy (); | ||
1152 | 327 | }); | ||
1153 | 328 | box.remove (net); | ||
1154 | 329 | box.reorder_child (entry, 2); | ||
1155 | 330 | entry.show (); | ||
1156 | 331 | }); | ||
1157 | 332 | |||
1158 | 333 | box.pack_start (fil); | ||
1159 | 334 | if (has_dvd) | ||
1160 | 335 | box.pack_start (dvd); | ||
1161 | 336 | //box.pack_start (net); uri temporary dropped | ||
1162 | 337 | |||
1163 | 338 | /*temporary until popover closing gets fixed*/ | ||
1164 | 339 | var canc = new Gtk.Button.from_stock (Gtk.Stock.CANCEL); | ||
1165 | 340 | box.pack_start (canc); | ||
1166 | 341 | canc.clicked.connect ( () => { | ||
1167 | 342 | pop.destroy (); | ||
1168 | 343 | }); | ||
1169 | 344 | |||
1170 | 345 | int x_r, y_r; | ||
1171 | 346 | this.mainwindow.get_window ().get_origin (out x_r, out y_r); | ||
1172 | 347 | |||
1173 | 348 | pop.move_to_coords ((int)(x_r + clutter.get_stage ().width - 50), | ||
1174 | 349 | (int)(y_r + stage.height - 18)); | ||
1175 | 350 | |||
1176 | 351 | pop.show_all (); | ||
1177 | 352 | |||
1178 | 353 | Timeout.add (300, () => { //for some reason this doesn't cause a crash :) | ||
1179 | 354 | pop.present (); | ||
1180 | 355 | pop.run (); | ||
1181 | 356 | pop.destroy (); | ||
1182 | 357 | if (has_been_stopped) | ||
1183 | 358 | video_player.playing = true; | ||
1184 | 359 | |||
1185 | 360 | return false; | ||
1186 | 361 | }); | ||
1187 | 362 | }); | ||
1188 | 363 | |||
1189 | 364 | video_player.error.connect (() => { | 205 | video_player.error.connect (() => { |
1190 | 365 | welcome.show_all (); | 206 | welcome.show_all (); |
1191 | 366 | clutter.hide (); | 207 | clutter.hide (); |
1192 | @@ -375,196 +216,347 @@ | |||
1193 | 375 | mainwindow.set_keep_above (video_player.playing && settings.stay_on_top); | 216 | mainwindow.set_keep_above (video_player.playing && settings.stay_on_top); |
1194 | 376 | }); | 217 | }); |
1195 | 377 | 218 | ||
1223 | 378 | video_player.exit_fullscreen.connect (toggle_fullscreen); | 219 | notify["fullscreened"].connect (() => {bottom_bar.fullscreen = fullscreened;}); |
1224 | 379 | 220 | ||
1225 | 380 | video_player.toggle_side_pane.connect ((show) => { | 221 | setup_drag_n_drop (); |
1226 | 381 | if (show) { | 222 | video_player.configure_window.connect ((video_w, video_h) => {on_configure_window (video_w, video_h);}); |
1227 | 382 | tagview.expand (); | 223 | |
1228 | 383 | } else { | 224 | //fullscreen on maximize |
1229 | 384 | tagview.collapse (); | 225 | mainwindow.window_state_event.connect ((e) => { |
1230 | 385 | } | 226 | on_window_state_changed (e.window.get_state ()); |
1231 | 386 | }); | 227 | return false; |
1232 | 387 | 228 | }); | |
1233 | 388 | video_player.configure_window.connect ((video_w, video_h) => { | 229 | |
1234 | 389 | 230 | mainwindow.size_allocate.connect ((alloc) => {on_size_allocate (alloc);}); | |
1235 | 390 | Gdk.Rectangle monitor; | 231 | mainwindow.motion_notify_event.connect ((event) => { |
1236 | 391 | var screen = Gdk.Screen.get_default (); | 232 | if (event.window == null) |
1237 | 392 | screen.get_monitor_geometry ( | 233 | return false; |
1238 | 393 | screen.get_monitor_at_window (mainwindow.get_window ()), | 234 | |
1239 | 394 | out monitor); | 235 | if (mouse_primary_down && settings.move_window) { |
1240 | 395 | 236 | mouse_primary_down = false; | |
1241 | 396 | int width = 0, height = 0; | 237 | mainwindow.begin_move_drag (Gdk.BUTTON_PRIMARY, |
1242 | 397 | if (monitor.width > video_w && monitor.height > video_h) { | 238 | (int)event.x_root, (int)event.y_root, event.time); |
1243 | 398 | width = (int)video_w; | 239 | } |
1244 | 399 | height = (int)video_h; | 240 | |
1245 | 400 | } else { | 241 | Gtk.Allocation allocation; |
1246 | 401 | width = (int)(monitor.width * 0.9); | 242 | clutter.get_allocation (out allocation); |
1247 | 402 | height = (int)((double)video_h / video_w * width); | 243 | return update_pointer_position (event.y, allocation.height); |
1248 | 403 | } | 244 | }); |
1249 | 404 | 245 | ||
1250 | 246 | bottom_bar.time_widget.slider_motion_event.connect ((event) => { | ||
1251 | 247 | int x, y; | ||
1252 | 248 | bottom_bar.translate_coordinates (mainwindow, (int)event.x, (int)event.y, out x, out y); | ||
1253 | 249 | Gtk.Allocation allocation; | ||
1254 | 250 | clutter.get_allocation (out allocation); | ||
1255 | 251 | update_pointer_position (y, allocation.height); | ||
1256 | 252 | }); | ||
1257 | 253 | |||
1258 | 254 | mainwindow.button_press_event.connect ((event) => { | ||
1259 | 255 | if (event.type == Gdk.EventType.2BUTTON_PRESS) { | ||
1260 | 256 | toggle_fullscreen (); | ||
1261 | 257 | } | ||
1262 | 258 | |||
1263 | 259 | if (event.button == Gdk.BUTTON_PRIMARY) | ||
1264 | 260 | mouse_primary_down = true; | ||
1265 | 261 | |||
1266 | 262 | return false; | ||
1267 | 263 | }); | ||
1268 | 264 | |||
1269 | 265 | mainwindow.button_release_event.connect ((event) => { | ||
1270 | 266 | if (event.button == Gdk.BUTTON_PRIMARY) | ||
1271 | 267 | mouse_primary_down = false; | ||
1272 | 268 | |||
1273 | 269 | return false; | ||
1274 | 270 | }); | ||
1275 | 271 | |||
1276 | 272 | mainwindow.leave_notify_event.connect ((event) => { | ||
1277 | 273 | if (event.window == null) | ||
1278 | 274 | return false; | ||
1279 | 275 | |||
1280 | 276 | Gtk.Allocation allocation; | ||
1281 | 277 | clutter.get_allocation (out allocation); | ||
1282 | 278 | if (event.x == event.window.get_width ()) | ||
1283 | 279 | return update_pointer_position (event.window.get_height (), allocation.height); | ||
1284 | 280 | else if (event.x == 0) | ||
1285 | 281 | return update_pointer_position (event.window.get_height (), allocation.height); | ||
1286 | 282 | return update_pointer_position (event.y, allocation.height); | ||
1287 | 283 | }); | ||
1288 | 284 | //shortcuts | ||
1289 | 285 | this.mainwindow.key_press_event.connect ((e) => { | ||
1290 | 286 | return on_key_press_event (e); | ||
1291 | 287 | }); | ||
1292 | 288 | |||
1293 | 289 | //save position in video when not finished playing | ||
1294 | 290 | mainwindow.destroy.connect (() => {on_destroy ();}); | ||
1295 | 291 | |||
1296 | 292 | //playlist wants us to open a file | ||
1297 | 293 | playlist.play.connect ((file) => { | ||
1298 | 294 | this.play_file (file.get_uri ()); | ||
1299 | 295 | }); | ||
1300 | 296 | |||
1301 | 297 | bottom_bar.notify["child-revealed"].connect (() => { | ||
1302 | 298 | if (bottom_bar.child_revealed == true) { | ||
1303 | 299 | mainwindow.get_window ().set_cursor (null); | ||
1304 | 300 | } else { | ||
1305 | 301 | mainwindow.get_window ().set_cursor (new Gdk.Cursor (Gdk.CursorType.BLANK_CURSOR)); | ||
1306 | 302 | } | ||
1307 | 303 | }); | ||
1308 | 304 | |||
1309 | 305 | stage.notify["allocation"].connect (() => {allocate_bottombar ();}); | ||
1310 | 306 | |||
1311 | 307 | if (settings.resume_videos == true && settings.last_played_videos.length > 0) { | ||
1312 | 308 | welcome.hide (); | ||
1313 | 309 | clutter.show_all (); | ||
1314 | 310 | foreach (var filename in settings.last_played_videos) { | ||
1315 | 311 | open_file (filename); | ||
1316 | 312 | } | ||
1317 | 313 | |||
1318 | 314 | video_player.playing = false; | ||
1319 | 315 | video_player.progress = settings.last_stopped; | ||
1320 | 316 | video_player.playing = true; | ||
1321 | 317 | } | ||
1322 | 318 | } | ||
1323 | 319 | |||
1324 | 320 | private void allocate_bottombar () { | ||
1325 | 321 | bottom_actor.width = stage.get_width (); | ||
1326 | 322 | bottom_bar.queue_resize (); | ||
1327 | 323 | bottom_actor.y = stage.get_height () - bottom_bar_size; | ||
1328 | 324 | unfullscreen_actor.y = 6; | ||
1329 | 325 | unfullscreen_actor.x = stage.get_width () - bottom_bar_size - 6; | ||
1330 | 326 | } | ||
1331 | 327 | |||
1332 | 328 | private void setup_welcome_screen () { | ||
1333 | 329 | welcome = new Granite.Widgets.Welcome (_("No Videos Open"), _("Select a source to begin playing.")); | ||
1334 | 330 | welcome.append ("document-open", _("Open file"), _("Open a saved file.")); | ||
1335 | 331 | |||
1336 | 332 | //welcome.append ("internet-web-browser", _("Open a location"), _("Watch something from the infinity of the internet")); | ||
1337 | 333 | var filename = settings.last_played_videos.length > 0 ? settings.last_played_videos[0] : ""; | ||
1338 | 334 | var last_file = File.new_for_path (filename); | ||
1339 | 335 | welcome.append ("media-playback-start", _("Resume last video"), get_title (last_file.get_basename ())); | ||
1340 | 336 | bool show_last_file = settings.last_played_videos.length > 0; | ||
1341 | 337 | if (last_file.query_exists () == false) { | ||
1342 | 338 | show_last_file = false; | ||
1343 | 339 | } | ||
1344 | 340 | |||
1345 | 341 | welcome.set_item_visible (1, show_last_file); | ||
1346 | 342 | |||
1347 | 343 | welcome.append ("media-cdrom", _("Play from Disc"), _("Watch a DVD or open a file from disc")); | ||
1348 | 344 | welcome.set_item_visible (2, false); | ||
1349 | 345 | |||
1350 | 346 | //look for dvd | ||
1351 | 347 | var disk_manager = DiskManager.get_default (); | ||
1352 | 348 | foreach (var volume in disk_manager.get_volumes ()) { | ||
1353 | 349 | welcome.set_item_visible (2, true); | ||
1354 | 350 | } | ||
1355 | 351 | |||
1356 | 352 | disk_manager.volume_found.connect ((vol) => { | ||
1357 | 353 | welcome.set_item_visible (2, true); | ||
1358 | 354 | }); | ||
1359 | 355 | |||
1360 | 356 | disk_manager.volume_removed.connect ((vol) => { | ||
1361 | 357 | if (disk_manager.get_volumes ().length () <= 0) | ||
1362 | 358 | welcome.set_item_visible (2, false); | ||
1363 | 359 | }); | ||
1364 | 360 | |||
1365 | 361 | //handle welcome | ||
1366 | 362 | welcome.activated.connect ((index) => { | ||
1367 | 363 | switch (index) { | ||
1368 | 364 | case 0: | ||
1369 | 365 | run_open_file (); | ||
1370 | 366 | break; | ||
1371 | 367 | case 1: | ||
1372 | 368 | welcome.hide (); | ||
1373 | 369 | clutter.show_all (); | ||
1374 | 370 | open_file (filename); | ||
1375 | 371 | video_player.playing = false; | ||
1376 | 372 | video_player.progress = settings.last_stopped; | ||
1377 | 373 | video_player.playing = true; | ||
1378 | 374 | break; | ||
1379 | 375 | case 2: | ||
1380 | 376 | run_open_dvd (); | ||
1381 | 377 | break; | ||
1382 | 378 | default: | ||
1383 | 379 | var d = new Gtk.Dialog.with_buttons (_("Open location"), | ||
1384 | 380 | this.mainwindow, Gtk.DialogFlags.MODAL, | ||
1385 | 381 | _("Cancel"), Gtk.ResponseType.CANCEL, | ||
1386 | 382 | _("OK"), Gtk.ResponseType.OK); | ||
1387 | 383 | |||
1388 | 384 | var grid = new Gtk.Grid (); | ||
1389 | 385 | var entry = new Gtk.Entry (); | ||
1390 | 386 | |||
1391 | 387 | grid.attach (new Gtk.Image.from_icon_name ("internet-web-browser", | ||
1392 | 388 | Gtk.IconSize.DIALOG), 0, 0, 1, 2); | ||
1393 | 389 | grid.attach (new Gtk.Label (_("Choose location")), 1, 0, 1, 1); | ||
1394 | 390 | grid.attach (entry, 1, 1, 1, 1); | ||
1395 | 391 | |||
1396 | 392 | ((Gtk.Container)d.get_content_area ()).add (grid); | ||
1397 | 393 | grid.show_all (); | ||
1398 | 394 | |||
1399 | 395 | if (d.run () == Gtk.ResponseType.OK) { | ||
1400 | 396 | open_file (entry.text, true); | ||
1401 | 397 | video_player.playing = true; | ||
1402 | 398 | welcome.hide (); | ||
1403 | 399 | clutter.show_all (); | ||
1404 | 400 | } | ||
1405 | 401 | |||
1406 | 402 | d.destroy (); | ||
1407 | 403 | break; | ||
1408 | 404 | } | ||
1409 | 405 | |||
1410 | 406 | int current_state = mainwindow.get_window ().get_state (); | ||
1411 | 407 | bool currently_maximized = (current_state & Gdk.WindowState.MAXIMIZED) != 0; | ||
1412 | 408 | |||
1413 | 409 | // video is playing and we are maximized, go fullscreen | ||
1414 | 410 | if (video_player.playing && currently_maximized) { | ||
1415 | 411 | mainwindow.fullscreen (); | ||
1416 | 412 | fullscreened = true; | ||
1417 | 413 | } | ||
1418 | 414 | }); | ||
1419 | 415 | } | ||
1420 | 416 | |||
1421 | 417 | private bool on_key_press_event (Gdk.EventKey e) { | ||
1422 | 418 | switch (e.keyval) { | ||
1423 | 419 | case Gdk.Key.p: | ||
1424 | 420 | case Gdk.Key.space: | ||
1425 | 421 | video_player.playing = !video_player.playing; | ||
1426 | 422 | break; | ||
1427 | 423 | case Gdk.Key.Escape: | ||
1428 | 424 | if (fullscreened) | ||
1429 | 425 | toggle_fullscreen (); | ||
1430 | 426 | else | ||
1431 | 427 | mainwindow.destroy (); | ||
1432 | 428 | break; | ||
1433 | 429 | case Gdk.Key.o: | ||
1434 | 430 | run_open_file (); | ||
1435 | 431 | break; | ||
1436 | 432 | case Gdk.Key.f: | ||
1437 | 433 | case Gdk.Key.F11: | ||
1438 | 434 | toggle_fullscreen (); | ||
1439 | 435 | break; | ||
1440 | 436 | case Gdk.Key.q: | ||
1441 | 437 | mainwindow.destroy (); | ||
1442 | 438 | break; | ||
1443 | 439 | case Gdk.Key.Left: | ||
1444 | 440 | if ((video_player.progress - 0.05) < 0) | ||
1445 | 441 | video_player.progress = 0.0; | ||
1446 | 442 | else | ||
1447 | 443 | video_player.progress -= 0.05; | ||
1448 | 444 | break; | ||
1449 | 445 | case Gdk.Key.Right: | ||
1450 | 446 | video_player.progress += 0.05; | ||
1451 | 447 | break; | ||
1452 | 448 | case Gdk.Key.a: | ||
1453 | 449 | bottom_bar.preferences_popover.next_audio (); | ||
1454 | 450 | break; | ||
1455 | 451 | case Gdk.Key.s: | ||
1456 | 452 | bottom_bar.preferences_popover.next_text (); | ||
1457 | 453 | break; | ||
1458 | 454 | default: | ||
1459 | 455 | break; | ||
1460 | 456 | } | ||
1461 | 457 | |||
1462 | 458 | return true; | ||
1463 | 459 | } | ||
1464 | 460 | |||
1465 | 461 | private void on_configure_window (uint video_w, uint video_h) { | ||
1466 | 462 | Gdk.Rectangle monitor; | ||
1467 | 463 | var screen = Gdk.Screen.get_default (); | ||
1468 | 464 | screen.get_monitor_geometry (screen.get_monitor_at_window (mainwindow.get_window ()), out monitor); | ||
1469 | 465 | |||
1470 | 466 | int width = 0, height = 0; | ||
1471 | 467 | if (monitor.width > video_w && monitor.height > video_h) { | ||
1472 | 468 | width = (int)video_w; | ||
1473 | 469 | height = (int)video_h; | ||
1474 | 470 | } else { | ||
1475 | 471 | width = (int)(monitor.width * 0.9); | ||
1476 | 472 | height = (int)((double)video_h / video_w * width); | ||
1477 | 473 | } | ||
1478 | 474 | |||
1479 | 475 | mainwindow.get_window ().move_resize (monitor.width / 2 - width / 2 + monitor.x, | ||
1480 | 476 | monitor.height / 2 - height / 2 + monitor.y, | ||
1481 | 477 | width, height); | ||
1482 | 478 | |||
1483 | 479 | if (settings.keep_aspect) { | ||
1484 | 405 | var geom = Gdk.Geometry (); | 480 | var geom = Gdk.Geometry (); |
1569 | 406 | if (settings.keep_aspect) { | 481 | geom.min_aspect = geom.max_aspect = video_w / (double)video_h; |
1570 | 407 | geom.min_aspect = geom.max_aspect = video_w / (double)video_h; | 482 | mainwindow.get_window ().set_geometry_hints (geom, Gdk.WindowHints.ASPECT); |
1571 | 408 | } else { | 483 | } |
1572 | 409 | geom.min_aspect = 0.0; | 484 | } |
1573 | 410 | geom.max_aspect = 99999999.0; | 485 | |
1574 | 411 | } | 486 | private void on_window_state_changed (Gdk.WindowState window_state) { |
1575 | 412 | 487 | bool currently_maximized = (window_state & Gdk.WindowState.MAXIMIZED) == 0; | |
1576 | 413 | mainwindow.get_window ().move_resize (monitor.width / 2 - width / 2 + monitor.x, | 488 | |
1577 | 414 | monitor.height / 2 - height / 2 + monitor.y, | 489 | if (!currently_maximized && !fullscreened && !welcome.is_visible ()) { |
1578 | 415 | width, height); | 490 | mainwindow.fullscreen (); |
1579 | 416 | 491 | fullscreened = true; | |
1580 | 417 | if (settings.keep_aspect) { | 492 | } |
1581 | 418 | mainwindow.get_window ().set_geometry_hints (geom, Gdk.WindowHints.ASPECT); | 493 | } |
1582 | 419 | } | 494 | |
1583 | 420 | 495 | /*DnD*/ | |
1584 | 421 | }); | 496 | private void setup_drag_n_drop () { |
1501 | 422 | |||
1502 | 423 | //fullscreen on maximize | ||
1503 | 424 | mainwindow.window_state_event.connect ( (e) => { | ||
1504 | 425 | bool currently_maximized = (e.window.get_state () & Gdk.WindowState.MAXIMIZED) == 0; | ||
1505 | 426 | |||
1506 | 427 | if (!currently_maximized && !video_player.fullscreened && !welcome.is_visible ()) { | ||
1507 | 428 | mainwindow.fullscreen (); | ||
1508 | 429 | video_player.fullscreened = true; | ||
1509 | 430 | |||
1510 | 431 | return true; | ||
1511 | 432 | } | ||
1512 | 433 | return false; | ||
1513 | 434 | }); | ||
1514 | 435 | |||
1515 | 436 | //positioning | ||
1516 | 437 | int old_h = - 1; | ||
1517 | 438 | int old_w = - 1; | ||
1518 | 439 | mainwindow.size_allocate.connect ( (alloc) => { | ||
1519 | 440 | if (alloc.width != old_w || | ||
1520 | 441 | alloc.height != old_h) { | ||
1521 | 442 | if (video_player.relayout ()) { | ||
1522 | 443 | old_w = alloc.width; | ||
1523 | 444 | old_h = alloc.height; | ||
1524 | 445 | } | ||
1525 | 446 | } | ||
1526 | 447 | |||
1527 | 448 | tagview.x = tagview.expanded ? stage.width - tagview.width + 10 : stage.width; | ||
1528 | 449 | }); | ||
1529 | 450 | |||
1530 | 451 | /*moving the window by drag, fullscreen for dbl-click*/ | ||
1531 | 452 | bool down = false; | ||
1532 | 453 | bool moving = false; | ||
1533 | 454 | video_player.button_press_event.connect ( (e) => { | ||
1534 | 455 | if (e.click_count > 1) { | ||
1535 | 456 | toggle_fullscreen (); | ||
1536 | 457 | down = false; | ||
1537 | 458 | return true; | ||
1538 | 459 | } else { | ||
1539 | 460 | down = true; | ||
1540 | 461 | return true; | ||
1541 | 462 | } | ||
1542 | 463 | }); | ||
1543 | 464 | clutter.motion_notify_event.connect ( (e) => { | ||
1544 | 465 | if (down && settings.move_window) { | ||
1545 | 466 | down = false; | ||
1546 | 467 | moving = true; | ||
1547 | 468 | mainwindow.begin_move_drag (1, | ||
1548 | 469 | (int)e.x_root, (int)e.y_root, e.time); | ||
1549 | 470 | |||
1550 | 471 | video_player.lock_hide (); | ||
1551 | 472 | |||
1552 | 473 | return true; | ||
1553 | 474 | } | ||
1554 | 475 | return false; | ||
1555 | 476 | }); | ||
1556 | 477 | clutter.button_release_event.connect ( (e) => { | ||
1557 | 478 | down = false; | ||
1558 | 479 | return false; | ||
1559 | 480 | }); | ||
1560 | 481 | mainwindow.focus_in_event.connect (() => { | ||
1561 | 482 | if (moving) { | ||
1562 | 483 | video_player.unlock_hide (); | ||
1563 | 484 | moving = false; | ||
1564 | 485 | } | ||
1565 | 486 | return false; | ||
1566 | 487 | }); | ||
1567 | 488 | |||
1568 | 489 | /*DnD*/ | ||
1585 | 490 | Gtk.TargetEntry uris = {"text/uri-list", 0, 0}; | 497 | Gtk.TargetEntry uris = {"text/uri-list", 0, 0}; |
1586 | 491 | Gtk.drag_dest_set (mainwindow, Gtk.DestDefaults.ALL, {uris}, Gdk.DragAction.MOVE); | 498 | Gtk.drag_dest_set (mainwindow, Gtk.DestDefaults.ALL, {uris}, Gdk.DragAction.MOVE); |
1587 | 492 | mainwindow.drag_data_received.connect ( (ctx, x, y, sel, info, time) => { | 499 | mainwindow.drag_data_received.connect ( (ctx, x, y, sel, info, time) => { |
1590 | 493 | for (var i=1;i<sel.get_uris ().length; i++) | 500 | foreach (var uri in sel.get_uris ()) { |
1591 | 494 | playlist.add_item (File.new_for_uri (sel.get_uris ()[i])); | 501 | playlist.add_item (File.new_for_uri (uri)); |
1592 | 502 | } | ||
1593 | 495 | open_file (sel.get_uris ()[0]); | 503 | open_file (sel.get_uris ()[0]); |
1594 | 496 | |||
1595 | 497 | welcome.hide (); | 504 | welcome.hide (); |
1596 | 498 | clutter.show_all (); | 505 | clutter.show_all (); |
1597 | 499 | }); | 506 | }); |
1652 | 500 | 507 | } | |
1653 | 501 | //save position in video when not finished playing | 508 | |
1654 | 502 | mainwindow.destroy.connect ( () => { | 509 | private void on_destroy () { |
1655 | 503 | if (video_player.uri == null || video_player.uri == "" || video_player.uri.has_prefix ("dvd://")) | 510 | if (video_player.uri == null || video_player.uri == "" || video_player.uri.has_prefix ("dvd://")) |
1656 | 504 | return; | 511 | return; |
1657 | 505 | if (!video_player.at_end) { | 512 | if (!video_player.at_end) { |
1658 | 506 | for (var i = 0; i < last_played_videos.length (); i += 2){ | 513 | save_last_played_videos (); |
1659 | 507 | if (video_player.uri == last_played_videos.nth_data (i)){ | 514 | } |
1660 | 508 | last_played_videos.nth (i+1).data = video_player.progress.to_string (); | 515 | } |
1661 | 509 | save_last_played_videos (); | 516 | |
1662 | 510 | 517 | private int old_h = - 1; | |
1663 | 511 | return; | 518 | private int old_w = - 1; |
1664 | 512 | } | 519 | private void on_size_allocate (Gtk.Allocation alloc) { |
1665 | 513 | } | 520 | if (alloc.width != old_w || alloc.height != old_h) { |
1666 | 514 | //not in list yet, insert at start | 521 | if (video_player.relayout ()) { |
1667 | 515 | last_played_videos.insert (video_player.uri, 0); | 522 | old_w = alloc.width; |
1668 | 516 | last_played_videos.insert (video_player.progress.to_string (), 1); | 523 | old_h = alloc.height; |
1669 | 517 | if (last_played_videos.length () > 10) { | 524 | } |
1670 | 518 | last_played_videos.delete_link (last_played_videos.nth (10)); | 525 | } |
1671 | 519 | last_played_videos.delete_link (last_played_videos.nth (11)); | 526 | } |
1672 | 520 | } | 527 | |
1673 | 521 | save_last_played_videos (); | 528 | private bool update_pointer_position (double y, int window_height) { |
1674 | 522 | } | 529 | allocate_bottombar (); |
1675 | 523 | }); | 530 | mainwindow.get_window ().set_cursor (null); |
1676 | 524 | } | 531 | if (bottom_bar_size == 0) { |
1677 | 525 | 532 | int minimum = 0; | |
1678 | 526 | public void next_audio () { | 533 | bottom_bar.get_preferred_height (out minimum, out bottom_bar_size); |
1679 | 527 | int n_audio; | 534 | } |
1680 | 528 | video_player.playbin.get ("n-audio", out n_audio); | 535 | |
1681 | 529 | int current = video_player.current_audio; | 536 | if (bottom_bar.child_revealed == false) |
1682 | 530 | 537 | bottom_bar.set_reveal_child (true); | |
1683 | 531 | if (n_audio > 1) { | 538 | |
1684 | 532 | if (current < n_audio - 1) { | 539 | if (y >= (window_height - bottom_bar_size) && y < window_height) { |
1685 | 533 | current += 1; | 540 | bottom_bar.hovered = true; |
1686 | 534 | } else { | 541 | } else { |
1687 | 535 | current = 0; | 542 | bottom_bar.hovered = false; |
1688 | 536 | } | 543 | } |
1689 | 537 | } | 544 | |
1690 | 538 | tagview.languages.active_id = current.to_string (); | 545 | return false; |
1637 | 539 | } | ||
1638 | 540 | |||
1639 | 541 | public void next_text () { | ||
1640 | 542 | int n_text; | ||
1641 | 543 | video_player.playbin.get ("n-text", out n_text); | ||
1642 | 544 | int current = int.parse (tagview.subtitles.active_id); | ||
1643 | 545 | |||
1644 | 546 | if (n_text > 1) { | ||
1645 | 547 | if (current < n_text - 1) { | ||
1646 | 548 | current += 1; | ||
1647 | 549 | } else { | ||
1648 | 550 | current = -1; | ||
1649 | 551 | } | ||
1650 | 552 | } | ||
1651 | 553 | tagview.subtitles.active_id = current.to_string (); | ||
1691 | 554 | } | 546 | } |
1692 | 555 | 547 | ||
1693 | 556 | private inline void save_last_played_videos () { | 548 | private inline void save_last_played_videos () { |
1697 | 557 | string res = ""; | 549 | playlist.save_playlist_config (); |
1695 | 558 | for (var i = 0; i < last_played_videos.length () - 1; i ++) | ||
1696 | 559 | res += last_played_videos.nth_data (i) + ","; | ||
1698 | 560 | 550 | ||
1701 | 561 | res += last_played_videos.nth_data (last_played_videos.length () - 1); | 551 | if (settings.last_played_videos.length > 0) |
1702 | 562 | settings.last_played_videos = res; | 552 | settings.last_stopped = video_player.progress; |
1703 | 553 | else | ||
1704 | 554 | settings.last_stopped = 0; | ||
1705 | 563 | } | 555 | } |
1706 | 564 | 556 | ||
1708 | 565 | private void run_open_file () { | 557 | public void run_open_file () { |
1709 | 566 | var file = new Gtk.FileChooserDialog (_("Open"), mainwindow, Gtk.FileChooserAction.OPEN, | 558 | var file = new Gtk.FileChooserDialog (_("Open"), mainwindow, Gtk.FileChooserAction.OPEN, |
1711 | 567 | Gtk.Stock.CANCEL, Gtk.ResponseType.CANCEL, Gtk.Stock.OPEN, Gtk.ResponseType.ACCEPT); | 559 | _("_Cancel"), Gtk.ResponseType.CANCEL, _("_Open"), Gtk.ResponseType.ACCEPT); |
1712 | 568 | file.select_multiple = true; | 560 | file.select_multiple = true; |
1713 | 569 | 561 | ||
1714 | 570 | var all_files_filter = new Gtk.FileFilter (); | 562 | var all_files_filter = new Gtk.FileFilter (); |
1715 | @@ -582,92 +574,95 @@ | |||
1716 | 582 | if (file.run () == Gtk.ResponseType.ACCEPT) { | 574 | if (file.run () == Gtk.ResponseType.ACCEPT) { |
1717 | 583 | welcome.hide (); | 575 | welcome.hide (); |
1718 | 584 | clutter.show_all (); | 576 | clutter.show_all (); |
1719 | 585 | for (var i=1;i<file.get_files ().length ();i++) { | ||
1720 | 586 | playlist.add_item (file.get_files ().nth_data (i)); | ||
1721 | 587 | } | ||
1722 | 588 | open_file (file.get_uri ()); | 577 | open_file (file.get_uri ()); |
1723 | 589 | settings.last_folder = file.get_current_folder (); | 578 | settings.last_folder = file.get_current_folder (); |
1724 | 590 | } | 579 | } |
1725 | 580 | |||
1726 | 591 | file.destroy (); | 581 | file.destroy (); |
1727 | 592 | } | 582 | } |
1728 | 593 | 583 | ||
1731 | 594 | private void run_open_dvd () { | 584 | public void run_open_dvd () { |
1732 | 595 | open_file ("dvd://", true); | 585 | read_first_disk.begin (); |
1733 | 586 | } | ||
1734 | 587 | |||
1735 | 588 | private async void read_first_disk () { | ||
1736 | 589 | var disk_manager = DiskManager.get_default (); | ||
1737 | 590 | if (disk_manager.get_volumes ().length () <= 0) | ||
1738 | 591 | return; | ||
1739 | 592 | var volume = disk_manager.get_volumes ().nth_data (0); | ||
1740 | 593 | if (volume.can_mount () == true && volume.get_mount ().can_unmount () == false) { | ||
1741 | 594 | try { | ||
1742 | 595 | yield volume.mount (MountMountFlags.NONE, null); | ||
1743 | 596 | } catch (Error e) { | ||
1744 | 597 | critical (e.message); | ||
1745 | 598 | } | ||
1746 | 599 | } | ||
1747 | 600 | |||
1748 | 601 | var root = volume.get_mount ().get_default_location (); | ||
1749 | 602 | open_file (root.get_uri (), true); | ||
1750 | 596 | video_player.playing = true; | 603 | video_player.playing = true; |
1751 | 597 | 604 | ||
1752 | 598 | welcome.hide (); | 605 | welcome.hide (); |
1753 | 599 | clutter.show_all (); | 606 | clutter.show_all (); |
1754 | 600 | } | 607 | } |
1755 | 601 | 608 | ||
1759 | 602 | private void toggle_fullscreen () | 609 | private void toggle_fullscreen () { |
1760 | 603 | { | 610 | if (fullscreened) { |
1758 | 604 | if (video_player.fullscreened) { | ||
1761 | 605 | mainwindow.unmaximize (); | 611 | mainwindow.unmaximize (); |
1762 | 606 | mainwindow.unfullscreen (); | 612 | mainwindow.unfullscreen (); |
1764 | 607 | video_player.fullscreened = false; | 613 | fullscreened = false; |
1765 | 608 | } else { | 614 | } else { |
1766 | 609 | mainwindow.fullscreen (); | 615 | mainwindow.fullscreen (); |
1768 | 610 | video_player.fullscreened = true; | 616 | fullscreened = true; |
1769 | 611 | } | 617 | } |
1770 | 612 | } | 618 | } |
1771 | 613 | 619 | ||
1774 | 614 | internal void open_file (string filename, bool dont_modify=false) | 620 | internal void open_file (string filename, bool dont_modify = false) { |
1773 | 615 | { | ||
1775 | 616 | var file = File.new_for_commandline_arg (filename); | 621 | var file = File.new_for_commandline_arg (filename); |
1776 | 617 | 622 | ||
1777 | 618 | if (file.query_file_type (0) == FileType.DIRECTORY) { | 623 | if (file.query_file_type (0) == FileType.DIRECTORY) { |
1778 | 619 | Audience.recurse_over_dir (file, (file_ret) => { | 624 | Audience.recurse_over_dir (file, (file_ret) => { |
1779 | 620 | playlist.add_item (file_ret); | 625 | playlist.add_item (file_ret); |
1780 | 621 | }); | 626 | }); |
1781 | 627 | |||
1782 | 622 | file = playlist.get_first_item (); | 628 | file = playlist.get_first_item (); |
1783 | 623 | } else if (is_subtitle (filename) && video_player.playing) { | 629 | } else if (is_subtitle (filename) && video_player.playing) { |
1784 | 624 | video_player.set_subtitle_uri (filename); | 630 | video_player.set_subtitle_uri (filename); |
1786 | 625 | return; | 631 | } else if (video_player.playing == true) { |
1787 | 632 | playlist.add_item (file); | ||
1788 | 633 | } else { | ||
1789 | 634 | playlist.add_item (file); | ||
1790 | 635 | play_file (file.get_uri ()); | ||
1791 | 626 | } | 636 | } |
1794 | 627 | else | 637 | } |
1793 | 628 | playlist.add_item (file); | ||
1795 | 629 | 638 | ||
1796 | 630 | play_file (file.get_uri ()); | ||
1797 | 631 | } | ||
1798 | 632 | |||
1799 | 633 | private bool is_subtitle (string uri) { | 639 | private bool is_subtitle (string uri) { |
1800 | 634 | if (uri.length < 4 || uri.get_char (uri.length-4) != '.') | 640 | if (uri.length < 4 || uri.get_char (uri.length-4) != '.') |
1801 | 635 | return false; | 641 | return false; |
1802 | 642 | |||
1803 | 636 | foreach (string ext in SUBTITLE_EXTENSIONS) { | 643 | foreach (string ext in SUBTITLE_EXTENSIONS) { |
1804 | 637 | if (uri.down ().has_suffix (ext)) | 644 | if (uri.down ().has_suffix (ext)) |
1805 | 638 | return true; | 645 | return true; |
1806 | 639 | } | 646 | } |
1807 | 647 | |||
1808 | 640 | return false; | 648 | return false; |
1809 | 641 | } | 649 | } |
1810 | 642 | 650 | ||
1811 | 643 | public void play_file (string uri) { | 651 | public void play_file (string uri) { |
1812 | 644 | debug ("Opening %s", uri); | 652 | debug ("Opening %s", uri); |
1813 | 645 | video_player.uri = uri; | 653 | video_player.uri = uri; |
1814 | 654 | bottom_bar.set_preview_uri (uri); | ||
1815 | 646 | 655 | ||
1816 | 647 | mainwindow.title = get_title (uri); | 656 | mainwindow.title = get_title (uri); |
1817 | 648 | if (!settings.playback_wait) | 657 | if (!settings.playback_wait) |
1818 | 649 | video_player.playing = true; | 658 | video_player.playing = true; |
1819 | 650 | 659 | ||
1820 | 651 | if (settings.resume_videos) { | ||
1821 | 652 | int i; | ||
1822 | 653 | for (i = 0; i < last_played_videos.length () && i != -1; i += 2) { | ||
1823 | 654 | if (video_player.uri == last_played_videos.nth_data (i)) | ||
1824 | 655 | break; | ||
1825 | 656 | if (i == last_played_videos.length () - 1) | ||
1826 | 657 | i = -1; | ||
1827 | 658 | } | ||
1828 | 659 | if (i != -1 && last_played_videos.nth_data (i + 1) != null) { | ||
1829 | 660 | Idle.add (() => { video_player.progress = double.parse (last_played_videos.nth_data (i + 1)); return false;}); | ||
1830 | 661 | debug ("Resuming video from " + last_played_videos.nth_data (i + 1)); | ||
1831 | 662 | } | ||
1832 | 663 | } | ||
1833 | 664 | |||
1834 | 665 | Gtk.RecentManager recent_manager = Gtk.RecentManager.get_default (); | 660 | Gtk.RecentManager recent_manager = Gtk.RecentManager.get_default (); |
1835 | 666 | recent_manager.add_item (uri); | 661 | recent_manager.add_item (uri); |
1836 | 667 | 662 | ||
1837 | 668 | /*subtitles/audio tracks*/ | 663 | /*subtitles/audio tracks*/ |
1840 | 669 | tagview.setup_setup ("text"); | 664 | bottom_bar.preferences_popover.setup_text (); |
1841 | 670 | tagview.setup_setup ("audio"); | 665 | bottom_bar.preferences_popover.setup_audio (); |
1842 | 671 | } | 666 | } |
1843 | 672 | 667 | ||
1844 | 673 | //the application started | 668 | //the application started |
1845 | @@ -676,16 +671,15 @@ | |||
1846 | 676 | } | 671 | } |
1847 | 677 | 672 | ||
1848 | 678 | //the application was requested to open some files | 673 | //the application was requested to open some files |
1850 | 679 | public override void open (File [] files, string hint) { | 674 | public override void open (File[] files, string hint) { |
1851 | 680 | if (mainwindow == null) | 675 | if (mainwindow == null) |
1852 | 681 | activate (); | 676 | activate (); |
1853 | 682 | 677 | ||
1854 | 683 | for (var i = 1; i < files.length; i ++) | ||
1855 | 684 | playlist.add_item (files[i]); | ||
1856 | 685 | |||
1857 | 686 | open_file (files[0].get_path ()); | ||
1858 | 687 | welcome.hide (); | 678 | welcome.hide (); |
1859 | 688 | clutter.show_all (); | 679 | clutter.show_all (); |
1860 | 680 | foreach (var file in files) { | ||
1861 | 681 | open_file (file.get_path ()); | ||
1862 | 682 | } | ||
1863 | 689 | } | 683 | } |
1864 | 690 | } | 684 | } |
1865 | 691 | } | 685 | } |
1866 | 692 | 686 | ||
1867 | === added file 'src/CMakeLists.txt' | |||
1868 | --- src/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
1869 | +++ src/CMakeLists.txt 2014-07-06 11:18:29 +0000 | |||
1870 | @@ -0,0 +1,57 @@ | |||
1871 | 1 | # Vala stuff | ||
1872 | 2 | find_package (Vala REQUIRED) | ||
1873 | 3 | include (ValaVersion) | ||
1874 | 4 | ensure_vala_version ("0.22" MINIMUM) | ||
1875 | 5 | include (ValaPrecompile) | ||
1876 | 6 | |||
1877 | 7 | # Configure file | ||
1878 | 8 | set (CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/config.vala) | ||
1879 | 9 | configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Config.vala.cmake ${CONFIG_FILE}) | ||
1880 | 10 | |||
1881 | 11 | # pkgconfig, real C code | ||
1882 | 12 | find_package (PkgConfig) | ||
1883 | 13 | |||
1884 | 14 | set (PKG_DEPS granite clutter-gtk-1.0 gstreamer-1.0 gstreamer-pbutils-1.0 gstreamer-tag-1.0) | ||
1885 | 15 | set (VALA_DEPS | ||
1886 | 16 | granite | ||
1887 | 17 | clutter-gtk-1.0 | ||
1888 | 18 | gdk-x11-3.0 | ||
1889 | 19 | gstreamer-1.0 | ||
1890 | 20 | gstreamer-pbutils-1.0 | ||
1891 | 21 | gstreamer-tag-1.0 | ||
1892 | 22 | ) | ||
1893 | 23 | |||
1894 | 24 | pkg_check_modules (DEPS REQUIRED ${PKG_DEPS}) | ||
1895 | 25 | set (CFLAGS ${DEPS_CFLAGS} ${DEPS_CFLAGS_OTHER}) | ||
1896 | 26 | link_directories (${DEPS_LIBRARY_DIRS}) | ||
1897 | 27 | add_definitions (${CFLAGS}) | ||
1898 | 28 | |||
1899 | 29 | set (EXEC_NAME ${CMAKE_PROJECT_NAME}) | ||
1900 | 30 | |||
1901 | 31 | vala_precompile (VALA_C ${EXEC_NAME} | ||
1902 | 32 | ${CONFIG_FILE} | ||
1903 | 33 | Audience.vala | ||
1904 | 34 | Consts.vala | ||
1905 | 35 | Settings.vala | ||
1906 | 36 | Utils.vala | ||
1907 | 37 | DiskManager.vala | ||
1908 | 38 | Widgets/BottomBar.vala | ||
1909 | 39 | Widgets/SettingsPopover.vala | ||
1910 | 40 | Widgets/PreviewPopover.vala | ||
1911 | 41 | Widgets/TimeWidget.vala | ||
1912 | 42 | Widgets/Playlist.vala | ||
1913 | 43 | Widgets/PlaylistPopover.vala | ||
1914 | 44 | Widgets/VideoPlayer.vala | ||
1915 | 45 | desktop-launcher.vala | ||
1916 | 46 | PACKAGES | ||
1917 | 47 | ${VALA_DEPS} | ||
1918 | 48 | OPTIONS | ||
1919 | 49 | --enable-experimental | ||
1920 | 50 | --target-glib=2.32 # Remember to keep this updated. | ||
1921 | 51 | --thread | ||
1922 | 52 | -g | ||
1923 | 53 | ) | ||
1924 | 54 | |||
1925 | 55 | add_executable (${EXEC_NAME} ${VALA_C}) | ||
1926 | 56 | target_link_libraries (${EXEC_NAME} ${DEPS_LIBRARIES}) | ||
1927 | 57 | install (TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin) | ||
1928 | 0 | \ No newline at end of file | 58 | \ No newline at end of file |
1929 | 1 | 59 | ||
1930 | === modified file 'src/Consts.vala' | |||
1931 | --- src/Consts.vala 2013-03-31 21:46:37 +0000 | |||
1932 | +++ src/Consts.vala 2014-07-06 11:18:29 +0000 | |||
1933 | @@ -1,6 +1,7 @@ | |||
1934 | 1 | 1 | ||
1935 | 2 | namespace Audience { | 2 | namespace Audience { |
1936 | 3 | |||
1937 | 4 | public const int CONTROLS_HEIGHT = 32; | 3 | public const int CONTROLS_HEIGHT = 32; |
1938 | 4 | // 204/255 = 80% opacity | ||
1939 | 5 | public const uint GLOBAL_OPACITY = 204; | ||
1940 | 5 | 6 | ||
1942 | 6 | } | 7 | } |
1943 | 7 | \ No newline at end of file | 8 | \ No newline at end of file |
1944 | 8 | 9 | ||
1945 | === added file 'src/DiskManager.vala' | |||
1946 | --- src/DiskManager.vala 1970-01-01 00:00:00 +0000 | |||
1947 | +++ src/DiskManager.vala 2014-07-06 11:18:29 +0000 | |||
1948 | @@ -0,0 +1,98 @@ | |||
1949 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1950 | 2 | /*- | ||
1951 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
1952 | 4 | * | ||
1953 | 5 | * This program is free software: you can redistribute it and/or modify | ||
1954 | 6 | * it under the terms of the GNU General Public License as published by | ||
1955 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
1956 | 8 | * (at your option) any later version. | ||
1957 | 9 | |||
1958 | 10 | * This program is distributed in the hope that it will be useful, | ||
1959 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1960 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1961 | 13 | * GNU General Public License for more details. | ||
1962 | 14 | |||
1963 | 15 | * You should have received a copy of the GNU General Public License | ||
1964 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1965 | 17 | * | ||
1966 | 18 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
1967 | 19 | */ | ||
1968 | 20 | |||
1969 | 21 | public class Audience.DiskManager : GLib.Object { | ||
1970 | 22 | public signal void volume_found (Volume volume); | ||
1971 | 23 | public signal void volume_removed (Volume volume); | ||
1972 | 24 | |||
1973 | 25 | private static DiskManager disk_manager = null; | ||
1974 | 26 | public static DiskManager get_default () { | ||
1975 | 27 | if (disk_manager == null) { | ||
1976 | 28 | disk_manager = new DiskManager (); | ||
1977 | 29 | } | ||
1978 | 30 | |||
1979 | 31 | return disk_manager; | ||
1980 | 32 | } | ||
1981 | 33 | |||
1982 | 34 | private GLib.VolumeMonitor monitor; | ||
1983 | 35 | private List<Volume> volumes; | ||
1984 | 36 | |||
1985 | 37 | private DiskManager () { | ||
1986 | 38 | monitor = GLib.VolumeMonitor.get (); | ||
1987 | 39 | volumes = monitor.get_volumes (); | ||
1988 | 40 | |||
1989 | 41 | monitor.drive_changed.connect ((drive) => { | ||
1990 | 42 | debug ("Drive changed: %s\n", drive.get_name ()); | ||
1991 | 43 | }); | ||
1992 | 44 | |||
1993 | 45 | monitor.drive_connected.connect ((drive) => { | ||
1994 | 46 | debug ("Drive connected: %s", drive.get_name ()); | ||
1995 | 47 | }); | ||
1996 | 48 | |||
1997 | 49 | monitor.drive_disconnected.connect ((drive) => { | ||
1998 | 50 | debug ("Drive disconnected: %s", drive.get_name ()); | ||
1999 | 51 | }); | ||
2000 | 52 | |||
2001 | 53 | monitor.drive_eject_button.connect ((drive) => { | ||
2002 | 54 | debug ("Drive eject-button: %s", drive.get_name ()); | ||
2003 | 55 | }); | ||
2004 | 56 | |||
2005 | 57 | monitor.drive_stop_button.connect ((drive) => { | ||
2006 | 58 | debug ("Drive stop-button:%s", drive.get_name ()); | ||
2007 | 59 | }); | ||
2008 | 60 | |||
2009 | 61 | monitor.volume_added.connect ((volume) => { | ||
2010 | 62 | check_for_volume (volume); | ||
2011 | 63 | debug ("Volume added: %s", volume.get_name ()); | ||
2012 | 64 | }); | ||
2013 | 65 | |||
2014 | 66 | monitor.volume_changed.connect ((volume) => { | ||
2015 | 67 | check_for_volume (volume); | ||
2016 | 68 | debug ("Volume changed: %s", volume.get_name ()); | ||
2017 | 69 | }); | ||
2018 | 70 | |||
2019 | 71 | monitor.volume_removed.connect ((volume) => { | ||
2020 | 72 | volumes.remove (volume); | ||
2021 | 73 | volume_removed (volume); | ||
2022 | 74 | debug ("Volume removed: %s", volume.get_name ()); | ||
2023 | 75 | }); | ||
2024 | 76 | } | ||
2025 | 77 | |||
2026 | 78 | public GLib.List<Volume> get_volumes () { | ||
2027 | 79 | return volumes.copy (); | ||
2028 | 80 | } | ||
2029 | 81 | |||
2030 | 82 | private void check_for_volume (Volume volume) { | ||
2031 | 83 | if (volume.get_drive ().is_media_check_automatic () == true) { | ||
2032 | 84 | if (volume.get_drive ().has_media () == true) { | ||
2033 | 85 | var root = volume.get_activation_root (); | ||
2034 | 86 | if (root != null) { | ||
2035 | 87 | var video = root.get_child ("VIDEO_TS"); | ||
2036 | 88 | var bdmv = root.get_child ("BDMV"); | ||
2037 | 89 | var audio = root.get_child ("AUDIO_TS"); | ||
2038 | 90 | if (audio.query_exists () == true || video.query_exists () == true || bdmv.query_exists () == true) { | ||
2039 | 91 | volumes.append (volume); | ||
2040 | 92 | volume_found (volume); | ||
2041 | 93 | } | ||
2042 | 94 | } | ||
2043 | 95 | } | ||
2044 | 96 | } | ||
2045 | 97 | } | ||
2046 | 98 | } | ||
2047 | 0 | \ No newline at end of file | 99 | \ No newline at end of file |
2048 | 1 | 100 | ||
2049 | === modified file 'src/Settings.vala' | |||
2050 | --- src/Settings.vala 2013-03-31 21:46:37 +0000 | |||
2051 | +++ src/Settings.vala 2014-07-06 11:18:29 +0000 | |||
2052 | @@ -1,19 +1,36 @@ | |||
2070 | 1 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | |
2071 | 2 | namespace Audience { | 2 | /*- |
2072 | 3 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | |
2073 | 4 | public class Settings : Granite.Services.Settings { | 4 | * |
2074 | 5 | public bool move_window {get; set;} | 5 | * This program is free software: you can redistribute it and/or modify |
2075 | 6 | public bool keep_aspect {get; set;} | 6 | * it under the terms of the GNU General Public License as published by |
2076 | 7 | public bool resume_videos {get; set;} | 7 | * the Free Software Foundation, either version 3 of the License, or |
2077 | 8 | public string last_played_videos {get; set;} /*video1,time,video2,time2,...*/ | 8 | * (at your option) any later version. |
2078 | 9 | public string last_folder {get; set;} | 9 | |
2079 | 10 | public bool playback_wait {get; set;} | 10 | * This program is distributed in the hope that it will be useful, |
2080 | 11 | public bool stay_on_top {get; set;} | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2081 | 12 | public bool show_window_decoration {get; set;} | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2082 | 13 | 13 | * GNU General Public License for more details. | |
2083 | 14 | public Settings () { | 14 | |
2084 | 15 | base ("org.pantheon.Audience"); | 15 | * You should have received a copy of the GNU General Public License |
2085 | 16 | } | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2086 | 17 | 17 | * | |
2087 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
2088 | 19 | */ | ||
2089 | 20 | |||
2090 | 21 | public class Audience.Settings : Granite.Services.Settings { | ||
2091 | 22 | public bool move_window {get; set;} | ||
2092 | 23 | public bool keep_aspect {get; set;} | ||
2093 | 24 | public bool resume_videos {get; set;} | ||
2094 | 25 | public string[] last_played_videos {get; set;} | ||
2095 | 26 | public double last_stopped {get; set;} | ||
2096 | 27 | public string last_folder {get; set;} | ||
2097 | 28 | public bool playback_wait {get; set;} | ||
2098 | 29 | public bool stay_on_top {get; set;} | ||
2099 | 30 | public bool show_window_decoration {get; set;} | ||
2100 | 31 | |||
2101 | 32 | public Settings () { | ||
2102 | 33 | base ("org.pantheon.Audience"); | ||
2103 | 18 | } | 34 | } |
2105 | 19 | } | 35 | |
2106 | 36 | } | ||
2107 | 20 | \ No newline at end of file | 37 | \ No newline at end of file |
2108 | 21 | 38 | ||
2109 | === modified file 'src/Utils.vala' | |||
2110 | --- src/Utils.vala 2014-04-28 12:58:09 +0000 | |||
2111 | +++ src/Utils.vala 2014-07-06 11:18:29 +0000 | |||
2112 | @@ -1,3 +1,22 @@ | |||
2113 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
2114 | 2 | /*- | ||
2115 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
2116 | 4 | * | ||
2117 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2118 | 6 | * it under the terms of the GNU General Public License as published by | ||
2119 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
2120 | 8 | * (at your option) any later version. | ||
2121 | 9 | |||
2122 | 10 | * This program is distributed in the hope that it will be useful, | ||
2123 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2124 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2125 | 13 | * GNU General Public License for more details. | ||
2126 | 14 | |||
2127 | 15 | * You should have received a copy of the GNU General Public License | ||
2128 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2129 | 17 | * | ||
2130 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
2131 | 19 | */ | ||
2132 | 1 | 20 | ||
2133 | 2 | [DBus (name = "org.gnome.SettingsDaemon.MediaKeys")] | 21 | [DBus (name = "org.gnome.SettingsDaemon.MediaKeys")] |
2134 | 3 | public interface GnomeMediaKeys : GLib.Object { | 22 | public interface GnomeMediaKeys : GLib.Object { |
2135 | @@ -8,7 +27,7 @@ | |||
2136 | 8 | 27 | ||
2137 | 9 | [DBus (name = "org.gnome.SessionManager")] | 28 | [DBus (name = "org.gnome.SessionManager")] |
2138 | 10 | public interface GnomeSessionManager : GLib.Object { | 29 | public interface GnomeSessionManager : GLib.Object { |
2140 | 11 | public abstract bool isSessionRunning() throws GLib.IOError; | 30 | public abstract bool isSessionRunning() throws GLib.IOError; |
2141 | 12 | public abstract uint32 Inhibit (string app_id, uint32 toplevel_xid, string reason, uint32 flags) throws GLib.IOError; | 31 | public abstract uint32 Inhibit (string app_id, uint32 toplevel_xid, string reason, uint32 flags) throws GLib.IOError; |
2142 | 13 | public abstract void Uninhibit (uint32 inhibit_cookie) throws GLib.IOError; | 32 | public abstract void Uninhibit (uint32 inhibit_cookie) throws GLib.IOError; |
2143 | 14 | } | 33 | } |
2144 | @@ -18,16 +37,16 @@ | |||
2145 | 18 | public static void recurse_over_dir (File file_to_process, FuncOverDir func) { | 37 | public static void recurse_over_dir (File file_to_process, FuncOverDir func) { |
2146 | 19 | if (file_to_process.query_file_type (0) == FileType.DIRECTORY) { | 38 | if (file_to_process.query_file_type (0) == FileType.DIRECTORY) { |
2147 | 20 | try { | 39 | try { |
2149 | 21 | var files = file_to_process.enumerate_children (FileAttribute.STANDARD_NAME, 0); | 40 | var files = file_to_process.enumerate_children (FileAttribute.STANDARD_NAME + "," + FileAttribute.ACCESS_CAN_READ, FileQueryInfoFlags.NONE); |
2150 | 22 | FileInfo info; | 41 | FileInfo info; |
2151 | 23 | while ((info = files.next_file ()) != null) { | 42 | while ((info = files.next_file ()) != null) { |
2155 | 24 | var file = GLib.File.new_for_uri ( | 43 | var file = GLib.File.new_for_uri (file_to_process.get_uri () + "/" + info.get_name ()); |
2156 | 25 | file_to_process.get_uri () +"/"+info.get_name ()); | 44 | recurse_over_dir (file, func); |
2154 | 26 | recurse_over_dir (file,func); | ||
2157 | 27 | } | 45 | } |
2161 | 28 | } catch (Error e) { warning (e.message); } | 46 | } catch (Error e) { |
2162 | 29 | } | 47 | critical (e.message); |
2163 | 30 | else { | 48 | } |
2164 | 49 | } else { | ||
2165 | 31 | func (file_to_process); | 50 | func (file_to_process); |
2166 | 32 | } | 51 | } |
2167 | 33 | } | 52 | } |
2168 | @@ -40,216 +59,51 @@ | |||
2169 | 40 | } | 59 | } |
2170 | 41 | 60 | ||
2171 | 42 | public static string get_extension (string filename) { | 61 | public static string get_extension (string filename) { |
2176 | 43 | int i=0; | 62 | for (uint i=filename.length; i!=0; i--) { |
2177 | 44 | for (i=filename.length;i!=0;i--) { | 63 | if (filename[i] == '.') |
2178 | 45 | if (filename [i] == '.') | 64 | return filename.substring (i+1); |
2175 | 46 | break; | ||
2179 | 47 | } | 65 | } |
2181 | 48 | return filename.substring (i+1); | 66 | |
2182 | 67 | return filename; | ||
2183 | 49 | } | 68 | } |
2184 | 50 | 69 | ||
2185 | 51 | public static string get_basename (string filename) { | 70 | public static string get_basename (string filename) { |
2188 | 52 | int start = 0, end = 0; | 71 | uint end = 0; |
2189 | 53 | for (start=filename.length; start != 0; start--) { | 72 | for (uint start=filename.length; start != 0; start--) { |
2190 | 54 | if (filename[start] == '/') { | 73 | if (filename[start] == '/') { |
2191 | 55 | start ++; | 74 | start ++; |
2193 | 56 | break; | 75 | return filename.substring (start, end - start); |
2194 | 57 | } | 76 | } |
2195 | 77 | |||
2196 | 58 | if (filename[start] == '.' && end == 0) | 78 | if (filename[start] == '.' && end == 0) |
2197 | 59 | end = start; | 79 | end = start; |
2198 | 60 | } | 80 | } |
2200 | 61 | return filename.substring (start, end - start); | 81 | |
2201 | 82 | return filename.substring (0, end); | ||
2202 | 62 | } | 83 | } |
2203 | 63 | 84 | ||
2204 | 64 | public static string seconds_to_time (int seconds) { | 85 | public static string seconds_to_time (int seconds) { |
2205 | 65 | int hours = seconds / 3600; | 86 | int hours = seconds / 3600; |
2213 | 66 | int minutes = (seconds % 3600) / 60; | 87 | string min = normalize_time ((seconds % 3600) / 60); |
2214 | 67 | seconds = seconds % 60; | 88 | string sec = normalize_time (seconds % 60); |
2215 | 68 | 89 | ||
2216 | 69 | string time = (hours > 0) ? hours.to_string() + ":" : ""; | 90 | if (hours > 0) { |
2217 | 70 | time += (((hours > 0) && (minutes < 10)) ? "0" : "") + minutes.to_string() + ":"; | 91 | return ("%d:%s:%s".printf (hours, min, sec)); |
2218 | 71 | time += ((seconds < 10) ? "0" : "") + seconds.to_string(); | 92 | } else { |
2219 | 72 | return time; | 93 | return ("%s:%s".printf (min, sec)); |
2220 | 94 | } | ||
2221 | 95 | } | ||
2222 | 96 | |||
2223 | 97 | public static string normalize_time (int time) { | ||
2224 | 98 | if (time < 10) { | ||
2225 | 99 | return "0%d".printf (time); | ||
2226 | 100 | } else { | ||
2227 | 101 | return "%d".printf (time); | ||
2228 | 102 | } | ||
2229 | 73 | } | 103 | } |
2230 | 74 | 104 | ||
2231 | 75 | public static bool has_dvd () { | 105 | public static bool has_dvd () { |
2410 | 76 | var volume_monitor = GLib.VolumeMonitor.get (); | 106 | var disk_manager = DiskManager.get_default (); |
2411 | 77 | var volumes = volume_monitor.get_connected_drives (); | 107 | return disk_manager.get_volumes ().length () > 0; |
2234 | 78 | |||
2235 | 79 | for (var i=0; i < volumes.length ();i++) { | ||
2236 | 80 | if (volumes.nth_data (i).get_name ().index_of ("DVD") != -1 && | ||
2237 | 81 | volumes.nth_data (i).has_media ()) | ||
2238 | 82 | return true; | ||
2239 | 83 | } | ||
2240 | 84 | |||
2241 | 85 | return false; | ||
2242 | 86 | } | ||
2243 | 87 | |||
2244 | 88 | public static dynamic Gst.Element get_clutter_sink () | ||
2245 | 89 | { | ||
2246 | 90 | var sink = Gst.ElementFactory.make ("autocluttersink", "videosink"); | ||
2247 | 91 | if (sink == null) { | ||
2248 | 92 | warning ("autocluttersink not available"); | ||
2249 | 93 | sink = Gst.ElementFactory.make ("cluttersink", "videosink"); | ||
2250 | 94 | } | ||
2251 | 95 | |||
2252 | 96 | return sink; | ||
2253 | 97 | } | ||
2254 | 98 | |||
2255 | 99 | /* | ||
2256 | 100 | * get a thumbnail from a file | ||
2257 | 101 | * @param file the file | ||
2258 | 102 | * @param position the position in the video or -1 for 5% | ||
2259 | 103 | * @param pixbuf gtkclutter texture to put the pixbuf in once it's ready | ||
2260 | 104 | * TODO appears not to load thumbs for bigger files | ||
2261 | 105 | **/ | ||
2262 | 106 | /* NOT NEEDED CURRENTLY | ||
2263 | 107 | public static void get_thumb (File file, int64 position, GtkClutter.Texture tex) { | ||
2264 | 108 | //pipeline | ||
2265 | 109 | bool got_video = false; | ||
2266 | 110 | var pipe = new Gst.Pipeline ("pipeline"); | ||
2267 | 111 | var src = Gst.ElementFactory.make ("filesrc", "file"); | ||
2268 | 112 | dynamic Gst.Element dec = Gst.ElementFactory.make ("decodebin2", "dec"); | ||
2269 | 113 | |||
2270 | 114 | pipe.add_many (src, dec); | ||
2271 | 115 | src.link (dec); | ||
2272 | 116 | src.set ("location", file.get_path ()); | ||
2273 | 117 | dynamic Gst.Element sink = null; | ||
2274 | 118 | dec.pad_added.connect ( (new_pad) => { | ||
2275 | 119 | if (got_video) | ||
2276 | 120 | return; | ||
2277 | 121 | |||
2278 | 122 | var csp = Gst.ElementFactory.make ("ffmpegcolorspace", "f"); | ||
2279 | 123 | var scale = Gst.ElementFactory.make ("videoscale", "s"); | ||
2280 | 124 | var filter = Gst.ElementFactory.make ("capsfilter", "c"); | ||
2281 | 125 | sink = Gst.ElementFactory.make ("gdkpixbufsink", "sink"); | ||
2282 | 126 | |||
2283 | 127 | pipe.add_many (csp, scale, filter, sink); | ||
2284 | 128 | |||
2285 | 129 | var sinkpad = csp.get_static_pad ("sink"); | ||
2286 | 130 | new_pad.link (sinkpad); | ||
2287 | 131 | |||
2288 | 132 | csp.link (scale); | ||
2289 | 133 | scale.link (filter); | ||
2290 | 134 | filter.link (sink); | ||
2291 | 135 | |||
2292 | 136 | sink.set_state (Gst.State.PAUSED); | ||
2293 | 137 | filter.set_state (Gst.State.PAUSED); | ||
2294 | 138 | scale.set_state (Gst.State.PAUSED); | ||
2295 | 139 | csp.set_state (Gst.State.PAUSED); | ||
2296 | 140 | |||
2297 | 141 | got_video = true; | ||
2298 | 142 | }); | ||
2299 | 143 | |||
2300 | 144 | pipe.get_bus ().add_signal_watch (); | ||
2301 | 145 | |||
2302 | 146 | pipe.set_state (Gst.State.PAUSED); | ||
2303 | 147 | |||
2304 | 148 | bool ready = false; | ||
2305 | 149 | pipe.get_bus ().message.connect ( (bus, msg) => { | ||
2306 | 150 | switch (msg.type) { | ||
2307 | 151 | case Gst.MessageType.ASYNC_DONE: | ||
2308 | 152 | if (msg.src != pipe) | ||
2309 | 153 | break; | ||
2310 | 154 | var fmt = Gst.Format.TIME; | ||
2311 | 155 | int64 pos; | ||
2312 | 156 | pipe.query_position (fmt, out pos); | ||
2313 | 157 | if (pos > 1) | ||
2314 | 158 | ready = true; | ||
2315 | 159 | else | ||
2316 | 160 | break; | ||
2317 | 161 | if (position == -1) { | ||
2318 | 162 | int64 dur; | ||
2319 | 163 | pipe.query_duration (fmt, out dur); | ||
2320 | 164 | pipe.seek_simple (Gst.Format.TIME, Gst.SeekFlags.ACCURATE | | ||
2321 | 165 | Gst.SeekFlags.FLUSH, (int64)(dur*0.5)); | ||
2322 | 166 | }else { | ||
2323 | 167 | pipe.seek_simple (Gst.Format.TIME, Gst.SeekFlags.ACCURATE | | ||
2324 | 168 | Gst.SeekFlags.FLUSH, position); | ||
2325 | 169 | } | ||
2326 | 170 | break; | ||
2327 | 171 | case Gst.MessageType.ELEMENT: | ||
2328 | 172 | if (!ready) | ||
2329 | 173 | break; | ||
2330 | 174 | if (msg.src != sink) | ||
2331 | 175 | break; | ||
2332 | 176 | if (!msg.get_structure ().has_name ("prerollpixbuf") && | ||
2333 | 177 | !msg.get_structure ().has_name ("pixbuf")) | ||
2334 | 178 | break; | ||
2335 | 179 | var val = msg.get_structure ().get_value ("pixbuf"); | ||
2336 | 180 | var pixbuf = (Gdk.Pixbuf)val.dup_object (); | ||
2337 | 181 | if (pixbuf == null) | ||
2338 | 182 | return; | ||
2339 | 183 | try { | ||
2340 | 184 | tex.set_from_pixbuf (pixbuf); | ||
2341 | 185 | } catch (Error e) {warning (e.message);} | ||
2342 | 186 | pipe.set_state (Gst.State.NULL); | ||
2343 | 187 | break; | ||
2344 | 188 | default: | ||
2345 | 189 | break; | ||
2346 | 190 | } | ||
2347 | 191 | }); | ||
2348 | 192 | |||
2349 | 193 | pipe.set_state (Gst.State.PLAYING); | ||
2350 | 194 | }*/ | ||
2351 | 195 | |||
2352 | 196 | namespace Drawing { | ||
2353 | 197 | |||
2354 | 198 | /** | ||
2355 | 199 | * Draws a popover shape | ||
2356 | 200 | */ | ||
2357 | 201 | public static void cairo_popover (Cairo.Context cr, double x, double y, double width, double height, | ||
2358 | 202 | double radius, double arrow_height, double arrow_width) | ||
2359 | 203 | { | ||
2360 | 204 | double edge_width = (width - radius * 2); | ||
2361 | 205 | double arrow_offset = (edge_width - arrow_width) / 2; | ||
2362 | 206 | |||
2363 | 207 | |||
2364 | 208 | cr.arc (x + width - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 2); | ||
2365 | 209 | cr.arc (x + width - radius, y + height - radius, radius, 0, Math.PI * 0.5); | ||
2366 | 210 | |||
2367 | 211 | cr.arc (x + radius, y + height - radius, radius, Math.PI * 0.5, Math.PI); | ||
2368 | 212 | cr.arc (x + radius, y + radius, radius, Math.PI, Math.PI * 1.5); | ||
2369 | 213 | cr.move_to (x + radius + arrow_offset, y + height); | ||
2370 | 214 | |||
2371 | 215 | cr.rel_line_to (arrow_width / 2, arrow_height); | ||
2372 | 216 | cr.rel_line_to (arrow_width / 2, -arrow_height); | ||
2373 | 217 | |||
2374 | 218 | cr.close_path (); | ||
2375 | 219 | } | ||
2376 | 220 | |||
2377 | 221 | /** | ||
2378 | 222 | * Draws a 'pill' shape (rounded rectangle with boder radius such that both ends are semicircles) | ||
2379 | 223 | */ | ||
2380 | 224 | public static void cairo_pill (Cairo.Context cr, double x, double y, double width, double height) { | ||
2381 | 225 | Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, x, y, width, height, height / 2); | ||
2382 | 226 | } | ||
2383 | 227 | |||
2384 | 228 | /** | ||
2385 | 229 | * Draws a ' halfpill' shape (rounded rectangle with boder radius such that one ends is a semicircle) | ||
2386 | 230 | */ | ||
2387 | 231 | public static void cairo_half_pill (Cairo.Context cr, double x, double y, double width, double height, Gtk.PositionType side) { | ||
2388 | 232 | double radius = height / 2; | ||
2389 | 233 | cr.move_to (x + radius, y); | ||
2390 | 234 | switch (side) { | ||
2391 | 235 | case Gtk.PositionType.LEFT: | ||
2392 | 236 | cr.arc (x + width - radius, y + radius, radius, Math.PI * 1.5, Math.PI * 0.5); | ||
2393 | 237 | cr.line_to ((int)x, y + height); // (int) required to not draw 'half' pixels (blurry) | ||
2394 | 238 | cr.line_to ((int)x, y); | ||
2395 | 239 | cr.line_to ((int)(x + width - radius), y); | ||
2396 | 240 | break; | ||
2397 | 241 | case Gtk.PositionType.RIGHT: | ||
2398 | 242 | cr.arc (x + radius, y + height - radius, radius, Math.PI * 0.5, Math.PI * 1.5); | ||
2399 | 243 | cr.line_to ((int)(x + width), y); | ||
2400 | 244 | cr.line_to ((int)(x + width), y + height); | ||
2401 | 245 | cr.line_to ((int)(x + radius), y + height); | ||
2402 | 246 | break; | ||
2403 | 247 | default: | ||
2404 | 248 | assert_not_reached(); | ||
2405 | 249 | } | ||
2406 | 250 | cr.close_path (); | ||
2407 | 251 | } | ||
2408 | 252 | |||
2409 | 253 | |||
2412 | 254 | } | 108 | } |
2413 | 255 | } | 109 | } |
2414 | 256 | \ No newline at end of file | 110 | \ No newline at end of file |
2415 | 257 | 111 | ||
2416 | === added file 'src/Widgets/BottomBar.vala' | |||
2417 | --- src/Widgets/BottomBar.vala 1970-01-01 00:00:00 +0000 | |||
2418 | +++ src/Widgets/BottomBar.vala 2014-07-06 11:18:29 +0000 | |||
2419 | @@ -0,0 +1,160 @@ | |||
2420 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
2421 | 2 | /*- | ||
2422 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
2423 | 4 | * | ||
2424 | 5 | * This program is free software: you can redistribute it and/or modify | ||
2425 | 6 | * it under the terms of the GNU General Public License as published by | ||
2426 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
2427 | 8 | * (at your option) any later version. | ||
2428 | 9 | |||
2429 | 10 | * This program is distributed in the hope that it will be useful, | ||
2430 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2431 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2432 | 13 | * GNU General Public License for more details. | ||
2433 | 14 | |||
2434 | 15 | * You should have received a copy of the GNU General Public License | ||
2435 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2436 | 17 | * | ||
2437 | 18 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
2438 | 19 | */ | ||
2439 | 20 | |||
2440 | 21 | public class Audience.Widgets.BottomBar : Gtk.Revealer { | ||
2441 | 22 | public signal void play_toggled (); | ||
2442 | 23 | public signal void unfullscreen (); | ||
2443 | 24 | public signal void seeked (double val); | ||
2444 | 25 | |||
2445 | 26 | public bool hovered { get; set; default=false; } | ||
2446 | 27 | public bool fullscreen { get; set; default=false; } | ||
2447 | 28 | public SettingsPopover preferences_popover; | ||
2448 | 29 | public TimeWidget time_widget; | ||
2449 | 30 | |||
2450 | 31 | private Gtk.Button play_button; | ||
2451 | 32 | private Gtk.Button preferences_button; | ||
2452 | 33 | private Gtk.Revealer unfullscreen_revealer; | ||
2453 | 34 | private PlaylistPopover playlist_popover; | ||
2454 | 35 | private bool is_playing = false; | ||
2455 | 36 | private uint hiding_timer = 0; | ||
2456 | 37 | |||
2457 | 38 | public BottomBar () { | ||
2458 | 39 | transition_type = Gtk.RevealerTransitionType.CROSSFADE; | ||
2459 | 40 | var main_actionbar = new Gtk.ActionBar (); | ||
2460 | 41 | main_actionbar.opacity = GLOBAL_OPACITY; | ||
2461 | 42 | |||
2462 | 43 | play_button = new Gtk.Button.from_icon_name ("media-playback-start-symbolic", Gtk.IconSize.BUTTON); | ||
2463 | 44 | play_button.tooltip_text = _("Play"); | ||
2464 | 45 | play_button.clicked.connect (() => {play_toggled ();}); | ||
2465 | 46 | |||
2466 | 47 | var playlist_button = new Gtk.Button.from_icon_name ("view-list-symbolic", Gtk.IconSize.BUTTON); | ||
2467 | 48 | playlist_button.tooltip_text = _("Playlist"); | ||
2468 | 49 | playlist_button.clicked.connect (() => {playlist_popover.show_all (); playlist_popover.queue_resize ();}); | ||
2469 | 50 | |||
2470 | 51 | preferences_button = new Gtk.Button.from_icon_name ("document-properties-symbolic", Gtk.IconSize.BUTTON); | ||
2471 | 52 | preferences_button.tooltip_text = _("Settings"); | ||
2472 | 53 | preferences_button.clicked.connect (() => {preferences_popover.show_all (); preferences_popover.queue_resize ();}); | ||
2473 | 54 | |||
2474 | 55 | time_widget = new TimeWidget (); | ||
2475 | 56 | time_widget.seeked.connect ((val) => {seeked (val);}); | ||
2476 | 57 | |||
2477 | 58 | playlist_popover = new PlaylistPopover (); | ||
2478 | 59 | playlist_popover.relative_to = playlist_button; | ||
2479 | 60 | preferences_popover = new SettingsPopover (); | ||
2480 | 61 | preferences_popover.relative_to = preferences_button; | ||
2481 | 62 | |||
2482 | 63 | main_actionbar.pack_start (play_button); | ||
2483 | 64 | main_actionbar.set_center_widget (time_widget); | ||
2484 | 65 | main_actionbar.pack_end (preferences_button); | ||
2485 | 66 | main_actionbar.pack_end (playlist_button); | ||
2486 | 67 | add (main_actionbar); | ||
2487 | 68 | |||
2488 | 69 | notify["hovered"].connect (() => { | ||
2489 | 70 | if (hovered == false) { | ||
2490 | 71 | set_timeout (); | ||
2491 | 72 | } else { | ||
2492 | 73 | if (hiding_timer != 0) { | ||
2493 | 74 | Source.remove (hiding_timer); | ||
2494 | 75 | hiding_timer = 0; | ||
2495 | 76 | } | ||
2496 | 77 | } | ||
2497 | 78 | }); | ||
2498 | 79 | |||
2499 | 80 | notify["fullscreen"].connect (() => { | ||
2500 | 81 | if (fullscreen == true && child_revealed == true) { | ||
2501 | 82 | unfullscreen_revealer.set_reveal_child (true); | ||
2502 | 83 | } else if (fullscreen == false && child_revealed == true) { | ||
2503 | 84 | unfullscreen_revealer.set_reveal_child (false); | ||
2504 | 85 | } | ||
2505 | 86 | }); | ||
2506 | 87 | |||
2507 | 88 | show_all (); | ||
2508 | 89 | } | ||
2509 | 90 | |||
2510 | 91 | public void set_preview_uri (string uri) { | ||
2511 | 92 | time_widget.set_preview_uri (uri); | ||
2512 | 93 | } | ||
2513 | 94 | |||
2514 | 95 | public Gtk.Revealer get_unfullscreen_button () { | ||
2515 | 96 | unfullscreen_revealer = new Gtk.Revealer (); | ||
2516 | 97 | unfullscreen_revealer.opacity = GLOBAL_OPACITY; | ||
2517 | 98 | unfullscreen_revealer.get_style_context ().add_class ("header-bar"); | ||
2518 | 99 | unfullscreen_revealer.transition_type = Gtk.RevealerTransitionType.CROSSFADE; | ||
2519 | 100 | var unfullscreen_button = new Gtk.Button.from_icon_name ("view-restore-symbolic", Gtk.IconSize.BUTTON); | ||
2520 | 101 | unfullscreen_button.tooltip_text = _("Unfullscreen"); | ||
2521 | 102 | unfullscreen_button.clicked.connect (() => {unfullscreen ();}); | ||
2522 | 103 | unfullscreen_revealer.add (unfullscreen_button); | ||
2523 | 104 | unfullscreen_revealer.show_all (); | ||
2524 | 105 | return unfullscreen_revealer; | ||
2525 | 106 | } | ||
2526 | 107 | |||
2527 | 108 | public void toggle_play_pause () { | ||
2528 | 109 | is_playing = !is_playing; | ||
2529 | 110 | if (is_playing == true) { | ||
2530 | 111 | play_button.image = new Gtk.Image.from_icon_name ("media-playback-pause-symbolic", Gtk.IconSize.BUTTON); | ||
2531 | 112 | play_button.tooltip_text = _("Pause"); | ||
2532 | 113 | set_timeout (); | ||
2533 | 114 | } else { | ||
2534 | 115 | play_button.image = new Gtk.Image.from_icon_name ("media-playback-start-symbolic", Gtk.IconSize.BUTTON); | ||
2535 | 116 | play_button.tooltip_text = _("Play"); | ||
2536 | 117 | set_reveal_child (true); | ||
2537 | 118 | } | ||
2538 | 119 | } | ||
2539 | 120 | |||
2540 | 121 | public new void set_reveal_child (bool reveal) { | ||
2541 | 122 | base.set_reveal_child (reveal); | ||
2542 | 123 | if (reveal == true && fullscreen == true) { | ||
2543 | 124 | unfullscreen_revealer.set_reveal_child (reveal); | ||
2544 | 125 | } else if (reveal == false) { | ||
2545 | 126 | unfullscreen_revealer.set_reveal_child (reveal); | ||
2546 | 127 | } | ||
2547 | 128 | } | ||
2548 | 129 | |||
2549 | 130 | public override void get_preferred_width (out int minimum_width, out int natural_width) { | ||
2550 | 131 | base.get_preferred_width (out minimum_width, out natural_width); | ||
2551 | 132 | if (parent.get_window () == null) | ||
2552 | 133 | return; | ||
2553 | 134 | |||
2554 | 135 | var width = parent.get_window ().get_width (); | ||
2555 | 136 | if (width > 0 && width >= minimum_width) { | ||
2556 | 137 | natural_width = width; | ||
2557 | 138 | } | ||
2558 | 139 | } | ||
2559 | 140 | |||
2560 | 141 | public void set_progression_time (double current_time, double total_time) { | ||
2561 | 142 | time_widget.set_progression_time (current_time, total_time); | ||
2562 | 143 | } | ||
2563 | 144 | |||
2564 | 145 | private void set_timeout () { | ||
2565 | 146 | if (hiding_timer != 0) | ||
2566 | 147 | Source.remove (hiding_timer); | ||
2567 | 148 | |||
2568 | 149 | hiding_timer = GLib.Timeout.add (2000, () => { | ||
2569 | 150 | if (hovered == true || preferences_popover.visible == true || playlist_popover.visible == true || is_playing == false) { | ||
2570 | 151 | hiding_timer = 0; | ||
2571 | 152 | return false; | ||
2572 | 153 | } | ||
2573 | 154 | set_reveal_child (false); | ||
2574 | 155 | unfullscreen_revealer.set_reveal_child (false); | ||
2575 | 156 | hiding_timer = 0; | ||
2576 | 157 | return false; | ||
2577 | 158 | }); | ||
2578 | 159 | } | ||
2579 | 160 | } | ||
2580 | 0 | \ No newline at end of file | 161 | \ No newline at end of file |
2581 | 1 | 162 | ||
2582 | === removed file 'src/Widgets/Button.vala' | |||
2583 | --- src/Widgets/Button.vala 2013-05-19 17:10:26 +0000 | |||
2584 | +++ src/Widgets/Button.vala 1970-01-01 00:00:00 +0000 | |||
2585 | @@ -1,53 +0,0 @@ | |||
2586 | 1 | |||
2587 | 2 | namespace Audience.Widgets{ | ||
2588 | 3 | |||
2589 | 4 | public class Button : GtkClutter.Texture { | ||
2590 | 5 | public signal void clicked (); | ||
2591 | 6 | |||
2592 | 7 | bool pressed = false; | ||
2593 | 8 | |||
2594 | 9 | public Button (string icon, string fallback, string alt_fallback=""){ | ||
2595 | 10 | set_icon (icon, fallback, alt_fallback); | ||
2596 | 11 | |||
2597 | 12 | reactive = true; | ||
2598 | 13 | width = 16; | ||
2599 | 14 | height = 16; | ||
2600 | 15 | opacity = 255; | ||
2601 | 16 | } | ||
2602 | 17 | |||
2603 | 18 | public override bool leave_event (Clutter.CrossingEvent event) { | ||
2604 | 19 | animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:255); | ||
2605 | 20 | return true; | ||
2606 | 21 | } | ||
2607 | 22 | |||
2608 | 23 | public override bool enter_event (Clutter.CrossingEvent event) { | ||
2609 | 24 | animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:170); | ||
2610 | 25 | return true; | ||
2611 | 26 | } | ||
2612 | 27 | |||
2613 | 28 | public override bool button_press_event (Clutter.ButtonEvent event) { | ||
2614 | 29 | pressed = true; | ||
2615 | 30 | return true; | ||
2616 | 31 | } | ||
2617 | 32 | |||
2618 | 33 | public override bool button_release_event (Clutter.ButtonEvent event) { | ||
2619 | 34 | if (pressed) { | ||
2620 | 35 | clicked (); | ||
2621 | 36 | pressed = false; | ||
2622 | 37 | } | ||
2623 | 38 | return true; | ||
2624 | 39 | } | ||
2625 | 40 | |||
2626 | 41 | public void set_icon (string icon, string fallback, string alt_fallback="") { | ||
2627 | 42 | try { | ||
2628 | 43 | var ti = new ThemedIcon.from_names ({icon, alt_fallback, fallback}); | ||
2629 | 44 | var l = Gtk.IconTheme.get_default ().lookup_by_gicon (ti, 16, 0); | ||
2630 | 45 | if (l != null) { | ||
2631 | 46 | this.set_from_pixbuf (l.load_symbolic ({1.0,1.0,1.0,1.0}, null, null, null, null)); | ||
2632 | 47 | } else { | ||
2633 | 48 | warning("NULL detected when trying to load icon: " + icon + " (or " + fallback + ")"); | ||
2634 | 49 | } | ||
2635 | 50 | } catch (Error e){warning (e.message);} | ||
2636 | 51 | } | ||
2637 | 52 | } | ||
2638 | 53 | } | ||
2639 | 54 | 0 | ||
2640 | === removed file 'src/Widgets/ControlsBar.vala' | |||
2641 | --- src/Widgets/ControlsBar.vala 2013-05-19 17:10:26 +0000 | |||
2642 | +++ src/Widgets/ControlsBar.vala 1970-01-01 00:00:00 +0000 | |||
2643 | @@ -1,137 +0,0 @@ | |||
2644 | 1 | using Clutter; | ||
2645 | 2 | |||
2646 | 3 | namespace Audience.Widgets | ||
2647 | 4 | { | ||
2648 | 5 | public class Controls : Actor | ||
2649 | 6 | { | ||
2650 | 7 | public MediaSlider slider; | ||
2651 | 8 | public Button play; | ||
2652 | 9 | public Button view; | ||
2653 | 10 | public Button open; | ||
2654 | 11 | |||
2655 | 12 | public Text current; | ||
2656 | 13 | public Text remaining; | ||
2657 | 14 | |||
2658 | 15 | private Gdk.Pixbuf play_pix; | ||
2659 | 16 | private Gdk.Pixbuf pause_pix; | ||
2660 | 17 | |||
2661 | 18 | public bool showing_view = false; | ||
2662 | 19 | public bool hovered { get; set; } | ||
2663 | 20 | |||
2664 | 21 | public Controls () | ||
2665 | 22 | { | ||
2666 | 23 | layout_manager = new BoxLayout (); | ||
2667 | 24 | content = new Canvas (); | ||
2668 | 25 | |||
2669 | 26 | (layout_manager as BoxLayout).spacing = 10; | ||
2670 | 27 | |||
2671 | 28 | this.current = new Text.full ("", "0", {255,255,255,255}); | ||
2672 | 29 | this.remaining = new Text.full ("", "0", {255,255,255,255}); | ||
2673 | 30 | |||
2674 | 31 | this.slider = new MediaSlider (); | ||
2675 | 32 | |||
2676 | 33 | this.play = new Button ("media-playback-start-symbolic", Gtk.Stock.MEDIA_PLAY); | ||
2677 | 34 | |||
2678 | 35 | this.view = new Button ("pane-show-symbolic", Gtk.Stock.GO_BACK, "go-previous-symbolic"); | ||
2679 | 36 | |||
2680 | 37 | this.open = new Button ("list-add-symbolic", Gtk.Stock.OPEN); | ||
2681 | 38 | |||
2682 | 39 | var spacer_left = new Rectangle.with_color ({0,0,0,0}); | ||
2683 | 40 | spacer_left.width = 0; | ||
2684 | 41 | var spacer_right = new Rectangle.with_color ({0,0,0,0}); | ||
2685 | 42 | spacer_right.width = 0; | ||
2686 | 43 | |||
2687 | 44 | this.add_child (spacer_left); | ||
2688 | 45 | this.add_child (this.play); | ||
2689 | 46 | this.add_child (this.current); | ||
2690 | 47 | this.add_child (this.slider); | ||
2691 | 48 | this.add_child (this.remaining); | ||
2692 | 49 | this.add_child (this.open); | ||
2693 | 50 | this.add_child (this.view); | ||
2694 | 51 | this.add_child (spacer_right); | ||
2695 | 52 | |||
2696 | 53 | (layout_manager as BoxLayout).set_expand (slider, true); | ||
2697 | 54 | (layout_manager as BoxLayout).set_fill (slider, true, true); | ||
2698 | 55 | |||
2699 | 56 | /*setup a css style for the control background*/ | ||
2700 | 57 | var style_holder = new Gtk.EventBox (); | ||
2701 | 58 | var css = new Gtk.CssProvider (); | ||
2702 | 59 | try{css.load_from_data (""" | ||
2703 | 60 | * { | ||
2704 | 61 | engine: unico; | ||
2705 | 62 | background-image: -gtk-gradient (linear, | ||
2706 | 63 | left top, left bottom, | ||
2707 | 64 | from (alpha(#323232, 0.698)), | ||
2708 | 65 | to (alpha(#242424, 0.698))); | ||
2709 | 66 | |||
2710 | 67 | -unico-outer-stroke-gradient: -gtk-gradient (linear, | ||
2711 | 68 | left top, left bottom, | ||
2712 | 69 | from (alpha(#161616, 0.698)), | ||
2713 | 70 | to (alpha(#000000, 0.698))); | ||
2714 | 71 | -unico-inner-stroke-gradient: -gtk-gradient (linear, | ||
2715 | 72 | left top, left bottom, | ||
2716 | 73 | from (alpha(#ffffff, 0.149)), | ||
2717 | 74 | color-stop (0.1, alpha(#ffffff, 0.035)), | ||
2718 | 75 | color-stop (0.9, alpha(#ffffff, 0.024)), | ||
2719 | 76 | to (alpha(#ffffff, 0.059))); | ||
2720 | 77 | -unico-inner-stroke-width: 1; | ||
2721 | 78 | -unico-outer-stroke-width: 1; | ||
2722 | 79 | } | ||
2723 | 80 | """, -1);}catch (Error e){warning (e.message);} | ||
2724 | 81 | style_holder.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); | ||
2725 | 82 | |||
2726 | 83 | (content as Canvas).draw.connect ( (ctx) => { | ||
2727 | 84 | ctx.set_operator (Cairo.Operator.CLEAR); | ||
2728 | 85 | ctx.paint (); | ||
2729 | 86 | ctx.set_operator (Cairo.Operator.OVER); | ||
2730 | 87 | |||
2731 | 88 | style_holder.get_style_context ().render_background (ctx, -2, 0, width+4, CONTROLS_HEIGHT+1); | ||
2732 | 89 | style_holder.get_style_context ().render_frame (ctx, -2, 0, width+4, CONTROLS_HEIGHT+1); | ||
2733 | 90 | |||
2734 | 91 | return false; | ||
2735 | 92 | }); | ||
2736 | 93 | (content as Canvas).set_size (500, CONTROLS_HEIGHT); | ||
2737 | 94 | |||
2738 | 95 | try { | ||
2739 | 96 | var l = Gtk.IconTheme.get_default ().lookup_icon ("media-playback-pause-symbolic", 16, 0); | ||
2740 | 97 | if (l == null) | ||
2741 | 98 | this.pause_pix = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_PAUSE, Gtk.IconSize.LARGE_TOOLBAR).pixbuf; | ||
2742 | 99 | else | ||
2743 | 100 | this.pause_pix = l.load_symbolic ({1.0,1.0,1.0,1.0}, null, null, null, null); | ||
2744 | 101 | } catch (Error e) { warning (e.message); } | ||
2745 | 102 | |||
2746 | 103 | try { | ||
2747 | 104 | var l = Gtk.IconTheme.get_default ().lookup_icon ("media-playback-start-symbolic", 16, 0); | ||
2748 | 105 | if (l == null) | ||
2749 | 106 | this.play_pix = new Gtk.Image.from_stock (Gtk.Stock.MEDIA_PLAY, Gtk.IconSize.LARGE_TOOLBAR).pixbuf; | ||
2750 | 107 | else | ||
2751 | 108 | this.play_pix = l.load_symbolic ({1.0,1.0,1.0,1.0}, null, null, null, null); | ||
2752 | 109 | } catch (Error e) { warning (e.message); } | ||
2753 | 110 | |||
2754 | 111 | this.height = CONTROLS_HEIGHT; | ||
2755 | 112 | |||
2756 | 113 | this.reactive = true; | ||
2757 | 114 | this.enter_event.connect ( () => { | ||
2758 | 115 | this.hovered = true; | ||
2759 | 116 | return false; | ||
2760 | 117 | }); | ||
2761 | 118 | this.leave_event.connect ( (e) => { | ||
2762 | 119 | if (!contains (e.related)) | ||
2763 | 120 | this.hovered = false; | ||
2764 | 121 | return false; | ||
2765 | 122 | }); | ||
2766 | 123 | } | ||
2767 | 124 | |||
2768 | 125 | // catch all button presses | ||
2769 | 126 | public override bool button_press_event (Clutter.ButtonEvent event) { | ||
2770 | 127 | return true; | ||
2771 | 128 | } | ||
2772 | 129 | |||
2773 | 130 | public void show_play_button (bool show){ /*or show pause button*/ | ||
2774 | 131 | try{ | ||
2775 | 132 | this.play.set_from_pixbuf ((show)?play_pix:pause_pix); | ||
2776 | 133 | }catch (Error e){warning (e.message);} | ||
2777 | 134 | } | ||
2778 | 135 | } | ||
2779 | 136 | |||
2780 | 137 | } | ||
2781 | 138 | 0 | ||
2782 | === removed file 'src/Widgets/LLabel.vala' | |||
2783 | --- src/Widgets/LLabel.vala 2012-08-21 14:56:49 +0000 | |||
2784 | +++ src/Widgets/LLabel.vala 1970-01-01 00:00:00 +0000 | |||
2785 | @@ -1,27 +0,0 @@ | |||
2786 | 1 | |||
2787 | 2 | namespace Audience.Widgets{ | ||
2788 | 3 | |||
2789 | 4 | class LLabel : Gtk.Label { | ||
2790 | 5 | public LLabel (string label) { | ||
2791 | 6 | this.set_halign (Gtk.Align.START); | ||
2792 | 7 | this.label = label; | ||
2793 | 8 | } | ||
2794 | 9 | public LLabel.indent (string label) { | ||
2795 | 10 | this (label); | ||
2796 | 11 | this.margin_left = 10; | ||
2797 | 12 | } | ||
2798 | 13 | public LLabel.markup (string label) { | ||
2799 | 14 | this (label); | ||
2800 | 15 | this.use_markup = true; | ||
2801 | 16 | } | ||
2802 | 17 | public LLabel.right (string label) { | ||
2803 | 18 | this.set_halign (Gtk.Align.END); | ||
2804 | 19 | this.label = label; | ||
2805 | 20 | } | ||
2806 | 21 | public LLabel.right_with_markup (string label) { | ||
2807 | 22 | this.set_halign (Gtk.Align.END); | ||
2808 | 23 | this.use_markup = true; | ||
2809 | 24 | this.label = label; | ||
2810 | 25 | } | ||
2811 | 26 | } | ||
2812 | 27 | } | ||
2813 | 28 | 0 | ||
2814 | === removed file 'src/Widgets/MediaSlider.vala' | |||
2815 | --- src/Widgets/MediaSlider.vala 2014-04-28 12:58:09 +0000 | |||
2816 | +++ src/Widgets/MediaSlider.vala 1970-01-01 00:00:00 +0000 | |||
2817 | @@ -1,238 +0,0 @@ | |||
2818 | 1 | |||
2819 | 2 | namespace Audience.Widgets{ | ||
2820 | 3 | |||
2821 | 4 | public class MediaSlider : Clutter.Group { | ||
2822 | 5 | |||
2823 | 6 | public signal void seeked (double new_progress); | ||
2824 | 7 | |||
2825 | 8 | public Clutter.Texture preview; | ||
2826 | 9 | public Clutter.Actor preview_bg; | ||
2827 | 10 | dynamic Gst.Element preview_playbin; | ||
2828 | 11 | dynamic Gst.Element sink; | ||
2829 | 12 | |||
2830 | 13 | double progress_stacked = 0.0; | ||
2831 | 14 | bool seeking = false; | ||
2832 | 15 | |||
2833 | 16 | private double _buffered; | ||
2834 | 17 | public double buffered{ | ||
2835 | 18 | get { return _buffered; } | ||
2836 | 19 | set { _buffered = value; this.bar.invalidate (); } | ||
2837 | 20 | } | ||
2838 | 21 | |||
2839 | 22 | private double _progress; | ||
2840 | 23 | public double progress{ | ||
2841 | 24 | get { return _progress; } | ||
2842 | 25 | set { _progress = value; this.bar.invalidate (); } | ||
2843 | 26 | } | ||
2844 | 27 | |||
2845 | 28 | private Clutter.CairoTexture bar; | ||
2846 | 29 | |||
2847 | 30 | private const int BAR_HEIGHT = 8; | ||
2848 | 31 | |||
2849 | 32 | /*the mouse is currently on the controls*/ | ||
2850 | 33 | public bool mouse_grabbed = false; | ||
2851 | 34 | |||
2852 | 35 | public MediaSlider () { | ||
2853 | 36 | this.preview = new Clutter.Texture (); | ||
2854 | 37 | this._buffered = 0.0; | ||
2855 | 38 | this._progress = 0.0; | ||
2856 | 39 | this.bar = new Clutter.CairoTexture (1, BAR_HEIGHT); | ||
2857 | 40 | |||
2858 | 41 | preview.filter_quality = Clutter.TextureQuality.HIGH; | ||
2859 | 42 | preview.scale_x = 0.0; | ||
2860 | 43 | preview.scale_y = 0.0; | ||
2861 | 44 | preview.scale_gravity = Clutter.Gravity.CENTER; | ||
2862 | 45 | preview.height = 90.0f; | ||
2863 | 46 | // preview.width is set in VideoPlayer.vala | ||
2864 | 47 | |||
2865 | 48 | // connect gstreamer stuff | ||
2866 | 49 | preview_playbin = Gst.ElementFactory.make ("playbin", "play"); | ||
2867 | 50 | preview_playbin.get_bus ().add_signal_watch (); | ||
2868 | 51 | preview_playbin.get_bus ().message.connect ((msg) => { | ||
2869 | 52 | switch (msg.type) { | ||
2870 | 53 | case Gst.MessageType.STATE_CHANGED: | ||
2871 | 54 | if (progress_stacked != 0) | ||
2872 | 55 | seek (progress_stacked); | ||
2873 | 56 | break; | ||
2874 | 57 | case Gst.MessageType.ASYNC_DONE: | ||
2875 | 58 | if (seeking) { | ||
2876 | 59 | seeking = false; | ||
2877 | 60 | if (progress_stacked != 0) | ||
2878 | 61 | seek (progress_stacked); | ||
2879 | 62 | } | ||
2880 | 63 | break; | ||
2881 | 64 | } | ||
2882 | 65 | }); | ||
2883 | 66 | sink = Audience.get_clutter_sink (); | ||
2884 | 67 | sink.texture = preview; | ||
2885 | 68 | preview_playbin.video_sink = sink; | ||
2886 | 69 | |||
2887 | 70 | preview_bg = new Clutter.Actor (); | ||
2888 | 71 | preview_bg.y = -120.0f; | ||
2889 | 72 | preview_bg.add_constraint (new Clutter.BindConstraint (preview, Clutter.BindCoordinate.WIDTH, 30.0f)); | ||
2890 | 73 | preview_bg.add_constraint (new Clutter.BindConstraint (preview, Clutter.BindCoordinate.HEIGHT, 45.0f)); | ||
2891 | 74 | preview_bg.opacity = 0; | ||
2892 | 75 | preview_bg.content = new Clutter.Canvas (); | ||
2893 | 76 | preview_bg.allocation_changed.connect (() => { | ||
2894 | 77 | (preview_bg.content as Clutter.Canvas).set_size ((int)preview_bg.width, (int)preview_bg.height); | ||
2895 | 78 | }); | ||
2896 | 79 | var ARROW_HEIGHT = 17; | ||
2897 | 80 | var ARROW_WIDTH = 20; | ||
2898 | 81 | var popover_grad = new Cairo.Pattern.linear (0, 0, 0, preview_bg.height); | ||
2899 | 82 | popover_grad.add_color_stop_rgba (0.0, 0.243, 0.243, 0.243, 0.7); | ||
2900 | 83 | popover_grad.add_color_stop_rgba (1.0, 0.094, 0.094, 0.094, 0.7); | ||
2901 | 84 | |||
2902 | 85 | var popover_inset_grad = new Cairo.Pattern.linear (0, 0, 0, preview_bg.height); | ||
2903 | 86 | popover_inset_grad.add_color_stop_rgba (0.0, 1, 1, 1, 0.3); | ||
2904 | 87 | popover_inset_grad.add_color_stop_rgba (1.0, 1, 1, 1, 0.1); | ||
2905 | 88 | (preview_bg.content as Clutter.Canvas).draw.connect ( (ctx) => { | ||
2906 | 89 | ctx.set_operator (Cairo.Operator.CLEAR); | ||
2907 | 90 | ctx.paint (); | ||
2908 | 91 | ctx.set_operator (Cairo.Operator.OVER); | ||
2909 | 92 | |||
2910 | 93 | // Outline | ||
2911 | 94 | Drawing.cairo_popover (ctx, 0, 0, preview_bg.width, | ||
2912 | 95 | preview_bg.height - ARROW_HEIGHT, 3, ARROW_WIDTH, ARROW_HEIGHT); | ||
2913 | 96 | ctx.set_source_rgba (0, 0, 0, 0.7); | ||
2914 | 97 | ctx.fill (); | ||
2915 | 98 | |||
2916 | 99 | // Inset border | ||
2917 | 100 | Drawing.cairo_popover (ctx, 1, 1, preview_bg.width - 2, | ||
2918 | 101 | preview_bg.height - 2 - ARROW_HEIGHT, 3, ARROW_WIDTH - 2, ARROW_HEIGHT - 2); | ||
2919 | 102 | ctx.set_source (popover_inset_grad); | ||
2920 | 103 | ctx.fill (); | ||
2921 | 104 | |||
2922 | 105 | ctx.set_operator(Cairo.Operator.SOURCE); | ||
2923 | 106 | // Fill | ||
2924 | 107 | Drawing.cairo_popover (ctx, 2, 2, preview_bg.width - 4, | ||
2925 | 108 | preview_bg.height - 4 - ARROW_HEIGHT, 3, ARROW_WIDTH - 4, ARROW_HEIGHT - 4); | ||
2926 | 109 | ctx.set_source (popover_grad); | ||
2927 | 110 | ctx.fill (); | ||
2928 | 111 | |||
2929 | 112 | ctx.set_operator(Cairo.Operator.OVER); | ||
2930 | 113 | return true; | ||
2931 | 114 | }); | ||
2932 | 115 | |||
2933 | 116 | this.bar.y = CONTROLS_HEIGHT / 2 - BAR_HEIGHT / 2; | ||
2934 | 117 | this.bar.auto_resize = true; | ||
2935 | 118 | var bar_grad = new Cairo.Pattern.linear (0, 0, 0, BAR_HEIGHT); | ||
2936 | 119 | bar_grad.add_color_stop_rgba (0.0, 0.254, 0.247, 0.231, 0.4); | ||
2937 | 120 | bar_grad.add_color_stop_rgba (1.0, 0.298, 0.290, 0.282, 0.4); | ||
2938 | 121 | var bar_shadow_grad = new Cairo.Pattern.linear (0, 0, 0, BAR_HEIGHT); | ||
2939 | 122 | bar_shadow_grad.add_color_stop_rgba (0.0, 1, 1, 1, 0); | ||
2940 | 123 | bar_shadow_grad.add_color_stop_rgba (1.0, 1, 1, 1, 0.2); | ||
2941 | 124 | this.bar.draw.connect ( (ctx) => { | ||
2942 | 125 | this.bar.clear(); | ||
2943 | 126 | //drop shadow | ||
2944 | 127 | Drawing.cairo_pill (ctx, 0, 0, this.bar.width, BAR_HEIGHT); | ||
2945 | 128 | ctx.set_source (bar_shadow_grad); | ||
2946 | 129 | ctx.fill (); | ||
2947 | 130 | //outline | ||
2948 | 131 | Drawing.cairo_pill (ctx, 1, 1, this.bar.width - 2, BAR_HEIGHT - 2); | ||
2949 | 132 | ctx.set_source_rgba (0, 0, 0, 0.4); | ||
2950 | 133 | ctx.fill (); | ||
2951 | 134 | //bg | ||
2952 | 135 | Drawing.cairo_pill (ctx, 2, 2, this.bar.width - 4, BAR_HEIGHT - 4); | ||
2953 | 136 | ctx.set_source (bar_grad); | ||
2954 | 137 | ctx.fill (); | ||
2955 | 138 | //buffering | ||
2956 | 139 | if (this._buffered != 0.0){ | ||
2957 | 140 | int64 duration; | ||
2958 | 141 | preview_playbin.query_duration (Gst.Format.TIME, out duration); | ||
2959 | 142 | Drawing.cairo_half_pill (ctx, 2, 2, | ||
2960 | 143 | (this._buffered / duration * this.bar.width) - 4, BAR_HEIGHT - 4, Gtk.PositionType.RIGHT); | ||
2961 | 144 | ctx.set_source_rgb (0.6, 0.6, 0.6); | ||
2962 | 145 | ctx.fill (); | ||
2963 | 146 | } | ||
2964 | 147 | //progress | ||
2965 | 148 | if (this._progress != 0.0){ | ||
2966 | 149 | Drawing.cairo_half_pill (ctx, 2, 2, (this._progress * this.width) - 4, BAR_HEIGHT - 4, Gtk.PositionType.RIGHT); | ||
2967 | 150 | ctx.set_source_rgb (1.0, 1.0, 1.0); | ||
2968 | 151 | ctx.fill (); | ||
2969 | 152 | } | ||
2970 | 153 | return true; | ||
2971 | 154 | }); | ||
2972 | 155 | |||
2973 | 156 | var scalex = new Clutter.BindConstraint (this, Clutter.BindCoordinate.WIDTH, 0); | ||
2974 | 157 | bar.add_constraint (scalex); | ||
2975 | 158 | |||
2976 | 159 | //seek | ||
2977 | 160 | preview.reactive = true; | ||
2978 | 161 | |||
2979 | 162 | reactive = true; | ||
2980 | 163 | add_child (bar); | ||
2981 | 164 | add_child (preview_bg); | ||
2982 | 165 | } | ||
2983 | 166 | |||
2984 | 167 | public override bool motion_event (Clutter.MotionEvent event) | ||
2985 | 168 | { | ||
2986 | 169 | float local_x, local_y; | ||
2987 | 170 | this.transform_stage_point (event.x, event.y, out local_x, out local_y); | ||
2988 | 171 | |||
2989 | 172 | preview.x = event.x - preview.width / 2; | ||
2990 | 173 | preview_bg.x = local_x - preview.width / 2 - 15.0f; | ||
2991 | 174 | |||
2992 | 175 | seek (float.max (local_x, 0.0000001f) / this.width); | ||
2993 | 176 | |||
2994 | 177 | return true; | ||
2995 | 178 | } | ||
2996 | 179 | |||
2997 | 180 | public override bool enter_event (Clutter.CrossingEvent event) | ||
2998 | 181 | { | ||
2999 | 182 | this.preview.animate (Clutter.AnimationMode.EASE_OUT_ELASTIC, 800, | ||
3000 | 183 | scale_x:1.0, scale_y:1.0); | ||
3001 | 184 | preview_bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 500, opacity:240); | ||
3002 | 185 | preview_toggle_playing (true); | ||
3003 | 186 | this.mouse_grabbed = true; | ||
3004 | 187 | return false; | ||
3005 | 188 | } | ||
3006 | 189 | |||
3007 | 190 | public override bool leave_event (Clutter.CrossingEvent event) | ||
3008 | 191 | { | ||
3009 | 192 | preview.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 150, | ||
3010 | 193 | scale_x:0.0, scale_y:0.0); | ||
3011 | 194 | preview_bg.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 150, opacity:0); | ||
3012 | 195 | preview_toggle_playing (false); | ||
3013 | 196 | mouse_grabbed = false; | ||
3014 | 197 | return false; | ||
3015 | 198 | } | ||
3016 | 199 | |||
3017 | 200 | public override bool button_release_event (Clutter.ButtonEvent event) | ||
3018 | 201 | { | ||
3019 | 202 | float x, y; | ||
3020 | 203 | this.transform_stage_point (event.x, event.y, out x, out y); | ||
3021 | 204 | this.seeked (x / this.width); | ||
3022 | 205 | return true; | ||
3023 | 206 | } | ||
3024 | 207 | |||
3025 | 208 | public void set_preview_uri (string uri) | ||
3026 | 209 | { | ||
3027 | 210 | preview_playbin.set_state (Gst.State.READY); | ||
3028 | 211 | preview_playbin.uri = uri; | ||
3029 | 212 | preview_playbin.volume = 0.0; | ||
3030 | 213 | } | ||
3031 | 214 | |||
3032 | 215 | void preview_toggle_playing (bool play) | ||
3033 | 216 | { | ||
3034 | 217 | this.preview_playbin.set_state (play ? Gst.State.PLAYING : Gst.State.PAUSED); | ||
3035 | 218 | } | ||
3036 | 219 | |||
3037 | 220 | void seek (double progress) | ||
3038 | 221 | { | ||
3039 | 222 | if (seeking) { | ||
3040 | 223 | progress_stacked = progress; | ||
3041 | 224 | return; | ||
3042 | 225 | } | ||
3043 | 226 | |||
3044 | 227 | int64 duration; | ||
3045 | 228 | preview_playbin.query_duration (Gst.Format.TIME, out duration); | ||
3046 | 229 | preview_playbin.seek (1.0, Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, | ||
3047 | 230 | Gst.SeekType.SET, (int64)(progress * duration), | ||
3048 | 231 | Gst.SeekType.NONE, (int64)Gst.CLOCK_TIME_NONE); | ||
3049 | 232 | |||
3050 | 233 | this.progress_stacked = 0; | ||
3051 | 234 | |||
3052 | 235 | seeking = true; | ||
3053 | 236 | } | ||
3054 | 237 | } | ||
3055 | 238 | } | ||
3056 | 239 | 0 | ||
3057 | === modified file 'src/Widgets/Playlist.vala' | |||
3058 | --- src/Widgets/Playlist.vala 2012-08-21 14:56:49 +0000 | |||
3059 | +++ src/Widgets/Playlist.vala 2014-07-06 11:18:29 +0000 | |||
3060 | @@ -1,93 +1,98 @@ | |||
3062 | 1 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | |
3063 | 2 | /*- | ||
3064 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
3065 | 4 | * | ||
3066 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3067 | 6 | * it under the terms of the GNU General Public License as published by | ||
3068 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
3069 | 8 | * (at your option) any later version. | ||
3070 | 9 | |||
3071 | 10 | * This program is distributed in the hope that it will be useful, | ||
3072 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3073 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3074 | 13 | * GNU General Public License for more details. | ||
3075 | 14 | |||
3076 | 15 | * You should have received a copy of the GNU General Public License | ||
3077 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3078 | 17 | * | ||
3079 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
3080 | 19 | */ | ||
3081 | 2 | 20 | ||
3082 | 3 | namespace Audience.Widgets { | 21 | namespace Audience.Widgets { |
3083 | 4 | |||
3084 | 5 | public class Playlist : Gtk.TreeView { | 22 | public class Playlist : Gtk.TreeView { |
3087 | 6 | 23 | // the player is requested to play path | |
3086 | 7 | /*the player is requested to play path*/ | ||
3088 | 8 | public signal void play (File path); | 24 | public signal void play (File path); |
3089 | 9 | 25 | ||
3092 | 10 | private int current; | 26 | private enum Columns { |
3093 | 11 | private Gtk.ListStore playlist; | 27 | PLAYING, |
3094 | 28 | TITLE, | ||
3095 | 29 | FILENAME, | ||
3096 | 30 | N_COLUMNS | ||
3097 | 31 | } | ||
3098 | 32 | |||
3099 | 33 | private int current = 0; | ||
3100 | 34 | private Gtk.ListStore playlist; | ||
3101 | 12 | 35 | ||
3102 | 13 | public Playlist () { | 36 | public Playlist () { |
3108 | 14 | this.current = 0; | 37 | this.playlist = new Gtk.ListStore (Columns.N_COLUMNS, typeof (Icon), typeof (string), typeof (string)); |
3104 | 15 | this.playlist = new Gtk.ListStore (4, typeof (Gdk.Pixbuf), /*playing*/ | ||
3105 | 16 | typeof (Gdk.Pixbuf), /*icon*/ | ||
3106 | 17 | typeof (string), /*title*/ | ||
3107 | 18 | typeof (string)); /*filename*/ | ||
3109 | 19 | this.model = this.playlist; | 38 | this.model = this.playlist; |
3110 | 20 | this.expand = true; | 39 | this.expand = true; |
3111 | 21 | this.headers_visible = false; | 40 | this.headers_visible = false; |
3112 | 41 | this.activate_on_single_click = true; | ||
3113 | 42 | this.can_focus = false; | ||
3114 | 43 | get_selection ().mode = Gtk.SelectionMode.NONE; | ||
3115 | 22 | 44 | ||
3116 | 23 | var text_render = new Gtk.CellRendererText (); | 45 | var text_render = new Gtk.CellRendererText (); |
3117 | 24 | text_render.ellipsize = Pango.EllipsizeMode.END; | 46 | text_render.ellipsize = Pango.EllipsizeMode.END; |
3118 | 25 | 47 | ||
3124 | 26 | this.insert_column_with_attributes (-1, "", new Gtk.CellRendererPixbuf (), | 48 | this.insert_column_with_attributes (-1, "Playing", new Gtk.CellRendererPixbuf (), "gicon", Columns.PLAYING); |
3125 | 27 | "pixbuf", 0); | 49 | this.insert_column_with_attributes (-1, "Title", text_render, "text", Columns.TITLE); |
3121 | 28 | this.insert_column_with_attributes (-1, "", new Gtk.CellRendererPixbuf (), | ||
3122 | 29 | "pixbuf", 1); | ||
3123 | 30 | this.insert_column_with_attributes (-1, "", text_render, "text", 2); | ||
3126 | 31 | 50 | ||
3128 | 32 | this.row_activated.connect ( (path ,col) => { | 51 | this.row_activated.connect ((path ,col) => { |
3129 | 33 | Gtk.TreeIter iter; | 52 | Gtk.TreeIter iter; |
3130 | 34 | playlist.get_iter (out iter, path); | 53 | playlist.get_iter (out iter, path); |
3131 | 35 | string filename; | 54 | string filename; |
3133 | 36 | playlist.get (iter, 3, out filename); | 55 | playlist.get (iter, Columns.FILENAME, out filename); |
3134 | 37 | play (File.new_for_commandline_arg (filename)); | 56 | play (File.new_for_commandline_arg (filename)); |
3135 | 38 | change_current_symbol (iter); | 57 | change_current_symbol (iter); |
3136 | 39 | this.current = int.parse (path.to_string ()); | 58 | this.current = int.parse (path.to_string ()); |
3137 | 40 | }); | 59 | }); |
3138 | 41 | 60 | ||
3139 | 42 | this.reorderable = true; | 61 | this.reorderable = true; |
3141 | 43 | this.model.row_inserted.connect ( (path, iter) => { | 62 | this.model.row_inserted.connect ((path, iter) => { |
3142 | 44 | Gtk.TreeIter it; | 63 | Gtk.TreeIter it; |
3143 | 45 | playlist.get_iter (out it, path); | 64 | playlist.get_iter (out it, path); |
3144 | 46 | Gdk.Pixbuf playing; | 65 | Gdk.Pixbuf playing; |
3146 | 47 | playlist.get (it, 0, out playing); | 66 | playlist.get (it, Columns.PLAYING, out playing); |
3147 | 48 | if (playing != null) //if playing is not null it's the current item | 67 | if (playing != null) //if playing is not null it's the current item |
3148 | 49 | this.current = int.parse (path.to_string ()); | 68 | this.current = int.parse (path.to_string ()); |
3149 | 50 | }); | 69 | }); |
3150 | 51 | |||
3151 | 52 | var css_fix = new Gtk.CssProvider (); | ||
3152 | 53 | try { | ||
3153 | 54 | css_fix.load_from_data (" | ||
3154 | 55 | * { | ||
3155 | 56 | background-image:none; | ||
3156 | 57 | background-color:@transparent; | ||
3157 | 58 | border-color:@transparent; | ||
3158 | 59 | }", -1); | ||
3159 | 60 | } catch (Error e) { warning (e.message); } | ||
3160 | 61 | this.get_style_context ().add_provider (css_fix, 20000); | ||
3161 | 62 | } | 70 | } |
3162 | 63 | 71 | ||
3163 | 64 | private inline void change_current_symbol (Gtk.TreeIter new_item) { | 72 | private inline void change_current_symbol (Gtk.TreeIter new_item) { |
3164 | 65 | try{ | ||
3165 | 66 | playlist.set (new_item, 0, Gtk.IconTheme.get_default (). | ||
3166 | 67 | load_icon ("media-playback-start-symbolic", 16, 0)); | ||
3167 | 68 | }catch (Error e) { warning (e.message); } | ||
3168 | 69 | Gtk.TreeIter old_item; | 73 | Gtk.TreeIter old_item; |
3169 | 70 | playlist.get_iter_from_string (out old_item, this.current.to_string ()); | 74 | playlist.get_iter_from_string (out old_item, this.current.to_string ()); |
3171 | 71 | playlist.set (old_item, 0, null); | 75 | playlist.set (old_item, Columns.PLAYING, null); |
3172 | 76 | playlist.set (new_item, Columns.PLAYING, new ThemedIcon ("media-playback-start-symbolic")); | ||
3173 | 72 | } | 77 | } |
3174 | 73 | 78 | ||
3175 | 74 | public void next () { | 79 | public void next () { |
3178 | 75 | Gtk.TreeIter it; | 80 | Gtk.TreeIter iter; |
3179 | 76 | if (playlist.get_iter_from_string (out it, (this.current + 1).to_string ())){ | 81 | if (playlist.get_iter_from_string (out iter, (this.current + 1).to_string ())){ |
3180 | 77 | string filename; | 82 | string filename; |
3183 | 78 | playlist.get (it, 3, out filename); | 83 | playlist.get (iter, Columns.FILENAME, out filename); |
3184 | 79 | change_current_symbol (it); | 84 | change_current_symbol (iter); |
3185 | 80 | current++; | 85 | current++; |
3186 | 81 | play (File.new_for_commandline_arg (filename)); | 86 | play (File.new_for_commandline_arg (filename)); |
3187 | 82 | } | 87 | } |
3188 | 83 | } | 88 | } |
3189 | 84 | 89 | ||
3190 | 85 | public void previous () { | 90 | public void previous () { |
3193 | 86 | Gtk.TreeIter it; | 91 | Gtk.TreeIter iter; |
3194 | 87 | if (playlist.get_iter_from_string (out it, (this.current - 1).to_string ())){ | 92 | if (playlist.get_iter_from_string (out iter, (this.current - 1).to_string ())){ |
3195 | 88 | string filename; | 93 | string filename; |
3198 | 89 | playlist.get (it, 3, out filename); | 94 | playlist.get (iter, Columns.FILENAME, out filename); |
3199 | 90 | change_current_symbol (it); | 95 | change_current_symbol (iter); |
3200 | 91 | current--; | 96 | current--; |
3201 | 92 | play (File.new_for_commandline_arg (filename)); | 97 | play (File.new_for_commandline_arg (filename)); |
3202 | 93 | } | 98 | } |
3203 | @@ -95,37 +100,67 @@ | |||
3204 | 95 | 100 | ||
3205 | 96 | public void add_item (File path) { | 101 | public void add_item (File path) { |
3206 | 97 | Gtk.TreeIter iter; | 102 | Gtk.TreeIter iter; |
3207 | 98 | Gdk.Pixbuf pix = null; //may becoming the thumb... | ||
3208 | 99 | 103 | ||
3210 | 100 | Gdk.Pixbuf? playing = null; | 104 | Icon? playing = null; |
3211 | 101 | Gtk.TreeIter dummy; | 105 | Gtk.TreeIter dummy; |
3217 | 102 | if (!playlist.get_iter_first (out dummy)){ //first item | 106 | if (!playlist.get_iter_first (out dummy)){ |
3218 | 103 | try { | 107 | playing = new ThemedIcon ("media-playback-start-symbolic"); |
3214 | 104 | playing = Gtk.IconTheme.get_default ().lookup_icon ("media-playback-start-symbolic", | ||
3215 | 105 | 16, 0).load_symbolic ({0, 0, 0, 255}, null, null, null); | ||
3216 | 106 | } catch (Error e) { warning (e.message); } | ||
3219 | 107 | } else { | 108 | } else { |
3220 | 108 | playing = null; | 109 | playing = null; |
3221 | 109 | } | 110 | } |
3222 | 110 | 111 | ||
3223 | 111 | playlist.append (out iter); | 112 | playlist.append (out iter); |
3226 | 112 | playlist.set (iter, 0, playing, 1, pix, | 113 | playlist.set (iter, Columns.PLAYING, playing, |
3227 | 113 | 2, Audience.get_title (path.get_basename ()), 3, path.get_path ()); | 114 | Columns.TITLE, Audience.get_title (path.get_basename ()), |
3228 | 115 | Columns.FILENAME, path.get_path ()); | ||
3229 | 114 | } | 116 | } |
3230 | 115 | 117 | ||
3231 | 116 | public void remove_item (File path) { | 118 | public void remove_item (File path) { |
3232 | 117 | /*not needed up to now*/ | 119 | /*not needed up to now*/ |
3233 | 118 | } | 120 | } |
3234 | 121 | |||
3235 | 119 | public File? get_first_item () { | 122 | public File? get_first_item () { |
3238 | 120 | Gtk.TreeIter it; | 123 | Gtk.TreeIter iter; |
3239 | 121 | if (playlist.get_iter_from_string (out it, 0.to_string ())){ | 124 | if (playlist.get_iter_first (out iter)){ |
3240 | 122 | string filename; | 125 | string filename; |
3242 | 123 | playlist.get (it, 3, out filename); | 126 | playlist.get (iter, Columns.FILENAME, out filename); |
3243 | 124 | return File.new_for_commandline_arg (filename); | 127 | return File.new_for_commandline_arg (filename); |
3244 | 125 | } | 128 | } |
3245 | 126 | return null; | 129 | return null; |
3246 | 127 | } | 130 | } |
3247 | 128 | 131 | ||
3248 | 132 | public List<string> get_all_items () { | ||
3249 | 133 | var list = new List<string> (); | ||
3250 | 134 | playlist.foreach ((model, path, iter) => { | ||
3251 | 135 | Value filename; | ||
3252 | 136 | playlist.get_value (iter, Columns.FILENAME, out filename); | ||
3253 | 137 | string name = filename.get_string (); | ||
3254 | 138 | list.append (name); | ||
3255 | 139 | return false; | ||
3256 | 140 | }); | ||
3257 | 141 | return list.copy (); | ||
3258 | 142 | } | ||
3259 | 143 | |||
3260 | 144 | public void save_playlist_config () { | ||
3261 | 145 | var list = new List<string> (); | ||
3262 | 146 | playlist.foreach ((model, path, iter) => { | ||
3263 | 147 | Value filename; | ||
3264 | 148 | playlist.get_value (iter, Columns.FILENAME, out filename); | ||
3265 | 149 | string name = filename.get_string (); | ||
3266 | 150 | list.append (name); | ||
3267 | 151 | return false; | ||
3268 | 152 | }); | ||
3269 | 153 | |||
3270 | 154 | uint i = 0; | ||
3271 | 155 | var videos = new string[list.length ()]; | ||
3272 | 156 | foreach (var filename in list) { | ||
3273 | 157 | videos[i] = filename; | ||
3274 | 158 | i++; | ||
3275 | 159 | } | ||
3276 | 160 | |||
3277 | 161 | settings.last_played_videos = videos; | ||
3278 | 162 | } | ||
3279 | 163 | |||
3280 | 129 | } | 164 | } |
3281 | 130 | 165 | ||
3283 | 131 | } | 166 | } |
3284 | 132 | \ No newline at end of file | 167 | \ No newline at end of file |
3285 | 133 | 168 | ||
3286 | === added file 'src/Widgets/PlaylistPopover.vala' | |||
3287 | --- src/Widgets/PlaylistPopover.vala 1970-01-01 00:00:00 +0000 | |||
3288 | +++ src/Widgets/PlaylistPopover.vala 2014-07-06 11:18:29 +0000 | |||
3289 | @@ -0,0 +1,116 @@ | |||
3290 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
3291 | 2 | /*- | ||
3292 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
3293 | 4 | * | ||
3294 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3295 | 6 | * it under the terms of the GNU General Public License as published by | ||
3296 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
3297 | 8 | * (at your option) any later version. | ||
3298 | 9 | |||
3299 | 10 | * This program is distributed in the hope that it will be useful, | ||
3300 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3301 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3302 | 13 | * GNU General Public License for more details. | ||
3303 | 14 | |||
3304 | 15 | * You should have received a copy of the GNU General Public License | ||
3305 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3306 | 17 | * | ||
3307 | 18 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
3308 | 19 | */ | ||
3309 | 20 | |||
3310 | 21 | public class Audience.Widgets.PlaylistPopover : Gtk.Popover { | ||
3311 | 22 | Gtk.ScrolledWindow playlist_scrolled; | ||
3312 | 23 | public PlaylistPopover () { | ||
3313 | 24 | opacity = GLOBAL_OPACITY; | ||
3314 | 25 | var grid = new Gtk.Grid (); | ||
3315 | 26 | grid.row_spacing = 6; | ||
3316 | 27 | grid.column_spacing = 12; | ||
3317 | 28 | grid.margin = 6; | ||
3318 | 29 | |||
3319 | 30 | var fil = new Gtk.Button.with_label (_("Add from Harddrive…")); | ||
3320 | 31 | fil.image = new Gtk.Image.from_icon_name ("document-open", Gtk.IconSize.DIALOG); | ||
3321 | 32 | var dvd = new Gtk.Button.with_label (_("Play a DVD…")); | ||
3322 | 33 | dvd.image = new Gtk.Image.from_icon_name ("media-cdrom", Gtk.IconSize.DIALOG); | ||
3323 | 34 | dvd.no_show_all = true; | ||
3324 | 35 | var net = new Gtk.Button.with_label (_("Network File…")); | ||
3325 | 36 | net.image = new Gtk.Image.from_icon_name ("internet-web-browser", Gtk.IconSize.DIALOG); | ||
3326 | 37 | |||
3327 | 38 | playlist_scrolled = new Gtk.ScrolledWindow (null, null); | ||
3328 | 39 | var app = ((Audience.App) GLib.Application.get_default ()); | ||
3329 | 40 | playlist_scrolled.add (app.playlist); | ||
3330 | 41 | |||
3331 | 42 | fil.clicked.connect ( () => { | ||
3332 | 43 | hide (); | ||
3333 | 44 | app.run_open_file (); | ||
3334 | 45 | }); | ||
3335 | 46 | |||
3336 | 47 | dvd.clicked.connect ( () => { | ||
3337 | 48 | hide (); | ||
3338 | 49 | app.run_open_dvd (); | ||
3339 | 50 | }); | ||
3340 | 51 | |||
3341 | 52 | net.clicked.connect ( () => { | ||
3342 | 53 | /*var entry = new Gtk.Entry (); | ||
3343 | 54 | entry.secondary_icon_stock = Gtk.Stock.OPEN; | ||
3344 | 55 | entry.icon_release.connect ( (pos, e) => { | ||
3345 | 56 | open_file (entry.text); | ||
3346 | 57 | video_player.playing = true; | ||
3347 | 58 | pop.destroy (); | ||
3348 | 59 | }); | ||
3349 | 60 | box.remove (net); | ||
3350 | 61 | box.reorder_child (entry, 2); | ||
3351 | 62 | entry.show ();*/ | ||
3352 | 63 | }); | ||
3353 | 64 | |||
3354 | 65 | grid.attach (playlist_scrolled, 0, 0, 2, 1); | ||
3355 | 66 | grid.attach (fil, 0, 1, 1, 1); | ||
3356 | 67 | grid.attach (dvd, 1, 1, 1, 1); | ||
3357 | 68 | |||
3358 | 69 | //look for dvd | ||
3359 | 70 | var disk_manager = DiskManager.get_default (); | ||
3360 | 71 | foreach (var volume in disk_manager.get_volumes ()) { | ||
3361 | 72 | dvd.no_show_all = false; | ||
3362 | 73 | dvd.show (); | ||
3363 | 74 | } | ||
3364 | 75 | |||
3365 | 76 | disk_manager.volume_found.connect ((vol) => { | ||
3366 | 77 | dvd.no_show_all = false; | ||
3367 | 78 | dvd.show (); | ||
3368 | 79 | }); | ||
3369 | 80 | |||
3370 | 81 | disk_manager.volume_removed.connect ((vol) => { | ||
3371 | 82 | if (disk_manager.get_volumes ().length () <= 0) { | ||
3372 | 83 | dvd.no_show_all = true; | ||
3373 | 84 | dvd.hide (); | ||
3374 | 85 | } | ||
3375 | 86 | }); | ||
3376 | 87 | |||
3377 | 88 | //grid.add (net); | ||
3378 | 89 | add (grid); | ||
3379 | 90 | } | ||
3380 | 91 | |||
3381 | 92 | //Override because the Popover doesn't auto-rejust his size. | ||
3382 | 93 | public override void get_preferred_height (out int minimum_height, out int natural_height) { | ||
3383 | 94 | base.get_preferred_height (out minimum_height, out natural_height); | ||
3384 | 95 | int p_minimum_height; | ||
3385 | 96 | int p_natural_height; | ||
3386 | 97 | var app = ((Audience.App) GLib.Application.get_default ()); | ||
3387 | 98 | app.playlist.get_preferred_height (out p_minimum_height, out p_natural_height); | ||
3388 | 99 | int temp_minimum_height = minimum_height + p_minimum_height; | ||
3389 | 100 | int r_minimum_height; | ||
3390 | 101 | int r_natural_height; | ||
3391 | 102 | relative_to.get_preferred_height (out r_minimum_height, out r_natural_height); | ||
3392 | 103 | if (temp_minimum_height < app.mainwindow.get_window ().get_height () - r_minimum_height*2) { | ||
3393 | 104 | minimum_height = temp_minimum_height; | ||
3394 | 105 | } else { | ||
3395 | 106 | minimum_height = app.mainwindow.get_window ().get_height () - r_minimum_height*2; | ||
3396 | 107 | } | ||
3397 | 108 | |||
3398 | 109 | int temp_natural_height = natural_height + p_natural_height; | ||
3399 | 110 | if (temp_natural_height < app.mainwindow.get_window ().get_height () - r_natural_height*2) { | ||
3400 | 111 | natural_height = temp_natural_height; | ||
3401 | 112 | } else { | ||
3402 | 113 | natural_height = minimum_height; | ||
3403 | 114 | } | ||
3404 | 115 | } | ||
3405 | 116 | } | ||
3406 | 0 | \ No newline at end of file | 117 | \ No newline at end of file |
3407 | 1 | 118 | ||
3408 | === added file 'src/Widgets/PreviewPopover.vala' | |||
3409 | --- src/Widgets/PreviewPopover.vala 1970-01-01 00:00:00 +0000 | |||
3410 | +++ src/Widgets/PreviewPopover.vala 2014-07-06 11:18:29 +0000 | |||
3411 | @@ -0,0 +1,90 @@ | |||
3412 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
3413 | 2 | /*- | ||
3414 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
3415 | 4 | * | ||
3416 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3417 | 6 | * it under the terms of the GNU General Public License as published by | ||
3418 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
3419 | 8 | * (at your option) any later version. | ||
3420 | 9 | |||
3421 | 10 | * This program is distributed in the hope that it will be useful, | ||
3422 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3423 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3424 | 13 | * GNU General Public License for more details. | ||
3425 | 14 | |||
3426 | 15 | * You should have received a copy of the GNU General Public License | ||
3427 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3428 | 17 | * | ||
3429 | 18 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
3430 | 19 | */ | ||
3431 | 20 | |||
3432 | 21 | public class Audience.Widgets.PreviewPopover : Gtk.Popover { | ||
3433 | 22 | public Clutter.Actor preview_actor; | ||
3434 | 23 | dynamic Gst.Element preview_playbin; | ||
3435 | 24 | Clutter.Texture video; | ||
3436 | 25 | double ratio = 0; | ||
3437 | 26 | public PreviewPopover () { | ||
3438 | 27 | opacity = GLOBAL_OPACITY; | ||
3439 | 28 | can_focus = false; | ||
3440 | 29 | sensitive = false; | ||
3441 | 30 | modal = false; | ||
3442 | 31 | |||
3443 | 32 | // connect gstreamer stuff | ||
3444 | 33 | preview_playbin = Gst.ElementFactory.make ("playbin", "play"); | ||
3445 | 34 | preview_playbin.get_bus ().add_signal_watch (); | ||
3446 | 35 | preview_playbin.get_bus ().message.connect ((msg) => { | ||
3447 | 36 | switch (msg.type) { | ||
3448 | 37 | case Gst.MessageType.STATE_CHANGED: | ||
3449 | 38 | break; | ||
3450 | 39 | case Gst.MessageType.ASYNC_DONE: | ||
3451 | 40 | break; | ||
3452 | 41 | } | ||
3453 | 42 | }); | ||
3454 | 43 | video = new Clutter.Texture (); | ||
3455 | 44 | |||
3456 | 45 | dynamic Gst.Element video_sink = Gst.ElementFactory.make ("cluttersink", "source"); | ||
3457 | 46 | video_sink.texture = video; | ||
3458 | 47 | preview_playbin.video_sink = video_sink; | ||
3459 | 48 | var clutter = new GtkClutter.Embed (); | ||
3460 | 49 | clutter.margin = 6; | ||
3461 | 50 | var stage = (Clutter.Stage)clutter.get_stage (); | ||
3462 | 51 | stage.background_color = {0, 0, 0, 0}; | ||
3463 | 52 | stage.use_alpha = true; | ||
3464 | 53 | |||
3465 | 54 | video.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.WIDTH, 0)); | ||
3466 | 55 | video.add_constraint (new Clutter.BindConstraint (stage, Clutter.BindCoordinate.HEIGHT, 0)); | ||
3467 | 56 | |||
3468 | 57 | stage.add_child (video); | ||
3469 | 58 | add (clutter); | ||
3470 | 59 | //show_all (); | ||
3471 | 60 | closed.connect (() => {preview_playbin.set_state (Gst.State.PAUSED);}); | ||
3472 | 61 | } | ||
3473 | 62 | |||
3474 | 63 | public void set_preview_uri (string uri) { | ||
3475 | 64 | preview_playbin.set_state (Gst.State.READY); | ||
3476 | 65 | preview_playbin.uri = uri; | ||
3477 | 66 | preview_playbin.volume = 0.0; | ||
3478 | 67 | |||
3479 | 68 | try { | ||
3480 | 69 | var info = new Gst.PbUtils.Discoverer (10 * Gst.SECOND).discover_uri (uri); | ||
3481 | 70 | var video = info.get_video_streams (); | ||
3482 | 71 | if (video.data != null) { | ||
3483 | 72 | var video_info = (Gst.PbUtils.DiscovererVideoInfo)video.data; | ||
3484 | 73 | uint video_width = video_info.get_width (); | ||
3485 | 74 | uint video_height = video_info.get_height (); | ||
3486 | 75 | ratio = ((double) video_height) / ((double) video_width); | ||
3487 | 76 | set_size_request (200, (int) (ratio*200)); | ||
3488 | 77 | } | ||
3489 | 78 | } catch (Error e) { | ||
3490 | 79 | warning (e.message); | ||
3491 | 80 | return; | ||
3492 | 81 | } | ||
3493 | 82 | } | ||
3494 | 83 | |||
3495 | 84 | public void set_preview_progress (double progress) { | ||
3496 | 85 | int64 length; | ||
3497 | 86 | preview_playbin.query_duration (Gst.Format.TIME, out length); | ||
3498 | 87 | preview_playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, (int64)(double.max (progress, 0.0) * length)); | ||
3499 | 88 | preview_playbin.set_state (Gst.State.PLAYING); | ||
3500 | 89 | } | ||
3501 | 90 | } | ||
3502 | 0 | \ No newline at end of file | 91 | \ No newline at end of file |
3503 | 1 | 92 | ||
3504 | === added file 'src/Widgets/SettingsPopover.vala' | |||
3505 | --- src/Widgets/SettingsPopover.vala 1970-01-01 00:00:00 +0000 | |||
3506 | +++ src/Widgets/SettingsPopover.vala 2014-07-06 11:18:29 +0000 | |||
3507 | @@ -0,0 +1,166 @@ | |||
3508 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
3509 | 2 | /*- | ||
3510 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
3511 | 4 | * | ||
3512 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3513 | 6 | * it under the terms of the GNU General Public License as published by | ||
3514 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
3515 | 8 | * (at your option) any later version. | ||
3516 | 9 | |||
3517 | 10 | * This program is distributed in the hope that it will be useful, | ||
3518 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3519 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3520 | 13 | * GNU General Public License for more details. | ||
3521 | 14 | |||
3522 | 15 | * You should have received a copy of the GNU General Public License | ||
3523 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3524 | 17 | * | ||
3525 | 18 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
3526 | 19 | */ | ||
3527 | 20 | |||
3528 | 21 | public class Audience.Widgets.SettingsPopover : Gtk.Popover { | ||
3529 | 22 | private Gtk.ComboBoxText languages; | ||
3530 | 23 | private Gtk.ComboBoxText subtitles; | ||
3531 | 24 | private Gtk.FileChooserButton external_subtitle_file; | ||
3532 | 25 | |||
3533 | 26 | public SettingsPopover () { | ||
3534 | 27 | opacity = GLOBAL_OPACITY; | ||
3535 | 28 | |||
3536 | 29 | languages = new Gtk.ComboBoxText (); | ||
3537 | 30 | subtitles = new Gtk.ComboBoxText (); | ||
3538 | 31 | external_subtitle_file = new Gtk.FileChooserButton (_("External Subtitles"), Gtk.FileChooserAction.OPEN); | ||
3539 | 32 | |||
3540 | 33 | var lang_label = new Gtk.Label (_("Audio:")); | ||
3541 | 34 | lang_label.halign = Gtk.Align.END; | ||
3542 | 35 | |||
3543 | 36 | var sub_label = new Gtk.Label (_("Subtitles:")); | ||
3544 | 37 | sub_label.halign = Gtk.Align.END; | ||
3545 | 38 | |||
3546 | 39 | var sub_ext_label = new Gtk.Label (_("External Subtitles:")); | ||
3547 | 40 | sub_ext_label.halign = Gtk.Align.END; | ||
3548 | 41 | |||
3549 | 42 | var setupgrid = new Gtk.Grid (); | ||
3550 | 43 | setupgrid.row_spacing = 6; | ||
3551 | 44 | setupgrid.margin = 6; | ||
3552 | 45 | setupgrid.attach (lang_label, 0, 1, 1, 1); | ||
3553 | 46 | setupgrid.attach (languages, 1, 1, 1, 1); | ||
3554 | 47 | setupgrid.attach (sub_label, 0, 2, 1, 1); | ||
3555 | 48 | setupgrid.attach (subtitles, 1, 2, 1, 1); | ||
3556 | 49 | setupgrid.attach (sub_ext_label, 0, 3, 1, 1); | ||
3557 | 50 | setupgrid.attach (external_subtitle_file, 1, 3, 1, 1); | ||
3558 | 51 | setupgrid.column_homogeneous = true; | ||
3559 | 52 | setupgrid.column_spacing = 12; | ||
3560 | 53 | |||
3561 | 54 | external_subtitle_file.file_set.connect (() => { | ||
3562 | 55 | VideoPlayer.get_default ().set_subtitle_uri (external_subtitle_file.get_uri ()); | ||
3563 | 56 | }); | ||
3564 | 57 | |||
3565 | 58 | VideoPlayer.get_default ().external_subtitle_changed.connect ((uri) => { | ||
3566 | 59 | external_subtitle_file.select_uri (uri); | ||
3567 | 60 | }); | ||
3568 | 61 | |||
3569 | 62 | subtitles.changed.connect (() => { | ||
3570 | 63 | if (subtitles.active_id == null) | ||
3571 | 64 | return; | ||
3572 | 65 | |||
3573 | 66 | var id = int.parse (subtitles.active_id); | ||
3574 | 67 | VideoPlayer.get_default ().current_text = id; | ||
3575 | 68 | }); | ||
3576 | 69 | |||
3577 | 70 | languages.changed.connect ( () => { //place it here to not get problems | ||
3578 | 71 | if (languages.active_id == null) | ||
3579 | 72 | return; | ||
3580 | 73 | |||
3581 | 74 | VideoPlayer.get_default ().current_audio = int.parse (languages.active_id); | ||
3582 | 75 | }); | ||
3583 | 76 | |||
3584 | 77 | add (setupgrid); | ||
3585 | 78 | } | ||
3586 | 79 | |||
3587 | 80 | public void setup_text () { | ||
3588 | 81 | subtitles.sensitive = false; | ||
3589 | 82 | if (subtitles.model.iter_n_children (null) > 0) | ||
3590 | 83 | subtitles.remove_all (); | ||
3591 | 84 | |||
3592 | 85 | int n_text; | ||
3593 | 86 | VideoPlayer.get_default ().playbin.get ("n-text", out n_text); | ||
3594 | 87 | for (var i=0; i<n_text; i++) { | ||
3595 | 88 | Gst.TagList tags = null; | ||
3596 | 89 | Signal.emit_by_name (VideoPlayer.get_default ().playbin, "get-text-tags", i, out tags); | ||
3597 | 90 | if (tags == null) | ||
3598 | 91 | continue; | ||
3599 | 92 | |||
3600 | 93 | string desc; | ||
3601 | 94 | string readable = null; | ||
3602 | 95 | tags.get_string (Gst.Tags.LANGUAGE_CODE, out desc); | ||
3603 | 96 | if (desc == null) | ||
3604 | 97 | tags.get_string (Gst.Tags.CODEC, out desc); | ||
3605 | 98 | |||
3606 | 99 | if (desc != null) { | ||
3607 | 100 | readable = Gst.Tag.get_language_name (desc); | ||
3608 | 101 | var language = Gst.Tag.get_language_name (desc); | ||
3609 | 102 | subtitles.append (i.to_string (), language == null ? desc : language); | ||
3610 | 103 | subtitles.sensitive = true; | ||
3611 | 104 | } | ||
3612 | 105 | } | ||
3613 | 106 | |||
3614 | 107 | subtitles.append ("-1", _("None")); | ||
3615 | 108 | subtitles.active_id = VideoPlayer.get_default ().current_text.to_string (); | ||
3616 | 109 | } | ||
3617 | 110 | |||
3618 | 111 | public void setup_audio () { | ||
3619 | 112 | languages.sensitive = false; | ||
3620 | 113 | if (languages.model.iter_n_children (null) > 0) | ||
3621 | 114 | languages.remove_all (); | ||
3622 | 115 | |||
3623 | 116 | int n_audio; | ||
3624 | 117 | VideoPlayer.get_default ().playbin.get ("n-audio", out n_audio); | ||
3625 | 118 | for (var i=0; i<n_audio; i++) { | ||
3626 | 119 | Gst.TagList tags = null; | ||
3627 | 120 | Signal.emit_by_name (VideoPlayer.get_default ().playbin, "get-audio-tags", i, out tags); | ||
3628 | 121 | if (tags == null) | ||
3629 | 122 | continue; | ||
3630 | 123 | |||
3631 | 124 | string desc; | ||
3632 | 125 | string readable = null; | ||
3633 | 126 | tags.get_string (Gst.Tags.LANGUAGE_CODE, out desc); | ||
3634 | 127 | if (desc == null) | ||
3635 | 128 | tags.get_string (Gst.Tags.CODEC, out desc); | ||
3636 | 129 | |||
3637 | 130 | if (desc != null) { | ||
3638 | 131 | readable = Gst.Tag.get_language_name (desc); | ||
3639 | 132 | languages.append (i.to_string (), readable == null ? desc : readable); | ||
3640 | 133 | languages.sensitive = true; | ||
3641 | 134 | } | ||
3642 | 135 | } | ||
3643 | 136 | |||
3644 | 137 | if (languages.model.iter_n_children (null) <= 0) { | ||
3645 | 138 | languages.append ("def", _("Default")); | ||
3646 | 139 | languages.active = 0; | ||
3647 | 140 | } else { | ||
3648 | 141 | languages.active_id = VideoPlayer.get_default ().current_audio.to_string (); | ||
3649 | 142 | } | ||
3650 | 143 | } | ||
3651 | 144 | |||
3652 | 145 | public void next_audio () { | ||
3653 | 146 | int current = int.parse (languages.active_id); | ||
3654 | 147 | if (current < languages.model.iter_n_children (null) - 1) { | ||
3655 | 148 | current++; | ||
3656 | 149 | } else { | ||
3657 | 150 | current = 0; | ||
3658 | 151 | } | ||
3659 | 152 | |||
3660 | 153 | languages.active_id = current.to_string (); | ||
3661 | 154 | } | ||
3662 | 155 | |||
3663 | 156 | public void next_text () { | ||
3664 | 157 | int current = int.parse (subtitles.active_id); | ||
3665 | 158 | if (current < subtitles.model.iter_n_children (null)) { | ||
3666 | 159 | current++; | ||
3667 | 160 | } else { | ||
3668 | 161 | current = 0; | ||
3669 | 162 | } | ||
3670 | 163 | |||
3671 | 164 | subtitles.active_id = current.to_string (); | ||
3672 | 165 | } | ||
3673 | 166 | } | ||
3674 | 0 | \ No newline at end of file | 167 | \ No newline at end of file |
3675 | 1 | 168 | ||
3676 | === removed file 'src/Widgets/TagView.vala' | |||
3677 | --- src/Widgets/TagView.vala 2014-05-15 07:10:20 +0000 | |||
3678 | +++ src/Widgets/TagView.vala 1970-01-01 00:00:00 +0000 | |||
3679 | @@ -1,253 +0,0 @@ | |||
3680 | 1 | |||
3681 | 2 | /* | ||
3682 | 3 | The panel on the right hand side | ||
3683 | 4 | */ | ||
3684 | 5 | |||
3685 | 6 | public const string LIGHT_WINDOW_STYLE = """ | ||
3686 | 7 | .content-view-window { | ||
3687 | 8 | background-image:none; | ||
3688 | 9 | background-color:@bg_color; | ||
3689 | 10 | |||
3690 | 11 | border-radius: 6px; | ||
3691 | 12 | |||
3692 | 13 | border-width:1px; | ||
3693 | 14 | border-style: solid; | ||
3694 | 15 | border-color: alpha (#000, 0.25); | ||
3695 | 16 | } | ||
3696 | 17 | """; | ||
3697 | 18 | |||
3698 | 19 | namespace Audience.Widgets | ||
3699 | 20 | { | ||
3700 | 21 | public class TagView : GtkClutter.Actor | ||
3701 | 22 | { | ||
3702 | 23 | public bool expanded; | ||
3703 | 24 | public Gtk.Grid taggrid; | ||
3704 | 25 | public Audience.App app; | ||
3705 | 26 | |||
3706 | 27 | public Gtk.ComboBoxText languages; | ||
3707 | 28 | public Gtk.ComboBoxText subtitles; | ||
3708 | 29 | private Gtk.FileChooserButton external_subtitle_file; | ||
3709 | 30 | |||
3710 | 31 | private Granite.Drawing.BufferSurface buffer; | ||
3711 | 32 | int shadow_blur = 30; | ||
3712 | 33 | int shadow_x = 0; | ||
3713 | 34 | int shadow_y = 0; | ||
3714 | 35 | double shadow_alpha = 0.5; | ||
3715 | 36 | |||
3716 | 37 | bool currently_parsing = false; | ||
3717 | 38 | |||
3718 | 39 | public signal void select_external_subtitle (string uri); | ||
3719 | 40 | |||
3720 | 41 | public TagView (Audience.App app) { | ||
3721 | 42 | this.app = app; | ||
3722 | 43 | this.reactive = true; | ||
3723 | 44 | this.buffer = new Granite.Drawing.BufferSurface (100, 100); | ||
3724 | 45 | |||
3725 | 46 | var notebook = new Granite.Widgets.StaticNotebook (false); | ||
3726 | 47 | |||
3727 | 48 | /*tags*/ | ||
3728 | 49 | var tagview = new Gtk.ScrolledWindow (null, null); | ||
3729 | 50 | taggrid = new Gtk.Grid (); | ||
3730 | 51 | taggrid.column_spacing = 10; | ||
3731 | 52 | taggrid.margin = 12; | ||
3732 | 53 | tagview.add_with_viewport (taggrid); | ||
3733 | 54 | |||
3734 | 55 | /*setup*/ | ||
3735 | 56 | var setupgrid = new Gtk.Grid (); | ||
3736 | 57 | this.languages = new Gtk.ComboBoxText (); | ||
3737 | 58 | this.subtitles = new Gtk.ComboBoxText (); | ||
3738 | 59 | this.external_subtitle_file = new Gtk.FileChooserButton (_("External Subtitles"), Gtk.FileChooserAction.OPEN); | ||
3739 | 60 | var lang_lbl = new LLabel.right (_("Audio")+":"); | ||
3740 | 61 | var sub_lbl = new LLabel.right (_("Subtitles")+":"); | ||
3741 | 62 | var sub_ext_lbl = new LLabel.right (_("External Subtitles") + ":"); | ||
3742 | 63 | setupgrid.attach (lang_lbl, 0, 1, 1, 1); | ||
3743 | 64 | setupgrid.attach (languages, 1, 1, 1, 1); | ||
3744 | 65 | setupgrid.attach (sub_lbl, 0, 2, 1, 1); | ||
3745 | 66 | setupgrid.attach (subtitles, 1, 2, 1, 1); | ||
3746 | 67 | setupgrid.attach (sub_ext_lbl, 0, 3, 1, 1); | ||
3747 | 68 | setupgrid.attach (this.external_subtitle_file, 1, 3, 1, 1); | ||
3748 | 69 | setupgrid.column_homogeneous = true; | ||
3749 | 70 | setupgrid.margin = 12; | ||
3750 | 71 | setupgrid.column_spacing = 12; | ||
3751 | 72 | |||
3752 | 73 | external_subtitle_file.file_set.connect (() => { | ||
3753 | 74 | select_external_subtitle (external_subtitle_file.get_uri ()); | ||
3754 | 75 | }); | ||
3755 | 76 | app.video_player.external_subtitle_changed.connect ( (uri) => { | ||
3756 | 77 | external_subtitle_file.set_uri (uri); | ||
3757 | 78 | }); | ||
3758 | 79 | this.subtitles.changed.connect ( () => { | ||
3759 | 80 | if (subtitles.active_id == null || currently_parsing) | ||
3760 | 81 | return; | ||
3761 | 82 | var id = int.parse (this.subtitles.active_id); | ||
3762 | 83 | app.video_player.current_text = id; | ||
3763 | 84 | }); | ||
3764 | 85 | |||
3765 | 86 | languages.changed.connect ( () => { //place it here to not get problems | ||
3766 | 87 | if (languages.active_id == null || currently_parsing) | ||
3767 | 88 | return; | ||
3768 | 89 | app.video_player.current_audio = int.parse (this.languages.active_id); | ||
3769 | 90 | }); | ||
3770 | 91 | |||
3771 | 92 | var playlist_scrolled = new Gtk.ScrolledWindow (null, null); | ||
3772 | 93 | playlist_scrolled.add (this.app.playlist); | ||
3773 | 94 | |||
3774 | 95 | notebook.append_page (playlist_scrolled, new Gtk.Label (_("Playlist"))); | ||
3775 | 96 | notebook.append_page (setupgrid, new Gtk.Label (_("Options"))); | ||
3776 | 97 | |||
3777 | 98 | /*draw the window stylish!*/ | ||
3778 | 99 | var css = new Gtk.CssProvider (); | ||
3779 | 100 | try { | ||
3780 | 101 | css.load_from_data (LIGHT_WINDOW_STYLE, -1); | ||
3781 | 102 | } catch (Error e) { warning (e.message); } | ||
3782 | 103 | |||
3783 | 104 | var draw_ref = new Gtk.Window (); | ||
3784 | 105 | draw_ref.get_style_context ().add_class ("content-view-window"); | ||
3785 | 106 | draw_ref.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK); | ||
3786 | 107 | |||
3787 | 108 | var w = -1; var h = -1; | ||
3788 | 109 | this.get_widget ().size_allocate.connect ( () => { | ||
3789 | 110 | if (w == this.get_widget ().get_allocated_width () && | ||
3790 | 111 | h == this.get_widget ().get_allocated_height ()) | ||
3791 | 112 | return; | ||
3792 | 113 | w = this.get_widget ().get_allocated_width (); | ||
3793 | 114 | h = this.get_widget ().get_allocated_height (); | ||
3794 | 115 | |||
3795 | 116 | this.buffer = new Granite.Drawing.BufferSurface (w, h); | ||
3796 | 117 | |||
3797 | 118 | this.buffer.context.rectangle (shadow_blur + shadow_x, | ||
3798 | 119 | shadow_blur + shadow_y, w - shadow_blur*2 + shadow_x, h - shadow_blur*2 + shadow_y); | ||
3799 | 120 | this.buffer.context.set_source_rgba (0, 0, 0, shadow_alpha); | ||
3800 | 121 | this.buffer.context.fill (); | ||
3801 | 122 | this.buffer.exponential_blur (shadow_blur / 2); | ||
3802 | 123 | |||
3803 | 124 | draw_ref.get_style_context ().render_activity (this.buffer.context, | ||
3804 | 125 | shadow_blur + shadow_x, shadow_blur + shadow_y, | ||
3805 | 126 | w - shadow_blur*2 + shadow_x, h - shadow_blur*2 + shadow_y); | ||
3806 | 127 | }); | ||
3807 | 128 | this.get_widget ().draw.connect ( (ctx) => { | ||
3808 | 129 | ctx.set_operator (Cairo.Operator.SOURCE); | ||
3809 | 130 | ctx.rectangle (0, 0, this.width, this.height); | ||
3810 | 131 | ctx.set_source_rgba (0.0, 0.0, 0.0, 0.0); | ||
3811 | 132 | ctx.fill (); | ||
3812 | 133 | |||
3813 | 134 | ctx.set_source_surface (this.buffer.surface, 0, 0); | ||
3814 | 135 | ctx.paint (); | ||
3815 | 136 | |||
3816 | 137 | return false; | ||
3817 | 138 | }); | ||
3818 | 139 | |||
3819 | 140 | var no_bg = new Gtk.CssProvider (); | ||
3820 | 141 | try { | ||
3821 | 142 | no_bg.load_from_data (""" | ||
3822 | 143 | * { | ||
3823 | 144 | background-color: alpha(#fff, 0); | ||
3824 | 145 | } | ||
3825 | 146 | .view:selected:focused { | ||
3826 | 147 | color: @selected_bg_color; | ||
3827 | 148 | } | ||
3828 | 149 | """, -1); | ||
3829 | 150 | } catch (Error e) { warning (e.message); } | ||
3830 | 151 | setupgrid.get_parent ().get_style_context ().add_provider (no_bg, 20000); | ||
3831 | 152 | app.playlist.get_style_context ().add_provider (no_bg, 20000); | ||
3832 | 153 | |||
3833 | 154 | playlist_scrolled.margin = 3; | ||
3834 | 155 | notebook.margin = shadow_blur + 2; | ||
3835 | 156 | notebook.margin_top += 3; | ||
3836 | 157 | this.get_widget ().get_style_context ().add_class ("content-view"); | ||
3837 | 158 | ((Gtk.Bin)this.get_widget ()).add (notebook); | ||
3838 | 159 | this.get_widget ().show_all (); | ||
3839 | 160 | this.width = 350; | ||
3840 | 161 | this.opacity = 0; | ||
3841 | 162 | this.expanded = false; | ||
3842 | 163 | } | ||
3843 | 164 | |||
3844 | 165 | public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) { | ||
3845 | 166 | //have a minimum height in order to not get the negative allocation warnings | ||
3846 | 167 | if (box.y2 - box.y1 < 100) { | ||
3847 | 168 | box.y2 = box.y1 + 100; | ||
3848 | 169 | } | ||
3849 | 170 | base.allocate (box, flags); | ||
3850 | 171 | } | ||
3851 | 172 | |||
3852 | 173 | public void expand (){ | ||
3853 | 174 | //make sure it comes from right bounds | ||
3854 | 175 | x = get_stage ().width + 100; | ||
3855 | 176 | |||
3856 | 177 | var x2 = this.get_stage ().width - this.width + 10; | ||
3857 | 178 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, x:x2); | ||
3858 | 179 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:255); | ||
3859 | 180 | this.expanded = true; | ||
3860 | 181 | } | ||
3861 | 182 | |||
3862 | 183 | public void collapse (){ | ||
3863 | 184 | var x2 = this.get_stage ().width; | ||
3864 | 185 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, x:x2); | ||
3865 | 186 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:0); | ||
3866 | 187 | this.expanded = false; | ||
3867 | 188 | } | ||
3868 | 189 | |||
3869 | 190 | public void setup_text_setup () { setup_setup ("text"); } | ||
3870 | 191 | public void setup_audio_setup () { setup_setup ("audio"); } | ||
3871 | 192 | /*target is either "text" or "audio"*/ | ||
3872 | 193 | public void setup_setup (string target) { | ||
3873 | 194 | currently_parsing = true; | ||
3874 | 195 | |||
3875 | 196 | if (target == "audio" && languages.model.iter_n_children (null) > 0) | ||
3876 | 197 | languages.remove_all (); | ||
3877 | 198 | else if (target == "text" && subtitles.model.iter_n_children (null) > 0) | ||
3878 | 199 | subtitles.remove_all (); | ||
3879 | 200 | |||
3880 | 201 | Value num = 0; | ||
3881 | 202 | app.video_player.playbin.get_property ("n-"+target, ref num); | ||
3882 | 203 | |||
3883 | 204 | int used = 0; | ||
3884 | 205 | for (var i=0;i<num.get_int ();i++) { | ||
3885 | 206 | Gst.TagList tags = null; | ||
3886 | 207 | Signal.emit_by_name (app.video_player.playbin, "get-"+target+"-tags", i, out tags); | ||
3887 | 208 | if (tags == null) | ||
3888 | 209 | continue; | ||
3889 | 210 | |||
3890 | 211 | string desc; | ||
3891 | 212 | string readable = null; | ||
3892 | 213 | tags.get_string (Gst.Tags.LANGUAGE_CODE, out desc); | ||
3893 | 214 | if (desc == null) | ||
3894 | 215 | tags.get_string (Gst.Tags.CODEC, out desc); | ||
3895 | 216 | |||
3896 | 217 | if (desc != null) | ||
3897 | 218 | readable = Gst.Tag.get_language_name (desc); | ||
3898 | 219 | |||
3899 | 220 | if (target == "audio" && desc != null) { | ||
3900 | 221 | this.languages.append (i.to_string (), readable == null ? desc : readable); | ||
3901 | 222 | used ++; | ||
3902 | 223 | } else if (desc != null) { | ||
3903 | 224 | var language = Gst.Tag.get_language_name (desc); | ||
3904 | 225 | this.subtitles.append (i.to_string (), language == null ? desc : language); | ||
3905 | 226 | used ++; | ||
3906 | 227 | } | ||
3907 | 228 | } | ||
3908 | 229 | |||
3909 | 230 | if (target == "audio") { | ||
3910 | 231 | |||
3911 | 232 | if (used == 0) { | ||
3912 | 233 | languages.append ("def", _("Default")); | ||
3913 | 234 | languages.active = 0; | ||
3914 | 235 | languages.sensitive = false; | ||
3915 | 236 | } else { | ||
3916 | 237 | languages.sensitive = true; | ||
3917 | 238 | languages.active_id = app.video_player.current_audio.to_string (); | ||
3918 | 239 | } | ||
3919 | 240 | } else { | ||
3920 | 241 | if (used == 0) | ||
3921 | 242 | subtitles.sensitive = false; | ||
3922 | 243 | else | ||
3923 | 244 | subtitles.sensitive = true; | ||
3924 | 245 | |||
3925 | 246 | subtitles.append ("-1", _("None")); | ||
3926 | 247 | subtitles.active_id = app.video_player.current_text.to_string (); | ||
3927 | 248 | } | ||
3928 | 249 | |||
3929 | 250 | currently_parsing = false; | ||
3930 | 251 | } | ||
3931 | 252 | } | ||
3932 | 253 | } | ||
3933 | 254 | 0 | ||
3934 | === added file 'src/Widgets/TimeWidget.vala' | |||
3935 | --- src/Widgets/TimeWidget.vala 1970-01-01 00:00:00 +0000 | |||
3936 | +++ src/Widgets/TimeWidget.vala 2014-07-06 11:18:29 +0000 | |||
3937 | @@ -0,0 +1,127 @@ | |||
3938 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
3939 | 2 | /*- | ||
3940 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
3941 | 4 | * | ||
3942 | 5 | * This program is free software: you can redistribute it and/or modify | ||
3943 | 6 | * it under the terms of the GNU General Public License as published by | ||
3944 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
3945 | 8 | * (at your option) any later version. | ||
3946 | 9 | |||
3947 | 10 | * This program is distributed in the hope that it will be useful, | ||
3948 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3949 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3950 | 13 | * GNU General Public License for more details. | ||
3951 | 14 | |||
3952 | 15 | * You should have received a copy of the GNU General Public License | ||
3953 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3954 | 17 | * | ||
3955 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
3956 | 19 | * Corentin Noël <corentin@elementaryos.org> | ||
3957 | 20 | */ | ||
3958 | 21 | |||
3959 | 22 | public class Audience.Widgets.TimeWidget : Gtk.Grid { | ||
3960 | 23 | public signal void slider_motion_event (Gdk.EventMotion event); | ||
3961 | 24 | |||
3962 | 25 | public Gtk.Label progression_label; | ||
3963 | 26 | public Gtk.Label time_label; | ||
3964 | 27 | public Gtk.Scale scale; | ||
3965 | 28 | public signal void seeked (double val); | ||
3966 | 29 | private Audience.Widgets.PreviewPopover preview_popover; | ||
3967 | 30 | private bool is_seeking = false; | ||
3968 | 31 | private bool released = true; | ||
3969 | 32 | private uint timeout_id = 0; | ||
3970 | 33 | private int original = 0; | ||
3971 | 34 | |||
3972 | 35 | public TimeWidget () { | ||
3973 | 36 | orientation = Gtk.Orientation.HORIZONTAL; | ||
3974 | 37 | column_spacing = 12; | ||
3975 | 38 | halign = Gtk.Align.CENTER; | ||
3976 | 39 | progression_label = new Gtk.Label (""); | ||
3977 | 40 | time_label = new Gtk.Label (""); | ||
3978 | 41 | |||
3979 | 42 | scale = new Gtk.Scale.with_range (Gtk.Orientation.HORIZONTAL, 0, 1, 0.1); | ||
3980 | 43 | scale.expand = true; | ||
3981 | 44 | scale.draw_value = false; | ||
3982 | 45 | scale.can_focus = false; | ||
3983 | 46 | scale.events |= Gdk.EventMask.POINTER_MOTION_MASK; | ||
3984 | 47 | scale.events |= Gdk.EventMask.LEAVE_NOTIFY_MASK; | ||
3985 | 48 | scale.events |= Gdk.EventMask.ENTER_NOTIFY_MASK; | ||
3986 | 49 | scale.button_press_event.connect ((event) => { | ||
3987 | 50 | is_seeking = true; | ||
3988 | 51 | released = false; | ||
3989 | 52 | |||
3990 | 53 | if (timeout_id != 0) | ||
3991 | 54 | Source.remove (timeout_id); | ||
3992 | 55 | |||
3993 | 56 | timeout_id = Timeout.add (300, () => { | ||
3994 | 57 | if (released == false) | ||
3995 | 58 | return true; | ||
3996 | 59 | seeked (scale.get_value ()); | ||
3997 | 60 | is_seeking = false; | ||
3998 | 61 | |||
3999 | 62 | timeout_id = 0; | ||
4000 | 63 | |||
4001 | 64 | return false; | ||
4002 | 65 | }); | ||
4003 | 66 | |||
4004 | 67 | return false; | ||
4005 | 68 | }); | ||
4006 | 69 | |||
4007 | 70 | scale.enter_notify_event.connect ((event) => { | ||
4008 | 71 | preview_popover.show_all (); | ||
4009 | 72 | return false; | ||
4010 | 73 | }); | ||
4011 | 74 | |||
4012 | 75 | scale.leave_notify_event.connect ((event) => { | ||
4013 | 76 | preview_popover.hide (); | ||
4014 | 77 | return false; | ||
4015 | 78 | }); | ||
4016 | 79 | |||
4017 | 80 | // XXX: Store the original size because the popover doesn't update his x=0 position when resizing. | ||
4018 | 81 | scale.motion_notify_event.connect ((event) => { | ||
4019 | 82 | if (original == 0) | ||
4020 | 83 | original = event.window.get_width (); | ||
4021 | 84 | |||
4022 | 85 | var pointing = preview_popover.pointing_to; | ||
4023 | 86 | var distance = original - event.window.get_width (); | ||
4024 | 87 | pointing.x = (int)(event.x) - event.window.get_width ()/2 - distance/2; | ||
4025 | 88 | preview_popover.set_pointing_to ((Gdk.Rectangle)pointing); | ||
4026 | 89 | preview_popover.set_preview_progress (((double)event.x)/((double)event.window.get_width ())); | ||
4027 | 90 | |||
4028 | 91 | slider_motion_event (event); | ||
4029 | 92 | |||
4030 | 93 | return false; | ||
4031 | 94 | }); | ||
4032 | 95 | |||
4033 | 96 | scale.button_release_event.connect ((event) => {released = true; return false;}); | ||
4034 | 97 | preview_popover = new Audience.Widgets.PreviewPopover (); | ||
4035 | 98 | preview_popover.relative_to = this; | ||
4036 | 99 | |||
4037 | 100 | add (progression_label); | ||
4038 | 101 | add (scale); | ||
4039 | 102 | add (time_label); | ||
4040 | 103 | } | ||
4041 | 104 | |||
4042 | 105 | public void set_preview_uri (string uri) { | ||
4043 | 106 | preview_popover.set_preview_uri (uri); | ||
4044 | 107 | } | ||
4045 | 108 | |||
4046 | 109 | public override void get_preferred_width (out int minimum_width, out int natural_width) { | ||
4047 | 110 | base.get_preferred_width (out minimum_width, out natural_width); | ||
4048 | 111 | |||
4049 | 112 | if (parent.get_window () == null) | ||
4050 | 113 | return; | ||
4051 | 114 | var width = parent.get_window ().get_width (); | ||
4052 | 115 | if (width > 0 && width >= minimum_width) { | ||
4053 | 116 | natural_width = width; | ||
4054 | 117 | } | ||
4055 | 118 | } | ||
4056 | 119 | |||
4057 | 120 | public void set_progression_time (double current_time, double total_time) { | ||
4058 | 121 | if (is_seeking == true) | ||
4059 | 122 | return; | ||
4060 | 123 | scale.set_value (current_time/total_time); | ||
4061 | 124 | progression_label.label = seconds_to_time ((int)(current_time / 1000000000)); | ||
4062 | 125 | time_label.label = seconds_to_time ((int)((total_time - current_time) / 1000000000)); | ||
4063 | 126 | } | ||
4064 | 127 | } | ||
4065 | 0 | \ No newline at end of file | 128 | \ No newline at end of file |
4066 | 1 | 129 | ||
4067 | === removed file 'src/Widgets/TopPanel.vala' | |||
4068 | --- src/Widgets/TopPanel.vala 2013-05-19 17:10:26 +0000 | |||
4069 | +++ src/Widgets/TopPanel.vala 1970-01-01 00:00:00 +0000 | |||
4070 | @@ -1,87 +0,0 @@ | |||
4071 | 1 | |||
4072 | 2 | namespace Audience.Widgets{ | ||
4073 | 3 | |||
4074 | 4 | /*a bar only shown for fullscreen including volume and unfullscreen*/ | ||
4075 | 5 | public class TopPanel : Clutter.Box { | ||
4076 | 6 | |||
4077 | 7 | public Button exit; | ||
4078 | 8 | public GtkClutter.Actor volume; | ||
4079 | 9 | public Gtk.VolumeButton vol; | ||
4080 | 10 | |||
4081 | 11 | bool _hidden; | ||
4082 | 12 | public bool hidden{ | ||
4083 | 13 | get { return _hidden; } | ||
4084 | 14 | set { | ||
4085 | 15 | if (_hidden && !value){ | ||
4086 | 16 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, y : 0.0f); | ||
4087 | 17 | }else if (!_hidden && value){ | ||
4088 | 18 | this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 1000, y : -this.height); | ||
4089 | 19 | } | ||
4090 | 20 | this._hidden = value; | ||
4091 | 21 | } | ||
4092 | 22 | } | ||
4093 | 23 | |||
4094 | 24 | public signal void unfullscreen (); | ||
4095 | 25 | |||
4096 | 26 | public TopPanel () { | ||
4097 | 27 | layout_manager = new Clutter.BoxLayout (); | ||
4098 | 28 | |||
4099 | 29 | this.exit = new Button ("view-restore-symbolic", Gtk.Stock.LEAVE_FULLSCREEN); | ||
4100 | 30 | this.volume = new GtkClutter.Actor (); | ||
4101 | 31 | var buf = new Clutter.Rectangle.with_color ({0,0,0,0}); | ||
4102 | 32 | this.vol = new Gtk.VolumeButton (); | ||
4103 | 33 | this.vol.use_symbolic = true; | ||
4104 | 34 | this._hidden = true; | ||
4105 | 35 | |||
4106 | 36 | exit.reactive = true; | ||
4107 | 37 | exit.y = 2; | ||
4108 | 38 | exit.button_release_event.connect ((e) => { | ||
4109 | 39 | unfullscreen (); | ||
4110 | 40 | return true; | ||
4111 | 41 | }); | ||
4112 | 42 | |||
4113 | 43 | var css = new Gtk.CssProvider (); | ||
4114 | 44 | try { | ||
4115 | 45 | css.load_from_data (""" | ||
4116 | 46 | * { | ||
4117 | 47 | color: #fff; | ||
4118 | 48 | transition: 2ms linear; | ||
4119 | 49 | } | ||
4120 | 50 | *:hover { | ||
4121 | 51 | color: #aaa; | ||
4122 | 52 | transition: 2ms linear; | ||
4123 | 53 | } | ||
4124 | 54 | .button { | ||
4125 | 55 | background-image: none; | ||
4126 | 56 | background-color: alpha (#000, 0); | ||
4127 | 57 | border-color: alpha (#000, 0); | ||
4128 | 58 | border-image: none; | ||
4129 | 59 | -unico-border-gradient: none; | ||
4130 | 60 | -unico-inner-stroke-width: 0px; | ||
4131 | 61 | -unico-outer-stroke-width: 0px; | ||
4132 | 62 | } | ||
4133 | 63 | """, -1); | ||
4134 | 64 | }catch (Error e) { warning (e.message); } | ||
4135 | 65 | this.vol.get_child ().get_style_context ().add_provider (css, 20000); | ||
4136 | 66 | this.vol.get_style_context ().add_provider (css, 20000); | ||
4137 | 67 | |||
4138 | 68 | ((Gtk.Container)this.volume.get_widget ()).add (this.vol); | ||
4139 | 69 | this.volume.get_widget ().draw.connect ( (ctx) => { | ||
4140 | 70 | ctx.rectangle (0, 0, this.volume.width, this.volume.height); | ||
4141 | 71 | ctx.set_operator (Cairo.Operator.SOURCE); | ||
4142 | 72 | ctx.set_source_rgba (0, 0, 0, 0); | ||
4143 | 73 | ctx.fill (); | ||
4144 | 74 | return false; | ||
4145 | 75 | }); | ||
4146 | 76 | |||
4147 | 77 | buf.width = 10; | ||
4148 | 78 | |||
4149 | 79 | //this.add_child (this.volume); removed until we get it to control global volume | ||
4150 | 80 | this.add_child (buf); | ||
4151 | 81 | this.add_child (this.exit); | ||
4152 | 82 | |||
4153 | 83 | y = -height; | ||
4154 | 84 | } | ||
4155 | 85 | } | ||
4156 | 86 | } | ||
4157 | 87 | |||
4158 | 88 | 0 | ||
4159 | === modified file 'src/Widgets/VideoPlayer.vala' | |||
4160 | --- src/Widgets/VideoPlayer.vala 2014-05-15 07:10:20 +0000 | |||
4161 | +++ src/Widgets/VideoPlayer.vala 2014-07-06 11:18:29 +0000 | |||
4162 | @@ -1,3 +1,24 @@ | |||
4163 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
4164 | 2 | /*- | ||
4165 | 3 | * Copyright (c) 2013-2014 Audience Developers (http://launchpad.net/pantheon-chat) | ||
4166 | 4 | * | ||
4167 | 5 | * This program is free software: you can redistribute it and/or modify | ||
4168 | 6 | * it under the terms of the GNU General Public License as published by | ||
4169 | 7 | * the Free Software Foundation, either version 3 of the License, or | ||
4170 | 8 | * (at your option) any later version. | ||
4171 | 9 | |||
4172 | 10 | * This program is distributed in the hope that it will be useful, | ||
4173 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4174 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4175 | 13 | * GNU General Public License for more details. | ||
4176 | 14 | |||
4177 | 15 | * You should have received a copy of the GNU General Public License | ||
4178 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4179 | 17 | * | ||
4180 | 18 | * Authored by: Tom Beckmann <tomjonabc@gmail.com> | ||
4181 | 19 | * Corentin Noël <corentin@elementaryos.org> | ||
4182 | 20 | */ | ||
4183 | 21 | |||
4184 | 1 | using Clutter; | 22 | using Clutter; |
4185 | 2 | 23 | ||
4186 | 3 | enum PlayFlags { | 24 | enum PlayFlags { |
4187 | @@ -14,14 +35,17 @@ | |||
4188 | 14 | SOFT_COLORBALANCE = (1 << 10) | 35 | SOFT_COLORBALANCE = (1 << 10) |
4189 | 15 | } | 36 | } |
4190 | 16 | 37 | ||
4196 | 17 | namespace Audience.Widgets | 38 | namespace Audience.Widgets { |
4197 | 18 | { | 39 | public class VideoPlayer : Actor { |
4198 | 19 | public class VideoPlayer : Actor | 40 | private static VideoPlayer? video_player = null; |
4199 | 20 | { | 41 | public static VideoPlayer get_default () { |
4200 | 21 | 42 | if (video_player == null) | |
4201 | 43 | video_player = new VideoPlayer (); | ||
4202 | 44 | return video_player; | ||
4203 | 45 | } | ||
4204 | 46 | |||
4205 | 22 | public bool at_end; | 47 | public bool at_end; |
4208 | 23 | 48 | ||
4207 | 24 | bool paused; | ||
4209 | 25 | bool _playing; | 49 | bool _playing; |
4210 | 26 | public bool playing { | 50 | public bool playing { |
4211 | 27 | get { | 51 | get { |
4212 | @@ -30,47 +54,31 @@ | |||
4213 | 30 | set { | 54 | set { |
4214 | 31 | if (value == playing) | 55 | if (value == playing) |
4215 | 32 | return; | 56 | return; |
4216 | 33 | |||
4217 | 34 | controls.show_play_button (!value); | ||
4218 | 35 | |||
4219 | 36 | playbin.set_state (value ? Gst.State.PLAYING : Gst.State.PAUSED); | ||
4220 | 37 | 57 | ||
4221 | 38 | set_screensaver (!value); | 58 | set_screensaver (!value); |
4222 | 39 | set_screenlock (!value); | 59 | set_screenlock (!value); |
4233 | 40 | 60 | playbin.set_state (value ? Gst.State.PLAYING : Gst.State.PAUSED); | |
4224 | 41 | if (!value) { | ||
4225 | 42 | paused = true; | ||
4226 | 43 | lock_hide (); | ||
4227 | 44 | } | ||
4228 | 45 | if (value && paused) { | ||
4229 | 46 | paused = false; | ||
4230 | 47 | unlock_hide (); | ||
4231 | 48 | } | ||
4232 | 49 | |||
4234 | 50 | _playing = value; | 61 | _playing = value; |
4235 | 51 | } | 62 | } |
4236 | 52 | } | 63 | } |
4238 | 53 | 64 | ||
4239 | 54 | public double progress { | 65 | public double progress { |
4240 | 55 | get { | 66 | get { |
4241 | 56 | int64 length, prog; | 67 | int64 length, prog; |
4242 | 57 | |||
4243 | 58 | playbin.query_duration (Gst.Format.TIME, out length); | 68 | playbin.query_duration (Gst.Format.TIME, out length); |
4244 | 59 | playbin.query_position (Gst.Format.TIME, out prog); | 69 | playbin.query_position (Gst.Format.TIME, out prog); |
4245 | 60 | |||
4246 | 61 | if (length == 0) | 70 | if (length == 0) |
4247 | 62 | return 0; | 71 | return 0; |
4249 | 63 | 72 | ||
4250 | 64 | return prog / (double)length; | 73 | return prog / (double)length; |
4251 | 65 | } | 74 | } |
4252 | 66 | set { | 75 | set { |
4253 | 67 | int64 length; | 76 | int64 length; |
4254 | 68 | playbin.query_duration (Gst.Format.TIME, out length); | 77 | playbin.query_duration (Gst.Format.TIME, out length); |
4257 | 69 | playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, | 78 | playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.ACCURATE, (int64)(double.max (value, 0.0) * length)); |
4256 | 70 | (int64)(double.max (value, 0.0) * length)); | ||
4258 | 71 | } | 79 | } |
4259 | 72 | } | 80 | } |
4261 | 73 | 81 | ||
4262 | 74 | public double volume { | 82 | public double volume { |
4263 | 75 | get { | 83 | get { |
4264 | 76 | return playbin.volume; | 84 | return playbin.volume; |
4265 | @@ -79,7 +87,7 @@ | |||
4266 | 79 | playbin.volume = value; | 87 | playbin.volume = value; |
4267 | 80 | } | 88 | } |
4268 | 81 | } | 89 | } |
4270 | 82 | 90 | ||
4271 | 83 | public string uri { | 91 | public string uri { |
4272 | 84 | owned get { | 92 | owned get { |
4273 | 85 | return playbin.current_uri; | 93 | return playbin.current_uri; |
4274 | @@ -101,38 +109,20 @@ | |||
4275 | 101 | warning (e.message); | 109 | warning (e.message); |
4276 | 102 | return; | 110 | return; |
4277 | 103 | } | 111 | } |
4279 | 104 | 112 | ||
4280 | 105 | intial_relayout = true; | 113 | intial_relayout = true; |
4281 | 106 | |||
4282 | 107 | playing = false; | 114 | playing = false; |
4283 | 108 | playbin.set_state (Gst.State.READY); | 115 | playbin.set_state (Gst.State.READY); |
4284 | 109 | playbin.suburi = null; | 116 | playbin.suburi = null; |
4285 | 110 | subtitle_uri = null; | 117 | subtitle_uri = null; |
4286 | 111 | playbin.uri = value; | 118 | playbin.uri = value; |
4287 | 112 | volume = 1.0; | 119 | volume = 1.0; |
4288 | 113 | controls.slider.set_preview_uri (value); | ||
4289 | 114 | at_end = false; | 120 | at_end = false; |
4291 | 115 | 121 | ||
4292 | 116 | relayout (); | 122 | relayout (); |
4293 | 117 | playing = true; | 123 | playing = true; |
4294 | 118 | } | 124 | } |
4295 | 119 | } | 125 | } |
4296 | 120 | |||
4297 | 121 | bool _controls_hidden; | ||
4298 | 122 | public bool controls_hidden | ||
4299 | 123 | { | ||
4300 | 124 | get { return _controls_hidden; } | ||
4301 | 125 | set { | ||
4302 | 126 | if (_controls_hidden && !value) { | ||
4303 | 127 | float y2 = get_stage ().height - controls.height; | ||
4304 | 128 | controls.animate (Clutter.AnimationMode.EASE_OUT_CUBIC, 300, y:y2); | ||
4305 | 129 | } else if (!_controls_hidden && value){ | ||
4306 | 130 | float y2 = get_stage ().height; | ||
4307 | 131 | controls.animate (Clutter.AnimationMode.EASE_IN_QUAD, 600, y:y2); | ||
4308 | 132 | } | ||
4309 | 133 | _controls_hidden = value; | ||
4310 | 134 | } | ||
4311 | 135 | } | ||
4312 | 136 | 126 | ||
4313 | 137 | public int current_audio { | 127 | public int current_audio { |
4314 | 138 | get { | 128 | get { |
4315 | @@ -167,161 +157,73 @@ | |||
4316 | 167 | } | 157 | } |
4317 | 168 | } | 158 | } |
4318 | 169 | } | 159 | } |
4320 | 170 | 160 | ||
4321 | 171 | public dynamic Gst.Element playbin; | 161 | public dynamic Gst.Element playbin; |
4322 | 172 | Clutter.Texture video; | 162 | Clutter.Texture video; |
4323 | 173 | Controls controls; | ||
4324 | 174 | TopPanel panel; | ||
4325 | 175 | 163 | ||
4326 | 176 | uint video_width; | 164 | uint video_width; |
4327 | 177 | uint video_height; | 165 | uint video_height; |
4334 | 178 | 166 | ||
4329 | 179 | // we will only hide if hide lock is 0 | ||
4330 | 180 | public int hide_lock = 0; | ||
4331 | 181 | |||
4332 | 182 | uint hiding_timer; | ||
4333 | 183 | |||
4335 | 184 | public GnomeSessionManager session_manager; | 167 | public GnomeSessionManager session_manager; |
4336 | 185 | uint32 inhibit_cookie; | 168 | uint32 inhibit_cookie; |
4340 | 186 | 169 | ||
4338 | 187 | public bool fullscreened { get; set; } | ||
4339 | 188 | |||
4341 | 189 | public signal void ended (); | 170 | public signal void ended (); |
4342 | 190 | public signal void toggle_side_pane (bool show); | 171 | public signal void toggle_side_pane (bool show); |
4343 | 191 | public signal void text_tags_changed (); | 172 | public signal void text_tags_changed (); |
4344 | 192 | public signal void audio_tags_changed (); | 173 | public signal void audio_tags_changed (); |
4345 | 193 | public signal void show_open_context (); | ||
4346 | 194 | public signal void exit_fullscreen (); | ||
4347 | 195 | public signal void error (); | 174 | public signal void error (); |
4348 | 196 | public signal void plugin_install_done (); | 175 | public signal void plugin_install_done (); |
4349 | 197 | public signal void configure_window (uint video_w, uint video_h); | 176 | public signal void configure_window (uint video_w, uint video_h); |
4350 | 177 | public signal void progression_changed (double current_time, double total_time); | ||
4351 | 198 | public signal void external_subtitle_changed (string? uri); | 178 | public signal void external_subtitle_changed (string? uri); |
4352 | 199 | 179 | ||
4363 | 200 | public VideoPlayer () | 180 | private VideoPlayer () { |
4354 | 201 | { | ||
4355 | 202 | reactive = true; | ||
4356 | 203 | |||
4357 | 204 | controls = new Controls (); | ||
4358 | 205 | controls.add_constraint (new BindConstraint (this, BindCoordinate.WIDTH, 0)); | ||
4359 | 206 | controls.slider.preview.add_constraint (new BindConstraint (controls, Clutter.BindCoordinate.Y, -105.0f)); | ||
4360 | 207 | |||
4361 | 208 | panel = new TopPanel (); | ||
4362 | 209 | |||
4364 | 210 | video = new Clutter.Texture (); | 181 | video = new Clutter.Texture (); |
4367 | 211 | video.reactive = true; | 182 | |
4368 | 212 | 183 | dynamic Gst.Element video_sink = Gst.ElementFactory.make ("cluttersink", "source"); | |
4369 | 184 | video_sink.texture = video; | ||
4370 | 185 | |||
4371 | 213 | playbin = Gst.ElementFactory.make ("playbin", "playbin"); | 186 | playbin = Gst.ElementFactory.make ("playbin", "playbin"); |
4372 | 214 | var video_sink = Audience.get_clutter_sink (); | ||
4373 | 215 | video_sink.texture = video; | ||
4374 | 216 | |||
4375 | 217 | playbin.video_sink = video_sink; | 187 | playbin.video_sink = video_sink; |
4377 | 218 | 188 | ||
4378 | 219 | add_child (video); | 189 | add_child (video); |
4379 | 220 | add_child (controls); | ||
4380 | 221 | add_child (panel); | ||
4381 | 222 | add_child (controls.slider.preview); | ||
4382 | 223 | |||
4383 | 224 | controls.slider.seeked.connect ( (v) => { | ||
4384 | 225 | debug ("Seeked to %f", v); | ||
4385 | 226 | progress = v; | ||
4386 | 227 | }); | ||
4387 | 228 | Timeout.add (100, () => { | 190 | Timeout.add (100, () => { |
4388 | 229 | int64 length, prog; | 191 | int64 length, prog; |
4389 | 230 | playbin.query_position (Gst.Format.TIME, out prog); | 192 | playbin.query_position (Gst.Format.TIME, out prog); |
4390 | 231 | playbin.query_duration (Gst.Format.TIME, out length); | 193 | playbin.query_duration (Gst.Format.TIME, out length); |
4391 | 232 | |||
4392 | 233 | if (length == 0) | 194 | if (length == 0) |
4393 | 234 | return true; | 195 | return true; |
4400 | 235 | 196 | ||
4401 | 236 | controls.slider.progress = prog / (double)length; | 197 | progression_changed ((double)prog, (double)length); |
4396 | 237 | |||
4397 | 238 | controls.current.text = seconds_to_time ((int)(prog / 1000000000)); | ||
4398 | 239 | controls.remaining.text = "-" + seconds_to_time ((int)(length / 1000000000) - (int)(prog / 1000000000)); | ||
4399 | 240 | |||
4402 | 241 | return true; | 198 | return true; |
4403 | 242 | }); | 199 | }); |
4404 | 200 | |||
4405 | 243 | playbin.about_to_finish.connect (() => { | 201 | playbin.about_to_finish.connect (() => { |
4406 | 244 | at_end = true; | 202 | at_end = true; |
4407 | 245 | ended (); | 203 | ended (); |
4408 | 246 | }); | 204 | }); |
4409 | 247 | 205 | ||
4410 | 248 | notify["fullscreened"].connect (() => { | ||
4411 | 249 | if (hide_lock > 0) | ||
4412 | 250 | panel.hidden = !fullscreened; | ||
4413 | 251 | }); | ||
4414 | 252 | panel.unfullscreen.connect (() => { | ||
4415 | 253 | exit_fullscreen (); | ||
4416 | 254 | }); | ||
4417 | 255 | |||
4418 | 256 | bool last_state = false; | ||
4419 | 257 | controls.notify["hovered"].connect (() => { | ||
4420 | 258 | if (controls.hovered == last_state) | ||
4421 | 259 | return; | ||
4422 | 260 | |||
4423 | 261 | last_state = controls.hovered; | ||
4424 | 262 | |||
4425 | 263 | if (controls.hovered) | ||
4426 | 264 | lock_hide (); | ||
4427 | 265 | else | ||
4428 | 266 | unlock_hide (); | ||
4429 | 267 | }); | ||
4430 | 268 | |||
4431 | 269 | controls.open.clicked.connect (() => { | ||
4432 | 270 | show_open_context (); | ||
4433 | 271 | }); | ||
4434 | 272 | controls.play.clicked.connect (() => playing = !playing ); | ||
4435 | 273 | controls.view.clicked.connect (() => { | ||
4436 | 274 | if (!controls.showing_view) { | ||
4437 | 275 | toggle_side_pane (true); | ||
4438 | 276 | controls.view.set_icon ("pane-hide-symbolic", Gtk.Stock.GO_FORWARD, "go-next-symbolic"); | ||
4439 | 277 | controls.showing_view = true; | ||
4440 | 278 | |||
4441 | 279 | lock_hide (); | ||
4442 | 280 | } else { | ||
4443 | 281 | toggle_side_pane (false); | ||
4444 | 282 | controls.view.set_icon ("pane-show-symbolic", Gtk.Stock.GO_BACK, "go-previous-symbolic"); | ||
4445 | 283 | controls.showing_view = false; | ||
4446 | 284 | |||
4447 | 285 | unlock_hide (); | ||
4448 | 286 | } | ||
4449 | 287 | }); | ||
4450 | 288 | |||
4451 | 289 | panel.vol.value_changed.connect ( (value) => { | ||
4452 | 290 | volume = value; | ||
4453 | 291 | }); | ||
4454 | 292 | panel.vol.value = 1.0; | ||
4455 | 293 | |||
4456 | 294 | playbin.text_tags_changed.connect ((el) => { | 206 | playbin.text_tags_changed.connect ((el) => { |
4457 | 295 | var structure = new Gst.Structure.empty ("tags-changed"); | 207 | var structure = new Gst.Structure.empty ("tags-changed"); |
4458 | 296 | structure.set_value ("type", "text"); | 208 | structure.set_value ("type", "text"); |
4459 | 297 | el.post_message (new Gst.Message.application (el, (owned) structure)); | 209 | el.post_message (new Gst.Message.application (el, (owned) structure)); |
4460 | 298 | }); | 210 | }); |
4461 | 211 | |||
4462 | 299 | playbin.audio_tags_changed.connect ((el) => { | 212 | playbin.audio_tags_changed.connect ((el) => { |
4463 | 300 | var structure = new Gst.Structure.empty ("tags-changed"); | 213 | var structure = new Gst.Structure.empty ("tags-changed"); |
4464 | 301 | structure.set_value ("type", "audio"); | 214 | structure.set_value ("type", "audio"); |
4465 | 302 | el.post_message (new Gst.Message.application (el, (owned) structure)); | 215 | el.post_message (new Gst.Message.application (el, (owned) structure)); |
4466 | 303 | }); | 216 | }); |
4468 | 304 | 217 | ||
4469 | 305 | playbin.get_bus ().add_signal_watch (); | 218 | playbin.get_bus ().add_signal_watch (); |
4470 | 306 | playbin.get_bus ().message.connect (watch); | 219 | playbin.get_bus ().message.connect (watch); |
4471 | 307 | } | 220 | } |
4472 | 308 | 221 | ||
4473 | 309 | public void lock_hide () { | ||
4474 | 310 | if (hide_lock == 0) | ||
4475 | 311 | toggle_controls (true); | ||
4476 | 312 | hide_lock++; | ||
4477 | 313 | } | ||
4478 | 314 | public void unlock_hide () { | ||
4479 | 315 | hide_lock--; | ||
4480 | 316 | |||
4481 | 317 | if (hide_lock < 1) | ||
4482 | 318 | toggle_controls (false); | ||
4483 | 319 | } | ||
4484 | 320 | |||
4485 | 321 | void watch () { | 222 | void watch () { |
4486 | 322 | var msg = playbin.get_bus ().peek (); | 223 | var msg = playbin.get_bus ().peek (); |
4487 | 323 | if (msg == null) | 224 | if (msg == null) |
4488 | 324 | return; | 225 | return; |
4489 | 226 | |||
4490 | 325 | switch (msg.type) { | 227 | switch (msg.type) { |
4491 | 326 | case Gst.MessageType.APPLICATION: | 228 | case Gst.MessageType.APPLICATION: |
4492 | 327 | if (msg.get_structure ().get_name () == "tags-changed") { | 229 | if (msg.get_structure ().get_name () == "tags-changed") { |
4493 | @@ -374,23 +276,7 @@ | |||
4494 | 374 | } | 276 | } |
4495 | 375 | } | 277 | } |
4496 | 376 | 278 | ||
4514 | 377 | public override bool motion_event (Clutter.MotionEvent event) | 279 | public void set_subtitle_uri (string? uri) { |
4498 | 378 | { | ||
4499 | 379 | if (!controls.slider.mouse_grabbed) | ||
4500 | 380 | get_stage ().cursor_visible = true; | ||
4501 | 381 | |||
4502 | 382 | Gst.State state; | ||
4503 | 383 | playbin.get_state (out state, null, 0); | ||
4504 | 384 | if (state == Gst.State.PLAYING) { | ||
4505 | 385 | if (hiding_timer < 1) | ||
4506 | 386 | lock_hide (); | ||
4507 | 387 | set_timeout (); | ||
4508 | 388 | } | ||
4509 | 389 | return true; | ||
4510 | 390 | } | ||
4511 | 391 | |||
4512 | 392 | public void set_subtitle_uri (string? uri) | ||
4513 | 393 | { | ||
4515 | 394 | subtitle_uri = uri; | 280 | subtitle_uri = uri; |
4516 | 395 | if (!check_text_layer (subtitle_uri != null)) { | 281 | if (!check_text_layer (subtitle_uri != null)) { |
4517 | 396 | apply_subtitles (); | 282 | apply_subtitles (); |
4518 | @@ -400,8 +286,7 @@ | |||
4519 | 400 | 286 | ||
4520 | 401 | // checks whether text layer has to be enabled | 287 | // checks whether text layer has to be enabled |
4521 | 402 | // returns if apply_subtitles has been called | 288 | // returns if apply_subtitles has been called |
4524 | 403 | bool check_text_layer (bool enable) | 289 | bool check_text_layer (bool enable) { |
4523 | 404 | { | ||
4525 | 405 | int flags; | 290 | int flags; |
4526 | 406 | playbin.get ("flags", out flags); | 291 | playbin.get ("flags", out flags); |
4527 | 407 | 292 | ||
4528 | @@ -419,8 +304,7 @@ | |||
4529 | 419 | } | 304 | } |
4530 | 420 | 305 | ||
4531 | 421 | // ported from totem bvw widget set_subtitle_uri | 306 | // ported from totem bvw widget set_subtitle_uri |
4534 | 422 | void apply_subtitles () | 307 | void apply_subtitles () { |
4533 | 423 | { | ||
4535 | 424 | int64 time; | 308 | int64 time; |
4536 | 425 | playbin.query_position (Gst.Format.TIME, out time); | 309 | playbin.query_position (Gst.Format.TIME, out time); |
4537 | 426 | 310 | ||
4538 | @@ -434,7 +318,6 @@ | |||
4539 | 434 | } | 318 | } |
4540 | 435 | 319 | ||
4541 | 436 | playbin.suburi = subtitle_uri; | 320 | playbin.suburi = subtitle_uri; |
4542 | 437 | |||
4543 | 438 | if (current > Gst.State.READY) { | 321 | if (current > Gst.State.READY) { |
4544 | 439 | playbin.set_state (current); | 322 | playbin.set_state (current); |
4545 | 440 | playbin.get_state (null, null, Gst.CLOCK_TIME_NONE); | 323 | playbin.get_state (null, null, Gst.CLOCK_TIME_NONE); |
4546 | @@ -451,10 +334,9 @@ | |||
4547 | 451 | playbin.get_state (null, null, Gst.CLOCK_TIME_NONE); | 334 | playbin.get_state (null, null, Gst.CLOCK_TIME_NONE); |
4548 | 452 | } | 335 | } |
4549 | 453 | } | 336 | } |
4551 | 454 | 337 | ||
4552 | 455 | bool intial_relayout = false; | 338 | bool intial_relayout = false; |
4555 | 456 | public bool relayout () | 339 | public bool relayout () { |
4554 | 457 | { | ||
4556 | 458 | if (video_width < 1 || video_height < 1 || uri == null) | 340 | if (video_width < 1 || video_height < 1 || uri == null) |
4557 | 459 | return false; | 341 | return false; |
4558 | 460 | 342 | ||
4559 | @@ -464,136 +346,100 @@ | |||
4560 | 464 | } | 346 | } |
4561 | 465 | 347 | ||
4562 | 466 | var stage = get_stage (); | 348 | var stage = get_stage (); |
4563 | 467 | |||
4564 | 468 | var aspect = stage.width / video_width < stage.height / video_height ? | 349 | var aspect = stage.width / video_width < stage.height / video_height ? |
4565 | 469 | stage.width / video_width : stage.height / video_height; | 350 | stage.width / video_width : stage.height / video_height; |
4566 | 470 | video.width = video_width * aspect; | 351 | video.width = video_width * aspect; |
4567 | 471 | video.height = video_height * aspect; | 352 | video.height = video_height * aspect; |
4568 | 472 | video.x = (stage.width - video.width) / 2; | 353 | video.x = (stage.width - video.width) / 2; |
4569 | 473 | video.y = (stage.height - video.height) / 2; | 354 | video.y = (stage.height - video.height) / 2; |
4570 | 474 | |||
4571 | 475 | if (controls.get_animation () != null) | ||
4572 | 476 | controls.detach_animation (); | ||
4573 | 477 | controls.y = controls_hidden ? stage.height : stage.height - controls.height; | ||
4574 | 478 | |||
4575 | 479 | (controls.content as Clutter.Canvas).set_size ((int)controls.width, (int)controls.height); | ||
4576 | 480 | controls.content.invalidate (); | ||
4577 | 481 | |||
4578 | 482 | panel.x = get_stage ().width - panel.width - 10; | ||
4579 | 483 | controls.slider.preview.width = (float) video_width / video_height * controls.slider.preview.height; | ||
4580 | 484 | 355 | ||
4581 | 485 | return true; | 356 | return true; |
4582 | 486 | } | 357 | } |
4587 | 487 | 358 | ||
4588 | 488 | void show_error (string? message=null) | 359 | void show_error (string? message=null) { |
4589 | 489 | { | 360 | var dlg = new Gtk.Dialog.with_buttons (_("Error"), null, Gtk.DialogFlags.MODAL, _("_OK"), Gtk.ResponseType.OK); |
4586 | 490 | var dlg = new Gtk.Dialog.with_buttons (_("Error"), null, Gtk.DialogFlags.MODAL, Gtk.Stock.OK, Gtk.ResponseType.OK); | ||
4590 | 491 | var grid = new Gtk.Grid (); | 361 | var grid = new Gtk.Grid (); |
4593 | 492 | var err = new Gtk.Image.from_stock (Gtk.Stock.DIALOG_ERROR, Gtk.IconSize.DIALOG); | 362 | var err = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG); |
4592 | 493 | |||
4594 | 494 | err.margin_right = 12; | 363 | err.margin_right = 12; |
4595 | 364 | |||
4596 | 365 | var err_label = new Gtk.Label (""); | ||
4597 | 366 | err_label.set_markup ("<b>%s</b>".printf (_("Oops! Audience can't play this file!"))); | ||
4598 | 367 | |||
4599 | 495 | grid.margin = 12; | 368 | grid.margin = 12; |
4600 | 496 | grid.attach (err, 0, 0, 1, 1); | 369 | grid.attach (err, 0, 0, 1, 1); |
4603 | 497 | grid.attach (new Widgets.LLabel.markup ("<b>"+ | 370 | grid.attach (err_label, 1, 0, 1, 1); |
4602 | 498 | _("Oops! Audience can't play this file!")+"</b>"), 1, 0, 1, 1); | ||
4604 | 499 | if (message != null) | 371 | if (message != null) |
4606 | 500 | grid.attach (new Widgets.LLabel (message), 1, 1, 1, 2); | 372 | grid.attach (new Gtk.Label (message), 1, 1, 1, 2); |
4607 | 501 | 373 | ||
4608 | 502 | error (); | 374 | error (); |
4609 | 503 | |||
4610 | 504 | ((Gtk.Box)dlg.get_content_area ()).add (grid); | 375 | ((Gtk.Box)dlg.get_content_area ()).add (grid); |
4611 | 505 | dlg.show_all (); | 376 | dlg.show_all (); |
4612 | 506 | dlg.run (); | 377 | dlg.run (); |
4613 | 507 | dlg.destroy (); | 378 | dlg.destroy (); |
4614 | 508 | } | 379 | } |
4618 | 509 | 380 | ||
4619 | 510 | void handle_missing_plugin (Gst.Message msg) | 381 | void handle_missing_plugin (Gst.Message msg) { |
4617 | 511 | { | ||
4620 | 512 | var detail = Gst.PbUtils.missing_plugin_message_get_description (msg); | 382 | var detail = Gst.PbUtils.missing_plugin_message_get_description (msg); |
4623 | 513 | var dlg = new Gtk.Dialog.with_buttons ("Missing plugin", null, | 383 | var dlg = new Gtk.Dialog.with_buttons ("Missing plugin", null, Gtk.DialogFlags.MODAL); |
4622 | 514 | Gtk.DialogFlags.MODAL); | ||
4624 | 515 | var grid = new Gtk.Grid (); | 384 | var grid = new Gtk.Grid (); |
4629 | 516 | var err = new Gtk.Image.from_stock (Gtk.Stock.DIALOG_ERROR, | 385 | var err = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG); |
4630 | 517 | Gtk.IconSize.DIALOG); | 386 | var phrase = new Gtk.Label (_("Some media files need extra software to be played. Audience can install this software automatically.")); |
4631 | 518 | var phrase = new Widgets.LLabel (_("Some media files need extra software to be played. Audience can install this software automatically.")); | 387 | |
4628 | 519 | |||
4632 | 520 | err.margin_right = 12; | 388 | err.margin_right = 12; |
4633 | 389 | |||
4634 | 390 | var err_label = new Gtk.Label (""); | ||
4635 | 391 | err_label.set_markup ("<b>%s</b>".printf (_("Audience needs %s to play this file.").printf (detail))); | ||
4636 | 392 | |||
4637 | 521 | grid.margin = 12; | 393 | grid.margin = 12; |
4638 | 522 | grid.attach (err, 0, 0, 1, 1); | 394 | grid.attach (err, 0, 0, 1, 1); |
4641 | 523 | grid.attach (new Widgets.LLabel.markup ("<b>"+ | 395 | grid.attach (err_label, 1, 0, 1, 1); |
4640 | 524 | _("Audience needs %s to play this file.").printf (detail)+"</b>"), 1, 0, 1, 1); | ||
4642 | 525 | grid.attach (phrase, 1, 1, 1, 2); | 396 | grid.attach (phrase, 1, 1, 1, 2); |
4643 | 526 | 397 | ||
4644 | 527 | dlg.add_button (_("Don't install"), 1); | 398 | dlg.add_button (_("Don't install"), 1); |
4645 | 528 | dlg.add_button (_("Install")+" "+detail, 0); | 399 | dlg.add_button (_("Install")+" "+detail, 0); |
4647 | 529 | 400 | ||
4648 | 530 | (dlg.get_content_area () as Gtk.Container).add (grid); | 401 | (dlg.get_content_area () as Gtk.Container).add (grid); |
4649 | 531 | |||
4650 | 532 | dlg.show_all (); | 402 | dlg.show_all (); |
4651 | 533 | if (dlg.run () == 0) { | 403 | if (dlg.run () == 0) { |
4652 | 534 | var installer = Gst.PbUtils.missing_plugin_message_get_installer_detail (msg); | 404 | var installer = Gst.PbUtils.missing_plugin_message_get_installer_detail (msg); |
4653 | 535 | var context = new Gst.PbUtils.InstallPluginsContext (); | 405 | var context = new Gst.PbUtils.InstallPluginsContext (); |
4657 | 536 | Gst.PbUtils.install_plugins_async ({installer}, context, | 406 | Gst.PbUtils.install_plugins_async ({installer}, context, () => { //finished |
4658 | 537 | () => { //finished | 407 | debug ("Finished plugin install"); |
4656 | 538 | debug ("Finished plugin install\n"); | ||
4659 | 539 | Gst.update_registry (); | 408 | Gst.update_registry (); |
4660 | 540 | plugin_install_done (); | 409 | plugin_install_done (); |
4661 | 541 | playing = true; | 410 | playing = true; |
4662 | 542 | }); | 411 | }); |
4663 | 543 | } | 412 | } |
4664 | 413 | |||
4665 | 544 | dlg.destroy (); | 414 | dlg.destroy (); |
4666 | 545 | } | 415 | } |
4694 | 546 | 416 | ||
4695 | 547 | void set_timeout () | 417 | //TODO: Remove X Dependency! |
4669 | 548 | { | ||
4670 | 549 | if (hiding_timer != 0) | ||
4671 | 550 | Source.remove (hiding_timer); | ||
4672 | 551 | |||
4673 | 552 | hiding_timer = GLib.Timeout.add (2000, () => { | ||
4674 | 553 | unlock_hide (); | ||
4675 | 554 | hiding_timer = 0; | ||
4676 | 555 | return false; | ||
4677 | 556 | }); | ||
4678 | 557 | } | ||
4679 | 558 | |||
4680 | 559 | void toggle_controls (bool show) | ||
4681 | 560 | { | ||
4682 | 561 | if (show) { | ||
4683 | 562 | controls_hidden = false; | ||
4684 | 563 | get_stage ().cursor_visible = true; | ||
4685 | 564 | if (fullscreened) | ||
4686 | 565 | panel.hidden = false; | ||
4687 | 566 | } else { | ||
4688 | 567 | get_stage ().cursor_visible = false; | ||
4689 | 568 | controls_hidden = true; | ||
4690 | 569 | panel.hidden = true; | ||
4691 | 570 | } | ||
4692 | 571 | } | ||
4693 | 572 | |||
4696 | 573 | //store the default values for setting back | 418 | //store the default values for setting back |
4697 | 574 | X.Display dpy; int timeout = -1; int interval; int prefer_blanking; int allow_exposures; | 419 | X.Display dpy; int timeout = -1; int interval; int prefer_blanking; int allow_exposures; |
4700 | 575 | void set_screensaver (bool enable) | 420 | void set_screensaver (bool enable) { |
4699 | 576 | { | ||
4701 | 577 | if (dpy == null) | 421 | if (dpy == null) |
4702 | 578 | dpy = new X.Display (); | 422 | dpy = new X.Display (); |
4704 | 579 | 423 | ||
4705 | 580 | if (timeout == -1) | 424 | if (timeout == -1) |
4706 | 581 | dpy.get_screensaver (out timeout, out interval, out prefer_blanking, out allow_exposures); | 425 | dpy.get_screensaver (out timeout, out interval, out prefer_blanking, out allow_exposures); |
4707 | 426 | |||
4708 | 582 | dpy.set_screensaver (enable ? timeout : 0, interval, prefer_blanking, allow_exposures); | 427 | dpy.set_screensaver (enable ? timeout : 0, interval, prefer_blanking, allow_exposures); |
4709 | 583 | } | 428 | } |
4711 | 584 | 429 | ||
4712 | 585 | //prevent screenlocking in Gnome 3 using org.gnome.SessionManager | 430 | //prevent screenlocking in Gnome 3 using org.gnome.SessionManager |
4716 | 586 | void set_screenlock (bool enable) | 431 | void set_screenlock (bool enable) { |
4717 | 587 | { | 432 | try { |
4715 | 588 | try{ | ||
4718 | 589 | session_manager = Bus.get_proxy_sync (BusType.SESSION, | 433 | session_manager = Bus.get_proxy_sync (BusType.SESSION, |
4719 | 590 | "org.gnome.SessionManager", "/org/gnome/SessionManager"); | 434 | "org.gnome.SessionManager", "/org/gnome/SessionManager"); |
4720 | 591 | if (enable) { | 435 | if (enable) { |
4721 | 592 | session_manager.Uninhibit (inhibit_cookie); | 436 | session_manager.Uninhibit (inhibit_cookie); |
4723 | 593 | }else{ | 437 | } else { |
4724 | 594 | inhibit_cookie = session_manager.Inhibit ("audience", 0, "Playing Video using Audience", 12); | 438 | inhibit_cookie = session_manager.Inhibit ("audience", 0, "Playing Video using Audience", 12); |
4725 | 595 | } | 439 | } |
4727 | 596 | } catch (Error e) { warning (e.message); } | 440 | } catch (Error e) { |
4728 | 441 | warning (e.message); | ||
4729 | 442 | } | ||
4730 | 597 | } | 443 | } |
4731 | 598 | } | 444 | } |
4733 | 599 | } | 445 | } |
4734 | 600 | \ No newline at end of file | 446 | \ No newline at end of file |
I have tested this branch a few times, felt stable and working. Just for nitpicking: The diff seems a bit hard to read, given that some changes not necessarily related to GTK-3.12 migration have been added (e.g. CMake file splitting per subdir for data and src, generated Makefile removal), those might be better in separate merges, but necessary. If no one else has objections against those being in this one, I'll give this an approve.