Show selected server's information on active tab changing.
URTrator will now show information about selected server on activated tab. E.g. when you switched from "Servers" to "Favorites", sidebar informational widget will be updated with server's data for selected server on "Favorites" tab.
This commit is contained in:
parent
9c8aa1cc34
commit
5ca8299714
@ -132,8 +132,14 @@ type MainWindow struct {
|
|||||||
|
|
||||||
|
|
||||||
// Flags.
|
// Flags.
|
||||||
|
// Application is initialized?
|
||||||
|
initialized bool
|
||||||
// Window is hidden?
|
// Window is hidden?
|
||||||
hidden bool
|
hidden bool
|
||||||
|
// Use other's tab information?
|
||||||
|
// Used when user changed active tab, to show information about
|
||||||
|
// server which is selected on activated tab.
|
||||||
|
use_other_servers_tab bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MainWindow) addToFavorites() {
|
func (m *MainWindow) addToFavorites() {
|
||||||
@ -502,6 +508,24 @@ func (m *MainWindow) loadProfiles(data map[string]string) {
|
|||||||
m.profiles.SetActive(0)
|
m.profiles.SetActive(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MainWindow) tabChanged() {
|
||||||
|
if !m.initialized {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Active tab changed...")
|
||||||
|
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||||
|
fmt.Println(current_tab)
|
||||||
|
|
||||||
|
m.use_other_servers_tab = true
|
||||||
|
if strings.Contains(current_tab, "Servers") {
|
||||||
|
m.fav_servers.Emit("cursor-changed")
|
||||||
|
} else if strings.Contains(current_tab, "Favorites") {
|
||||||
|
m.all_servers.Emit("cursor-changed")
|
||||||
|
}
|
||||||
|
m.use_other_servers_tab = false
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MainWindow) serversUpdateCompleted(data map[string]string) {
|
func (m *MainWindow) serversUpdateCompleted(data map[string]string) {
|
||||||
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "Servers updated."})
|
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "Servers updated."})
|
||||||
// Trigger "selection-changed" events on currently active tab's
|
// Trigger "selection-changed" events on currently active tab's
|
||||||
@ -548,6 +572,13 @@ func (m *MainWindow) showShortServerInformation() {
|
|||||||
fmt.Println("Server selection changed, updating server's information widget...")
|
fmt.Println("Server selection changed, updating server's information widget...")
|
||||||
m.server_info_store.Clear()
|
m.server_info_store.Clear()
|
||||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||||
|
if m.use_other_servers_tab {
|
||||||
|
if strings.Contains(current_tab, "Servers") {
|
||||||
|
current_tab = "Favorites"
|
||||||
|
} else if strings.Contains(current_tab, "Favorites") {
|
||||||
|
current_tab = "Servers"
|
||||||
|
}
|
||||||
|
}
|
||||||
srv_address := m.getIpFromServersList(current_tab)
|
srv_address := m.getIpFromServersList(current_tab)
|
||||||
|
|
||||||
// Getting server information from cache.
|
// Getting server information from cache.
|
||||||
|
@ -165,6 +165,9 @@ func (m *MainWindow) Initialize() {
|
|||||||
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
ctx.Eventer.LaunchEvent("loadFavoriteServers", map[string]string{})
|
||||||
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "URTrator is ready."})
|
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "URTrator is ready."})
|
||||||
|
|
||||||
|
// Set flag that shows to other parts that we're initialized.
|
||||||
|
m.initialized = true
|
||||||
|
|
||||||
gtk.Main()
|
gtk.Main()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +294,9 @@ func (m *MainWindow) initializeSidebar() {
|
|||||||
|
|
||||||
// Initializes internal storages.
|
// Initializes internal storages.
|
||||||
func (m *MainWindow) initializeStorages() {
|
func (m *MainWindow) initializeStorages() {
|
||||||
|
// Application isn't initialized.
|
||||||
|
m.initialized = false
|
||||||
|
m.use_other_servers_tab = false
|
||||||
// Gamemodes.
|
// Gamemodes.
|
||||||
m.gamemodes = make(map[string]string)
|
m.gamemodes = make(map[string]string)
|
||||||
m.gamemodes = map[string]string{
|
m.gamemodes = map[string]string{
|
||||||
@ -379,6 +385,7 @@ func (m *MainWindow) initializeStorages() {
|
|||||||
func (m *MainWindow) InitializeTabs() {
|
func (m *MainWindow) InitializeTabs() {
|
||||||
// Create tabs widget.
|
// Create tabs widget.
|
||||||
m.tab_widget = gtk.NewNotebook()
|
m.tab_widget = gtk.NewNotebook()
|
||||||
|
m.tab_widget.Connect("switch-page", m.tabChanged)
|
||||||
|
|
||||||
tab_allsrv_hbox := gtk.NewHBox(false, 0)
|
tab_allsrv_hbox := gtk.NewHBox(false, 0)
|
||||||
swin1 := gtk.NewScrolledWindow(nil, nil)
|
swin1 := gtk.NewScrolledWindow(nil, nil)
|
||||||
|
Reference in New Issue
Block a user