diff options
author | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-14 19:31:02 -0500 |
---|---|---|
committer | Jesús Eduardo <heckyel@hyperbola.info> | 2018-01-14 19:31:02 -0500 |
commit | 990d76f7b38705eba89924b9b6404a2e7969730a (patch) | |
tree | c1b8a87b3b258bb6d8f0f721029a2b2c79192f50 | |
parent | 10251d991656d6a22f2f5124921b083afecedbba (diff) | |
download | librevideoconverter-990d76f7b38705eba89924b9b6404a2e7969730a.tar.lz librevideoconverter-990d76f7b38705eba89924b9b6404a2e7969730a.tar.xz librevideoconverter-990d76f7b38705eba89924b9b6404a2e7969730a.zip |
pep8 en lvc/widgets/gtk/customcontrols.py
-rw-r--r-- | lvc/widgets/gtk/customcontrols.py | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lvc/widgets/gtk/customcontrols.py b/lvc/widgets/gtk/customcontrols.py index ff5b068..16c7c4b 100644 --- a/lvc/widgets/gtk/customcontrols.py +++ b/lvc/widgets/gtk/customcontrols.py @@ -42,18 +42,20 @@ import wrappermap from .base import Widget from .simple import Label, Image from .drawing import (CustomDrawingMixin, Drawable, - ImageSurface) + ImageSurface) from lvc.widgets import widgetconst + class CustomControlMixin(CustomDrawingMixin): def do_expose_event(self, event): CustomDrawingMixin.do_expose_event(self, event) if self.is_focus(): style = self.get_style() style.paint_focus(self.window, self.state, - event.area, self, None, self.allocation.x, - self.allocation.y, self.allocation.width, - self.allocation.height) + event.area, self, None, self.allocation.x, + self.allocation.y, self.allocation.width, + self.allocation.height) + class CustomButtonWidget(CustomControlMixin, gtk.Button): def draw(self, wrapper, context): @@ -69,11 +71,13 @@ class CustomButtonWidget(CustomControlMixin, gtk.Button): def is_active(self): return self.state == gtk.STATE_ACTIVE + class ContinuousCustomButtonWidget(CustomButtonWidget): def is_active(self): return (self.state == gtk.STATE_ACTIVE or wrappermap.wrapper(self).button_down) + class DragableCustomButtonWidget(CustomButtonWidget): def __init__(self): CustomButtonWidget.__init__(self) @@ -99,7 +103,7 @@ class DragableCustomButtonWidget(CustomButtonWidget): wrappermap.wrapper(self).emit('dragged-right') self.last_drag_event = 'right' elif (self.last_drag_event != 'left' and - event.x < self.button_press_x - DRAG_THRESHOLD): + event.x < self.button_press_x - DRAG_THRESHOLD): wrappermap.wrapper(self).emit('dragged-left') self.last_drag_event = 'left' @@ -108,6 +112,7 @@ class DragableCustomButtonWidget(CustomButtonWidget): if self.last_drag_event is None: wrappermap.wrapper(self).emit('clicked') + class _DragInfo(object): """Info about the start of a drag. @@ -126,6 +131,7 @@ class _DragInfo(object): self.start_pos = start_pos self.click_pos = click_pos + class CustomScaleMixin(CustomControlMixin): def __init__(self): CustomControlMixin.__init__(self) @@ -238,7 +244,7 @@ class CustomScaleMixin(CustomControlMixin): elif event.direction == gtk.gdk.SCROLL_DOWN: event.direction = gtk.gdk.SCROLL_UP if (wrapper._scroll_step is not None and - event.direction in (gtk.gdk.SCROLL_UP, gtk.gdk.SCROLL_DOWN)): + event.direction in (gtk.gdk.SCROLL_UP, gtk.gdk.SCROLL_DOWN)): # handle the scroll ourself if event.direction == gtk.gdk.SCROLL_DOWN: delta = wrapper._scroll_step @@ -269,6 +275,7 @@ class CustomScaleMixin(CustomControlMixin): scroll = gtk.SCROLL_START return self.gtk_scale_class().do_move_slider(self, scroll) + class CustomHScaleWidget(CustomScaleMixin, gtk.HScale): def __init__(self): CustomScaleMixin.__init__(self) @@ -277,6 +284,7 @@ class CustomHScaleWidget(CustomScaleMixin, gtk.HScale): def is_horizontal(self): return True + class CustomVScaleWidget(CustomScaleMixin, gtk.VScale): def __init__(self): CustomScaleMixin.__init__(self) @@ -291,6 +299,7 @@ gobject.type_register(DragableCustomButtonWidget) gobject.type_register(CustomHScaleWidget) gobject.type_register(CustomVScaleWidget) + class CustomControlBase(Drawable, Widget): def __init__(self): Widget.__init__(self) @@ -301,12 +310,12 @@ class CustomControlBase(Drawable, Widget): def _connect_enter_notify_handlers(self): if self._entry_handlers is None: self._entry_handlers = [ - self.wrapped_widget_connect('enter-notify-event', - self.on_enter_notify), - self.wrapped_widget_connect('leave-notify-event', - self.on_leave_notify), - self.wrapped_widget_connect('button-release-event', - self.on_click) + self.wrapped_widget_connect('enter-notify-event', + self.on_enter_notify), + self.wrapped_widget_connect('leave-notify-event', + self.on_leave_notify), + self.wrapped_widget_connect('button-release-event', + self.on_click) ] def _disconnect_enter_notify_handlers(self): @@ -336,6 +345,7 @@ class CustomControlBase(Drawable, Widget): self.emit('clicked') return True + class CustomButton(CustomControlBase): def __init__(self): """Create a new CustomButton. active_image will be displayed while @@ -346,6 +356,7 @@ class CustomButton(CustomControlBase): self.create_signal('clicked') self.forward_signal('clicked') + class DragableCustomButton(CustomControlBase): def __init__(self): CustomControlBase.__init__(self) @@ -354,6 +365,7 @@ class DragableCustomButton(CustomControlBase): self.create_signal('dragged-left') self.create_signal('dragged-right') + class CustomSlider(CustomControlBase): def __init__(self): CustomControlBase.__init__(self) @@ -416,6 +428,7 @@ class CustomSlider(CustomControlBase): self._widget.set_increments(small_step, big_step) self._scroll_step = scroll_step + def to_miro_volume(value): """Convert from 0 to 1.0 to 0.0 to MAX_VOLUME. """ @@ -423,6 +436,7 @@ def to_miro_volume(value): return 0.0 return value * widgetconst.MAX_VOLUME + def to_gtk_volume(value): """Convert from 0.0 to MAX_VOLUME to 0 to 1.0. """ @@ -469,6 +483,7 @@ if hasattr(gtk.VolumeButton, "get_popup"): value = to_gtk_volume(value) self._widget.set_property('value', value) + class ClickableImageButton(CustomButton): """Image that can send clicked events. If max_width and/or max_height are specified, resizes the image proportionally such that all constraints are |