]> www.fi.muni.cz Git - evince.git/commitdiff
Change selection color on focus in and focus out events. Also, poppler now
authorKristian Høgsberg <krh@redhat.com>
Sat, 6 Aug 2005 18:14:24 +0000 (18:14 +0000)
committerKristian Høgsberg <krh@src.gnome.org>
Sat, 6 Aug 2005 18:14:24 +0000 (18:14 +0000)
2005-08-06  Kristian Høgsberg  <krh@redhat.com>

        * backend/ev-selection.c: (ev_selection_render_selection):
        * backend/ev-selection.h:
        * pdf/ev-poppler.cc:
        * shell/ev-jobs.c: (ev_job_render_new):
        * shell/ev-jobs.h:
        * shell/ev-pixbuf-cache.c: (get_selection_colors),
        (add_job_if_needed), (ev_pixbuf_cache_get_selection_pixbuf):
        * shell/ev-view.c: (ev_view_focus_in), (ev_view_focus_out),
        (ev_view_class_init):

        Change selection color on focus in and focus out events.  Also,
        poppler now uses GdkColor for specifying the selection colors, so
        drop some awkward conversion code.

ChangeLog
backend/ev-selection.c
backend/ev-selection.h
pdf/ev-poppler.cc
shell/ev-jobs.c
shell/ev-jobs.h
shell/ev-pixbuf-cache.c
shell/ev-view.c

index 02055f99f908acea59c349cd7ac1a100382f0853..642d196446ec7cb488f1afd79573e2093a84790a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2005-08-06  Kristian Høgsberg  <krh@redhat.com>
+
+       * backend/ev-selection.c: (ev_selection_render_selection):
+       * backend/ev-selection.h:
+       * pdf/ev-poppler.cc:
+       * shell/ev-jobs.c: (ev_job_render_new):
+       * shell/ev-jobs.h:
+       * shell/ev-pixbuf-cache.c: (get_selection_colors),
+       (add_job_if_needed), (ev_pixbuf_cache_get_selection_pixbuf):
+       * shell/ev-view.c: (ev_view_focus_in), (ev_view_focus_out),
+       (ev_view_class_init):
+
+       Change selection color on focus in and focus out events.  Also,
+       poppler now uses GdkColor for specifying the selection colors, so
+       drop some awkward conversion code.
+
 2005-08-06  Yair Hershkovitz  <yairhr@gmail.com>
 
        * configure.ac: Added Hebrew translation
index f9f73e08649a69b5d289a5af85e69430bc2754f5..36c32e3a53c696436eaa18ab63a27aa9d68e8156 100644 (file)
@@ -62,8 +62,8 @@ ev_selection_render_selection (EvSelection      *selection,
                               GdkPixbuf       **pixbuf,
                               EvRectangle      *points,
                               EvRectangle      *old_points,
-                              guint             text,
-                              guint             base)
+                              GdkColor        *text,
+                              GdkColor        *base)
 {
        EvSelectionIface *iface = EV_SELECTION_GET_IFACE (selection);
 
index 8ed416bfbaabe599c6e5add72b52a0e4bf02ac6a..d0816040b16380c0f81bdae5b300dcdf6127dfbc 100644 (file)
@@ -48,8 +48,8 @@ struct _EvSelectionIface
                                              GdkPixbuf       **pixbuf,
                                              EvRectangle      *points,
                                              EvRectangle      *old_points,
-                                             guint             text,
-                                             guint             base);
+                                             GdkColor        *text,
+                                             GdkColor        *base);
        GdkRegion * (* get_selection_map)    (EvSelection      *selection,
                                              EvRenderContext  *rc);
        GdkRegion * (* get_selection_region) (EvSelection      *selection,
@@ -63,8 +63,8 @@ void       ev_selection_render_selection     (EvSelection      *selection,
                                              GdkPixbuf       **pixbuf,
                                              EvRectangle      *points,
                                              EvRectangle      *old_points,
-                                             guint             text,
-                                             guint             base);
+                                             GdkColor         *text,
+                                             GdkColor         *base);
 GdkRegion *ev_selection_get_selection_map    (EvSelection      *selection,
                                              EvRenderContext  *rc);
 GdkRegion *ev_selection_get_selection_region (EvSelection      *selection,
index b4a6799521877a6c30733097665d29d4ec873e89..610f598388a1bf093568a1ac12a2951f06a6cdb4 100644 (file)
@@ -1182,8 +1182,8 @@ pdf_selection_render_selection (EvSelection      *selection,
                                GdkPixbuf       **pixbuf,
                                EvRectangle      *points,
                                EvRectangle      *old_points,
-                               guint             text,
-                               guint             base)
+                               GdkColor        *text,
+                               GdkColor        *base)
 {
        PdfDocument *pdf_document;
        double width_points, height_points;
index 595f9e839de76dc116259f3341063a10a0d21f85..5060231bee32edf333bdfe42cb9fcade056893db 100644 (file)
@@ -236,8 +236,8 @@ ev_job_render_new (EvDocument      *document,
                   gint             width,
                   gint             height,
                   EvRectangle     *selection_points,
-                  guint            text,
-                  guint            base,
+                  GdkColor        *text,
+                  GdkColor        *base,
                   gboolean         include_links,
                   gboolean         include_text,
                   gboolean         include_selection)
index 15768371412846dfae665365ad9e227cc705ee41..8836d925abe5d7946252bb322f81fedefc42d0c5 100644 (file)
@@ -120,8 +120,8 @@ struct _EvJobRender
        GdkPixbuf *selection;
        GdkRegion *selection_region;
        EvRectangle selection_points;
-       guint base;
-       guint text; 
+       GdkColor *base;
+       GdkColor *text; 
 
        gint include_links : 1;
        gint include_text : 1;
@@ -187,8 +187,8 @@ EvJob          *ev_job_render_new         (EvDocument      *document,
                                           gint             width,
                                           gint             height,
                                           EvRectangle     *selection_points,
-                                          guint            text,
-                                          guint            base,
+                                          GdkColor        *text,
+                                          GdkColor        *base,
                                           gboolean         include_links,
                                           gboolean         include_text,
                                           gboolean         include_selection);
index cbb6d18c68e3e2f27bbfbc71c04a253c13245547..1b6966d39b733e2ede96ab3a39043a27b397bd16 100644 (file)
@@ -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,
@@ -489,6 +488,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 +513,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 +546,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 +674,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 +823,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 +844,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),
index 5d7df6b3a5f1b768e50aabe3f36448a82c45d02e..c4ae90465f727f067e45c2a5cce8c171c04741f4 100644 (file)
@@ -1566,6 +1566,28 @@ ev_view_button_release_event (GtkWidget      *widget,
        return FALSE;
 }
 
+static gint
+ev_view_focus_in (GtkWidget     *widget,
+                 GdkEventFocus *event)
+{
+       if (EV_VIEW (widget)->pixbuf_cache)
+               ev_pixbuf_cache_style_changed (EV_VIEW (widget)->pixbuf_cache);
+       gtk_widget_queue_draw (widget);
+
+       return FALSE;
+}
+
+static gint
+ev_view_focus_out (GtkWidget     *widget,
+                    GdkEventFocus *event)
+{
+       if (EV_VIEW (widget)->pixbuf_cache)
+               ev_pixbuf_cache_style_changed (EV_VIEW (widget)->pixbuf_cache);
+       gtk_widget_queue_draw (widget);
+
+       return FALSE;
+}
+
 static gboolean
 ev_view_leave_notify_event (GtkWidget *widget, GdkEventCrossing   *event)
 {
@@ -1894,6 +1916,8 @@ ev_view_class_init (EvViewClass *class)
        widget_class->button_press_event = ev_view_button_press_event;
        widget_class->motion_notify_event = ev_view_motion_notify_event;
        widget_class->button_release_event = ev_view_button_release_event;
+       widget_class->focus_in_event = ev_view_focus_in;
+       widget_class->focus_out_event = ev_view_focus_out;
        widget_class->size_request = ev_view_size_request;
        widget_class->size_allocate = ev_view_size_allocate;
        widget_class->realize = ev_view_realize;