diff --git a/v3/pkg/application/jumplist.go b/v3/pkg/application/jumplist.go new file mode 100644 index 000000000..0c33f77f5 --- /dev/null +++ b/v3/pkg/application/jumplist.go @@ -0,0 +1,55 @@ +package application + +// JumpListItemType represents the type of jump list item +type JumpListItemType int + +const ( + // JumpListItemTypeTask represents a task item + JumpListItemTypeTask JumpListItemType = iota + // JumpListItemTypeSeparator represents a separator (Windows only) + JumpListItemTypeSeparator +) + +// JumpListItem represents a single item in a jump list +type JumpListItem struct { + Type JumpListItemType + Title string + Description string + FilePath string + Arguments string + IconPath string + IconIndex int +} + +// JumpListCategory represents a category of items in a jump list +type JumpListCategory struct { + Name string + Items []JumpListItem +} + +// JumpList provides an interface for managing application jump lists. +// This is primarily a Windows feature, but the API is designed to be +// cross-platform safe (no-op on non-Windows platforms). +type JumpList struct { + app platformApp + categories []JumpListCategory +} + +// AddCategory adds a category to the jump list. +// If the category name is empty, the items will be added as tasks. +func (j *JumpList) AddCategory(category JumpListCategory) { + j.categories = append(j.categories, category) +} + +// ClearCategories removes all categories from the jump list. +func (j *JumpList) ClearCategories() { + j.categories = []JumpListCategory{} +} + +// Apply applies the current jump list configuration. +// On Windows, this updates the taskbar jump list. +// On other platforms, this is a no-op. +func (j *JumpList) Apply() error { + // Platform-specific implementation + return j.applyPlatform() +} \ No newline at end of file diff --git a/v3/pkg/application/jumplist_darwin.go b/v3/pkg/application/jumplist_darwin.go index d2e524923..23f1db048 100644 --- a/v3/pkg/application/jumplist_darwin.go +++ b/v3/pkg/application/jumplist_darwin.go @@ -2,33 +2,6 @@ package application -type JumpListItemType int - -const ( - JumpListItemTypeTask JumpListItemType = iota - JumpListItemTypeSeparator -) - -type JumpListItem struct { - Type JumpListItemType - Title string - Description string - FilePath string - Arguments string - IconPath string - IconIndex int -} - -type JumpListCategory struct { - Name string - Items []JumpListItem -} - -type JumpList struct { - app *darwinApp - categories []JumpListCategory -} - func (app *darwinApp) CreateJumpList() *JumpList { return &JumpList{ app: app, @@ -36,17 +9,7 @@ func (app *darwinApp) CreateJumpList() *JumpList { } } -func (j *JumpList) AddCategory(category JumpListCategory) { - // Stub implementation for macOS - j.categories = append(j.categories, category) -} - -func (j *JumpList) ClearCategories() { - // Stub implementation for macOS - j.categories = []JumpListCategory{} -} - -func (j *JumpList) Apply() error { +func (j *JumpList) applyPlatform() error { // Stub implementation for macOS // Jump lists are Windows-specific, so this is a no-op on macOS return nil diff --git a/v3/pkg/application/jumplist_linux.go b/v3/pkg/application/jumplist_linux.go index 29c2845e3..c408b00dd 100644 --- a/v3/pkg/application/jumplist_linux.go +++ b/v3/pkg/application/jumplist_linux.go @@ -2,33 +2,6 @@ package application -type JumpListItemType int - -const ( - JumpListItemTypeTask JumpListItemType = iota - JumpListItemTypeSeparator -) - -type JumpListItem struct { - Type JumpListItemType - Title string - Description string - FilePath string - Arguments string - IconPath string - IconIndex int -} - -type JumpListCategory struct { - Name string - Items []JumpListItem -} - -type JumpList struct { - app *linuxApp - categories []JumpListCategory -} - func (app *linuxApp) CreateJumpList() *JumpList { return &JumpList{ app: app, @@ -36,17 +9,7 @@ func (app *linuxApp) CreateJumpList() *JumpList { } } -func (j *JumpList) AddCategory(category JumpListCategory) { - // Stub implementation for Linux - j.categories = append(j.categories, category) -} - -func (j *JumpList) ClearCategories() { - // Stub implementation for Linux - j.categories = []JumpListCategory{} -} - -func (j *JumpList) Apply() error { +func (j *JumpList) applyPlatform() error { // Stub implementation for Linux // Jump lists are Windows-specific, so this is a no-op on Linux return nil diff --git a/v3/pkg/application/jumplist_windows.go b/v3/pkg/application/jumplist_windows.go index eff3aeb79..2891a17db 100644 --- a/v3/pkg/application/jumplist_windows.go +++ b/v3/pkg/application/jumplist_windows.go @@ -9,33 +9,6 @@ import ( "unsafe" ) -type JumpListItemType int - -const ( - JumpListItemTypeTask JumpListItemType = iota - JumpListItemTypeSeparator -) - -type JumpListItem struct { - Type JumpListItemType - Title string - Description string - FilePath string - Arguments string - IconPath string - IconIndex int -} - -type JumpListCategory struct { - Name string - Items []JumpListItem -} - -type JumpList struct { - app *windowsApp - categories []JumpListCategory -} - var ( modole32 = syscall.NewLazyDLL("ole32.dll") modshell32 = syscall.NewLazyDLL("shell32.dll") @@ -169,15 +142,13 @@ func (app *windowsApp) CreateJumpList() *JumpList { } } -func (j *JumpList) AddCategory(category JumpListCategory) { - j.categories = append(j.categories, category) -} +func (j *JumpList) applyPlatform() error { + // Type assert to get the windowsApp + app, ok := j.app.(*windowsApp) + if !ok { + return fmt.Errorf("invalid app type for Windows jumplist") + } -func (j *JumpList) ClearCategories() { - j.categories = []JumpListCategory{} -} - -func (j *JumpList) Apply() error { hr := w32.CoInitializeEx(0, w32.COINIT_APARTMENTTHREADED) if hr != w32.S_OK && hr != w32.S_FALSE { return fmt.Errorf("CoInitializeEx failed: %v", hr) @@ -197,7 +168,7 @@ func (j *JumpList) Apply() error { } defer pDestList.Release() - appID := w32.MustStringToUTF16Ptr(j.app.parent.options.Name) + appID := w32.MustStringToUTF16Ptr(app.parent.options.Name) hr = pDestList.SetAppID(appID) if hr != w32.S_OK {