Author: sveinung Date: Tue Aug 23 04:47:18 2016 New Revision: 33676 URL: http://svn.gna.org/viewcvs/freeciv?rev=33676&view=rev Log: Gtk 3 client: standardize unit selection text.
Standardize on the unit selection dialog's unit description text in unit selection text items. Use it in the transport dialog and in the action selection dialog's unit target switcher. (The last two both use the unit selects unit dialog) This gives them information like home city. This adds information like home city. See patch #7643 Modified: branches/S2_6/client/gui-gtk-3.0/unitselect.c branches/S2_6/client/gui-gtk-3.0/unitselect.h branches/S2_6/client/gui-gtk-3.0/unitselunitdlg.c Modified: branches/S2_6/client/gui-gtk-3.0/unitselect.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/unitselect.c?rev=33676&r1=33675&r2=33676&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-3.0/unitselect.c (original) +++ branches/S2_6/client/gui-gtk-3.0/unitselect.c Tue Aug 23 04:47:18 2016 @@ -783,35 +783,15 @@ return out; } -/***************************************************************************** - Append units (recursively). -*****************************************************************************/ -static void usdlg_tab_append_units(struct unit_select_dialog *pdialog, - enum unit_select_location_mode loc, - enum unit_activity act, - const struct unit *punit, - bool transported, GtkTreeIter *it, - GtkTreeIter *parent) -{ - char buf[248] = "", buf2[248] = ""; - GdkPixbuf *pix; +/************************************************************************** + Get an unit selection list item suitable description of the specified + unit. +**************************************************************************/ +const char *usdlg_get_unit_descr(const struct unit *punit) +{ + static char buf[248] = ""; + char buf2[248] = ""; struct city *phome; - enum usdlg_row_types row = ROW_UNIT; - int style = PANGO_STYLE_NORMAL; - int weight = PANGO_WEIGHT_NORMAL; - GtkTreeStore *store; - - fc_assert_ret(pdialog != NULL); - fc_assert_ret(punit != NULL); - - store = pdialog->tabs[loc].store; - - - /* Add this item. */ - gtk_tree_store_append(GTK_TREE_STORE(store), it, parent); - - /* Unit gfx */ - pix = usdlg_get_unit_image(punit); phome = game_city_by_number(punit->homecity); if (phome) { @@ -843,6 +823,40 @@ buf2); #endif /* FREECIV_DEBUG */ + return buf; +} + +/***************************************************************************** + Append units (recursively). +*****************************************************************************/ +static void usdlg_tab_append_units(struct unit_select_dialog *pdialog, + enum unit_select_location_mode loc, + enum unit_activity act, + const struct unit *punit, + bool transported, GtkTreeIter *it, + GtkTreeIter *parent) +{ + const char *text; + GdkPixbuf *pix; + enum usdlg_row_types row = ROW_UNIT; + int style = PANGO_STYLE_NORMAL; + int weight = PANGO_WEIGHT_NORMAL; + GtkTreeStore *store; + + fc_assert_ret(pdialog != NULL); + fc_assert_ret(punit != NULL); + + store = pdialog->tabs[loc].store; + + + /* Add this item. */ + gtk_tree_store_append(GTK_TREE_STORE(store), it, parent); + + /* Unit gfx */ + pix = usdlg_get_unit_image(punit); + + text = usdlg_get_unit_descr(punit); + if (transported) { weight = PANGO_WEIGHT_NORMAL; style = PANGO_STYLE_ITALIC; @@ -852,7 +866,7 @@ /* Add it to the tree. */ gtk_tree_store_set(GTK_TREE_STORE(store), it, 0, pix, /* Unit pixmap */ - 1, buf, /* Text */ + 1, text, /* Text */ 2, 1, /* Number of units */ 3, utype_index(unit_type_get(punit)), /* Unit type ID */ 4, punit->id, /* Unit ID */ Modified: branches/S2_6/client/gui-gtk-3.0/unitselect.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/unitselect.h?rev=33676&r1=33675&r2=33676&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-3.0/unitselect.h (original) +++ branches/S2_6/client/gui-gtk-3.0/unitselect.h Tue Aug 23 04:47:18 2016 @@ -22,5 +22,6 @@ void unit_select_dialog_popdown(void); GdkPixbuf *usdlg_get_unit_image(const struct unit *punit); +const char *usdlg_get_unit_descr(const struct unit *punit); #endif /* FC__UNITSELECT_H */ Modified: branches/S2_6/client/gui-gtk-3.0/unitselunitdlg.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/unitselunitdlg.c?rev=33676&r1=33675&r2=33676&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-3.0/unitselunitdlg.c (original) +++ branches/S2_6/client/gui-gtk-3.0/unitselunitdlg.c Tue Aug 23 04:47:18 2016 @@ -131,7 +131,6 @@ unit_list_iterate(potential_tgt_units, ptgt) { GdkPixbuf *tubuf; - struct unit_type *tgt_type = unit_type_get(ptgt); struct unit_sel_unit_cb_data *cbdata = fc_malloc(sizeof(struct unit_sel_unit_cb_data)); @@ -158,7 +157,7 @@ } gtk_grid_attach(GTK_GRID(box), icon, 1, tcount, 1, 1); - lbl = gtk_label_new(utype_name_translation(tgt_type)); + lbl = gtk_label_new(usdlg_get_unit_descr(ptgt)); gtk_grid_attach(GTK_GRID(box), lbl, 2, tcount, 1, 1); tcount++; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits