[gedit/gnome-3-16] Printing: fix margins



commit df76102321b6f5f733d01c0973a0af7a230267fb
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 a01b3ec..c34e4db 100644
--- a/data/org.gnome.gedit.gschema.xml.in
+++ b/data/org.gnome.gedit.gschema.xml.in
@@ -222,6 +222,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="auto-detected" type="as">
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
index e8a363b..f76debd 100644
--- a/gedit/gedit-print-job.c
+++ b/gedit/gedit-print-job.c
@@ -480,6 +480,7 @@ create_compositor (GeditPrintJob *job)
        guint print_line_numbers;
        gboolean print_header;
        guint tab_width;
+       gdouble margin;
 
        print_font_body = g_settings_get_string (job->priv->gsettings,
                                                 GEDIT_SETTINGS_PRINT_FONT_BODY_PANGO);
@@ -520,9 +521,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->priv->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_LEFT);
+       gtk_source_print_compositor_set_left_margin (job->priv->compositor, margin, GTK_UNIT_MM);
+
+       margin = g_settings_get_double (job->priv->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_TOP);
+       gtk_source_print_compositor_set_top_margin (job->priv->compositor, margin, GTK_UNIT_MM);
+
+       margin = g_settings_get_double (job->priv->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_RIGHT);
+       gtk_source_print_compositor_set_right_margin (job->priv->compositor, margin, GTK_UNIT_MM);
+
+       margin = g_settings_get_double (job->priv->gsettings, GEDIT_SETTINGS_PRINT_MARGIN_BOTTOM);
+       gtk_source_print_compositor_set_bottom_margin (job->priv->compositor, margin, GTK_UNIT_MM);
 
        if (print_header)
        {
@@ -548,6 +557,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 39ee82e..85cdc94 100644
--- a/gedit/gedit-settings.h
+++ b/gedit/gedit-settings.h
@@ -108,6 +108,10 @@ void                        gedit_settings_set_list                        (GSettings    
 *settings,
 #define GEDIT_SETTINGS_PRINT_FONT_NUMBERS_PANGO                "print-font-numbers-pango"
 #define GEDIT_SETTINGS_ENCODING_AUTO_DETECTED          "auto-detected"
 #define GEDIT_SETTINGS_ENCODING_SHOWN_IN_MENU          "shown-in-menu"
+#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_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]