def run(self): """Runs the dialog and updates the configuration.""" response = self.dialog.run() if response == gtk.RESPONSE_OK: # set new config self.newconfig['window.remember_size'] = \ self.remember_button.get_active() self.newconfig['preferences.use_weight_plan'] = \ self.use_plan_button.get_active() self.newconfig['preferences.use_bodyfat'] = \ self.use_bodyfat_button.get_active() self.newconfig['preferences.use_muscle'] = \ self.use_muscle_button.get_active() self.newconfig['preferences.use_water'] = \ self.use_water_button.get_active() self.newconfig['preferences.use_note'] = \ self.use_note_button.get_active() self.newconfig['preferences.use_calendar'] = \ self.use_calendar_button.get_active() parameters.config = self.newconfig # set new user height newheight1 = self.height_entry1.get_value() newheight2 = self.height_entry2.get_value() if self.newconfig['preferences.unit_system'] == 'metric': parameters.user.height = \ util.metric_to_height(newheight1, newheight2) else: parameters.user.height = \ util.imperial_to_height(newheight1, newheight2) self.dialog.hide()
def on_unit_change(self, widget, data): """Remembers the selected weight unit to be saved later.""" if widget.get_active(): if (data == 'metric' and self.newconfig['preferences.unit_system'] == 'imperial'): newheight1 = self.height_entry1.get_value() newheight2 = self.height_entry2.get_value() height_cm = util.imperial_to_height(newheight1, newheight2) self.set_metric(height_cm) elif (data == 'imperial' and self.newconfig['preferences.unit_system'] == 'metric'): newheight1 = self.height_entry1.get_value() newheight2 = self.height_entry2.get_value() height_cm = util.metric_to_height(newheight1, newheight2) self.set_imperial(height_cm) self.newconfig['preferences.unit_system'] = data