mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 23:14:46 +00:00
Save state of timeline visibility
This commit is contained in:
parent
6e056f8e20
commit
d4237c5600
6 changed files with 47 additions and 18 deletions
|
@ -212,9 +212,10 @@ class StateString (object):
|
|||
|
||||
"""Descriptor for binding to StateSection classes."""
|
||||
|
||||
def __init__ (self, option):
|
||||
def __init__ (self, option, default = None):
|
||||
|
||||
self.option = option
|
||||
self.default = default
|
||||
|
||||
def __get__ (self, section, section_class = None):
|
||||
|
||||
|
@ -241,7 +242,7 @@ class StateString (object):
|
|||
|
||||
def get_default (self, section):
|
||||
|
||||
return None
|
||||
return self.default
|
||||
|
||||
def set (self, section, value):
|
||||
|
||||
|
@ -300,9 +301,9 @@ class StateItem (StateString):
|
|||
"""Descriptor for binding to StateSection classes. This implements storing
|
||||
a class controlled by a Manager class."""
|
||||
|
||||
def __init__ (self, option, manager_class):
|
||||
def __init__ (self, option, manager_class, default = None):
|
||||
|
||||
StateString.__init__ (self, option)
|
||||
StateString.__init__ (self, option, default = default)
|
||||
|
||||
self.manager = manager_class
|
||||
|
||||
|
@ -357,7 +358,11 @@ class StateItemList (StateItem):
|
|||
|
||||
def get_default (self, section):
|
||||
|
||||
return []
|
||||
default = StateItem.get_default (self, section)
|
||||
if default is None:
|
||||
return []
|
||||
else:
|
||||
return default
|
||||
|
||||
def set (self, section, value):
|
||||
|
||||
|
|
|
@ -1014,7 +1014,7 @@ class Window (object):
|
|||
self.features = []
|
||||
|
||||
for plugin_feature in self.app.iter_plugin_features ():
|
||||
feature = plugin_feature ()
|
||||
feature = plugin_feature (self.app)
|
||||
self.features.append (feature)
|
||||
|
||||
for feature in self.features:
|
||||
|
@ -1284,15 +1284,17 @@ class App (object):
|
|||
|
||||
def __init__ (self):
|
||||
|
||||
self.load_plugins ()
|
||||
|
||||
self.attach ()
|
||||
|
||||
def load_plugins (self):
|
||||
|
||||
from GstDebugViewer import Plugins
|
||||
|
||||
self.plugins = list (Plugins.load ([os.path.dirname (Plugins.__file__)]))
|
||||
plugin_classes = list (Plugins.load ([os.path.dirname (Plugins.__file__)]))
|
||||
self.plugins = []
|
||||
for plugin_class in plugin_classes:
|
||||
plugin = plugin_class (self)
|
||||
self.plugins.append (plugin)
|
||||
|
||||
def iter_plugin_features (self):
|
||||
|
||||
|
@ -1309,6 +1311,8 @@ class App (object):
|
|||
self.state = AppState (state_filename)
|
||||
self.state_section = self.state.sections["state"]
|
||||
|
||||
self.load_plugins ()
|
||||
|
||||
self.windows = [Window (self)]
|
||||
|
||||
def detach (self):
|
||||
|
|
|
@ -33,7 +33,7 @@ class FilePropertiesDialog (gtk.Dialog):
|
|||
|
||||
class FilePropertiesFeature (FeatureBase):
|
||||
|
||||
def __init__ (self):
|
||||
def __init__ (self, *a, **kw):
|
||||
|
||||
self.action_group = gtk.ActionGroup ("FilePropertiesActions")
|
||||
self.action_group.add_actions ([("show-file-properties", gtk.STOCK_PROPERTIES,
|
||||
|
|
|
@ -108,9 +108,9 @@ class FindBarWidget (gtk.HBox):
|
|||
|
||||
class FindBarFeature (FeatureBase):
|
||||
|
||||
def __init__ (self):
|
||||
def __init__ (self, app):
|
||||
|
||||
FeatureBase.__init__ (self)
|
||||
FeatureBase.__init__ (self, app)
|
||||
|
||||
self.matches = []
|
||||
|
||||
|
|
|
@ -153,6 +153,10 @@ class LevelDistributionSentinel (object):
|
|||
partitions = self.freq_sentinel.partitions
|
||||
counts = [0] * 6
|
||||
tree_iter = self.model.get_iter_first ()
|
||||
|
||||
if not partitions:
|
||||
return
|
||||
|
||||
while tree_iter:
|
||||
y -= 1
|
||||
if y == 0:
|
||||
|
@ -555,11 +559,15 @@ class TimelineWidget (gtk.DrawingArea):
|
|||
# FIXME:
|
||||
req.height = 64
|
||||
|
||||
class TimelineState (Common.GUI.StateSection):
|
||||
|
||||
_name = "timeline"
|
||||
|
||||
shown = Common.GUI.StateBool ("shown", default = True)
|
||||
|
||||
class TimelineFeature (FeatureBase):
|
||||
|
||||
state_section_name = "timeline"
|
||||
|
||||
def __init__ (self):
|
||||
def __init__ (self, app):
|
||||
|
||||
self.logger = logging.getLogger ("ui.timeline")
|
||||
|
||||
|
@ -567,6 +575,8 @@ class TimelineFeature (FeatureBase):
|
|||
self.action_group.add_toggle_actions ([("show-timeline",
|
||||
None, _("_Timeline"),)])
|
||||
|
||||
self.state = app.state.sections[TimelineState._name]
|
||||
|
||||
def handle_attach_window (self, window):
|
||||
|
||||
self.log_view = window.log_view
|
||||
|
@ -601,7 +611,7 @@ class TimelineFeature (FeatureBase):
|
|||
handler = self.handle_show_action_toggled
|
||||
action = self.action_group.get_action ("show-timeline")
|
||||
action.connect ("toggled", handler)
|
||||
action.activate ()
|
||||
action.props.active = self.state.shown
|
||||
|
||||
def handle_detach_window (self, window):
|
||||
|
||||
|
@ -672,9 +682,11 @@ class TimelineFeature (FeatureBase):
|
|||
if show:
|
||||
self.timeline.show ()
|
||||
self.vtimeline.show ()
|
||||
self.state.shown = True
|
||||
else:
|
||||
self.timeline.hide ()
|
||||
self.vtimeline.hide ()
|
||||
self.state.shown = False
|
||||
|
||||
def handle_timeline_button_press_event (self, widget, event):
|
||||
|
||||
|
@ -719,3 +731,8 @@ class TimelineFeature (FeatureBase):
|
|||
class Plugin (PluginBase):
|
||||
|
||||
features = [TimelineFeature]
|
||||
|
||||
def __init__ (self, app):
|
||||
|
||||
app.state.add_section_class (TimelineState)
|
||||
self.state = app.state.sections[TimelineState._name]
|
||||
|
|
|
@ -47,7 +47,9 @@ def _load_plugins (path):
|
|||
|
||||
class FeatureBase (object):
|
||||
|
||||
state_section_name = None
|
||||
def __init__ (self, app):
|
||||
|
||||
pass
|
||||
|
||||
def handle_attach_window (self, window):
|
||||
|
||||
|
@ -69,6 +71,7 @@ class PluginBase (object):
|
|||
|
||||
features = ()
|
||||
|
||||
def __init__ (self):
|
||||
def __init__ (self, app):
|
||||
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in a new issue