Updated to latest GTK2 bindings API and moved to Gitlab.

This commit is contained in:
Stanislav Nikitin 2018-11-10 13:21:53 +05:00
parent 070aa50762
commit 127e1b8ab9
27 changed files with 3347 additions and 3351 deletions

View File

@ -15,7 +15,7 @@ import (
"sync" "sync"
// local // local
"github.com/pztrn/urtrator/cachemodels" "gitlab.com/pztrn/urtrator/cachemodels"
) )
type Cache struct { type Cache struct {

View File

@ -15,8 +15,8 @@ import (
"strconv" "strconv"
// local // local
"github.com/pztrn/urtrator/cachemodels" "gitlab.com/pztrn/urtrator/cachemodels"
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
) )
func (c *Cache) CreateProfile(name string) { func (c *Cache) CreateProfile(name string) {

View File

@ -14,8 +14,8 @@ import (
"fmt" "fmt"
// local // local
"github.com/pztrn/urtrator/cachemodels" "gitlab.com/pztrn/urtrator/cachemodels"
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
) )
func (c *Cache) CreateServer(addr string) { func (c *Cache) CreateServer(addr string) {

4
cache/exported.go vendored
View File

@ -11,8 +11,8 @@ package cache
import ( import (
// local // local
event "github.com/pztrn/urtrator/eventer" "gitlab.com/pztrn/urtrator/database"
"github.com/pztrn/urtrator/database" event "gitlab.com/pztrn/urtrator/eventer"
) )
var ( var (

View File

@ -11,7 +11,7 @@ package cachemodels
import ( import (
// local // local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
) )
type Profile struct { type Profile struct {

View File

@ -11,7 +11,7 @@ package cachemodels
import ( import (
// local // local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Other // Other
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"

View File

@ -9,10 +9,10 @@
// ToDo: put full text of license here. // ToDo: put full text of license here.
package clipboardwatcher package clipboardwatcher
import( import (
// local // local
"github.com/pztrn/urtrator/cache" "gitlab.com/pztrn/urtrator/cache"
"github.com/pztrn/urtrator/eventer" "gitlab.com/pztrn/urtrator/eventer"
) )
var ( var (

View File

@ -15,16 +15,16 @@ import (
"fmt" "fmt"
// local // local
"github.com/pztrn/urtrator/cache" "gitlab.com/pztrn/urtrator/cache"
"github.com/pztrn/urtrator/clipboardwatcher" "gitlab.com/pztrn/urtrator/clipboardwatcher"
"github.com/pztrn/urtrator/colorizer" "gitlab.com/pztrn/urtrator/colorizer"
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
"github.com/pztrn/urtrator/database" "gitlab.com/pztrn/urtrator/database"
"github.com/pztrn/urtrator/eventer" "gitlab.com/pztrn/urtrator/eventer"
"github.com/pztrn/urtrator/launcher" "gitlab.com/pztrn/urtrator/launcher"
"github.com/pztrn/urtrator/requester" "gitlab.com/pztrn/urtrator/requester"
"github.com/pztrn/urtrator/timer" "gitlab.com/pztrn/urtrator/timer"
"github.com/pztrn/urtrator/translator" "gitlab.com/pztrn/urtrator/translator"
// Github // Github
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"

View File

@ -18,8 +18,8 @@ import (
"strconv" "strconv"
// local // local
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Other // Other
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -89,6 +89,5 @@ func (d *Database) Migrate() {
fmt.Println("No database found, will create new one") fmt.Println("No database found, will create new one")
} }
migrate_full(d, dbver) migrate_full(d, dbver)
} }

View File

@ -11,7 +11,7 @@ package database
import ( import (
// Local // Local
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
) )
var ( var (

View File

@ -51,14 +51,14 @@ fi
# Okay, let's compile. # Okay, let's compile.
echo "Getting URTrator (and dependencies) sources" echo "Getting URTrator (and dependencies) sources"
go get -u -v -d github.com/pztrn/urtrator go get -u -v -d gitlab.com/pztrn/urtrator
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to get URTrator sources" echo "Failed to get URTrator sources"
exit 1 exit 1
fi fi
echo "Building URTrator..." echo "Building URTrator..."
go install -v github.com/pztrn/urtrator go install -v gitlab.com/pztrn/urtrator
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Failed to build URTrator! Please, create a new bug report at https://github.com/pztrn/urtrator and attach FULL console output!" echo "Failed to build URTrator! Please, create a new bug report at https://github.com/pztrn/urtrator and attach FULL console output!"
exit 1 exit 1
@ -69,7 +69,7 @@ mkdir -p URTrator.app/Contents/{MacOS,Framework,Resources}
# Copying URTrator binary # Copying URTrator binary
cp $GOPATH/bin/urtrator URTrator.app/Contents/MacOS/ cp $GOPATH/bin/urtrator URTrator.app/Contents/MacOS/
# Copying main resources. # Copying main resources.
cp $GOPATH/src/github.com/pztrn/urtrator/artwork/urtrator.icns ./URTrator.app/Contents/Resources/ cp $GOPATH/src/gitlab.com/pztrn/urtrator/artwork/urtrator.icns ./URTrator.app/Contents/Resources/
cp -R ./Resources/themes ./URTrator.app/Contents/Resources/ cp -R ./Resources/themes ./URTrator.app/Contents/Resources/
##################################################################### #####################################################################
@ -90,7 +90,7 @@ INFOPLIST='<?xml version="1.0" encoding="UTF-8"?>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>urtrator.icns</string> <string>urtrator.icns</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.1.0</string> <string>0.2.0</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>

View File

@ -21,7 +21,7 @@ import (
"strings" "strings"
// local // local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Github // Github
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"
@ -101,7 +101,7 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
} }
launch_params = append(launch_params, "--", ":" + display) launch_params = append(launch_params, "--", ":"+display)
} }
if runtime.GOOS == "darwin" { if runtime.GOOS == "darwin" {
// On macOS we should not start binary, but application bundle. // On macOS we should not start binary, but application bundle.
@ -130,7 +130,7 @@ func (l *Launcher) Launch(server_profile *datamodels.Server, user_profile *datam
}() }()
select { select {
case <- done: case <-done:
callback() callback()
} }
}() }()

View File

@ -14,10 +14,10 @@ import (
"fmt" "fmt"
// local // local
"github.com/pztrn/urtrator/cache" "gitlab.com/pztrn/urtrator/cache"
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
"github.com/pztrn/urtrator/eventer" "gitlab.com/pztrn/urtrator/eventer"
"github.com/pztrn/urtrator/timer" "gitlab.com/pztrn/urtrator/timer"
) )
var ( var (

View File

@ -21,7 +21,7 @@ import (
"time" "time"
// local // local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
) )
type Pooler struct { type Pooler struct {
@ -222,25 +222,25 @@ func (p *Pooler) UpdateSpecificServer(server *datamodels.Server) error {
// Parse server configuration into passed server's datamodel. // Parse server configuration into passed server's datamodel.
for i := 0; i < len(srv_config); i = i + 1 { for i := 0; i < len(srv_config); i = i + 1 {
if srv_config[i] == "g_modversion" { if srv_config[i] == "g_modversion" {
server.Version = srv_config[i + 1] server.Version = srv_config[i+1]
} }
if srv_config[i] == "g_gametype" { if srv_config[i] == "g_gametype" {
server.Gamemode = srv_config[i + 1] server.Gamemode = srv_config[i+1]
} }
if srv_config[i] == "sv_maxclients" { if srv_config[i] == "sv_maxclients" {
server.Maxplayers = srv_config[i + 1] server.Maxplayers = srv_config[i+1]
} }
if srv_config[i] == "clients" { if srv_config[i] == "clients" {
server.Players = srv_config[i + 1] server.Players = srv_config[i+1]
} }
if srv_config[i] == "mapname" { if srv_config[i] == "mapname" {
server.Map = srv_config[i + 1] server.Map = srv_config[i+1]
} }
if srv_config[i] == "sv_hostname" { if srv_config[i] == "sv_hostname" {
server.Name = srv_config[i + 1] server.Name = srv_config[i+1]
} }
if srv_config[i] == "g_needpass" { if srv_config[i] == "g_needpass" {
if srv_config[i + 1] == "0" { if srv_config[i+1] == "0" {
server.IsPrivate = "0" server.IsPrivate = "0"
} else { } else {
server.IsPrivate = "1" server.IsPrivate = "1"

View File

@ -14,8 +14,8 @@ import (
"fmt" "fmt"
// local // local
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
"github.com/pztrn/urtrator/eventer" "gitlab.com/pztrn/urtrator/eventer"
) )
var ( var (

View File

@ -11,7 +11,7 @@ package translator
import ( import (
// local // local
"github.com/pztrn/urtrator/configuration" "gitlab.com/pztrn/urtrator/configuration"
) )
var ( var (

View File

@ -11,7 +11,7 @@ package ui
import ( import (
// local // local
"github.com/pztrn/urtrator/common" "gitlab.com/pztrn/urtrator/common"
// other // other
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"
@ -23,7 +23,7 @@ func ShowAboutDialog() {
ad.SetProgramName("URTrator") ad.SetProgramName("URTrator")
ad.SetComments(ctx.Translator.Translate("Urban Terror servers browser and game launcher", nil)) ad.SetComments(ctx.Translator.Translate("Urban Terror servers browser and game launcher", nil))
ad.SetVersion(common.URTRATOR_VERSION) ad.SetVersion(common.URTRATOR_VERSION)
ad.SetWebsite("http://urtrator.pztrn.name") ad.SetWebsite("https://gitlab.com/pztrn/urtrator")
ad.SetLogo(logo) ad.SetLogo(logo)
// ToDo: put it in plain text files. // ToDo: put it in plain text files.

View File

@ -11,7 +11,7 @@ package ui
import ( import (
// local // local
"github.com/pztrn/urtrator/context" "gitlab.com/pztrn/urtrator/context"
// Other // Other
"github.com/mattn/go-gtk/gdkpixbuf" "github.com/mattn/go-gtk/gdkpixbuf"

View File

@ -18,9 +18,9 @@ import (
"strings" "strings"
// Local // Local
"github.com/pztrn/urtrator/cachemodels" "gitlab.com/pztrn/urtrator/cachemodels"
"github.com/pztrn/urtrator/common" "gitlab.com/pztrn/urtrator/common"
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Other // Other
"github.com/mattn/go-gtk/gdkpixbuf" "github.com/mattn/go-gtk/gdkpixbuf"
@ -178,7 +178,7 @@ func (f *FavoriteDialog) initializeWindow() {
table.Attach(profile_label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK, 5, 5) table.Attach(profile_label, 0, 1, 3, 4, gtk.FILL, gtk.SHRINK, 5, 5)
f.profile = gtk.NewComboBoxText() f.profile = gtk.NewComboBoxText()
table.Attach(f.profile , 1, 2, 3, 4, gtk.FILL, gtk.FILL, 5, 5) table.Attach(f.profile, 1, 2, 3, 4, gtk.FILL, gtk.FILL, 5, 5)
// Invisible thing. // Invisible thing.
inv_label1 := gtk.NewLabel("") inv_label1 := gtk.NewLabel("")

View File

@ -18,8 +18,8 @@ import (
"strings" "strings"
// Local // Local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
"github.com/pztrn/urtrator/ioq3dataparser" "gitlab.com/pztrn/urtrator/ioq3dataparser"
// Other // Other
"github.com/mattn/go-gtk/gdkpixbuf" "github.com/mattn/go-gtk/gdkpixbuf"
@ -143,7 +143,6 @@ type MainWindow struct {
// For public server // For public server
server_public_pic *gdkpixbuf.Pixbuf server_public_pic *gdkpixbuf.Pixbuf
// Flags. // Flags.
// Application is initialized? // Application is initialized?
initialized bool initialized bool
@ -209,8 +208,8 @@ func (m *MainWindow) checkMainPanePosition() {
// widgets hell :). // widgets hell :).
func (m *MainWindow) checkPositionAndSize() { func (m *MainWindow) checkPositionAndSize() {
glib.IdleAdd(func() bool { glib.IdleAdd(func() bool {
m.window.GetPosition(&m.window_pos_x, &m.window_pos_y) m.window_pos_x, m.window_pos_y = m.window.GetPosition()
m.window.GetSize(&m.window_width, &m.window_height) m.window_width, m.window_height = m.window.GetSize()
m.hpane.SetPosition(m.window_width - m.pane_negative_position) m.hpane.SetPosition(m.window_width - m.pane_negative_position)
return false return false
@ -229,13 +228,13 @@ func (m *MainWindow) Close() {
// Saving columns sizes and positions. // Saving columns sizes and positions.
all_servers_columns := m.all_servers.GetColumns() all_servers_columns := m.all_servers.GetColumns()
for i := range all_servers_columns { for i := range all_servers_columns {
ctx.Cfg.Cfg["/mainwindow/all_servers/" + all_servers_columns[i].GetTitle() + "_position"] = strconv.Itoa(i) ctx.Cfg.Cfg["/mainwindow/all_servers/"+all_servers_columns[i].GetTitle()+"_position"] = strconv.Itoa(i)
ctx.Cfg.Cfg["/mainwindow/all_servers/" + all_servers_columns[i].GetTitle() + "_width"] = strconv.Itoa(all_servers_columns[i].GetWidth()) ctx.Cfg.Cfg["/mainwindow/all_servers/"+all_servers_columns[i].GetTitle()+"_width"] = strconv.Itoa(all_servers_columns[i].GetWidth())
} }
fav_servers_columns := m.fav_servers.GetColumns() fav_servers_columns := m.fav_servers.GetColumns()
for i := range fav_servers_columns { for i := range fav_servers_columns {
ctx.Cfg.Cfg["/mainwindow/fav_servers/" + fav_servers_columns[i].GetTitle() + "_position"] = strconv.Itoa(i) ctx.Cfg.Cfg["/mainwindow/fav_servers/"+fav_servers_columns[i].GetTitle()+"_position"] = strconv.Itoa(i)
ctx.Cfg.Cfg["/mainwindow/fav_servers/" + fav_servers_columns[i].GetTitle() + "_width"] = strconv.Itoa(fav_servers_columns[i].GetWidth()) ctx.Cfg.Cfg["/mainwindow/fav_servers/"+fav_servers_columns[i].GetTitle()+"_width"] = strconv.Itoa(fav_servers_columns[i].GetWidth())
} }
// Additional actions should be taken on Windows. // Additional actions should be taken on Windows.
@ -453,7 +452,7 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
if server.Server.Name == "" && server.Server.Players == "" { if server.Server.Name == "" && server.Server.Players == "" {
m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf) m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("IP", nil)], server.Server.Ip + ":" + server.Server.Port) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("IP", nil)], server.Server.Ip+":"+server.Server.Port)
} else { } else {
if ping > 9000 { if ping > 9000 {
m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf) m.all_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
@ -469,10 +468,10 @@ func (m *MainWindow) loadAllServers(data map[string]string) {
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], server_name) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], server_name)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Mode", nil)], m.getGameModeName(server.Server.Gamemode)) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Mode", nil)], m.getGameModeName(server.Server.Gamemode))
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Map", nil)], server.Server.Map) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Map", nil)], server.Server.Map)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Players", nil)], server.Server.Players + "/" + server.Server.Bots + "/" + server.Server.Maxplayers) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Players", nil)], server.Server.Players+"/"+server.Server.Bots+"/"+server.Server.Maxplayers)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Ping", nil)], server.Server.Ping) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Ping", nil)], server.Server.Ping)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Version", nil)], server.Server.Version) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("Version", nil)], server.Server.Version)
m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("IP", nil)], server.Server.Ip + ":" + server.Server.Port) m.all_servers_store.SetValue(iter, m.column_pos["Servers"][ctx.Translator.Translate("IP", nil)], server.Server.Ip+":"+server.Server.Port)
} }
} }
} }
@ -549,7 +548,7 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
if server.Server.Name == "" && server.Server.Players == "" { if server.Server.Name == "" && server.Server.Players == "" {
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf) m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("IP", nil)], server.Server.Ip + ":" + server.Server.Port) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("IP", nil)], server.Server.Ip+":"+server.Server.Port)
} else { } else {
if ping > 9000 { if ping > 9000 {
m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf) m.fav_servers_store.SetValue(iter, 0, m.server_offline_pic.GPixbuf)
@ -565,10 +564,10 @@ func (m *MainWindow) loadFavoriteServers(data map[string]string) {
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Name", nil)], server_name) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Name", nil)], server_name)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Mode", nil)], m.getGameModeName(server.Server.Gamemode)) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Mode", nil)], m.getGameModeName(server.Server.Gamemode))
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Map", nil)], server.Server.Map) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Map", nil)], server.Server.Map)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Players", nil)], server.Server.Players + "/" + server.Server.Bots + "/" + server.Server.Maxplayers) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Players", nil)], server.Server.Players+"/"+server.Server.Bots+"/"+server.Server.Maxplayers)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Ping", nil)], server.Server.Ping) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Ping", nil)], server.Server.Ping)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Version", nil)], server.Server.Version) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("Version", nil)], server.Server.Version)
m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("IP", nil)], server.Server.Ip + ":" + server.Server.Port) m.fav_servers_store.SetValue(iter, m.column_pos["Favorites"][ctx.Translator.Translate("IP", nil)], server.Server.Ip+":"+server.Server.Port)
} }
} }
} }
@ -710,14 +709,14 @@ func (m *MainWindow) showShortServerInformation() {
iter = new(gtk.TreeIter) iter = new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, ctx.Translator.Translate("Players", nil)) m.server_info_store.SetValue(iter, 0, ctx.Translator.Translate("Players", nil))
m.server_info_store.SetValue(iter, 1, server_info.Players + " of " + parsed_general_data["sv_maxclients"] + " (" + server_info.Bots + " bots)") m.server_info_store.SetValue(iter, 1, server_info.Players+" of "+parsed_general_data["sv_maxclients"]+" ("+server_info.Bots+" bots)")
delete(parsed_general_data, "sv_maxclients") delete(parsed_general_data, "sv_maxclients")
// Ping // Ping
iter = new(gtk.TreeIter) iter = new(gtk.TreeIter)
m.server_info_store.Append(iter) m.server_info_store.Append(iter)
m.server_info_store.SetValue(iter, 0, ctx.Translator.Translate("Ping", nil)) m.server_info_store.SetValue(iter, 0, ctx.Translator.Translate("Ping", nil))
m.server_info_store.SetValue(iter, 1, server_info.Ping + " ms") m.server_info_store.SetValue(iter, 1, server_info.Ping+" ms")
// Game mode // Game mode
iter = new(gtk.TreeIter) iter = new(gtk.TreeIter)

View File

@ -9,8 +9,8 @@ import (
"strconv" "strconv"
// local // local
"github.com/pztrn/urtrator/common" "gitlab.com/pztrn/urtrator/common"
"github.com/pztrn/urtrator/timer" "gitlab.com/pztrn/urtrator/timer"
// Other // Other
"github.com/mattn/go-gtk/gdkpixbuf" "github.com/mattn/go-gtk/gdkpixbuf"
@ -109,8 +109,7 @@ func (m *MainWindow) Initialize() {
pane_negative_pos, _ := strconv.Atoi(saved_pane_pos) pane_negative_pos, _ := strconv.Atoi(saved_pane_pos)
m.hpane.SetPosition(m.window_width - pane_negative_pos) m.hpane.SetPosition(m.window_width - pane_negative_pos)
} else { } else {
var w, h int = 0, 0 w, _ := m.window.GetSize()
m.window.GetSize(&w, &h)
m.hpane.SetPosition(w - 150) m.hpane.SetPosition(w - 150)
} }
@ -444,18 +443,18 @@ func (m *MainWindow) InitializeTabs() {
// ...aand lets do dynamic generation :) // ...aand lets do dynamic generation :)
// +2 because we have 2 static columns. // +2 because we have 2 static columns.
all_servers_columns_to_append := make([]*gtk.TreeViewColumn, len(m.column_names) + 2) all_servers_columns_to_append := make([]*gtk.TreeViewColumn, len(m.column_names)+2)
for pos, name := range m.column_names { for pos, name := range m.column_names {
// Check if we have column position saved. If so - use it. // Check if we have column position saved. If so - use it.
// Otherwise use default position. // Otherwise use default position.
// Should be actual only for first launch. // Should be actual only for first launch.
position := ctx.Cfg.Cfg["/mainwindow/all_servers/" + ctx.Translator.Translate(name, nil) + "_position"] position := ctx.Cfg.Cfg["/mainwindow/all_servers/"+ctx.Translator.Translate(name, nil)+"_position"]
if len(position) == 0 { if len(position) == 0 {
position = pos position = pos
} }
position_int, _ := strconv.Atoi(position) position_int, _ := strconv.Atoi(position)
// Same for width. // Same for width.
width := ctx.Cfg.Cfg["/mainwindow/all_servers/" + ctx.Translator.Translate(name, nil) + "_width"] width := ctx.Cfg.Cfg["/mainwindow/all_servers/"+ctx.Translator.Translate(name, nil)+"_width"]
if len(width) == 0 { if len(width) == 0 {
width = "-1" width = "-1"
} }
@ -486,9 +485,9 @@ func (m *MainWindow) InitializeTabs() {
m.all_servers_store_sortable.SetSortColumnId(m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], gtk.SORT_ASCENDING) m.all_servers_store_sortable.SetSortColumnId(m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], gtk.SORT_ASCENDING)
// Sorting functions. // Sorting functions.
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], m.sortServersByName) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Name", nil)], m.sortServersByName, nil)
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Players", nil)], m.sortServersByPlayers) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Players", nil)], m.sortServersByPlayers, nil)
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Ping", nil)], m.sortServersByPing) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Servers"][ctx.Translator.Translate("Ping", nil)], m.sortServersByPing, nil)
// Selection changed signal, which will update server's short info pane. // Selection changed signal, which will update server's short info pane.
m.all_servers.Connect("cursor-changed", m.showShortServerInformation) m.all_servers.Connect("cursor-changed", m.showShortServerInformation)
@ -586,18 +585,18 @@ func (m *MainWindow) InitializeTabs() {
m.fav_servers.AppendColumn(gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate("Public", nil), gtk.NewCellRendererPixbuf(), "pixbuf", 1)) m.fav_servers.AppendColumn(gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate("Public", nil), gtk.NewCellRendererPixbuf(), "pixbuf", 1))
// +2 because we have 2 static columns. // +2 because we have 2 static columns.
fav_servers_columns_to_append := make([]*gtk.TreeViewColumn, len(m.column_names) + 2) fav_servers_columns_to_append := make([]*gtk.TreeViewColumn, len(m.column_names)+2)
for pos, name := range m.column_names { for pos, name := range m.column_names {
// Check if we have column position saved. If so - use it. // Check if we have column position saved. If so - use it.
// Otherwise use default position. // Otherwise use default position.
// Should be actual only for first launch. // Should be actual only for first launch.
position := ctx.Cfg.Cfg["/mainwindow/fav_servers/" + ctx.Translator.Translate(name, nil) + "_position"] position := ctx.Cfg.Cfg["/mainwindow/fav_servers/"+ctx.Translator.Translate(name, nil)+"_position"]
if len(position) == 0 { if len(position) == 0 {
position = pos position = pos
} }
position_int, _ := strconv.Atoi(position) position_int, _ := strconv.Atoi(position)
// Same for width. // Same for width.
width := ctx.Cfg.Cfg["/mainwindow/fav_servers/" + ctx.Translator.Translate(name, nil) + "_width"] width := ctx.Cfg.Cfg["/mainwindow/fav_servers/"+ctx.Translator.Translate(name, nil)+"_width"]
if len(width) == 0 { if len(width) == 0 {
width = "-1" width = "-1"
} }
@ -628,9 +627,9 @@ func (m *MainWindow) InitializeTabs() {
} }
// Sorting functions. // Sorting functions.
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Name", nil)], m.sortServersByName) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Name", nil)], m.sortServersByName, nil)
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Players", nil)], m.sortServersByPlayers) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Players", nil)], m.sortServersByPlayers, nil)
m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Ping", nil)], m.sortServersByPing) m.all_servers_store_sortable.SetSortFunc(m.column_pos["Favorites"][ctx.Translator.Translate("Ping", nil)], m.sortServersByPing, nil)
// Selection changed signal, which will update server's short info pane. // Selection changed signal, which will update server's short info pane.
m.fav_servers.Connect("cursor-changed", m.showShortServerInformation) m.fav_servers.Connect("cursor-changed", m.showShortServerInformation)

View File

@ -8,7 +8,7 @@ import (
"strings" "strings"
// Local // Local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// other // other
"github.com/mattn/go-gtk/glib" "github.com/mattn/go-gtk/glib"
@ -238,10 +238,10 @@ func (m *MainWindow) launchActually(server_profile *datamodels.Server, user_prof
// Clear server name from "<markup></markup>" things. // Clear server name from "<markup></markup>" things.
srv_name_for_label := server_profile.Name srv_name_for_label := server_profile.Name
if strings.Contains(server_profile.Name, "markup") { if strings.Contains(server_profile.Name, "markup") {
srv_name_for_label = string([]byte(server_profile.Name)[8:len(server_profile.Name)-9]) srv_name_for_label = string([]byte(server_profile.Name)[8 : len(server_profile.Name)-9])
} else { } else {
srv_name := ctx.Colorizer.Fix(server_profile.Name) srv_name := ctx.Colorizer.Fix(server_profile.Name)
srv_name_for_label = string([]byte(srv_name)[8:len(srv_name)-9]) srv_name_for_label = string([]byte(srv_name)[8 : len(srv_name)-9])
} }
// Show great coloured label. // Show great coloured label.
ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "<markup><span foreground=\"red\" font_weight=\"bold\">" + ctx.Translator.Translate("Urban Terror is launched with profile", nil) + " </span><span foreground=\"blue\">" + user_profile.Name + "</span> <span foreground=\"red\" font_weight=\"bold\">" + ctx.Translator.Translate("and connected to", nil) + " </span><span foreground=\"orange\" font_weight=\"bold\">" + srv_name_for_label + "</span></markup>"}) ctx.Eventer.LaunchEvent("setToolbarLabelText", map[string]string{"text": "<markup><span foreground=\"red\" font_weight=\"bold\">" + ctx.Translator.Translate("Urban Terror is launched with profile", nil) + " </span><span foreground=\"blue\">" + user_profile.Name + "</span> <span foreground=\"red\" font_weight=\"bold\">" + ctx.Translator.Translate("and connected to", nil) + " </span><span foreground=\"orange\" font_weight=\"bold\">" + srv_name_for_label + "</span></markup>"})

View File

@ -10,7 +10,7 @@ import (
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"
) )
func (m *MainWindow) sortServersByName(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int { func (m *MainWindow) sortServersByName(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter, userData interface{}) int {
var name1_raw glib.GValue var name1_raw glib.GValue
var name2_raw glib.GValue var name2_raw glib.GValue
@ -37,7 +37,7 @@ func (m *MainWindow) sortServersByName(model *gtk.TreeModel, a *gtk.TreeIter, b
return 0 return 0
} }
func (m *MainWindow) sortServersByPlayers(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int { func (m *MainWindow) sortServersByPlayers(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter, userData interface{}) int {
var players1_raw glib.GValue var players1_raw glib.GValue
var players2_raw glib.GValue var players2_raw glib.GValue
@ -68,7 +68,7 @@ func (m *MainWindow) sortServersByPlayers(model *gtk.TreeModel, a *gtk.TreeIter,
return -1 return -1
} }
func (m *MainWindow) sortServersByPing(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter) int { func (m *MainWindow) sortServersByPing(model *gtk.TreeModel, a *gtk.TreeIter, b *gtk.TreeIter, userData interface{}) int {
var ping1_raw glib.GValue var ping1_raw glib.GValue
var ping2_raw glib.GValue var ping2_raw glib.GValue

View File

@ -15,11 +15,11 @@ import (
"runtime" "runtime"
// Local // Local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Other // Other
"github.com/mattn/go-gtk/gtk"
"github.com/mattn/go-gtk/glib" "github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
) )
type OptionsDialog struct { type OptionsDialog struct {
@ -194,7 +194,7 @@ func (o *OptionsDialog) initializeAppearanceTab() {
} }
o.language_combo.SetActive(lang_active) o.language_combo.SetActive(lang_active)
appearance_table.Attach(o.language_combo, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL, 5, 5) appearance_table.Attach(o.language_combo, 1, 2, 0, 1, gtk.FILL|gtk.EXPAND, gtk.FILL, 5, 5)
appearance_vbox.PackStart(appearance_table, false, true, 0) appearance_vbox.PackStart(appearance_table, false, true, 0)
o.tab_widget.AppendPage(appearance_vbox, gtk.NewLabel(ctx.Translator.Translate("Appearance", nil))) o.tab_widget.AppendPage(appearance_vbox, gtk.NewLabel(ctx.Translator.Translate("Appearance", nil)))
@ -212,7 +212,7 @@ func (o *OptionsDialog) initializeGeneralTab() {
o.show_tray_icon = gtk.NewCheckButtonWithLabel("") o.show_tray_icon = gtk.NewCheckButtonWithLabel("")
o.show_tray_icon.SetTooltipText(ctx.Translator.Translate("Show icon in tray", nil)) o.show_tray_icon.SetTooltipText(ctx.Translator.Translate("Show icon in tray", nil))
general_table.Attach(o.show_tray_icon, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL, 5, 5) general_table.Attach(o.show_tray_icon, 1, 2, 0, 1, gtk.FILL|gtk.EXPAND, gtk.FILL, 5, 5)
// Autoupdate checkbox. // Autoupdate checkbox.
autoupdate_tooltip := ctx.Translator.Translate("Should URTrator check for updates and update itself? Not working now.", nil) autoupdate_tooltip := ctx.Translator.Translate("Should URTrator check for updates and update itself? Not working now.", nil)
@ -223,7 +223,7 @@ func (o *OptionsDialog) initializeGeneralTab() {
o.autoupdate = gtk.NewCheckButtonWithLabel("") o.autoupdate = gtk.NewCheckButtonWithLabel("")
o.autoupdate.SetTooltipText(autoupdate_tooltip) o.autoupdate.SetTooltipText(autoupdate_tooltip)
general_table.Attach(o.autoupdate, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL, 5, 5) general_table.Attach(o.autoupdate, 1, 2, 1, 2, gtk.FILL|gtk.EXPAND, gtk.FILL, 5, 5)
// Vertical separator. // Vertical separator.
sep := gtk.NewVBox(false, 0) sep := gtk.NewVBox(false, 0)
@ -256,11 +256,11 @@ func (o *OptionsDialog) initializeServersOptionsTab() {
servers_autoupdate_cb_label := gtk.NewLabel(ctx.Translator.Translate("Servers autoupdate", nil)) servers_autoupdate_cb_label := gtk.NewLabel(ctx.Translator.Translate("Servers autoupdate", nil))
servers_autoupdate_cb_label.SetTooltipText(servers_autoupdate_cb_tooptip) servers_autoupdate_cb_label.SetTooltipText(servers_autoupdate_cb_tooptip)
servers_autoupdate_cb_label.SetAlignment(0, 0) servers_autoupdate_cb_label.SetAlignment(0, 0)
servers_updating_table.Attach(servers_autoupdate_cb_label, 0, 1 ,1, 2, gtk.FILL, gtk.SHRINK, 5, 5) servers_updating_table.Attach(servers_autoupdate_cb_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
o.servers_autoupdate = gtk.NewCheckButtonWithLabel("") o.servers_autoupdate = gtk.NewCheckButtonWithLabel("")
o.servers_autoupdate.SetTooltipText(servers_autoupdate_cb_tooptip) o.servers_autoupdate.SetTooltipText(servers_autoupdate_cb_tooptip)
servers_updating_table.Attach(o.servers_autoupdate, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL, 5, 5) servers_updating_table.Attach(o.servers_autoupdate, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, gtk.FILL, 5, 5)
// Servers update timeout. // Servers update timeout.
servers_autoupdate_timeout_tooltip := ctx.Translator.Translate("Timeout which will trigger servers information update, in minutes.", nil) servers_autoupdate_timeout_tooltip := ctx.Translator.Translate("Timeout which will trigger servers information update, in minutes.", nil)

View File

@ -17,7 +17,7 @@ import (
"strings" "strings"
// Local // Local
"github.com/pztrn/urtrator/datamodels" "gitlab.com/pztrn/urtrator/datamodels"
// Other // Other
"github.com/mattn/go-gtk/gtk" "github.com/mattn/go-gtk/gtk"
@ -185,7 +185,6 @@ func (op *OptionsProfile) Initialize(update bool) {
op.profile_name.SetTooltipText(profile_name_tooltip) op.profile_name.SetTooltipText(profile_name_tooltip)
op.table.Attach(op.profile_name, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5) op.table.Attach(op.profile_name, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
// Urban Terror version. // Urban Terror version.
urt_version_tooltip := ctx.Translator.Translate("Urban Terror version for which this profile applies.", nil) urt_version_tooltip := ctx.Translator.Translate("Urban Terror version for which this profile applies.", nil)
urt_version_label := gtk.NewLabel(ctx.Translator.Translate("Urban Terror version:", nil)) urt_version_label := gtk.NewLabel(ctx.Translator.Translate("Urban Terror version:", nil))

View File

@ -15,11 +15,11 @@ import (
"sort" "sort"
// Local // Local
"github.com/pztrn/urtrator/ioq3dataparser" "gitlab.com/pztrn/urtrator/ioq3dataparser"
// Other // Other
"github.com/mattn/go-gtk/gtk"
"github.com/mattn/go-gtk/glib" "github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
) )
type ServerCVarsDialog struct { type ServerCVarsDialog struct {

View File

@ -11,9 +11,9 @@ package main
import ( import (
// local // local
"github.com/pztrn/urtrator/common" "gitlab.com/pztrn/urtrator/common"
"github.com/pztrn/urtrator/context" "gitlab.com/pztrn/urtrator/context"
"github.com/pztrn/urtrator/ui/gtk2" "gitlab.com/pztrn/urtrator/ui/gtk2"
//"github.com/pztrn/urtrator/ui/qt5" //"github.com/pztrn/urtrator/ui/qt5"
// stdlib // stdlib