v2.3.0 Fixed Chinese input and gtk3 issues for linux packagin

This commit is contained in:
杨红岩 2023-01-10 10:32:59 +08:00
parent b7263f3089
commit 295210c4cd
3 changed files with 104 additions and 94 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/energye/energy/cef"
"github.com/energye/energy/common/assetserve"
sys_tray "github.com/energye/energy/example/dev-test/sys-tray"
"github.com/energye/golcl/lcl"
"github.com/energye/golcl/lcl/types"
)
@ -51,6 +52,9 @@ func main() {
//win.SetLayeredWindowAttributes(browserWindow.Handle(), 0, 100, win.LWA_ALPHA)
})
})
cef.BrowserWindow.SetBrowserInitAfter(func(window cef.IBrowserWindow) {
sys_tray.TrayMain()
})
cef.SetBrowserProcessStartAfterCallback(func(b bool) {
fmt.Println("主进程启动 创建一个内置http服务")
//通过内置http服务加载资源

View File

@ -0,0 +1,98 @@
package sys_tray
import (
"energye/systray"
"energye/systray/icon"
"fmt"
"time"
)
func TrayMain() {
onExit := func() {
now := time.Now()
fmt.Println("Exit at", now.String())
}
go systray.Run(onReady, onExit)
}
func addQuitItem() {
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
mQuit.Enable()
go func() {
<-mQuit.ClickedCh
fmt.Println("Requesting quit")
systray.Quit()
fmt.Println("Finished quitting")
}()
}
func onReady() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Lantern")
addQuitItem()
// We can manipulate the systray in other goroutines
go func() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Pretty awesome棒棒嗒")
mChange := systray.AddMenuItem("Change Me", "Change Me")
mChecked := systray.AddMenuItemCheckbox("Checked", "Check Me", true)
mEnabled := systray.AddMenuItem("Enabled", "Enabled")
// Sets the icon of a menu item. Only available on Mac.
mEnabled.SetTemplateIcon(icon.Data, icon.Data)
systray.AddMenuItem("Ignored", "Ignored")
subMenuTop := systray.AddMenuItem("SubMenuTop", "SubMenu Test (top)")
subMenuMiddle := subMenuTop.AddSubMenuItem("SubMenuMiddle", "SubMenu Test (middle)")
subMenuBottom := subMenuMiddle.AddSubMenuItemCheckbox("SubMenuBottom - Toggle Panic!", "SubMenu Test (bottom) - Hide/Show Panic!", false)
subMenuBottom2 := subMenuMiddle.AddSubMenuItem("SubMenuBottom - Panic!", "SubMenu Test (bottom)")
systray.AddSeparator()
mToggle := systray.AddMenuItem("Toggle", "Toggle some menu items")
shown := true
toggle := func() {
if shown {
subMenuBottom.Check()
subMenuBottom2.Hide()
mEnabled.Hide()
shown = false
} else {
subMenuBottom.Uncheck()
subMenuBottom2.Show()
mEnabled.Show()
shown = true
}
}
mReset := systray.AddMenuItem("Reset", "Reset all items")
for {
select {
case <-mChange.ClickedCh:
mChange.SetTitle("I've Changed")
case <-mChecked.ClickedCh:
if mChecked.Checked() {
mChecked.Uncheck()
mChecked.SetTitle("Unchecked")
} else {
mChecked.Check()
mChecked.SetTitle("Checked")
}
case <-mEnabled.ClickedCh:
mEnabled.SetTitle("Disabled")
mEnabled.Disable()
case <-subMenuBottom2.ClickedCh:
panic("panic button pressed")
case <-subMenuBottom.ClickedCh:
toggle()
case <-mReset.ClickedCh:
systray.ResetMenu()
addQuitItem()
case <-mToggle.ClickedCh:
toggle()
}
}
}()
}

View File

@ -2,14 +2,12 @@ package main
import (
"embed"
"energye/systray"
"energye/systray/icon"
"fmt"
"github.com/energye/energy/cef"
"github.com/energye/energy/common/assetserve"
sys_tray "github.com/energye/energy/example/dev-test/sys-tray"
"github.com/energye/energy/ipc"
"github.com/energye/golcl/lcl"
"time"
)
//go:embed resources
@ -64,7 +62,7 @@ func main() {
bw := window.AsViewsFrameworkBrowserWindow().BrowserWindow()
fmt.Println("handle", bw.WindowComponent().WindowHandle().ToPtr())
//cefTray(window)
trayMain()
sys_tray.TrayMain()
fmt.Println("SetBrowserInitAfter 结束")
})
//在主进程启动成功之后执行
@ -123,93 +121,3 @@ func cefTray(browserWindow cef.IBrowserWindow) {
})
//托盘 end
}
func trayMain() {
onExit := func() {
now := time.Now()
fmt.Println("Exit at", now.String())
}
go systray.Run(onReady, onExit)
}
func addQuitItem() {
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
mQuit.Enable()
go func() {
<-mQuit.ClickedCh
fmt.Println("Requesting quit")
systray.Quit()
fmt.Println("Finished quitting")
}()
}
func onReady() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Lantern")
addQuitItem()
// We can manipulate the systray in other goroutines
go func() {
systray.SetTemplateIcon(icon.Data, icon.Data)
systray.SetTitle("Awesome App")
systray.SetTooltip("Pretty awesome棒棒嗒")
mChange := systray.AddMenuItem("Change Me", "Change Me")
mChecked := systray.AddMenuItemCheckbox("Checked", "Check Me", true)
mEnabled := systray.AddMenuItem("Enabled", "Enabled")
// Sets the icon of a menu item. Only available on Mac.
mEnabled.SetTemplateIcon(icon.Data, icon.Data)
systray.AddMenuItem("Ignored", "Ignored")
subMenuTop := systray.AddMenuItem("SubMenuTop", "SubMenu Test (top)")
subMenuMiddle := subMenuTop.AddSubMenuItem("SubMenuMiddle", "SubMenu Test (middle)")
subMenuBottom := subMenuMiddle.AddSubMenuItemCheckbox("SubMenuBottom - Toggle Panic!", "SubMenu Test (bottom) - Hide/Show Panic!", false)
subMenuBottom2 := subMenuMiddle.AddSubMenuItem("SubMenuBottom - Panic!", "SubMenu Test (bottom)")
systray.AddSeparator()
mToggle := systray.AddMenuItem("Toggle", "Toggle some menu items")
shown := true
toggle := func() {
if shown {
subMenuBottom.Check()
subMenuBottom2.Hide()
mEnabled.Hide()
shown = false
} else {
subMenuBottom.Uncheck()
subMenuBottom2.Show()
mEnabled.Show()
shown = true
}
}
mReset := systray.AddMenuItem("Reset", "Reset all items")
for {
select {
case <-mChange.ClickedCh:
mChange.SetTitle("I've Changed")
case <-mChecked.ClickedCh:
if mChecked.Checked() {
mChecked.Uncheck()
mChecked.SetTitle("Unchecked")
} else {
mChecked.Check()
mChecked.SetTitle("Checked")
}
case <-mEnabled.ClickedCh:
mEnabled.SetTitle("Disabled")
mEnabled.Disable()
case <-subMenuBottom2.ClickedCh:
panic("panic button pressed")
case <-subMenuBottom.ClickedCh:
toggle()
case <-mReset.ClickedCh:
systray.ResetMenu()
addQuitItem()
case <-mToggle.ClickedCh:
toggle()
}
}
}()
}