From 7f80f9952950836ce49cff846f852548165f8a98 Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Fri, 4 Nov 2016 18:28:52 +0500 Subject: [PATCH] GTK actions fix WIP and icon size fix. Again, possibly fixed GTK actions calls from other goroutines by wrapping events calls in glib.IdleAdd(). This should prevent executing more than one event simultaneously, which will also prevent crashes. Fixed icons sizing for couple of icons. --- eventer/eventer_object.go | 20 ++++++++++++++++---- ui/favorite.go | 2 +- ui/mainwindow_init.go | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/eventer/eventer_object.go b/eventer/eventer_object.go index f5160bf..acdd097 100644 --- a/eventer/eventer_object.go +++ b/eventer/eventer_object.go @@ -13,6 +13,10 @@ import ( crand "crypto/rand" "errors" "fmt" + //"reflect" + + // github + "github.com/mattn/go-gtk/glib" ) type Eventer struct { @@ -44,11 +48,19 @@ func (e *Eventer) LaunchEvent(event string, data map[string]string) error { if !ok { return errors.New("Event " + event + " not found!") } - fmt.Println("Launching event " + event) - for _, val := range e.events[event] { - val(data) - } + fmt.Println("Launching event " + event) + glib.IdleAdd(func() bool { + e.reallyLaunchEvent(event, data) + return false + }) return nil } + +func (e *Eventer) reallyLaunchEvent(event string, data map[string]string) { + fmt.Println("Really launching event " + event + "...") + for _, val := range e.events[event] { + val(data) + } +} diff --git a/ui/favorite.go b/ui/favorite.go index da8a95a..9ba860e 100644 --- a/ui/favorite.go +++ b/ui/favorite.go @@ -152,7 +152,7 @@ func (f *FavoriteDialog) initializeWindow() { srv_addr_hbox.PackStart(f.server_address, true, true, 5) srv_addr_update_btn := gtk.NewButton() srv_addr_update_btn.SetTooltipText("Update server information") - srv_addr_update_btn_image := gtk.NewImageFromStock(gtk.STOCK_REDO, 24) + srv_addr_update_btn_image := gtk.NewImageFromStock(gtk.STOCK_REDO, gtk.ICON_SIZE_SMALL_TOOLBAR) srv_addr_update_btn.SetImage(srv_addr_update_btn_image) srv_addr_update_btn.Clicked(f.updateServerInfo) srv_addr_hbox.PackStart(srv_addr_update_btn, false, true, 5) diff --git a/ui/mainwindow_init.go b/ui/mainwindow_init.go index c7f71fb..a0cdd09 100644 --- a/ui/mainwindow_init.go +++ b/ui/mainwindow_init.go @@ -153,7 +153,7 @@ func (m *MainWindow) Initialize() { m.launch_button = gtk.NewButtonWithLabel("Launch!") m.launch_button.SetTooltipText("Launch Urban Terror") m.launch_button.Clicked(m.launchGame) - launch_button_image := gtk.NewImageFromStock(gtk.STOCK_APPLY, 24) + launch_button_image := gtk.NewImageFromStock(gtk.STOCK_APPLY, gtk.ICON_SIZE_SMALL_TOOLBAR) m.launch_button.SetImage(launch_button_image) profile_and_launch_hbox.PackStart(m.launch_button, false, true, 5)