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

The attached patches for S2_1 and trunk rearrange and
cleanup widget layout in the gtk2 gui so that a freeciv
window can fit on an 800x600 screen.

There are a number of things that I changed so that this
is possible:

- The buttons in the main page (the very first window
  to appear when starting the program) are arranged in
  a 3x2 table.
- Removed most calls to gtk_widget_set_size_request();
  instead, packing parameters are used to determine how
  much of the main window's space is allocated to each
  widget.
- The "unit pixmap" table (the bunch of units below the
  unit info label below the turn done button) is not
  filled in until the game starts.
- The buttons in the players/nations report (plrdlg)
  are replaced by two menus:
    = Diplomacy:
      + Meet
      + Cancel Treaty
      + Withdraw Vision
    = Intelligence
      + Report
      + Spaceship
  and the menu bar is packed to the left (similarly
  to the city report).
- The pregame player list and chat textview scroll
  windows may have horizontal scroll bars.
- The unit info label and civilization info label
  contents are aligned to the left.


This allows the freeciv window to be resized down to
a minimum of around 640x560. Unfortunately, using
amplio as the tileset makes the unit pixmap table much
taller (making the in game window height around 710).
I would suggest if users really are constrained to a
display with 600 pixel height to either use trident
as the tileset, or detach the minimap and move it over
the main window, until a deeper redesign of the gui
interface can fix this problem (maybe in 2.2).

Also, in trunk the freeciv window is much wider because
of widgets in the editor toolbar. I will cleanup and
simplify the editor interface when I get back to working
on it anyway, so I will leave that as is for the moment.


I would appreciate some testing on win32 and mac (i.e.
not linux but still using the gtk gui) to make sure
that the layout code works alright for those ports of
the gtk libraries.


-----------------------------------------------------------------------
見よ、小型化の奇跡。
 client/gui-gtk-2.0/gui_main.c |   66 +++++++++++++++-----------
 client/gui-gtk-2.0/pages.c    |   85 ++++++++++++++++------------------
 client/gui-gtk-2.0/plrdlg.c   |  103 ++++++++++++++++++++++++++--------------
 3 files changed, 144 insertions(+), 110 deletions(-)

diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c
index 653f6fb..6abe3fa 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -1005,8 +1005,6 @@ static void populate_unit_pixmap_table(void)
       
     gtk_table_attach_defaults(GTK_TABLE(table), unit_below_pixmap_button[i],
                               i, i + 1, 1, 2);
-    gtk_widget_set_size_request(unit_below_pixmap[i],
-				tileset_full_tile_width(tileset), tileset_full_tile_height(tileset));
     gtk_pixcomm_clear(GTK_PIXCOMM(unit_below_pixmap[i]));
   }
 
@@ -1026,23 +1024,25 @@ void reset_unit_table(void)
 {
   int i;
 
-  /* Unreference all of the widgets that we're about to reallocate, thus
-   * avoiding a memory leak. Remove them from the container first, just
-   * to be safe. Note, the widgets are ref'd in
-   * populatate_unit_pixmap_table. */
-  gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-		       unit_pixmap_button);
-  gtk_widget_unref(unit_pixmap);
-  gtk_widget_unref(unit_pixmap_button);
-  for (i = 0; i < num_units_below; i++) {
+  if (unit_pixmap_button) {
+    /* Unreference all of the widgets that we're about to reallocate, thus
+     * avoiding a memory leak. Remove them from the container first, just
+     * to be safe. Note, the widgets are ref'd in
+     * populatate_unit_pixmap_table. */
+    gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
+                         unit_pixmap_button);
+    gtk_widget_unref(unit_pixmap);
+    gtk_widget_unref(unit_pixmap_button);
+    for (i = 0; i < num_units_below; i++) {
+      gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
+                           unit_below_pixmap_button[i]);
+      gtk_widget_unref(unit_below_pixmap[i]);
+      gtk_widget_unref(unit_below_pixmap_button[i]);
+    }
     gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-			 unit_below_pixmap_button[i]);
-    gtk_widget_unref(unit_below_pixmap[i]);
-    gtk_widget_unref(unit_below_pixmap_button[i]);
+                         more_arrow_pixmap);
+    gtk_widget_unref(more_arrow_pixmap);
   }
-  gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-		       more_arrow_pixmap);
-  gtk_widget_unref(more_arrow_pixmap);
 
   populate_unit_pixmap_table();
 
@@ -1191,13 +1191,15 @@ static void setup_widgets(void)
 
   ebox = gtk_event_box_new();
   gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
-
-  gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 0);
-
-  main_label_info = gtk_label_new("\n\n\n\n");
-  gtk_container_add(GTK_CONTAINER(ebox), main_label_info);
   g_signal_connect(ebox, "button_press_event",
                    G_CALLBACK(show_info_popup), NULL);
+  gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 0);
+
+  label = gtk_label_new(NULL);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_misc_set_padding(GTK_MISC(label), 2, 2);
+  gtk_container_add(GTK_CONTAINER(ebox), label);
+  main_label_info = label;
 
   /* Production status */
 
@@ -1280,7 +1282,6 @@ static void setup_widgets(void)
   timeout_label = gtk_label_new("");
 
   frame = gtk_frame_new(NULL);
-  gtk_widget_set_size_request(frame, tileset_small_sprite_width(tileset), tileset_small_sprite_height(tileset));
   gtk_table_attach_defaults(GTK_TABLE(table), frame, 4, 10, 1, 2);
   gtk_container_add(GTK_CONTAINER(frame), timeout_label);
 
@@ -1310,8 +1311,11 @@ static void setup_widgets(void)
   unit_info_frame = gtk_frame_new("");
   gtk_box_pack_start(GTK_BOX(unit_info_box), unit_info_frame, FALSE, FALSE, 0);
     
-  unit_info_label = gtk_label_new("\n\n\n");
-  gtk_container_add(GTK_CONTAINER(unit_info_frame), unit_info_label);
+  label = gtk_label_new(NULL);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_misc_set_padding(GTK_MISC(label), 2, 2);
+  gtk_container_add(GTK_CONTAINER(unit_info_frame), label);
+  unit_info_label = label;
 
   box = gtk_hbox_new(FALSE,0);
   gtk_box_pack_start(GTK_BOX(unit_info_box), box, FALSE, FALSE, 0);
@@ -1323,7 +1327,6 @@ static void setup_widgets(void)
   gtk_table_set_col_spacings(GTK_TABLE(table), 2);
 
   unit_pixmap_table = table;
-  populate_unit_pixmap_table();
 
   /* Map canvas, editor toolbar, and scrollbars */
 
@@ -1366,7 +1369,6 @@ static void setup_widgets(void)
                                    |GDK_POINTER_MOTION_MASK
                                    |GDK_SCROLL_MASK);
 
-  gtk_widget_set_size_request(map_canvas, 510, 300);
   gtk_container_add(GTK_CONTAINER(frame), map_canvas);
 
   map_horizontal_scrollbar = gtk_hscrollbar_new(NULL);
@@ -1434,7 +1436,6 @@ static void setup_widgets(void)
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
   				 GTK_POLICY_ALWAYS);
-  gtk_widget_set_size_request(sw, 600, 100);
   gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
 
   label = gtk_label_new(_("Chat"));
@@ -1468,7 +1469,6 @@ static void setup_widgets(void)
   /* Other things to take care of */
 
   gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(toplevel)));
-  gtk_widget_hide(more_arrow_pixmap);
 
   if (enable_tabs) {
     popup_meswin_dialog(FALSE);
@@ -1954,6 +1954,10 @@ void set_unit_icon(int idx, struct unit *punit)
     unit_ids[idx] = punit ? punit->id : 0;
   }
 
+  if (!w) {
+    return;
+  }
+
   gtk_pixcomm_freeze(GTK_PIXCOMM(w));
 
   if (punit) {
@@ -1974,6 +1978,10 @@ void set_unit_icons_more_arrow(bool onoff)
 {
   static bool showing = FALSE;
 
+  if (!more_arrow_pixmap) {
+    return;
+  }
+
   if (onoff && !showing) {
     gtk_widget_show(more_arrow_pixmap);
     showing = TRUE;
diff --git a/client/gui-gtk-2.0/pages.c b/client/gui-gtk-2.0/pages.c
index 29645e1..ffe8b8b 100644
--- a/client/gui-gtk-2.0/pages.c
+++ b/client/gui-gtk-2.0/pages.c
@@ -171,19 +171,17 @@ static void ggz_login(void)
 **************************************************************************/
 GtkWidget *create_main_page(void)
 {
-  GtkWidget *align, *box, *sbox, *bbox, *frame, *image;
-
-  GtkWidget *button;
+  GtkWidget *widget, *align, *vbox, *frame, *image, *button, *table;
   GtkSizeGroup *size;
 
   size = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
 
-  box = gtk_vbox_new(FALSE, 6);
-  gtk_container_set_border_width(GTK_CONTAINER(box), 4);
+  vbox = gtk_vbox_new(FALSE, 0);
+  widget = vbox;
 
   align = gtk_alignment_new(0.5, 0.0, 0.0, 0.0);
   gtk_container_set_border_width(GTK_CONTAINER(align), 18);
-  gtk_box_pack_start(GTK_BOX(box), align, FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 0);
 
   frame = gtk_frame_new(NULL);
   gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
@@ -191,74 +189,68 @@ GtkWidget *create_main_page(void)
 
   image = gtk_image_new_from_file(tileset_main_intro_filename(tileset));
   g_signal_connect_after(image, "expose_event",
-      G_CALLBACK(intro_expose), NULL);
+                         G_CALLBACK(intro_expose), NULL);
   gtk_container_add(GTK_CONTAINER(frame), image);
 
-  align = gtk_alignment_new(0.5, 0.0, 0.0, 0.0);
-  gtk_box_pack_start(GTK_BOX(box), align, FALSE, FALSE, 0);
+#if IS_BETA_VERSION
+  {
+    GtkWidget *label;
 
-  sbox = gtk_vbox_new(FALSE, 18);
-  gtk_container_add(GTK_CONTAINER(align), sbox);
+    label = gtk_label_new(beta_message());
+    gtk_widget_set_name(label, "beta_label");
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+    gtk_container_add(GTK_CONTAINER(sbox), label);
+  }
+#endif
 
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
+  table = gtk_table_new(3, 2, TRUE);
+  align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+  gtk_box_pack_start(GTK_BOX(vbox), align, TRUE, TRUE, 12);
+
+  gtk_table_set_row_spacings(GTK_TABLE(table), 8);
+  gtk_table_set_col_spacings(GTK_TABLE(table), 18);
+  gtk_container_add(GTK_CONTAINER(align), table);
 
   button = gtk_button_new_with_mnemonic(_("Start _New Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 0, 1);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(start_new_game_callback), NULL);
+                   G_CALLBACK(start_new_game_callback), NULL);
 
   button = gtk_button_new_with_mnemonic(_("Start _Scenario Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 1, 2);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(start_scenario_callback), NULL);
+                   G_CALLBACK(start_scenario_callback), NULL);
 
   button = gtk_button_new_with_mnemonic(_("_Load Saved Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 2, 3);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(load_saved_game_callback), NULL);
-
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
+                   G_CALLBACK(load_saved_game_callback), NULL);
 
   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);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(set_page_callback), GUINT_TO_POINTER(PAGE_NETWORK));
+                   G_CALLBACK(set_page_callback),
+                   GUINT_TO_POINTER(PAGE_NETWORK));
 
 #ifdef GGZ_GTK
   button = gtk_button_new_with_mnemonic(_("Connect to Gaming _Zone"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1, 2);
   g_signal_connect(button, "clicked", ggz_login, NULL);
 #endif
 
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
-
   button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(gtk_main_quit), NULL);
-
-#if IS_BETA_VERSION
-  {
-    GtkWidget *label;
+                   G_CALLBACK(gtk_main_quit), NULL);
 
-    label = gtk_label_new(beta_message());
-    gtk_widget_set_name(label, "beta_label");
-    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
-    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
-    gtk_container_add(GTK_CONTAINER(sbox), label);
-  }
-#endif
-
-  return box;
+  return widget;
 }
 
 
@@ -1630,7 +1622,8 @@ GtkWidget *create_start_page(void)
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-				 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+                                 GTK_POLICY_AUTOMATIC,
+                                 GTK_POLICY_ALWAYS);
   gtk_widget_set_size_request(sw, -1, 200);
   gtk_container_add(GTK_CONTAINER(sw), view);
   gtk_box_pack_start(GTK_BOX(sbox), sw, TRUE, TRUE, 0);
@@ -1640,7 +1633,8 @@ GtkWidget *create_start_page(void)
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-				 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+                                 GTK_POLICY_AUTOMATIC,
+                                 GTK_POLICY_ALWAYS);
   gtk_box_pack_start(GTK_BOX(box), sw, TRUE, TRUE, 0);
 
   text = gtk_text_view_new_with_buffer(message_buffer);
@@ -2261,6 +2255,7 @@ void set_client_page(enum client_pages page)
   case PAGE_NATION:
     break;
   case PAGE_GAME:
+    reset_unit_table();
     enable_menus(TRUE);
     break;
   case PAGE_LOAD:
diff --git a/client/gui-gtk-2.0/plrdlg.c b/client/gui-gtk-2.0/plrdlg.c
index e1f6267..0a23f88 100644
--- a/client/gui-gtk-2.0/plrdlg.c
+++ b/client/gui-gtk-2.0/plrdlg.c
@@ -306,6 +306,62 @@ static void toggle_dead_players(GtkCheckMenuItem* item, gpointer data)
 }
 
 /**************************************************************************
+  Create and return the "diplomacy" menu for the player report. This menu
+  contains diplomacy actions the current player can use on other nations.
+**************************************************************************/
+static GtkWidget *create_diplomacy_menu(void)
+{
+  GtkWidget *menu, *item;
+
+  menu = gtk_menu_new();
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Meet"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_meet_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_meet_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("Cancel _Treaty"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_war_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_war_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Withdraw Vision"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_vision_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_vision_command = item;
+
+  return menu;
+}
+
+/**************************************************************************
+  Create and return the "intelligence" menu. The items in this menu are
+  used by the player to see more detailed information about other nations.
+**************************************************************************/
+static GtkWidget *create_intelligence_menu(void)
+{
+  GtkWidget *menu, *item;
+
+  menu = gtk_menu_new();
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Report"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_intel_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_int_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Spaceship"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_sship_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_sship_command = item;
+
+  return menu;
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 static GtkWidget* create_show_menu(void)
@@ -442,41 +498,6 @@ void create_players_dialog(void)
   gtk_box_pack_start(GTK_BOX(players_dialog_shell->vbox), sw,
 		     TRUE, TRUE, 0);
 
-  players_int_command = gtk_button_new_with_mnemonic(_("_Intelligence"));
-  g_signal_connect(players_int_command, "clicked",
-      G_CALLBACK(players_intel_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_int_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button, 
-      players_int_command);
-
-  players_meet_command = gtk_button_new_with_mnemonic(_("_Meet"));
-  g_signal_connect(players_meet_command, "clicked",
-      G_CALLBACK(players_meet_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_meet_command);
-  gtk_size_group_add_widget(players_dialog_shell->gui_button, 
-      players_meet_command);
-
-  players_war_command = gtk_button_new_with_mnemonic(_("Cancel _Treaty"));
-  g_signal_connect(players_war_command, "clicked",
-      G_CALLBACK(players_war_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_war_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-      players_war_command);
-
-  players_vision_command  = gtk_button_new_with_mnemonic(_("_Withdraw vision"));
-  g_signal_connect(players_vision_command, "clicked",
-      G_CALLBACK(players_vision_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_vision_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-     players_vision_command);
-
-  players_sship_command = gtk_button_new_with_mnemonic(_("_Spaceship"));
-  g_signal_connect(players_sship_command, "clicked",
-      G_CALLBACK(players_sship_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_sship_command);
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-      players_sship_command);
-
   vbox = gtk_vbox_new(FALSE, 0);
   
   sep = gtk_hseparator_new();
@@ -487,7 +508,17 @@ void create_players_dialog(void)
 
   gui_dialog_add_widget(players_dialog_shell, vbox);
   gtk_box_set_child_packing(GTK_BOX(players_dialog_shell->action_area), 
-      vbox, FALSE, FALSE, 0, GTK_PACK_END);
+                            vbox, FALSE, FALSE, 0, GTK_PACK_START);
+
+  item = gtk_menu_item_new_with_mnemonic(_("Di_plomacy"));
+  menu = create_diplomacy_menu();
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Intelligence"));
+  menu = create_intelligence_menu();
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
 
   item = gtk_menu_item_new_with_mnemonic(_("_Display"));
   menu = create_show_menu();
 client/gui-gtk-2.0/gui_main.c |   66 +++++++++++++++-----------
 client/gui-gtk-2.0/pages.c    |   85 ++++++++++++++++------------------
 client/gui-gtk-2.0/plrdlg.c   |  103 ++++++++++++++++++++++++++--------------
 3 files changed, 144 insertions(+), 110 deletions(-)

diff --git a/client/gui-gtk-2.0/gui_main.c b/client/gui-gtk-2.0/gui_main.c
index 33d13fe..bc01107 100644
--- a/client/gui-gtk-2.0/gui_main.c
+++ b/client/gui-gtk-2.0/gui_main.c
@@ -900,8 +900,6 @@ static void populate_unit_pixmap_table(void)
       
     gtk_table_attach_defaults(GTK_TABLE(table), unit_below_pixmap_button[i],
                               i, i + 1, 1, 2);
-    gtk_widget_set_size_request(unit_below_pixmap[i],
-				tileset_full_tile_width(tileset), tileset_full_tile_height(tileset));
     gtk_pixcomm_clear(GTK_PIXCOMM(unit_below_pixmap[i]));
   }
 
@@ -920,23 +918,25 @@ void reset_unit_table(void)
 {
   int i;
 
-  /* Unreference all of the widgets that we're about to reallocate, thus
-   * avoiding a memory leak. Remove them from the container first, just
-   * to be safe. Note, the widgets are ref'd in
-   * populatate_unit_pixmap_table. */
-  gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-		       unit_pixmap_button);
-  gtk_widget_unref(unit_pixmap);
-  gtk_widget_unref(unit_pixmap_button);
-  for (i = 0; i < num_units_below; i++) {
+  if (unit_pixmap_button) {
+    /* Unreference all of the widgets that we're about to reallocate, thus
+     * avoiding a memory leak. Remove them from the container first, just
+     * to be safe. Note, the widgets are ref'd in
+     * populatate_unit_pixmap_table. */
+    gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
+                         unit_pixmap_button);
+    gtk_widget_unref(unit_pixmap);
+    gtk_widget_unref(unit_pixmap_button);
+    for (i = 0; i < num_units_below; i++) {
+      gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
+                           unit_below_pixmap_button[i]);
+      gtk_widget_unref(unit_below_pixmap[i]);
+      gtk_widget_unref(unit_below_pixmap_button[i]);
+    }
     gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-			 unit_below_pixmap_button[i]);
-    gtk_widget_unref(unit_below_pixmap[i]);
-    gtk_widget_unref(unit_below_pixmap_button[i]);
+                         more_arrow_pixmap);
+    gtk_widget_unref(more_arrow_pixmap);
   }
-  gtk_container_remove(GTK_CONTAINER(unit_pixmap_table),
-		       more_arrow_pixmap);
-  gtk_widget_unref(more_arrow_pixmap);
 
   populate_unit_pixmap_table();
 
@@ -1083,13 +1083,15 @@ static void setup_widgets(void)
 
   ebox = gtk_event_box_new();
   gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
-
-  gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 0);
-
-  main_label_info = gtk_label_new("\n\n\n\n");
-  gtk_container_add(GTK_CONTAINER(ebox), main_label_info);
   g_signal_connect(ebox, "button_press_event",
                    G_CALLBACK(show_info_popup), NULL);
+  gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 0);
+
+  label = gtk_label_new(NULL);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_misc_set_padding(GTK_MISC(label), 2, 2);
+  gtk_container_add(GTK_CONTAINER(ebox), label);
+  main_label_info = label;
 
   /* Production status */
 
@@ -1172,7 +1174,6 @@ static void setup_widgets(void)
   timeout_label = gtk_label_new("");
 
   frame = gtk_frame_new(NULL);
-  gtk_widget_set_size_request(frame, tileset_small_sprite_width(tileset), tileset_small_sprite_height(tileset));
   gtk_table_attach_defaults(GTK_TABLE(table), frame, 4, 10, 1, 2);
   gtk_container_add(GTK_CONTAINER(frame), timeout_label);
 
@@ -1193,8 +1194,11 @@ static void setup_widgets(void)
   unit_info_frame = gtk_frame_new("");
   gtk_box_pack_start(GTK_BOX(avbox), unit_info_frame, FALSE, FALSE, 0);
     
-  unit_info_label = gtk_label_new("\n\n\n");
-  gtk_container_add(GTK_CONTAINER(unit_info_frame), unit_info_label);
+  label = gtk_label_new(NULL);
+  gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+  gtk_misc_set_padding(GTK_MISC(label), 2, 2);
+  gtk_container_add(GTK_CONTAINER(unit_info_frame), label);
+  unit_info_label = label;
 
   box = gtk_hbox_new(FALSE,0);
   gtk_box_pack_start(GTK_BOX(avbox), box, FALSE, FALSE, 0);
@@ -1206,7 +1210,6 @@ static void setup_widgets(void)
   gtk_table_set_col_spacings(GTK_TABLE(table), 2);
 
   unit_pixmap_table = table;
-  populate_unit_pixmap_table();
 
   top_notebook = gtk_notebook_new();  
   gtk_notebook_set_tab_pos(GTK_NOTEBOOK(top_notebook), GTK_POS_BOTTOM);
@@ -1242,7 +1245,6 @@ static void setup_widgets(void)
                                    |GDK_POINTER_MOTION_MASK
                                    |GDK_SCROLL_MASK);
 
-  gtk_widget_set_size_request(map_canvas, 510, 300);
   gtk_container_add(GTK_CONTAINER(frame), map_canvas);
 
   map_horizontal_scrollbar = gtk_hscrollbar_new(NULL);
@@ -1307,7 +1309,6 @@ static void setup_widgets(void)
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
   				 GTK_POLICY_ALWAYS);
-  gtk_widget_set_size_request(sw, 600, 100);
   gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
 
   label = gtk_label_new(_("Chat"));
@@ -1344,7 +1345,6 @@ static void setup_widgets(void)
   /* Other things to take care of */
 
   gtk_widget_show_all(gtk_bin_get_child(GTK_BIN(toplevel)));
-  gtk_widget_hide(more_arrow_pixmap);
 
   if (enable_tabs) {
     popup_meswin_dialog(FALSE);
@@ -1794,6 +1794,10 @@ void set_unit_icon(int idx, struct unit *punit)
     unit_ids[idx] = punit ? punit->id : 0;
   }
 
+  if (!w) {
+    return;
+  }
+
   gtk_pixcomm_freeze(GTK_PIXCOMM(w));
 
   if (punit) {
@@ -1814,6 +1818,10 @@ void set_unit_icons_more_arrow(bool onoff)
 {
   static bool showing = FALSE;
 
+  if (!more_arrow_pixmap) {
+    return;
+  }
+
   if (onoff && !showing) {
     gtk_widget_show(more_arrow_pixmap);
     showing = TRUE;
diff --git a/client/gui-gtk-2.0/pages.c b/client/gui-gtk-2.0/pages.c
index 414c848..df82c75 100644
--- a/client/gui-gtk-2.0/pages.c
+++ b/client/gui-gtk-2.0/pages.c
@@ -177,19 +177,17 @@ static void ggz_login(void)
 **************************************************************************/
 GtkWidget *create_main_page(void)
 {
-  GtkWidget *align, *box, *sbox, *bbox, *frame, *image;
-
-  GtkWidget *button;
+  GtkWidget *widget, *align, *vbox, *frame, *image, *button, *table;
   GtkSizeGroup *size;
 
   size = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
 
-  box = gtk_vbox_new(FALSE, 6);
-  gtk_container_set_border_width(GTK_CONTAINER(box), 4);
+  vbox = gtk_vbox_new(FALSE, 0);
+  widget = vbox;
 
   align = gtk_alignment_new(0.5, 0.0, 0.0, 0.0);
   gtk_container_set_border_width(GTK_CONTAINER(align), 18);
-  gtk_box_pack_start(GTK_BOX(box), align, FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(vbox), align, FALSE, FALSE, 0);
 
   frame = gtk_frame_new(NULL);
   gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT);
@@ -197,74 +195,68 @@ GtkWidget *create_main_page(void)
 
   image = gtk_image_new_from_file(tileset_main_intro_filename(tileset));
   g_signal_connect_after(image, "expose_event",
-      G_CALLBACK(intro_expose), NULL);
+                         G_CALLBACK(intro_expose), NULL);
   gtk_container_add(GTK_CONTAINER(frame), image);
 
-  align = gtk_alignment_new(0.5, 0.0, 0.0, 0.0);
-  gtk_box_pack_start(GTK_BOX(box), align, FALSE, FALSE, 0);
+#if IS_BETA_VERSION
+  {
+    GtkWidget *label;
 
-  sbox = gtk_vbox_new(FALSE, 18);
-  gtk_container_add(GTK_CONTAINER(align), sbox);
+    label = gtk_label_new(beta_message());
+    gtk_widget_set_name(label, "beta label");
+    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
+    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+    gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
+  }
+#endif
 
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
+  table = gtk_table_new(3, 2, TRUE);
+  align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
+  gtk_box_pack_start(GTK_BOX(vbox), align, TRUE, TRUE, 12);
+
+  gtk_table_set_row_spacings(GTK_TABLE(table), 8);
+  gtk_table_set_col_spacings(GTK_TABLE(table), 18);
+  gtk_container_add(GTK_CONTAINER(align), table);
 
   button = gtk_button_new_with_mnemonic(_("Start _New Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 0, 1);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(start_new_game_callback), NULL);
+                   G_CALLBACK(start_new_game_callback), NULL);
 
   button = gtk_button_new_with_mnemonic(_("Start _Scenario Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 1, 2);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(start_scenario_callback), NULL);
+                   G_CALLBACK(start_scenario_callback), NULL);
 
   button = gtk_button_new_with_mnemonic(_("_Load Saved Game"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 0, 1, 2, 3);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(load_saved_game_callback), NULL);
-
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
+                   G_CALLBACK(load_saved_game_callback), NULL);
 
   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);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(set_page_callback), GUINT_TO_POINTER(PAGE_NETWORK));
+                   G_CALLBACK(set_page_callback),
+                   GUINT_TO_POINTER(PAGE_NETWORK));
 
 #ifdef GGZ_GTK
   button = gtk_button_new_with_mnemonic(_("Connect to Gaming _Zone"));
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1, 2);
   g_signal_connect(button, "clicked", ggz_login, NULL);
 #endif
 
-  bbox = gtk_vbox_new(FALSE, 6);
-  gtk_container_add(GTK_CONTAINER(sbox), bbox);
-
   button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
   gtk_size_group_add_widget(size, button);
-  gtk_container_add(GTK_CONTAINER(bbox), button);
+  gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 2, 3);
   g_signal_connect(button, "clicked",
-      G_CALLBACK(gtk_main_quit), NULL);
-
-#if IS_BETA_VERSION
-  {
-    GtkWidget *label;
+                   G_CALLBACK(gtk_main_quit), NULL);
 
-    label = gtk_label_new(beta_message());
-    gtk_widget_set_name(label, "beta label");
-    gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5);
-    gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
-    gtk_container_add(GTK_CONTAINER(sbox), label);
-  }
-#endif
-
-  return box;
+  return widget;
 }
 
 
@@ -1628,7 +1620,8 @@ GtkWidget *create_start_page(void)
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-				 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+                                 GTK_POLICY_AUTOMATIC,
+                                 GTK_POLICY_ALWAYS);
   gtk_widget_set_size_request(sw, -1, 200);
   gtk_container_add(GTK_CONTAINER(sw), view);
   gtk_box_pack_start(GTK_BOX(sbox), sw, TRUE, TRUE, 0);
@@ -1638,7 +1631,8 @@ GtkWidget *create_start_page(void)
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
 				      GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
-				 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+                                 GTK_POLICY_AUTOMATIC,
+                                 GTK_POLICY_ALWAYS);
   gtk_box_pack_start(GTK_BOX(box), sw, TRUE, TRUE, 0);
 
   text = gtk_text_view_new_with_buffer(message_buffer);
@@ -2268,6 +2262,7 @@ void set_client_page(enum client_pages page)
   case PAGE_NATION:
     break;
   case PAGE_GAME:
+    reset_unit_table();
     enable_menus(TRUE);
     break;
   case PAGE_LOAD:
diff --git a/client/gui-gtk-2.0/plrdlg.c b/client/gui-gtk-2.0/plrdlg.c
index cd88021..e49fd3e 100644
--- a/client/gui-gtk-2.0/plrdlg.c
+++ b/client/gui-gtk-2.0/plrdlg.c
@@ -305,6 +305,62 @@ static void toggle_dead_players(GtkCheckMenuItem* item, gpointer data)
 }
 
 /**************************************************************************
+  Create and return the "diplomacy" menu for the player report. This menu
+  contains diplomacy actions the current player can use on other nations.
+**************************************************************************/
+static GtkWidget *create_diplomacy_menu(void)
+{
+  GtkWidget *menu, *item;
+
+  menu = gtk_menu_new();
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Meet"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_meet_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_meet_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("Cancel _Treaty"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_war_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_war_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Withdraw Vision"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_vision_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_vision_command = item;
+
+  return menu;
+}
+
+/**************************************************************************
+  Create and return the "intelligence" menu. The items in this menu are
+  used by the player to see more detailed information about other nations.
+**************************************************************************/
+static GtkWidget *create_intelligence_menu(void)
+{
+  GtkWidget *menu, *item;
+
+  menu = gtk_menu_new();
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Report"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_intel_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_int_command = item;
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Spaceship"));
+  g_signal_connect(item, "activate",
+                   G_CALLBACK(players_sship_callback), NULL);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+  players_sship_command = item;
+
+  return menu;
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 static GtkWidget* create_show_menu(void)
@@ -440,41 +496,6 @@ void create_players_dialog(void)
   gtk_box_pack_start(GTK_BOX(players_dialog_shell->vbox), sw,
 		     TRUE, TRUE, 0);
 
-  players_int_command = gtk_button_new_with_mnemonic(_("_Intelligence"));
-  g_signal_connect(players_int_command, "clicked",
-      G_CALLBACK(players_intel_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_int_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button, 
-      players_int_command);
-
-  players_meet_command = gtk_button_new_with_mnemonic(_("_Meet"));
-  g_signal_connect(players_meet_command, "clicked",
-      G_CALLBACK(players_meet_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_meet_command);
-  gtk_size_group_add_widget(players_dialog_shell->gui_button, 
-      players_meet_command);
-
-  players_war_command = gtk_button_new_with_mnemonic(_("Cancel _Treaty"));
-  g_signal_connect(players_war_command, "clicked",
-      G_CALLBACK(players_war_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_war_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-      players_war_command);
-
-  players_vision_command  = gtk_button_new_with_mnemonic(_("_Withdraw vision"));
-  g_signal_connect(players_vision_command, "clicked",
-      G_CALLBACK(players_vision_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_vision_command);  
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-     players_vision_command);
-
-  players_sship_command = gtk_button_new_with_mnemonic(_("_Spaceship"));
-  g_signal_connect(players_sship_command, "clicked",
-      G_CALLBACK(players_sship_callback), NULL);
-  gui_dialog_add_widget(players_dialog_shell, players_sship_command);
-  gtk_size_group_add_widget(players_dialog_shell->gui_button,
-      players_sship_command);
-
   vbox = gtk_vbox_new(FALSE, 0);
   
   sep = gtk_hseparator_new();
@@ -485,7 +506,17 @@ void create_players_dialog(void)
 
   gui_dialog_add_widget(players_dialog_shell, vbox);
   gtk_box_set_child_packing(GTK_BOX(players_dialog_shell->action_area), 
-      vbox, FALSE, FALSE, 0, GTK_PACK_END);
+                            vbox, FALSE, FALSE, 0, GTK_PACK_START);
+
+  item = gtk_menu_item_new_with_mnemonic(_("Di_plomacy"));
+  menu = create_diplomacy_menu();
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
+
+  item = gtk_menu_item_new_with_mnemonic(_("_Intelligence"));
+  menu = create_intelligence_menu();
+  gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), menu);
+  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), item);
 
   item = gtk_menu_item_new_with_mnemonic(_("_Display"));
   menu = create_show_menu();
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to