Example #1
0
    def save(self):
        '''saves the entered data and closes the app'''
        # Credentials
        self.keys.delete_credentials(self.creds.username)

        user = self.input_user.get_text()
        self.keys.set_credentials(user, self.input_password.get_text())

        settings_provider = account_settings_provider.create_settings_provider(
            user)
        # Mailboxes
        labels = []
        for label in self.wTree.get_object("entry_labels").get_text().split(
                ","):
            labels.append(label.strip())
        settings_provider.save_labels(labels)
        settings_provider.save_ignore_inbox(
            self.wTree.get_object("checkbutton_inbox").get_active())

        # ClickAction
        settings_provider.save_use_mail_client(
            self.wTree.get_object("radiobutton_openclient").get_active())

        # Port
        settings_provider.save_preferred_port(
            settings_provider.retrieve_preferred_port())

        # Soundfile
        if self.wTree.get_object("checkbutton_sound").get_active(
        ) and self.wTree.get_object("fcbutton_sound").get_filename():
            settings_provider.save_sound_enabled(True)
            settings_provider.save_sound_file(
                str(self.wTree.get_object("fcbutton_sound").get_filename()))
        else:
            settings_provider.save_sound_enabled(False)
Example #2
0
 def save(self):
     '''saves the entered data and closes the app'''
     # Credentials
     self.keys.delete_credentials(self.creds.username)
     
     user = self.input_user.get_text()
     self.keys.set_credentials(user,
                               self.input_password.get_text())
     
     settings_provider = account_settings_provider.create_settings_provider(user)
     # Mailboxes
     labels = []
     for label in self.wTree.get_object("entry_labels").get_text().split(","):
         labels.append(label.strip())
     settings_provider.save_labels(labels)
     settings_provider.save_ignore_inbox(self.wTree.get_object("checkbutton_inbox").get_active())
     
     # ClickAction
     settings_provider.save_use_mail_client(self.wTree.get_object("radiobutton_openclient").get_active())
     
     # Port
     settings_provider.save_preferred_port(settings_provider.retrieve_preferred_port())
     
     # Soundfile
     if self.wTree.get_object("checkbutton_sound").get_active() and self.wTree.get_object("fcbutton_sound").get_filename():
         settings_provider.save_sound_enabled(True)
         settings_provider.save_sound_file(str(self.wTree.get_object("fcbutton_sound").get_filename()))
     else:
         settings_provider.save_sound_enabled(False)
Example #3
0
    def init_window(self, parent):
        if os.path.exists("gm-config.ui"):
            builder_file = "gm-config.ui"
        elif os.path.exists("/usr/local/share/gm-notify/gm-config.ui"):
            builder_file = "/usr/local/share/gm-notify/gm-config.ui"
        elif os.path.exists("/usr/share/gm-notify/gm-config.ui"):
            builder_file = "/usr/share/gm-notify/gm-config.ui"

        self.wTree = Gtk.Builder.new()
        self.wTree.add_from_file(builder_file)
        self.wTree.set_translation_domain("gm-notify")
        self.window = self.wTree.get_object("gmnotify_add_account")

        self.window.set_transient_for(parent)
        self.window.set_modal(True)
        self.window.set_destroy_with_parent(True)

        self.window.show_all()

        self.wTree.get_object("notebook_main").set_current_page(0)

        self.input_user = self.wTree.get_object("input_user")
        self.input_password = self.wTree.get_object("input_password")
        self.image_credentials = self.wTree.get_object("image_credentials")
        self.label_credentials = self.wTree.get_object("label_credentials")
        self.button_apply = self.wTree.get_object("button_apply")

        self.window.connect("delete_event", self.close)
        self.wTree.get_object("button_close").connect("clicked", self.close)
        self.button_apply.connect("clicked", self.apply)
        self.input_password.connect("focus-out-event", self.check_credentials)
        self.input_user.connect("focus-out-event", self.check_user)
        self.wTree.get_object("checkbutton_sound").connect(
            "toggled", self.on_checkbutton_sound_toggled)

        #####
        # Init with stored values
        #####

        # Credentials

        settings_provider = account_settings_provider.create_settings_provider(
            self.creds.username)

        if self.creds.username:
            self.input_user.set_text(self.creds.username)
            self.input_user.set_sensitive(False)

        self.input_password.set_text(self.creds.password)

        self.api = MailChecker("", "", settings_provider)
        self.api.setOnAuthSucceeded(self.credentials_valid)
        self.api.setOnAuthFailed(self.credentials_invalid)
        self.api.setOnConnectionErrorCB(self.connection_error)

        self.check_credentials(None, None)

        # Sound
        self.wTree.get_object("checkbutton_sound").set_active(
            settings_provider.retrieve_sound_enabled())
        sound_file = settings_provider.retrieve_sound_file()
        if sound_file:
            self.wTree.get_object("fcbutton_sound").set_filename(sound_file)
        self.on_checkbutton_sound_toggled(
            self.wTree.get_object("checkbutton_sound"))

        # ClickAction
        if settings_provider.retrieve_use_mail_client():
            self.wTree.get_object("radiobutton_openclient").set_active(True)
        else:
            self.wTree.get_object("radiobutton_openweb").set_active(True)

        # Mailboxes
        self.wTree.get_object("checkbutton_inbox").set_active(
            settings_provider.retrieve_ignore_inbox())
        labels = settings_provider.retrieve_labels()
        self.wTree.get_object("entry_labels").set_text(", ".join(labels))

        return self.window
Example #4
0
    def init_window(self, parent):
        if os.path.exists("gm-config.ui"):
            builder_file = "gm-config.ui"
        elif os.path.exists("/usr/local/share/gm-notify/gm-config.ui"):
            builder_file = "/usr/local/share/gm-notify/gm-config.ui"
        elif os.path.exists("/usr/share/gm-notify/gm-config.ui"):
            builder_file = "/usr/share/gm-notify/gm-config.ui"

        self.wTree = Gtk.Builder.new()
        self.wTree.add_from_file(builder_file)
        self.wTree.set_translation_domain("gm-notify")
        self.window = self.wTree.get_object("gmnotify_add_account")

        self.window.set_transient_for(parent)
        self.window.set_modal(True)
        self.window.set_destroy_with_parent(True)
        
        self.window.show_all()

        self.wTree.get_object("notebook_main").set_current_page(0)
        
        self.input_user = self.wTree.get_object("input_user")
        self.input_password = self.wTree.get_object("input_password")
        self.image_credentials = self.wTree.get_object("image_credentials")
        self.label_credentials = self.wTree.get_object("label_credentials")
        self.button_apply = self.wTree.get_object("button_apply")

        self.window.connect("delete_event", self.close)
        self.wTree.get_object("button_close").connect("clicked", self.close)
        self.button_apply.connect("clicked", self.apply)
        self.input_password.connect("focus-out-event", self.check_credentials)
        self.input_user.connect("focus-out-event", self.check_user)
        self.wTree.get_object("checkbutton_sound").connect("toggled", self.on_checkbutton_sound_toggled)

        #####
        # Init with stored values
        #####
        
        # Credentials

        settings_provider = account_settings_provider.create_settings_provider(self.creds.username)

        if self.creds.username:
            self.input_user.set_text(self.creds.username)
            self.input_user.set_sensitive(False)
            
        self.input_password.set_text(self.creds.password)
         
        self.api = MailChecker("", "", settings_provider)
        self.api.setOnAuthSucceeded(self.credentials_valid)
        self.api.setOnAuthFailed(self.credentials_invalid)
        self.api.setOnConnectionErrorCB(self.connection_error)

        self.check_credentials(None, None)

        # Sound
        self.wTree.get_object("checkbutton_sound").set_active(settings_provider.retrieve_sound_enabled())
        sound_file = settings_provider.retrieve_sound_file()
        if sound_file:
            self.wTree.get_object("fcbutton_sound").set_filename(sound_file)
        self.on_checkbutton_sound_toggled(self.wTree.get_object("checkbutton_sound"))
         
        # ClickAction
        if settings_provider.retrieve_use_mail_client():
            self.wTree.get_object("radiobutton_openclient").set_active(True)
        else:
            self.wTree.get_object("radiobutton_openweb").set_active(True)
         
        # Mailboxes
        self.wTree.get_object("checkbutton_inbox").set_active(settings_provider.retrieve_ignore_inbox())
        labels = settings_provider.retrieve_labels()
        self.wTree.get_object("entry_labels").set_text(", ".join(labels))

        return self.window