Author: cazfi Date: Wed Jan 27 01:52:03 2016 New Revision: 31618 URL: http://svn.gna.org/viewcvs/freeciv?rev=31618&view=rev Log: Cleanup and improve comments of gtk-clients' refresh_worklist()
Requested by Jacob Nevins <jtn> See bug #17595 Modified: trunk/client/gui-gtk-2.0/wldlg.c trunk/client/gui-gtk-3.0/wldlg.c trunk/client/gui-gtk-3.x/wldlg.c Modified: trunk/client/gui-gtk-2.0/wldlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/wldlg.c?rev=31618&r1=31617&r2=31618&view=diff ============================================================================== --- trunk/client/gui-gtk-2.0/wldlg.c (original) +++ trunk/client/gui-gtk-2.0/wldlg.c Wed Jan 27 01:52:03 2016 @@ -1329,7 +1329,6 @@ void refresh_worklist(GtkWidget *editor) { struct worklist_data *ptr; - const struct global_worklist *pgwl = NULL; struct worklist queue; struct universal targets[MAX_NUM_PRODUCTION_TARGETS]; int i, targets_used; @@ -1343,10 +1342,6 @@ ptr = g_object_get_data(G_OBJECT(editor), "data"); - if (!ptr->pcity - && !(pgwl = global_worklist_by_id(ptr->global_worklist_id))) { - } - /* refresh source tasks. */ if (gtk_tree_selection_get_selected(ptr->src_selection, NULL, &it)) { gtk_tree_model_get(GTK_TREE_MODEL(ptr->src), &it, 0, &id, -1); @@ -1356,6 +1351,8 @@ } gtk_list_store_clear(ptr->src); + /* These behave just right if ptr->pcity is NULL -> in case of global + * worklist. */ targets_used = collect_eventually_buildable_targets(targets, ptr->pcity, ptr->future); name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity); @@ -1380,10 +1377,15 @@ exists = gtk_tree_model_get_iter_first(model, &it); /* dance around worklist braindamage. */ - if (ptr->pcity) { + if (ptr->pcity != NULL) { city_get_queue(ptr->pcity, &queue); } else { + const struct global_worklist *pgwl; + + pgwl = global_worklist_by_id(ptr->global_worklist_id); + fc_assert(NULL != pgwl); + worklist_copy(&queue, global_worklist_get(pgwl)); } @@ -1416,8 +1418,8 @@ /* update widget sensitivity. */ if (ptr->pcity) { - if ((can_client_issue_orders() && - city_owner(ptr->pcity) == client.conn.playing)) { + if ((can_client_issue_orders() + && city_owner(ptr->pcity) == client.conn.playing)) { gtk_widget_set_sensitive(ptr->add_cmd, TRUE); gtk_widget_set_sensitive(ptr->dst_view, TRUE); } else { Modified: trunk/client/gui-gtk-3.0/wldlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/wldlg.c?rev=31618&r1=31617&r2=31618&view=diff ============================================================================== --- trunk/client/gui-gtk-3.0/wldlg.c (original) +++ trunk/client/gui-gtk-3.0/wldlg.c Wed Jan 27 01:52:03 2016 @@ -1334,7 +1334,6 @@ void refresh_worklist(GtkWidget *editor) { struct worklist_data *ptr; - const struct global_worklist *pgwl = NULL; struct worklist queue; struct universal targets[MAX_NUM_PRODUCTION_TARGETS]; int i, targets_used; @@ -1348,10 +1347,6 @@ ptr = g_object_get_data(G_OBJECT(editor), "data"); - if (!ptr->pcity - && !(pgwl = global_worklist_by_id(ptr->global_worklist_id))) { - } - /* refresh source tasks. */ if (gtk_tree_selection_get_selected(ptr->src_selection, NULL, &it)) { gtk_tree_model_get(GTK_TREE_MODEL(ptr->src), &it, 0, &id, -1); @@ -1361,6 +1356,8 @@ } gtk_list_store_clear(ptr->src); + /* These behave just right if ptr->pcity is NULL -> in case of global + * worklist. */ targets_used = collect_eventually_buildable_targets(targets, ptr->pcity, ptr->future); name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity); @@ -1385,10 +1382,15 @@ exists = gtk_tree_model_get_iter_first(model, &it); /* dance around worklist braindamage. */ - if (ptr->pcity) { + if (ptr->pcity != NULL) { city_get_queue(ptr->pcity, &queue); } else { + const struct global_worklist *pgwl; + + pgwl = global_worklist_by_id(ptr->global_worklist_id); + fc_assert(NULL != pgwl); + worklist_copy(&queue, global_worklist_get(pgwl)); } @@ -1421,8 +1423,8 @@ /* update widget sensitivity. */ if (ptr->pcity) { - if ((can_client_issue_orders() && - city_owner(ptr->pcity) == client.conn.playing)) { + if ((can_client_issue_orders() + && city_owner(ptr->pcity) == client.conn.playing)) { gtk_widget_set_sensitive(ptr->add_cmd, TRUE); gtk_widget_set_sensitive(ptr->dst_view, TRUE); } else { Modified: trunk/client/gui-gtk-3.x/wldlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/wldlg.c?rev=31618&r1=31617&r2=31618&view=diff ============================================================================== --- trunk/client/gui-gtk-3.x/wldlg.c (original) +++ trunk/client/gui-gtk-3.x/wldlg.c Wed Jan 27 01:52:03 2016 @@ -1332,7 +1332,6 @@ void refresh_worklist(GtkWidget *editor) { struct worklist_data *ptr; - const struct global_worklist *pgwl = NULL; struct worklist queue; struct universal targets[MAX_NUM_PRODUCTION_TARGETS]; int i, targets_used; @@ -1346,10 +1345,6 @@ ptr = g_object_get_data(G_OBJECT(editor), "data"); - if (!ptr->pcity - && !(pgwl = global_worklist_by_id(ptr->global_worklist_id))) { - } - /* refresh source tasks. */ if (gtk_tree_selection_get_selected(ptr->src_selection, NULL, &it)) { gtk_tree_model_get(GTK_TREE_MODEL(ptr->src), &it, 0, &id, -1); @@ -1359,6 +1354,8 @@ } gtk_list_store_clear(ptr->src); + /* These behave just right if ptr->pcity is NULL -> in case of global + * worklist. */ targets_used = collect_eventually_buildable_targets(targets, ptr->pcity, ptr->future); name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity); @@ -1383,10 +1380,15 @@ exists = gtk_tree_model_get_iter_first(model, &it); /* dance around worklist braindamage. */ - if (ptr->pcity) { + if (ptr->pcity != NULL) { city_get_queue(ptr->pcity, &queue); } else { + const struct global_worklist *pgwl; + + pgwl = global_worklist_by_id(ptr->global_worklist_id); + fc_assert(NULL != pgwl); + worklist_copy(&queue, global_worklist_get(pgwl)); } @@ -1419,8 +1421,8 @@ /* update widget sensitivity. */ if (ptr->pcity) { - if ((can_client_issue_orders() && - city_owner(ptr->pcity) == client.conn.playing)) { + if ((can_client_issue_orders() + && city_owner(ptr->pcity) == client.conn.playing)) { gtk_widget_set_sensitive(ptr->add_cmd, TRUE); gtk_widget_set_sensitive(ptr->dst_view, TRUE); } else { _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits