Example #1
0
/****************************************************************
  Selection from source
*****************************************************************/
static void src_selection_callback(GtkTreeSelection *selection, gpointer data)
{
  struct worklist_data *ptr;

  ptr = data;

  /* update widget sensitivity. */
  if (gtk_tree_selection_get_selected(selection, NULL, NULL)) {
    if (can_client_issue_orders()
      && (!ptr->pcity || city_owner(ptr->pcity) == client.conn.playing)) {
      /* if ptr->pcity is NULL, this is a global worklist */
      gtk_widget_set_sensitive(ptr->change_cmd, TRUE);
      gtk_widget_set_sensitive(ptr->prepend_cmd, TRUE);
      gtk_widget_set_sensitive(ptr->append_cmd, TRUE);
    } else {
      gtk_widget_set_sensitive(ptr->change_cmd, FALSE);
      gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE);
      gtk_widget_set_sensitive(ptr->append_cmd, FALSE);
    }
    gtk_widget_set_sensitive(ptr->help_cmd, TRUE);
  } else {
    gtk_widget_set_sensitive(ptr->change_cmd, FALSE);
    gtk_widget_set_sensitive(ptr->help_cmd, FALSE);
    gtk_widget_set_sensitive(ptr->prepend_cmd, FALSE);
    gtk_widget_set_sensitive(ptr->append_cmd, FALSE);
  }
}
Example #2
0
/****************************************************************
  Popup rates dialog
*****************************************************************/
void popup_rates_dialog(void)
{
  char buf[64];

  if (!can_client_issue_orders()) {
    return;
  }

  if (!rates_dialog_shell) {
    rates_dialog_shell = create_rates_dialog();
  }
  if (!rates_dialog_shell) {
    return;
  }

  fc_snprintf(buf, sizeof(buf), _("%s max rate: %d%%"),
      government_name_for_player(client.conn.playing),
      get_player_bonus(client.conn.playing, EFT_MAX_RATES));
  gtk_label_set_text(GTK_LABEL(rates_gov_label), buf);
  gtk_range_set_fill_level(GTK_RANGE(rates_tax_scale),
                           get_player_bonus(client.conn.playing,
                                            EFT_MAX_RATES)/10);
  gtk_range_set_fill_level(GTK_RANGE(rates_lux_scale),
                           get_player_bonus(client.conn.playing,
                                            EFT_MAX_RATES)/10);
  gtk_range_set_fill_level(GTK_RANGE(rates_sci_scale),
                           get_player_bonus(client.conn.playing,
                                            EFT_MAX_RATES)/10);

  gtk_window_present(GTK_WINDOW(rates_dialog_shell));
}
Example #3
0
/****************************************************************
... 
*****************************************************************/
void popup_rates_dialog(void)
{
  Position x, y;
  Dimension width, height;
  char buf[64];

  if (!can_client_issue_orders()) {
    return;
  }

  XtSetSensitive(main_form, FALSE);

  create_rates_dialog();
  
  XtVaGetValues(toplevel, XtNwidth, &width, XtNheight, &height, NULL);
  
  XtTranslateCoords(toplevel, (Position) width/10, (Position) height/10,
		    &x, &y);
  XtVaSetValues(rates_dialog_shell, XtNx, x, XtNy, y, NULL);

  my_snprintf(buf, sizeof(buf), _("%s max rate: %d%%"),
	      government_name_for_player(client.conn.playing),
	      get_player_bonus(client.conn.playing, EFT_MAX_RATES));
  xaw_set_label(rates_gov_label, buf);
  
  XtPopup(rates_dialog_shell, XtGrabNone);
}
Example #4
0
/****************************************************************************
  Invoked when the key binding for orders->airbase is pressed.
****************************************************************************/
static void xaw_key_unit_airbase(Widget w, XEvent *event,
				 String *argv, Cardinal *argc)
{
  if (can_client_issue_orders()
      && is_menu_item_active(MENU_ORDER, MENU_ORDER_AIRBASE)) {
    key_unit_airbase();
  }
}
Example #5
0
/****************************************************************************
  Adds focus units to given battlegroup
  (or removes unit from battlegoup if battlegroup is the same that unit has).
****************************************************************************/
void add_unit_to_battlegroup(int battlegroup)
{
  if (NULL != client.conn.playing && can_client_issue_orders()) {
    struct unit *punit;

    punit = head_of_units_in_focus();
    if (punit && punit->battlegroup == battlegroup) {
      /* If top unit already in the same battlegroup, detach it */
      unit_change_battlegroup(punit, BATTLEGROUP_NONE);
      refresh_unit_mapcanvas(punit, punit->tile, TRUE, FALSE);
    } else {
      key_unit_assign_battlegroup(battlegroup, TRUE);
    }
  }
}
Example #6
0
/**************************************************************************
  Button pressed at overview
**************************************************************************/
gboolean butt_down_overviewcanvas(GtkWidget *w, GdkEventButton *ev, gpointer data)
{
  int xtile, ytile;

  if (ev->type != GDK_BUTTON_PRESS)
    return TRUE; /* Double-clicks? Triple-clicks? No thanks! */

  overview_to_map_pos(&xtile, &ytile, ev->x, ev->y);

  if (can_client_change_view() && (ev->button == 3)) {
    center_tile_mapcanvas(map_pos_to_tile(xtile, ytile));
  } else if (can_client_issue_orders() && (ev->button == 1)) {
    do_map_click(map_pos_to_tile(xtile, ytile),
		 (ev->state & GDK_SHIFT_MASK) ? SELECT_APPEND : SELECT_POPUP);
  }

  return TRUE;
}
Example #7
0
/****************************************************************
...
*****************************************************************/
static void unitdisband_callback_yes(Widget w, XtPointer client_data, XtPointer call_data)
{
  struct unit_list *punits = client_data;

  /* Is it right place for breaking? -ev */
  if (!can_client_issue_orders()) {
    unit_list_destroy(punits);
    return;
  }

  unit_list_iterate(punits, punit) {
    if (!unit_has_type_flag(punit, UTYF_UNDISBANDABLE)) {
      request_unit_disband(punit);
    }
  } unit_list_iterate_end;

  unit_list_destroy(punits);
  destroy_message_dialog(w);
}
Example #8
0
/**************************************************************************
...
**************************************************************************/
void update_goto_dialog(Widget goto_list)
{
  int j = 0;
  Boolean all_cities;

  if (!can_client_issue_orders()) {
    return;
  }

  XtVaGetValues(goto_all_toggle, XtNstate, &all_cities, NULL);

  cleanup_goto_list();

  if(all_cities) {
    ncities_total = 0;
    players_iterate(pplayer) {
      ncities_total += city_list_size(pplayer->cities);
    } players_iterate_end;
  } else {
Example #9
0
/****************************************************************
popup the dialog 10% inside the main-window 
*****************************************************************/
void popup_goto_dialog(void)
{
  Position x, y;
  Dimension width, height;
  Boolean no_player_cities;

  if (!can_client_issue_orders() || get_num_units_in_focus() == 0) {
    return;
  }

  no_player_cities = !(city_list_size(client.conn.playing->cities));

  original_tile = get_center_tile_mapcanvas();
  
  XtSetSensitive(main_form, FALSE);
  
  goto_dialog_shell =
    I_T(XtCreatePopupShell("gotodialog", transientShellWidgetClass,
			   toplevel, NULL, 0));

  goto_form = XtVaCreateManagedWidget("gotoform", 
				      formWidgetClass, 
				      goto_dialog_shell, NULL);

  goto_label =
    I_L(XtVaCreateManagedWidget("gotolabel", labelWidgetClass, 
				goto_form, NULL));

  goto_viewport = XtVaCreateManagedWidget("gotoviewport", 
				      viewportWidgetClass, 
				      goto_form, 
				      NULL);

  goto_list = XtVaCreateManagedWidget("gotolist", 
				      listWidgetClass, 
				      goto_viewport, 
				      XtNlist, 
				      (XtArgVal)dummy_city_list,
				      NULL);

  goto_center_command =
    I_L(XtVaCreateManagedWidget("gotocentercommand", commandWidgetClass,
				goto_form, NULL));

  goto_airlift_command =
    I_L(XtVaCreateManagedWidget("gotoairliftcommand", commandWidgetClass,
				goto_form, NULL));

  goto_all_toggle =
    I_L(XtVaCreateManagedWidget("gotoalltoggle", toggleWidgetClass,
				goto_form,
				XtNstate, no_player_cities,
				XtNsensitive, !no_player_cities,
				NULL));

  goto_cancel_command =
    I_L(XtVaCreateManagedWidget("gotocancelcommand", commandWidgetClass,
				goto_form, NULL));

  XtAddCallback(goto_list, XtNcallback, goto_list_callback, NULL);
  XtAddCallback(goto_center_command, XtNcallback, 
		goto_goto_command_callback, NULL);
  XtAddCallback(goto_airlift_command, XtNcallback, 
		goto_airlift_command_callback, NULL);
  XtAddCallback(goto_all_toggle, XtNcallback,
		goto_all_toggle_callback, NULL);
  XtAddCallback(goto_cancel_command, XtNcallback, 
		goto_cancel_command_callback, NULL);

  XtRealizeWidget(goto_dialog_shell);

  update_goto_dialog(goto_list);

  XtVaGetValues(toplevel, XtNwidth, &width, XtNheight, &height, NULL);

  XtTranslateCoords(toplevel, (Position) width/10, (Position) height/10,
		    &x, &y);
  XtVaSetValues(goto_dialog_shell, XtNx, x, XtNy, y, NULL);

  XtPopup(goto_dialog_shell, XtGrabNone);

  /* force refresh of viewport so the scrollbar is added.
   * Buggy sun athena requires this */
  XtVaSetValues(goto_viewport, XtNforceBars, True, NULL);
}
Example #10
0
/****************************************************************
  Create rates dialog
*****************************************************************/
static GtkWidget *create_rates_dialog(void)
{
  GtkWidget     *shell, *content;
  GtkWidget	*frame, *hgrid;
  int i;

  if (!can_client_issue_orders()) {
    return NULL;
  }
  
  shell = gtk_dialog_new_with_buttons(_("Select tax, luxury and science rates"),
  	NULL,
	0,
	GTK_STOCK_CANCEL,
	GTK_RESPONSE_CANCEL,
	GTK_STOCK_OK,
	GTK_RESPONSE_OK,
	NULL);
  setup_dialog(shell, toplevel);
  gtk_dialog_set_default_response(GTK_DIALOG(shell), GTK_RESPONSE_OK);
  gtk_window_set_position(GTK_WINDOW(shell), GTK_WIN_POS_MOUSE);
  content = gtk_dialog_get_content_area(GTK_DIALOG(shell));

  rates_gov_label = gtk_label_new("");
  gtk_box_pack_start( GTK_BOX( content ), rates_gov_label, TRUE, TRUE, 5 );

  frame = gtk_frame_new( _("Tax") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_tax_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_tax_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_tax_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_tax_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_tax_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_tax_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_scale);

  rates_tax_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_label);
  gtk_widget_set_size_request(rates_tax_label, 40, -1);

  rates_tax_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_tax_toggle);

  frame = gtk_frame_new( _("Luxury") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_lux_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_lux_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_lux_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_lux_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_lux_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_lux_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_scale);

  rates_lux_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_label);
  gtk_widget_set_size_request(rates_lux_label, 40, -1);

  rates_lux_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_lux_toggle);

  frame = gtk_frame_new( _("Science") );
  gtk_box_pack_start( GTK_BOX( content ), frame, TRUE, TRUE, 5 );

  hgrid = gtk_grid_new();
  gtk_grid_set_column_spacing(GTK_GRID(hgrid), 10);
  gtk_container_add(GTK_CONTAINER(frame), hgrid);

  rates_sci_scale =
    gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 10, 1);
  gtk_range_set_increments(GTK_RANGE(rates_sci_scale), 1, 1);
  for (i = 0; i <= 10; i++) {
    gtk_scale_add_mark(GTK_SCALE(rates_sci_scale), i, GTK_POS_TOP, NULL);
  }
  gtk_widget_set_size_request(rates_sci_scale, 300, 40);
  gtk_scale_set_digits(GTK_SCALE(rates_sci_scale), 0);
  gtk_scale_set_draw_value(GTK_SCALE(rates_sci_scale), FALSE);
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_scale);

  rates_sci_label = gtk_label_new("  0%");
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_label);
  gtk_widget_set_size_request(rates_sci_label, 40, -1);

  rates_sci_toggle = gtk_check_button_new_with_label( _("Lock") );
  gtk_container_add(GTK_CONTAINER(hgrid), rates_sci_toggle);


  g_signal_connect(shell, "response",
		   G_CALLBACK(rates_command_callback), NULL);
  g_signal_connect(shell, "destroy",
		   G_CALLBACK(gtk_widget_destroyed), &rates_dialog_shell);

  gtk_widget_show_all(content);
  gtk_widget_show_all(gtk_dialog_get_action_area(GTK_DIALOG(shell)));

  rates_tax_value=-1;
  rates_lux_value=-1;
  rates_sci_value=-1;

  rates_tax_sig =
    g_signal_connect_after(rates_tax_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_lux_sig =
    g_signal_connect_after(rates_lux_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_sci_sig =
    g_signal_connect_after(rates_sci_scale, "value-changed",
			   G_CALLBACK(rates_changed_callback), NULL);

  rates_set_values(client.conn.playing->economic.tax, 0,
		   client.conn.playing->economic.luxury, 0,
		   client.conn.playing->economic.science, 0);
  return shell;
}
Example #11
0
/**************************************************************************
...
**************************************************************************/
void rates_set_values(int tax, int no_tax_scroll, 
		      int lux, int no_lux_scroll,
		      int sci, int no_sci_scroll)
{
  char buf[64];
  Boolean tax_lock, lux_lock, sci_lock;
  int maxrate;
  
  if (!can_client_issue_orders()) {
    return;
  }

  XtVaGetValues(rates_tax_toggle, XtNstate, &tax_lock, NULL);
  XtVaGetValues(rates_lux_toggle, XtNstate, &lux_lock, NULL);
  XtVaGetValues(rates_sci_toggle, XtNstate, &sci_lock, NULL);
  
  maxrate = get_player_bonus(client.conn.playing, EFT_MAX_RATES);
  /* This's quite a simple-minded "double check".. */
  tax=MIN(tax, maxrate);
  lux=MIN(lux, maxrate);
  sci=MIN(sci, maxrate);
  
  if(tax+sci+lux!=100) {
    if(tax!=rates_tax_value) {
      if(!lux_lock)
	lux=MIN(MAX(100-tax-sci, 0), maxrate);
      if(!sci_lock)
	sci=MIN(MAX(100-tax-lux, 0), maxrate);
    }
    else if(lux!=rates_lux_value) {
      if(!tax_lock)
	tax=MIN(MAX(100-lux-sci, 0), maxrate);
      if(!sci_lock)
	sci=MIN(MAX(100-lux-tax, 0), maxrate);
    }
    else if(sci!=rates_sci_value) {
      if(!lux_lock)
	lux=MIN(MAX(100-tax-sci, 0), maxrate);
      if(!tax_lock)
	tax=MIN(MAX(100-lux-sci, 0), maxrate);
    }
    
    if(tax+sci+lux!=100) {
      lux=rates_lux_value;
      sci=rates_sci_value;
      tax=rates_tax_value;
      rates_tax_value=-1;
      rates_lux_value=-1;
      rates_sci_value=-1;
      no_tax_scroll=0;
      no_lux_scroll=0;
      no_sci_scroll=0;
    }

  }
  
  if(tax!=rates_tax_value) {
    my_snprintf(buf, sizeof(buf), _("Tax: %d%%"), tax);
    xaw_set_label(rates_tax_label, buf);
    if(!no_tax_scroll)
      XawScrollbarSetThumb(rates_tax_scroll, (tax/10)*1/11.0f, 1/11.0f);
    rates_tax_value=tax;
  }

  if(lux!=rates_lux_value) {
    my_snprintf(buf, sizeof(buf), _("Luxury: %d%%"), lux);
    xaw_set_label(rates_lux_label, buf);
    if(!no_lux_scroll)
      XawScrollbarSetThumb(rates_lux_scroll, (lux/10)*1/11.0f, 1/11.0f);
    rates_lux_value=lux;
  }

  if(sci!=rates_sci_value) {
    my_snprintf(buf, sizeof(buf), _("Science: %d%%"), sci);
    xaw_set_label(rates_sci_label, buf);
    if(!no_sci_scroll)
      XawScrollbarSetThumb(rates_sci_scroll, (sci/10)*1/11.0f, 1/11.0f);
    rates_sci_value=sci;
  }
  
}
Example #12
0
/****************************************************************
...
*****************************************************************/
void create_rates_dialog(void)
{
  Widget rates_form;
  Widget rates_ok_command, rates_cancel_command;
  
  if (!can_client_issue_orders()) {
    return;
  }

  rates_dialog_shell =
    I_T(XtCreatePopupShell("ratespopup", transientShellWidgetClass,
			   toplevel, NULL, 0));

  rates_form = XtVaCreateManagedWidget("ratesform", 
				       formWidgetClass, 
				       rates_dialog_shell, NULL);   

  I_L(XtVaCreateManagedWidget("rateslabel", labelWidgetClass, 
			      rates_form, NULL));   

  rates_gov_label = XtVaCreateManagedWidget("ratesgovlabel",
					    labelWidgetClass,
					    rates_form, NULL);
  
  rates_tax_label = XtVaCreateManagedWidget("ratestaxlabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_tax_scroll = XtVaCreateManagedWidget("ratestaxscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);

  rates_tax_toggle = I_L(XtVaCreateManagedWidget("ratestaxtoggle", 
						 toggleWidgetClass, 
						 rates_form,
						 NULL));
    
  rates_lux_label = XtVaCreateManagedWidget("ratesluxlabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_lux_scroll = XtVaCreateManagedWidget("ratesluxscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);

  rates_lux_toggle = I_L(XtVaCreateManagedWidget("ratesluxtoggle", 
						 toggleWidgetClass, 
						 rates_form,
						 NULL));
  
  rates_sci_label = XtVaCreateManagedWidget("ratesscilabel", 
					    labelWidgetClass, 
					    rates_form, NULL);

  rates_sci_scroll = XtVaCreateManagedWidget("ratessciscroll", 
					     scrollbarWidgetClass, 
					     rates_form,
					     NULL);
  
  rates_sci_toggle = I_L(XtVaCreateManagedWidget("ratesscitoggle", 
						 toggleWidgetClass, 
						 rates_form,
						 NULL));
  
  rates_ok_command = I_L(XtVaCreateManagedWidget("ratesokcommand", 
						 commandWidgetClass,
						 rates_form,
						 NULL));

  rates_cancel_command = I_L(XtVaCreateManagedWidget("ratescancelcommand", 
						     commandWidgetClass,
						     rates_form,
						     NULL));

  XtAddCallback(rates_ok_command, XtNcallback, 
		rates_ok_command_callback, NULL);
  XtAddCallback(rates_cancel_command, XtNcallback, 
		rates_cancel_command_callback, NULL);

  XtAddCallback(rates_tax_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_tax_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  
  XtAddCallback(rates_lux_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_lux_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  
  XtAddCallback(rates_sci_scroll, XtNjumpProc, 
		rates_scroll_jump_callback, NULL);
  XtAddCallback(rates_sci_scroll, XtNscrollProc,
		rates_scroll_scroll_callback, NULL);

  XtRealizeWidget(rates_dialog_shell);

  
  rates_tax_value=-1;
  rates_lux_value=-1;
  rates_sci_value=-1;
  
  rates_set_values(client.conn.playing->economic.tax, 0,
		   client.conn.playing->economic.luxury, 0,
		   client.conn.playing->economic.science, 0);
}
Example #13
0
/****************************************************************
  Refresh worklist info
*****************************************************************/
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;
  struct item items[MAX_NUM_PRODUCTION_TARGETS];
  bool selected;
  gint id;
  GtkTreeIter it;
  GtkTreePath *path;
  GtkTreeModel *model;
  gboolean exists;

  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);
    selected = TRUE;
  } else {
    selected = FALSE;
  }
  gtk_list_store_clear(ptr->src);

  targets_used = collect_eventually_buildable_targets(targets, ptr->pcity,
                                                      ptr->future);
  name_and_sort_items(targets, targets_used, items, FALSE, ptr->pcity);

  path = NULL;
  for (i = 0; i < targets_used; i++) {
    gtk_list_store_append(ptr->src, &it);
    gtk_list_store_set(ptr->src, &it, 0, (gint) cid_encode(items[i].item), -1);

    if (selected && cid_encode(items[i].item) == id) {
      path = gtk_tree_model_get_path(GTK_TREE_MODEL(ptr->src), &it);
    }
  }
  if (path) {
    gtk_tree_view_set_cursor(GTK_TREE_VIEW(ptr->src_view), path, NULL, FALSE);
    gtk_tree_path_free(path);
  }


  /* refresh target worklist. */
  model = GTK_TREE_MODEL(ptr->dst);
  exists = gtk_tree_model_get_iter_first(model, &it);

  /* dance around worklist braindamage. */
  if (ptr->pcity) {
    city_get_queue(ptr->pcity, &queue);
  } else {
    fc_assert(NULL != pgwl);
    worklist_copy(&queue, global_worklist_get(pgwl));
  }

  for (i = 0; i < worklist_length(&queue); i++) {
    struct universal target = queue.entries[i];

    if (!exists) {
      gtk_list_store_append(ptr->dst, &it);
    }

    gtk_list_store_set(ptr->dst, &it, 0, (gint) cid_encode(target), -1);

    if (exists) {
      exists = gtk_tree_model_iter_next(model, &it);
    }
  }

  if (exists) {
    GtkTreeIter it_next;
    bool more;

    do {
      it_next = it;
      more = gtk_tree_model_iter_next(model, &it_next);

      gtk_list_store_remove(ptr->dst, &it);
      it = it_next;
    } while (more);
  }

  /* update widget sensitivity. */
  if (ptr->pcity) {
    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 {
      gtk_widget_set_sensitive(ptr->add_cmd, FALSE);
      gtk_widget_set_sensitive(ptr->dst_view, FALSE);
    }
  } else {
    gtk_widget_set_sensitive(ptr->add_cmd, TRUE);
    gtk_widget_set_sensitive(ptr->dst_view, TRUE);
  }
}