[Freeciv-Dev] (PR#10624) gtk2 startscreen doesn't tell you why you can't
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10624 >
> [jdorje - Tue Oct 19 18:17:23 2004]:
>
> If a connection to a server fails (because of bad auth, a capstring
> mismatch, the username is already taken, etc.) the player doesn't have
> any idea why. He is just returned to the intro screen.
Try this patch.
Index: client/gui-gtk-2.0/chatline.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/chatline.c,v
retrieving revision 1.11
diff -u -u -r1.11 chatline.c
--- client/gui-gtk-2.0/chatline.c 18 Oct 2004 23:49:27 -0000 1.11
+++ client/gui-gtk-2.0/chatline.c 24 Oct 2004 00:14:52 -0000
@@ -114,6 +114,9 @@
gtk_text_buffer_delete_mark(buf, mark);
+
+
+ append_network_statusbar(astring, FALSE);
}
/**************************************************************************
Index: client/gui-gtk-2.0/pages.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.c,v
retrieving revision 1.4
diff -u -u -r1.4 pages.c
--- client/gui-gtk-2.0/pages.c 23 Oct 2004 19:32:29 -0000 1.4
+++ client/gui-gtk-2.0/pages.c 24 Oct 2004 00:14:52 -0000
@@ -105,7 +105,8 @@
if (aconnection.used) {
disconnect_from_server();
} else {
- set_client_page(PAGE_MAIN);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(toplevel_tabs), PAGE_MAIN);
+ old_page = PAGE_MAIN;
}
}
@@ -237,6 +238,8 @@
static GtkWidget *network_confirm_password_label, *network_confirm_password;
static GtkWidget *network_statusbar;
+static GQueue *network_statusbar_queue;
+static guint network_statusbar_timer = 0;
/**************************************************************************
get the list of servers from the metaserver
@@ -344,15 +347,44 @@
static enum connection_state connection_status;
/**************************************************************************
+ update statusbar label text.
+**************************************************************************/
+static gboolean update_network_statusbar(gpointer data)
+{
+ if (!g_queue_is_empty(network_statusbar_queue)) {
+ char *text;
+
+ text = g_queue_pop_head(network_statusbar_queue);
+ gtk_label_set_text(GTK_LABEL(network_statusbar), text);
+ free(text);
+ }
+
+ return TRUE;
+}
+
+/**************************************************************************
+ queue statusbar label text change.
+**************************************************************************/
+void append_network_statusbar(const char *text, bool force)
+{
+ if (force) {
+ while (!g_queue_is_empty(network_statusbar_queue)) {
+ g_queue_pop_head(network_statusbar_queue);
+ }
+ gtk_label_set_text(GTK_LABEL(network_statusbar), text);
+ } else {
+ g_queue_push_tail(network_statusbar_queue, mystrdup(text));
+ }
+}
+
+/**************************************************************************
update network page connection state.
**************************************************************************/
static void set_connection_state(enum connection_state state)
{
switch (state) {
case LOGIN_TYPE:
- while (GTK_STATUSBAR(network_statusbar)->messages) {
- gtk_statusbar_pop(GTK_STATUSBAR(network_statusbar), 1);
- }
+ append_network_statusbar("", FALSE);
gtk_entry_set_text(GTK_ENTRY(network_password), "");
gtk_entry_set_text(GTK_ENTRY(network_confirm_password), "");
@@ -394,9 +426,7 @@
gtk_widget_grab_focus(network_password);
break;
case WAITING_TYPE:
- while (GTK_STATUSBAR(network_statusbar)->messages) {
- gtk_statusbar_pop(GTK_STATUSBAR(network_statusbar), 1);
- }
+ append_network_statusbar("", TRUE);
gtk_widget_set_sensitive(network_login, FALSE);
gtk_widget_set_sensitive(network_password_label, FALSE);
@@ -415,7 +445,7 @@
**************************************************************************/
void handle_authentication_req(enum authentication_type type, char *message)
{
- gtk_statusbar_push(GTK_STATUSBAR(network_statusbar), 1, message);
+ append_network_statusbar(message, TRUE);
switch (type) {
case AUTH_NEWUSER_FIRST:
@@ -462,7 +492,7 @@
if (connect_to_server(user_name, server_host, server_port,
errbuf, sizeof(errbuf)) != -1) {
} else {
- gtk_statusbar_push(GTK_STATUSBAR(network_statusbar), 1, errbuf);
+ append_network_statusbar(errbuf, TRUE);
append_output_window(errbuf);
}
@@ -479,8 +509,8 @@
set_connection_state(WAITING_TYPE);
} else {
- gtk_statusbar_push(GTK_STATUSBAR(network_statusbar), 1,
- _("Passwords don't match, enter password."));
+ append_network_statusbar(_("Passwords don't match, enter password."),
+ TRUE);
set_connection_state(NEW_PASSWORD_TYPE);
}
@@ -552,7 +582,7 @@
{
GtkWidget *salign, *box, *sbox, *bbox, *notebook;
- GtkWidget *button, *label, *view, *sw;
+ GtkWidget *button, *label, *view, *sw, *frame;
GtkCellRenderer *rend;
GtkTreeSelection *selection;
@@ -766,8 +796,17 @@
g_signal_connect(button, "clicked",
G_CALLBACK(connect_callback), NULL);
- network_statusbar = gtk_statusbar_new();
- gtk_box_pack_start(GTK_BOX(sbox), network_statusbar, FALSE, FALSE, 0);
+ frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
+ gtk_box_pack_start(GTK_BOX(sbox), frame, FALSE, FALSE, 0);
+
+ network_statusbar = gtk_label_new("");
+ gtk_misc_set_padding(GTK_MISC(network_statusbar), 2, 2);
+ gtk_container_add(GTK_CONTAINER(frame), network_statusbar);
+
+ network_statusbar_queue = g_queue_new();
+ network_statusbar_timer = g_timeout_add(2000, update_network_statusbar,
+ NULL);
return box;
}
@@ -1488,9 +1527,14 @@
}
break;
case PAGE_NETWORK:
- if (lan_timer != 0) {
- g_source_remove(lan_timer);
- lan_timer = 0;
+ if (new_page == PAGE_MAIN) {
+ set_connection_state(LOGIN_TYPE);
+ return;
+ } else {
+ if (lan_timer != 0) {
+ g_source_remove(lan_timer);
+ lan_timer = 0;
+ }
}
break;
case PAGE_GAME:
Index: client/gui-gtk-2.0/pages.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/pages.h,v
retrieving revision 1.1
diff -u -u -r1.1 pages.h
--- client/gui-gtk-2.0/pages.h 18 Oct 2004 23:52:54 -0000 1.1
+++ client/gui-gtk-2.0/pages.h 24 Oct 2004 00:14:52 -0000
@@ -26,6 +26,7 @@
GtkWidget *create_network_page(void);
GtkWidget *create_nation_page(void);
+void append_network_statusbar(const char *text, bool force);
void popup_save_dialog(void);
#endif /* FC__PAGES_H */
|
|