Пример #1
0
	def handle_queue_select(cls, widget, dialog):
		"""Handle changing operation queue or adding a new one."""
		selected_iter = widget.get_active_iter()
		if selected_iter is None:
			return False

		model = widget.get_model()
		option_type = model.get_value(selected_iter, cls.COLUMN_TYPE)

		# we handle only new option selection
		if option_type != cls.TYPE_NEW:
			return False

		# import locally to avoid circular imports
		from gui.input_dialog import InputDialog

		# create dialog
		dialog = InputDialog(dialog)
		dialog.set_title(_('New operation queue'))
		dialog.set_label(_('Enter name for new operation queue:'))

		# get response from the user
		response = dialog.get_response()

		if response[0] != gtk.RESPONSE_OK:
			widget.set_active(0)
			return False

		# make sure queue doesn't already exist
		if response[1] in cls._queue_list:
			dialog = gtk.MessageDialog(
									dialog,
									gtk.DIALOG_DESTROY_WITH_PARENT,
									gtk.MESSAGE_ERROR,
									gtk.BUTTONS_OK,
									_('Operation queue with specified name already exists.')
								)
			dialog.run()
			dialog.destroy()
			return False

		# select newly added queue
		cls._lock.acquire()
		cls._queue_list[response[1]] = Queue()
		cls._active_list[response[1]] = False
		cls._lock.release()
		cls.__update_list()

		queue_index = 0
		for index, row in enumerate(cls._list_store):
			if row[0] == response[1]:
				queue_index = index
				break

		widget.set_active(queue_index)

		return True
Пример #2
0
        def ask_password(operation, message, default_user, default_domain,
                         flags):
            # configure mount operation
            operation.set_domain(domain if domain is not None and domain != ''
                                 else default_domain)
            operation.set_username(username if username is not None
                                   and username != '' else default_user)

            if password is not None:
                # set password to stored one
                operation.set_password(password)
                operation.reply(gio.MOUNT_OPERATION_HANDLED)

            else:
                # we don't have stored password, ask user to provide one
                with gtk.gdk.lock:
                    dialog = InputDialog(self._application)
                    dialog.set_title(_('Mount operation'))
                    dialog.set_label(message)
                    dialog.set_password()

                    response = dialog.get_response()

                    if response[0] == gtk.RESPONSE_OK:
                        operation.set_password(response[1])
                        operation.reply(gio.MOUNT_OPERATION_HANDLED)
Пример #3
0
    def get_values_from_user(self, title, data, on_ok_clicked=None):
        """Gets values from user

        Args:
            title (str): Input dialog title
            data (list): List of dicts
            on_ok_clicked (method): Callback function to e.g. check the input
        Returns:
            list: List of values given by user, empty list if user canceled
        """
        input_dlg = InputDialog(self, title, data, on_ok_clicked)
        input_dlg.exec_()
        return input_dlg.get_data()
Пример #4
0
	def _add_path(self, widget, source):
		"""Add path to the list from specified source"""
		if source == Source.CUSTOM:
			# show dialog for custom path entry
			dialog = InputDialog(self._application)
			dialog.set_title(_('Add custom directory'))
			dialog.set_label(_('Full path:'))

			response = dialog.get_response()

			if response[0] == gtk.RESPONSE_OK:
				self._directory_store.append((response[1], False, False))

		else:
			# add path from notebook
			list_object = {
					Source.LEFT: self._application.get_left_object(),
					Source.RIGHT: self._application.get_right_object()
				}[source]

			path = list_object._options.get('path')

			if path is not None:
				self._directory_store.append((path, False, False))

		# enable save button
		self._parent.enable_save()

		return True
Пример #5
0
    def _add_always_visible(self, widget, data=None):
        """Add item name to the list of always visible files and directories."""
        # show dialog
        dialog = InputDialog(self._parent)
        dialog.set_title(_('Add always visible item'))
        dialog.set_label(_('Full name of file or directory to always show:'))

        response = dialog.get_response()

        # add data to the list
        if response[0] == gtk.RESPONSE_OK:
            self._always_visible_store.append((response[1], ))
            self._parent.enable_save()
Пример #6
0
	def _add_always_visible(self, widget, data=None):
		"""Add item name to the list of always visible files and directories."""
		# show dialog
		dialog = InputDialog(self._parent)
		dialog.set_title(_('Add always visible item'))
		dialog.set_label(_('Full name of file or directory to always show:'))

		response = dialog.get_response()

		# add data to the list
		if response[0] == gtk.RESPONSE_OK:
			self._always_visible_store.append((response[1],))
			self._parent.enable_save()
Пример #7
0
	def __unlock_keyring(self):
		"""Unlock keyring and schedule automatic lock"""
		result = False

		dialog = InputDialog(self._application)
		dialog.set_title(_('Unlock keyring'))
		dialog.set_label(_('Please enter your keyring password:'))
		dialog.set_password()

		response = dialog.get_response()

		if response[0] == gtk.RESPONSE_OK:
			# try to unlock keyring
			keyring.unlock_sync(self.KEYRING_NAME, response[1])

			# update status information
			self.__update_info()

			if not self.is_locked():
				# set timeout for automatic locking
				self.__reset_timeout()
				result = True

		return result
Пример #8
0
    def __add_mime_type(self, widget, data=None):
        """Show dialog for adding mime type"""
        dialog = InputDialog(self._application)
        dialog.set_title(_('Add mime type'))
        dialog.set_label(_('Enter MIME type (eg. image/png):'))

        response = dialog.get_response()

        # add new mime type to the table
        if response[0] == gtk.RESPONSE_OK:
            mime_type = response[1]
            description = self._application.associations_manager.get_mime_description(
                mime_type)

            # add item to the store
            self._associations.append(None, (description, mime_type))

            # enable save button on parent
            self._parent.enable_save()
Пример #9
0
		def ask_password(operation, message, default_user, default_domain, flags): 
			# configure mount operation
			operation.set_domain(domain if domain is not None and domain != '' else default_domain)
			operation.set_username(username if username is not None and username != '' else default_user)

			if password is not None:
				# set password to stored one
				operation.set_password(password)
				operation.reply(gio.MOUNT_OPERATION_HANDLED)

			else:
				# we don't have stored password, ask user to provide one
				with gtk.gdk.lock:
					dialog = InputDialog(self._application)
					dialog.set_title(_('Mount operation'))
					dialog.set_label(message)
					dialog.set_password()

					response = dialog.get_response()

					if response[0] == gtk.RESPONSE_OK:
						operation.set_password(response[1])
						operation.reply(gio.MOUNT_OPERATION_HANDLED)
Пример #10
0
	def __add_mime_type(self, widget, data=None):
		"""Show dialog for adding mime type"""
		dialog = InputDialog(self._application)
		dialog.set_title(_('Add mime type'))
		dialog.set_label(_('Enter MIME type (eg. image/png):'))

		response = dialog.get_response()

		# add new mime type to the table
		if response[0] == gtk.RESPONSE_OK:
			mime_type = response[1]
			description = self._application.associations_manager.get_mime_description(mime_type)

			# add item to the store
			self._associations.append(None, (description, mime_type))

			# enable save button on parent
			self._parent.enable_save()
Пример #11
0
    def handle_queue_select(cls, widget, dialog):
        """Handle changing operation queue or adding a new one."""
        selected_iter = widget.get_active_iter()
        if selected_iter is None:
            return False

        model = widget.get_model()
        option_type = model.get_value(selected_iter, cls.COLUMN_TYPE)

        # we handle only new option selection
        if option_type != cls.TYPE_NEW:
            return False

        # import locally to avoid circular imports
        from gui.input_dialog import InputDialog

        # create dialog
        dialog = InputDialog(dialog)
        dialog.set_title(_('New operation queue'))
        dialog.set_label(_('Enter name for new operation queue:'))

        # get response from the user
        response = dialog.get_response()

        if response[0] != gtk.RESPONSE_OK:
            widget.set_active(0)
            return False

        # make sure queue doesn't already exist
        if response[1] in cls._queue_list:
            dialog = gtk.MessageDialog(
                dialog, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
                gtk.BUTTONS_OK,
                _('Operation queue with specified name already exists.'))
            dialog.run()
            dialog.destroy()
            return False

        # select newly added queue
        cls._lock.acquire()
        cls._queue_list[response[1]] = Queue()
        cls._active_list[response[1]] = False
        cls._lock.release()
        cls.__update_list()

        queue_index = 0
        for index, row in enumerate(cls._list_store):
            if row[0] == response[1]:
                queue_index = index
                break

        widget.set_active(queue_index)

        return True