[gedit] Printing: fix margins
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Printing: fix margins
- Date: Sun, 7 Jun 2015 14:37:43 +0000 (UTC)
commit 355cd2dd89e66efa1023310d66936eddfb55d58f
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 6 20:36:36 2015 +0200
Printing: fix margins
GTK+'s default margins are too small. It was not possible to use a hole
punch, and with some printers the text was truncated on the right.
Add gsettings to configure margins, with better defaults (25mm on each
side). The unit chosen is the millimeter, because it's the international
standard.
https://bugzilla.gnome.org/show_bug.cgi?id=572741
data/org.gnome.gedit.gschema.xml.in | 20 ++++++++++++++++++++
gedit/gedit-print-job.c | 19 ++++++++++++++++---
gedit/gedit-settings.h | 4 ++++
3 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.gedit.gschema.xml.in b/data/org.gnome.gedit.gschema.xml.in
index 9ee2ea9..a7b1f76 100644
--- a/data/org.gnome.gedit.gschema.xml.in
+++ b/data/org.gnome.gedit.gschema.xml.in
@@ -237,6 +237,26 @@
<summary>Line Number Font for Printing</summary>
<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>
</key>
+ <key name="margin-left" type="d">
+ <default>25</default>
+ <summary>Margin Left</summary>
+ <description>The left margin, in millimeters.</description>
+ </key>
+ <key name="margin-top" type="d">
+ <default>25</default>
+ <summary>Margin Top</summary>
+ <description>The top margin, in millimeters.</description>
+ </key>
+ <key name="margin-right" type="d">
+ <default>25</default>
+ <summary>Margin Right</summary>
+ <description>The right margin, in millimeters.</description>
+ </key>
+ <key name="margin-bottom" type="d">
+ <default>25</default>
+ <summary>Margin Bottom</summary>
+ <description>The bottom margin, in millimeters.</description>
+ </key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.preferences.encodings"
path="/org/gnome/gedit/preferences/encodings/">
<key name="candidate-encodings" type="as">
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
index e1069ff..8695f9f 100644
--- a/gedit/gedit-print-job.c
+++ b/gedit/gedit-print-job.c
@@ -487,6 +487,7 @@ create_compositor (GeditPrintJob *job)
guint print_line_numbers;
gboolean print_header;
guint tab_width;
+ gdouble margin;
buf = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (job->view)));
@@ -530,9 +531,17 @@ create_compositor (GeditPrintJob *job)
"header-font-name", print_font_header,
NULL));
- g_free (print_font_body);
- g_free (print_font_header);
- g_free (print_font_numbers);
+ margin = g_settings_get_double (job->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_LEFT);
+ gtk_source_print_compositor_set_left_margin (job->compositor, margin, GTK_UNIT_MM);
+
+ margin = g_settings_get_double (job->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_TOP);
+ gtk_source_print_compositor_set_top_margin (job->compositor, margin, GTK_UNIT_MM);
+
+ margin = g_settings_get_double (job->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_RIGHT);
+ gtk_source_print_compositor_set_right_margin (job->compositor, margin, GTK_UNIT_MM);
+
+ margin = g_settings_get_double (job->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_BOTTOM);
+ gtk_source_print_compositor_set_bottom_margin (job->compositor, margin, GTK_UNIT_MM);
if (print_header)
{
@@ -558,6 +567,10 @@ create_compositor (GeditPrintJob *job)
g_free (name_to_display);
g_free (left);
}
+
+ g_free (print_font_body);
+ g_free (print_font_header);
+ g_free (print_font_numbers);
}
static void
diff --git a/gedit/gedit-settings.h b/gedit/gedit-settings.h
index bfc852b..16d0d86 100644
--- a/gedit/gedit-settings.h
+++ b/gedit/gedit-settings.h
@@ -87,6 +87,10 @@ void gedit_settings_set_list (GSettings
*settings,
#define GEDIT_SETTINGS_PRINT_FONT_BODY_PANGO "print-font-body-pango"
#define GEDIT_SETTINGS_PRINT_FONT_HEADER_PANGO "print-font-header-pango"
#define GEDIT_SETTINGS_PRINT_FONT_NUMBERS_PANGO "print-font-numbers-pango"
+#define GEDIT_SETTINGS_PRINT_MARGIN_LEFT "margin-left"
+#define GEDIT_SETTINGS_PRINT_MARGIN_TOP "margin-top"
+#define GEDIT_SETTINGS_PRINT_MARGIN_RIGHT "margin-right"
+#define GEDIT_SETTINGS_PRINT_MARGIN_BOTTOM "margin-bottom"
#define GEDIT_SETTINGS_CANDIDATE_ENCODINGS "candidate-encodings"
#define GEDIT_SETTINGS_ACTIVE_PLUGINS "active-plugins"
#define GEDIT_SETTINGS_ENSURE_TRAILING_NEWLINE "ensure-trailing-newline"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]