Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2003:
[Freeciv-Dev] Re: (PR#3736) Pregame player list
Home

[Freeciv-Dev] Re: (PR#3736) Pregame player list

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#3736) Pregame player list
From: "andrearo@xxxxxxxxxxxx" <andrearo@xxxxxxxxxxxx>
Date: Sun, 4 May 2003 05:39:49 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Vasco Alexandre da Silva Costa wrote:

>[andrearo@xxxxxxxxxxxx - Thu Apr 24 16:37:29 2003]:
>
>I changed the popup to have more decent padding and did some minor
>cleanups. This means the GTK+ 1.2 piece needs changing and I didn't make
>the changes to it yet. Please feel free to do so. :-)
>  
>
Hopefully, I've updated all the changes to the gtk1 client.

However, there is an issue with this patch, when reattaching a detached 
window.
I don't know why, but it only happens when there are no scrollbars on 
the users-list widget.
"Gdk-CRITICAL **: file gdkwindow.c: line 908 (gdk_window_reparent): 
assertion `window != NULL' failed."

Andreas Røsdal

diff -Nur -Xfreeciv-changed/diff_ignore 
freeciv-cvs-May-02/client/gui-gtk/gui_main.c 
freeciv-changed/client/gui-gtk/gui_main.c
--- freeciv-cvs-May-02/client/gui-gtk/gui_main.c        2003-05-04 
14:13:21.000000000 +0200
+++ freeciv-changed/client/gui-gtk/gui_main.c   2003-05-04 14:24:32.000000000 
+0200
@@ -103,6 +103,9 @@
 GtkWidget *main_frame_civ_name;
 GtkWidget *main_label_info;
 
+GtkWidget *avbox, *ahbox, *vbox, *conn_box;
+GtkWidget* conn_list;
+
 GtkWidget *econ_label[10];
 GtkWidget *bulb_label;
 GtkWidget *sun_label;
@@ -151,6 +154,8 @@
 
 static void select_unit_pixmap_callback(GtkWidget *w, GdkEvent *ev, 
                                         gpointer data);
+static gboolean show_conn_popup(GtkWidget *view, 
+                       GdkEventButton *event, gpointer data);
 static gint timer_callback(gpointer data);
 
 /**************************************************************************
@@ -520,8 +525,7 @@
 **************************************************************************/
 static void setup_widgets(void)
 {
-  GtkWidget *box, *ebox, *hbox, *vbox;
-  GtkWidget *avbox, *ahbox;
+  GtkWidget *box, *ebox, *hbox, *vbox, *sbox, *label, *sw;
   GtkWidget *frame, *table, *paned, *menubar, *text;
   GtkStyle  *text_style, *style;
   int i;
@@ -557,7 +561,7 @@
                                       | GDK_BUTTON_PRESS_MASK );
 
   gtk_drawing_area_size(GTK_DRAWING_AREA(overview_canvas), 160, 100);
-  gtk_box_pack_start(GTK_BOX(avbox), overview_canvas, FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(avbox), overview_canvas, FALSE, TRUE, 0);
 
   gtk_signal_connect(GTK_OBJECT(overview_canvas), "expose_event",
                      (GtkSignalFunc) overview_canvas_expose, NULL);
@@ -565,6 +569,32 @@
   gtk_signal_connect(GTK_OBJECT(overview_canvas), "button_press_event",
                      (GtkSignalFunc) butt_down_overviewcanvas, NULL);
 
+  /* prepare list of Connected Users in the pregame state. */
+  conn_list = gtk_clist_new(1);
+  gtk_clist_set_column_auto_resize (GTK_CLIST(conn_list), 1, TRUE);
+  gtk_clist_set_column_width(GTK_CLIST(conn_list), 0,
+       GTK_CLIST(conn_list)->clist_window_width);
+
+  /* display the list of Connected Users. */
+  conn_box = gtk_vbox_new(FALSE, 2);
+  label=gtk_widget_new(GTK_TYPE_LABEL,
+                           "GtkLabel::label", _("Connected Users:"),
+                           "GtkWidget::visible", TRUE,
+                           "xalign", 0.0, "yalign", 0.5, 
+                           NULL);
+  sw = gtk_scrolled_window_new(NULL,NULL);
+  gtk_widget_set_usize(sw, 160, 300);
+
+  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
+                             GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+  gtk_container_add(GTK_CONTAINER(sw), conn_list);
+  gtk_box_pack_start(GTK_BOX(conn_box), label, FALSE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(conn_box), sw, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(avbox), conn_box, TRUE, TRUE, 0);
+
+  gtk_signal_connect(GTK_OBJECT(conn_list), "button-press-event",
+                 GTK_SIGNAL_FUNC(show_conn_popup), NULL);
+
   /* The Rest */
 
   ahbox = detached_widget_new();
@@ -732,9 +762,9 @@
 
   /* *** The message window -- this is a detachable widget *** */
 
-  ahbox = detached_widget_new();
-  gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);
-  avbox = detached_widget_fill(ahbox);
+  sbox = detached_widget_new();
+  gtk_paned_pack2(GTK_PANED(paned), sbox, TRUE, TRUE);
+  avbox = detached_widget_fill(sbox);
 
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(avbox), hbox, TRUE, TRUE, 0);
@@ -780,6 +810,7 @@
     gtk_widget_hide(map_horizontal_scrollbar);
     gtk_widget_hide(map_vertical_scrollbar);
   }
+  gtk_widget_hide(ahbox);  /* Hide info on player's civ in pregame */
 }
 
 /**************************************************************************
@@ -960,7 +991,77 @@
 ***************************************************************************/
 void update_conn_list_dialog(void)
 {
-  /* PORTME */
+  gchar *row[1];
+  if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+    gtk_clist_freeze(GTK_CLIST(conn_list));
+    gtk_clist_clear(GTK_CLIST(conn_list));
+    conn_list_iterate(game.est_connections, pconn)
+      row[0] = pconn->username;
+      gtk_clist_append(GTK_CLIST(conn_list), row);
+    conn_list_iterate_end;
+    gtk_clist_thaw(GTK_CLIST(conn_list));
+    gtk_widget_hide(ahbox);
+    gtk_widget_show(conn_box);
+  } else {
+    gtk_widget_hide(conn_box);
+    gtk_widget_show(ahbox);
+  } 
+}
+
+/**************************************************************************
+ Show details about a user in the Connected Users dialog in a popup
+**************************************************************************/
+static gboolean show_conn_popup(GtkWidget *view, GdkEventButton *ev,
+                               gpointer data)
+{
+  GtkWidget *popup, *table, *label;
+  gchar *name;
+  struct connection *pconn;
+  gint row;
+
+  /* Get the current selection in the Connected Users list */
+  if (!gtk_clist_get_selection_info(GTK_CLIST(conn_list),
+                                   ev->x, ev->y, &row ,NULL)) {
+    return FALSE;
+  }
+  gtk_clist_select_row(GTK_CLIST(conn_list), row, 0);
+  gtk_clist_get_text(GTK_CLIST(conn_list), row, 0, &name); 
+  pconn = find_conn_by_user(name);
+  ev->button=3; 
+
+  /* Show popup. */
+  popup = gtk_window_new(GTK_WINDOW_POPUP);
+  gtk_widget_set_app_paintable(popup, TRUE);
+  gtk_container_set_border_width(GTK_CONTAINER(popup), 4);
+  gtk_window_set_position(GTK_WINDOW(popup), GTK_WIN_POS_MOUSE);
+
+  table = gtk_table_new(2, 2, FALSE);
+  gtk_table_set_col_spacings(GTK_TABLE(table), 6);
+  gtk_container_add(GTK_CONTAINER(popup), table);
+
+  label = gtk_label_new(_("Name:"));
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+  label = gtk_label_new(pconn->username);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
+
+  label = gtk_label_new(_("Host:"));
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
+  label = gtk_label_new(pconn->addr);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
+
+  gtk_widget_show_all(table);
+  gtk_widget_show(popup);
+
+  gdk_pointer_grab(popup->window, TRUE, GDK_BUTTON_RELEASE_MASK,
+                  NULL, NULL, ev->time);
+  gtk_grab_add(popup);
+  gtk_signal_connect_after(GTK_OBJECT(popup), "button_release_event",
+                        GTK_SIGNAL_FUNC(show_info_button_release), NULL);
+  return FALSE;
 }
 
 /**************************************************************************

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