X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-sidebar-thumbnails.c;h=4aaeebab191409a8b5cc404b8527859b6fb64c9a;hb=df408ff0086984d7c067ea31f298c0aad002b2e6;hp=78784ed56a1483d861cbba7cc08ad742f9e62941;hpb=677ce2c9e5d684bf74b5dd23dee1303b51e2f6a4;p=evince.git diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 78784ed5..4aaeebab 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H @@ -72,6 +72,7 @@ struct _EvSidebarThumbnailsPrivate { gint n_pages, pages_done; int rotation; + gboolean inverted_colors; /* Visible pages */ gint start_page, end_page; @@ -90,14 +91,14 @@ enum { PROP_WIDGET, }; -static void ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar); -static gboolean ev_sidebar_thumbnails_support_document (EvSidebarPage *sidebar_page, - EvDocument *document); -static void ev_sidebar_thumbnails_page_iface_init (EvSidebarPageIface *iface); -static const gchar* ev_sidebar_thumbnails_get_label (EvSidebarPage *sidebar_page); -static void thumbnail_job_completed_callback (EvJobThumbnail *job, - EvSidebarThumbnails *sidebar_thumbnails); -static void adjustment_changed_cb (EvSidebarThumbnails *sidebar_thumbnails); +static void ev_sidebar_thumbnails_clear_model (EvSidebarThumbnails *sidebar); +static gboolean ev_sidebar_thumbnails_support_document (EvSidebarPage *sidebar_page, + EvDocument *document); +static void ev_sidebar_thumbnails_page_iface_init (EvSidebarPageInterface *iface); +static const gchar* ev_sidebar_thumbnails_get_label (EvSidebarPage *sidebar_page); +static void thumbnail_job_completed_callback (EvJobThumbnail *job, + EvSidebarThumbnails *sidebar_thumbnails); +static void adjustment_changed_cb (EvSidebarThumbnails *sidebar_thumbnails); G_DEFINE_TYPE_EXTENDED (EvSidebarThumbnails, ev_sidebar_thumbnails, @@ -331,15 +332,18 @@ ev_sidebar_thumbnails_get_loading_icon (EvSidebarThumbnails *sidebar_thumbnails, gint width, gint height) { + EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; GdkPixbuf *icon; gchar *key; key = g_strdup_printf ("%dx%d", width, height); - icon = g_hash_table_lookup (sidebar_thumbnails->priv->loading_icons, key); + icon = g_hash_table_lookup (priv->loading_icons, key); if (!icon) { - icon = ev_document_misc_get_thumbnail_frame (width, height, NULL); - g_hash_table_insert (sidebar_thumbnails->priv->loading_icons, - key, icon); + gboolean inverted_colors; + + inverted_colors = ev_document_model_get_inverted_colors (priv->model); + icon = ev_document_misc_get_loading_thumbnail (width, height, inverted_colors); + g_hash_table_insert (priv->loading_icons, key, icon); } else { g_free (key); } @@ -498,25 +502,31 @@ adjustment_changed_cb (EvSidebarThumbnails *sidebar_thumbnails) EvSidebarThumbnailsPrivate *priv = sidebar_thumbnails->priv; GtkTreePath *path = NULL; GtkTreePath *path2 = NULL; + gdouble page_size; + gdouble value; gint wy1; gint wy2; /* Widget is not currently visible */ - if (!GTK_WIDGET_MAPPED (sidebar_thumbnails)) + if (!gtk_widget_get_mapped (GTK_WIDGET (sidebar_thumbnails))) return; - if (priv->vadjustment->page_size == 0) + page_size = gtk_adjustment_get_page_size (priv->vadjustment); + + if (page_size == 0) return; + + value = gtk_adjustment_get_value (priv->vadjustment); if (priv->tree_view) { - if (! GTK_WIDGET_REALIZED (priv->tree_view)) + if (! gtk_widget_get_realized (priv->tree_view)) return; gtk_tree_view_convert_tree_to_bin_window_coords (GTK_TREE_VIEW (priv->tree_view), - 0, (int) priv->vadjustment->value, + 0, (int) value, NULL, &wy1); gtk_tree_view_convert_tree_to_bin_window_coords (GTK_TREE_VIEW (priv->tree_view), - 0, (int) (priv->vadjustment->value + priv->vadjustment->page_size), + 0, (int) (value + page_size), NULL, &wy2); gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->tree_view), 1, wy1 + 1, &path, @@ -525,7 +535,7 @@ adjustment_changed_cb (EvSidebarThumbnails *sidebar_thumbnails) 1, wy2 -1, &path2, NULL, NULL, NULL); } else if (priv->icon_view) { - if (! GTK_WIDGET_REALIZED (priv->icon_view)) + if (! gtk_widget_get_realized (priv->icon_view)) return; if (! gtk_icon_view_get_visible_range (GTK_ICON_VIEW (priv->icon_view), &path, &path2)) return; @@ -765,13 +775,10 @@ refresh (EvSidebarThumbnails *sidebar_thumbnails) } static void -ev_sidebar_thumbnails_rotation_changed_cb (EvDocumentModel *model, - GParamSpec *pspec, - EvSidebarThumbnails *sidebar_thumbnails) +ev_sidebar_thumbnails_reload (EvSidebarThumbnails *sidebar_thumbnails) { - gint rotation = ev_document_model_get_rotation (model); + EvDocumentModel *model; - sidebar_thumbnails->priv->rotation = rotation; if (sidebar_thumbnails->priv->loading_icons) g_hash_table_remove_all (sidebar_thumbnails->priv->loading_icons); @@ -779,6 +786,8 @@ ev_sidebar_thumbnails_rotation_changed_cb (EvDocumentModel *model, sidebar_thumbnails->priv->n_pages <= 0) return; + model = sidebar_thumbnails->priv->model; + ev_sidebar_thumbnails_clear_model (sidebar_thumbnails); ev_sidebar_thumbnails_fill_model (sidebar_thumbnails); @@ -790,6 +799,28 @@ ev_sidebar_thumbnails_rotation_changed_cb (EvDocumentModel *model, g_idle_add ((GSourceFunc)refresh, sidebar_thumbnails); } +static void +ev_sidebar_thumbnails_rotation_changed_cb (EvDocumentModel *model, + GParamSpec *pspec, + EvSidebarThumbnails *sidebar_thumbnails) +{ + gint rotation = ev_document_model_get_rotation (model); + + sidebar_thumbnails->priv->rotation = rotation; + ev_sidebar_thumbnails_reload (sidebar_thumbnails); +} + +static void +ev_sidebar_thumbnails_inverted_colors_changed_cb (EvDocumentModel *model, + GParamSpec *pspec, + EvSidebarThumbnails *sidebar_thumbnails) +{ + gboolean inverted_colors = ev_document_model_get_inverted_colors (model); + + sidebar_thumbnails->priv->inverted_colors = inverted_colors; + ev_sidebar_thumbnails_reload (sidebar_thumbnails); +} + static void thumbnail_job_completed_callback (EvJobThumbnail *job, EvSidebarThumbnails *sidebar_thumbnails) @@ -798,6 +829,8 @@ thumbnail_job_completed_callback (EvJobThumbnail *job, GtkTreeIter *iter; iter = (GtkTreeIter *) g_object_get_data (G_OBJECT (job), "tree_iter"); + if (priv->inverted_colors) + ev_document_misc_invert_pixbuf (job->thumbnail); gtk_list_store_set (priv->list_store, iter, COLUMN_PIXBUF, job->thumbnail, @@ -824,6 +857,7 @@ ev_sidebar_thumbnails_document_changed_cb (EvDocumentModel *model, priv->document = document; priv->n_pages = ev_document_get_n_pages (document); priv->rotation = ev_document_model_get_rotation (model); + priv->inverted_colors = ev_document_model_get_inverted_colors (model); priv->loading_icons = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, @@ -864,6 +898,9 @@ ev_sidebar_thumbnails_document_changed_cb (EvDocumentModel *model, g_signal_connect (priv->model, "notify::rotation", G_CALLBACK (ev_sidebar_thumbnails_rotation_changed_cb), sidebar_thumbnails); + g_signal_connect (priv->model, "notify::inverted-colors", + G_CALLBACK (ev_sidebar_thumbnails_inverted_colors_changed_cb), + sidebar_thumbnails); sidebar_thumbnails->priv->start_page = -1; sidebar_thumbnails->priv->end_page = -1; ev_sidebar_thumbnails_set_current_page (sidebar_thumbnails, @@ -929,10 +966,9 @@ ev_sidebar_thumbnails_get_label (EvSidebarPage *sidebar_page) } static void -ev_sidebar_thumbnails_page_iface_init (EvSidebarPageIface *iface) +ev_sidebar_thumbnails_page_iface_init (EvSidebarPageInterface *iface) { iface->support_document = ev_sidebar_thumbnails_support_document; iface->set_model = ev_sidebar_thumbnails_set_model; iface->get_label = ev_sidebar_thumbnails_get_label; } -