Update system.Environment

This commit is contained in:
Lea Anthony
2024-03-19 20:37:03 +11:00
parent e92994d2e7
commit aba82cc527
9 changed files with 210 additions and 9 deletions
+9 -4
View File
@@ -3,6 +3,7 @@ package application
import (
"embed"
"encoding/json"
"github.com/wailsapp/wails/v3/internal/operatingsystem"
"io"
"log"
"log/slog"
@@ -891,11 +892,15 @@ func (a *App) BrowserOpenFile(path string) error {
}
func (a *App) Environment() EnvironmentInfo {
return EnvironmentInfo{
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Debug: a.isDebugMode,
info, _ := operatingsystem.Info()
result := EnvironmentInfo{
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Debug: a.isDebugMode,
OSInfo: info,
}
result.PlatformInfo = a.platformEnvironment()
return result
}
func (a *App) shouldQuit() bool {
+4
View File
@@ -355,3 +355,7 @@ func (a *App) logPlatformInfo() {
a.info("Platform Info:", info.AsLogSlice()...)
}
func (a *App) platformEnvironment() map[string]any {
return map[string]any{}
}
+40
View File
@@ -2,6 +2,16 @@
package application
/*
#include "gtk/gtk.h"
#include "webkit2/webkit2.h"
static guint get_compiled_gtk_major_version() { return GTK_MAJOR_VERSION; }
static guint get_compiled_gtk_minor_version() { return GTK_MINOR_VERSION; }
static guint get_compiled_gtk_micro_version() { return GTK_MICRO_VERSION; }
static guint get_compiled_webkit_major_version() { return WEBKIT_MAJOR_VERSION; }
static guint get_compiled_webkit_minor_version() { return WEBKIT_MINOR_VERSION; }
static guint get_compiled_webkit_micro_version() { return WEBKIT_MICRO_VERSION; }
*/
import "C"
import (
"fmt"
@@ -216,3 +226,33 @@ func processWindowEvent(windowID C.uint, eventID C.uint) {
EventID: uint(eventID),
}
}
func buildVersionString(major, minor, micro C.uint) string {
return fmt.Sprintf("%d.%d.%d", uint(major), uint(minor), uint(micro))
}
func (a *App) platformEnvironment() map[string]any {
result := map[string]any{}
result["gtk3-compiled"] = buildVersionString(
C.get_compiled_gtk_major_version(),
C.get_compiled_gtk_minor_version(),
C.get_compiled_gtk_micro_version(),
)
result["gtk3-runtime"] = buildVersionString(
C.gtk_get_major_version(),
C.gtk_get_minor_version(),
C.gtk_get_micro_version(),
)
result["webkit2gtk-compiled"] = buildVersionString(
C.get_compiled_webkit_major_version(),
C.get_compiled_webkit_minor_version(),
C.get_compiled_webkit_micro_version(),
)
result["webkit2gtk-runtime"] = buildVersionString(
C.webkit_get_major_version(),
C.webkit_get_minor_version(),
C.webkit_get_micro_version(),
)
return result
}
@@ -350,3 +350,11 @@ func (a *App) logPlatformInfo() {
a.info("Platform Info:", args...)
}
func (a *App) platformEnvironment() map[string]any {
result := map[string]any{}
webviewVersion, _ := webviewloader.GetAvailableCoreWebView2BrowserVersionString(a.options.Windows.WebviewBrowserPath)
result["Go-WebView2Loader"] = webviewloader.UsingGoWebview2Loader
result["WebView2"] = webviewVersion
return result
}
+8 -3
View File
@@ -1,13 +1,18 @@
package application
import "github.com/wailsapp/wails/v3/internal/operatingsystem"
// EnvironmentInfo represents information about the current environment.
//
// Fields:
// - OS: the operating system that the program is running on.
// - Arch: the architecture of the operating system.
// - Debug: indicates whether debug mode is enabled.
// - OSInfo: information about the operating system.
type EnvironmentInfo struct {
OS string
Arch string
Debug bool
OS string
Arch string
Debug bool
OSInfo *operatingsystem.OS
PlatformInfo map[string]any
}