]> www.fi.muni.cz Git - evince.git/blobdiff - properties/ev-properties-view.c
Fix bug #570054
[evince.git] / properties / ev-properties-view.c
index 65f29d115162b87f180c710908ebf16a191b024b..9a9d13c0d7ab624da2c901fc601a864a262ec8ea 100644 (file)
 #include <langinfo.h>
 #endif
 
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 
 #include "ev-properties-view.h"
 
 typedef enum {
        TITLE_PROPERTY,
+       URI_PROPERTY,
        SUBJECT_PROPERTY,
        AUTHOR_PROPERTY,
        KEYWORDS_PROPERTY,
@@ -55,25 +56,27 @@ typedef struct {
 } PropertyInfo;
 
 static const PropertyInfo properties_info[] = {
-       { TITLE_PROPERTY,         N_("Title") },
-       { SUBJECT_PROPERTY,       N_("Subject") },
-       { AUTHOR_PROPERTY,        N_("Author") },
-       { KEYWORDS_PROPERTY,      N_("Keywords") },
-       { PRODUCER_PROPERTY,      N_("Producer") },
-       { CREATOR_PROPERTY,       N_("Creator") },
-       { CREATION_DATE_PROPERTY, N_("Created") },
-       { MOD_DATE_PROPERTY,      N_("Modified") },
-       { N_PAGES_PROPERTY,       N_("Number of Pages") },
-       { LINEARIZED_PROPERTY,    N_("Optimized") },
-       { FORMAT_PROPERTY,        N_("Format") },
-       { SECURITY_PROPERTY,      N_("Security") },
-       { PAPER_SIZE_PROPERTY,    N_("Paper Size") }
+       { TITLE_PROPERTY,         N_("Title:") },
+       { URI_PROPERTY,           N_("Location:") },
+       { SUBJECT_PROPERTY,       N_("Subject:") },
+       { AUTHOR_PROPERTY,        N_("Author:") },
+       { KEYWORDS_PROPERTY,      N_("Keywords:") },
+       { PRODUCER_PROPERTY,      N_("Producer:") },
+       { CREATOR_PROPERTY,       N_("Creator:") },
+       { CREATION_DATE_PROPERTY, N_("Created:") },
+       { MOD_DATE_PROPERTY,      N_("Modified:") },
+       { N_PAGES_PROPERTY,       N_("Number of Pages:") },
+       { LINEARIZED_PROPERTY,    N_("Optimized:") },
+       { FORMAT_PROPERTY,        N_("Format:") },
+       { SECURITY_PROPERTY,      N_("Security:") },
+       { PAPER_SIZE_PROPERTY,    N_("Paper Size:") }
 };
 
 struct _EvPropertiesView {
        GtkVBox base_instance;
 
        GtkWidget *table;
+       gchar     *uri;
 };
 
 struct _EvPropertiesViewClass {
@@ -82,9 +85,25 @@ struct _EvPropertiesViewClass {
 
 G_DEFINE_TYPE (EvPropertiesView, ev_properties_view, GTK_TYPE_VBOX)
 
+static void
+ev_properties_view_dispose (GObject *object)
+{
+       EvPropertiesView *properties = EV_PROPERTIES_VIEW (object);
+       
+       if (properties->uri) {
+               g_free (properties->uri);
+               properties->uri = NULL;
+       }
+       
+       G_OBJECT_CLASS (ev_properties_view_parent_class)->dispose (object);
+}
+
 static void
 ev_properties_view_class_init (EvPropertiesViewClass *properties_class)
 {
+       GObjectClass *g_object_class = G_OBJECT_CLASS (properties_class);
+
+       g_object_class->dispose = ev_properties_view_dispose;
 }
 
 /* Returns a locale specific date and time representation */
@@ -92,14 +111,19 @@ static char *
 ev_properties_view_format_date (GTime utime)
 {
        time_t time = (time_t) utime;
-       struct tm t;
        char s[256];
-       const char *fmt_hack = "%c";
+       const char fmt_hack[] = "%c";
        size_t len;
-
+#ifdef HAVE_LOCALTIME_R
+       struct tm t;
        if (time == 0 || !localtime_r (&time, &t)) return NULL;
-
        len = strftime (s, sizeof (s), fmt_hack, &t);
+#else
+       struct tm *t;
+       if (time == 0 || !(t = localtime (&time)) ) return NULL;
+       len = strftime (s, sizeof (s), fmt_hack, t);
+#endif
+
        if (len == 0 || s[0] == '\0') return NULL;
 
        return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);
@@ -157,7 +181,7 @@ set_property (GtkTable    *table,
 
        label = gtk_label_new (NULL);
        g_object_set (G_OBJECT (label), "xalign", 0.0, NULL);
-       markup = g_strdup_printf ("<b>%s:</b>", properties_info[property].label);
+       markup = g_strdup_printf ("<b>%s</b>", _(properties_info[property].label));
        gtk_label_set_markup (GTK_LABEL (label), markup);
        g_free (markup);
        
@@ -304,10 +328,11 @@ ev_properties_view_set_info (EvPropertiesView *properties, const EvDocumentInfo
        gint       row = 0;
 
        table = properties->table;
-       
+
        if (info->fields_mask & EV_DOCUMENT_INFO_TITLE) {
                set_property (GTK_TABLE (table), TITLE_PROPERTY, info->title, &row);
        }
+       set_property (GTK_TABLE (table), URI_PROPERTY, properties->uri, &row);
        if (info->fields_mask & EV_DOCUMENT_INFO_SUBJECT) {
                set_property (GTK_TABLE (table), SUBJECT_PROPERTY, info->subject, &row);
        }
@@ -373,11 +398,12 @@ ev_properties_view_register_type (GTypeModule *module)
 }
 
 GtkWidget *
-ev_properties_view_new (void)
+ev_properties_view_new (const gchar *uri)
 {
        EvPropertiesView *properties;
 
        properties = g_object_new (EV_TYPE_PROPERTIES, NULL);
+       properties->uri = g_strdup (uri);
 
        return GTK_WIDGET (properties);
 }