Author: cazfi
Date: Wed Jun 22 22:23:50 2016
New Revision: 32971

URL: http://svn.gna.org/viewcvs/freeciv?rev=32971&view=rev
Log:
Never have gtk-clients' citydlg 'Next City' or 'Prev City' buttons sensitive
when running as global observer, as those buttons do nothing for global 
observer.

See bug #24059

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

Modified: branches/S2_5/client/gui-gtk-2.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-2.0/citydlg.c?rev=32971&r1=32970&r2=32971&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-2.0/citydlg.c  (original)
+++ branches/S2_5/client/gui-gtk-2.0/citydlg.c  Wed Jun 22 22:23:50 2016
@@ -1389,17 +1389,16 @@
                   G_CALLBACK(show_units_callback), pdialog);
 
   pdialog->prev_command = gtk_stockbutton_new(GTK_STOCK_GO_BACK,
-       _("_Prev city"));
+                                              _("_Prev city"));
   gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell),
-                              pdialog->prev_command, 1);
+                               pdialog->prev_command, 1);
 
   pdialog->next_command = gtk_stockbutton_new(GTK_STOCK_GO_FORWARD,
-       _("_Next city"));
+                                              _("_Next city"));
   gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell),
-                              pdialog->next_command, 2);
+                               pdialog->next_command, 2);
   
-  if (NULL == client.conn.playing
-      || city_owner(pcity) != client.conn.playing) {
+  if (city_owner(pcity) != client.conn.playing) {
     gtk_widget_set_sensitive(pdialog->prev_command, FALSE);
     gtk_widget_set_sensitive(pdialog->next_command, FALSE);
   }
@@ -1414,10 +1413,10 @@
                   G_CALLBACK(close_callback), pdialog);
 
   g_signal_connect(pdialog->prev_command, "clicked",
-                  G_CALLBACK(switch_city_callback), pdialog);
+                   G_CALLBACK(switch_city_callback), pdialog);
 
   g_signal_connect(pdialog->next_command, "clicked",
-                  G_CALLBACK(switch_city_callback), pdialog);
+                   G_CALLBACK(switch_city_callback), pdialog);
 
   /* some other things we gotta do */
 
@@ -2026,45 +2025,42 @@
 }
 
 /****************************************************************
- updates the sensitivity of the the prev and next buttons.
- this does not need pdialog as a parameter, since it iterates
- over all the open dialogs.
- note: we still need the sensitivity code in create_city_dialog()
- for the spied dialogs.
+  Updates the sensitivity of the the prev and next buttons.
+  this does not need pdialog as a parameter, since it iterates
+  over all the open dialogs.
+  note: we still need the sensitivity code in create_city_dialog()
+  for the spied dialogs.
 *****************************************************************/
 static void city_dialog_update_prev_next(void)
 {
   int count = 0;
   int city_number;
 
-  if (NULL != client.conn.playing) {
-    city_number = city_list_size(client.conn.playing->cities);
-  } else {
-    city_number = FC_INFINITY; /* ? */
-  }
+  if (client_is_global_observer()) {
+    return; /* Keep them insensitive as initially set */
+  }
+
+  city_number = city_list_size(client.conn.playing->cities);
 
   /* the first time, we see if all the city dialogs are open */
-
   dialog_list_iterate(dialog_list, pdialog) {
-    if (city_owner(pdialog->pcity) == client.conn.playing)
+    if (city_owner(pdialog->pcity) == client.conn.playing) {
       count++;
-  }
-  dialog_list_iterate_end;
+    }
+  } dialog_list_iterate_end;
 
   if (count == city_number) {  /* all are open, shouldn't prev/next */
     dialog_list_iterate(dialog_list, pdialog) {
       gtk_widget_set_sensitive(pdialog->prev_command, FALSE);
       gtk_widget_set_sensitive(pdialog->next_command, FALSE);
-    }
-    dialog_list_iterate_end;
+    } dialog_list_iterate_end;
   } else {
     dialog_list_iterate(dialog_list, pdialog) {
       if (city_owner(pdialog->pcity) == client.conn.playing) {
        gtk_widget_set_sensitive(pdialog->prev_command, TRUE);
        gtk_widget_set_sensitive(pdialog->next_command, TRUE);
       }
-    }
-    dialog_list_iterate_end;
+    } dialog_list_iterate_end;
   }
 }
 
@@ -2946,7 +2942,7 @@
   int i, j, dir, size;
   struct city *new_pcity = NULL;
 
-  if (NULL == client.conn.playing) {
+  if (client_is_global_observer()) {
     return;
   }
 

Modified: branches/S2_5/client/gui-gtk-3.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-gtk-3.0/citydlg.c?rev=32971&r1=32970&r2=32971&view=diff
==============================================================================
--- branches/S2_5/client/gui-gtk-3.0/citydlg.c  (original)
+++ branches/S2_5/client/gui-gtk-3.0/citydlg.c  Wed Jun 22 22:23:50 2016
@@ -1582,17 +1582,16 @@
                    G_CALLBACK(citydlg_response_callback), pdialog);
 
   pdialog->prev_command = gtk_stockbutton_new(GTK_STOCK_GO_BACK,
-       _("_Prev city"));
+                                              _("_Prev city"));
   gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell),
-                              pdialog->prev_command, 1);
+                               pdialog->prev_command, 1);
 
   pdialog->next_command = gtk_stockbutton_new(GTK_STOCK_GO_FORWARD,
-       _("_Next city"));
+                                              _("_Next city"));
   gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell),
-                              pdialog->next_command, 2);
+                               pdialog->next_command, 2);
   
-  if (NULL == client.conn.playing
-      || city_owner(pcity) != client.conn.playing) {
+  if (city_owner(pcity) != client.conn.playing) {
     gtk_widget_set_sensitive(pdialog->prev_command, FALSE);
     gtk_widget_set_sensitive(pdialog->next_command, FALSE);
   }
@@ -1607,10 +1606,10 @@
                   G_CALLBACK(close_callback), pdialog);
 
   g_signal_connect(pdialog->prev_command, "clicked",
-                  G_CALLBACK(switch_city_callback), pdialog);
+                   G_CALLBACK(switch_city_callback), pdialog);
 
   g_signal_connect(pdialog->next_command, "clicked",
-                  G_CALLBACK(switch_city_callback), pdialog);
+                   G_CALLBACK(switch_city_callback), pdialog);
 
   /* some other things we gotta do */
 
@@ -2220,45 +2219,42 @@
 }
 
 /****************************************************************
- updates the sensitivity of the the prev and next buttons.
- this does not need pdialog as a parameter, since it iterates
- over all the open dialogs.
- note: we still need the sensitivity code in create_city_dialog()
- for the spied dialogs.
+  Updates the sensitivity of the the prev and next buttons.
+  this does not need pdialog as a parameter, since it iterates
+  over all the open dialogs.
+  note: we still need the sensitivity code in create_city_dialog()
+  for the spied dialogs.
 *****************************************************************/
 static void city_dialog_update_prev_next(void)
 {
   int count = 0;
   int city_number;
 
-  if (NULL != client.conn.playing) {
-    city_number = city_list_size(client.conn.playing->cities);
-  } else {
-    city_number = FC_INFINITY; /* ? */
-  }
+  if (client_is_global_observer()) {
+    return; /* Keep them insensitive as initially set */
+  }
+
+  city_number = city_list_size(client.conn.playing->cities);
 
   /* the first time, we see if all the city dialogs are open */
-
   dialog_list_iterate(dialog_list, pdialog) {
-    if (city_owner(pdialog->pcity) == client.conn.playing)
+    if (city_owner(pdialog->pcity) == client.conn.playing) {
       count++;
-  }
-  dialog_list_iterate_end;
+    }
+  } dialog_list_iterate_end;
 
   if (count == city_number) {  /* all are open, shouldn't prev/next */
     dialog_list_iterate(dialog_list, pdialog) {
       gtk_widget_set_sensitive(pdialog->prev_command, FALSE);
       gtk_widget_set_sensitive(pdialog->next_command, FALSE);
-    }
-    dialog_list_iterate_end;
+    } dialog_list_iterate_end;
   } else {
     dialog_list_iterate(dialog_list, pdialog) {
       if (city_owner(pdialog->pcity) == client.conn.playing) {
        gtk_widget_set_sensitive(pdialog->prev_command, TRUE);
        gtk_widget_set_sensitive(pdialog->next_command, TRUE);
       }
-    }
-    dialog_list_iterate_end;
+    } dialog_list_iterate_end;
   }
 }
 
@@ -3160,7 +3156,7 @@
   int i, j, dir, size;
   struct city *new_pcity = NULL;
 
-  if (NULL == client.conn.playing) {
+  if (client_is_global_observer()) {
     return;
   }
 


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

Reply via email to