94 GtkWidget *label, *button, *vbox, *hbox, *arrow;
96 const int BUTTON_HEIGHT = 12;
101 hbox = gtk_grid_new();
102 gtk_grid_set_column_spacing(GTK_GRID(hbox), 4);
103 g_object_set_data(G_OBJECT(hbox),
"voteinfo_bar", vib);
108 vbox = gtk_grid_new();
109 gtk_grid_set_row_homogeneous(GTK_GRID(vbox),
TRUE);
110 gtk_orientable_set_orientation(GTK_ORIENTABLE(vbox),
111 GTK_ORIENTATION_VERTICAL);
112 gtk_grid_set_row_spacing(GTK_GRID(vbox), 4);
113 g_object_set_data(G_OBJECT(vbox),
"voteinfo_bar", vib);
116 hbox = gtk_grid_new();
117 gtk_grid_set_column_spacing(GTK_GRID(hbox), 4);
118 gtk_container_add(GTK_CONTAINER(vbox), hbox);
121 label = gtk_label_new(
"");
123 gtk_widget_set_halign(
label, GTK_ALIGN_START);
124 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
125 gtk_widget_set_margin_start(
label, 8);
126 gtk_widget_set_margin_end(
label, 8);
127 gtk_widget_set_margin_top(
label, 4);
128 gtk_widget_set_margin_bottom(
label, 4);
129 gtk_label_set_max_width_chars(GTK_LABEL(
label), 80);
130 gtk_container_add(GTK_CONTAINER(hbox),
label);
131 gtk_widget_set_name(
label,
"vote label");
134 arrow = gtk_image_new_from_icon_name(
"media-seek-backward",
135 GTK_ICON_SIZE_SMALL_TOOLBAR);
136 gtk_widget_set_halign(arrow, GTK_ALIGN_CENTER);
137 gtk_widget_set_valign(arrow, GTK_ALIGN_START);
140 hbox = gtk_grid_new();
141 gtk_grid_set_column_spacing(GTK_GRID(hbox), 4);
142 gtk_container_add(GTK_CONTAINER(vbox), hbox);
145 button = gtk_button_new();
146 gtk_widget_set_margin_end(button, 16);
147 g_signal_connect(button,
"clicked",
149 gtk_button_set_image(GTK_BUTTON(button), arrow);
150 gtk_widget_set_size_request(button, -1, BUTTON_HEIGHT);
151 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
152 gtk_widget_set_focus_on_click(button,
FALSE);
153 gtk_container_add(GTK_CONTAINER(hbox), button);
156 button = gtk_button_new_with_mnemonic(
_(
"_YES"));
157 g_signal_connect(button,
"clicked",
160 gtk_widget_set_focus_on_click(button,
FALSE);
161 gtk_container_add(GTK_CONTAINER(hbox), button);
162 gtk_widget_set_name(button,
"vote yes button");
165 label = gtk_label_new(
"0");
166 gtk_widget_set_halign(
label, GTK_ALIGN_START);
167 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
168 gtk_container_add(GTK_CONTAINER(hbox),
label);
171 button = gtk_button_new_with_mnemonic(
_(
"_NO"));
172 g_signal_connect(button,
"clicked",
175 gtk_widget_set_focus_on_click(button,
FALSE);
176 gtk_container_add(GTK_CONTAINER(hbox), button);
177 gtk_widget_set_name(button,
"vote no button");
180 label = gtk_label_new(
"0");
181 gtk_widget_set_halign(
label, GTK_ALIGN_START);
182 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
183 gtk_container_add(GTK_CONTAINER(hbox),
label);
186 button = gtk_button_new_with_mnemonic(
_(
"_ABSTAIN"));
187 g_signal_connect(button,
"clicked",
190 gtk_widget_set_focus_on_click(button,
FALSE);
191 gtk_container_add(GTK_CONTAINER(hbox), button);
192 gtk_widget_set_name(button,
"vote abstain button");
195 label = gtk_label_new(
"0");
196 gtk_widget_set_halign(
label, GTK_ALIGN_START);
197 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
198 gtk_container_add(GTK_CONTAINER(hbox),
label);
201 label = gtk_label_new(
"/0");
202 gtk_widget_set_halign(
label, GTK_ALIGN_START);
203 gtk_widget_set_valign(
label, GTK_ALIGN_CENTER);
204 gtk_container_add(GTK_CONTAINER(hbox),
label);
216 int vote_count, index;
219 char buf[1024], status[1024], ordstr[128],
color[32];
220 bool running, need_scroll;
221 gchar *escaped_desc, *escaped_user;
226 vib = g_object_get_data(G_OBJECT(
ingame_votebar),
"voteinfo_bar");
234 gtk_widget_hide(vib->
box);
257 if (vote_count > 1) {
259 "<span weight=\"bold\">(%d/%d)</span> ",
260 index + 1, vote_count);
265 if (status[0] !=
'\0') {
267 "<span weight=\"bold\" background=\"%s\">%s</span> ",
273 escaped_desc = g_markup_escape_text(vi->
desc, -1);
274 escaped_user = g_markup_escape_text(vi->
user, -1);
276 fc_snprintf(buf,
sizeof(buf),
_(
"%sVote %d by %s: %s%s"),
277 ordstr, vi->
vote_no, escaped_user, status,
279 g_free(escaped_desc);
280 g_free(escaped_user);
284 gtk_label_set_markup(GTK_LABEL(vib->
label), buf);
304 gtk_widget_set_sensitive(vib->
yes_button, running);
305 gtk_widget_set_sensitive(vib->
no_button, running);
308 need_scroll = !gtk_widget_get_visible(vib->
box)
311 gtk_widget_show_all(vib->
box);
313 if (vote_count <= 1) {
enum client_pages get_client_page(void)