// NewListJob creates a new list job for dbus. func NewGetTemplateJob(templateDirURI string) *GetTemplateJob { job := &GetTemplateJob{ dbusInfo: genDBusInfo("GetTemplateJob", &_GetTemplateJobCount), op: operations.NewGetTemplateJob(templateDirURI), } return job }
// GenMenu generates json format menu content used in DeepinMenu for Desktop itself. func (desktop *Desktop) GenMenu() (*Menu, error) { desktop.menu = NewMenu() menu := desktop.menu menu.AppendItem(NewMenuItem(Tr("New _folder"), func(uint32) { desktop.app.emitRequestCreateDirectory() }, true)) // NB: remove new document item for now, revert it when deepin file manager is out. newSubMenu := NewMenu().SetIDGenerator(menu.genID) // newSubMenu.AppendItem(NewMenuItem(Tr("_Text document"), func(uint32) { // desktop.app.emitRequestCreateFile() // }, true)) templatePath := GetUserSpecialDir(glib.UserDirectoryDirectoryTemplates) job := operations.NewGetTemplateJob(templatePath) templates := job.Execute() hasTemplates := len(templates) != 0 if hasTemplates { // newSubMenu.AddSeparator() sort.Sort(byName(templates)) for _, template := range templates { templateURI := template newSubMenu.AppendItem(NewMenuItem(getBaseName(templateURI), func(uint32) { desktop.app.emitRequestCreateFileFromTemplate(templateURI) }, true)) } } newMenuItem := NewMenuItem(Tr("New _document"), func(uint32) {}, hasTemplates) newMenuItem.subMenu = newSubMenu menu.AppendItem(newMenuItem) sortSubMenu := NewMenu().SetIDGenerator(desktop.menu.genID) sortPolicies := desktop.app.settings.getSortPolicies() for _, sortPolicy := range sortPolicies { if _, ok := sortPoliciesName[sortPolicy]; !ok { continue } sortSubMenu.AppendItem(NewMenuItem(Tr(sortPoliciesName[sortPolicy]), func(sortPolicy string) func(uint32) { return func(uint32) { desktop.app.emitRequestSort(sortPolicy) } }(sortPolicy), true)) } // TODO: not handle clean up for now. // sortSubMenu.AddSeparator().AppendItem(NewMenuItem(Tr("Clean up"), func(uint32) { // desktop.app.emitRequestCleanup() // }, true)) sortMenuItem := NewMenuItem(Tr("_Sort by"), func(uint32) {}, true) sortMenuItem.subMenu = sortSubMenu menu.AppendItem(sortMenuItem).AppendItem(NewMenuItem(Tr("_Paste"), func(uint32) { desktop.app.emitRequestPaste(GetDesktopDir()) }, operations.CanPaste(GetDesktopDir()))) // TODO: plugin if true { menu.AddSeparator().AppendItem(NewMenuItem(Tr("Display settings(_M)"), func(uint32) { showModule("display") }, true)).AppendItem(NewMenuItem(Tr("_Corner navigation"), func(uint32) { go exec.Command("/usr/lib/deepin-daemon/dde-zone").Run() }, true)) if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" { menu.AppendItem(NewMenuItem(Tr("Set _wallpaper"), func(uint32) { go exec.Command("/usr/lib/deepin-daemon/dde-wallpaper-chooser").Run() }, true)) } else { menu.AppendItem(NewMenuItem(Tr("_Personalize"), func(uint32) { showModule("personalization") }, true)) } } if desktop.displayExtraItems { menu.AppendItem(NewMenuItem(Tr("Open in _terminal"), func(uint32) { runInTerminal(GetDesktopDir(), "") }, true)) } return menu, nil }