Messageboxes fixes and copy server's creds to clipboard.
Fixed all messageboxes that can use struct object as self name (e.g. m for messageboxes in mainwindow). Should help to avoid some errors. Added possibility to copy server's credentials into clipboard for ease of sharing.
This commit is contained in:
@@ -202,6 +202,13 @@ func (m *MainWindow) Close() {
|
||||
ctx.Close()
|
||||
}
|
||||
|
||||
func (m *MainWindow) copyServerCredentialsToClipboard() {
|
||||
fmt.Println("Copying server's credentials to clipboard...")
|
||||
current_tab := m.tab_widget.GetTabLabelText(m.tab_widget.GetNthPage(m.tab_widget.GetCurrentPage()))
|
||||
server_address := m.getIpFromServersList(current_tab)
|
||||
ctx.Clipboard.CopyServerData(server_address)
|
||||
}
|
||||
|
||||
// Deleting server from favorites.
|
||||
func (m *MainWindow) deleteFromFavorites() {
|
||||
fmt.Println("Removing server from favorites...")
|
||||
|
@@ -560,15 +560,22 @@ func (m *MainWindow) InitializeToolbar() {
|
||||
fav_delete_button.OnClicked(m.deleteFromFavorites)
|
||||
m.toolbar.Insert(fav_delete_button, 5)
|
||||
|
||||
// Copy server address button.
|
||||
copy_srv_addr_button := gtk.NewToolButtonFromStock(gtk.STOCK_COPY)
|
||||
copy_srv_addr_button.SetLabel("Copy server's creds")
|
||||
copy_srv_addr_button.SetTooltipText("Copy server's credentials to clipboard for sharing")
|
||||
copy_srv_addr_button.OnClicked(m.copyServerCredentialsToClipboard)
|
||||
m.toolbar.Insert(copy_srv_addr_button, 6)
|
||||
|
||||
// Separator for toolbar's label and buttons.
|
||||
toolbar_separator_toolitem := gtk.NewToolItem()
|
||||
toolbar_separator_toolitem.SetExpand(true)
|
||||
m.toolbar.Insert(toolbar_separator_toolitem, 6)
|
||||
m.toolbar.Insert(toolbar_separator_toolitem, 7)
|
||||
// Toolbar's label.
|
||||
m.toolbar_label = gtk.NewLabel("URTrator is ready")
|
||||
toolbar_label_toolitem := gtk.NewToolItem()
|
||||
toolbar_label_toolitem.Add(m.toolbar_label)
|
||||
m.toolbar.Insert(toolbar_label_toolitem, 7)
|
||||
m.toolbar.Insert(toolbar_label_toolitem, 8)
|
||||
}
|
||||
|
||||
// Tray icon initialization.
|
||||
|
@@ -58,18 +58,18 @@ func (m *MainWindow) launchAsUsual() error {
|
||||
if len(server_profile.Name) == 0 {
|
||||
var will_continue bool = false
|
||||
mbox_string := "Selected server is offline.\n\nWould you still want to launch Urban Terror?\nIt will just launch a game, without connecting to\nany server."
|
||||
m := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_YES_NO, mbox_string)
|
||||
m.Connect("response", func(resp *glib.CallbackContext) {
|
||||
messagebox := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_YES_NO, mbox_string)
|
||||
messagebox.Connect("response", func(resp *glib.CallbackContext) {
|
||||
if resp.Args(0) == 4294967287 {
|
||||
will_continue = false
|
||||
} else {
|
||||
will_continue = true
|
||||
}
|
||||
})
|
||||
m.Response(func() {
|
||||
m.Destroy()
|
||||
messagebox.Response(func() {
|
||||
messagebox.Destroy()
|
||||
})
|
||||
m.Run()
|
||||
messagebox.Run()
|
||||
if !will_continue {
|
||||
return errors.New("User declined to connect to offline server")
|
||||
}
|
||||
@@ -84,11 +84,11 @@ func (m *MainWindow) launchAsUsual() error {
|
||||
// have profiles defined (see next).
|
||||
if len(profile_name) == 0 {
|
||||
mbox_string := "Invalid game profile selected.\n\nPlease, select profile and retry."
|
||||
m := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
m.Response(func() {
|
||||
m.Destroy()
|
||||
messagebox := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
messagebox.Response(func() {
|
||||
messagebox.Destroy()
|
||||
})
|
||||
m.Run()
|
||||
messagebox.Run()
|
||||
return errors.New("User didn't select valid profile.")
|
||||
}
|
||||
user_profile = ctx.Cache.Profiles[profile_name].Profile
|
||||
@@ -98,11 +98,11 @@ func (m *MainWindow) launchAsUsual() error {
|
||||
user_profile_cached, ok := ctx.Cache.Profiles[server_profile.ProfileToUse]
|
||||
if !ok {
|
||||
mbox_string := "Invalid game profile specified for favorite server.\n\nPlease, edit your favorite server, select valid profile and retry."
|
||||
m := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
m.Response(func() {
|
||||
m.Destroy()
|
||||
messagebox := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
messagebox.Response(func() {
|
||||
messagebox.Destroy()
|
||||
})
|
||||
m.Run()
|
||||
messagebox.Run()
|
||||
return errors.New("User didn't select valid profile.")
|
||||
}
|
||||
user_profile = user_profile_cached.Profile
|
||||
@@ -155,18 +155,18 @@ func (m *MainWindow) launchActually(server_profile *datamodels.Server, user_prof
|
||||
if server_profile.Name == "" {
|
||||
var will_continue bool = false
|
||||
mbox_string := "Selected server is offline.\n\nWould you still want to launch Urban Terror?\nIt will just launch a game, without connecting to\nany server."
|
||||
m := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_YES_NO, mbox_string)
|
||||
m.Connect("response", func(resp *glib.CallbackContext) {
|
||||
messagebox := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_YES_NO, mbox_string)
|
||||
messagebox.Connect("response", func(resp *glib.CallbackContext) {
|
||||
if resp.Args(0) == 4294967287 {
|
||||
will_continue = false
|
||||
} else {
|
||||
will_continue = true
|
||||
}
|
||||
})
|
||||
m.Response(func() {
|
||||
m.Destroy()
|
||||
messagebox.Response(func() {
|
||||
messagebox.Destroy()
|
||||
})
|
||||
m.Run()
|
||||
messagebox.Run()
|
||||
if !will_continue {
|
||||
return errors.New("User declined to connect to offline server")
|
||||
}
|
||||
@@ -175,11 +175,11 @@ func (m *MainWindow) launchActually(server_profile *datamodels.Server, user_prof
|
||||
// Check if server is applicable for selected profile.
|
||||
if server_profile.Version != user_profile.Version {
|
||||
mbox_string := "Invalid game profile selected.\n\nSelected profile have different game version than server.\nPlease, select valid profile and retry."
|
||||
m := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
m.Response(func() {
|
||||
m.Destroy()
|
||||
messagebox := gtk.NewMessageDialog(m.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, mbox_string)
|
||||
messagebox.Response(func() {
|
||||
messagebox.Destroy()
|
||||
})
|
||||
m.Run()
|
||||
messagebox.Run()
|
||||
return errors.New("User didn't select valid profile, mismatch with server's version.")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user