Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
pitivi
Commits
d91c1283
Commit
d91c1283
authored
Aug 07, 2018
by
HarishFulara07
Committed by
Alexandru Băluț
Jan 10, 2019
Browse files
viewer: Show resize status
parent
7f5a6085
Changes
4
Hide whitespace changes
Inline
Side-by-side
pitivi/editorperspective.py
View file @
d91c1283
...
...
@@ -43,10 +43,10 @@ from pitivi.transitions import TransitionsListWidget
from
pitivi.utils.loggable
import
Loggable
from
pitivi.utils.misc
import
path_from_uri
from
pitivi.utils.ui
import
beautify_time_delta
from
pitivi.utils.ui
import
EDITOR_PERSPECTIVE_CSS
from
pitivi.utils.ui
import
info_name
from
pitivi.utils.ui
import
PADDING
from
pitivi.utils.ui
import
SPACING
from
pitivi.utils.ui
import
TIMELINE_CSS
from
pitivi.viewer.viewer
import
ViewerContainer
...
...
@@ -110,7 +110,7 @@ class EditorPerspective(Perspective, Loggable):
def
__setup_css
(
self
):
css_provider
=
Gtk
.
CssProvider
()
css_provider
.
load_from_data
(
TIMELIN
E_CSS
.
encode
(
'
UTF-8
'
))
css_provider
.
load_from_data
(
EDITOR_PERSPECTIV
E_CSS
.
encode
(
"
UTF-8
"
))
screen
=
Gdk
.
Screen
.
get_default
()
style_context
=
self
.
app
.
gui
.
get_style_context
()
style_context
.
add_provider_for_screen
(
screen
,
css_provider
,
...
...
pitivi/utils/ui.py
View file @
d91c1283
...
...
@@ -157,7 +157,13 @@ GREETER_PERSPECTIVE_CSS = """
}
"""
TIMELINE_CSS
=
"""
EDITOR_PERSPECTIVE_CSS
=
"""
#resize_status {
font-size: 200%%;
background-color: black;
opacity: 0.8;
}
.AudioBackground {
background-color: #496c21;
}
...
...
pitivi/viewer/overlay_stack.py
View file @
d91c1283
...
...
@@ -19,6 +19,7 @@
import
numpy
from
gi.repository
import
Gdk
from
gi.repository
import
GES
from
gi.repository
import
GLib
from
gi.repository
import
Gtk
from
pitivi.utils.loggable
import
Loggable
...
...
@@ -50,6 +51,19 @@ class OverlayStack(Gtk.Overlay, Loggable):
self
.
add
(
sink_widget
)
self
.
connect
(
"size-allocate"
,
self
.
__on_size_allocate
)
# Whether to show the percent of the size relative to the project size.
# It is set to false initially because the viewer gets resized
# while the project is loading and we don't want to show the percent
# in this case.
self
.
__show_resize_status
=
False
# ID of resizing timeout callback, so it can be delayed.
self
.
__resizing_id
=
0
self
.
revealer
=
Gtk
.
Revealer
(
transition_type
=
Gtk
.
RevealerTransitionType
.
CROSSFADE
)
self
.
resize_status
=
Gtk
.
Label
(
name
=
"resize_status"
)
self
.
revealer
.
add
(
self
.
resize_status
)
self
.
add_overlay
(
self
.
revealer
)
sink_widget
.
connect
(
"size-allocate"
,
self
.
__sink_widget_size_allocate_cb
)
def
__on_size_allocate
(
self
,
widget
,
rectangle
):
self
.
window_size
=
numpy
.
array
([
rectangle
.
width
,
rectangle
.
height
])
...
...
@@ -169,3 +183,29 @@ class OverlayStack(Gtk.Overlay, Loggable):
def
get_normalized_cursor_position
(
self
,
cursor_position
):
return
cursor_position
/
self
.
window_size
def
enable_resize_status
(
self
,
enabled
):
self
.
__show_resize_status
=
enabled
def
__sink_widget_size_allocate_cb
(
self
,
unused_widget
,
allocation
):
if
not
self
.
__show_resize_status
:
return
if
not
self
.
revealer
.
get_reveal_child
():
self
.
revealer
.
set_transition_duration
(
10
)
self
.
revealer
.
set_reveal_child
(
True
)
video_width
=
self
.
app
.
project_manager
.
current_project
.
videowidth
percent
=
int
(
allocation
.
width
/
video_width
*
100
)
self
.
resize_status
.
set_text
(
"{}%"
.
format
(
percent
))
# Add timeout function to hide the resize percent.
if
self
.
__resizing_id
:
GLib
.
source_remove
(
self
.
__resizing_id
)
self
.
__resizing_id
=
GLib
.
timeout_add
(
1000
,
self
.
__resizing_timeout_cb
,
None
)
def
__resizing_timeout_cb
(
self
,
unused_data
):
self
.
__resizing_id
=
0
self
.
revealer
.
set_transition_duration
(
500
)
self
.
revealer
.
set_reveal_child
(
False
)
return
False
pitivi/viewer/viewer.py
View file @
d91c1283
...
...
@@ -21,6 +21,7 @@ from time import time
from
gi.repository
import
Gdk
from
gi.repository
import
GES
from
gi.repository
import
GLib
from
gi.repository
import
GObject
from
gi.repository
import
Gst
from
gi.repository
import
Gtk
...
...
@@ -148,6 +149,10 @@ class ViewerContainer(Gtk.Box, Loggable):
self
.
setDisplayAspectRatio
(
self
.
app
.
project_manager
.
current_project
.
getDAR
())
self
.
target
.
show_all
()
# Wait for 1s to make sure that the viewer has completely realized
# and then we can mark the resize status as showable.
GLib
.
timeout_add
(
1000
,
self
.
__viewer_realization_done_cb
,
None
)
def
_disconnectFromPipeline
(
self
):
if
self
.
pipeline
is
None
:
# silently return, there's nothing to disconnect from
...
...
@@ -402,6 +407,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self
.
docked
=
False
self
.
settings
.
viewerDocked
=
False
self
.
overlay_stack
.
enable_resize_status
(
False
)
self
.
remove
(
self
.
buttons_container
)
position
=
None
if
self
.
pipeline
:
...
...
@@ -431,6 +437,10 @@ class ViewerContainer(Gtk.Box, Loggable):
self
.
pipeline
.
pause
()
self
.
pipeline
.
simple_seek
(
position
)
def
__viewer_realization_done_cb
(
self
,
unused_data
):
self
.
overlay_stack
.
enable_resize_status
(
True
)
return
False
def
dock
(
self
):
if
self
.
docked
:
self
.
warning
(
"The viewer is already docked"
)
...
...
@@ -438,6 +448,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self
.
docked
=
True
self
.
settings
.
viewerDocked
=
True
self
.
overlay_stack
.
enable_resize_status
(
False
)
position
=
None
if
self
.
pipeline
:
...
...
Alexandru Băluț
@aleb
mentioned in issue
#1305 (closed)
·
Jan 28, 2019
mentioned in issue
#1305 (closed)
mentioned in issue #1305
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment