]> www.fi.muni.cz Git - evince.git/commitdiff
Use document thumbnail as window icon. Fixes bug #384442.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 12 Feb 2007 16:14:51 +0000 (16:14 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 12 Feb 2007 16:14:51 +0000 (16:14 +0000)
2007-02-12  Carlos Garcia Campos  <carlosgc@gnome.org>
* shell/ev-window.c: (ev_window_set_icon_from_thumbnail),
(ev_window_clear_thumbnail_job), (ev_window_setup_document),
(ev_window_dispose):
Use document thumbnail as window icon. Fixes bug #384442.

svn path=/trunk/; revision=2317

ChangeLog
shell/ev-window.c

index 1d8c50fdad5becfc9deaf30dadecd126dd2aaaee..2d2e8269477d7e05caa199ed44a4fd4f4775564b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-02-12  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-window.c: (ev_window_set_icon_from_thumbnail),
+       (ev_window_clear_thumbnail_job), (ev_window_setup_document),
+       (ev_window_dispose):
+
+       Use document thumbnail as window icon. Fixes bug #384442.
+
 2007-02-11  Ed Catmur  <ed@catmur.co.uk>
 
        * configure.ac:
index 1a964f84c1b6a9cd7fe00707309cb1ec39a0c799..10e2a5cce97cfe7dccedccbf9896cc599ce74c4a 100644 (file)
@@ -177,6 +177,7 @@ struct _EvWindowPrivate {
 #endif
 
        EvJob *load_job;
+       EvJob *thumbnail_job;
 #ifdef WITH_GNOME_PRINT
        GnomePrintJob *print_job;
 #endif
@@ -217,6 +218,8 @@ static void     ev_window_set_page_mode                 (EvWindow         *windo
                                                         EvWindowPageMode  page_mode);
 static void    ev_window_load_job_cb                   (EvJobLoad        *job,
                                                         gpointer          data);
+static void     ev_window_set_icon_from_thumbnail       (EvJobThumbnail   *job,
+                                                        EvWindow         *ev_window);
 #ifdef WITH_GTK_PRINT
 static void     ev_window_print_job_cb                  (EvJobPrint       *job,
                                                         EvWindow         *window);
@@ -661,8 +664,8 @@ page_changed_cb (EvPageCache *page_cache,
 }
 
 typedef struct _FindTask {
-    const gchar *page_label;
-    gchar *chapter;
+       const gchar *page_label;
+       gchar *chapter;
 } FindTask;
 
 static gboolean
@@ -671,26 +674,26 @@ ev_window_find_chapter (GtkTreeModel *tree_model,
                        GtkTreeIter  *iter,
                        gpointer      data)
 {
-    FindTask *task = (FindTask *)data;
-    gchar *page_string;
-    
-    gtk_tree_model_get (tree_model, iter,
-                       EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, &page_string, 
-                       -1);
-                       
-    if (!page_string)
-           return FALSE;
-           
-    if (!strcmp (page_string, task->page_label)) {
-           gtk_tree_model_get (tree_model, iter,
-                               EV_DOCUMENT_LINKS_COLUMN_MARKUP, &task->chapter, 
-                               -1);
-           g_free (page_string);
-           return TRUE;
-    }
-    
-    g_free (page_string);
-    return FALSE;
+       FindTask *task = (FindTask *)data;
+       gchar *page_string;
+       
+       gtk_tree_model_get (tree_model, iter,
+                           EV_DOCUMENT_LINKS_COLUMN_PAGE_LABEL, &page_string, 
+                           -1);
+       
+       if (!page_string)
+               return FALSE;
+       
+       if (!strcmp (page_string, task->page_label)) {
+               gtk_tree_model_get (tree_model, iter,
+                                   EV_DOCUMENT_LINKS_COLUMN_MARKUP, &task->chapter, 
+                                   -1);
+               g_free (page_string);
+               return TRUE;
+       }
+       
+       g_free (page_string);
+       return FALSE;
 }
 
 static void
@@ -1013,6 +1016,32 @@ setup_view_from_metadata (EvWindow *window)
        }
 }
 
+static void
+ev_window_clear_thumbnail_job (EvWindow *ev_window)
+{
+       if (ev_window->priv->thumbnail_job != NULL) {
+               ev_job_queue_remove_job (ev_window->priv->thumbnail_job);
+
+               g_signal_handlers_disconnect_by_func (ev_window->priv->thumbnail_job,
+                                                     ev_window_set_icon_from_thumbnail,
+                                                     ev_window);
+               g_object_unref (ev_window->priv->thumbnail_job);
+               ev_window->priv->thumbnail_job = NULL;
+       }
+}
+
+static void
+ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
+                                  EvWindow       *ev_window)
+{
+       if (job->thumbnail) {
+               gtk_window_set_icon (GTK_WINDOW (ev_window),
+                                    job->thumbnail);
+       }
+
+       ev_window_clear_thumbnail_job (ev_window);
+}
+
 static void
 ev_window_setup_document (EvWindow *ev_window)
 {
@@ -1034,6 +1063,15 @@ ev_window_setup_document (EvWindow *ev_window)
                                         ev_window, 0);
        }
 
+       if (EV_IS_DOCUMENT_THUMBNAILS (document)) {
+               ev_window_clear_thumbnail_job (ev_window);
+               ev_window->priv->thumbnail_job = ev_job_thumbnail_new (document, 0, 0, 100);
+               g_signal_connect (ev_window->priv->thumbnail_job, "finished",
+                                 G_CALLBACK (ev_window_set_icon_from_thumbnail),
+                                 ev_window);
+               ev_job_queue_add_job (EV_JOB (ev_window->priv->thumbnail_job), EV_JOB_PRIORITY_LOW);
+       }
+
        ev_sidebar_set_document (sidebar, document);
 
        if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
@@ -3862,9 +3900,14 @@ ev_window_dispose (GObject *object)
        if (priv->load_job) {
                ev_window_clear_load_job (window);
        }
+
+       if (priv->thumbnail_job) {
+               ev_window_clear_thumbnail_job (window);
+       }
        
        if (priv->local_uri) {
                ev_window_clear_local_uri (window);
+               priv->local_uri = NULL;
        }
        
        ev_window_close_dialogs (window);