3535else :
3636 from .hal_widgets import _HalSpeedControlBase
3737
38+ from gladevcp .core import Status , Action
39+
3840class SpeedControl (Gtk .Box , _HalSpeedControlBase ):
3941 '''
4042 The SpeedControl Widget serves as a slider with button to increment od decrease
@@ -98,6 +100,8 @@ class SpeedControl(Gtk.Box, _HalSpeedControlBase):
98100 "%.1f" , GObject .ParamFlags .READWRITE | GObject .ParamFlags .CONSTRUCT ),
99101 'do_hide_button' : ( GObject .TYPE_BOOLEAN , 'Hide the button' , 'Display the button + and - to alter the values' ,
100102 False , GObject .ParamFlags .READWRITE | GObject .ParamFlags .CONSTRUCT ),
103+ 'type' : ( GObject .TYPE_INT , 'Type of adjustment' , 'Set to -1 for general, 0 for jograte' ,
104+ - 1 , 0 , - 1 , GObject .ParamFlags .READWRITE | GObject .ParamFlags .CONSTRUCT ),
101105 }
102106 __gproperties = __gproperties__
103107
@@ -112,6 +116,9 @@ class SpeedControl(Gtk.Box, _HalSpeedControlBase):
112116 def __init__ (self , size = 36 , value = 0 , min = 0 , max = 100 , inc_speed = 100 , unit = "" , color = "#FF8116" , template = "%.1f" ):
113117 super (SpeedControl , self ).__init__ ()
114118
119+ self ._action = Action ()
120+ self ._status = Status ()
121+
115122 # basic settings
116123 self ._size = size
117124 self ._value = value
@@ -123,6 +130,7 @@ def __init__(self, size = 36, value = 0, min = 0, max = 100, inc_speed = 100, un
123130 self ._increment = (self ._max - self ._min ) / 100.0
124131 self ._template = template
125132 self ._speed = inc_speed
133+ self .type_linear_jog = False
126134
127135 self .adjustment = Gtk .Adjustment (value = self ._value , lower = self ._min , upper = self ._max , step_increment = self ._increment , page_increment = 0 )
128136 self .adjustment .connect ("value_changed" , self ._on_value_changed )
@@ -175,6 +183,10 @@ def _hal_init(self):
175183 self .hal_pin_decrease = self .hal .newpin (self .hal_name + ".decrease" , hal .HAL_BIT , hal .HAL_IN )
176184 self .hal_pin_decrease .connect ("value-changed" , self ._on_minus_changed )
177185
186+ if self .type_linear_jog :
187+ print ('->>' ,self .type_linear_jog )
188+ self ._status .connect ('jograte-changed' , lambda w , data : self .set_value (data ))
189+
178190 # this draws our widget on the screen
179191 def expose (self , widget , event ):
180192 # create the cairo window
@@ -269,6 +281,9 @@ def get_value(self):
269281 # we are not sync, so
270282 def _on_value_changed (self , widget ):
271283 value = widget .get_value ()
284+ if self .type_linear_jog :
285+ self ._action .SET_JOG_RATE (value )
286+
272287 if value != self ._value :
273288 self ._value = value
274289 self .set_value (self ._value )
@@ -453,6 +468,10 @@ def do_set_property(self, property, value):
453468 self ._template = value
454469 if name == "do_hide_button" :
455470 self .hide_button (value )
471+ if name == "type" :
472+ print (name ,value )
473+ if value == 0 :
474+ self .type_linear_jog = True
456475 self ._draw_widget ()
457476 else :
458477 raise AttributeError ('unknown property %s' % property .name )
0 commit comments