+ def sensitivity_dialog(button):
+ def seekbar_changed(seekbar):
+ label.set_text(str(seekbar.get_position()) + " %")
+
+ dialog = gtk.Dialog("Sensitivity", self.dialog)
+ dialog.add_button("OK", gtk.RESPONSE_OK)
+ seekbar = hildon.Seekbar()
+ seekbar.set_size_request(400, -1)
+ seekbar.set_total_time(200)
+ seekbar.set_position(self.config.get_sensitivity())
+ seekbar.connect("value-changed", seekbar_changed)
+
+ hbox = gtk.HBox()
+ hbox.add(seekbar)
+ label = gtk.Label(str(self.config.get_sensitivity()) + " %")
+ label.set_size_request(30, -1)
+ hbox.add(label)
+
+ dialog.vbox.add(hbox)
+ dialog.show_all()
+
+ if dialog.run() == gtk.RESPONSE_OK:
+ value = seekbar.get_position()
+ self.config.set_sensitivity(value)
+ button.set_value(str(value) + " %")
+
+ dialog.destroy()
+
+ def stepLengthButton_value_update():
+ if self.config.get_height() == 5:
+ l_unit = ["m", "ft"]
+ stepLengthButton.set_value("Custom value: %.2f %s" % (self.config.get_step_length(), l_unit[self.config.get_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[self.config.get_unit()][self.config.get_height()]
+ stepLengthButton.set_value(str)
+
+ def stepLength_dialog(button):
+ def selectorH_changed(selector, data, dialog):
+ height = selector.get_active(0)
+ self.config.set_height(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 self.config.get_height() == 5:
+ entry.set_text(str(self.config.get_step_length()))
+
+ labelSuffix = gtk.Label()
+ if self.config.get_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.config.set_step_length(value)
+ self.config.set_height(5)
+ 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")
+
+
+ unit = self.config.get_unit()
+ if unit == 0:
+ heightPicker.set_selector(selectorH)
+ else:
+ heightPicker.set_selector(selectorH_English)
+
+ height = self.config.get_height()
+ if height < 5:
+ heightPicker.set_active(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()
+
+ def donateButton_clicked(button, dialog):
+ url = "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=BKE6E9SLK7NP4&lc=RO&item_name=Pedometer%20Widget¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"
+ command = "dbus-send --system --type=method_call --dest=\"com.nokia.osso_browser\" --print-reply /com/nokia/osso_browser/request com.nokia.osso_browser.load_url string:\"%s\"" % url
+ os.system(command)
+