コード例 #1
0
	def __edit_selected(self, widget, data=None):
		"""Edit selected entry in keyring"""
		selection = self._list.get_selection()
		item_list, selected_iter = selection.get_selected()

		# show error if no entry is selected
		if selected_iter is None:
			dialog = gtk.MessageDialog(
									self._window,
									gtk.DIALOG_DESTROY_WITH_PARENT,
									gtk.MESSAGE_WARNING,
									gtk.BUTTONS_OK,
									_('Please select an entry to change!')
								)
			dialog.run()
			dialog.destroy()
			return True

		dialog = PasswordDialog(self._window)
		dialog.set_title(_('Change password'))
		dialog.set_label(_('Enter new password for selected keyring entry.'))

		response = dialog.get_response()

		if response[0] == gtk.RESPONSE_OK:
			if response[1] == response[2]:
				# passwords match, change value
				item_id = item_list.get_value(selected_iter, Column.ID)
				self._application.keyring_manager.change_secret(item_id, response[1])

				dialog = gtk.MessageDialog(
										self._window,
										gtk.DIALOG_DESTROY_WITH_PARENT,
										gtk.MESSAGE_INFO,
										gtk.BUTTONS_OK,
										_('Password was changed!')
									)
				dialog.run()
				dialog.destroy()

				# refresh list
				self.__populate_list()

			else:
				# passwords don't match, notify user
				dialog = gtk.MessageDialog(
										self._window,
										gtk.DIALOG_DESTROY_WITH_PARENT,
										gtk.MESSAGE_ERROR,
										gtk.BUTTONS_OK,
										_('Passwords do not match! Please try again.')
									)
				dialog.run()
				dialog.destroy()

		return True
コード例 #2
0
	def __edit_selected(self, widget, data=None):
		"""Edit selected entry in keyring"""
		selection = self._list.get_selection()
		item_list, selected_iter = selection.get_selected()

		# show error if no entry is selected
		if selected_iter is None:
			dialog = gtk.MessageDialog(
									self._window,
									gtk.DIALOG_DESTROY_WITH_PARENT,
									gtk.MESSAGE_WARNING,
									gtk.BUTTONS_OK,
									_('Please select an entry to change!')
								)
			dialog.run()
			dialog.destroy()
			return True

		dialog = PasswordDialog(self._window)
		dialog.set_title(_('Change password'))
		dialog.set_label(_('Enter new password for selected keyring entry.'))

		response = dialog.get_response()

		if response[0] == gtk.RESPONSE_OK:
			if response[1] == response[2]:
				# passwords match, change value
				item_id = item_list.get_value(selected_iter, Column.ID)
				self._application.keyring_manager.change_secret(item_id, response[1])

				dialog = gtk.MessageDialog(
										self._window,
										gtk.DIALOG_DESTROY_WITH_PARENT,
										gtk.MESSAGE_INFO,
										gtk.BUTTONS_OK,
										_('Password was changed!')
									)
				dialog.run()
				dialog.destroy()

				# refresh list
				self.__populate_list()

			else:
				# passwords don't match, notify user
				dialog = gtk.MessageDialog(
										self._window,
										gtk.DIALOG_DESTROY_WITH_PARENT,
										gtk.MESSAGE_ERROR,
										gtk.BUTTONS_OK,
										_('Passwords do not match! Please try again.')
									)
				dialog.run()
				dialog.destroy()

		return True
コード例 #3
0
ファイル: keyring.py プロジェクト: ulukyn/Sunflower
    def store_password(self,
                       entry,
                       password,
                       attributes=None,
                       entry_type=EntryType.GENERIC):
        """Create new entry in keyring with specified data"""
        assert self.is_available()

        # create a new keyring if it doesn't exist
        if not self.KEYRING_NAME in keyring.list_keyring_names_sync():
            dialog = PasswordDialog(self._application)
            dialog.set_title(_('New keyring'))
            dialog.set_label(
                _('We need to create a new keyring to safely '
                  'store your passwords. Choose the password you '
                  'want to use for it.'))

            response = dialog.get_response()

            if response[0] == gtk.RESPONSE_OK \
            and response[1] == response[2]:
                # create new keyring
                keyring.create_sync(self.KEYRING_NAME, response[1])
                self.__update_info()

            else:
                # wrong password
                raise KeyringCreateError('No keyring to store password to.')

        # if keyring is locked, try to unlock it
        if self.is_locked() and not self.__unlock_keyring():
            return False

        # store password to existing keyring
        keyring.item_create_sync(
            self.KEYRING_NAME,
            self.KEYRING_TYPE[entry_type],
            entry,
            attributes if attributes is not None else {},
            password,
            True  # update if exists
        )

        return True
コード例 #4
0
ファイル: keyring.py プロジェクト: SmokeyCosmy/Sunflower
	def store_password(self, entry, password, attributes=None, entry_type=EntryType.GENERIC):
		"""Create new entry in keyring with specified data"""
		assert self.is_available()

		# create a new keyring if it doesn't exist
		if not self.KEYRING_NAME in keyring.list_keyring_names_sync():
			dialog = PasswordDialog(self._application)
			dialog.set_title(_('New keyring'))
			dialog.set_label(_(
						'We need to create a new keyring to safely '
						'store your passwords. Choose the password you '
						'want to use for it.'
					))

			response = dialog.get_response()

			if response[0] == gtk.RESPONSE_OK \
			and response[1] == response[2]:
				# create new keyring
				keyring.create_sync(self.KEYRING_NAME, response[1])
				self.__update_info()

			else:
				# wrong password
				raise KeyringCreateError('No keyring to store password to.')

		# if keyring is locked, try to unlock it
		if self.is_locked() and not self.__unlock_keyring():
			return False 

		# store password to existing keyring
		keyring.item_create_sync(
					self.KEYRING_NAME,
					self.KEYRING_TYPE[entry_type],
					entry,
					attributes if attributes is not None else {},
					password,
					True  # update if exists
				)

		return True