2016-10-04 15:42:36 +05:00
|
|
|
// URTator - Urban Terror server browser and game launcher, written in
|
|
|
|
// Go.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2016, Stanslav N. a.k.a pztrn (or p0z1tr0n)
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under Terms and Conditions of GNU General Public License
|
|
|
|
// version 3 or any higher.
|
|
|
|
// ToDo: put full text of license here.
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
// stdlib
|
|
|
|
"fmt"
|
2016-11-22 01:10:31 +05:00
|
|
|
"runtime"
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
// Local
|
|
|
|
"github.com/pztrn/urtrator/datamodels"
|
|
|
|
|
|
|
|
// Other
|
|
|
|
"github.com/mattn/go-gtk/gtk"
|
|
|
|
"github.com/mattn/go-gtk/glib"
|
|
|
|
)
|
|
|
|
|
|
|
|
type OptionsDialog struct {
|
|
|
|
// Window.
|
|
|
|
window *gtk.Window
|
|
|
|
// Options main VBox.
|
|
|
|
vbox *gtk.VBox
|
|
|
|
// Tabs widget.
|
|
|
|
tab_widget *gtk.Notebook
|
|
|
|
|
|
|
|
// Widgets.
|
|
|
|
// General tab.
|
|
|
|
// Show tray icon checkbutton.
|
|
|
|
show_tray_icon *gtk.CheckButton
|
|
|
|
// Enable autoupdate checkbutton.
|
|
|
|
autoupdate *gtk.CheckButton
|
|
|
|
// Urban Terror tab.
|
|
|
|
// Profiles list.
|
|
|
|
profiles_list *gtk.TreeView
|
2016-12-13 08:01:48 +05:00
|
|
|
// Servers updating tab.
|
|
|
|
// Master server address.
|
|
|
|
master_server_addr *gtk.Entry
|
|
|
|
// Servers autoupdate.
|
|
|
|
servers_autoupdate *gtk.CheckButton
|
|
|
|
// Timeout for servers autoupdating.
|
|
|
|
servers_autoupdate_timeout *gtk.Entry
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
// Data stores.
|
|
|
|
// Urban Terror profiles list.
|
|
|
|
profiles_list_store *gtk.ListStore
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) addProfile() {
|
|
|
|
fmt.Println("Adding profile...")
|
|
|
|
|
|
|
|
op := OptionsProfile{}
|
2016-10-08 19:57:33 +05:00
|
|
|
op.Initialize(false)
|
|
|
|
ctx.Eventer.LaunchEvent("flushProfiles", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoOptionsWindow", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoMainWindow", map[string]string{})
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) closeOptionsDialogByCancel() {
|
|
|
|
o.window.Destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) closeOptionsDialogWithDiscard() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) closeOptionsDialogWithSaving() {
|
|
|
|
fmt.Println("Saving changes to options...")
|
|
|
|
|
2016-10-05 01:03:46 +05:00
|
|
|
o.saveGeneral()
|
|
|
|
|
2016-11-22 01:10:31 +05:00
|
|
|
// Temporary disable all these modals on Linux.
|
|
|
|
// See https://github.com/mattn/go-gtk/issues/289.
|
|
|
|
if runtime.GOOS != "linux" {
|
|
|
|
mbox_string := "Some options require application restart to be applied."
|
|
|
|
m := gtk.NewMessageDialog(o.window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, mbox_string)
|
|
|
|
m.Response(func() {
|
|
|
|
m.Destroy()
|
|
|
|
})
|
|
|
|
m.Run()
|
|
|
|
}
|
2016-10-05 01:03:46 +05:00
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
o.window.Destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) deleteProfile() {
|
|
|
|
// Oh... dat... GTK...
|
|
|
|
sel := o.profiles_list.GetSelection()
|
|
|
|
model := o.profiles_list.GetModel()
|
|
|
|
iter := new(gtk.TreeIter)
|
|
|
|
_ = sel.GetSelected(iter)
|
|
|
|
var p string
|
|
|
|
gval := glib.ValueFromNative(p)
|
|
|
|
model.GetValue(iter, 0, gval)
|
|
|
|
profile_name := gval.GetString()
|
|
|
|
|
|
|
|
if len(profile_name) > 0 {
|
|
|
|
fmt.Println("Deleting profile '" + profile_name + "'")
|
|
|
|
|
|
|
|
profile := datamodels.Profile{}
|
|
|
|
profile.Name = profile_name
|
2016-10-08 19:57:33 +05:00
|
|
|
ctx.Eventer.LaunchEvent("deleteProfile", map[string]string{"profile_name": profile_name})
|
|
|
|
ctx.Eventer.LaunchEvent("flushProfiles", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoMainWindow", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoOptionsWindow", map[string]string{})
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) editProfile() {
|
|
|
|
// Oh... dat... GTK...
|
|
|
|
sel := o.profiles_list.GetSelection()
|
|
|
|
model := o.profiles_list.GetModel()
|
|
|
|
iter := new(gtk.TreeIter)
|
|
|
|
_ = sel.GetSelected(iter)
|
|
|
|
var p string
|
|
|
|
gval := glib.ValueFromNative(p)
|
|
|
|
model.GetValue(iter, 0, gval)
|
|
|
|
profile_name := gval.GetString()
|
|
|
|
|
|
|
|
if len(profile_name) > 0 {
|
|
|
|
op := OptionsProfile{}
|
2016-10-08 19:57:33 +05:00
|
|
|
op.InitializeUpdate(profile_name)
|
|
|
|
ctx.Eventer.LaunchEvent("flushProfiles", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoMainWindow", map[string]string{})
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoOptionsWindow", map[string]string{})
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 01:03:46 +05:00
|
|
|
func (o *OptionsDialog) fill() {
|
|
|
|
if ctx.Cfg.Cfg["/general/show_tray_icon"] == "1" {
|
|
|
|
o.show_tray_icon.SetActive(true)
|
|
|
|
}
|
|
|
|
if ctx.Cfg.Cfg["/general/urtrator_autoupdate"] == "1" {
|
|
|
|
o.autoupdate.SetActive(true)
|
|
|
|
}
|
2016-12-13 08:01:48 +05:00
|
|
|
|
|
|
|
// Servers updating tab.
|
|
|
|
master_server_addr, ok := ctx.Cfg.Cfg["/servers_updating/master_server"]
|
|
|
|
if !ok {
|
|
|
|
o.master_server_addr.SetText("master.urbanterror.info:27900")
|
|
|
|
} else {
|
|
|
|
o.master_server_addr.SetText(master_server_addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
servers_autoupdate, ok1 := ctx.Cfg.Cfg["/servers_updating/servers_autoupdate"]
|
|
|
|
if ok1 {
|
|
|
|
if servers_autoupdate == "1" {
|
|
|
|
o.servers_autoupdate.SetActive(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
servers_update_timeout, ok2 := ctx.Cfg.Cfg["/servers_updating/servers_autoupdate_timeout"]
|
|
|
|
if !ok2 {
|
|
|
|
o.servers_autoupdate_timeout.SetText("10")
|
|
|
|
} else {
|
|
|
|
o.servers_autoupdate_timeout.SetText(servers_update_timeout)
|
|
|
|
}
|
|
|
|
|
2016-10-05 01:03:46 +05:00
|
|
|
}
|
|
|
|
|
2016-10-10 19:22:21 +05:00
|
|
|
// Appearance tab initialization.
|
|
|
|
func (o *OptionsDialog) initializeAppearanceTab() {
|
|
|
|
appearance_vbox := gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
l := gtk.NewLabel("There will be some appearance configuration options soon.")
|
|
|
|
appearance_vbox.PackStart(l, false, true, 5)
|
|
|
|
|
|
|
|
o.tab_widget.AppendPage(appearance_vbox, gtk.NewLabel("Appearance"))
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
func (o *OptionsDialog) initializeGeneralTab() {
|
|
|
|
general_vbox := gtk.NewVBox(false, 0)
|
|
|
|
|
2016-11-25 04:31:45 +05:00
|
|
|
general_table := gtk.NewTable(2, 2, false)
|
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
// Tray icon checkbox.
|
2016-11-25 04:31:45 +05:00
|
|
|
show_tray_icon_label := gtk.NewLabel("Show icon in tray")
|
|
|
|
show_tray_icon_label.SetAlignment(0, 0)
|
|
|
|
general_table.Attach(show_tray_icon_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
|
|
|
|
|
|
|
|
o.show_tray_icon = gtk.NewCheckButtonWithLabel("")
|
2016-10-04 19:21:48 +05:00
|
|
|
o.show_tray_icon.SetTooltipText("Show icon in tray")
|
2016-11-25 04:31:45 +05:00
|
|
|
general_table.Attach(o.show_tray_icon, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
// Autoupdate checkbox.
|
2016-11-25 04:31:45 +05:00
|
|
|
autoupdate_tooltip := "Should URTrator check for updates and update itself? Not working now."
|
|
|
|
autoupdate_label := gtk.NewLabel("Automatically update URTrator?")
|
|
|
|
autoupdate_label.SetTooltipText(autoupdate_tooltip)
|
|
|
|
autoupdate_label.SetAlignment(0, 0)
|
|
|
|
general_table.Attach(autoupdate_label, 0, 1, 1, 2, gtk.FILL, gtk.SHRINK, 5, 5)
|
|
|
|
|
|
|
|
o.autoupdate = gtk.NewCheckButtonWithLabel("")
|
|
|
|
o.autoupdate.SetTooltipText(autoupdate_tooltip)
|
|
|
|
general_table.Attach(o.autoupdate, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
|
|
|
|
|
|
|
// Vertical separator.
|
|
|
|
sep := gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
general_vbox.PackStart(general_table, false, true, 0)
|
|
|
|
general_vbox.PackStart(sep, false, true, 0)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
o.tab_widget.AppendPage(general_vbox, gtk.NewLabel("General"))
|
|
|
|
}
|
|
|
|
|
2016-12-13 08:01:48 +05:00
|
|
|
func (o *OptionsDialog) initializeServersOptionsTab() {
|
|
|
|
servers_options_vbox := gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
servers_updating_table := gtk.NewTable(3, 2, false)
|
|
|
|
servers_updating_table.SetRowSpacings(2)
|
|
|
|
|
|
|
|
// Master server address.
|
|
|
|
master_server_addr_tooltip := "Address of master server. Specify in form: addr:port."
|
|
|
|
master_server_addr_label := gtk.NewLabel("Master server address")
|
|
|
|
master_server_addr_label.SetTooltipText(master_server_addr_tooltip)
|
|
|
|
master_server_addr_label.SetAlignment(0, 0)
|
|
|
|
servers_updating_table.Attach(master_server_addr_label, 0, 1, 0, 1, gtk.FILL, gtk.SHRINK, 5, 5)
|
|
|
|
|
|
|
|
o.master_server_addr = gtk.NewEntry()
|
|
|
|
o.master_server_addr.SetTooltipText(master_server_addr_tooltip)
|
|
|
|
servers_updating_table.Attach(o.master_server_addr, 1, 2, 0, 1, gtk.FILL, gtk.FILL, 5, 5)
|
|
|
|
|
|
|
|
// Servers autoupdate checkbox.
|
|
|
|
servers_autoupdate_cb_tooptip := "Should servers be automatically updated?"
|
|
|
|
servers_autoupdate_cb_label := gtk.NewLabel("Servers autoupdate")
|
|
|
|
servers_autoupdate_cb_label.SetTooltipText(servers_autoupdate_cb_tooptip)
|
|
|
|
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)
|
|
|
|
|
|
|
|
o.servers_autoupdate = gtk.NewCheckButtonWithLabel("")
|
|
|
|
o.servers_autoupdate.SetTooltipText(servers_autoupdate_cb_tooptip)
|
|
|
|
servers_updating_table.Attach(o.servers_autoupdate, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 5, 5)
|
|
|
|
|
|
|
|
// Servers update timeout.
|
|
|
|
servers_autoupdate_timeout_tooltip := "Timeout which will trigger servers information update, in minutes."
|
|
|
|
servers_autoupdate_label := gtk.NewLabel("Servers update timeout (minutes)")
|
|
|
|
servers_autoupdate_label.SetTooltipText(servers_autoupdate_timeout_tooltip)
|
|
|
|
servers_autoupdate_label.SetAlignment(0, 0)
|
|
|
|
servers_updating_table.Attach(servers_autoupdate_label, 0, 1, 2, 3, gtk.FILL, gtk.SHRINK, 5, 5)
|
|
|
|
|
|
|
|
o.servers_autoupdate_timeout = gtk.NewEntry()
|
|
|
|
o.servers_autoupdate_timeout.SetTooltipText(servers_autoupdate_timeout_tooltip)
|
|
|
|
servers_updating_table.Attach(o.servers_autoupdate_timeout, 1, 2, 2, 3, gtk.FILL, gtk.FILL, 5, 5)
|
|
|
|
|
|
|
|
// Vertical separator.
|
|
|
|
sep := gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
servers_options_vbox.PackStart(servers_updating_table, false, true, 0)
|
|
|
|
servers_options_vbox.PackStart(sep, true, true, 0)
|
|
|
|
|
|
|
|
o.tab_widget.AppendPage(servers_options_vbox, gtk.NewLabel("Servers updating"))
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
func (o *OptionsDialog) initializeStorages() {
|
|
|
|
// Structure:
|
|
|
|
// Name|Version|Second X session
|
|
|
|
o.profiles_list_store = gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_STRING, glib.G_TYPE_BOOL)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) initializeTabs() {
|
|
|
|
o.initializeStorages()
|
|
|
|
o.tab_widget = gtk.NewNotebook()
|
2016-10-10 19:22:21 +05:00
|
|
|
o.tab_widget.SetTabPos(gtk.POS_LEFT)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
o.initializeGeneralTab()
|
2016-10-10 19:22:21 +05:00
|
|
|
o.initializeAppearanceTab()
|
2016-10-04 15:42:36 +05:00
|
|
|
o.initializeUrtTab()
|
2016-12-13 08:01:48 +05:00
|
|
|
o.initializeServersOptionsTab()
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
// Buttons for saving and discarding changes.
|
|
|
|
buttons_hbox := gtk.NewHBox(false, 0)
|
2016-11-25 04:11:44 +05:00
|
|
|
sep := gtk.NewHBox(false, 0)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
cancel_button := gtk.NewButtonWithLabel("Cancel")
|
|
|
|
cancel_button.Clicked(o.closeOptionsDialogByCancel)
|
|
|
|
|
|
|
|
ok_button := gtk.NewButtonWithLabel("OK")
|
|
|
|
ok_button.Clicked(o.closeOptionsDialogWithSaving)
|
|
|
|
|
|
|
|
buttons_hbox.PackStart(sep, true, true, 5)
|
|
|
|
buttons_hbox.PackStart(cancel_button, false, true, 5)
|
|
|
|
buttons_hbox.PackStart(ok_button, false, true, 5)
|
|
|
|
|
|
|
|
o.vbox.PackStart(o.tab_widget, true, true, 5)
|
|
|
|
o.vbox.PackStart(buttons_hbox, false, true, 5)
|
2016-10-08 19:57:33 +05:00
|
|
|
|
|
|
|
ctx.Eventer.AddEventHandler("loadProfilesIntoOptionsWindow", o.loadProfiles)
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (o *OptionsDialog) initializeUrtTab() {
|
2016-11-25 04:31:45 +05:00
|
|
|
urt_hbox := gtk.NewHBox(false, 5)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
// Profiles list.
|
|
|
|
o.profiles_list = gtk.NewTreeView()
|
2016-10-04 19:21:48 +05:00
|
|
|
o.profiles_list.SetTooltipText("All available profiles")
|
2016-10-04 15:42:36 +05:00
|
|
|
urt_hbox.Add(o.profiles_list)
|
|
|
|
o.profiles_list.SetModel(o.profiles_list_store)
|
|
|
|
o.profiles_list.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Profile name", gtk.NewCellRendererText(), "text", 0))
|
|
|
|
o.profiles_list.AppendColumn(gtk.NewTreeViewColumnWithAttributes("Urban Terror version", gtk.NewCellRendererText(), "text", 1))
|
2016-10-06 16:31:31 +05:00
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
// Profiles list buttons.
|
|
|
|
urt_profiles_buttons_vbox := gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
button_add := gtk.NewButtonWithLabel("Add")
|
2016-10-04 19:21:48 +05:00
|
|
|
button_add.SetTooltipText("Add new profile")
|
2016-10-04 15:42:36 +05:00
|
|
|
button_add.Clicked(o.addProfile)
|
2016-11-25 04:31:45 +05:00
|
|
|
urt_profiles_buttons_vbox.PackStart(button_add, false, true, 0)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
button_edit := gtk.NewButtonWithLabel("Edit")
|
2016-10-04 19:21:48 +05:00
|
|
|
button_edit.SetTooltipText("Edit selected profile. Do nothing if no profile was selected.")
|
2016-10-04 15:42:36 +05:00
|
|
|
button_edit.Clicked(o.editProfile)
|
|
|
|
urt_profiles_buttons_vbox.PackStart(button_edit, false, true, 5)
|
|
|
|
|
|
|
|
// Spacer for profiles list buttons.
|
2016-11-25 04:11:44 +05:00
|
|
|
sep := gtk.NewVBox(false, 0)
|
2016-10-04 15:42:36 +05:00
|
|
|
urt_profiles_buttons_vbox.PackStart(sep, true, true, 5)
|
|
|
|
|
|
|
|
button_delete := gtk.NewButtonWithLabel("Delete")
|
2016-10-04 19:21:48 +05:00
|
|
|
button_delete.SetTooltipText("Delete selected profile. Do nothing if no profile was selected.")
|
2016-10-04 15:42:36 +05:00
|
|
|
button_delete.Clicked(o.deleteProfile)
|
2016-11-25 04:31:45 +05:00
|
|
|
urt_profiles_buttons_vbox.PackStart(button_delete, false, true, 0)
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
urt_hbox.Add(urt_profiles_buttons_vbox)
|
|
|
|
|
|
|
|
o.tab_widget.AppendPage(urt_hbox, gtk.NewLabel("Urban Terror"))
|
|
|
|
|
|
|
|
// Load Profiles.
|
2016-10-08 19:57:33 +05:00
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoOptionsWindow", map[string]string{})
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
|
2016-10-08 19:57:33 +05:00
|
|
|
func (o *OptionsDialog) loadProfiles(data map[string]string) {
|
2016-10-04 15:42:36 +05:00
|
|
|
fmt.Println("Loading profiles...")
|
|
|
|
o.profiles_list_store.Clear()
|
|
|
|
|
2016-10-08 19:57:33 +05:00
|
|
|
for _, p := range ctx.Cache.Profiles {
|
2016-10-04 15:42:36 +05:00
|
|
|
var iter gtk.TreeIter
|
|
|
|
o.profiles_list_store.Append(&iter)
|
2016-10-08 19:57:33 +05:00
|
|
|
o.profiles_list_store.Set(&iter, 0, p.Profile.Name)
|
|
|
|
o.profiles_list_store.Set(&iter, 1, p.Profile.Version)
|
2016-10-04 15:42:36 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 01:03:46 +05:00
|
|
|
func (o *OptionsDialog) saveGeneral() {
|
|
|
|
if o.show_tray_icon.GetActive() {
|
|
|
|
ctx.Cfg.Cfg["/general/show_tray_icon"] = "1"
|
|
|
|
} else {
|
|
|
|
ctx.Cfg.Cfg["/general/show_tray_icon"] = "0"
|
|
|
|
}
|
|
|
|
|
|
|
|
if o.autoupdate.GetActive() {
|
|
|
|
ctx.Cfg.Cfg["/general/urtrator_autoupdate"] = "1"
|
|
|
|
} else {
|
|
|
|
ctx.Cfg.Cfg["/general/urtrator_autoupdate"] = "0"
|
|
|
|
}
|
|
|
|
|
2016-12-13 08:01:48 +05:00
|
|
|
// Servers updating tab.
|
|
|
|
master_server_addr := o.master_server_addr.GetText()
|
|
|
|
if len(master_server_addr) < 1 {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/master_server"] = "master.urbanterror.info:27900"
|
|
|
|
} else {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/master_server"] = master_server_addr
|
|
|
|
}
|
|
|
|
|
|
|
|
if o.servers_autoupdate.GetActive() {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/servers_autoupdate"] = "1"
|
|
|
|
} else {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/servers_autoupdate"] = "0"
|
|
|
|
}
|
|
|
|
|
|
|
|
update_timeout := o.servers_autoupdate_timeout.GetText()
|
|
|
|
if len(update_timeout) < 1 {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/servers_autoupdate_timeout"] = "10"
|
|
|
|
} else {
|
|
|
|
ctx.Cfg.Cfg["/servers_updating/servers_autoupdate_timeout"] = update_timeout
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx.Eventer.LaunchEvent("initializeTasksForMainWindow", map[string]string{})
|
2016-10-05 01:03:46 +05:00
|
|
|
}
|
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
func (o *OptionsDialog) ShowOptionsDialog() {
|
|
|
|
o.window = gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
|
|
|
|
o.window.SetTitle("URTrator - Options")
|
|
|
|
o.window.Connect("destroy", o.closeOptionsDialogWithDiscard)
|
|
|
|
o.window.SetModal(true)
|
|
|
|
o.window.SetSizeRequest(550, 400)
|
|
|
|
o.window.SetPosition(gtk.WIN_POS_CENTER)
|
|
|
|
o.window.SetIcon(logo)
|
|
|
|
|
|
|
|
o.vbox = gtk.NewVBox(false, 0)
|
|
|
|
|
|
|
|
o.initializeTabs()
|
2016-10-05 01:03:46 +05:00
|
|
|
o.fill()
|
2016-10-04 15:42:36 +05:00
|
|
|
|
|
|
|
o.window.Add(o.vbox)
|
2016-10-08 19:57:33 +05:00
|
|
|
|
|
|
|
ctx.Eventer.LaunchEvent("loadProfilesIntoOptionsWindow", map[string]string{})
|
|
|
|
|
2016-10-04 15:42:36 +05:00
|
|
|
o.window.ShowAll()
|
|
|
|
}
|