[pitivi] Disable scroll on widgets in scrollable container
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Disable scroll on widgets in scrollable container
- Date: Fri, 22 Jan 2021 21:36:14 +0000 (UTC)
commit 31c8fa782b38b51bbe5d59d051b7470d9bfc6f82
Author: Aitik Gupta <aitikgupta gmail com>
Date: Fri Jan 22 20:42:21 2021 +0530
Disable scroll on widgets in scrollable container
Fixes #2495
pitivi/clipproperties.py | 3 ++-
pitivi/effects.py | 4 +++-
pitivi/utils/ui.py | 18 +++++++++++++-----
pitivi/utils/widgets.py | 14 ++++++--------
4 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index c714f0bf4..6daa1a22b 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -107,6 +107,8 @@ class ClipProperties(Gtk.ScrolledWindow, Loggable):
self.helper_box = self.create_helper_box()
self.clips_box.pack_start(self.helper_box, False, False, 0)
+ disable_scroll(vbox)
+
self.transformation_expander.set_source(None)
self.title_expander.set_source(None)
self.color_expander.set_source(None)
@@ -841,7 +843,6 @@ class TransformationProperties(Gtk.Expander, Loggable):
spinbtn = self.builder.get_object(widget_name)
handler_id = spinbtn.connect(
"value-changed", self._on_value_changed_cb, property_name)
- disable_scroll(spinbtn)
self.spin_buttons[property_name] = spinbtn
self.spin_buttons_handler_ids[property_name] = handler_id
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 2cfb5bc87..0c1749e21 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -46,6 +46,7 @@ from pitivi.configure import get_pixmap_dir
from pitivi.configure import get_ui_dir
from pitivi.settings import GlobalSettings
from pitivi.utils.loggable import Loggable
+from pitivi.utils.ui import disable_scroll
from pitivi.utils.ui import EFFECT_TARGET_ENTRY
from pitivi.utils.ui import PADDING
from pitivi.utils.ui import SPACING
@@ -720,7 +721,8 @@ class EffectsPropertiesManager(GObject.Object, Loggable):
"""Creates a widget if the `create_widget` handlers did not."""
effect_name = effect.get_property("bin-description")
self.log('UI is being auto-generated for "%s"', effect_name)
- effect_widget.add_widgets(create_property_widget=self.create_property_widget, with_reset_button=True)
+ effect_widget.add_widgets(create_property_widget_func=self.create_property_widget,
with_reset_button=True)
+ disable_scroll(effect_widget)
self._post_configuration(effect, effect_widget)
def do_create_property_widget(self, effect_widget, effect, prop, prop_value):
diff --git a/pitivi/utils/ui.py b/pitivi/utils/ui.py
index 35e472de3..ef59cc3ce 100644
--- a/pitivi/utils/ui.py
+++ b/pitivi/utils/ui.py
@@ -844,13 +844,21 @@ def unset_children_state_recurse(widget, state):
unset_children_state_recurse(child, state)
+def disable_scroll_event_cb(widget, unused_event):
+ GObject.signal_stop_emission_by_name(widget, "scroll-event")
+ return False
+
+
def disable_scroll(widget):
- """Makes sure the specified widget does not react to scroll events."""
- def scroll_event_cb(widget, unused_event):
- GObject.signal_stop_emission_by_name(widget, "scroll-event")
- return False
+ """Disables scrolling on the specified widget and its children recursively.
+
+ Makes sure the vulnerable widgets do not react to scroll events.
+ """
+ if isinstance(widget, Gtk.Container):
+ widget.foreach(disable_scroll)
- widget.connect("scroll-event", scroll_event_cb)
+ if isinstance(widget, (Gtk.ComboBox, Gtk.Scale, Gtk.SpinButton)):
+ widget.connect("scroll-event", disable_scroll_event_cb)
def fix_infobar(infobar):
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 8581e8a8b..7aec460dd 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -121,7 +121,6 @@ class TextWidget(Gtk.Box, DynamicWidget):
self.combo = Gtk.ComboBoxText.new_with_entry()
self.text = self.combo.get_child()
self.combo.show()
- disable_scroll(self.combo)
self.pack_start(self.combo, expand=False, fill=False, padding=0)
for choice in choices:
self.combo.append_text(choice)
@@ -247,7 +246,6 @@ class NumericWidget(Gtk.Box, DynamicWidget):
Gtk.Orientation.HORIZONTAL, self.adjustment)
self.pack_start(self.slider, expand=False, fill=False, padding=0)
self.slider.show()
- disable_scroll(self.slider)
self.slider.set_size_request(width=100, height=-1)
self.slider.props.draw_value = False
# Abuse GTK3's progressbar "fill level" feature to provide
@@ -257,8 +255,6 @@ class NumericWidget(Gtk.Box, DynamicWidget):
self.slider.set_fill_level(float(default))
self.slider.set_show_fill_level(True)
- disable_scroll(self.spinner)
-
def block_signals(self):
if self.handler_id:
self.adjustment.handler_block(self.handler_id)
@@ -484,7 +480,6 @@ class ChoiceWidget(Gtk.Box, DynamicWidget):
self.pack_start(self.contents, expand=False, fill=False, padding=0)
self.set_choices(choices)
self.contents.show()
- disable_scroll(self.contents)
cell = self.contents.get_cells()[0]
cell.props.ellipsize = Pango.EllipsizeMode.END
@@ -702,6 +697,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
def show_widget(self, widget):
self.pack_start(widget, True, True, 0)
+ disable_scroll(widget)
self.show_all()
def map_builder(self, builder):
@@ -807,7 +803,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
grid.attach(label, 0, y, 1, 1)
grid.attach(widget, 1, y, 1, 1)
- def add_widgets(self, create_property_widget, values=None, with_reset_button=False, caps_values=None):
+ def add_widgets(self, create_property_widget_func, values=None, with_reset_button=False,
caps_values=None):
"""Prepares a Gtk.Grid containing the property widgets of an element.
Each property is on a separate row.
@@ -816,7 +812,8 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
If there are no properties, returns a "No properties" label.
Args:
- create_property_widget (function): The function that creates the widget for an effect property.
+ create_property_widget_func (function): The function that creates
+ the widget for an effect property.
values (dict): The current values of the element props, by name.
If empty, the default values will be used.
with_reset_button (bool): Whether to show a reset button for each
@@ -889,7 +886,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
else:
prop_value = values[prop.name]
- prop_widget = create_property_widget(self, prop, prop_value)
+ prop_widget = create_property_widget_func(self, prop, prop_value)
element_name = None
if isinstance(self.element, Gst.Element):
element_name = self.element.get_factory().get_name()
@@ -1162,6 +1159,7 @@ class GstElementSettingsDialog(Loggable):
with_reset_button=True,
values=properties,
caps_values=caps_values)
+ disable_scroll(self.elementsettings)
# Try to avoid scrolling, whenever possible.
screen_height = self.window.get_screen().get_height()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]