+ def stepLengthButton_value_update():
+ if widget.height == 5:
+ l_unit = ["m", "ft"]
+ stepLengthButton.set_value("Custom value: %.2f %s" % (widget.step_length, l_unit[widget.unit]))
+ else:
+ h = [ ["< 1.50 m", "1.50 - 1.65 m", "1.66 - 1.80 m", "1.81 - 1.95 m", " > 1.95 m"],
+ ["< 5 ft", "5 - 5.5 ft", "5.5 - 6 ft", "6 - 6.5 ft", "> 6.5 ft"]]
+ str = "Using predefined value for height: %s" % h[widget.unit][widget.height]
+ stepLengthButton.set_value(str)
+
+ def stepLength_dialog(button):
+ def selectorH_changed(selector, data, dialog):
+ widget.height = selector.get_active(0)
+ widget.client.set_int(HEIGHT, widget.height)
+ widget.controller.set_height(widget.height)
+ stepLengthButton_value_update()
+
+ def manualButton_clicked(button, dialog):
+ dlg = gtk.Dialog()
+ dlg.set_title("Custom step length")
+ dlg.add_button("OK", gtk.RESPONSE_OK)
+
+ label = gtk.Label("Length")
+
+ entry = hildon.Entry(gtk.HILDON_SIZE_AUTO_WIDTH)
+ if widget.height == 5:
+ entry.set_text(str(widget.step_length))
+
+ labelSuffix = gtk.Label()
+ if widget.unit == 0:
+ labelSuffix.set_label("m")
+ else:
+ labelSuffix.set_label("ft")
+ hbox = gtk.HBox()
+ hbox.add(label)
+ hbox.add(entry)
+ hbox.add(labelSuffix)
+ dlg.vbox.add(hbox)
+ dlg.show_all()
+
+ while 1:
+ response = dlg.run()
+ if response != gtk.RESPONSE_OK:
+ break
+ try:
+ value = float(entry.get_text())
+ if value <= 0:
+ raise ValueError
+ self.controller.set_height(5, value)
+ self.client.set_int(HEIGHT, 5)
+ self.client.set_float(STEP_LENGTH, value)
+ widget.height = 5
+ widget.step_length = value
+ stepLengthButton_value_update()
+ break
+ except ValueError:
+ hildon.hildon_banner_show_information(self, "None", "Invalid length")
+ dlg.destroy()
+ dialog.destroy()
+
+ def heightButton_clicked(button, dialog):
+ dialog.destroy()
+
+ dialog = gtk.Dialog()
+ dialog.set_title("Step length")
+
+ manualButton = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ manualButton.set_title("Enter custom value")
+ manualButton.set_alignment(0, 0.8, 1, 1)
+ manualButton.connect("clicked", manualButton_clicked, dialog)
+
+ selectorH = hildon.TouchSelector(text=True)
+ selectorH.set_column_selection_mode(hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
+ selectorH.append_text("< 1.50 m")
+ selectorH.append_text("1.50 - 1.65 m")
+ selectorH.append_text("1.66 - 1.80 m")
+ selectorH.append_text("1.81 - 1.95 m")
+ selectorH.append_text(" > 1.95 m")
+
+ selectorH_English = hildon.TouchSelector(text=True)
+ selectorH_English.set_column_selection_mode(hildon.TOUCH_SELECTOR_SELECTION_MODE_SINGLE)
+ selectorH_English.append_text("< 5 ft")
+ selectorH_English.append_text("5 - 5.5 ft")
+ selectorH_English.append_text("5.5 - 6 ft")
+ selectorH_English.append_text("6 - 6.5 ft")
+ selectorH_English.append_text("> 6.5 ft")
+
+ heightPicker = hildon.PickerButton(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ heightPicker.set_alignment(0.0, 0.5, 1.0, 1.0)
+ heightPicker.set_title("Use predefined values for height")
+
+ if widget.height < 5:
+ heightPicker.set_active(widget.height)
+
+ if widget.unit == 0:
+ heightPicker.set_selector(selectorH)
+ else:
+ heightPicker.set_selector(selectorH_English)
+
+ if widget.height < 5:
+ heightPicker.set_active(widget.height)
+ heightPicker.get_selector().connect("changed", selectorH_changed, dialog)
+ heightPicker.connect("value-changed", heightButton_clicked, dialog)
+
+ dialog.vbox.add(heightPicker)
+ dialog.vbox.add(manualButton)
+ dialog.show_all()
+
+ if dialog.run() == gtk.RESPONSE_DELETE_EVENT:
+ dialog.destroy()
+