Bug #1605 ยป 1605_gtk322.patch
client/gui-gtk-3.22/helpdlg.c | ||
---|---|---|
gtk_label_new(help_ulabel_name[j][i] ? _(help_ulabel_name[j][i]) : "");
|
||
gtk_widget_set_hexpand(help_ulabel[j][i], TRUE);
|
||
if (j == 4 && (i == 1 || i == 4)) {
|
||
if (i == 1) {
|
||
button = help_hyperlink_new_page(help_ulabel[j][i], HELP_TECH);
|
||
} else {
|
||
if (j == 4 && (i == 1 || i == 2 || i == 4)) {
|
||
if (i == 4) {
|
||
button = help_hyperlink_new_page(help_ulabel[j][i], HELP_UNIT);
|
||
} else {
|
||
button = help_hyperlink_new_page(help_ulabel[j][i], HELP_TECH);
|
||
}
|
||
gtk_grid_attach(GTK_GRID(help_utable), button, i, j, 1, 1);
|
||
... | ... | |
{
|
||
char buf[8192];
|
||
struct unit_type *utype = unit_type_by_translated_name(title);
|
||
int row_num, col_num, req_num;
|
||
GtkWidget *button2, *button;
|
||
GtkWidget *label;
|
||
static int num_rows_in_grid = 5;
|
||
if (utype) {
|
||
sprintf(buf, "%d", utype_build_shield_cost_base(utype));
|
||
... | ... | |
helptext_unit_upkeep_str(utype));
|
||
sprintf(buf, "%d", (int)sqrt((double)utype->vision_radius_sq));
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[3][4]), buf);
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
|
||
advance_name_translation(utype_primary_tech_req(utype)));
|
||
/* requirements */
|
||
/* need to make the 2nd requirement button go away until it's needed */
|
||
button2 = gtk_grid_get_child_at(GTK_GRID(help_utable), 2, 4);
|
||
gtk_widget_set_visible(button2, FALSE);
|
||
/* also make the extra rows (if any) go away for now */
|
||
for (row_num = num_rows_in_grid; row_num >=5; row_num--)
|
||
gtk_grid_remove_row(GTK_GRID(help_utable), row_num);
|
||
num_rows_in_grid = 5;
|
||
/* About memory management - the docs don't say anything
|
||
* about gtk_grid_remove_row(), and say about gtk_grid_attach() that
|
||
* "The data is owned by the caller of the method."
|
||
* The source code for gtk_grid_remove_row() shows it calling
|
||
* gtk_container_remove(), and the doc for that says -
|
||
* "Note that container will own a reference to widget, and that this
|
||
* may be the last reference held; so removing a widget from its container
|
||
* can destroy that widget."
|
||
* I also did some testing that showed the buttons in the removed row
|
||
* are destroyed and not leaked.
|
||
*/
|
||
/* see if any reqs */
|
||
if (utype->build_reqs.size == 0) {
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
|
||
skip_intl_qualifier_prefix(REQ_LABEL_NONE));
|
||
} else {
|
||
row_num = 5;
|
||
col_num = 0;
|
||
req_num = 1;
|
||
// iterate the reqs
|
||
unit_tech_reqs_iterate(utype, padv) {
|
||
switch (req_num++) {
|
||
case 1:
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[4][1]),
|
||
advance_name_translation(padv));
|
||
break;
|
||
case 2:
|
||
/* bring back the 2nd requirement button */
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[4][2]),
|
||
advance_name_translation(padv));
|
||
gtk_widget_set_visible(button2, TRUE);
|
||
break;
|
||
default:
|
||
/* make and add another requirement button */
|
||
label = gtk_label_new(advance_name_translation(padv));
|
||
gtk_widget_set_hexpand(label, TRUE);
|
||
gtk_widget_set_visible(label, TRUE);
|
||
button = help_hyperlink_new_page(label, HELP_TECH);
|
||
gtk_grid_attach(GTK_GRID(help_utable), button, col_num, row_num,
|
||
1, 1);
|
||
if (++col_num == 3) {
|
||
col_num = 0;
|
||
++row_num;
|
||
++num_rows_in_grid;
|
||
}
|
||
break;
|
||
} /* end switch */
|
||
} unit_tech_reqs_iterate_end;
|
||
}
|
||
/* create_tech_tree(help_improvement_tree, 0, advance_number(utype->require_advance), 3);*/
|
||
if (U_NOT_OBSOLETED == utype->obsoleted_by) {
|
||
gtk_label_set_text(GTK_LABEL(help_ulabel[4][4]), skip_intl_qualifier_prefix(REQ_LABEL_NONE));
|