Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2006:
[Freeciv-Dev] (PR#15688) Re: (PR#15709) pregame support for observers
Home

[Freeciv-Dev] (PR#15688) Re: (PR#15709) pregame support for observers

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#15688) Re: (PR#15709) pregame support for observers
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Feb 2006 01:08:39 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=15688 >

Here is a patch that does half of it.

This changes the liststore to a treestore and puts observers underneath 
their players in the tree.

The only real problem is that for some reason the tree always wants to 
collapse itself.

Also I'm not sure whether controlling connections should be shown in the 
tree.

-jason


Index: client/gui-gtk-2.0/gui_main.c
===================================================================
--- client/gui-gtk-2.0/gui_main.c       (revision 11658)
+++ client/gui-gtk-2.0/gui_main.c       (working copy)
@@ -120,7 +120,7 @@
 GtkWidget *main_label_info;
 
 GtkWidget *avbox, *ahbox, *vbox, *conn_box;
-GtkListStore *conn_model;       
+GtkTreeStore *conn_model;
 GtkWidget* scroll_panel;
 
 GtkWidget *econ_label[10];
@@ -1361,7 +1361,7 @@
 **************************************************************************/
 void update_conn_list_dialog(void)
 {
-  GtkTreeIter it;
+  GtkTreeIter it[game.info.nplayers];
 
   if (game.player_ptr) {
     char *text;
@@ -1398,7 +1398,7 @@
     char name[MAX_LEN_NAME + 4], rating_text[128], record_text[128];
     int rating, wins, losses, ties, forfeits;
 
-    gtk_list_store_clear(conn_model);
+    gtk_tree_store_clear(conn_model);
     players_iterate(pplayer) {
       enum cmdlevel_id access_level = ALLOW_NONE;
 
@@ -1461,8 +1461,8 @@
        }
       }
 
-      gtk_list_store_append(conn_model, &it);
-      gtk_list_store_set(conn_model, &it,
+      gtk_tree_store_append(conn_model, &it[pplayer->player_no], NULL);
+      gtk_tree_store_set(conn_model, &it[pplayer->player_no],
                         0, pplayer->player_no,
                         1, name,
                         2, is_ready,
@@ -1474,17 +1474,20 @@
                         -1);
     } players_iterate_end;
     conn_list_iterate(game.est_connections, pconn) {
+      GtkTreeIter conn_it, *parent;
+
       if (pconn->player && !pconn->observer) {
        continue; /* Already listed above. */
       }
       sz_strlcpy(name, pconn->username);
-      is_ready = FALSE;
+      is_ready = TRUE;
       nation = "";
       leader = "";
-      team = "";
+      team = pconn->observer ? _("Observer") : _("Detached");
+      parent = pconn->player ? &it[pconn->player->player_no] : NULL;
 
-      gtk_list_store_append(conn_model, &it);
-      gtk_list_store_set(conn_model, &it,
+      gtk_tree_store_append(conn_model, &conn_it, parent);
+      gtk_tree_store_set(conn_model, &conn_it,
                         0, -1,
                         1, name,
                         2, is_ready,
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
--- client/gui-gtk-2.0/gui_main.h       (revision 11658)
+++ client/gui-gtk-2.0/gui_main.h       (working copy)
@@ -71,6 +71,7 @@
 extern GtkWidget *     top_notebook;
 extern GtkWidget *     bottom_notebook;
 extern GtkTextBuffer * message_buffer;
+extern GtkTreeStore *conn_model;
 
 void enable_menus(bool enable);
 
Index: client/gui-gtk-2.0/pages.c
===================================================================
--- client/gui-gtk-2.0/pages.c  (revision 11658)
+++ client/gui-gtk-2.0/pages.c  (working copy)
@@ -54,7 +54,6 @@
 
 GtkWidget *start_message_area;
 
-GtkListStore *conn_model;
 static GtkTreeViewColumn *nation_col, *ready_col, *team_col;
 GtkTreeViewColumn *rating_col, *record_col;
 
@@ -1224,7 +1223,7 @@
   gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 8);
 
 
-  conn_model = gtk_list_store_new(8, G_TYPE_INT,
+  conn_model = gtk_tree_store_new(8, G_TYPE_INT,
                                  G_TYPE_STRING, G_TYPE_BOOLEAN,
                                  G_TYPE_STRING, G_TYPE_STRING,
                                  G_TYPE_STRING, G_TYPE_STRING,
@@ -1233,6 +1232,7 @@
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(conn_model));
   g_object_unref(conn_model);
   gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), TRUE);
+  gtk_tree_view_expand_all(GTK_TREE_VIEW(view));
 
   rend = gtk_cell_renderer_text_new();
   gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),

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