本文整理汇总了Golang中pkg/deepin/io/lib/dbus.Emit函数的典型用法代码示例。如果您正苦于以下问题:Golang Emit函数的具体用法?Golang Emit怎么用?Golang Emit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Emit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Execute
func (job *GetAllLaunchAppsJob) Execute() {
job.op.ListenDone(func(e error) {
defer dbus.UnInstallObject(job)
if e != nil {
dbus.Emit(job, "Done", e.Error())
return
}
apps := job.op.Result().([]*gio.AppInfo)
info := LaunchAppInfo{
Names: make([]string, len(apps)),
Ids: make([]string, len(apps)),
}
for i, app := range apps {
info.Names[i] = app.GetName()
info.Ids[i] = app.GetId()
// TODO: get icon
// app.GetIcon()
app.Unref()
}
bInfos, err := json.Marshal(info)
if err != nil {
dbus.Emit(job, "Done", err.Error())
return
}
dbus.Emit(job, "LaunchAppInfo", string(bInfos))
dbus.Emit(job, "Done", "")
})
job.op.Execute()
}
示例2: Execute
// Execute list job.
func (job *ListJob) Execute() []operations.ListProperty {
defer dbus.UnInstallObject(job)
var files []operations.ListProperty
job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) {
dbus.Emit(job, "ProcessedAmount", size, uint16(unit))
})
job.op.ListenProperty(func(property operations.ListProperty) {
dbus.Emit(job, "EntryInfo", property)
files = append(files, property)
})
job.op.ListenDone(func(err error) {
errMsg := ""
if err != nil {
errMsg = err.Error()
}
// time.Sleep(time.Microsecond * 200)
dbus.Emit(job, "Done", errMsg)
})
job.op.ListenAborted(func() {
defer dbus.UnInstallObject(job)
dbus.Emit(job, "Aborted")
})
job.op.Execute()
return files
}
示例3: Execute
// Execute stat job.
func (job *StatJob) Execute() {
job.op.ListenDone(func(err error) {
defer dbus.UnInstallObject(job)
if err != nil {
dbus.Emit(job, "Done", err.Error())
return
}
dbus.Emit(job, "Stat", job.op.Result().(operations.StatProperty))
dbus.Emit(job, "Done", "")
})
job.op.Execute()
}
示例4: Execute
func (job *RenameJob) Execute() {
defer dbus.UnInstallObject(job)
job.op.ListenDone(func(err error) {
var errMsg = ""
if err != nil {
errMsg = err.Error()
}
dbus.Emit(job, "Done", errMsg)
})
job.op.ListenOldName(func(oldName string) {
dbus.Emit(job, "OldName", oldName)
})
job.op.ListenNewFile(func(fileURL string) {
dbus.Emit(job, "NewFile", fileURL)
})
job.op.Execute()
}
示例5: Execute
// Execute trash job.
func (job *TrashJob) Execute() {
job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) {
dbus.Emit(job, "ProcessedAmount", size, uint16(unit))
})
job.op.ListenPercent(func(percent int64) {
dbus.Emit(job, "ProcessedPercent", percent)
})
job.op.ListenAborted(func() {
defer dbus.UnInstallObject(job)
dbus.Emit(job, "Aborted")
})
job.op.ListenDone(func(err error) {
dbus.Emit(job, "Done")
})
// TODO: fill signals.
defer dbus.UnInstallObject(job)
job.op.Execute()
}
示例6: listenSignals
func (job *DeleteJob) listenSignals() {
job.op.ListenTotalAmount(func(amount int64, unit operations.AmountUnit) {
dbus.Emit(job, "TotalAmount", amount, uint16(unit))
})
job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) {
dbus.Emit(job, "ProcessedAmount", size, uint16(unit))
})
job.op.ListenPercent(func(percent int64) {
dbus.Emit(job, "ProcessedPercent", percent)
})
job.op.ListenDeleting(func(deletingURL string) {
dbus.Emit(job, "Deleting", deletingURL)
})
job.op.ListenAborted(func() {
defer dbus.UnInstallObject(job)
dbus.Emit(job, "Aborted")
})
}
示例7: Execute
// Execute chmod job.
func (job *ChmodJob) Execute() {
job.op.ListenDone(func(err error) {
defer dbus.UnInstallObject(job)
errMsg := ""
if err != nil {
errMsg = err.Error()
}
dbus.Emit(job, "Done", errMsg)
})
job.op.Execute()
}
示例8: listenSignals
func (job *CopyJob) listenSignals() {
job.op.ListenTotalAmount(func(amount int64, unit operations.AmountUnit) {
dbus.Emit(job, "TotalAmount", amount, uint16(unit))
})
job.op.ListenProcessedAmount(func(amount int64, unit operations.AmountUnit) {
dbus.Emit(job, "ProcessedAmount", amount, uint16(unit))
})
job.op.ListenPercent(func(percent int64) {
dbus.Emit(job, "ProcessedPercent", percent)
})
job.op.ListenCopying(func(srcURL string) {
Log.Debug("copying", srcURL)
dbus.Emit(job, "Copying", srcURL)
})
job.op.ListenCreatingDir(func(dirURL string) {
// TODO
// dbus.Emit(job, "CreatingDir", dirURL)
})
job.op.ListenCopyingMovingDone(func(srcURL string, destURL string) {
})
job.op.ListenDone(func(err error) {
defer dbus.UnInstallObject(job)
errMsg := ""
if err != nil {
errMsg = err.Error()
}
dbus.Emit(job, "Done", errMsg)
})
job.op.ListenAborted(func() {
defer dbus.UnInstallObject(job)
dbus.Emit(job, "Aborted")
})
}
示例9: NewWatcher
func NewWatcher(id uint32, fileURI string) (*Watcher, error) {
fsWatcher, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
}
if err := fsWatcher.Watch(fileURI); err != nil {
fsWatcher.Close()
return nil, err
}
watcher := &Watcher{
ID: WatcherID(id),
watcher: fsWatcher,
end: make(chan struct{}),
}
watcher.dbusInfo = dbus.DBusInfo{
Dest: "com.deepin.filemanager.Backend.Watcher",
ObjectPath: fmt.Sprintf("/com/deepin/filemanager/Backend/Watcher/%d", watcher.ID),
Interface: "com.deepin.filemanager.Backend.Watcher",
}
go func() {
for {
select {
case ev := <-fsWatcher.Event:
var event uint32
switch {
case ev.IsAttrib():
event = FsNotifyAttributeChanged
case ev.IsCreate():
event = FsNotifyCreated
case ev.IsDelete():
event = FsNotifyDeleted
case ev.IsModify():
event = FsNotifyModified
case ev.IsRename():
event = FsNotifyRename
}
dbus.Emit(watcher, "Changed", ev.Name, event)
case err := <-fsWatcher.Error:
Log.Warning("fsWatcher error:", err)
return
case <-watcher.end:
return
}
}
}()
return watcher, nil
}
示例10: Execute
// Execute create job.
func (job *CreateJob) Execute() {
go func() {
defer dbus.UnInstallObject(job)
err := job.op.Execute()
errMsg := ""
if err != nil {
errMsg = err.Error()
}
dbus.Emit(job, "Done", job.op.Result().(string), errMsg)
// TODO:
// job.commandRecorder
// operations.FileUndoManagerInstance().RecordJob(create, job.op)
}()
}
示例11: NewTrashMonitor
func NewTrashMonitor() (*TrashMonitor, error) {
trashMonitor := new(TrashMonitor)
trash := gio.FileNewForUri("trash://")
trashMonitor.trash = trash
monitor, err := trash.MonitorDirectory(gio.FileMonitorFlagsNone, nil)
if err != nil {
return nil, err
}
trashMonitor.monitor = monitor
monitor.Connect("changed", func(*gio.FileMonitor, *gio.File, *gio.File, gio.FileMonitorEvent) {
// TODO: seperate trash monitor and dbus into two parts.
dbus.Emit(trashMonitor, "ItemCountChanged", trashMonitor.ItemCount())
})
return trashMonitor, nil
}
示例12: EmitPaste
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")
}
}
示例13: NewMonitor
func NewMonitor(id uint32, fileURI string, flags gio.FileMonitorFlags) (*Monitor, error) {
file := gio.FileNewForCommandlineArg(fileURI)
if file == nil {
return nil, fmt.Errorf("create file from %s failed\n", fileURI)
}
monitor := &Monitor{
file: file,
cancellable: gio.NewCancellable(),
flags: flags,
ID: id,
}
monitor.dbusInfo = dbus.DBusInfo{
Dest: "com.deepin.filemanager.Backend.Monitor",
ObjectPath: fmt.Sprintf("/com/deepin/filemanager/Backend/Monitor/%d", monitor.ID),
Interface: "com.deepin.filemanager.Backend.Monitor",
}
var err error
monitor.monitor, err = monitor.file.Monitor(flags, monitor.cancellable)
if err != nil {
monitor.finalize()
return nil, fmt.Errorf("create file monitor failed: %s", err)
}
monitor.monitor.Connect("changed", func(m *gio.FileMonitor, file *gio.File, newFile *gio.File, events gio.FileMonitorEvent) {
newFileURI := ""
if newFile != nil {
newFileURI = newFile.GetUri()
}
err := dbus.Emit(monitor, "Changed", file.GetUri(), newFileURI, uint32(events))
if err != nil {
Log.Warning("emit signal failed:", err)
}
})
return monitor, nil
}
示例14: emitThunbnailSizeLimitationChanged
func (s *Settings) emitThunbnailSizeLimitationChanged(size uint64) error {
return dbus.Emit(s, "ThumbnailSizeLimitationChanged", size)
}
示例15: emitIconZoomLevelChanged
func (s *Settings) emitIconZoomLevelChanged(level int32) error {
return dbus.Emit(s, "IconZoomLevelChanged", level)
}