[simple-scan] page-view: Use theme's foreground color for border and rullers



commit 982b33851cbd02e9d937ff0a6595090d6bae4414
Author: vanadiae <vanadiae35 gmail com>
Date:   Thu Dec 3 16:10:01 2020 +0100

    page-view: Use theme's foreground color for border and rullers
    
    This means it looks nicer for dark themes, and any other theme that can
    be found out there.

 src/book-view.vala |  9 ++++++++-
 src/page-view.vala | 10 ++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/book-view.vala b/src/book-view.vala
index 12da06fd..59e24694 100644
--- a/src/book-view.vala
+++ b/src/book-view.vala
@@ -189,7 +189,14 @@ public class BookView : Gtk.Box
 
     private void add_cb (Book book, Page page)
     {
-        var page_view = new PageView (page);
+        Gdk.RGBA page_ruler_color;
+        if (!get_style_context ().lookup_color ("theme_fg_color", out page_ruler_color))
+        {
+            warning ("Couldn't get theme_fg_color from GTK theme, needed to draw the page view ruler");
+            /* Use a bright color so that theme makers notice it. */
+            page_ruler_color.parse ("#00ff00");
+        }
+        var page_view = new PageView (page, page_ruler_color);
         page_view.changed.connect (page_view_changed_cb);
         page_view.size_changed.connect (page_view_size_changed_cb);
         page_data.insert (page, page_view);
diff --git a/src/page-view.vala b/src/page-view.vala
index 90a8071c..342df278 100644
--- a/src/page-view.vala
+++ b/src/page-view.vala
@@ -45,6 +45,8 @@ public class PageView : Object
         }
     }
 
+    private Gdk.RGBA ruler_color;
+
     private int ruler_width = 8;
 
     private int border_width = 2;
@@ -84,9 +86,13 @@ public class PageView : Object
     public signal void size_changed ();
     public signal void changed ();
 
-    public PageView (Page page)
+    /* It is necessary to ask the ruler color since it is themed with the GTK */
+    /* theme foreground color, and this class doesn't have any GTK widget     */
+    /* available to lookup the color. */
+    public PageView (Page page, Gdk.RGBA ruler_color)
     {
         this.page = page;
+        this.ruler_color = ruler_color;
         page.pixels_changed.connect (page_pixels_changed_cb);
         page.size_changed.connect (page_size_changed_cb);
         page.crop_changed.connect (page_overlay_changed_cb);
@@ -839,7 +845,7 @@ public class PageView : Object
         context.paint ();
 
         /* Draw page border */
-        context.set_source_rgb (0, 0, 0);
+        context.set_source_rgb (ruler_color.red, ruler_color.green, ruler_color.blue);
         context.set_line_width (border_width);
 
         context.rectangle (0,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]