This repository has been archived on 2022-06-29. You can view files and clone it, but cannot push or open issues or pull requests.
urtrator/ui/mainwindow_helpers.go
pztrn e46d203a3c Many fixes and debug prints removed.
Removed debug prints, as we don't really need them now.

Fixed database updating from cache, until now only inserts was working
fine, updates failing. All because of forgotten comma :(.

Reworked handling of icons in servers lists, now they didn't
recreated, but reused from created on application start. Can also
save us much memory for long runs.

Moved gamemode detector to mainwindow_helpers, where it should be.
2016-10-07 22:21:19 +05:00

46 lines
1.1 KiB
Go

package ui
import (
// stdlib
"strings"
// other
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func (m *MainWindow) getGameModeName(name string) string {
val, ok := m.gamemodes[name]
if !ok {
return "Unknown or custom"
}
return val
}
func (m *MainWindow) getIpFromServersList(current_tab string) string {
// Getting server's address from list.
sel := m.all_servers.GetSelection()
model := m.all_servers.GetModel()
iter := new(gtk.TreeIter)
_ = sel.GetSelected(iter)
// Getting server address.
var srv_addr string
srv_addr_gval := glib.ValueFromNative(srv_addr)
model.GetValue(iter, m.column_pos["Servers"]["IP"], srv_addr_gval)
if strings.Contains(current_tab, "Favorites") {
// Getting server's address from list.
sel = m.fav_servers.GetSelection()
model = m.fav_servers.GetModel()
iter := new(gtk.TreeIter)
_ = sel.GetSelected(iter)
model.GetValue(iter, m.column_pos["Favorites"]["IP"], srv_addr_gval)
}
server_address := srv_addr_gval.GetString()
return server_address
}