[simple-scan/wip/exalm/dark: 7/7] page-view: Handle ruler color changes in runtime
- From: Bartosz <bkosiorek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan/wip/exalm/dark: 7/7] page-view: Handle ruler color changes in runtime
- Date: Wed, 5 Jan 2022 20:39:48 +0000 (UTC)
commit 2778fe927234586dba144aaff40b77a20ef8190d
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Jan 5 16:45:43 2022 +0500
page-view: Handle ruler color changes in runtime
src/book-view.vala | 13 ++++---------
src/page-view.vala | 15 ++++++---------
2 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/src/book-view.vala b/src/book-view.vala
index 59e24694..df2beb4c 100644
--- a/src/book-view.vala
+++ b/src/book-view.vala
@@ -189,14 +189,7 @@ public class BookView : Gtk.Box
private void add_cb (Book book, Page 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);
+ var page_view = new PageView (page);
page_view.changed.connect (page_view_changed_cb);
page_view.size_changed.connect (page_view_size_changed_cb);
page_data.insert (page, page_view);
@@ -450,6 +443,8 @@ public class BookView : Gtk.Box
for (var i = 0; i < book.n_pages; i++)
pages.append (get_nth_page (i));
+ var ruler_color = get_style_context ().get_color (get_state_flags ());
+
/* Render each page */
foreach (var page in pages)
{
@@ -462,7 +457,7 @@ public class BookView : Gtk.Box
context.save ();
context.translate (-x_offset, 0);
- page.render (context);
+ page.render (context, ruler_color);
context.restore ();
if (page.selected)
diff --git a/src/page-view.vala b/src/page-view.vala
index 342df278..148dcca7 100644
--- a/src/page-view.vala
+++ b/src/page-view.vala
@@ -45,8 +45,6 @@ public class PageView : Object
}
}
- private Gdk.RGBA ruler_color;
-
private int ruler_width = 8;
private int border_width = 2;
@@ -86,13 +84,9 @@ public class PageView : Object
public signal void size_changed ();
public signal void changed ();
- /* 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)
+ public PageView (Page page)
{
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);
@@ -828,7 +822,10 @@ public class PageView : Object
}
}
- public void render (Cairo.Context context)
+ /* 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 void render (Cairo.Context context, Gdk.RGBA ruler_color)
{
update_animation ();
update_page_view ();
@@ -845,7 +842,7 @@ public class PageView : Object
context.paint ();
/* Draw page border */
- context.set_source_rgb (ruler_color.red, ruler_color.green, ruler_color.blue);
+ Gdk.cairo_set_source_rgba (context, ruler_color);
context.set_line_width (border_width);
context.rectangle (0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]