94 GtkWidget *label, *button, *vgrid, *hgrid;
96 const int BUTTON_HEIGHT = 12;
103 hgrid = gtk_grid_new();
104 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4);
105 g_object_set_data(G_OBJECT(hgrid),
"voteinfo_bar", vib);
110 vgrid = gtk_grid_new();
111 gtk_grid_set_row_homogeneous(GTK_GRID(vgrid),
TRUE);
112 gtk_orientable_set_orientation(GTK_ORIENTABLE(vgrid),
113 GTK_ORIENTATION_VERTICAL);
114 gtk_grid_set_row_spacing(GTK_GRID(vgrid), 4);
115 g_object_set_data(G_OBJECT(vgrid),
"voteinfo_bar", vib);
118 hgrid = gtk_grid_new();
119 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4);
120 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
123 label = gtk_label_new(
"");
125 gtk_widget_set_halign(
label, GTK_ALIGN_START);
126 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
127 gtk_widget_set_margin_start(
label, 8);
128 gtk_widget_set_margin_end(
label, 8);
129 gtk_widget_set_margin_top(
label, 4);
130 gtk_widget_set_margin_bottom(
label, 4);
131 gtk_label_set_max_width_chars(GTK_LABEL(
label), 80);
132 gtk_grid_attach(GTK_GRID(hgrid),
label, grid_col++, 0, 1, 1);
133 gtk_widget_set_name(
label,
"vote label");
137 hgrid = gtk_grid_new();
139 gtk_grid_set_column_spacing(GTK_GRID(hgrid), 4);
140 gtk_grid_attach(GTK_GRID(vgrid), hgrid, 0, grid_row++, 1, 1);
143 button = gtk_button_new();
144 gtk_widget_set_margin_end(button, 16);
145 g_signal_connect(button,
"clicked",
147 gtk_button_set_icon_name(GTK_BUTTON(button),
"media-seek-backward");
148 gtk_widget_set_size_request(button, -1, BUTTON_HEIGHT);
149 gtk_button_set_has_frame(GTK_BUTTON(button),
FALSE);
150 gtk_widget_set_focus_on_click(button,
FALSE);
151 gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1);
154 button = gtk_button_new_with_mnemonic(
_(
"_YES"));
155 g_signal_connect(button,
"clicked",
158 gtk_widget_set_focus_on_click(button,
FALSE);
159 gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1);
160 gtk_widget_set_name(button,
"vote yes button");
163 label = gtk_label_new(
"0");
164 gtk_widget_set_halign(
label, GTK_ALIGN_START);
165 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
166 gtk_grid_attach(GTK_GRID(hgrid),
label, grid_col++, 0, 1, 1);
169 button = gtk_button_new_with_mnemonic(
_(
"_NO"));
170 g_signal_connect(button,
"clicked",
173 gtk_widget_set_focus_on_click(button,
FALSE);
174 gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1);
175 gtk_widget_set_name(button,
"vote no button");
178 label = gtk_label_new(
"0");
179 gtk_widget_set_halign(
label, GTK_ALIGN_START);
180 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
181 gtk_grid_attach(GTK_GRID(hgrid),
label, grid_col++, 0, 1, 1);
184 button = gtk_button_new_with_mnemonic(
_(
"_ABSTAIN"));
185 g_signal_connect(button,
"clicked",
188 gtk_widget_set_focus_on_click(button,
FALSE);
189 gtk_grid_attach(GTK_GRID(hgrid), button, grid_col++, 0, 1, 1);
190 gtk_widget_set_name(button,
"vote abstain button");
193 label = gtk_label_new(
"0");
194 gtk_widget_set_halign(
label, GTK_ALIGN_START);
195 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
196 gtk_grid_attach(GTK_GRID(hgrid),
label, grid_col++, 0, 1, 1);
199 label = gtk_label_new(
"/0");
200 gtk_widget_set_halign(
label, GTK_ALIGN_START);
201 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
202 gtk_grid_attach(GTK_GRID(hgrid),
label, grid_col++, 0, 1, 1);
214 int vote_count, index;
217 char buf[1024], status[1024], ordstr[128],
color[32];
218 bool running, need_scroll;
219 gchar *escaped_desc, *escaped_user;
224 vib = g_object_get_data(G_OBJECT(
ingame_votebar),
"voteinfo_bar");
232 gtk_widget_hide(vib->
box);
255 if (vote_count > 1) {
257 "<span weight=\"bold\">(%d/%d)</span> ",
258 index + 1, vote_count);
263 if (status[0] !=
'\0') {
265 "<span weight=\"bold\" background=\"%s\">%s</span> ",
271 escaped_desc = g_markup_escape_text(vi->
desc, -1);
272 escaped_user = g_markup_escape_text(vi->
user, -1);
274 fc_snprintf(buf,
sizeof(buf),
_(
"%sVote %d by %s: %s%s"),
275 ordstr, vi->
vote_no, escaped_user, status,
277 g_free(escaped_desc);
278 g_free(escaped_user);
282 gtk_label_set_markup(GTK_LABEL(vib->
label), buf);
302 gtk_widget_set_sensitive(vib->
yes_button, running);
303 gtk_widget_set_sensitive(vib->
no_button, running);
306 need_scroll = !gtk_widget_get_visible(vib->
box)
309 gtk_widget_show(vib->
box);
311 if (vote_count <= 1) {
enum client_pages get_client_page(void)