X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libview%2Fev-pixbuf-cache.c;h=98719a36e1ad213d9081d160c4a1b8cfbe7d04c5;hb=f3731bd3bdbcdc18c53e0f74bdaac93311046352;hp=367f70d781fd52490186d3a09b354ee8a26e4c81;hpb=fbbc1a0d02847de2b0a0ddbae8cf33bfec9dab81;p=evince.git diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c index 367f70d7..98719a36 100644 --- a/libview/ev-pixbuf-cache.c +++ b/libview/ev-pixbuf-cache.c @@ -602,17 +602,25 @@ ev_pixbuf_cache_clear_job_sizes (EvPixbufCache *pixbuf_cache, } static void -get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base) +get_selection_colors (GtkWidget *widget, GdkColor *text, GdkColor *base) { - GtkStyle *style = gtk_widget_get_style (widget); - - if (gtk_widget_has_focus (widget)) { - *text = &style->text [GTK_STATE_SELECTED]; - *base = &style->base [GTK_STATE_SELECTED]; - } else { - *text = &style->text [GTK_STATE_ACTIVE]; - *base = &style->base [GTK_STATE_ACTIVE]; - } + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkStateFlags state = 0; + GdkRGBA fg, bg; + + state |= gtk_widget_has_focus (widget) ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE; + + gtk_style_context_get_color (context, state, &fg); + text->pixel = 0; + text->red = CLAMP ((guint) (fg.red * 65535), 0, 65535); + text->green = CLAMP ((guint) (fg.green * 65535), 0, 65535); + text->blue = CLAMP ((guint) (fg.blue * 65535), 0, 65535); + + gtk_style_context_get_background_color (context, state, &bg); + base->pixel = 0; + base->red = CLAMP ((guint) (bg.red * 65535), 0, 65535); + base->green = CLAMP ((guint) (bg.green * 65535), 0, 65535); + base->blue = CLAMP ((guint) (bg.blue * 65535), 0, 65535); } static void @@ -637,14 +645,13 @@ add_job (EvPixbufCache *pixbuf_cache, width, height); if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) { - GdkColor *text, *base; + GdkColor text, base; - gtk_widget_ensure_style (pixbuf_cache->view); get_selection_colors (pixbuf_cache->view, &text, &base); ev_job_render_set_selection_info (EV_JOB_RENDER (job_info->job), &(job_info->target_points), job_info->selection_style, - text, base); + &text, &base); } g_signal_connect (job_info->job, "finished", @@ -952,7 +959,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache, */ if (ev_rect_cmp (&(job_info->target_points), &(job_info->selection_points))) { EvRectangle *old_points; - GdkColor *text, *base; + GdkColor text, base; EvRenderContext *rc; EvPage *ev_page; @@ -977,8 +984,6 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache, rc, job_info->selection_style, &(job_info->target_points)); - gtk_widget_ensure_style (pixbuf_cache->view); - get_selection_colors (pixbuf_cache->view, &text, &base); ev_selection_render_selection (EV_SELECTION (pixbuf_cache->document), @@ -986,7 +991,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache, &(job_info->target_points), old_points, job_info->selection_style, - text, base); + &text, &base); job_info->selection_points = job_info->target_points; g_object_unref (rc); ev_document_doc_mutex_unlock (); @@ -1035,6 +1040,9 @@ ev_pixbuf_cache_set_selection_list (EvPixbufCache *pixbuf_cache, if (!EV_IS_SELECTION (pixbuf_cache->document)) return; + if (pixbuf_cache->start_page == -1 || pixbuf_cache->end_page == -1) + return; + /* We check each area to see what needs updating, and what needs freeing; */ page = pixbuf_cache->start_page - pixbuf_cache->preload_cache_size; for (i = 0; i < pixbuf_cache->preload_cache_size; i++) { @@ -1114,6 +1122,9 @@ ev_pixbuf_cache_get_selection_list (EvPixbufCache *pixbuf_cache) g_return_val_if_fail (EV_IS_PIXBUF_CACHE (pixbuf_cache), NULL); + if (pixbuf_cache->start_page == -1 || pixbuf_cache->end_page == -1) + return NULL; + /* We check each area to see what needs updating, and what needs freeing; */ page = pixbuf_cache->start_page - pixbuf_cache->preload_cache_size; for (i = 0; i < pixbuf_cache->preload_cache_size; i++) {