This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
clipboard.go
69 lines (57 loc) · 1.6 KB
/
clipboard.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Copyright (C) 2015 Deepin Technology Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
**/
package clipboard
import (
"pkg.deepin.io/lib/dbus"
. "pkg.deepin.io/service/file-manager-backend/log"
"pkg.deepin.io/service/file-manager-backend/operations"
)
type Clipboard struct {
RequestPaste func(string, []string, string)
}
func NewClipboard() *Clipboard {
c := &Clipboard{}
return c
}
func (c *Clipboard) GetDBusInfo() dbus.DBusInfo {
return dbus.DBusInfo{
Dest: "com.deepin.filemanager.Backend.Clipboard",
ObjectPath: "/com/deepin/filemanager/Backend/Clipboard",
Interface: "com.deepin.filemanager.Backend.Clipboard",
}
}
func (c *Clipboard) EmitPaste(file string) {
contents := operations.GetClipboardContents()
if len(contents) < 2 {
Log.Warning("invalid content or empty content in clipboard")
return
}
op := contents[0]
files := contents[1:]
switch op {
case operations.OpCut:
fallthrough
case operations.OpCopy:
dbus.Emit(c, "RequestPaste", op, files, file)
default:
Log.Warning("not valid operation")
}
}
func (c *Clipboard) CutToClipboard(files []string) {
operations.CutToClipboard(files)
}
func (c *Clipboard) CopyToClipboard(files []string) {
operations.CopyToClipboard(files)
}
func (c *Clipboard) ClearClipboard() {
operations.ClearClipboard()
}
// func (c *Clipboard) GetContent() []string {
// return operations.GetClipboardContents()
// }