Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10624) gtk2 startscreen doesn't tell you why you can't
Home

[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]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10624) gtk2 startscreen doesn't tell you why you can't connect
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Sun, 24 Oct 2004 09:27:00 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10624 >

> [jdorje - Sun Oct 24 07:26:12 2004]:
> 
> > [vasc - Sun Oct 24 00:15:12 2004]:
> > Try this patch.
> 
> It no longer applies cleanly.

This one is up to date with current CVS HEAD.

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 -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 16:26:10 -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.5
diff -u -r1.5 pages.c
--- client/gui-gtk-2.0/pages.c  24 Oct 2004 04:23:44 -0000      1.5
+++ client/gui-gtk-2.0/pages.c  24 Oct 2004 16:26:10 -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
@@ -353,15 +356,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), "");
@@ -403,9 +435,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);
@@ -424,7 +454,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:
@@ -471,7 +501,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);
     }
@@ -488,8 +518,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);
       }
@@ -561,7 +591,7 @@
 {
   GtkWidget *salign, *box, *sbox, *bbox, *notebook;
 
-  GtkWidget *button, *label, *view, *sw;
+  GtkWidget *button, *label, *view, *sw, *frame;
   GtkCellRenderer *rend;
   GtkTreeSelection *selection;
 
@@ -775,8 +805,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;
 }
@@ -1497,8 +1536,13 @@
     }
     break;
   case PAGE_NETWORK:
-    if (lan_timer != 0) {
-      g_source_remove(lan_timer);
+    if (new_page == PAGE_MAIN) {
+      set_connection_state(LOGIN_TYPE);
+      return;
+    } else {
+      if (lan_timer != 0) {
+       g_source_remove(lan_timer);
+      }
     }
     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 -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 16:26:10 -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 */

[Prev in Thread] Current Thread [Next in Thread]