Author: cazfi
Date: Wed Nov 18 17:07:43 2015
New Revision: 30668

URL: http://svn.gna.org/viewcvs/freeciv?rev=30668&view=rev
Log:
Make sure "Airlift" button is insensitive when the gtk-clients' "Goto City" 
dialog has no cities
listed at all.

See bug #24060

Modified:
    branches/S2_5/client/gui-gtk-2.0/gotodlg.c
    branches/S2_5/client/gui-gtk-3.0/gotodlg.c

Modified: branches/S2_5/client/gui-gtk-2.0/gotodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/gotodlg.c?rev=30668&r1=30667&r2=30668&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/gotodlg.c  (original)
+++ branches/S2_5/client/gui-gtk-2.0/gotodlg.c  Wed Nov 18 17:07:43 2015
@@ -286,13 +286,19 @@
 /**************************************************************************
   Appends the list of the city owned by the player in the goto dialog.
 **************************************************************************/
-static void list_store_append_player_cities(GtkListStore *store,
+static bool list_store_append_player_cities(GtkListStore *store,
                                             const struct player *pplayer)
 {
   GtkTreeIter it;
   struct nation_type *pnation = nation_of_player(pplayer);
   const char *nation = nation_adjective_translation(pnation);
-  GdkPixbuf *pixbuf = get_flag(pnation);
+  GdkPixbuf *pixbuf;
+
+  if (city_list_size(pplayer->cities) == 0) {
+    return FALSE;
+  }
+
+  pixbuf = get_flag(pnation);
 
   city_list_iterate(pplayer->cities, pcity) {
     gtk_list_store_append(store, &it);
@@ -305,6 +311,8 @@
                        -1);
   } city_list_iterate_end;
   g_object_unref(pixbuf);
+
+  return TRUE;
 }
 
 /**************************************************************************
@@ -418,6 +426,8 @@
 **************************************************************************/
 static void update_goto_dialog(GtkToggleButton *button)
 {
+  bool nonempty = FALSE;
+
   gtk_list_store_clear(store);
 
   if (!client_has_player()) {
@@ -427,12 +437,18 @@
 
   if (gtk_toggle_button_get_active(button)) {
     players_iterate(pplayer) {
-      list_store_append_player_cities(store, pplayer);
+      nonempty |= list_store_append_player_cities(store, pplayer);
     } players_iterate_end;
   } else {
-    list_store_append_player_cities(store, client_player());
+    nonempty |= list_store_append_player_cities(store, client_player());
   }
   refresh_airlift_column();
+
+  if (!nonempty) {
+    /* No selection causes callbacks to fire, causing also Airlift button
+     * to update. Do it here. */
+    refresh_airlift_button();
+  }
 }
 
 /**************************************************************************
@@ -494,6 +510,7 @@
                                     gpointer data)
 {
   struct city *pdestcity = get_selected_city();
+
   if (NULL != pdestcity) {
     center_tile_mapcanvas(city_tile(pdestcity));
   }

Modified: branches/S2_5/client/gui-gtk-3.0/gotodlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/gotodlg.c?rev=30668&r1=30667&r2=30668&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/gotodlg.c  (original)
+++ branches/S2_5/client/gui-gtk-3.0/gotodlg.c  Wed Nov 18 17:07:43 2015
@@ -290,13 +290,19 @@
 /**************************************************************************
   Appends the list of the city owned by the player in the goto dialog.
 **************************************************************************/
-static void list_store_append_player_cities(GtkListStore *store,
+static bool list_store_append_player_cities(GtkListStore *store,
                                             const struct player *pplayer)
 {
   GtkTreeIter it;
   struct nation_type *pnation = nation_of_player(pplayer);
   const char *nation = nation_adjective_translation(pnation);
-  GdkPixbuf *pixbuf = get_flag(pnation);
+  GdkPixbuf *pixbuf;
+
+  if (city_list_size(pplayer->cities) == 0) {
+    return FALSE;
+  }
+
+  pixbuf = get_flag(pnation);
 
   city_list_iterate(pplayer->cities, pcity) {
     gtk_list_store_append(store, &it);
@@ -309,6 +315,8 @@
                        -1);
   } city_list_iterate_end;
   g_object_unref(pixbuf);
+
+  return TRUE;
 }
 
 /**************************************************************************
@@ -422,6 +430,8 @@
 **************************************************************************/
 static void update_goto_dialog(GtkToggleButton *button)
 {
+  bool nonempty = FALSE;
+
   if (!client_has_player()) {
     /* Case global observer. */
     return;
@@ -433,15 +443,21 @@
 
   if (gtk_toggle_button_get_active(button)) {
     players_iterate(pplayer) {
-      list_store_append_player_cities(store, pplayer);
+      nonempty |= list_store_append_player_cities(store, pplayer);
     } players_iterate_end;
   } else {
-    list_store_append_player_cities(store, client_player());
+    nonempty |= list_store_append_player_cities(store, client_player());
   }
 
   gotodlg_updating = FALSE;
 
   refresh_airlift_column();
+
+  if (!nonempty) {
+    /* No selection causes callbacks to fire, causing also Airlift button
+     * to update. Do it here. */
+    refresh_airlift_button();
+  }
 }
 
 /**************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to