27 #ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
31 #include <glib/gi18n-lib.h>
98 if (properties->uri) {
99 g_free (properties->uri);
100 properties->uri = NULL;
103 G_OBJECT_CLASS (ev_properties_view_parent_class)->dispose (
object);
109 GObjectClass *g_object_class = G_OBJECT_CLASS (properties_class);
121 const gchar *remainder, *invalid;
122 gint remaining_bytes, valid_bytes;
126 remaining_bytes = strlen (name);
128 while (remaining_bytes != 0)
130 if (g_utf8_validate (remainder, remaining_bytes, &invalid))
132 valid_bytes = invalid - remainder;
135 string = g_string_sized_new (remaining_bytes);
137 g_string_append_len (
string, remainder, valid_bytes);
138 g_string_append_c (
string,
'?');
140 remaining_bytes -= valid_bytes + 1;
141 remainder = invalid + 1;
145 return g_strdup (name);
147 g_string_append (
string, remainder);
149 g_assert (g_utf8_validate (string->str, -1, NULL));
151 return g_string_free (
string,
FALSE);
161 GtkWidget *property_label = NULL;
162 GtkWidget *value_label = NULL;
166 if (!properties->labels[property]) {
167 property_label = gtk_label_new (NULL);
168 g_object_set (G_OBJECT (property_label),
"xalign", 0.0, NULL);
169 markup = g_strdup_printf (
"<b>%s</b>",
_(properties_info[property].
label));
170 gtk_label_set_markup (GTK_LABEL (property_label), markup);
173 gtk_grid_attach (grid, property_label, 0, *row, 1, 1);
174 gtk_widget_show (property_label);
177 if (!properties->labels[property]) {
178 value_label = gtk_label_new (NULL);
180 g_object_set (G_OBJECT (value_label),
184 "ellipsize", PANGO_ELLIPSIZE_END,
187 value_label = properties->labels[property];
190 if (text == NULL || text[0] ==
'\000') {
196 markup = g_markup_printf_escaped (
"<i>%s</i>",
_(
"None"));
197 gtk_label_set_markup (GTK_LABEL (value_label), markup);
201 gtk_label_set_text (GTK_LABEL (value_label), valid_text);
205 if (!properties->labels[property]) {
206 gtk_grid_attach (grid, value_label, 1, *row, 1, 1);
207 properties->labels[property] = value_label;
210 if (property_label && value_label) {
211 atk_object_add_relationship (gtk_widget_get_accessible (property_label),
212 ATK_RELATION_LABEL_FOR,
213 gtk_widget_get_accessible (value_label));
214 atk_object_add_relationship (gtk_widget_get_accessible (value_label),
215 ATK_RELATION_LABELLED_BY,
216 gtk_widget_get_accessible (property_label));
219 gtk_widget_show (value_label);
233 gchar *e =
_(
"default:mm");
235 #ifdef HAVE__NL_MEASUREMENT_MEASUREMENT
236 gchar *imperial = NULL;
238 imperial = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
239 if (imperial && imperial[0] == 2)
240 return GTK_UNIT_INCH;
241 if (imperial && imperial[0] == 1)
245 if (strcmp (e,
"default:mm") == 0)
247 if (strcmp (e,
"default:inch") == 0)
248 return GTK_UNIT_INCH;
250 g_warning (
"Whoever translated default:mm did so wrongly.\n");
260 else if (size >= 150.0f && size <= 600.0f)
269 GList *paper_sizes, *l;
276 if (units == GTK_UNIT_MM) {
277 exact_size = g_strdup_printf(
_(
"%.0f × %.0f mm"),
281 exact_size = g_strdup_printf (
_(
"%.2f × %.2f inch"),
282 info->paper_width / 25.4f,
283 info->paper_height / 25.4f);
286 paper_sizes = gtk_paper_size_get_paper_sizes (
FALSE);
288 for (l = paper_sizes; l && l->data; l = g_list_next (l)) {
289 GtkPaperSize *
size = (GtkPaperSize *) l->data;
291 gdouble paper_height;
292 gdouble width_tolerance;
293 gdouble height_tolerance;
295 paper_width = gtk_paper_size_get_width (size, GTK_UNIT_MM);
296 paper_height = gtk_paper_size_get_height (size, GTK_UNIT_MM);
301 if (ABS (info->paper_height - paper_height) <= height_tolerance &&
302 ABS (info->paper_width - paper_width) <= width_tolerance) {
305 str = g_strdup_printf (
_(
"%s, Portrait (%s)"),
306 gtk_paper_size_get_display_name (size),
308 }
else if (ABS (info->paper_width - paper_height) <= height_tolerance &&
309 ABS (info->paper_height - paper_width) <= width_tolerance) {
312 str = g_strdup_printf (
_(
"%s, Landscape (%s)"),
313 gtk_paper_size_get_display_name (size),
318 g_list_foreach (paper_sizes, (GFunc) gtk_paper_size_free, NULL);
319 g_list_free (paper_sizes);
336 grid = properties->grid;
371 text = g_strdup_printf (
"%d", info->n_pages);
386 if (properties->file_size) {
387 text = g_format_size (properties->file_size);
396 properties->grid = gtk_grid_new ();
397 gtk_grid_set_column_spacing (GTK_GRID (properties->grid), 12);
398 gtk_grid_set_row_spacing (GTK_GRID (properties->grid), 6);
399 gtk_container_set_border_width (GTK_CONTAINER (properties->grid), 12);
400 gtk_box_pack_start (GTK_BOX (properties), properties->grid,
TRUE,
TRUE, 0);
401 gtk_widget_show (properties->grid);
416 "orientation", GTK_ORIENTATION_VERTICAL,
421 return GTK_WIDGET (properties);