From ec95cd00fbffdb58196e0adadd664e07f5c343a1 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 12 Feb 2007 16:14:51 +0000 Subject: [PATCH] Use document thumbnail as window icon. Fixes bug #384442. 2007-02-12 Carlos Garcia Campos * 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 | 8 +++++ shell/ev-window.c | 87 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d8c50fd..2d2e8269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-02-12 Carlos Garcia Campos + + * 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 * configure.ac: diff --git a/shell/ev-window.c b/shell/ev-window.c index 1a964f84..10e2a5cc 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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); -- 2.43.5