Blame SOURCES/0011-Printing-fix-margins.patch

8f91ed
From 83edea9c0319d6e5f9c65338ddbc31c24ae736c9 Mon Sep 17 00:00:00 2001
8f91ed
From: =?UTF-8?q?S=C3=A9bastien=20Wilmet?= <swilmet@gnome.org>
8f91ed
Date: Sat, 6 Jun 2015 20:36:36 +0200
8f91ed
Subject: [PATCH 11/26] Printing: fix margins
8f91ed
8f91ed
GTK+'s default margins are too small. It was not possible to use a hole
8f91ed
punch, and with some printers the text was truncated on the right.
8f91ed
8f91ed
Add gsettings to configure margins, with better defaults (25mm on each
8f91ed
side). The unit chosen is the millimeter, because it's the international
8f91ed
standard.
8f91ed
8f91ed
https://bugzilla.gnome.org/show_bug.cgi?id=572741
8f91ed
---
8f91ed
 data/org.gnome.gedit.gschema.xml.in | 20 ++++++++++++++++++++
8f91ed
 gedit/gedit-print-job.c             | 19 ++++++++++++++++---
8f91ed
 gedit/gedit-settings.h              |  4 ++++
8f91ed
 3 files changed, 40 insertions(+), 3 deletions(-)
8f91ed
8f91ed
diff --git a/data/org.gnome.gedit.gschema.xml.in b/data/org.gnome.gedit.gschema.xml.in
8f91ed
index a01b3ec..c34e4db 100644
8f91ed
--- a/data/org.gnome.gedit.gschema.xml.in
8f91ed
+++ b/data/org.gnome.gedit.gschema.xml.in
8f91ed
@@ -222,6 +222,26 @@
8f91ed
       <summary>Line Number Font for Printing</summary>
8f91ed
       <description>Specifies the font to use for line numbers when printing. This will only take effect if the "Print Line Numbers" option is non-zero.</description>
8f91ed
     </key>
8f91ed
+    <key name="margin-left" type="d">
8f91ed
+      <default>25</default>
8f91ed
+      <summary>Margin Left</summary>
8f91ed
+      <description>The left margin, in millimeters.</description>
8f91ed
+    </key>
8f91ed
+    <key name="margin-top" type="d">
8f91ed
+      <default>25</default>
8f91ed
+      <summary>Margin Top</summary>
8f91ed
+      <description>The top margin, in millimeters.</description>
8f91ed
+    </key>
8f91ed
+    <key name="margin-right" type="d">
8f91ed
+      <default>25</default>
8f91ed
+      <summary>Margin Right</summary>
8f91ed
+      <description>The right margin, in millimeters.</description>
8f91ed
+    </key>
8f91ed
+    <key name="margin-bottom" type="d">
8f91ed
+      <default>25</default>
8f91ed
+      <summary>Margin Bottom</summary>
8f91ed
+      <description>The bottom margin, in millimeters.</description>
8f91ed
+    </key>
8f91ed
   </schema>
8f91ed
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.preferences.encodings" path="/org/gnome/gedit/preferences/encodings/">
8f91ed
     <key name="auto-detected" type="as">
8f91ed
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
8f91ed
index a19ef65..34816da 100644
8f91ed
--- a/gedit/gedit-print-job.c
8f91ed
+++ b/gedit/gedit-print-job.c
8f91ed
@@ -507,6 +507,7 @@ create_compositor (GeditPrintJob *job)
8f91ed
 	GtkWrapMode wrap_mode;
8f91ed
 	guint print_line_numbers;
8f91ed
 	gboolean print_header;
8f91ed
+	gdouble margin;
8f91ed
 
8f91ed
 	/* Create and initialize print compositor */
8f91ed
 	print_font_body = g_settings_get_string (job->priv->print_settings,
8f91ed
@@ -540,9 +541,17 @@ create_compositor (GeditPrintJob *job)
8f91ed
 						     "header-font-name", print_font_header,
8f91ed
 						     NULL));
8f91ed
 
8f91ed
-	g_free (print_font_body);
8f91ed
-	g_free (print_font_header);
8f91ed
-	g_free (print_font_numbers);
8f91ed
+	margin = g_settings_get_double (job->priv->print_settings, GEDIT_SETTINGS_PRINT_MARGIN_LEFT);
8f91ed
+	gtk_source_print_compositor_set_left_margin (job->priv->compositor, margin, GTK_UNIT_MM);
8f91ed
+
8f91ed
+	margin = g_settings_get_double (job->priv->print_settings, GEDIT_SETTINGS_PRINT_MARGIN_TOP);
8f91ed
+	gtk_source_print_compositor_set_top_margin (job->priv->compositor, margin, GTK_UNIT_MM);
8f91ed
+
8f91ed
+	margin = g_settings_get_double (job->priv->print_settings, GEDIT_SETTINGS_PRINT_MARGIN_RIGHT);
8f91ed
+	gtk_source_print_compositor_set_right_margin (job->priv->compositor, margin, GTK_UNIT_MM);
8f91ed
+
8f91ed
+	margin = g_settings_get_double (job->priv->print_settings, GEDIT_SETTINGS_PRINT_MARGIN_BOTTOM);
8f91ed
+	gtk_source_print_compositor_set_bottom_margin (job->priv->compositor, margin, GTK_UNIT_MM);
8f91ed
 
8f91ed
 	if (print_header)
8f91ed
 	{
8f91ed
@@ -568,6 +577,10 @@ create_compositor (GeditPrintJob *job)
8f91ed
 		g_free (name_to_display);
8f91ed
 		g_free (left);
8f91ed
 	}
8f91ed
+
8f91ed
+	g_free (print_font_body);
8f91ed
+	g_free (print_font_header);
8f91ed
+	g_free (print_font_numbers);
8f91ed
 }
8f91ed
 
8f91ed
 static void
8f91ed
diff --git a/gedit/gedit-settings.h b/gedit/gedit-settings.h
8f91ed
index 39ee82e..85cdc94 100644
8f91ed
--- a/gedit/gedit-settings.h
8f91ed
+++ b/gedit/gedit-settings.h
8f91ed
@@ -108,6 +108,10 @@ void			 gedit_settings_set_list			(GSettings     *settings,
8f91ed
 #define GEDIT_SETTINGS_PRINT_FONT_NUMBERS_PANGO		"print-font-numbers-pango"
8f91ed
 #define GEDIT_SETTINGS_ENCODING_AUTO_DETECTED		"auto-detected"
8f91ed
 #define GEDIT_SETTINGS_ENCODING_SHOWN_IN_MENU		"shown-in-menu"
8f91ed
+#define GEDIT_SETTINGS_PRINT_MARGIN_LEFT		"margin-left"
8f91ed
+#define GEDIT_SETTINGS_PRINT_MARGIN_TOP			"margin-top"
8f91ed
+#define GEDIT_SETTINGS_PRINT_MARGIN_RIGHT		"margin-right"
8f91ed
+#define GEDIT_SETTINGS_PRINT_MARGIN_BOTTOM		"margin-bottom"
8f91ed
 #define GEDIT_SETTINGS_ACTIVE_PLUGINS			"active-plugins"
8f91ed
 #define GEDIT_SETTINGS_ENSURE_TRAILING_NEWLINE		"ensure-trailing-newline"
8f91ed
 
8f91ed
-- 
8f91ed
1.8.3.1
8f91ed