]> www.fi.muni.cz Git - evince.git/commitdiff
Fix document title bugs and fallback to filename when not available.
authorMarco Pesenti Gritti <marco@gnome.org>
Mon, 3 Jan 2005 18:18:57 +0000 (18:18 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 3 Jan 2005 18:18:57 +0000 (18:18 +0000)
2005-01-03  Marco Pesenti Gritti  <marco@gnome.org>

        * backend/ev-document.c: (ev_document_class_init):
        * pdf/xpdf/pdf-document.cc:
        * shell/ev-window.c: (ev_window_open):

        Fix document title bugs and fallback to
        filename when not available.

ChangeLog
backend/ev-document.c
pdf/xpdf/pdf-document.cc
shell/ev-window.c

index 1ce27d45ce2dc6178d51c15e07333844f438052d..cb92d3646a945c16dae2fa51316b2d99fe731505 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-01-03  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * backend/ev-document.c: (ev_document_class_init):
+       * pdf/xpdf/pdf-document.cc:
+       * shell/ev-window.c: (ev_window_open):
+
+       Fix document title bugs and fallback to
+       filename when not available.
+
 2005-01-03  Marco Pesenti Gritti  <marco@gnome.org>
 
        * backend/ev-document.c: (ev_document_get_type),
index a76a555b64e295d9ebc25d1bed28d8fba9a48b0f..e80f95fccf2567a50dd204ce7e824f0ca66c31f3 100644 (file)
@@ -73,7 +73,8 @@ ev_document_class_init (gpointer g_class)
                                g_param_spec_string ("title",
                                                     "Document Title",
                                                     "The title of the document",
-                                                    NULL, 0));
+                                                    NULL,
+                                                    G_PARAM_READABLE));
 }
 
 gboolean
index ede8f77e992309d1743c399a3067f9a50c2cb905..284b3710cefe5392775f2a48927a359ec498de5c 100644 (file)
@@ -928,6 +928,8 @@ pdf_document_get_title (PdfDocument *pdf_document)
        if (info.isDict ()) {
                title = pdf_info_dict_get_string (info.getDict(), "Title");
        }
+
+       return title;
 }
 
 static void
@@ -942,7 +944,7 @@ pdf_document_get_property (GObject *object,
        switch (prop_id)
        {
                case PROP_TITLE:
-                       title = pdf_document_get_title (pdf_document);  
+                       title = pdf_document_get_title (pdf_document);
                        g_value_set_string (value, title);
                        g_free (title);
                        break;
index 19c67342dd016b0d1a40f28cc47e95843cd4176a..a1e86548c70aeeeef44e892d8650d98f72e38edf 100644 (file)
@@ -72,6 +72,7 @@ struct _EvWindowPrivate {
        GtkWidget *statusbar;
        guint help_message_cid;
        GtkWidget *exit_fullscreen_popup;
+       char *uri;
 
        EvDocument *document;
 
@@ -254,12 +255,14 @@ update_window_title (EvDocument *document, GParamSpec *pspec, EvWindow *ev_windo
 {
        char *title = NULL;
 
-       if (document) {
+       if (document == NULL) {
+               title = g_strdup (_("Document Viewer"));
+       } else {
                title = ev_document_get_title (document);
-       }
 
-       if (title == NULL) {
-               title = g_strdup (_("Document Viewer"));
+               if (title == NULL) {
+                       title = g_path_get_basename (ev_window->priv->uri);
+               }
        }
 
        gtk_window_set_title (GTK_WINDOW (ev_window), title);
@@ -272,6 +275,9 @@ ev_window_open (EvWindow *ev_window, const char *uri)
 {
        EvDocument *document = NULL;
        char *mime_type;
+       
+       g_free (ev_window->priv->uri);
+       ev_window->priv->uri = g_strdup (uri);
 
        mime_type = gnome_vfs_get_mime_type (uri);
 
@@ -287,6 +293,11 @@ ev_window_open (EvWindow *ev_window, const char *uri)
        if (document) {
                GError *error = NULL;
 
+               g_signal_connect_object (G_OBJECT (document),
+                                        "notify::title",
+                                        G_CALLBACK (update_window_title),
+                                        ev_window, 0);
+
                if (ev_document_load (document, uri, &error)) {
                        if (ev_window->priv->document)
                                g_object_unref (ev_window->priv->document);
@@ -297,11 +308,6 @@ ev_window_open (EvWindow *ev_window, const char *uri)
                        ev_sidebar_set_document (EV_SIDEBAR (ev_window->priv->sidebar),
                                                 document);
 
-                       g_signal_connect_object (G_OBJECT (document),
-                                                "notify::title",
-                                                G_CALLBACK (update_window_title),
-                                                ev_window, 0);
-
                        update_action_sensitivity (ev_window);
                
                } else {