Author: cazfi Date: Wed Jun 22 22:23:37 2016 New Revision: 32969 URL: http://svn.gna.org/viewcvs/freeciv?rev=32969&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: trunk/client/gui-gtk-2.0/citydlg.c trunk/client/gui-gtk-3.0/citydlg.c trunk/client/gui-gtk-3.x/citydlg.c Modified: trunk/client/gui-gtk-2.0/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/citydlg.c?rev=32969&r1=32968&r2=32969&view=diff ============================================================================== --- trunk/client/gui-gtk-2.0/citydlg.c (original) +++ trunk/client/gui-gtk-2.0/citydlg.c Wed Jun 22 22:23:37 2016 @@ -1396,17 +1396,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); } @@ -1421,10 +1420,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 */ @@ -2035,45 +2034,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; } } @@ -2962,7 +2958,7 @@ int i, j, dir, size; struct city *new_pcity = NULL; - if (NULL == client.conn.playing) { + if (client_is_global_observer()) { return; } Modified: trunk/client/gui-gtk-3.0/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/citydlg.c?rev=32969&r1=32968&r2=32969&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/citydlg.c (original) +++ trunk/client/gui-gtk-3.0/citydlg.c Wed Jun 22 22:23:37 2016 @@ -1609,17 +1609,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); } @@ -1634,10 +1633,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 */ @@ -2255,45 +2254,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; } } @@ -3335,7 +3331,7 @@ int i, j, dir, size; struct city *new_pcity = NULL; - if (NULL == client.conn.playing) { + if (client_is_global_observer()) { return; } Modified: trunk/client/gui-gtk-3.x/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/citydlg.c?rev=32969&r1=32968&r2=32969&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/citydlg.c (original) +++ trunk/client/gui-gtk-3.x/citydlg.c Wed Jun 22 22:23:37 2016 @@ -1614,8 +1614,7 @@ gtk_dialog_add_action_widget(GTK_DIALOG(pdialog->shell), GTK_WIDGET(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(GTK_WIDGET(pdialog->prev_command), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(pdialog->next_command), FALSE); } @@ -1630,10 +1629,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 */ @@ -3356,7 +3355,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