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 13:42:45 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [vasc - Sun Oct 24 19:22:34 2004]:
> 
> > [jdorje - Sun Oct 24 18:15:09 2004]:
> > 
> > But I don't know what this patch is supposed to do.
> > 
> > If I compile only the client, then choose "start game" from the 
> > startscreen, nothing happens for a few seconds then the widgets resize 
> > themselves.  But there is no message of why the start failed.
> 
> I thought the original bug report was regarding no feedback on
> connection loss when connecting to a remote server.
> This is what that patch adds. Feedback on the network page statusbar on
> connection loss.
> 
> If the issue is on start as well, I guess I need to revise this.

How about this patch? Does it do what you want?

? client/gui-gtk-2.0/.pages.c.swp
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 20:41:11 -0000
@@ -114,6 +114,9 @@
 
 
   gtk_text_buffer_delete_mark(buf, mark);
+
+
+  append_network_statusbar(astring, FALSE);
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.85
diff -u -r1.85 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       19 Oct 2004 17:07:12 -0000      1.85
+++ client/gui-gtk-2.0/gui_main.c       24 Oct 2004 20:41:12 -0000
@@ -620,7 +620,7 @@
   int i;
   struct Sprite *sprite;
 
-  GtkWidget *notebook, *messages;
+  GtkWidget *notebook, *messages, *statusbar;
 
   message_buffer = gtk_text_buffer_new(NULL);
 
@@ -628,7 +628,12 @@
   notebook = gtk_notebook_new();
   toplevel_tabs = notebook;
   gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
-  gtk_container_add(GTK_CONTAINER(toplevel), notebook);
+  gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), FALSE);
+  box = gtk_vbox_new(FALSE, 4);
+  gtk_container_add(GTK_CONTAINER(toplevel), box);
+  gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, 0);
+  statusbar = create_statusbar();
+  gtk_box_pack_start(GTK_BOX(box), statusbar, FALSE, FALSE, 0);
 
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
       create_main_page(), NULL);
@@ -643,7 +648,6 @@
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
       create_nation_page(), NULL);
 
-
   main_tips = gtk_tooltips_new();
 
   /* the window is divided into two panes. "top" and "message window" */ 
@@ -954,7 +958,7 @@
 
   /* Other things to take care of */
 
-  gtk_widget_show_all(toplevel_tabs);
+  gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(toplevel)));
   gtk_widget_hide(more_arrow_pixmap);
 
   if (!map_scrollbars) {
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 20:41:14 -0000
@@ -60,6 +60,10 @@
 static guint lan_timer = 0;
 static int num_lanservers_timer = 0;
 
+static GtkWidget *statusbar, *statusbar_frame;
+static GQueue *statusbar_queue;
+static guint statusbar_timer = 0;
+
 
 /**************************************************************************
   spawn a server, if there isn't one, using the default settings.
@@ -175,13 +179,13 @@
   bbox = gtk_vbox_new(FALSE, 6);
   gtk_container_add(GTK_CONTAINER(sbox), bbox);
 
-  button = gtk_button_new_with_mnemonic(_("_Start New Game"));
+  button = gtk_button_new_with_mnemonic(_("Start _New Game"));
   gtk_size_group_add_widget(size, button);
   gtk_container_add(GTK_CONTAINER(bbox), button);
   g_signal_connect(button, "clicked",
       G_CALLBACK(start_new_game_callback), NULL);
 
-  button = gtk_button_new_with_mnemonic(_("Start S_cenario Game"));
+  button = gtk_button_new_with_mnemonic(_("Start _Scenario Game"));
   gtk_size_group_add_widget(size, button);
   gtk_container_add(GTK_CONTAINER(bbox), button);
   g_signal_connect(button, "clicked",
@@ -196,7 +200,7 @@
   bbox = gtk_vbox_new(FALSE, 6);
   gtk_container_add(GTK_CONTAINER(sbox), bbox);
 
-  button = gtk_button_new_with_mnemonic(_("Connect to _Network Game"));
+  button = gtk_button_new_with_mnemonic(_("C_onnect to Network Game"));
   gtk_size_group_add_widget(size, button);
   gtk_container_add(GTK_CONTAINER(bbox), button);
   g_signal_connect(button, "clicked",
@@ -236,8 +240,6 @@
 static GtkWidget *network_password_label, *network_password;
 static GtkWidget *network_confirm_password_label, *network_confirm_password;
 
-static GtkWidget *network_statusbar;
-
 /**************************************************************************
   get the list of servers from the metaserver
 **************************************************************************/
@@ -353,15 +355,76 @@
 static enum connection_state connection_status;
 
 /**************************************************************************
+  update statusbar label text.
+**************************************************************************/
+static gboolean update_network_statusbar(gpointer data)
+{
+  if (!g_queue_is_empty(statusbar_queue)) {
+    char *txt;
+
+    txt = g_queue_pop_head(statusbar_queue);
+    gtk_label_set_text(GTK_LABEL(statusbar), txt);
+    free(txt);
+  }
+
+  return TRUE;
+}
+
+/**************************************************************************
+  clear statusbar queue.
+**************************************************************************/
+static void clear_network_statusbar(void)
+{
+  while (!g_queue_is_empty(statusbar_queue)) {
+    char *txt;
+
+    txt = g_queue_pop_head(statusbar_queue);
+    free(txt);
+  }
+  gtk_label_set_text(GTK_LABEL(statusbar), "");
+}
+
+/**************************************************************************
+  queue statusbar label text change.
+**************************************************************************/
+void append_network_statusbar(const char *text, bool force)
+{
+  if (GTK_WIDGET_VISIBLE(statusbar_frame)) {
+    if (force) {
+      clear_network_statusbar();
+      gtk_label_set_text(GTK_LABEL(statusbar), text);
+    } else {
+      g_queue_push_tail(statusbar_queue, mystrdup(text));
+    }
+  }
+}
+
+/**************************************************************************
+  create statusbar.
+**************************************************************************/
+GtkWidget *create_statusbar(void)
+{
+  statusbar_frame = gtk_frame_new(NULL);
+  gtk_frame_set_shadow_type(GTK_FRAME(statusbar_frame), GTK_SHADOW_IN);
+
+  statusbar = gtk_label_new("");
+  gtk_misc_set_padding(GTK_MISC(statusbar), 2, 2);
+  gtk_container_add(GTK_CONTAINER(statusbar_frame), statusbar);
+
+  statusbar_queue = g_queue_new();
+  statusbar_timer = g_timeout_add(2000, update_network_statusbar, NULL);
+
+  return statusbar_frame;
+}
+
+/**************************************************************************
   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 +466,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 +485,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 +532,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 +549,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);
       }
@@ -775,9 +836,6 @@
   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);
-
   return box;
 }
 
@@ -1510,6 +1568,7 @@
 
   switch (new_page) {
   case PAGE_MAIN:
+    break;
   case PAGE_START:
   case PAGE_NATION:
     break;
@@ -1527,6 +1586,14 @@
     break;
   }
 
+  /* hide/show statusbar. */
+  if (new_page == PAGE_START || new_page == PAGE_GAME) {
+    clear_network_statusbar();
+    gtk_widget_hide(statusbar_frame);
+  } else {
+    gtk_widget_show(statusbar_frame);
+  }
+
   gtk_notebook_set_current_page(GTK_NOTEBOOK(toplevel_tabs), new_page);
 
   /* Update the GUI. */
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 20:41:14 -0000
@@ -26,6 +26,8 @@
 GtkWidget *create_network_page(void);
 GtkWidget *create_nation_page(void);
 
+GtkWidget *create_statusbar(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]