Example #1
0
 def on_ok_button_clicked(self, widget):
     pin = self.view['pin_entry'].get_text()
     if pin:
         # save keyring preferences
         from vmc.common.config import config
         active = self.view['gnomekeyring_checkbutton'].get_active()
         config.setboolean('preferences', 'manage_keyring', active)
         config.write()
         
         # callback the PIN to the state machine
         self.deferred.callback(pin)
         
         self.view.hide()
         self.model.unregister_observer(self)
    def on_preferences_ok_button_clicked(self, widget):
        # first page
        if self.view['custom_profile_checkbutton'].get_active():
            # get combobox option
            profile = self.get_selected_dialer_profile()
            config.current_profile.set('connection', 'dialer_profile',
                                       profile.name)
        else:
            # use default profile
            config.current_profile.set('connection', 'dialer_profile',
                                       'default')

        config.current_profile.write()

        # second page
        exit_without_confirmation = \
            self.view['exit_without_confirmation_checkbutton'].get_active()
        minimize_to_tray = self.view['close_window_checkbutton'].get_active()
        show_icon = self.view['show_icon_checkbutton'].get_active()
        manage_keyring = self.view['gnomekeyring_checkbutton'].get_active()

        config.setboolean('preferences', 'exit_without_confirmation',
                          exit_without_confirmation)
        config.setboolean('preferences', 'show_icon', show_icon)
        config.setboolean('preferences', 'close_minimizes', minimize_to_tray)
        config.setboolean('preferences', 'manage_keyring', manage_keyring)

        # third page
        model = self.view['browser_combobox'].get_model()
        iter = self.view['browser_combobox'].get_active_iter()
        browser_opt = model.get_value(iter, 0)

        if browser_opt == 'xdg-open':
            config.set('preferences', 'browser', browser_opt)
        else:
            browser_binary = self.view['browser_entry'].get_text()
            if not browser_binary:
                return

            config.set('preferences', 'browser', browser_binary)

        model = self.view['mail_combobox'].get_model()
        iter = self.view['mail_combobox'].get_active_iter()
        mail_opt = model.get_value(iter, 0)

        if mail_opt == 'xdg-email':
            config.set('preferences', 'mail', mail_opt)
        else:
            mail_binary = self.view['mail_entry'].get_text()
            if not mail_binary:
                return

            config.set('preferences', 'mail', mail_binary)

        # fourth page
        #XXX: To Current Profile if any?
        max_traffic = self.view['maximum_traffic_entry'].get_value()
        threshold = self.view['threshold_entry'].get_value()
        usage_notification = self.view['usage_notification_check'].get_active()
        config.set('preferences', 'max_traffic', str(int(max_traffic)))
        config.set('preferences', 'traffic_threshold', str(int(threshold)))
        config.setboolean('preferences', 'usage_notification',
                          usage_notification)

        config.write()

        self._hide_ourselves()
    def on_preferences_ok_button_clicked(self, widget):
        # first page
        if self.view['custom_profile_checkbutton'].get_active():
            # get combobox option
            profile = self.get_selected_dialer_profile()
            config.current_profile.set('connection',
                                       'dialer_profile', profile.name)
        else:
            # use default profile
            config.current_profile.set('connection',
                                       'dialer_profile', 'default')
        
        config.current_profile.write()
        
        # second page
        exit_without_confirmation = \
            self.view['exit_without_confirmation_checkbutton'].get_active()
        minimize_to_tray = self.view['close_window_checkbutton'].get_active()
        show_icon = self.view['show_icon_checkbutton'].get_active()
        manage_keyring = self.view['gnomekeyring_checkbutton'].get_active()
        
        config.setboolean('preferences', 'exit_without_confirmation',
                        exit_without_confirmation)
        config.setboolean('preferences', 'show_icon', show_icon)
        config.setboolean('preferences', 'close_minimizes', minimize_to_tray)
        config.setboolean('preferences', 'manage_keyring', manage_keyring)
        
        # third page
        model = self.view['browser_combobox'].get_model()
        iter = self.view['browser_combobox'].get_active_iter()
        browser_opt = model.get_value(iter, 0)
        
        if browser_opt == 'xdg-open':
            config.set('preferences', 'browser', browser_opt)
        else:
            browser_binary = self.view['browser_entry'].get_text()
            if not browser_binary:
                return
            
            config.set('preferences', 'browser', browser_binary)
        
        model = self.view['mail_combobox'].get_model()
        iter = self.view['mail_combobox'].get_active_iter()
        mail_opt = model.get_value(iter, 0)
        
        if mail_opt == 'xdg-email':
            config.set('preferences', 'mail', mail_opt)
        else:
            mail_binary = self.view['mail_entry'].get_text()
            if not mail_binary:
                return
            
            config.set('preferences', 'mail', mail_binary)

        # fourth page
        #XXX: To Current Profile if any?
        max_traffic = self.view['maximum_traffic_entry'].get_value()
        threshold = self.view['threshold_entry'].get_value()
        usage_notification = self.view['usage_notification_check'].get_active()
        config.set('preferences', 'max_traffic', str(int(max_traffic)))
        config.set('preferences', 'traffic_threshold', str(int(threshold)))
        config.setboolean('preferences', 'usage_notification', usage_notification)

        config.write()
        
        self._hide_ourselves()