operations

package
v0.0.0-...-9514eed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2016 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpCut  = "cut"
	OpCopy = "copy"
)
View Source
const (
	ErrorInvalidFileName = -1 - iota
	ErrorSameFileName
	ErrorStatFileFailed
	ErrorSaveFileFailed
	ErrorReadFileFailed
)
View Source
const (
	ErrorInvalidSignalName = iota
	ErrorSignalNotFound
	ErrorNoMonitor
)

Variables

View Source
var NTr = gettext.NTr

Tr is a alias for gettext.Tr, which avoids to use dot import.

Functions

func CanPaste

func CanPaste(file string) bool

func CanPasteClipboardContent

func CanPasteClipboardContent() bool

func CanPasteInto

func CanPasteInto(file string) bool

func ClearClipboard

func ClearClipboard()

func CopyTag

func CopyTag() string

func CopyTagFmt

func CopyTagFmt() string

func CopyToClipboard

func CopyToClipboard(files []string)

func CutToClipboard

func CutToClipboard(files []string)

func DirIsParentOf

func DirIsParentOf(root *gio.File, child *gio.File) bool

DirIsParentOf checks whether the root is the parent directory of child.

func FilenameGetExtensionOffset

func FilenameGetExtensionOffset(name string) int

FilenameGetExtensionOffset is a C function wrap which return the offset of the extension.

func FilenameStripExtension

func FilenameStripExtension(name string) string

FilenameStripExtension returns the basename without extension name.

func GIconGetThemeIconForApp

func GIconGetThemeIconForApp(icon *gio.Icon, size int) string

GIconGetThemeIconForApp returns the icon for application.

func GIconGetThemeIconForFile

func GIconGetThemeIconForFile(icon *gio.Icon, size int) string

GIconGetThemeIconForFile returns the icon for normal files.

func GetClipboardContents

func GetClipboardContents() []string

func GetGIconForApp

func GetGIconForApp(filePath string) *gio.Icon

GetGIconForApp get gio.Icon for application. @param filePath app's filepath.

func GetGIconForFile

func GetGIconForFile(filePath string) *gio.Icon

GetGIconForFile gets gio.Icon for file. @param filePath is file's path

func GetIconName

func GetIconName(filePath string) string

GetIconName gets icon for app or file. @param filePath path for app or file.

func GetLanguageNames

func GetLanguageNames() []string

GetLanguageNames returns all language names.

func GetLocaleVariants

func GetLocaleVariants(locale string) []string

GetLocaleVariants returns locale variants

func GetThemeIcon

func GetThemeIcon(iconStr string, size int) string

GetThemeIcon returns full path for icon. @param iconStr can be uri or path of files, or the icon name. @param size is the expected size of icon.

func GetThemeIconForFile

func GetThemeIconForFile(file string, size int) string

func GetThemeIconFromIconName

func GetThemeIconFromIconName(iconName string, size int) string

GetThemeIconFromIconName returns icon from icon name.

func HasFsID

func HasFsID(file *gio.File, expectedID string) bool

HasFsID checks whether the file has the expected filesystem ID.

func MakeNextDuplicateName

func MakeNextDuplicateName(namebase string, suffix string, count int, maxLength int) (newName string)

func ParsePreviousDuplicateName

func ParsePreviousDuplicateName(name string) (namebase string, suffix string, count int)

func ShortenUtf8String

func ShortenUtf8String(str string, reduceByNumBytes int) string

ShortenUtf8String shortens a utf8 string according to the reduceByNumBytes.

Types

type AmountUnit

type AmountUnit uint16

AmountUnit indicates which unit is used for amount. Bytes, Files, Directories

const (
	AmountUnitBytes AmountUnit = iota
	AmountUnitFiles
	AmountUnitDirectories
	AmountUnitSumOfFilesAndDirs = AmountUnitBytes // using Bytes as the sum of files and directories when it's useless.
)

The AmountUnit

type ChmodJob

type ChmodJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

ChmodJob change the mode of a file/directory.

func NewChmodJob

func NewChmodJob(uri string, permission uint32) *ChmodJob

NewChmodJob creates a new ChmodJob.

func (*ChmodJob) Execute

func (job *ChmodJob) Execute()

Execute the ChmodJob.

type ChownJob

type ChownJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

ChownJob changes the owner or group of a file or directory.

func NewChownJob

func NewChownJob(uri string, newOwner string, newGroup string) *ChownJob

NewChownJob creates a new ChownJob.

func (*ChownJob) Execute

func (job *ChownJob) Execute()

Execute ChownJob.

type CommandRecorder

type CommandRecorder struct {
}

type CommandType

type CommandType int32
const (
	CommandCopy CommandType = iota
	CommandMove
	CommandRename
	CommandLink
	CommandMkdir
	CommandTrash
	CommandPut
)

TODO: compact command type

type CommonJob

type CommonJob struct {
	*SignalManager
	// contains filtered or unexported fields
}

CommonJob is the base data field of real job.

func (*CommonJob) Abort

func (job *CommonJob) Abort()

Abort the job, Finalize will not be called.

func (*CommonJob) GetError

func (job *CommonJob) GetError() error

func (*CommonJob) HasError

func (job *CommonJob) HasError() bool

func (*CommonJob) ListenAborted

func (job *CommonJob) ListenAborted(fn func()) (func(), error)

func (*CommonJob) ListenDone

func (job *CommonJob) ListenDone(fn func(error)) (func(), error)

func (*CommonJob) ListenPercent

func (job *CommonJob) ListenPercent(fn func(int64)) (func(), error)

func (*CommonJob) ListenProcessedAmount

func (job *CommonJob) ListenProcessedAmount(fn func(amount int64, unit AmountUnit)) (func(), error)

ListenProcessedAmount adds observers to processed-amount signal.

func (*CommonJob) ListenSpeed

func (job *CommonJob) ListenSpeed(fn func(uint64)) (func(), error)

func (*CommonJob) ListenTotalAmount

func (job *CommonJob) ListenTotalAmount(fn func(int64, AmountUnit)) (func(), error)

func (*CommonJob) Result

func (job *CommonJob) Result() interface{}

func (*CommonJob) UI

func (job *CommonJob) UI() IUIDelegate

UI returns the uiDelegate.

type CopyMoveJob

type CopyMoveJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

CopyMoveJob copy or move the files or directories

func NewCopyJob

func NewCopyJob(srcURLs []string, destDirURL string, targetName string, flags gio.FileCopyFlags, uiDelegate IUIDelegate) *CopyMoveJob

NewCopyJob creates a copy job.

func NewMoveJob

func NewMoveJob(srcURLs []string, destDirURL string, targetName string, flags gio.FileCopyFlags, uiDelegate IUIDelegate) *CopyMoveJob

NewMoveJob creates a move job.

func (*CopyMoveJob) Execute

func (job *CopyMoveJob) Execute()

Execute a move job or a copy job.

func (*CopyMoveJob) ListenCopying

func (job *CopyMoveJob) ListenCopying(fn func(string)) (func(), error)

func (*CopyMoveJob) ListenCopyingMovingDone

func (job *CopyMoveJob) ListenCopyingMovingDone(fn func(string, string)) (func(), error)

func (*CopyMoveJob) ListenCreatingDir

func (job *CopyMoveJob) ListenCreatingDir(fn func(string)) (func(), error)

func (*CopyMoveJob) ListenMoving

func (job *CopyMoveJob) ListenMoving(fn func(string)) (func(), error)

type CreateJob

type CreateJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

CreateJob is used to create file, directory or symbol link. The uri of created file will be returned.

func NewCreateDirectoryJob

func NewCreateDirectoryJob(destDirURL string, dirname string, uiDelegate IUIDelegate) *CreateJob

NewCreateDirectoryJob creates directory @param destURL: parent dir which contains the new directory.

func NewCreateFileFromTemplateJob

func NewCreateFileFromTemplateJob(destDirURL string, templateURL string, uiDelegate IUIDelegate) *CreateJob

NewCreateFileFromTemplateJob creates new file from template. @param destURL: parent dir which contains the new directory.

func NewCreateFileJob

func NewCreateFileJob(destDirURL string, filename string, initContent []byte, uiDelegate IUIDelegate) *CreateJob

NewCreateFileJob is used to create a new file. @param destURL: parent dir which contains the new directory.

func NewCreateLinkJob

func NewCreateLinkJob(srcURL string, destDirURL string, uiDelegate IUIDelegate) *CreateJob

NewCreateLinkJob creates symbol link.

func (*CreateJob) Execute

func (job *CreateJob) Execute() error

Execute create job

type DeleteJob

type DeleteJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

DeleteJob delete or trash files/directories.

func NewDeleteJob

func NewDeleteJob(urls []string, shouldConfirm bool, uiDelegate IUIDelegate) *DeleteJob

NewDeleteJob creates a new delete job to delete files or directories.

func NewTrashJob

func NewTrashJob(urls []string, shouldConfirm bool, uiDelegate IUIDelegate) *DeleteJob

NewTrashJob creates a new trash job to trash files or directories.

func (*DeleteJob) Execute

func (job *DeleteJob) Execute()

Execute the delete job to delete files/directories.

func (*DeleteJob) ListenDeleting

func (job *DeleteJob) ListenDeleting(fn func(string)) (func(), error)

func (*DeleteJob) ListenTrashing

func (job *DeleteJob) ListenTrashing(fn func(string)) (func(), error)

type EmptyTrashJob

type EmptyTrashJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

EmptyTrashJob is a job to empty trash.

func NewEmptyTrashJob

func NewEmptyTrashJob(shouldConfirm bool, uiDelegate IUIDelegate) *EmptyTrashJob

NewEmptyTrashJob creates a new empty trash job.

func (*EmptyTrashJob) Execute

func (job *EmptyTrashJob) Execute()

Execute EmptyTrashJob and finalize resources.

type Enumerator

type Enumerator struct {
	// contains filtered or unexported fields
}

TODO: make a real Enumerator.

func NewEnumerator

func NewEnumerator(ch chan interface{}) *Enumerator

func (*Enumerator) Close

func (e *Enumerator) Close()

func (*Enumerator) IsClosed

func (e *Enumerator) IsClosed() bool

func (*Enumerator) Next

func (e *Enumerator) Next() <-chan interface{}

type FileUndoManager

type FileUndoManager struct {
	*SignalManager
}

func FileUndoManagerInstance

func FileUndoManagerInstance() *FileUndoManager

func (*FileUndoManager) ListenAvaiable

func (m *FileUndoManager) ListenAvaiable(fn func(bool)) (func(), error)

func (*FileUndoManager) ListenJobRecordingFinished

func (m *FileUndoManager) ListenJobRecordingFinished(fn func(CommandType)) (func(), error)

func (*FileUndoManager) ListenJobRecordingStarted

func (m *FileUndoManager) ListenJobRecordingStarted(fn func(CommandType)) (func(), error)

func (*FileUndoManager) ListenUndoJobFinished

func (m *FileUndoManager) ListenUndoJobFinished(fn func()) (func(), error)

func (*FileUndoManager) ListenUndoJobTextChanged

func (m *FileUndoManager) ListenUndoJobTextChanged(fn func(string)) (func(), error)

func (*FileUndoManager) RecordJob

func (*FileUndoManager) RecordJob(op CommandType, srcURLs []string, destURL string, job interface{})

func (*FileUndoManager) Undo

func (*FileUndoManager) Undo()

type GFileWrapper

type GFileWrapper struct {
	*gio.File // this field should not be operated directly in common.
	// contains filtered or unexported fields
}

GFileWrapper wraps *gio.File to make gio.File safer and easy to use.

func NewGFileWrapper

func NewGFileWrapper(file *gio.File) *GFileWrapper

NewGFileWrapper creates a new GFileWrapper.

func (*GFileWrapper) IsNil

func (o *GFileWrapper) IsNil() bool

IsNil checks whether the GFile is nil or not.

func (*GFileWrapper) Reset

func (o *GFileWrapper) Reset(x *gio.File)

Reset unref the old GFile that belongs to GFileWrapper and set a new GFile to it.

func (*GFileWrapper) Unref

func (o *GFileWrapper) Unref()

Unref the object.

type GetAllLaunchAppsJob

type GetAllLaunchAppsJob struct {
	*CommonJob
}

GetAllLaunchAppsJob will get all apps.

func NewGetAllLaunchAppsJob

func NewGetAllLaunchAppsJob() *GetAllLaunchAppsJob

func (*GetAllLaunchAppsJob) Execute

func (job *GetAllLaunchAppsJob) Execute()

type GetDefaultLaunchAppJob

type GetDefaultLaunchAppJob struct {
	*GetLaunchAppJob
	// contains filtered or unexported fields
}

GetDefaultLaunchAppJob will get the default launch app.

func NewGetDefaultLaunchAppJob

func NewGetDefaultLaunchAppJob(uri string, mustSupportURI bool) *GetDefaultLaunchAppJob

func (*GetDefaultLaunchAppJob) Execute

func (job *GetDefaultLaunchAppJob) Execute()

type GetLaunchAppJob

type GetLaunchAppJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

GetLaunchAppJob is the base struct for get launch relatived job.

func NewGetLaunchAppJob

func NewGetLaunchAppJob(uri string) *GetLaunchAppJob

type GetRecommendedLaunchAppsJob

type GetRecommendedLaunchAppsJob struct {
	*GetLaunchAppJob
}

GetRecommendedLaunchAppsJob will get all recommended launch apps.

func NewGetRecommendedLaunchAppsJob

func NewGetRecommendedLaunchAppsJob(uri string) *GetRecommendedLaunchAppsJob

func (*GetRecommendedLaunchAppsJob) Execute

func (job *GetRecommendedLaunchAppsJob) Execute()

type GetTemplateJob

type GetTemplateJob struct {
	// contains filtered or unexported fields
}

func NewGetTemplateJob

func NewGetTemplateJob(templateDirURI string) *GetTemplateJob

func (*GetTemplateJob) Execute

func (job *GetTemplateJob) Execute() []string

type IMountUI

type IMountUI interface {
	Username() string
	Domain() string
	Password() string
	IsAnonymous() bool
	RememberPasswordFlags() int

	// TODO: ???
	AskPassword()
	AskQuestion()
	ShowProcess()
	ShowUnmountProcess()
}

type IUIDelegate

type IUIDelegate interface {
	// TODO: using this internally, give a simpler interface, like kio,
	// a.k.a: AskDeleteConfirmation(urls, deleteType, confirmationType))
	// if necessary, ask user to confirm whether to delete or trash files.
	AskDeleteConfirmation(primaryText string, secondaryText string, detailText string) bool

	AskDelete(string, string, string, UIFlags) Response
	AskSkip(primaryText string, secondaryText string, detailText string, uiFlags UIFlags) Response
	AskRetry(primaryText string, secondaryText string, detailText string) Response

	// TODO: decide arguments
	ConflictDialog() Response
}

IUIDelegate is the interface for ui delegate.

type ListJob

type ListJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

ListJob lists a directory.

func NewListDirJob

func NewListDirJob(dir string, flags ListJobFlag) *ListJob

NewListDirJob creates a new list job to list the contents of a directory. if recursive, recursively list the contents of a directory. if includeHidden, list hidden files and direcories as well.

func (*ListJob) Execute

func (job *ListJob) Execute()

Execute ListJob.

func (*ListJob) ListenProperty

func (job *ListJob) ListenProperty(fn func(ListProperty)) (func(), error)

ListenProperty adds observers to property signal.

type ListJobFlag

type ListJobFlag int32
const (
	ListJobFlagNone ListJobFlag = iota
	ListJobFlagRecusive
	ListJobFlagIncludeHidden
)

type ListProperty

type ListProperty struct {
	DisplayName string
	BaseName    string
	URI         string
	MIME        string
	Size        int64
	FileType    uint16
	IsBackup    bool
	IsHidden    bool
	IsReadOnly  bool
	IsSymlink   bool
	CanDelete   bool
	CanExecute  bool
	CanRead     bool
	CanRename   bool
	CanTrash    bool
	CanWrite    bool
}

ListProperty represents the properties of files when ListJob is executed.

func GetListProperty

func GetListProperty(file *gio.File, cancellable *gio.Cancellable) (ListProperty, error)

type MountJob

type MountJob struct {
	*CommonJob
}

func NewMountJob

func NewMountJob() *MountJob

type OpKind

type OpKind int32

OpKind is the flag for which kind of operations is.

const (
	OpKindCopy OpKind = iota
	OpKindMove
	OpKindDelete
	OpKindTrash
	OpKindList
)

the value of OpKind

type ReactorElement

type ReactorElement struct {
	// contains filtered or unexported fields
}

ReactorElement holds signal handler and a id for that.

type RenameError

type RenameError struct {
	Code int
	Msg  string
}

func (*RenameError) Error

func (e *RenameError) Error() string

type RenameJob

type RenameJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

Rename is just working for current directory.

func NewRenameJob

func NewRenameJob(file string, newName string) *RenameJob

func (*RenameJob) Execute

func (job *RenameJob) Execute()

func (*RenameJob) ListenNewFile

func (job *RenameJob) ListenNewFile(fn func(string))

func (*RenameJob) ListenOldName

func (job *RenameJob) ListenOldName(fn func(string))

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response stores the response relavant information like ResponseCode.

func NewResponse

func NewResponse(code ResponseCode, applyToAll bool) Response

NewResponse creates a new Response from response code and apply to all.

func NewResponseWithUserData

func NewResponseWithUserData(code ResponseCode, applyToAll bool, userData string) Response

NewResponseWithUserData creates a Response from response code code, apply to all and user data.

func (Response) ApplyToAll

func (response Response) ApplyToAll() bool

ApplyToAll returns whether apply to all.

func (Response) Code

func (response Response) Code() ResponseCode

Code returns response code.

func (Response) String

func (response Response) String() string

String returns a human readable string for debuging or something like it.

func (Response) UserData

func (response Response) UserData() string

UserData returns some extra data.

type ResponseCode

type ResponseCode int32

ResponseCode is a type for the response of UIDelegate.

const (
	ResponseCancel ResponseCode = 1 << iota
	ResponseSkip
	ResponseRetry
	ResponseDelete
	ResponseOverwrite
	ResponseAutoRename // auto rename the conflict file/directory
	ResponseYes
)

the code for response of UIDelegate.

func (ResponseCode) String

func (code ResponseCode) String() string

String returns a human readable string for ResponseCode.

type SetDefaultLaunchAppJob

type SetDefaultLaunchAppJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

SetDefaultLaunchAppJob sets the default launch applications for a MIME type.

func NewSetDefaultLaunchAppJob

func NewSetDefaultLaunchAppJob(id string, mimeType string) *SetDefaultLaunchAppJob

NewSetLaunchAppJob creates a new SetLaunchAppJob.

func (*SetDefaultLaunchAppJob) Execute

func (job *SetDefaultLaunchAppJob) Execute()

Execute the SetLaunchAppJob.

type SignalError

type SignalError struct {
	Code       int
	SignalName string
}

func (SignalError) Error

func (e SignalError) Error() string

type SignalManager

type SignalManager struct {
	// contains filtered or unexported fields
}

func NewSignalManager

func NewSignalManager() *SignalManager

func (*SignalManager) Emit

func (m *SignalManager) Emit(signalName string, args ...interface{}) error

func (*SignalManager) ListenSignal

func (m *SignalManager) ListenSignal(signalName string, fn interface{}) (func(), error)

func (*SignalManager) RegisterMonitor

func (m *SignalManager) RegisterMonitor(signalName string) *SignalManager

type SignalReactor

type SignalReactor struct {
	// contains filtered or unexported fields
}

SignalReactor is a reactor of one signal.

func NewSignalReactor

func NewSignalReactor(signalName string) *SignalReactor

NewSignalReactor creates a new SignalReactor.

func (*SignalReactor) Add

func (l *SignalReactor) Add(fn interface{}) func()

Add adds a new handler to signal.

func (*SignalReactor) Enumerator

func (l *SignalReactor) Enumerator() *Enumerator

Enumerator return a channel of handler.

type StatJob

type StatJob struct {
	*CommonJob
	// contains filtered or unexported fields
}

StatJob list some useful properties for properties window.

func NewStatJob

func NewStatJob(uri string) *StatJob

NewStatJob creates a new StatJob.

func (*StatJob) Execute

func (job *StatJob) Execute()

Execute StatJob.

type StatProperty

type StatProperty struct {
	URI        string
	Name       string
	MIME       string
	LinkTarget string
	Mode       uint32
	Size       int64
	MTime      uint64
	ATime      uint64
	Owner      string
	OwnerReal  string
	Group      string
}

StatProperty is the useful properties for properties window. the size field of directory is not the size of the whole directory, using list job with includeHidden and recursive flags to get the real size of a directory.

type UIFlags

type UIFlags int32
const (
	UIFlagsNone UIFlags = iota << 0
	UIFlagsRetry
	UIFlagsMulti
)

UIFlags

func (UIFlags) String

func (flags UIFlags) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL