예제 #1
0
    def on_connect_button_toggled(self, widget):
        dialmanager = self.model.get_dialer_manager()

        if widget.get_active():
            # user wants to connect
            if not self.model.device:
                widget.set_active(False)
                show_warning_dialog(
                    _("No device found"),
                    _("No device has been found. Insert one and try again."))
                return


            profiles_model = self.model.preferences_model.profiles_model
            if not profiles_model.has_active_profile():
                widget.set_active(False)
                show_warning_dialog(
                    _("Profile needed"),
                    _("You need to create a profile for connecting."))
                self.ask_for_new_profile()
                return

            active_profile = profiles_model.get_active_profile()

            dialmanager.ActivateConnection(active_profile.profile_path,
                                           self.model.device_opath,
                                           timeout=40,
                                           reply_handler=self._on_connect_cb,
                                           error_handler=self._on_connect_eb)

            self._setup_connection_signals()

            def cancel_cb():
                self.view.set_disconnected()
                self.model.dial_path = None

            def stop_connection_attempt():
                self._ignore_no_reply = True
                dialmanager.StopConnection(self.model.device_opath,
                                           reply_handler=cancel_cb,
                                           error_handler=logger.error)

            self.apb = ActivityProgressBar(_("Connecting"), self)
            self.apb.set_cancel_cb(stop_connection_attempt)
            self.apb.init()
            logger.info("Connecting...")
        else:
            # user wants to disconnect
            if not self.model.dial_path:
                return

            self.apb = ActivityProgressBar(_("Disconnecting"), self,
                                           disable_cancel=True)
            dialmanager.DeactivateConnection(self.model.dial_path,
                                        reply_handler=self._on_disconnect_cb,
                                        error_handler=self._on_disconnect_eb)

            self.apb.init()
            self.model.dial_path = None
예제 #2
0
    def close_application(self, *args):
        if self.model.dial_path:
            show_warning_dialog(_("Can not close application"),
                               _("Can not close while a connection is active"))
            window = self.view.get_top_widget()
            try:
                window.emit_stop_by_name('delete_event')
            except IOError:
                pass

            return True
        else:
            self.view.start_throbber()
            self.model.quit(self._close_application_cb)
예제 #3
0
    def on_preferences_menu_item_activate(self, widget):
        from wader.gtk.views.preferences import PreferencesView
        from wader.gtk.controllers.preferences import PreferencesController

        view = PreferencesView()
        controller = PreferencesController(self.model.preferences_model, view,
                                           lambda: self.model.device)

        profiles_model = self.model.preferences_model.profiles_model
        if not profiles_model.has_active_profile():
            show_warning_dialog(
                _("Profile needed"),
                _("You need to create a profile to save preferences"))
            self.ask_for_new_profile()
            return
        view.show()
예제 #4
0
 def property_transfer_limit_exceeded_value_change(self, model, old, new):
     if not old and new:
         show_warning_dialog(_("Transfer limit exceeded"),
                             _("You have exceeded your transfer limit"))