X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-pixbuf-cache.c;h=b780724887515fc98a3be7b6e033f3c747c350d9;hb=578c78ee1a5ee3b2aa858ebf257646c195cd9885;hp=cbb6d18c68e3e2f27bbfbc71c04a253c13245547;hpb=00efc5c16ed191f07f9a8a5d00acc41ddb064b46;p=evince.git diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index cbb6d18c..b7807248 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -67,7 +67,6 @@ static CacheJobInfo *find_job_cache (EvPixbufCache *pixbuf_cach static void copy_job_to_job_info (EvJobRender *job_render, CacheJobInfo *job_info, EvPixbufCache *pixbuf_cache); -static guint convert_gdk_color_to_uint (GdkColor *color); static gboolean new_selection_pixbuf_needed(EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, gint page, @@ -161,6 +160,10 @@ dispose_cache_job_info (CacheJobInfo *job_info, gdk_region_destroy (job_info->selection_region); job_info->selection_region = NULL; } + if (job_info->rc) { + g_object_unref (G_OBJECT (job_info->rc)); + job_info->rc = NULL; + } job_info->selection_points.x1 = -1; job_info->new_points.x1 = -1; @@ -489,6 +492,18 @@ ev_pixbuf_cache_clear_job_sizes (EvPixbufCache *pixbuf_cache, #define FIRST_VISABLE_PREV(pixbuf_cache) \ (MAX (0, pixbuf_cache->preload_cache_size + 1 - pixbuf_cache->start_page)) +static void +get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base) +{ + if (GTK_WIDGET_HAS_FOCUS (widget)) { + *text = &widget->style->text [GTK_STATE_SELECTED]; + *base = &widget->style->base [GTK_STATE_SELECTED]; + } else { + *text = &widget->style->text [GTK_STATE_ACTIVE]; + *base = &widget->style->base [GTK_STATE_ACTIVE]; + } +} + static void add_job_if_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, @@ -502,7 +517,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, gboolean include_text = FALSE; gboolean include_selection = FALSE; int width, height; - guint text, base; + GdkColor *text, *base; if (job_info->job) return; @@ -535,8 +550,7 @@ add_job_if_needed (EvPixbufCache *pixbuf_cache, gtk_widget_ensure_style (pixbuf_cache->view); - text = convert_gdk_color_to_uint (& (pixbuf_cache->view->style->text [GTK_STATE_SELECTED])); - base = convert_gdk_color_to_uint (& (pixbuf_cache->view->style->base [GTK_STATE_SELECTED])); + get_selection_colors (pixbuf_cache->view, &text, &base); job_info->job = ev_job_render_new (pixbuf_cache->document, job_info->rc, @@ -664,18 +678,6 @@ ev_pixbuf_cache_get_link_mapping (EvPixbufCache *pixbuf_cache, return job_info->link_mapping; } -/* Selection */ -static guint -convert_gdk_color_to_uint (GdkColor *color) -{ - g_assert (color); - - return 0xff << 24 | - (color->red & 0xff00) << 8 | - (color->green & 0xff00) | - (color->blue & 0xff00) >> 8; -} - static gboolean new_selection_pixbuf_needed (EvPixbufCache *pixbuf_cache, CacheJobInfo *job_info, @@ -825,7 +827,7 @@ ev_pixbuf_cache_get_selection_pixbuf (EvPixbufCache *pixbuf_cache, */ if (ev_rect_cmp (&(job_info->new_points), &(job_info->selection_points))) { EvRectangle *old_points; - guint text, base; + GdkColor *text, *base; /* we need to get a new selection pixbuf */ ev_document_doc_mutex_lock (); @@ -846,8 +848,7 @@ ev_pixbuf_cache_get_selection_pixbuf (EvPixbufCache *pixbuf_cache, gtk_widget_ensure_style (pixbuf_cache->view); - text = convert_gdk_color_to_uint (& (pixbuf_cache->view->style->text [GTK_STATE_SELECTED])); - base = convert_gdk_color_to_uint (& (pixbuf_cache->view->style->base [GTK_STATE_SELECTED])); + get_selection_colors (pixbuf_cache->view, &text, &base); ev_selection_render_selection (EV_SELECTION (pixbuf_cache->document), job_info->rc, &(job_info->selection),