func NewDesktopDaemon() (*Application, error) { var app *Application initializer := initializer.NewInitializer() initializer.InitOnSessionBus(func(v interface{}) (interface{}, error) { return NewSettings() }).InitOnSessionBus(func(v interface{}) (interface{}, error) { app = NewApplication(v.(*Settings)) return app, nil }) return app, initializer.GetError() }
// NewSettings creates a new settings. func NewSettings() (*Settings, error) { s := new(Settings) err := initializer.NewInitializer().Init(func(interface{}) (interface{}, error) { return utils.CheckAndNewGSettings(FileManagerPerferenceSchemaID) }).Init(func(v interface{}) (interface{}, error) { s.filemanagerPreferences = v.(*gio.Settings) s.filemanagerPreferences.Connect("changed", func(_ *gio.Settings, key string) { switch key { case ConfirmEmptyTrash: s.emitConfirmEmptyTrashChanged(s.ConfirmEmptyTrashIsEnable()) case ConfirmTrash: case ActivationPolicy: s.emitActivationPolicyChanged(s.ActivationPolicy()) case ClickPolicy: s.emitClickPolicyChanged(s.ClickPolicy()) case ShowThumbnail: s.emitShowThumbnailChanged(s.ShowThumbnail()) case ShowHiddenFiles: s.emitShowHiddenFilesChanged(s.ShowHiddenFilesIsEnable()) case ShowExtensionName: s.emitShowExtensionNameChanged(s.ShowExtensionNameIsEnable()) case LabelPosition: s.emitLabelPositionChanged(s.LabelPosition()) case AllowDeleteImmediatly: s.emitAllowDeleteImmediatlyChanged(s.AllowDeleteImmediatlyIsEnable()) case ThumbnailSizeLimitation: fallthrough case ThumbnailSizeUnit: s.updateThumbnailSizeLimitation() s.emitThunbnailSizeLimitationChanged(s.thumbnailSizeLimitation) } }) s.filemanagerPreferences.GetBoolean(ConfirmEmptyTrash) // enable connection. s.updateThumbnailSizeLimitation() return utils.CheckAndNewGSettings(FileManagerDesktopSchemaID) }).Init(func(v interface{}) (interface{}, error) { s.desktopPreferences = v.(*gio.Settings) s.desktopPreferences.Connect("changed", func(_ *gio.Settings, key string) { switch key { case ShowComputerIcon: s.emitShowComputerIconChanged(s.ShowComputerIconIsEnable()) case ShowTrashIcon: s.emitShowTrashIconChanged(s.ShowTrashIconIsEnable()) case StickupGrid: s.emitStickupGridChanged(s.StickupGridIsEnable()) // case ShowTrashedItemCount: case AutoArrangement: s.emitAutoArrangementChanged(s.AutoArrangement()) case IconDefaultSize: s.updateIconSize() case IconZoomLevel: s.updateIconSize() s.emitIconZoomLevelChanged(s.IconZoomLevel()) } }) s.updateIconSize() return nil, nil }).GetError() if err != nil { return nil, err } return s, nil }