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