[simple-scan] Move PageIcon into it's own file.



commit a8fa00ed5f184037f9823d1fd14091a63b196399
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Dec 6 11:33:07 2019 +1300

    Move PageIcon into it's own file.
    
    Seems like it wasn't fully split up in 30587f6e

 src/meson.build             |  1 +
 src/page-icon.vala          | 76 +++++++++++++++++++++++++++++++++++++++++++++
 src/preferences-dialog.vala | 65 --------------------------------------
 3 files changed, 77 insertions(+), 65 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 7d535c8..419ed06 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -24,6 +24,7 @@ simple_scan = executable ('simple-scan',
                             'book.vala',
                             'book-view.vala',
                             'page.vala',
+                            'page-icon.vala',
                             'page-view.vala',
                             'preferences-dialog.vala',
                             'simple-scan.vala',
diff --git a/src/page-icon.vala b/src/page-icon.vala
new file mode 100644
index 0000000..0822b71
--- /dev/null
+++ b/src/page-icon.vala
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2009-2017 Canonical Ltd.
+ * Author: Robert Ancell <robert ancell canonical com>,
+ *         Eduard Gotwig <g ox io>
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
+ * license.
+ */
+
+private class PageIcon : Gtk.DrawingArea
+{
+    private string text;
+    private double r;
+    private double g;
+    private double b;
+    private const int MINIMUM_WIDTH = 20;
+
+    public PageIcon (string text, double r = 1.0, double g = 1.0, double b = 1.0)
+    {
+        this.text = text;
+        this.r = r;
+        this.g = g;
+        this.b = b;
+    }
+
+    public override void get_preferred_width (out int minimum_width, out int natural_width)
+    {
+        minimum_width = natural_width = MINIMUM_WIDTH;
+    }
+
+    public override void get_preferred_height (out int minimum_height, out int natural_height)
+    {
+        minimum_height = natural_height = (int) Math.round (MINIMUM_WIDTH * Math.SQRT2);
+    }
+
+    public override void get_preferred_height_for_width (int width, out int minimum_height, out int 
natural_height)
+    {
+        minimum_height = natural_height = (int) (width * Math.SQRT2);
+    }
+
+    public override void get_preferred_width_for_height (int height, out int minimum_width, out int 
natural_width)
+    {
+        minimum_width = natural_width = (int) (height / Math.SQRT2);
+    }
+
+    public override bool draw (Cairo.Context c)
+    {
+        var w = get_allocated_width ();
+        var h = get_allocated_height ();
+        if (w * Math.SQRT2 > h)
+            w = (int) Math.round (h / Math.SQRT2);
+        else
+            h = (int) Math.round (w * Math.SQRT2);
+
+        c.translate ((get_allocated_width () - w) / 2, (get_allocated_height () - h) / 2);
+
+        c.rectangle (0.5, 0.5, w - 1, h - 1);
+
+        c.set_source_rgb (r, g, b);
+        c.fill_preserve ();
+
+        c.set_line_width (1.0);
+        c.set_source_rgb (0.0, 0.0, 0.0);
+        c.stroke ();
+
+        Cairo.TextExtents extents;
+        c.text_extents (text, out extents);
+        c.translate ((w - extents.width) * 0.5 - 0.5, (h + extents.height) * 0.5 - 0.5);
+        c.show_text (text);
+
+        return true;
+    }
+}
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 8ea9693..06dca75 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -302,68 +302,3 @@ private class PreferencesDialog : Gtk.Dialog
         }
     }
 }
-
-private class PageIcon : Gtk.DrawingArea
-{
-    private string text;
-    private double r;
-    private double g;
-    private double b;
-    private const int MINIMUM_WIDTH = 20;
-
-    public PageIcon (string text, double r = 1.0, double g = 1.0, double b = 1.0)
-    {
-        this.text = text;
-        this.r = r;
-        this.g = g;
-        this.b = b;
-    }
-
-    public override void get_preferred_width (out int minimum_width, out int natural_width)
-    {
-        minimum_width = natural_width = MINIMUM_WIDTH;
-    }
-
-    public override void get_preferred_height (out int minimum_height, out int natural_height)
-    {
-        minimum_height = natural_height = (int) Math.round (MINIMUM_WIDTH * Math.SQRT2);
-    }
-
-    public override void get_preferred_height_for_width (int width, out int minimum_height, out int 
natural_height)
-    {
-        minimum_height = natural_height = (int) (width * Math.SQRT2);
-    }
-
-    public override void get_preferred_width_for_height (int height, out int minimum_width, out int 
natural_width)
-    {
-        minimum_width = natural_width = (int) (height / Math.SQRT2);
-    }
-
-    public override bool draw (Cairo.Context c)
-    {
-        var w = get_allocated_width ();
-        var h = get_allocated_height ();
-        if (w * Math.SQRT2 > h)
-            w = (int) Math.round (h / Math.SQRT2);
-        else
-            h = (int) Math.round (w * Math.SQRT2);
-
-        c.translate ((get_allocated_width () - w) / 2, (get_allocated_height () - h) / 2);
-
-        c.rectangle (0.5, 0.5, w - 1, h - 1);
-
-        c.set_source_rgb (r, g, b);
-        c.fill_preserve ();
-
-        c.set_line_width (1.0);
-        c.set_source_rgb (0.0, 0.0, 0.0);
-        c.stroke ();
-
-        Cairo.TextExtents extents;
-        c.text_extents (text, out extents);
-        c.translate ((w - extents.width) * 0.5 - 0.5, (h + extents.height) * 0.5 - 0.5);
-        c.show_text (text);
-
-        return true;
-    }
-}


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