mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Support ProgramName on linux
This commit is contained in:
@@ -186,6 +186,11 @@ func newPlatformApp(parent *App) *linuxApp {
|
||||
application: appNew(name),
|
||||
windowMap: map[windowPointer]uint{},
|
||||
}
|
||||
|
||||
if parent.options.Linux.ProgramName != "" {
|
||||
setProgramName(parent.options.Linux.ProgramName)
|
||||
}
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
|
||||
@@ -8,18 +8,6 @@ import (
|
||||
"github.com/wailsapp/wails/v3/internal/assetserver"
|
||||
)
|
||||
|
||||
// ActivationPolicy is the activation policy for the application.
|
||||
type ActivationPolicy int
|
||||
|
||||
const (
|
||||
// ActivationPolicyRegular is used for applications that have a user interface,
|
||||
ActivationPolicyRegular ActivationPolicy = iota
|
||||
// ActivationPolicyAccessory is used for applications that do not have a main window,
|
||||
// such as system tray applications or background applications.
|
||||
ActivationPolicyAccessory
|
||||
ActivationPolicyProhibited
|
||||
)
|
||||
|
||||
// Options contains the options for the application
|
||||
type Options struct {
|
||||
// Name is the name of the application (used in the default about box)
|
||||
@@ -32,39 +20,13 @@ type Options struct {
|
||||
Icon []byte
|
||||
|
||||
// Mac is the Mac specific configuration for Mac builds
|
||||
Mac struct {
|
||||
// ActivationPolicy is the activation policy for the application. Defaults to
|
||||
// applicationActivationPolicyRegular.
|
||||
ActivationPolicy ActivationPolicy
|
||||
// If set to true, the application will terminate when the last window is closed.
|
||||
ApplicationShouldTerminateAfterLastWindowClosed bool
|
||||
}
|
||||
Mac MacOptions
|
||||
|
||||
// Windows is the Windows specific configuration for Windows builds
|
||||
Windows struct {
|
||||
|
||||
// WndProcInterceptor is a function that will be called for every message sent in the application.
|
||||
// Use this to hook into the main message loop. This is useful for handling custom window messages.
|
||||
// If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.
|
||||
// If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop.
|
||||
WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool)
|
||||
|
||||
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
|
||||
DisableQuitOnLastWindowClosed bool
|
||||
|
||||
// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
|
||||
// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
|
||||
WebviewUserDataPath string
|
||||
|
||||
// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
|
||||
WebviewBrowserPath string
|
||||
}
|
||||
Windows WindowsOptions
|
||||
|
||||
// Linux is the Linux specific configuration for Linux builds
|
||||
Linux struct {
|
||||
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
|
||||
DisableQuitOnLastWindowClosed bool
|
||||
}
|
||||
Linux LinuxOptions
|
||||
|
||||
// Bind allows you to bind Go methods to the frontend.
|
||||
Bind []any
|
||||
@@ -214,4 +176,13 @@ type WindowsOptions struct {
|
||||
type LinuxOptions struct {
|
||||
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
|
||||
DisableQuitOnLastWindowClosed bool
|
||||
|
||||
// ProgramName is used to set the program's name for the window manager via GTK's g_set_prgname().
|
||||
//This name should not be localized. [see the docs]
|
||||
//
|
||||
//When a .desktop file is created this value helps with window grouping and desktop icons when the .desktop file's Name
|
||||
//property differs form the executable's filename.
|
||||
//
|
||||
//[see the docs]: https://docs.gtk.org/glib/func.set_prgname.html
|
||||
ProgramName string
|
||||
}
|
||||
|
||||
@@ -332,6 +332,12 @@ func appNew(name string) pointer {
|
||||
return pointer(C.gtk_application_new(nameC, C.APPLICATION_DEFAULT_FLAGS))
|
||||
}
|
||||
|
||||
func setProgramName(prgName string) {
|
||||
cPrgName := C.CString(prgName)
|
||||
defer C.free(unsafe.Pointer(cPrgName))
|
||||
C.g_set_prgname(cPrgName)
|
||||
}
|
||||
|
||||
func appRun(app pointer) error {
|
||||
application := (*C.GApplication)(app)
|
||||
//TODO: Only set this if we configure it to do so
|
||||
|
||||
@@ -513,13 +513,4 @@ type LinuxWindow struct {
|
||||
// Client code may override this behavior by passing a non-nil Options and set
|
||||
// WebviewGpuPolicy as needed.
|
||||
WebviewGpuPolicy WebviewGpuPolicy
|
||||
|
||||
// ProgramName is used to set the program's name for the window manager via GTK's g_set_prgname().
|
||||
//This name should not be localized. [see the docs]
|
||||
//
|
||||
//When a .desktop file is created this value helps with window grouping and desktop icons when the .desktop file's Name
|
||||
//property differs form the executable's filename.
|
||||
//
|
||||
//[see the docs]: https://docs.gtk.org/glib/func.set_prgname.html
|
||||
ProgramName string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user