[pitivi] utils: Combine set_children_state methods into one
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] utils: Combine set_children_state methods into one
- Date: Fri, 25 Feb 2022 07:12:27 +0000 (UTC)
commit 1a62b5c59bbebbf831c48ef28d0506423d535314
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Jan 23 19:35:16 2022 +0100
utils: Combine set_children_state methods into one
pitivi/timeline/elements.py | 4 ++--
pitivi/utils/ui.py | 15 +++------------
2 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 57f873dbd..78343f9fe 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -53,7 +53,7 @@ from pitivi.utils.timeline import Selected
from pitivi.utils.timeline import UNSELECT
from pitivi.utils.timeline import Zoomable
from pitivi.utils.ui import EFFECT_TARGET_ENTRY
-from pitivi.utils.ui import set_children_state_except
+from pitivi.utils.ui import set_children_state_recurse
from pitivi.utils.ui import unset_children_state_recurse
KEYFRAME_LINE_HEIGHT = 2
@@ -1416,7 +1416,7 @@ class Clip(Gtk.EventBox, Zoomable, Loggable):
if (event.type == Gdk.EventType.ENTER_NOTIFY and
event.mode == Gdk.CrossingMode.NORMAL and
not self.timeline.scrubbing):
- set_children_state_except(self, Gtk.StateFlags.PRELIGHT, Marker)
+ set_children_state_recurse(self, Gtk.StateFlags.PRELIGHT, ignored_classes=(Marker,))
for handle in self.handles:
handle.enlarge()
elif (event.type == Gdk.EventType.LEAVE_NOTIFY and
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index 56094139e..776e00542 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -869,25 +869,16 @@ def alter_style_class(style_class, target_widget, css_style):
css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
-def set_children_state_recurse(widget, state):
+def set_children_state_recurse(widget, state, ignored_classes=()):
"""Sets the provided state on all children of the given widget."""
widget.set_state_flags(state, False)
for child in widget.get_children():
- child.set_state_flags(state, False)
- if isinstance(child, Gtk.Container):
- set_children_state_recurse(child, state)
-
-
-def set_children_state_except(widget, state, *ignored_types):
- """Sets the provided state on all children of the widget, except those of given types."""
- widget.set_state_flags(state, False)
- for child in widget.get_children():
- if any(isinstance(child, klass) for klass in ignored_types):
+ if isinstance(child, ignored_classes):
continue
child.set_state_flags(state, False)
if isinstance(child, Gtk.Container):
- set_children_state_except(child, state, ignored_types)
+ set_children_state_recurse(child, state, ignored_classes)
def unset_children_state_recurse(widget, state):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]