[gtksourceview/wip/chergert/gsv-gtk4: 29/172] print: modernize GtkSourcePrintCompositor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 29/172] print: modernize GtkSourcePrintCompositor
- Date: Thu, 14 May 2020 02:04:01 +0000 (UTC)
commit ea7a420c7d1a4bb524c3930263812d70ad71ae9a
Author: Christian Hergert <chergert redhat com>
Date: Thu Jan 9 10:04:22 2020 -0800
print: modernize GtkSourcePrintCompositor
- Use G_DECLARE_ macros
- Fix multi-line function indentation
- Use get_instance_private()
gtksourceview/gtksourceautocleanups.h | 1 -
gtksourceview/gtksourceprintcompositor.c | 952 +++++++++++++++++--------------
gtksourceview/gtksourceprintcompositor.h | 216 +++----
3 files changed, 600 insertions(+), 569 deletions(-)
---
diff --git a/gtksourceview/gtksourceautocleanups.h b/gtksourceview/gtksourceautocleanups.h
index 919b484f..c2aebf57 100644
--- a/gtksourceview/gtksourceautocleanups.h
+++ b/gtksourceview/gtksourceautocleanups.h
@@ -28,7 +28,6 @@ G_BEGIN_DECLS
#ifndef __GI_SCANNER__
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourcePrintCompositor, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceSearchContext, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceSearchSettings, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceSpaceDrawer, g_object_unref)
diff --git a/gtksourceview/gtksourceprintcompositor.c b/gtksourceview/gtksourceprintcompositor.c
index f152cfba..0bc23b27 100644
--- a/gtksourceview/gtksourceprintcompositor.c
+++ b/gtksourceview/gtksourceprintcompositor.c
@@ -102,7 +102,7 @@ typedef enum _PaginatorState
DONE
} PaginatorState;
-struct _GtkSourcePrintCompositorPrivate
+typedef struct
{
GtkSourceBuffer *buffer;
@@ -174,7 +174,7 @@ struct _GtkSourcePrintCompositorPrivate
PangoLanguage *language; /* must not be freed */
GtkTextMark *pagination_mark;
-};
+} GtkSourcePrintCompositorPrivate;
enum
{
@@ -199,7 +199,8 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkSourcePrintCompositor, gtk_source_print_composito
#define POINTS_PER_INCH 72
static gdouble
-convert_to_mm (gdouble len, GtkUnit unit)
+convert_to_mm (gdouble len,
+ GtkUnit unit)
{
switch (unit)
{
@@ -220,7 +221,8 @@ convert_to_mm (gdouble len, GtkUnit unit)
}
static gdouble
-convert_from_mm (gdouble len, GtkUnit unit)
+convert_from_mm (gdouble len,
+ GtkUnit unit)
{
switch (unit)
{
@@ -242,16 +244,17 @@ convert_from_mm (gdouble len, GtkUnit unit)
static void
gtk_source_print_compositor_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GtkSourcePrintCompositor *compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
switch (prop_id)
{
case PROP_BUFFER:
- g_value_set_object (value, compositor->priv->buffer);
+ g_value_set_object (value, priv->buffer);
break;
case PROP_TAB_WIDTH:
g_value_set_uint (value,
@@ -305,16 +308,17 @@ gtk_source_print_compositor_get_property (GObject *object,
static void
gtk_source_print_compositor_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GtkSourcePrintCompositor *compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
switch (prop_id)
{
case PROP_BUFFER:
- compositor->priv->buffer = GTK_SOURCE_BUFFER (g_value_dup_object (value));
+ priv->buffer = GTK_SOURCE_BUFFER (g_value_dup_object (value));
break;
case PROP_TAB_WIDTH:
gtk_source_print_compositor_set_tab_width (compositor,
@@ -364,42 +368,41 @@ gtk_source_print_compositor_set_property (GObject *object,
static void
gtk_source_print_compositor_finalize (GObject *object)
{
- GtkSourcePrintCompositor *compositor;
-
- compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositor *compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
- if (compositor->priv->pages != NULL)
- g_array_free (compositor->priv->pages, TRUE);
+ if (priv->pages != NULL)
+ g_array_free (priv->pages, TRUE);
- if (compositor->priv->layout != NULL)
- g_object_unref (compositor->priv->layout);
+ if (priv->layout != NULL)
+ g_object_unref (priv->layout);
- if (compositor->priv->line_numbers_layout != NULL)
- g_object_unref (compositor->priv->line_numbers_layout);
+ if (priv->line_numbers_layout != NULL)
+ g_object_unref (priv->line_numbers_layout);
- if (compositor->priv->header_layout != NULL)
- g_object_unref (compositor->priv->header_layout);
+ if (priv->header_layout != NULL)
+ g_object_unref (priv->header_layout);
- if (compositor->priv->footer_layout != NULL)
- g_object_unref (compositor->priv->footer_layout);
+ if (priv->footer_layout != NULL)
+ g_object_unref (priv->footer_layout);
- pango_font_description_free (compositor->priv->body_font);
+ pango_font_description_free (priv->body_font);
- if (compositor->priv->line_numbers_font != NULL)
- pango_font_description_free (compositor->priv->line_numbers_font);
+ if (priv->line_numbers_font != NULL)
+ pango_font_description_free (priv->line_numbers_font);
- if (compositor->priv->header_font != NULL)
- pango_font_description_free (compositor->priv->header_font);
+ if (priv->header_font != NULL)
+ pango_font_description_free (priv->header_font);
- if (compositor->priv->footer_font != NULL)
- pango_font_description_free (compositor->priv->footer_font);
+ if (priv->footer_font != NULL)
+ pango_font_description_free (priv->footer_font);
- g_free (compositor->priv->header_format_left);
- g_free (compositor->priv->header_format_right);
- g_free (compositor->priv->header_format_center);
- g_free (compositor->priv->footer_format_left);
- g_free (compositor->priv->footer_format_right);
- g_free (compositor->priv->footer_format_center);
+ g_free (priv->header_format_left);
+ g_free (priv->header_format_right);
+ g_free (priv->header_format_center);
+ g_free (priv->footer_format_left);
+ g_free (priv->footer_format_right);
+ g_free (priv->footer_format_center);
G_OBJECT_CLASS (gtk_source_print_compositor_parent_class)->finalize (object);
}
@@ -407,11 +410,10 @@ gtk_source_print_compositor_finalize (GObject *object)
static void
gtk_source_print_compositor_dispose (GObject *object)
{
- GtkSourcePrintCompositor *compositor;
-
- compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositor *compositor = GTK_SOURCE_PRINT_COMPOSITOR (object);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
- g_clear_object (&compositor->priv->buffer);
+ g_clear_object (&priv->buffer);
G_OBJECT_CLASS (gtk_source_print_compositor_parent_class)->dispose (object);
}
@@ -689,11 +691,7 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
static void
gtk_source_print_compositor_init (GtkSourcePrintCompositor *compositor)
{
- GtkSourcePrintCompositorPrivate *priv;
-
- priv = gtk_source_print_compositor_get_instance_private (compositor);
-
- compositor->priv = priv;
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
priv->buffer = NULL;
@@ -791,6 +789,7 @@ gtk_source_print_compositor_new_from_view (GtkSourceView *view)
PangoContext *pango_context;
PangoFontDescription* font_desc;
GtkSourcePrintCompositor *compositor;
+ GtkSourcePrintCompositorPrivate *priv;
g_return_val_if_fail (GTK_SOURCE_IS_VIEW (view), NULL);
g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))), NULL);
@@ -805,13 +804,14 @@ gtk_source_print_compositor_new_from_view (GtkSourceView *view)
"wrap-mode", gtk_text_view_get_wrap_mode (GTK_TEXT_VIEW (view)),
"print-line-numbers", (gtk_source_view_get_show_line_numbers (view) ==
FALSE) ? 0 : 1,
NULL));
+ priv = gtk_source_print_compositor_get_instance_private (compositor);
/* Set the body font directly since the property get a name while body_font is a PangoFontDescription
*/
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (view));
font_desc = pango_context_get_font_description (pango_context);
- compositor->priv->body_font = pango_font_description_copy (font_desc);
+ priv->body_font = pango_font_description_copy (font_desc);
g_object_notify (G_OBJECT (compositor), "body-font-name"); /* FIXME: is this needed? */
return compositor;
@@ -832,9 +832,11 @@ gtk_source_print_compositor_new_from_view (GtkSourceView *view)
GtkSourceBuffer *
gtk_source_print_compositor_get_buffer (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), NULL);
- return compositor->priv->buffer;
+ return priv->buffer;
}
/**
@@ -851,16 +853,18 @@ gtk_source_print_compositor_get_buffer (GtkSourcePrintCompositor *compositor)
*/
void
gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor *compositor,
- guint width)
+ guint width)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
g_return_if_fail (width > 0 && width <= MAX_TAB_WIDTH);
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
- if (width == compositor->priv->tab_width)
+ if (width == priv->tab_width)
return;
- compositor->priv->tab_width = width;
+ priv->tab_width = width;
g_object_notify (G_OBJECT (compositor), "tab-width");
}
@@ -878,9 +882,11 @@ gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor *compositor,
guint
gtk_source_print_compositor_get_tab_width (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), DEFAULT_TAB_WIDTH);
- return compositor->priv->tab_width;
+ return priv->tab_width;
}
/**
@@ -897,15 +903,17 @@ gtk_source_print_compositor_get_tab_width (GtkSourcePrintCompositor *compositor)
*/
void
gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor *compositor,
- GtkWrapMode wrap_mode)
+ GtkWrapMode wrap_mode)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
- if (wrap_mode == compositor->priv->wrap_mode)
+ if (wrap_mode == priv->wrap_mode)
return;
- compositor->priv->wrap_mode = wrap_mode;
+ priv->wrap_mode = wrap_mode;
g_object_notify (G_OBJECT (compositor), "wrap-mode");
}
@@ -923,9 +931,11 @@ gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor *compositor,
GtkWrapMode
gtk_source_print_compositor_get_wrap_mode (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), GTK_WRAP_NONE);
- return compositor->priv->wrap_mode;
+ return priv->wrap_mode;
}
/**
@@ -943,17 +953,19 @@ gtk_source_print_compositor_get_wrap_mode (GtkSourcePrintCompositor *compositor)
**/
void
gtk_source_print_compositor_set_highlight_syntax (GtkSourcePrintCompositor *compositor,
- gboolean highlight)
+ gboolean highlight)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
highlight = (highlight != FALSE);
- if (highlight == compositor->priv->highlight_syntax)
+ if (highlight == priv->highlight_syntax)
return;
- compositor->priv->highlight_syntax = highlight;
+ priv->highlight_syntax = highlight;
g_object_notify (G_OBJECT (compositor), "highlight-syntax");
}
@@ -973,9 +985,11 @@ gtk_source_print_compositor_set_highlight_syntax (GtkSourcePrintCompositor *comp
gboolean
gtk_source_print_compositor_get_highlight_syntax (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), FALSE);
- return compositor->priv->highlight_syntax;
+ return priv->highlight_syntax;
}
/**
@@ -996,16 +1010,18 @@ gtk_source_print_compositor_get_highlight_syntax (GtkSourcePrintCompositor *comp
**/
void
gtk_source_print_compositor_set_print_line_numbers (GtkSourcePrintCompositor *compositor,
- guint interval)
+ guint interval)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
g_return_if_fail (interval <= 100);
- if (interval == compositor->priv->print_line_numbers)
+ if (interval == priv->print_line_numbers)
return;
- compositor->priv->print_line_numbers = interval;
+ priv->print_line_numbers = interval;
g_object_notify (G_OBJECT (compositor), "print-line-numbers");
}
@@ -1030,17 +1046,19 @@ gtk_source_print_compositor_set_print_line_numbers (GtkSourcePrintCompositor *co
**/
void
gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor *compositor,
- gboolean print)
+ gboolean print)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
print = (print != FALSE);
- if (print == compositor->priv->print_header)
+ if (print == priv->print_header)
return;
- compositor->priv->print_header = print;
+ priv->print_header = print;
g_object_notify (G_OBJECT (compositor), "print-header");
}
@@ -1061,9 +1079,11 @@ gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor *composit
gboolean
gtk_source_print_compositor_get_print_header (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), FALSE);
- return compositor->priv->print_header;
+ return priv->print_header;
}
/**
@@ -1086,17 +1106,19 @@ gtk_source_print_compositor_get_print_header (GtkSourcePrintCompositor *composit
**/
void
gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor *compositor,
- gboolean print)
+ gboolean print)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
print = (print != FALSE);
- if (print == compositor->priv->print_footer)
+ if (print == priv->print_footer)
return;
- compositor->priv->print_footer = print;
+ priv->print_footer = print;
g_object_notify (G_OBJECT (compositor), "print-footer");
}
@@ -1117,9 +1139,11 @@ gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor *composit
gboolean
gtk_source_print_compositor_get_print_footer (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), FALSE);
- return compositor->priv->print_footer;
+ return priv->print_footer;
}
/**
@@ -1156,24 +1180,26 @@ gtk_source_print_compositor_get_print_footer (GtkSourcePrintCompositor *composit
**/
void
gtk_source_print_compositor_set_header_format (GtkSourcePrintCompositor *compositor,
- gboolean separator,
- const gchar *left,
- const gchar *center,
- const gchar *right)
+ gboolean separator,
+ const gchar *left,
+ const gchar *center,
+ const gchar *right)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
/* FIXME: validate given strings? */
- g_free (compositor->priv->header_format_left);
- g_free (compositor->priv->header_format_center);
- g_free (compositor->priv->header_format_right);
+ g_free (priv->header_format_left);
+ g_free (priv->header_format_center);
+ g_free (priv->header_format_right);
- compositor->priv->header_separator = separator;
+ priv->header_separator = separator;
- compositor->priv->header_format_left = g_strdup (left);
- compositor->priv->header_format_center = g_strdup (center);
- compositor->priv->header_format_right = g_strdup (right);
+ priv->header_format_left = g_strdup (left);
+ priv->header_format_center = g_strdup (center);
+ priv->header_format_right = g_strdup (right);
}
/**
@@ -1191,24 +1217,26 @@ gtk_source_print_compositor_set_header_format (GtkSourcePrintCompositor *composi
**/
void
gtk_source_print_compositor_set_footer_format (GtkSourcePrintCompositor *compositor,
- gboolean separator,
- const gchar *left,
- const gchar *center,
- const gchar *right)
+ gboolean separator,
+ const gchar *left,
+ const gchar *center,
+ const gchar *right)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
/* FIXME: validate given strings? */
- g_free (compositor->priv->footer_format_left);
- g_free (compositor->priv->footer_format_center);
- g_free (compositor->priv->footer_format_right);
+ g_free (priv->footer_format_left);
+ g_free (priv->footer_format_center);
+ g_free (priv->footer_format_right);
- compositor->priv->footer_separator = separator;
+ priv->footer_separator = separator;
- compositor->priv->footer_format_left = g_strdup (left);
- compositor->priv->footer_format_center = g_strdup (center);
- compositor->priv->footer_format_right = g_strdup (right);
+ priv->footer_format_left = g_strdup (left);
+ priv->footer_format_center = g_strdup (center);
+ priv->footer_format_right = g_strdup (right);
}
/**
@@ -1226,24 +1254,27 @@ gtk_source_print_compositor_set_footer_format (GtkSourcePrintCompositor *composi
guint
gtk_source_print_compositor_get_print_line_numbers (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0);
- return compositor->priv->print_line_numbers;
+ return priv->print_line_numbers;
}
static gboolean
set_font_description_from_name (GtkSourcePrintCompositor *compositor,
- PangoFontDescription **font,
- const gchar *font_name)
+ PangoFontDescription **font,
+ const gchar *font_name)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
PangoFontDescription *new;
if (font_name != NULL)
new = pango_font_description_from_string (font_name);
else
{
- g_return_val_if_fail (compositor->priv->body_font != NULL, FALSE);
- new = pango_font_description_copy (compositor->priv->body_font);
+ g_return_val_if_fail (priv->body_font != NULL, FALSE);
+ new = pango_font_description_copy (priv->body_font);
}
if (*font == NULL || !pango_font_description_equal (*font, new))
@@ -1281,14 +1312,16 @@ set_font_description_from_name (GtkSourcePrintCompositor *compositor,
*/
void
gtk_source_print_compositor_set_body_font_name (GtkSourcePrintCompositor *compositor,
- const gchar *font_name)
+ const gchar *font_name)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
g_return_if_fail (font_name != NULL);
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
if (set_font_description_from_name (compositor,
- &compositor->priv->body_font,
+ &priv->body_font,
font_name))
{
g_object_notify (G_OBJECT (compositor), "body-font-name");
@@ -1310,9 +1343,11 @@ gtk_source_print_compositor_set_body_font_name (GtkSourcePrintCompositor *compos
gchar *
gtk_source_print_compositor_get_body_font_name (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), NULL);
- return pango_font_description_to_string (compositor->priv->body_font);
+ return pango_font_description_to_string (priv->body_font);
}
/**
@@ -1336,14 +1371,16 @@ gtk_source_print_compositor_get_body_font_name (GtkSourcePrintCompositor *compos
*/
void
gtk_source_print_compositor_set_line_numbers_font_name (GtkSourcePrintCompositor *compositor,
- const gchar *font_name)
+ const gchar *font_name)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
g_return_if_fail (font_name != NULL);
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
if (set_font_description_from_name (compositor,
- &compositor->priv->line_numbers_font,
+ &priv->line_numbers_font,
font_name))
{
g_object_notify (G_OBJECT (compositor), "line-numbers-font-name");
@@ -1365,15 +1402,17 @@ gtk_source_print_compositor_set_line_numbers_font_name (GtkSourcePrintCompositor
gchar *
gtk_source_print_compositor_get_line_numbers_font_name (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), NULL);
- if (compositor->priv->line_numbers_font == NULL)
+ if (priv->line_numbers_font == NULL)
{
- g_return_val_if_fail (compositor->priv->body_font != NULL, NULL);
- compositor->priv->line_numbers_font = pango_font_description_copy
(compositor->priv->body_font);
+ g_return_val_if_fail (priv->body_font != NULL, NULL);
+ priv->line_numbers_font = pango_font_description_copy (priv->body_font);
}
- return pango_font_description_to_string (compositor->priv->line_numbers_font);
+ return pango_font_description_to_string (priv->line_numbers_font);
}
/**
@@ -1397,14 +1436,16 @@ gtk_source_print_compositor_get_line_numbers_font_name (GtkSourcePrintCompositor
*/
void
gtk_source_print_compositor_set_header_font_name (GtkSourcePrintCompositor *compositor,
- const gchar *font_name)
+ const gchar *font_name)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
g_return_if_fail (font_name != NULL);
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
if (set_font_description_from_name (compositor,
- &compositor->priv->header_font,
+ &priv->header_font,
font_name))
{
@@ -1427,15 +1468,17 @@ gtk_source_print_compositor_set_header_font_name (GtkSourcePrintCompositor *comp
gchar *
gtk_source_print_compositor_get_header_font_name (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), NULL);
- if (compositor->priv->header_font == NULL)
+ if (priv->header_font == NULL)
{
- g_return_val_if_fail (compositor->priv->body_font != NULL, NULL);
- compositor->priv->header_font = pango_font_description_copy (compositor->priv->body_font);
+ g_return_val_if_fail (priv->body_font != NULL, NULL);
+ priv->header_font = pango_font_description_copy (priv->body_font);
}
- return pango_font_description_to_string (compositor->priv->header_font);
+ return pango_font_description_to_string (priv->header_font);
}
/**
@@ -1459,14 +1502,16 @@ gtk_source_print_compositor_get_header_font_name (GtkSourcePrintCompositor *comp
*/
void
gtk_source_print_compositor_set_footer_font_name (GtkSourcePrintCompositor *compositor,
- const gchar *font_name)
+ const gchar *font_name)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
g_return_if_fail (font_name != NULL);
- g_return_if_fail (compositor->priv->state == INIT);
+ g_return_if_fail (priv->state == INIT);
if (set_font_description_from_name (compositor,
- &compositor->priv->footer_font,
+ &priv->footer_font,
font_name))
{
@@ -1489,15 +1534,17 @@ gtk_source_print_compositor_set_footer_font_name (GtkSourcePrintCompositor *comp
gchar *
gtk_source_print_compositor_get_footer_font_name (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), NULL);
- if (compositor->priv->footer_font == NULL)
+ if (priv->footer_font == NULL)
{
- g_return_val_if_fail (compositor->priv->body_font != NULL, NULL);
- compositor->priv->footer_font = pango_font_description_copy (compositor->priv->body_font);
+ g_return_val_if_fail (priv->body_font != NULL, NULL);
+ priv->footer_font = pango_font_description_copy (priv->body_font);
}
- return pango_font_description_to_string (compositor->priv->footer_font);
+ return pango_font_description_to_string (priv->footer_font);
}
/**
@@ -1512,12 +1559,14 @@ gtk_source_print_compositor_get_footer_font_name (GtkSourcePrintCompositor *comp
*/
void
gtk_source_print_compositor_set_top_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit)
+ gdouble margin,
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- compositor->priv->margin_top = convert_to_mm (margin, unit);
+ priv->margin_top = convert_to_mm (margin, unit);
}
/**
@@ -1533,11 +1582,13 @@ gtk_source_print_compositor_set_top_margin (GtkSourcePrintCompositor *compositor
*/
gdouble
gtk_source_print_compositor_get_top_margin (GtkSourcePrintCompositor *compositor,
- GtkUnit unit)
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0);
- return convert_from_mm (compositor->priv->margin_top, unit);
+ return convert_from_mm (priv->margin_top, unit);
}
/**
@@ -1552,12 +1603,14 @@ gtk_source_print_compositor_get_top_margin (GtkSourcePrintCompositor *compositor
*/
void
gtk_source_print_compositor_set_bottom_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit)
+ gdouble margin,
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- compositor->priv->margin_bottom = convert_to_mm (margin, unit);
+ priv->margin_bottom = convert_to_mm (margin, unit);
}
/**
@@ -1573,11 +1626,13 @@ gtk_source_print_compositor_set_bottom_margin (GtkSourcePrintCompositor *composi
*/
gdouble
gtk_source_print_compositor_get_bottom_margin (GtkSourcePrintCompositor *compositor,
- GtkUnit unit)
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0);
- return convert_from_mm (compositor->priv->margin_bottom, unit);
+ return convert_from_mm (priv->margin_bottom, unit);
}
/**
@@ -1592,12 +1647,14 @@ gtk_source_print_compositor_get_bottom_margin (GtkSourcePrintCompositor *composi
*/
void
gtk_source_print_compositor_set_left_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit)
+ gdouble margin,
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- compositor->priv->margin_left = convert_to_mm (margin, unit);
+ priv->margin_left = convert_to_mm (margin, unit);
}
/**
@@ -1613,11 +1670,13 @@ gtk_source_print_compositor_set_left_margin (GtkSourcePrintCompositor *composito
*/
gdouble
gtk_source_print_compositor_get_left_margin (GtkSourcePrintCompositor *compositor,
- GtkUnit unit)
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0);
- return convert_from_mm (compositor->priv->margin_left, unit);
+ return convert_from_mm (priv->margin_left, unit);
}
/**
@@ -1632,12 +1691,14 @@ gtk_source_print_compositor_get_left_margin (GtkSourcePrintCompositor *composito
*/
void
gtk_source_print_compositor_set_right_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit)
+ gdouble margin,
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor));
- compositor->priv->margin_right = convert_to_mm (margin, unit);
+ priv->margin_right = convert_to_mm (margin, unit);
}
/**
@@ -1653,11 +1714,13 @@ gtk_source_print_compositor_set_right_margin (GtkSourcePrintCompositor *composit
*/
gdouble
gtk_source_print_compositor_get_right_margin (GtkSourcePrintCompositor *compositor,
- GtkUnit unit)
+ GtkUnit unit)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0);
- return convert_from_mm (compositor->priv->margin_right, unit);
+ return convert_from_mm (priv->margin_right, unit);
}
/**
@@ -1673,14 +1736,16 @@ gtk_source_print_compositor_get_right_margin (GtkSourcePrintCompositor *composit
* Since: 2.2
*/
gint
-gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor *compositor)
+gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), -1);
- if (compositor->priv->state != DONE)
+ if (priv->state != DONE)
return -1;
- return compositor->priv->n_pages;
+ return priv->n_pages;
}
/* utility functions to deal with coordinates (returns) */
@@ -1688,12 +1753,13 @@ gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor *compositor)
static gdouble
get_text_x (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gdouble x;
- x = compositor->priv->real_margin_left;
+ x = priv->real_margin_left;
- if (compositor->priv->print_line_numbers)
- x += compositor->priv->line_numbers_width + NUMBERS_TEXT_SEPARATION;
+ if (priv->print_line_numbers)
+ x += priv->line_numbers_width + NUMBERS_TEXT_SEPARATION;
return x;
}
@@ -1701,9 +1767,10 @@ get_text_x (GtkSourcePrintCompositor *compositor)
static gdouble
get_text_y (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gdouble y;
- y = compositor->priv->real_margin_top + compositor->priv->header_height;
+ y = priv->real_margin_top + priv->header_height;
return y;
}
@@ -1711,9 +1778,10 @@ get_text_y (GtkSourcePrintCompositor *compositor)
static gdouble
get_line_numbers_x (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gdouble x;
- x = compositor->priv->real_margin_left;
+ x = priv->real_margin_left;
return x;
}
@@ -1721,14 +1789,15 @@ get_line_numbers_x (GtkSourcePrintCompositor *compositor)
static gdouble
get_text_width (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gdouble w;
- w = compositor->priv->paper_width -
- compositor->priv->real_margin_left -
- compositor->priv->real_margin_right;
+ w = priv->paper_width -
+ priv->real_margin_left -
+ priv->real_margin_right;
- if (compositor->priv->print_line_numbers)
- w -= (compositor->priv->line_numbers_width + NUMBERS_TEXT_SEPARATION);
+ if (priv->print_line_numbers)
+ w -= (priv->line_numbers_width + NUMBERS_TEXT_SEPARATION);
if (w < convert_from_mm (50, GTK_UNIT_POINTS)) {
g_warning ("Printable page width too little.");
@@ -1741,13 +1810,14 @@ get_text_width (GtkSourcePrintCompositor *compositor)
static gdouble
get_text_height (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
double h;
- h = compositor->priv->paper_height -
- compositor->priv->real_margin_top -
- compositor->priv->real_margin_bottom -
- compositor->priv->header_height -
- compositor->priv->footer_height;
+ h = priv->paper_height -
+ priv->real_margin_top -
+ priv->real_margin_bottom -
+ priv->header_height -
+ priv->footer_height;
if (h < convert_from_mm (50, GTK_UNIT_POINTS)) {
g_warning ("Printable page height too little.");
@@ -1760,29 +1830,34 @@ get_text_height (GtkSourcePrintCompositor *compositor)
static gboolean
is_header_to_print (GtkSourcePrintCompositor *compositor)
{
- return (compositor->priv->print_header &&
- ((compositor->priv->header_format_left != NULL) ||
- (compositor->priv->header_format_center != NULL) ||
- (compositor->priv->header_format_right != NULL)));
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ return (priv->print_header &&
+ ((priv->header_format_left != NULL) ||
+ (priv->header_format_center != NULL) ||
+ (priv->header_format_right != NULL)));
}
static gboolean
is_footer_to_print (GtkSourcePrintCompositor *compositor)
{
- return (compositor->priv->print_footer &&
- ((compositor->priv->footer_format_left != NULL) ||
- (compositor->priv->footer_format_center != NULL) ||
- (compositor->priv->footer_format_right != NULL)));
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ return (priv->print_footer &&
+ ((priv->footer_format_left != NULL) ||
+ (priv->footer_format_center != NULL) ||
+ (priv->footer_format_right != NULL)));
}
static void
set_layout_tab_width (GtkSourcePrintCompositor *compositor,
- PangoLayout *layout)
+ PangoLayout *layout)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gchar *str;
gint tab_width = 0;
- str = g_strnfill (compositor->priv->tab_width, ' ');
+ str = g_strnfill (priv->tab_width, ' ');
pango_layout_set_text (layout, str, -1);
g_free (str);
@@ -1806,15 +1881,16 @@ set_layout_tab_width (GtkSourcePrintCompositor *compositor,
static void
setup_pango_layouts (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
PangoLayout *layout;
/* Layout for the text */
layout = gtk_print_context_create_pango_layout (context);
- pango_layout_set_font_description (layout, compositor->priv->body_font);
+ pango_layout_set_font_description (layout, priv->body_font);
- switch (compositor->priv->wrap_mode)
+ switch (priv->wrap_mode)
{
case GTK_WRAP_CHAR:
pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
@@ -1841,21 +1917,21 @@ setup_pango_layouts (GtkSourcePrintCompositor *compositor,
set_layout_tab_width (compositor, layout);
- g_return_if_fail (compositor->priv->layout == NULL);
- compositor->priv->layout = layout;
+ g_return_if_fail (priv->layout == NULL);
+ priv->layout = layout;
/* Layout for line numbers */
- if (compositor->priv->print_line_numbers > 0)
+ if (priv->print_line_numbers > 0)
{
layout = gtk_print_context_create_pango_layout (context);
- if (compositor->priv->line_numbers_font == NULL)
- compositor->priv->line_numbers_font = pango_font_description_copy_static
(compositor->priv->body_font);
- pango_layout_set_font_description (layout, compositor->priv->line_numbers_font);
+ if (priv->line_numbers_font == NULL)
+ priv->line_numbers_font = pango_font_description_copy_static (priv->body_font);
+ pango_layout_set_font_description (layout, priv->line_numbers_font);
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
- g_return_if_fail (compositor->priv->line_numbers_layout == NULL);
- compositor->priv->line_numbers_layout = layout;
+ g_return_if_fail (priv->line_numbers_layout == NULL);
+ priv->line_numbers_layout = layout;
}
/* Layout for header */
@@ -1863,13 +1939,13 @@ setup_pango_layouts (GtkSourcePrintCompositor *compositor,
{
layout = gtk_print_context_create_pango_layout (context);
- if (compositor->priv->header_font == NULL)
- compositor->priv->header_font = pango_font_description_copy_static
(compositor->priv->body_font);
+ if (priv->header_font == NULL)
+ priv->header_font = pango_font_description_copy_static (priv->body_font);
- pango_layout_set_font_description (layout, compositor->priv->header_font);
+ pango_layout_set_font_description (layout, priv->header_font);
- g_return_if_fail (compositor->priv->header_layout == NULL);
- compositor->priv->header_layout = layout;
+ g_return_if_fail (priv->header_layout == NULL);
+ priv->header_layout = layout;
}
/* Layout for footer */
@@ -1877,20 +1953,21 @@ setup_pango_layouts (GtkSourcePrintCompositor *compositor,
{
layout = gtk_print_context_create_pango_layout (context);
- if (compositor->priv->footer_font == NULL)
- compositor->priv->footer_font = pango_font_description_copy_static
(compositor->priv->body_font);
+ if (priv->footer_font == NULL)
+ priv->footer_font = pango_font_description_copy_static (priv->body_font);
- pango_layout_set_font_description (layout, compositor->priv->footer_font);
+ pango_layout_set_font_description (layout, priv->footer_font);
- g_return_if_fail (compositor->priv->footer_layout == NULL);
- compositor->priv->footer_layout = layout;
+ g_return_if_fail (priv->footer_layout == NULL);
+ priv->footer_layout = layout;
}
}
static gchar *
evaluate_format_string (GtkSourcePrintCompositor *compositor,
- const gchar *format)
+ const gchar *format)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
GDateTime *now;
GString *eval;
gchar *eval_str, *retval;
@@ -1908,9 +1985,9 @@ evaluate_format_string (GtkSourcePrintCompositor *compositor,
format = g_utf8_next_char (format);
ch = g_utf8_get_char (format);
if (ch == 'N')
- g_string_append_printf (eval, "%d", compositor->priv->current_page + 1);
+ g_string_append_printf (eval, "%d", priv->current_page + 1);
else if (ch == 'Q')
- g_string_append_printf (eval, "%d", compositor->priv->n_pages);
+ g_string_append_printf (eval, "%d", priv->n_pages);
else
{
g_string_append_c (eval, '%');
@@ -1964,55 +2041,57 @@ get_n_digits (guint n)
static void
calculate_line_numbers_layout_size (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gint line_count;
gint n_digits;
gchar *str;
- if (compositor->priv->print_line_numbers == 0)
+ if (priv->print_line_numbers == 0)
{
- compositor->priv->line_numbers_width = 0.0;
- compositor->priv->line_numbers_height = 0.0;
+ priv->line_numbers_width = 0.0;
+ priv->line_numbers_height = 0.0;
DEBUG ({
g_debug ("line_numbers_width: %f points (%f mm)",
- compositor->priv->line_numbers_width,
- convert_to_mm (compositor->priv->line_numbers_width, GTK_UNIT_POINTS));
+ priv->line_numbers_width,
+ convert_to_mm (priv->line_numbers_width, GTK_UNIT_POINTS));
g_debug ("line_numbers_height: %f points (%f mm)",
- compositor->priv->line_numbers_height,
- convert_to_mm (compositor->priv->line_numbers_height, GTK_UNIT_POINTS));
+ priv->line_numbers_height,
+ convert_to_mm (priv->line_numbers_height, GTK_UNIT_POINTS));
});
return;
}
- line_count = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (compositor->priv->buffer));
+ line_count = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (priv->buffer));
n_digits = get_n_digits (line_count);
str = g_strnfill (n_digits, '9');
- pango_layout_set_text (compositor->priv->line_numbers_layout, str, -1);
+ pango_layout_set_text (priv->line_numbers_layout, str, -1);
g_free (str);
- get_layout_size (compositor->priv->line_numbers_layout,
- &compositor->priv->line_numbers_width,
- &compositor->priv->line_numbers_height);
+ get_layout_size (priv->line_numbers_layout,
+ &priv->line_numbers_width,
+ &priv->line_numbers_height);
DEBUG ({
g_debug ("line_numbers_width: %f points (%f mm)",
- compositor->priv->line_numbers_width,
- convert_to_mm (compositor->priv->line_numbers_width, GTK_UNIT_POINTS));
+ priv->line_numbers_width,
+ convert_to_mm (priv->line_numbers_width, GTK_UNIT_POINTS));
g_debug ("line_numbers_height: %f points (%f mm)",
- compositor->priv->line_numbers_height,
- convert_to_mm (compositor->priv->line_numbers_height, GTK_UNIT_POINTS));
+ priv->line_numbers_height,
+ convert_to_mm (priv->line_numbers_height, GTK_UNIT_POINTS));
});
}
static gdouble
calculate_header_footer_height (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context,
- PangoFontDescription *font,
- gdouble *d)
+ GtkPrintContext *context,
+ PangoFontDescription *font,
+ gdouble *d)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
PangoContext *pango_context;
PangoFontMetrics* font_metrics;
gdouble ascent;
@@ -2023,7 +2102,7 @@ calculate_header_footer_height (GtkSourcePrintCompositor *compositor,
font_metrics = pango_context_get_metrics (pango_context,
font,
- compositor->priv->language);
+ priv->language);
ascent = (gdouble) pango_font_metrics_get_ascent (font_metrics) / PANGO_SCALE;
descent = (gdouble) pango_font_metrics_get_descent (font_metrics) / PANGO_SCALE;
@@ -2039,123 +2118,128 @@ calculate_header_footer_height (GtkSourcePrintCompositor *compositor,
static void
calculate_header_height (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
if (!is_header_to_print(compositor))
{
- compositor->priv->header_height = 0.0;
+ priv->header_height = 0.0;
DEBUG ({
g_debug ("header_height: %f points (%f mm)",
- compositor->priv->header_height,
- convert_to_mm (compositor->priv->header_height, GTK_UNIT_POINTS));
+ priv->header_height,
+ convert_to_mm (priv->header_height, GTK_UNIT_POINTS));
});
return;
}
- g_return_if_fail (compositor->priv->header_font != NULL);
+ g_return_if_fail (priv->header_font != NULL);
- compositor->priv->header_height = calculate_header_footer_height (compositor,
+ priv->header_height = calculate_header_footer_height (compositor,
context,
- compositor->priv->header_font,
+ priv->header_font,
NULL);
DEBUG ({
g_debug ("header_height: %f points (%f mm)",
- compositor->priv->header_height,
- convert_to_mm (compositor->priv->header_height, GTK_UNIT_POINTS));
+ priv->header_height,
+ convert_to_mm (priv->header_height, GTK_UNIT_POINTS));
});
}
static void
calculate_footer_height (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
if (!is_footer_to_print (compositor))
{
- compositor->priv->footer_height = 0.0;
+ priv->footer_height = 0.0;
DEBUG ({
g_debug ("footer_height: %f points (%f mm)",
- compositor->priv->footer_height,
- convert_to_mm (compositor->priv->footer_height, GTK_UNIT_POINTS));
+ priv->footer_height,
+ convert_to_mm (priv->footer_height, GTK_UNIT_POINTS));
});
return;
}
- if (compositor->priv->footer_font == NULL)
- compositor->priv->footer_font = pango_font_description_copy_static
(compositor->priv->body_font);
+ if (priv->footer_font == NULL)
+ priv->footer_font = pango_font_description_copy_static (priv->body_font);
- compositor->priv->footer_height = calculate_header_footer_height (compositor,
+ priv->footer_height = calculate_header_footer_height (compositor,
context,
- compositor->priv->footer_font,
-
&compositor->priv->footer_font_descent);
+ priv->footer_font,
+ &priv->footer_font_descent);
DEBUG ({
g_debug ("footer_height: %f points (%f mm)",
- compositor->priv->footer_height,
- convert_to_mm (compositor->priv->footer_height, GTK_UNIT_POINTS));
+ priv->footer_height,
+ convert_to_mm (priv->footer_height, GTK_UNIT_POINTS));
});
}
static void
calculate_page_size_and_margins (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
GtkPageSetup *page_setup;
/* calculate_line_numbers_layout_size and calculate_header_footer_height
functions must be called before calculate_page_size_and_margins */
- g_return_if_fail (compositor->priv->line_numbers_width >= 0.0);
- g_return_if_fail (compositor->priv->header_height >= 0.0);
- g_return_if_fail (compositor->priv->footer_height >= 0.0);
+ g_return_if_fail (priv->line_numbers_width >= 0.0);
+ g_return_if_fail (priv->header_height >= 0.0);
+ g_return_if_fail (priv->footer_height >= 0.0);
page_setup = gtk_print_context_get_page_setup (context);
- compositor->priv->page_margin_top = gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_POINTS);
- compositor->priv->page_margin_left = gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_POINTS);
+ priv->page_margin_top = gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_POINTS);
+ priv->page_margin_left = gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_POINTS);
/* Calculate real margins: the margins specified in the GtkPageSetup object are the "print margins".
they are used to determine the minimal size for the layout margins. */
- compositor->priv->real_margin_top = MAX (compositor->priv->page_margin_top,
- convert_from_mm (compositor->priv->margin_top,
GTK_UNIT_POINTS));
- compositor->priv->real_margin_bottom = MAX (gtk_page_setup_get_bottom_margin (page_setup,
GTK_UNIT_POINTS),
- convert_from_mm (compositor->priv->margin_bottom,
GTK_UNIT_POINTS));
- compositor->priv->real_margin_left = MAX (compositor->priv->page_margin_left,
- convert_from_mm (compositor->priv->margin_left,
GTK_UNIT_POINTS));
- compositor->priv->real_margin_right = MAX (gtk_page_setup_get_right_margin (page_setup,
GTK_UNIT_POINTS),
- convert_from_mm (compositor->priv->margin_right,
GTK_UNIT_POINTS));
+ priv->real_margin_top = MAX (priv->page_margin_top,
+ convert_from_mm (priv->margin_top, GTK_UNIT_POINTS));
+ priv->real_margin_bottom = MAX (gtk_page_setup_get_bottom_margin (page_setup, GTK_UNIT_POINTS),
+ convert_from_mm (priv->margin_bottom, GTK_UNIT_POINTS));
+ priv->real_margin_left = MAX (priv->page_margin_left,
+ convert_from_mm (priv->margin_left, GTK_UNIT_POINTS));
+ priv->real_margin_right = MAX (gtk_page_setup_get_right_margin (page_setup, GTK_UNIT_POINTS),
+ convert_from_mm (priv->margin_right, GTK_UNIT_POINTS));
DEBUG ({
g_debug ("real_margin_top: %f points (%f mm)",
- compositor->priv->real_margin_top,
- convert_to_mm (compositor->priv->real_margin_top, GTK_UNIT_POINTS));
+ priv->real_margin_top,
+ convert_to_mm (priv->real_margin_top, GTK_UNIT_POINTS));
g_debug ("real_margin_bottom: %f points (%f mm)",
- compositor->priv->real_margin_bottom,
- convert_to_mm (compositor->priv->real_margin_bottom, GTK_UNIT_POINTS));
+ priv->real_margin_bottom,
+ convert_to_mm (priv->real_margin_bottom, GTK_UNIT_POINTS));
g_debug ("real_margin_left: %f points (%f mm)",
- compositor->priv->real_margin_left,
- convert_to_mm (compositor->priv->real_margin_left, GTK_UNIT_POINTS));
+ priv->real_margin_left,
+ convert_to_mm (priv->real_margin_left, GTK_UNIT_POINTS));
g_debug ("real_margin_righ: %f points (%f mm)",
- compositor->priv->real_margin_right,
- convert_to_mm (compositor->priv->real_margin_right, GTK_UNIT_POINTS));
+ priv->real_margin_right,
+ convert_to_mm (priv->real_margin_right, GTK_UNIT_POINTS));
});
- compositor->priv->paper_width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
- compositor->priv->paper_height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
+ priv->paper_width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_POINTS);
+ priv->paper_height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_POINTS);
DEBUG ({
gdouble text_width;
gdouble text_height;
g_debug ("paper_width: %f points (%f mm)",
- compositor->priv->paper_width,
- convert_to_mm (compositor->priv->paper_width, GTK_UNIT_POINTS));
+ priv->paper_width,
+ convert_to_mm (priv->paper_width, GTK_UNIT_POINTS));
g_debug ("paper_heigth: %f points (%f mm)",
- compositor->priv->paper_height,
- convert_to_mm (compositor->priv->paper_height, GTK_UNIT_POINTS));
+ priv->paper_height,
+ convert_to_mm (priv->paper_height, GTK_UNIT_POINTS));
text_width = get_text_width (compositor);
text_height = get_text_height (compositor);
g_debug ("text_width: %f points (%f mm)", text_width, convert_to_mm (text_width,
GTK_UNIT_POINTS));
@@ -2172,9 +2256,10 @@ static gboolean
ignore_tag (GtkSourcePrintCompositor *compositor,
GtkTextTag *tag)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
GtkTextTag *bm_tag;
- bm_tag = _gtk_source_buffer_get_bracket_match_tag (compositor->priv->buffer);
+ bm_tag = _gtk_source_buffer_get_bracket_match_tag (priv->buffer);
if ((bm_tag != NULL) && (tag == bm_tag))
return TRUE;
@@ -2183,8 +2268,8 @@ ignore_tag (GtkSourcePrintCompositor *compositor,
static GSList *
get_iter_attrs (GtkSourcePrintCompositor *compositor,
- GtkTextIter *iter,
- GtkTextIter *limit)
+ GtkTextIter *iter,
+ GtkTextIter *limit)
{
GSList *attrs = NULL;
GSList *tags;
@@ -2319,9 +2404,10 @@ is_empty_line (const gchar *text)
static void
layout_paragraph (GtkSourcePrintCompositor *compositor,
- GtkTextIter *start,
- GtkTextIter *end)
+ GtkTextIter *start,
+ GtkTextIter *end)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gchar *text;
text = gtk_text_iter_get_slice (start, end);
@@ -2333,22 +2419,22 @@ layout_paragraph (GtkSourcePrintCompositor *compositor,
if (gtk_text_iter_ends_line (start) ||
is_empty_line (text))
{
- pango_layout_set_text (compositor->priv->layout, " ", 1);
+ pango_layout_set_text (priv->layout, " ", 1);
g_free (text);
return;
}
- pango_layout_set_text (compositor->priv->layout, text, -1);
+ pango_layout_set_text (priv->layout, text, -1);
g_free (text);
- if (compositor->priv->highlight_syntax)
+ if (priv->highlight_syntax)
{
PangoAttrList *attr_list = NULL;
GtkTextIter segm_start, segm_end;
int start_index;
/* Make sure it is highlighted even if it was not shown yet */
- gtk_source_buffer_ensure_highlight (compositor->priv->buffer,
+ gtk_source_buffer_ensure_highlight (priv->buffer,
start,
end);
@@ -2386,7 +2472,7 @@ layout_paragraph (GtkSourcePrintCompositor *compositor,
segm_start = segm_end;
}
- pango_layout_set_attributes (compositor->priv->layout,
+ pango_layout_set_attributes (priv->layout,
attr_list);
if (attr_list)
@@ -2396,24 +2482,28 @@ layout_paragraph (GtkSourcePrintCompositor *compositor,
static gboolean
line_is_numbered (GtkSourcePrintCompositor *compositor,
- gint line_number)
+ gint line_number)
{
- return (compositor->priv->print_line_numbers > 0) &&
- ((line_number + 1) % compositor->priv->print_line_numbers == 0);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ return (priv->print_line_numbers > 0) &&
+ ((line_number + 1) % priv->print_line_numbers == 0);
}
static void
set_pango_layouts_width (GtkSourcePrintCompositor *compositor)
{
- g_return_if_fail (compositor->priv->layout != NULL);
- pango_layout_set_width (compositor->priv->layout,
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ g_return_if_fail (priv->layout != NULL);
+ pango_layout_set_width (priv->layout,
get_text_width (compositor) * PANGO_SCALE);
- if (compositor->priv->print_line_numbers)
+ if (priv->print_line_numbers)
{
- g_return_if_fail (compositor->priv->line_numbers_layout != NULL);
- pango_layout_set_width (compositor->priv->line_numbers_layout,
- compositor->priv->line_numbers_width * PANGO_SCALE);
+ g_return_if_fail (priv->line_numbers_layout != NULL);
+ pango_layout_set_width (priv->line_numbers_layout,
+ priv->line_numbers_width * PANGO_SCALE);
}
}
@@ -2494,8 +2584,9 @@ set_pango_layouts_width (GtkSourcePrintCompositor *compositor)
*/
gboolean
gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context)
+ GtkPrintContext *context)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
GtkTextIter start, end;
gint page_start_offset;
double text_height;
@@ -2507,10 +2598,10 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), TRUE);
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), TRUE);
- if (compositor->priv->state == DONE)
+ if (priv->state == DONE)
return TRUE;
- if (compositor->priv->state == INIT)
+ if (priv->state == INIT)
{
PROFILE ({
if (pagination_timer != NULL)
@@ -2519,9 +2610,9 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
pagination_timer = g_timer_new ();
});
- g_return_val_if_fail (compositor->priv->pages == NULL, TRUE);
+ g_return_val_if_fail (priv->pages == NULL, TRUE);
- compositor->priv->pages = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->pages = g_array_new (FALSE, FALSE, sizeof (gint));
setup_pango_layouts (compositor, context);
@@ -2534,37 +2625,37 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
/* Cannot be done when setting up layouts since we need the width */
set_pango_layouts_width (compositor);
- compositor->priv->state = PAGINATING;
+ priv->state = PAGINATING;
}
- g_return_val_if_fail (compositor->priv->state == PAGINATING, FALSE);
- g_return_val_if_fail (compositor->priv->layout != NULL, FALSE);
+ g_return_val_if_fail (priv->state == PAGINATING, FALSE);
+ g_return_val_if_fail (priv->layout != NULL, FALSE);
- if (compositor->priv->pagination_mark == NULL)
+ if (priv->pagination_mark == NULL)
{
- gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (compositor->priv->buffer), &start);
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (priv->buffer), &start);
- compositor->priv->pagination_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER
(compositor->priv->buffer),
+ priv->pagination_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (priv->buffer),
NULL,
&start,
TRUE);
/* add the first page start */
page_start_offset = gtk_text_iter_get_offset (&start);
- g_array_append_val (compositor->priv->pages, page_start_offset);
+ g_array_append_val (priv->pages, page_start_offset);
}
else
{
- gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (compositor->priv->buffer),
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->buffer),
&start,
- compositor->priv->pagination_mark);
+ priv->pagination_mark);
}
DEBUG ({
g_debug ("Start paginating at %d", gtk_text_iter_get_offset (&start));
});
- gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (compositor->priv->buffer), &end);
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (priv->buffer), &end);
cur_height = 0;
text_height = get_text_height (compositor);
@@ -2586,14 +2677,14 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
layout_paragraph (compositor, &start, &line_end);
- get_layout_size (compositor->priv->layout, NULL, &line_height);
+ get_layout_size (priv->layout, NULL, &line_height);
if (line_is_numbered (compositor, line_number))
{
- g_assert (compositor->priv->line_numbers_height > 0);
+ g_assert (priv->line_numbers_height > 0);
line_height = MAX (line_height,
- compositor->priv->line_numbers_height);
+ priv->line_numbers_height);
}
#define EPS (.1)
@@ -2601,8 +2692,8 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
{
/* if we have multiline paragraphs, see how much of
* it we can fit in the current page */
- if (compositor->priv->wrap_mode != GTK_WRAP_NONE &&
- pango_layout_get_line_count (compositor->priv->layout) > 1)
+ if (priv->wrap_mode != GTK_WRAP_NONE &&
+ pango_layout_get_line_count (priv->layout) > 1)
{
PangoLayoutIter *layout_iter;
PangoRectangle logical_rect;
@@ -2610,7 +2701,7 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
double part_height = 0;
gint idx;
- layout_iter = pango_layout_get_iter (compositor->priv->layout);
+ layout_iter = pango_layout_get_iter (priv->layout);
do
{
@@ -2622,7 +2713,7 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
if (is_first_line &&
line_is_numbered (compositor, line_number))
{
- layout_line_height = MAX
(compositor->priv->line_numbers_height,
+ layout_line_height = MAX (priv->line_numbers_height,
layout_line_height);
}
@@ -2648,8 +2739,8 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
page_start_offset = gtk_text_iter_get_offset (&start);
- gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (compositor->priv->buffer),
- compositor->priv->pagination_mark,
+ gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (priv->buffer),
+ priv->pagination_mark,
&start);
/* if the remainder fits on the next page, go
@@ -2670,8 +2761,8 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
{
page_start_offset = gtk_text_iter_get_offset (&start);
- gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (compositor->priv->buffer),
- compositor->priv->pagination_mark,
+ gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (priv->buffer),
+ priv->pagination_mark,
&start);
/* reset cur_height for the next page */
@@ -2680,7 +2771,7 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
}
/* store the start of the new page */
- g_array_append_val (compositor->priv->pages,
+ g_array_append_val (priv->pages,
page_start_offset);
++pages_count;
@@ -2707,26 +2798,26 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
DEBUG ({
int i;
- for (i = 0; i < compositor->priv->pages->len; i += 1)
+ for (i = 0; i < priv->pages->len; i += 1)
{
gint offset;
GtkTextIter iter;
- offset = g_array_index (compositor->priv->pages, int, i);
- gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER
(compositor->priv->buffer), &iter, offset);
+ offset = g_array_index (priv->pages, int, i);
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (priv->buffer), &iter,
offset);
g_debug (" page %d starts at line %d (offset %d)\n", i,
gtk_text_iter_get_line (&iter), offset);
}
});
- compositor->priv->state = DONE;
+ priv->state = DONE;
- compositor->priv->n_pages = compositor->priv->pages->len;
+ priv->n_pages = priv->pages->len;
/* Remove the pagination mark */
- gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (compositor->priv->buffer),
- compositor->priv->pagination_mark);
- compositor->priv->pagination_mark = NULL;
+ gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (priv->buffer),
+ priv->pagination_mark);
+ priv->pagination_mark = NULL;
}
return (done != FALSE);
@@ -2745,36 +2836,38 @@ gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
gdouble
gtk_source_print_compositor_get_pagination_progress (GtkSourcePrintCompositor *compositor)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
GtkTextIter current;
gint char_count;
g_return_val_if_fail (GTK_SOURCE_IS_PRINT_COMPOSITOR (compositor), 0.0);
- if (compositor->priv->state == INIT)
+ if (priv->state == INIT)
return 0.0;
- if (compositor->priv->state == DONE)
+ if (priv->state == DONE)
return 1.0;
- char_count = gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (compositor->priv->buffer));
+ char_count = gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (priv->buffer));
if (char_count == 0)
return 1.0;
- g_return_val_if_fail (compositor->priv->pagination_mark != NULL, 0.0);
+ g_return_val_if_fail (priv->pagination_mark != NULL, 0.0);
- gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (compositor->priv->buffer),
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (priv->buffer),
¤t,
- compositor->priv->pagination_mark);
+ priv->pagination_mark);
return (gdouble) gtk_text_iter_get_offset (¤t) / (gdouble) char_count;
}
static void
print_header_string (GtkSourcePrintCompositor *compositor,
- cairo_t *cr,
- PangoAlignment alignment,
- const gchar *format)
+ cairo_t *cr,
+ PangoAlignment alignment,
+ const gchar *format)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gchar *text;
text = evaluate_format_string (compositor, format);
@@ -2789,31 +2882,31 @@ print_header_string (GtkSourcePrintCompositor *compositor,
gdouble header_width;
gdouble x;
- header_width = compositor->priv->paper_width -
- compositor->priv->real_margin_left -
- compositor->priv->real_margin_right;
+ header_width = priv->paper_width -
+ priv->real_margin_left -
+ priv->real_margin_right;
- pango_layout_set_text (compositor->priv->header_layout, text, -1);
+ pango_layout_set_text (priv->header_layout, text, -1);
/* Print only the first line */
- iter = pango_layout_get_iter (compositor->priv->header_layout);
+ iter = pango_layout_get_iter (priv->header_layout);
baseline = (gdouble) pango_layout_iter_get_baseline (iter) / (gdouble) PANGO_SCALE;
- get_layout_size (compositor->priv->header_layout, &layout_width, &layout_height);
+ get_layout_size (priv->header_layout, &layout_width, &layout_height);
switch (alignment)
{
case PANGO_ALIGN_RIGHT:
- x = compositor->priv->real_margin_left + header_width - layout_width;
+ x = priv->real_margin_left + header_width - layout_width;
break;
case PANGO_ALIGN_CENTER:
- x = compositor->priv->real_margin_left + header_width / 2 - layout_width / 2;
+ x = priv->real_margin_left + header_width / 2 - layout_width / 2;
break;
case PANGO_ALIGN_LEFT:
default:
- x = compositor->priv->real_margin_left;
+ x = priv->real_margin_left;
break;
}
@@ -2824,7 +2917,7 @@ print_header_string (GtkSourcePrintCompositor *compositor,
cairo_set_source_rgb (cr, 0., 0., 1.);
cairo_rectangle (cr,
x,
- compositor->priv->real_margin_top,
+ priv->real_margin_top,
layout_width,
layout_height);
cairo_stroke (cr);
@@ -2836,7 +2929,7 @@ print_header_string (GtkSourcePrintCompositor *compositor,
cairo_move_to (cr,
x,
- compositor->priv->real_margin_top + baseline);
+ priv->real_margin_top + baseline);
pango_cairo_show_layout_line (cr, line);
@@ -2847,42 +2940,44 @@ print_header_string (GtkSourcePrintCompositor *compositor,
static void
print_header (GtkSourcePrintCompositor *compositor,
- cairo_t *cr)
+ cairo_t *cr)
{
- pango_cairo_update_layout (cr, compositor->priv->header_layout);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ pango_cairo_update_layout (cr, priv->header_layout);
/* left format */
- if (compositor->priv->header_format_left != NULL)
+ if (priv->header_format_left != NULL)
print_header_string (compositor,
cr,
PANGO_ALIGN_LEFT,
- compositor->priv->header_format_left);
+ priv->header_format_left);
/* right format */
- if (compositor->priv->header_format_right != NULL)
+ if (priv->header_format_right != NULL)
print_header_string (compositor,
cr,
PANGO_ALIGN_RIGHT,
- compositor->priv->header_format_right);
+ priv->header_format_right);
/* center format */
- if (compositor->priv->header_format_center != NULL)
+ if (priv->header_format_center != NULL)
print_header_string (compositor,
cr,
PANGO_ALIGN_CENTER,
- compositor->priv->header_format_center);
+ priv->header_format_center);
/* separator */
- if (compositor->priv->header_separator)
+ if (priv->header_separator)
{
- gdouble y = compositor->priv->real_margin_top +
- (1 - SEPARATOR_SPACING_FACTOR) * compositor->priv->header_height;
+ gdouble y = priv->real_margin_top +
+ (1 - SEPARATOR_SPACING_FACTOR) * priv->header_height;
cairo_save (cr);
- cairo_move_to (cr, compositor->priv->real_margin_left, y);
+ cairo_move_to (cr, priv->real_margin_left, y);
cairo_set_line_width (cr, SEPARATOR_LINE_WIDTH);
- cairo_line_to (cr, compositor->priv->paper_width - compositor->priv->real_margin_right, y);
+ cairo_line_to (cr, priv->paper_width - priv->real_margin_right, y);
cairo_stroke (cr);
cairo_restore (cr);
@@ -2891,10 +2986,11 @@ print_header (GtkSourcePrintCompositor *compositor,
static void
print_footer_string (GtkSourcePrintCompositor *compositor,
- cairo_t *cr,
- PangoAlignment alignment,
- const gchar *format)
+ cairo_t *cr,
+ PangoAlignment alignment,
+ const gchar *format)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
gchar *text;
text = evaluate_format_string (compositor, format);
@@ -2907,44 +3003,44 @@ print_footer_string (GtkSourcePrintCompositor *compositor,
gdouble footer_width;
gdouble x;
- footer_width = compositor->priv->paper_width -
- compositor->priv->real_margin_left -
- compositor->priv->real_margin_right;
+ footer_width = priv->paper_width -
+ priv->real_margin_left -
+ priv->real_margin_right;
- pango_layout_set_text (compositor->priv->footer_layout, text, -1);
+ pango_layout_set_text (priv->footer_layout, text, -1);
- get_layout_size (compositor->priv->footer_layout, &layout_width, &layout_height);
+ get_layout_size (priv->footer_layout, &layout_width, &layout_height);
switch (alignment)
{
case PANGO_ALIGN_RIGHT:
- x = compositor->priv->real_margin_left + footer_width - layout_width;
+ x = priv->real_margin_left + footer_width - layout_width;
break;
case PANGO_ALIGN_CENTER:
- x = compositor->priv->real_margin_left + footer_width / 2 - layout_width / 2;
+ x = priv->real_margin_left + footer_width / 2 - layout_width / 2;
break;
case PANGO_ALIGN_LEFT:
default:
- x = compositor->priv->real_margin_left;
+ x = priv->real_margin_left;
break;
}
/* Print only the first line */
- line = pango_layout_get_line (compositor->priv->footer_layout, 0);
+ line = pango_layout_get_line (priv->footer_layout, 0);
DEBUG ({
gdouble w;
gdouble h;
- get_layout_size (compositor->priv->footer_layout, &w, &h);
+ get_layout_size (priv->footer_layout, &w, &h);
cairo_save (cr);
cairo_set_line_width (cr, 1.);
cairo_set_source_rgb (cr, 0., 0., 1.);
cairo_rectangle (cr,
x,
- compositor->priv->paper_height -
compositor->priv->real_margin_bottom - h,
+ priv->paper_height - priv->real_margin_bottom - h,
layout_width,
layout_height);
cairo_stroke (cr);
@@ -2953,8 +3049,8 @@ print_footer_string (GtkSourcePrintCompositor *compositor,
cairo_move_to (cr,
x,
- compositor->priv->paper_height -
- compositor->priv->real_margin_bottom - compositor->priv->footer_font_descent);
+ priv->paper_height -
+ priv->real_margin_bottom - priv->footer_font_descent);
pango_cairo_show_layout_line (cr, line);
@@ -2964,43 +3060,45 @@ print_footer_string (GtkSourcePrintCompositor *compositor,
static void
print_footer (GtkSourcePrintCompositor *compositor,
- cairo_t *cr)
+ cairo_t *cr)
{
- pango_cairo_update_layout (cr, compositor->priv->footer_layout);
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
+
+ pango_cairo_update_layout (cr, priv->footer_layout);
/* left format */
- if (compositor->priv->footer_format_left != NULL)
+ if (priv->footer_format_left != NULL)
print_footer_string (compositor,
cr,
PANGO_ALIGN_LEFT,
- compositor->priv->footer_format_left);
+ priv->footer_format_left);
/* right format */
- if (compositor->priv->footer_format_right != NULL)
+ if (priv->footer_format_right != NULL)
print_footer_string (compositor,
cr,
PANGO_ALIGN_RIGHT,
- compositor->priv->footer_format_right);
+ priv->footer_format_right);
/* center format */
- if (compositor->priv->footer_format_center != NULL)
+ if (priv->footer_format_center != NULL)
print_footer_string (compositor,
cr,
PANGO_ALIGN_CENTER,
- compositor->priv->footer_format_center);
+ priv->footer_format_center);
/* separator */
- if (compositor->priv->footer_separator)
+ if (priv->footer_separator)
{
- gdouble y = compositor->priv->paper_height -
- compositor->priv->real_margin_bottom -
- (1 - SEPARATOR_SPACING_FACTOR) * compositor->priv->footer_height;
+ gdouble y = priv->paper_height -
+ priv->real_margin_bottom -
+ (1 - SEPARATOR_SPACING_FACTOR) * priv->footer_height;
cairo_save (cr);
- cairo_move_to (cr, compositor->priv->real_margin_left, y);
+ cairo_move_to (cr, priv->real_margin_left, y);
cairo_set_line_width (cr, SEPARATOR_LINE_WIDTH);
- cairo_line_to (cr, compositor->priv->paper_width - compositor->priv->real_margin_right, y);
+ cairo_line_to (cr, priv->paper_width - priv->real_margin_right, y);
cairo_stroke (cr);
cairo_restore (cr);
@@ -3040,9 +3138,10 @@ print_footer (GtkSourcePrintCompositor *compositor,
*/
void
gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context,
- gint page_nr)
+ GtkPrintContext *context,
+ gint page_nr)
{
+ GtkSourcePrintCompositorPrivate *priv = gtk_source_print_compositor_get_instance_private (compositor);
cairo_t *cr;
GtkTextIter start, end;
gint offset;
@@ -3052,13 +3151,13 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
g_return_if_fail (page_nr >= 0);
- compositor->priv->current_page = page_nr;
+ priv->current_page = page_nr;
cr = gtk_print_context_get_cairo_context (context);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_translate (cr,
- -1 * compositor->priv->page_margin_left,
- -1 * compositor->priv->page_margin_top);
+ -1 * priv->page_margin_left,
+ -1 * priv->page_margin_top);
if (is_header_to_print (compositor))
{
@@ -3080,18 +3179,18 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
cairo_set_line_width (cr, 1.);
cairo_set_source_rgb (cr, 0., 0., 1.);
cairo_rectangle (cr,
- compositor->priv->real_margin_left,
- compositor->priv->real_margin_top,
- compositor->priv->paper_width -
- compositor->priv->real_margin_left -
compositor->priv->real_margin_right,
- compositor->priv->paper_height -
- compositor->priv->real_margin_top -
compositor->priv->real_margin_bottom);
+ priv->real_margin_left,
+ priv->real_margin_top,
+ priv->paper_width -
+ priv->real_margin_left - priv->real_margin_right,
+ priv->paper_height -
+ priv->real_margin_top - priv->real_margin_bottom);
cairo_stroke (cr);
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_rectangle (cr,
ln_x, y,
- compositor->priv->line_numbers_width,
+ priv->line_numbers_width,
get_text_height (compositor));
cairo_stroke (cr);
@@ -3105,39 +3204,39 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
cairo_set_source_rgb (cr, 1., 0., 0.);
cairo_rectangle (cr,
0, 0,
- compositor->priv->paper_width,
- compositor->priv->paper_height);
+ priv->paper_width,
+ priv->paper_height);
cairo_stroke (cr);
cairo_restore (cr);
});
- g_return_if_fail (compositor->priv->layout != NULL);
- pango_cairo_update_layout (cr, compositor->priv->layout);
+ g_return_if_fail (priv->layout != NULL);
+ pango_cairo_update_layout (cr, priv->layout);
- if (compositor->priv->print_line_numbers)
+ if (priv->print_line_numbers)
{
- g_return_if_fail (compositor->priv->line_numbers_layout != NULL);
- pango_cairo_update_layout (cr, compositor->priv->line_numbers_layout);
+ g_return_if_fail (priv->line_numbers_layout != NULL);
+ pango_cairo_update_layout (cr, priv->line_numbers_layout);
}
- g_return_if_fail (compositor->priv->buffer != NULL);
- g_return_if_fail (compositor->priv->pages != NULL);
- g_return_if_fail ((guint) page_nr < compositor->priv->pages->len);
+ g_return_if_fail (priv->buffer != NULL);
+ g_return_if_fail (priv->pages != NULL);
+ g_return_if_fail ((guint) page_nr < priv->pages->len);
- offset = g_array_index (compositor->priv->pages, int, page_nr);
- gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (compositor->priv->buffer),
+ offset = g_array_index (priv->pages, int, page_nr);
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (priv->buffer),
&start, offset);
- if ((guint) page_nr + 1 < compositor->priv->pages->len)
+ if ((guint) page_nr + 1 < priv->pages->len)
{
- offset = g_array_index (compositor->priv->pages, int, page_nr + 1);
- gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (compositor->priv->buffer),
+ offset = g_array_index (priv->pages, int, page_nr + 1);
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (priv->buffer),
&end, offset);
}
else
{
- gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (compositor->priv->buffer),
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (priv->buffer),
&end);
}
@@ -3169,7 +3268,7 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
layout_paragraph (compositor, &start, &line_end);
- get_layout_size (compositor->priv->layout, NULL, &line_height);
+ get_layout_size (priv->layout, NULL, &line_height);
baseline_offset = 0;
@@ -3183,15 +3282,15 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
gchar *str;
str = g_strdup_printf ("%d", line_number + 1);
- pango_layout_set_text (compositor->priv->line_numbers_layout, str, -1);
+ pango_layout_set_text (priv->line_numbers_layout, str, -1);
g_free (str);
/* Adjust the baseline */
- iter = pango_layout_get_iter (compositor->priv->layout);
+ iter = pango_layout_get_iter (priv->layout);
baseline = (double) pango_layout_iter_get_baseline (iter) / (double) PANGO_SCALE;
pango_layout_iter_free (iter);
- iter = pango_layout_get_iter (compositor->priv->line_numbers_layout);
+ iter = pango_layout_get_iter (priv->line_numbers_layout);
ln_baseline = (double) pango_layout_iter_get_baseline (iter) / (double) PANGO_SCALE;
pango_layout_iter_free (iter);
@@ -3205,18 +3304,17 @@ gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
cairo_move_to (cr, ln_x, y + ln_baseline_offset);
- g_return_if_fail (compositor->priv->line_numbers_layout != NULL);
- pango_cairo_show_layout (cr, compositor->priv->line_numbers_layout);
+ g_return_if_fail (priv->line_numbers_layout != NULL);
+ pango_cairo_show_layout (cr, priv->line_numbers_layout);
}
cairo_move_to (cr, x, y + baseline_offset);
- pango_cairo_show_layout (cr, compositor->priv->layout);
+ pango_cairo_show_layout (cr, priv->layout);
line_height = MAX (line_height,
- compositor->priv->line_numbers_height);
+ priv->line_numbers_height);
y += line_height;
gtk_text_iter_forward_line (&start);
}
}
-
diff --git a/gtksourceview/gtksourceprintcompositor.h b/gtksourceview/gtksourceprintcompositor.h
index f42074e9..ee6abca1 100644
--- a/gtksourceview/gtksourceprintcompositor.h
+++ b/gtksourceview/gtksourceprintcompositor.h
@@ -30,191 +30,125 @@
G_BEGIN_DECLS
-#define GTK_SOURCE_TYPE_PRINT_COMPOSITOR (gtk_source_print_compositor_get_type ())
-#define GTK_SOURCE_PRINT_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_SOURCE_TYPE_PRINT_COMPOSITOR, GtkSourcePrintCompositor))
-#define GTK_SOURCE_PRINT_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GTK_SOURCE_TYPE_PRINT_COMPOSITOR, GtkSourcePrintCompositorClass))
-#define GTK_SOURCE_IS_PRINT_COMPOSITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GTK_SOURCE_TYPE_PRINT_COMPOSITOR))
-#define GTK_SOURCE_IS_PRINT_COMPOSITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_SOURCE_TYPE_PRINT_COMPOSITOR))
-#define GTK_SOURCE_PRINT_COMPOSITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTK_SOURCE_TYPE_PRINT_COMPOSITOR, GtkSourcePrintCompositorClass))
+#define GTK_SOURCE_TYPE_PRINT_COMPOSITOR (gtk_source_print_compositor_get_type())
-typedef struct _GtkSourcePrintCompositorClass GtkSourcePrintCompositorClass;
-typedef struct _GtkSourcePrintCompositorPrivate GtkSourcePrintCompositorPrivate;
-
-struct _GtkSourcePrintCompositor
-{
- GObject parent_instance;
-
- GtkSourcePrintCompositorPrivate *priv;
-};
+GTK_SOURCE_AVAILABLE_IN_ALL
+G_DECLARE_DERIVABLE_TYPE (GtkSourcePrintCompositor, gtk_source_print_compositor, GTK_SOURCE,
PRINT_COMPOSITOR, GObject)
struct _GtkSourcePrintCompositorClass
{
GObjectClass parent_class;
- /* Padding for future expansion */
- gpointer padding[10];
+ /*< private >*/
+ gpointer _reserved[10];
};
GTK_SOURCE_AVAILABLE_IN_ALL
-GType gtk_source_print_compositor_get_type (void) G_GNUC_CONST;
-
-
+GtkSourcePrintCompositor *gtk_source_print_compositor_new (GtkSourceBuffer
*buffer);
GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourcePrintCompositor *gtk_source_print_compositor_new (GtkSourceBuffer *buffer);
-
+GtkSourcePrintCompositor *gtk_source_print_compositor_new_from_view (GtkSourceView
*view);
GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourcePrintCompositor *gtk_source_print_compositor_new_from_view (GtkSourceView *view);
-
-
+GtkSourceBuffer *gtk_source_print_compositor_get_buffer (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourceBuffer *gtk_source_print_compositor_get_buffer (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor
*compositor,
+ guint
width);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor *compositor,
- guint width);
-
+guint gtk_source_print_compositor_get_tab_width (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-guint gtk_source_print_compositor_get_tab_width (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor
*compositor,
+ GtkWrapMode
wrap_mode);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor *compositor,
- GtkWrapMode wrap_mode);
-
+GtkWrapMode gtk_source_print_compositor_get_wrap_mode (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-GtkWrapMode gtk_source_print_compositor_get_wrap_mode (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_highlight_syntax (GtkSourcePrintCompositor
*compositor,
+ gboolean
highlight);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_highlight_syntax
- (GtkSourcePrintCompositor *compositor,
- gboolean highlight);
-
+gboolean gtk_source_print_compositor_get_highlight_syntax (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean gtk_source_print_compositor_get_highlight_syntax
- (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_print_line_numbers (GtkSourcePrintCompositor
*compositor,
+ guint
interval);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_print_line_numbers
- (GtkSourcePrintCompositor *compositor,
- guint interval);
-
+guint gtk_source_print_compositor_get_print_line_numbers (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-guint gtk_source_print_compositor_get_print_line_numbers
- (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_body_font_name (GtkSourcePrintCompositor
*compositor,
+ const gchar
*font_name);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_body_font_name
- (GtkSourcePrintCompositor *compositor,
- const gchar *font_name);
-
+gchar *gtk_source_print_compositor_get_body_font_name (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gchar *gtk_source_print_compositor_get_body_font_name
- (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_line_numbers_font_name (GtkSourcePrintCompositor
*compositor,
+ const gchar
*font_name);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_line_numbers_font_name
- (GtkSourcePrintCompositor *compositor,
- const gchar *font_name);
-
+gchar *gtk_source_print_compositor_get_line_numbers_font_name (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gchar *gtk_source_print_compositor_get_line_numbers_font_name
- (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_header_font_name (GtkSourcePrintCompositor
*compositor,
+ const gchar
*font_name);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_header_font_name
- (GtkSourcePrintCompositor *compositor,
- const gchar *font_name);
-
+gchar *gtk_source_print_compositor_get_header_font_name (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gchar *gtk_source_print_compositor_get_header_font_name
- (GtkSourcePrintCompositor
*compositor);
-
+void gtk_source_print_compositor_set_footer_font_name (GtkSourcePrintCompositor
*compositor,
+ const gchar
*font_name);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_footer_font_name
- (GtkSourcePrintCompositor *compositor,
- const gchar *font_name);
-
+gchar *gtk_source_print_compositor_get_footer_font_name (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gchar *gtk_source_print_compositor_get_footer_font_name
- (GtkSourcePrintCompositor
*compositor);
-
+gdouble gtk_source_print_compositor_get_top_margin (GtkSourcePrintCompositor
*compositor,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-gdouble gtk_source_print_compositor_get_top_margin (GtkSourcePrintCompositor
*compositor,
- GtkUnit unit);
-
+void gtk_source_print_compositor_set_top_margin (GtkSourcePrintCompositor
*compositor,
+ gdouble
margin,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_top_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit);
-
+gdouble gtk_source_print_compositor_get_bottom_margin (GtkSourcePrintCompositor
*compositor,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-gdouble gtk_source_print_compositor_get_bottom_margin (GtkSourcePrintCompositor
*compositor,
- GtkUnit unit);
-
+void gtk_source_print_compositor_set_bottom_margin (GtkSourcePrintCompositor
*compositor,
+ gdouble
margin,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_bottom_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit);
-
+gdouble gtk_source_print_compositor_get_left_margin (GtkSourcePrintCompositor
*compositor,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-gdouble gtk_source_print_compositor_get_left_margin (GtkSourcePrintCompositor
*compositor,
- GtkUnit unit);
-
-GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_left_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit);
-
+void gtk_source_print_compositor_set_left_margin (GtkSourcePrintCompositor
*compositor,
+ gdouble
margin,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-gdouble gtk_source_print_compositor_get_right_margin (GtkSourcePrintCompositor
*compositor,
- GtkUnit unit);
-
+gdouble gtk_source_print_compositor_get_right_margin (GtkSourcePrintCompositor
*compositor,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_right_margin (GtkSourcePrintCompositor *compositor,
- gdouble margin,
- GtkUnit unit);
-
+void gtk_source_print_compositor_set_right_margin (GtkSourcePrintCompositor
*compositor,
+ gdouble
margin,
+ GtkUnit
unit);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor *compositor,
- gboolean print);
-
+void gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor
*compositor,
+ gboolean
print);
GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean gtk_source_print_compositor_get_print_header (GtkSourcePrintCompositor
*compositor);
-
+gboolean gtk_source_print_compositor_get_print_header (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor *compositor,
- gboolean print);
-
+void gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor
*compositor,
+ gboolean
print);
GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean gtk_source_print_compositor_get_print_footer (GtkSourcePrintCompositor
*compositor);
-
+gboolean gtk_source_print_compositor_get_print_footer (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_header_format (GtkSourcePrintCompositor *compositor,
- gboolean separator,
- const gchar *left,
- const gchar *center,
- const gchar *right);
-
+void gtk_source_print_compositor_set_header_format (GtkSourcePrintCompositor
*compositor,
+ gboolean
separator,
+ const gchar
*left,
+ const gchar
*center,
+ const gchar
*right);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_set_footer_format (GtkSourcePrintCompositor *compositor,
- gboolean separator,
- const gchar *left,
- const gchar *center,
- const gchar *right);
-
+void gtk_source_print_compositor_set_footer_format (GtkSourcePrintCompositor
*compositor,
+ gboolean
separator,
+ const gchar
*left,
+ const gchar
*center,
+ const gchar
*right);
GTK_SOURCE_AVAILABLE_IN_ALL
-gint gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor
*compositor);
-
+gint gtk_source_print_compositor_get_n_pages (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean gtk_source_print_compositor_paginate (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context);
-
+gboolean gtk_source_print_compositor_paginate (GtkSourcePrintCompositor
*compositor,
+ GtkPrintContext
*context);
GTK_SOURCE_AVAILABLE_IN_ALL
-gdouble gtk_source_print_compositor_get_pagination_progress
- (GtkSourcePrintCompositor
*compositor);
-
+gdouble gtk_source_print_compositor_get_pagination_progress (GtkSourcePrintCompositor
*compositor);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor *compositor,
- GtkPrintContext *context,
- gint page_nr);
+void gtk_source_print_compositor_draw_page (GtkSourcePrintCompositor
*compositor,
+ GtkPrintContext
*context,
+ gint
page_nr);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]