From ac594875e6e9bd1725ce7c1a2035b2b14ae4cf83 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 20 Jan 2007 04:52:11 +0000 Subject: [PATCH] 2007-01-19 Jim Evins * src/label-barcode.h: * src/label-object.c: (gl_label_object_set_font_weight), (gl_label_object_set_text_alignment), (gl_label_object_get_font_weight), (gl_label_object_get_text_alignment): * src/label-object.h: * src/label-text.c: (gl_label_text_instance_init), (copy), (get_size), (set_font_family), (set_font_weight), (set_text_alignment), (get_font_weight), (get_text_alignment): * src/label-text.h: * src/object-editor-text-page.c: (gl_object_editor_prepare_text_page), (gl_object_editor_set_font_family), (gl_object_editor_set_font_weight), (gl_object_editor_get_font_weight), (gl_object_editor_set_text_alignment), (gl_object_editor_get_text_alignment), (gl_object_editor_set_text_color): * src/object-editor.h: * src/prefs-dialog.c: (construct_object_page), (update_object_page_from_prefs), (update_prefs_from_object_page): * src/prefs-model.c: (gl_prefs_model_save_settings), (gl_prefs_model_load_settings): * src/prefs-model.h: * src/print.c: (draw_text_object): * src/ui-property-bar.c: (gl_ui_property_bar_construct), (reset_to_default_properties), (update_text_properties), (font_bold_toggled_cb), (text_align_toggled_cb): * src/ui-sidebar.c: * src/util.c: (gl_util_align_to_string), (gl_util_string_to_align), (gl_util_weight_to_string), (gl_util_string_to_weight), (gl_util_get_font_family_list), (gl_util_font_family_list_free): * src/util.h: * src/view-text.c: (update_object_from_editor_cb), (update_editor_from_object_cb), (draw_hacktext), (draw_cursor): * src/view.c: (gl_view_set_selection_text_alignment), (gl_view_set_default_text_alignment), (gl_view_get_default_text_alignment): * src/view.h: * src/xml-label-04.c: (xml04_parse_text_props): * src/xml-label-191.c: (xml191_parse_text_props): * src/xml-label.c: (xml_parse_object_text), (xml_parse_toplevel_span), (xml_create_object_text), (xml_create_toplevel_span): Converted all model internals to Pango. GnomeFont remains in view until GnomeCanvas can be replaced with a cairo-based canvas. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@608 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 49 ++++++ glabels2/src/label-barcode.h | 2 - glabels2/src/label-object.c | 20 +-- glabels2/src/label-object.h | 213 +++++++++++++------------ glabels2/src/label-text.c | 141 ++++++++-------- glabels2/src/label-text.h | 4 +- glabels2/src/object-editor-text-page.c | 45 +++--- glabels2/src/object-editor.h | 10 +- glabels2/src/prefs-dialog.c | 15 +- glabels2/src/prefs-model.c | 10 +- glabels2/src/prefs-model.h | 7 +- glabels2/src/print.c | 21 +-- glabels2/src/ui-property-bar.c | 99 ++++++------ glabels2/src/ui-sidebar.c | 3 +- glabels2/src/util.c | 90 ++++++++--- glabels2/src/util.h | 15 +- glabels2/src/view-text.c | 44 ++--- glabels2/src/view.c | 10 +- glabels2/src/view.h | 9 +- glabels2/src/xml-label-04.c | 17 +- glabels2/src/xml-label-191.c | 8 +- glabels2/src/xml-label.c | 20 +-- 22 files changed, 464 insertions(+), 388 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 1194dcf2..c2e8f648 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,52 @@ +2007-01-19 Jim Evins + + * src/label-barcode.h: + * src/label-object.c: (gl_label_object_set_font_weight), + (gl_label_object_set_text_alignment), + (gl_label_object_get_font_weight), + (gl_label_object_get_text_alignment): + * src/label-object.h: + * src/label-text.c: (gl_label_text_instance_init), (copy), + (get_size), (set_font_family), (set_font_weight), + (set_text_alignment), (get_font_weight), (get_text_alignment): + * src/label-text.h: + * src/object-editor-text-page.c: + (gl_object_editor_prepare_text_page), + (gl_object_editor_set_font_family), + (gl_object_editor_set_font_weight), + (gl_object_editor_get_font_weight), + (gl_object_editor_set_text_alignment), + (gl_object_editor_get_text_alignment), + (gl_object_editor_set_text_color): + * src/object-editor.h: + * src/prefs-dialog.c: (construct_object_page), + (update_object_page_from_prefs), (update_prefs_from_object_page): + * src/prefs-model.c: (gl_prefs_model_save_settings), + (gl_prefs_model_load_settings): + * src/prefs-model.h: + * src/print.c: (draw_text_object): + * src/ui-property-bar.c: (gl_ui_property_bar_construct), + (reset_to_default_properties), (update_text_properties), + (font_bold_toggled_cb), (text_align_toggled_cb): + * src/ui-sidebar.c: + * src/util.c: (gl_util_align_to_string), (gl_util_string_to_align), + (gl_util_weight_to_string), (gl_util_string_to_weight), + (gl_util_get_font_family_list), (gl_util_font_family_list_free): + * src/util.h: + * src/view-text.c: (update_object_from_editor_cb), + (update_editor_from_object_cb), (draw_hacktext), (draw_cursor): + * src/view.c: (gl_view_set_selection_text_alignment), + (gl_view_set_default_text_alignment), + (gl_view_get_default_text_alignment): + * src/view.h: + * src/xml-label-04.c: (xml04_parse_text_props): + * src/xml-label-191.c: (xml191_parse_text_props): + * src/xml-label.c: (xml_parse_object_text), + (xml_parse_toplevel_span), (xml_create_object_text), + (xml_create_toplevel_span): + Converted all model internals to Pango. GnomeFont remains in + view until GnomeCanvas can be replaced with a cairo-based canvas. + 2007-01-17 Jim Evins * src/Makefile.am: diff --git a/glabels2/src/label-barcode.h b/glabels2/src/label-barcode.h index 38bdf045..507cdcd4 100644 --- a/glabels2/src/label-barcode.h +++ b/glabels2/src/label-barcode.h @@ -23,8 +23,6 @@ #ifndef __LABEL_BARCODE_H__ #define __LABEL_BARCODE_H__ -#include -#include #include "bc.h" #include "text-node.h" #include "label-object.h" diff --git a/glabels2/src/label-object.c b/glabels2/src/label-object.c index b1bdec06..7d31868b 100644 --- a/glabels2/src/label-object.c +++ b/glabels2/src/label-object.c @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * label_object.c: GLabels label object base class * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2007 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -707,7 +709,7 @@ gl_label_object_set_font_size (glLabelObject *object, /****************************************************************************/ void gl_label_object_set_font_weight (glLabelObject *object, - GnomeFontWeight font_weight) + PangoWeight font_weight) { gl_debug (DEBUG_LABEL, "START"); @@ -750,7 +752,7 @@ gl_label_object_set_font_italic_flag (glLabelObject *object, /****************************************************************************/ void gl_label_object_set_text_alignment (glLabelObject *object, - GtkJustification text_alignment) + PangoAlignment text_alignment) { gl_debug (DEBUG_LABEL, "START"); @@ -860,14 +862,14 @@ gl_label_object_get_font_size (glLabelObject *object) /****************************************************************************/ /* Get font weight for all text contained in object. */ /****************************************************************************/ -GnomeFontWeight +PangoWeight gl_label_object_get_font_weight (glLabelObject *object) { - GnomeFontWeight ret = GNOME_FONT_BOOK; + PangoWeight ret = PANGO_WEIGHT_NORMAL; gl_debug (DEBUG_LABEL, "START"); - g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), GNOME_FONT_BOOK); + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), PANGO_WEIGHT_NORMAL); if ( GL_LABEL_OBJECT_GET_CLASS(object)->get_font_weight != NULL ) { @@ -908,14 +910,14 @@ gl_label_object_get_font_italic_flag (glLabelObject *object) /****************************************************************************/ /* Get text alignment for all text contained in object. */ /****************************************************************************/ -GtkJustification +PangoAlignment gl_label_object_get_text_alignment (glLabelObject *object) { - GtkJustification ret = GTK_JUSTIFY_LEFT; + PangoAlignment ret = PANGO_ALIGN_LEFT; gl_debug (DEBUG_LABEL, "START"); - g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), GTK_JUSTIFY_LEFT); + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), PANGO_ALIGN_LEFT); if ( GL_LABEL_OBJECT_GET_CLASS(object)->get_text_alignment != NULL ) { diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index 8464118e..a7b6bb89 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * label_object.h: GLabels label object base class * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2007 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +26,7 @@ #define __LABEL_OBJECT_H__ #include -#include -#include +#include G_BEGIN_DECLS @@ -57,100 +58,100 @@ typedef struct _glLabelObjectPrivate glLabelObjectPrivate; #include "color.h" struct _glLabelObject { - GObject object; + GObject object; - glLabel *parent; + glLabel *parent; - glLabelObjectPrivate *private; + glLabelObjectPrivate *private; }; struct _glLabelObjectClass { - GObjectClass parent_class; + GObjectClass parent_class; - /* - * Methods - */ + /* + * Methods + */ - void (*set_size) (glLabelObject *object, - gdouble w, - gdouble h); + void (*set_size) (glLabelObject *object, + gdouble w, + gdouble h); - void (*get_size) (glLabelObject *object, - gdouble *w, - gdouble *h); + void (*get_size) (glLabelObject *object, + gdouble *w, + gdouble *h); - void (*set_font_family) (glLabelObject *object, - const gchar *font_family); + void (*set_font_family) (glLabelObject *object, + const gchar *font_family); - void (*set_font_size) (glLabelObject *object, - gdouble font_size); + void (*set_font_size) (glLabelObject *object, + gdouble font_size); - void (*set_font_weight) (glLabelObject *object, - GnomeFontWeight font_weight); + void (*set_font_weight) (glLabelObject *object, + PangoWeight font_weight); - void (*set_font_italic_flag) (glLabelObject *object, - gboolean font_italic_flag); + void (*set_font_italic_flag) (glLabelObject *object, + gboolean font_italic_flag); - void (*set_text_alignment) (glLabelObject *object, - GtkJustification text_alignment); + void (*set_text_alignment) (glLabelObject *object, + PangoAlignment text_alignment); - void (*set_text_line_spacing) (glLabelObject *object, - gdouble text_line_spacing); + void (*set_text_line_spacing) (glLabelObject *object, + gdouble text_line_spacing); - void (*set_text_color) (glLabelObject *object, - glColorNode *text_color_node); + void (*set_text_color) (glLabelObject *object, + glColorNode *text_color_node); - void (*set_fill_color) (glLabelObject *object, - glColorNode *fill_color_node); + void (*set_fill_color) (glLabelObject *object, + glColorNode *fill_color_node); - void (*set_line_color) (glLabelObject *object, - glColorNode *line_color_node); + void (*set_line_color) (glLabelObject *object, + glColorNode *line_color_node); - void (*set_line_width) (glLabelObject *object, - gdouble line_width); + void (*set_line_width) (glLabelObject *object, + gdouble line_width); - gchar *(*get_font_family) (glLabelObject *object); + gchar *(*get_font_family) (glLabelObject *object); - gdouble (*get_font_size) (glLabelObject *object); + gdouble (*get_font_size) (glLabelObject *object); - GnomeFontWeight (*get_font_weight) (glLabelObject *object); + PangoWeight (*get_font_weight) (glLabelObject *object); - gboolean (*get_font_italic_flag) (glLabelObject *object); + gboolean (*get_font_italic_flag) (glLabelObject *object); - GtkJustification (*get_text_alignment) (glLabelObject *object); + PangoAlignment (*get_text_alignment) (glLabelObject *object); - gdouble (*get_text_line_spacing) (glLabelObject *object); + gdouble (*get_text_line_spacing) (glLabelObject *object); - glColorNode* (*get_text_color) (glLabelObject *object); + glColorNode* (*get_text_color) (glLabelObject *object); - glColorNode* (*get_fill_color) (glLabelObject *object); + glColorNode* (*get_fill_color) (glLabelObject *object); - glColorNode* (*get_line_color) (glLabelObject *object); + glColorNode* (*get_line_color) (glLabelObject *object); - gdouble (*get_line_width) (glLabelObject *object); + gdouble (*get_line_width) (glLabelObject *object); - void (*copy) (glLabelObject *dst_object, - glLabelObject *src_object); + void (*copy) (glLabelObject *dst_object, + glLabelObject *src_object); - /* - * Signals - */ - void (*changed) (glLabelObject *object, - gpointer user_data); + /* + * Signals + */ + void (*changed) (glLabelObject *object, + gpointer user_data); - void (*moved) (glLabelObject *object, - gdouble dx, - gdouble dy, - gpointer user_data); + void (*moved) (glLabelObject *object, + gdouble dx, + gdouble dy, + gpointer user_data); - void (*flip_rotate) (glLabelObject *object, - gpointer user_data); + void (*flip_rotate) (glLabelObject *object, + gpointer user_data); - void (*top) (glLabelObject *object, - gpointer user_data); + void (*top) (glLabelObject *object, + gpointer user_data); - void (*bottom) (glLabelObject *object, - gpointer user_data); + void (*bottom) (glLabelObject *object, + gpointer user_data); }; GType gl_label_object_get_type (void) G_GNUC_CONST; @@ -159,87 +160,87 @@ GObject *gl_label_object_new (glLabel *label); glLabelObject *gl_label_object_dup (glLabelObject *src_object, - glLabel *label); + glLabel *label); void gl_label_object_emit_changed (glLabelObject *object); void gl_label_object_set_parent (glLabelObject *object, - glLabel *label); + glLabel *label); glLabel *gl_label_object_get_parent (glLabelObject *object); void gl_label_object_set_name (glLabelObject *object, - gchar *name); + gchar *name); gchar *gl_label_object_get_name (glLabelObject *object); void gl_label_object_set_position (glLabelObject *object, - gdouble x, - gdouble y); + gdouble x, + gdouble y); void gl_label_object_set_position_relative (glLabelObject *object, - gdouble dx, - gdouble dy); + gdouble dx, + gdouble dy); void gl_label_object_get_position (glLabelObject *object, - gdouble *x, - gdouble *y); + gdouble *x, + gdouble *y); void gl_label_object_set_size (glLabelObject *object, - gdouble w, - gdouble h); + gdouble w, + gdouble h); void gl_label_object_set_size_honor_aspect (glLabelObject *object, - gdouble w, - gdouble h); + gdouble w, + gdouble h); void gl_label_object_get_size (glLabelObject *object, - gdouble *w, - gdouble *h); + gdouble *w, + gdouble *h); void gl_label_object_get_extent (glLabelObject *object, - gdouble *x1, - gdouble *y1, - gdouble *x2, - gdouble *y2); + gdouble *x1, + gdouble *y1, + gdouble *x2, + gdouble *y2); gboolean gl_label_object_can_text (glLabelObject *object); void gl_label_object_set_font_family (glLabelObject *object, - const gchar *font_family); + const gchar *font_family); void gl_label_object_set_font_size (glLabelObject *object, - gdouble font_size); + gdouble font_size); void gl_label_object_set_font_weight (glLabelObject *object, - GnomeFontWeight font_weight); + PangoWeight font_weight); void gl_label_object_set_font_italic_flag (glLabelObject *object, - gboolean font_italic_flag); + gboolean font_italic_flag); void gl_label_object_set_text_alignment (glLabelObject *object, - GtkJustification text_alignment); + PangoAlignment text_alignment); void gl_label_object_set_text_color (glLabelObject *object, - glColorNode *text_color_node); + glColorNode *text_color_node); void gl_label_object_set_text_line_spacing (glLabelObject *object, - gdouble text_line_spacing); + gdouble text_line_spacing); gchar *gl_label_object_get_font_family (glLabelObject *object); gdouble gl_label_object_get_font_size (glLabelObject *object); -GnomeFontWeight gl_label_object_get_font_weight (glLabelObject *object); +PangoWeight gl_label_object_get_font_weight (glLabelObject *object); gboolean gl_label_object_get_font_italic_flag (glLabelObject *object); -GtkJustification gl_label_object_get_text_alignment (glLabelObject *object); +PangoAlignment gl_label_object_get_text_alignment (glLabelObject *object); gdouble gl_label_object_get_text_line_spacing (glLabelObject *object); @@ -249,7 +250,7 @@ glColorNode *gl_label_object_get_text_color (glLabelObject *objec gboolean gl_label_object_can_fill (glLabelObject *object); void gl_label_object_set_fill_color (glLabelObject *object, - glColorNode *fill_color_node); + glColorNode *fill_color_node); glColorNode* gl_label_object_get_fill_color (glLabelObject *object); @@ -257,14 +258,14 @@ glColorNode* gl_label_object_get_fill_color (glLabelObject *object) gboolean gl_label_object_can_line_color (glLabelObject *object); void gl_label_object_set_line_color (glLabelObject *object, - glColorNode *line_color_node); + glColorNode *line_color_node); glColorNode *gl_label_object_get_line_color (glLabelObject *object); gboolean gl_label_object_can_line_width (glLabelObject *object); void gl_label_object_set_line_width (glLabelObject *object, - gdouble line_width); + gdouble line_width); gdouble gl_label_object_get_line_width (glLabelObject *object); @@ -279,38 +280,38 @@ void gl_label_object_flip_horiz (glLabelObject *object) void gl_label_object_flip_vert (glLabelObject *object); void gl_label_object_rotate (glLabelObject *object, - gdouble theta_degs); + gdouble theta_degs); void gl_label_object_set_affine (glLabelObject *object, - gdouble affine[6]); + gdouble affine[6]); void gl_label_object_get_affine (glLabelObject *object, - gdouble affine[6]); + gdouble affine[6]); void gl_label_object_get_i2w_affine (glLabelObject *object, - gdouble affine[6]); + gdouble affine[6]); void gl_label_object_get_w2i_affine (glLabelObject *object, - gdouble affine[6]); + gdouble affine[6]); void gl_label_object_set_shadow_state (glLabelObject *object, - gboolean state); + gboolean state); void gl_label_object_set_shadow_offset (glLabelObject *object, - gdouble x, - gdouble y); + gdouble x, + gdouble y); void gl_label_object_set_shadow_color (glLabelObject *object, - glColorNode *color_node); + glColorNode *color_node); void gl_label_object_set_shadow_opacity (glLabelObject *object, - gdouble alpha); + gdouble alpha); gboolean gl_label_object_get_shadow_state (glLabelObject *object); void gl_label_object_get_shadow_offset (glLabelObject *object, - gdouble *x, - gdouble *y); + gdouble *x, + gdouble *y); glColorNode* gl_label_object_get_shadow_color (glLabelObject *object); diff --git a/glabels2/src/label-text.c b/glabels2/src/label-text.c index fd8da7e1..bb61ff05 100644 --- a/glabels2/src/label-text.c +++ b/glabels2/src/label-text.c @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * label_text.c: GLabels label text object * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2007 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +27,9 @@ #include #include #include -#include +#include + +#include "util.h" #include "debug.h" @@ -35,13 +39,15 @@ #define DEFAULT_FONT_FAMILY "Sans" #define DEFAULT_FONT_SIZE 14.0 -#define DEFAULT_FONT_WEIGHT GNOME_FONT_BOOK +#define DEFAULT_FONT_WEIGHT PANGO_WEIGHT_NORMAL #define DEFAULT_FONT_ITALIC_FLAG FALSE -#define DEFAULT_JUST GTK_JUSTIFY_LEFT -#define DEFAULT_COLOR GNOME_CANVAS_COLOR (0,0,0) +#define DEFAULT_ALIGN PANGO_ALIGN_LEFT +#define DEFAULT_COLOR GL_COLOR (0,0,0) #define DEFAULT_TEXT_LINE_SPACING 1.0 #define DEFAULT_AUTO_SHRINK FALSE +#define FONT_SCALE (72.0/96.0) + /*========================================================*/ /* Private types. */ /*========================================================*/ @@ -52,9 +58,9 @@ struct _glLabelTextPrivate { gchar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; - GtkJustification just; + PangoAlignment align; glColorNode *color_node; gdouble line_spacing; gboolean auto_shrink; @@ -93,13 +99,13 @@ static void set_font_size (glLabelObject *object, gdouble font_size); static void set_font_weight (glLabelObject *object, - GnomeFontWeight font_weight); + PangoWeight font_weight); static void set_font_italic_flag (glLabelObject *object, gboolean font_italic_flag); static void set_text_alignment (glLabelObject *object, - GtkJustification text_alignment); + PangoAlignment text_alignment); static void set_text_line_spacing (glLabelObject *object, gdouble text_line_spacing); @@ -111,11 +117,11 @@ static gchar *get_font_family (glLabelObject *object); static gdouble get_font_size (glLabelObject *object); -static GnomeFontWeight get_font_weight (glLabelObject *object); +static PangoWeight get_font_weight (glLabelObject *object); static gboolean get_font_italic_flag (glLabelObject *object); -static GtkJustification get_text_alignment (glLabelObject *object); +static PangoAlignment get_text_alignment (glLabelObject *object); static gdouble get_text_line_spacing (glLabelObject *object); @@ -193,7 +199,7 @@ gl_label_text_instance_init (glLabelText *ltext) ltext->private->font_size = DEFAULT_FONT_SIZE; ltext->private->font_weight = DEFAULT_FONT_WEIGHT; ltext->private->font_italic_flag = DEFAULT_FONT_ITALIC_FLAG; - ltext->private->just = DEFAULT_JUST; + ltext->private->align = DEFAULT_ALIGN; ltext->private->color_node = gl_color_node_new_default (); ltext->private->color_node->color = DEFAULT_COLOR; ltext->private->line_spacing = DEFAULT_TEXT_LINE_SPACING; @@ -262,7 +268,7 @@ copy (glLabelObject *dst_object, new_ltext->private->font_weight = ltext->private->font_weight; new_ltext->private->font_italic_flag = ltext->private->font_italic_flag; set_text_color (dst_object, text_color_node); - new_ltext->private->just = ltext->private->just; + new_ltext->private->align = ltext->private->align; new_ltext->private->line_spacing = ltext->private->line_spacing; new_ltext->private->auto_shrink = ltext->private->auto_shrink; @@ -350,16 +356,17 @@ get_size (glLabelObject *object, gdouble *w, gdouble *h) { - glLabelText *ltext = (glLabelText *)object; - GnomeFont *font; - GtkTextIter start, end; - gchar *text; - gchar **line; - gint i; - GnomeGlyphList *glyphlist; - ArtDRect bbox; - gdouble affine[6]; - gdouble w_parent, h_parent; + glLabelText *ltext = (glLabelText *)object; + PangoFontMap *fontmap; + PangoContext *context; + cairo_font_options_t *options; + PangoStyle style; + PangoLayout *layout; + PangoFontDescription *desc; + GtkTextIter start, end; + gchar *text; + gdouble w_parent, h_parent; + gint iw, ih; gl_debug (DEBUG_LABEL, "START"); @@ -373,49 +380,39 @@ get_size (glLabelObject *object, return; } - font = gnome_font_find_closest_from_weight_slant ( - (guchar *)ltext->private->font_family, - ltext->private->font_weight, - ltext->private->font_italic_flag, - ltext->private->font_size); - gtk_text_buffer_get_bounds (ltext->private->buffer, &start, &end); text = gtk_text_buffer_get_text (ltext->private->buffer, &start, &end, FALSE); - line = g_strsplit (text, "\n", -1); - g_free (text); - - art_affine_identity (affine); - - *w = 0.0; - *h = 0.0; - for (i = 0; line[i] != NULL; i++) { - - glyphlist = gnome_glyphlist_from_text_dumb (font, 0, - 0.0, 0.0, - (guchar *)line[i]); - - gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox); - - gnome_glyphlist_unref (glyphlist); - if ( bbox.x1 > *w ) *w = bbox.x1; - - if (i) { - *h += ltext->private->line_spacing * ltext->private->font_size; - } else { - *h += ltext->private->font_size; - } - - } - - if ( *h == 0.0 ) *h = ltext->private->font_size; - - *w += 2*GL_LABEL_TEXT_MARGIN; - *h += 2*GL_LABEL_TEXT_MARGIN; - - - g_strfreev (line); + + fontmap = pango_cairo_font_map_new (); + context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); + options = cairo_font_options_create (); + cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF); + pango_cairo_context_set_font_options (context, options); + cairo_font_options_destroy (options); + + layout = pango_layout_new (context); + + style = GL_LABEL_TEXT (object)->private->font_italic_flag ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL; + + desc = pango_font_description_new (); + pango_font_description_set_family (desc, GL_LABEL_TEXT (object)->private->font_family); + pango_font_description_set_weight (desc, GL_LABEL_TEXT (object)->private->font_weight); + pango_font_description_set_style (desc, style); + pango_font_description_set_size (desc, GL_LABEL_TEXT (object)->private->font_size * PANGO_SCALE * FONT_SCALE); + pango_layout_set_font_description (layout, desc); + pango_font_description_free (desc); + + pango_layout_set_text (layout, text, -1); + pango_layout_get_size (layout, &iw, &ih); + *w = iw / PANGO_SCALE + 2*GL_LABEL_TEXT_MARGIN; + *h = ih / PANGO_SCALE; + + g_object_unref (layout); + g_object_unref (context); + g_object_unref (fontmap); + g_free (text); gl_debug (DEBUG_LABEL, "END"); } @@ -436,7 +433,7 @@ set_font_family (glLabelObject *object, g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext)); g_return_if_fail (font_family); - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) { good_font_family = g_strdup (font_family); } else { @@ -446,7 +443,7 @@ set_font_family (glLabelObject *object, good_font_family = g_strdup (font_family); } } - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); if (ltext->private->font_family) { if (g_strcasecmp (ltext->private->font_family, good_font_family) == 0) { @@ -494,7 +491,7 @@ set_font_size (glLabelObject *object, /*---------------------------------------------------------------------------*/ static void set_font_weight (glLabelObject *object, - GnomeFontWeight font_weight) + PangoWeight font_weight) { glLabelText *ltext = (glLabelText *)object; @@ -540,7 +537,7 @@ set_font_italic_flag (glLabelObject *object, /*---------------------------------------------------------------------------*/ static void set_text_alignment (glLabelObject *object, - GtkJustification text_alignment) + PangoAlignment text_alignment) { glLabelText *ltext = (glLabelText *)object; @@ -548,9 +545,9 @@ set_text_alignment (glLabelObject *object, g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext)); - if (ltext->private->just != text_alignment) { + if (ltext->private->align != text_alignment) { - ltext->private->just = text_alignment; + ltext->private->align = text_alignment; gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext)); } @@ -639,14 +636,14 @@ get_font_size (glLabelObject *object) /*---------------------------------------------------------------------------*/ /* PRIVATE. get font weight method. */ /*---------------------------------------------------------------------------*/ -static GnomeFontWeight +static PangoWeight get_font_weight (glLabelObject *object) { glLabelText *ltext = (glLabelText *)object; gl_debug (DEBUG_LABEL, ""); - g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), GNOME_FONT_BOOK); + g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), PANGO_WEIGHT_NORMAL); return ltext->private->font_weight; } @@ -669,7 +666,7 @@ get_font_italic_flag (glLabelObject *object) /*---------------------------------------------------------------------------*/ /* PRIVATE. get text alignment method. */ /*---------------------------------------------------------------------------*/ -static GtkJustification +static PangoAlignment get_text_alignment (glLabelObject *object) { glLabelText *ltext = (glLabelText *)object; @@ -678,7 +675,7 @@ get_text_alignment (glLabelObject *object) g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), GTK_JUSTIFY_LEFT); - return ltext->private->just; + return ltext->private->align; } /*---------------------------------------------------------------------------*/ diff --git a/glabels2/src/label-text.h b/glabels2/src/label-text.h index 57deadb1..50a359a0 100644 --- a/glabels2/src/label-text.h +++ b/glabels2/src/label-text.h @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * @@ -23,9 +25,7 @@ #ifndef __LABEL_TEXT_H__ #define __LABEL_TEXT_H__ -#include #include -#include #include "text-node.h" #include "label-object.h" diff --git a/glabels2/src/object-editor-text-page.c b/glabels2/src/object-editor-text-page.c index ab93283b..be4e231e 100644 --- a/glabels2/src/object-editor-text-page.c +++ b/glabels2/src/object-editor-text-page.c @@ -32,6 +32,7 @@ #include "prefs.h" #include "mygal/widget-color-combo.h" #include "color.h" +#include "util.h" #include "object-editor-private.h" @@ -102,10 +103,10 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->text_color_key_combo)); /* Load family names */ - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); gl_util_combo_box_set_strings (GTK_COMBO_BOX(editor->priv->text_family_combo), family_names); - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); /* Modify widgets */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_radio), TRUE); @@ -232,7 +233,7 @@ gl_object_editor_set_font_family (glObjectEditor *editor, editor); /* Make sure we have a valid font family. if not provide a good default. */ - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) { good_font_family = g_strdup (font_family); } else { @@ -242,7 +243,7 @@ gl_object_editor_set_font_family (glObjectEditor *editor, good_font_family = NULL; } } - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_family_combo), good_font_family); g_free (good_font_family); @@ -316,7 +317,7 @@ gl_object_editor_get_font_size (glObjectEditor *editor) /*****************************************************************************/ void gl_object_editor_set_font_weight (glObjectEditor *editor, - GnomeFontWeight font_weight) + PangoWeight font_weight) { gl_debug (DEBUG_EDITOR, "START"); @@ -325,7 +326,7 @@ gl_object_editor_set_font_weight (glObjectEditor *editor, editor); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_bold_toggle), - (font_weight == GNOME_FONT_BOLD)); + (font_weight == PANGO_WEIGHT_BOLD)); g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_bold_toggle), gl_object_editor_changed_cb, @@ -337,18 +338,18 @@ gl_object_editor_set_font_weight (glObjectEditor *editor, /*****************************************************************************/ /* Query font weight. */ /*****************************************************************************/ -GnomeFontWeight +PangoWeight gl_object_editor_get_font_weight (glObjectEditor *editor) { - GnomeFontWeight font_weight; + PangoWeight font_weight; gl_debug (DEBUG_EDITOR, "START"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->text_bold_toggle))) { - font_weight = GNOME_FONT_BOLD; + font_weight = PANGO_WEIGHT_BOLD; } else { - font_weight = GNOME_FONT_BOOK; + font_weight = PANGO_WEIGHT_NORMAL; } gl_debug (DEBUG_EDITOR, "END"); @@ -404,7 +405,7 @@ gl_object_editor_get_font_italic_flag (glObjectEditor *editor) /*****************************************************************************/ void gl_object_editor_set_text_alignment (glObjectEditor *editor, - GtkJustification just) + PangoAlignment align) { gl_debug (DEBUG_EDITOR, "START"); @@ -419,11 +420,11 @@ gl_object_editor_set_text_alignment (glObjectEditor *editor, editor); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_left_toggle), - (just == GTK_JUSTIFY_LEFT)); + (align == PANGO_ALIGN_LEFT)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_center_toggle), - (just == GTK_JUSTIFY_CENTER)); + (align == PANGO_ALIGN_CENTER)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_right_toggle), - (just == GTK_JUSTIFY_RIGHT)); + (align == PANGO_ALIGN_RIGHT)); g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_left_toggle), align_toggle_cb, @@ -441,31 +442,31 @@ gl_object_editor_set_text_alignment (glObjectEditor *editor, /*****************************************************************************/ /* Query text alignment. */ /*****************************************************************************/ -GtkJustification +PangoAlignment gl_object_editor_get_text_alignment (glObjectEditor *editor) { - GtkJustification just; + PangoAlignment align; gl_debug (DEBUG_EDITOR, "START"); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->text_left_toggle))) { - just = GTK_JUSTIFY_LEFT; + align = PANGO_ALIGN_LEFT; } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->text_right_toggle))) { - just = GTK_JUSTIFY_RIGHT; + align = PANGO_ALIGN_RIGHT; } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->text_center_toggle))) { - just = GTK_JUSTIFY_CENTER; + align = PANGO_ALIGN_CENTER; } else { - just = GTK_JUSTIFY_LEFT; /* Should not happen. */ + align = PANGO_ALIGN_LEFT; /* Should not happen. */ } gl_debug (DEBUG_EDITOR, "END"); - return just; + return align; } /*****************************************************************************/ @@ -517,7 +518,7 @@ gl_object_editor_set_text_color (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->text_color_key_combo, TRUE); gl_debug (DEBUG_EDITOR, "color field true 1"); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_color_key_combo)); + gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_color_key_combo), ""); gl_debug (DEBUG_EDITOR, "color field true 2"); } diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h index a67a652e..41424a7b 100644 --- a/glabels2/src/object-editor.h +++ b/glabels2/src/object-editor.h @@ -23,8 +23,6 @@ #define __OBJECT_EDITOR_H__ #include -#include -#include #include #include "text-node.h" @@ -192,9 +190,9 @@ void gl_object_editor_set_font_size (glObjectEditor *editor, gdouble gl_object_editor_get_font_size (glObjectEditor *editor); void gl_object_editor_set_font_weight (glObjectEditor *editor, - GnomeFontWeight font_weight); + PangoWeight font_weight); -GnomeFontWeight gl_object_editor_get_font_weight (glObjectEditor *editor); +PangoWeight gl_object_editor_get_font_weight (glObjectEditor *editor); void gl_object_editor_set_font_italic_flag (glObjectEditor *editor, gboolean font_italic_flag); @@ -202,9 +200,9 @@ void gl_object_editor_set_font_italic_flag (glObjectEditor *editor, gboolean gl_object_editor_get_font_italic_flag (glObjectEditor *editor); void gl_object_editor_set_text_alignment (glObjectEditor *editor, - GtkJustification text_alignment); + PangoAlignment text_alignment); -GtkJustification gl_object_editor_get_text_alignment (glObjectEditor *editor); +PangoAlignment gl_object_editor_get_text_alignment (glObjectEditor *editor); void gl_object_editor_set_text_line_spacing (glObjectEditor *editor, gdouble text_line_spacing); diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index 69fe674c..d97516bc 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -26,7 +26,6 @@ #include "prefs-dialog.h" #include -#include #include #include #include @@ -363,10 +362,10 @@ construct_object_page (glPrefsDialog *dlg) gl_util_combo_box_add_text_model (GTK_COMBO_BOX (dlg->priv->text_family_combo)); /* Load family names */ - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); gl_util_combo_box_set_strings (GTK_COMBO_BOX (dlg->priv->text_family_combo), family_names); - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); g_signal_connect_swapped (G_OBJECT(dlg->priv->text_family_combo), @@ -585,7 +584,7 @@ update_object_page_from_prefs (glPrefsDialog *dlg) /* Make sure we have a valid font family. if not provide a good default. */ - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); if (g_list_find_custom (family_names, gl_prefs->default_font_family, (GCompareFunc)g_utf8_collate)) { @@ -597,7 +596,7 @@ update_object_page_from_prefs (glPrefsDialog *dlg) good_font_family = NULL; } } - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); gl_util_combo_box_set_active_text (GTK_COMBO_BOX (dlg->priv->text_family_combo), good_font_family); g_free (good_font_family); @@ -606,7 +605,7 @@ update_object_page_from_prefs (glPrefsDialog *dlg) gl_prefs->default_font_size); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_bold_toggle), - (gl_prefs->default_font_weight == GNOME_FONT_BOLD)); + (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_italic_toggle), gl_prefs->default_font_italic_flag); @@ -725,9 +724,9 @@ update_prefs_from_object_page (glPrefsDialog *dlg) if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->text_bold_toggle))) { - gl_prefs->default_font_weight = GNOME_FONT_BOLD; + gl_prefs->default_font_weight = PANGO_WEIGHT_BOLD; } else { - gl_prefs->default_font_weight = GNOME_FONT_BOOK; + gl_prefs->default_font_weight = PANGO_WEIGHT_NORMAL; } gl_prefs->default_font_italic_flag = diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index 333f57f3..881ad833 100644 --- a/glabels2/src/prefs-model.c +++ b/glabels2/src/prefs-model.c @@ -75,9 +75,9 @@ #define DEFAULT_FONT_FAMILY "Sans" #define DEFAULT_FONT_SIZE 14.0 -#define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (GNOME_FONT_BOOK) +#define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (PANGO_WEIGHT_NORMAL) #define DEFAULT_FONT_ITALIC_FLAG FALSE -#define DEFAULT_TEXT_JUST_STRING gl_util_just_to_string (GTK_JUSTIFY_LEFT) +#define DEFAULT_TEXT_ALIGN_STRING gl_util_align_to_string (PANGO_ALIGN_LEFT) #define DEFAULT_TEXT_COLOR GNOME_CANVAS_COLOR (0,0,0) #define DEFAULT_TEXT_LINE_SPACING 1.0 @@ -300,7 +300,7 @@ gl_prefs_model_save_settings (glPrefsModel *prefs_model) gconf_client_set_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT, - gl_util_just_to_string(prefs_model->default_text_alignment), + gl_util_align_to_string(prefs_model->default_text_alignment), NULL); gconf_client_set_float (prefs_model->gconf_client, @@ -443,8 +443,8 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) string = get_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT, - DEFAULT_TEXT_JUST_STRING); - prefs_model->default_text_alignment = gl_util_string_to_just( string ); + DEFAULT_TEXT_ALIGN_STRING); + prefs_model->default_text_alignment = gl_util_string_to_align( string ); g_free( string ); prefs_model->default_text_line_spacing = diff --git a/glabels2/src/prefs-model.h b/glabels2/src/prefs-model.h index b2983097..e85b058f 100644 --- a/glabels2/src/prefs-model.h +++ b/glabels2/src/prefs-model.h @@ -23,9 +23,8 @@ #define __PREFS_MODEL_H__ #include -#include #include -#include +#include #include G_BEGIN_DECLS @@ -64,10 +63,10 @@ struct _glPrefsModel { /* Text properties */ gchar *default_font_family; gdouble default_font_size; - GnomeFontWeight default_font_weight; + PangoWeight default_font_weight; gboolean default_font_italic_flag; guint default_text_color; - GtkJustification default_text_alignment; + PangoAlignment default_text_alignment; gdouble default_text_line_spacing; /* Line properties */ diff --git a/glabels2/src/print.c b/glabels2/src/print.c index d3cbd39c..196219bf 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "label.h" #include "label-text.h" @@ -670,11 +669,10 @@ draw_text_object (PrintInfo *pi, GList *lines; gchar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; guint color; glColorNode *color_node; - GtkJustification just; gboolean auto_shrink; ArtDRect bbox; gdouble affine[6]; @@ -703,7 +701,7 @@ draw_text_object (PrintInfo *pi, color = gl_color_node_expand (color_node, record); gl_color_node_free (&color_node); - just = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object)); + alignment = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object)); text_line_spacing = gl_label_object_get_text_line_spacing (GL_LABEL_OBJECT(object)); auto_shrink = gl_label_text_get_auto_shrink (object); @@ -721,21 +719,6 @@ draw_text_object (PrintInfo *pi, text = gl_text_node_lines_expand (lines, record); - switch (just) { - case GTK_JUSTIFY_LEFT: - alignment = PANGO_ALIGN_LEFT; - break; - case GTK_JUSTIFY_CENTER: - alignment = PANGO_ALIGN_CENTER; - break; - case GTK_JUSTIFY_RIGHT: - alignment = PANGO_ALIGN_RIGHT; - break; - default: - alignment = PANGO_ALIGN_LEFT; - break; /* shouldn't happen */ - } - style = font_italic_flag ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL; diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index 6af07594..604f7d0e 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /** * (GLABELS) Label and Business Card Creation program for GNOME @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -306,7 +305,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar) /* Font family entry widget */ gl_util_combo_box_add_text_model (GTK_COMBO_BOX (property_bar->priv->font_family_combo)); - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); gl_util_combo_box_set_strings (GTK_COMBO_BOX (property_bar->priv->font_family_combo), family_names); gtk_widget_set_size_request (property_bar->priv->font_family_combo, 200, -1); @@ -322,7 +321,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar) } else { gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo), 0); } - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); g_signal_connect (G_OBJECT (property_bar->priv->font_family_combo), "changed", G_CALLBACK (font_family_changed_cb), property_bar); @@ -337,7 +336,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar) /* Bold and Italic toggles */ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), - (gl_prefs->default_font_weight == GNOME_FONT_BOLD)); + (gl_prefs->default_font_weight == PANGO_WEIGHT_BOLD)); g_signal_connect (G_OBJECT (property_bar->priv->font_bold_toggle), "toggled", G_CALLBACK (font_bold_toggled_cb), property_bar); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle), @@ -348,15 +347,15 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar) /* Text alignment radio group */ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), - (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT)); + (gl_prefs->default_text_alignment == PANGO_ALIGN_LEFT)); g_signal_connect (G_OBJECT (property_bar->priv->text_align_left_radio), "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), - (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER)); + (gl_prefs->default_text_alignment == PANGO_ALIGN_CENTER)); g_signal_connect (G_OBJECT (property_bar->priv->text_align_center_radio), "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), - (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT)); + (gl_prefs->default_text_alignment == PANGO_ALIGN_RIGHT)); g_signal_connect (G_OBJECT (property_bar->priv->text_align_right_radio), "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); @@ -406,7 +405,7 @@ reset_to_default_properties (glView *view, GdkColor *gdk_color; /* Make sure we have a valid font. if not provide a good default. */ - family_names = gnome_font_family_list (); + family_names = gl_util_get_font_family_list (); if (g_list_find_custom (family_names, view->default_font_family, (GCompareFunc)g_utf8_collate)) { @@ -421,22 +420,22 @@ reset_to_default_properties (glView *view, gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo), good_font_family); g_free (good_font_family); - gnome_font_family_list_free (family_names); + gl_util_font_family_list_free (family_names); gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin), view->default_font_size); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), - (view->default_font_weight == GNOME_FONT_BOLD)); + (view->default_font_weight == PANGO_WEIGHT_BOLD)); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle), view->default_font_italic_flag); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), - (view->default_text_alignment == GTK_JUSTIFY_LEFT)); + (view->default_text_alignment == PANGO_ALIGN_LEFT)); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), - (view->default_text_alignment == GTK_JUSTIFY_CENTER)); + (view->default_text_alignment == PANGO_ALIGN_CENTER)); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), - (view->default_text_alignment == GTK_JUSTIFY_RIGHT)); + (view->default_text_alignment == PANGO_ALIGN_RIGHT)); gdk_color = gl_color_to_gdk_color (view->default_text_color); color_combo_set_color (COLOR_COMBO(property_bar->priv->text_color_combo), gdk_color); @@ -517,20 +516,20 @@ static void update_text_properties (glView *view, glUIPropertyBar *property_bar) { - gboolean can_text, is_first_object; - gboolean is_same_font_family, is_same_font_size; - gboolean is_same_text_color, is_same_is_italic; - gboolean is_same_is_bold, is_same_justification; - GList *p; - glLabelObject *object; - gchar *selection_font_family, *font_family; - gdouble selection_font_size, font_size; - guint selection_text_color, text_color; - glColorNode *text_color_node; - gboolean selection_is_italic, is_italic; - gboolean selection_is_bold, is_bold; - GtkJustification selection_justification, justification; - GdkColor *gdk_color; + gboolean can_text, is_first_object; + gboolean is_same_font_family, is_same_font_size; + gboolean is_same_text_color, is_same_is_italic; + gboolean is_same_is_bold, is_same_align; + GList *p; + glLabelObject *object; + gchar *selection_font_family, *font_family; + gdouble selection_font_size, font_size; + guint selection_text_color, text_color; + glColorNode *text_color_node; + gboolean selection_is_italic, is_italic; + gboolean selection_is_bold, is_bold; + PangoAlignment selection_align, align; + GdkColor *gdk_color; can_text = gl_view_can_selection_text (view); set_text_items_sensitive (property_bar, can_text); @@ -540,7 +539,7 @@ update_text_properties (glView *view, is_same_is_italic = is_same_is_bold = - is_same_justification = + is_same_align = is_same_text_color = is_same_font_size = is_same_font_family = TRUE; @@ -577,15 +576,15 @@ update_text_properties (glView *view, gl_color_node_free (&text_color_node); is_italic = gl_label_object_get_font_italic_flag (object); - is_bold = gl_label_object_get_font_weight (object) == GNOME_FONT_BOLD; - justification = gl_label_object_get_text_alignment (object); + is_bold = gl_label_object_get_font_weight (object) == PANGO_WEIGHT_BOLD; + align = gl_label_object_get_text_alignment (object); if (is_first_object) { selection_font_size = font_size; selection_text_color = text_color; selection_is_italic = is_italic; selection_is_bold = is_bold; - selection_justification = justification; + selection_align = align; } else { if (font_size != selection_font_size) is_same_font_size = FALSE; @@ -595,8 +594,8 @@ update_text_properties (glView *view, is_same_is_italic = FALSE; if (is_bold != selection_is_bold) is_same_is_bold = FALSE; - if (justification != selection_justification) - is_same_justification = FALSE; + if (align != selection_align) + is_same_align = FALSE; } is_first_object = FALSE; } @@ -637,17 +636,17 @@ update_text_properties (glView *view, gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), selection_is_bold && is_same_is_bold); - if (is_same_justification) - gl_debug (DEBUG_PROPERTY_BAR, "same justification"); + if (is_same_align) + gl_debug (DEBUG_PROPERTY_BAR, "same align"); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), - (selection_justification == GTK_JUSTIFY_LEFT) && - is_same_justification); + (selection_align == PANGO_ALIGN_LEFT) && + is_same_align); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), - (selection_justification == GTK_JUSTIFY_CENTER) && - is_same_justification); + (selection_align == PANGO_ALIGN_CENTER) && + is_same_align); gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), - (selection_justification == GTK_JUSTIFY_RIGHT) && - is_same_justification); + (selection_align == PANGO_ALIGN_RIGHT) && + is_same_align); } static void @@ -1112,7 +1111,7 @@ font_bold_toggled_cb (GtkToggleToolButton *toggle, glUIPropertyBar *property_bar) { gboolean state; - GnomeFontWeight weight; + PangoWeight weight; if (property_bar->priv->stop_signals) @@ -1126,7 +1125,7 @@ font_bold_toggled_cb (GtkToggleToolButton *toggle, state = gtk_toggle_tool_button_get_active (toggle); - weight = state ? GNOME_FONT_BOLD : GNOME_FONT_BOOK; + weight = state ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL; gl_view_set_selection_font_weight (property_bar->priv->view, weight); gl_view_set_default_font_weight (property_bar->priv->view, weight); @@ -1187,25 +1186,25 @@ text_align_toggled_cb (GtkToggleToolButton *toggle, if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio))) { gl_view_set_selection_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_LEFT); + PANGO_ALIGN_LEFT); gl_view_set_default_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_LEFT); + PANGO_ALIGN_LEFT); } if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio))) { gl_view_set_selection_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_CENTER); + PANGO_ALIGN_CENTER); gl_view_set_default_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_CENTER); + PANGO_ALIGN_CENTER); } if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio))) { gl_view_set_selection_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_RIGHT); + PANGO_ALIGN_RIGHT); gl_view_set_default_text_alignment (property_bar->priv->view, - GTK_JUSTIFY_RIGHT); + PANGO_ALIGN_RIGHT); } g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), diff --git a/glabels2/src/ui-sidebar.c b/glabels2/src/ui-sidebar.c index 6d59ec67..2c13e557 100644 --- a/glabels2/src/ui-sidebar.c +++ b/glabels2/src/ui-sidebar.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /** * (GLABELS) Label and Business Card Creation program for GNOME @@ -27,7 +27,6 @@ #include "ui-sidebar.h" #include -#include #include "ui-util.h" #include "object-editor.h" diff --git a/glabels2/src/util.c b/glabels2/src/util.c index 9e261164..0273abfc 100644 --- a/glabels2/src/util.c +++ b/glabels2/src/util.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -132,65 +131,65 @@ gl_util_fraction (gdouble x) } /****************************************************************************/ -/* Utilities to deal with GTK_JUSTIFICATION types. */ +/* Utilities to deal with PangoAlignment types. */ /****************************************************************************/ const gchar * -gl_util_just_to_string (GtkJustification just) +gl_util_align_to_string (PangoAlignment align) { - switch (just) { - case GTK_JUSTIFY_LEFT: + switch (align) { + case PANGO_ALIGN_LEFT: return "Left"; - case GTK_JUSTIFY_CENTER: + case PANGO_ALIGN_CENTER: return "Center"; - case GTK_JUSTIFY_RIGHT: + case PANGO_ALIGN_RIGHT: return "Right"; default: return "?"; } } -GtkJustification -gl_util_string_to_just (const gchar *string) +PangoAlignment +gl_util_string_to_align (const gchar *string) { if (g_strcasecmp (string, "Left") == 0) { - return GTK_JUSTIFY_LEFT; + return PANGO_ALIGN_LEFT; } else if (g_strcasecmp (string, "Center") == 0) { - return GTK_JUSTIFY_CENTER; + return PANGO_ALIGN_CENTER; } else if (g_strcasecmp (string, "Right") == 0) { - return GTK_JUSTIFY_RIGHT; + return PANGO_ALIGN_RIGHT; } else { - return GTK_JUSTIFY_LEFT; + return PANGO_ALIGN_LEFT; } } /****************************************************************************/ -/* Utilities to deal with GNOME_FONT_WEIGHT types */ +/* Utilities to deal with PangoWeight types */ /****************************************************************************/ const gchar * -gl_util_weight_to_string (GnomeFontWeight weight) +gl_util_weight_to_string (PangoWeight weight) { switch (weight) { - case GNOME_FONT_BOOK: + case PANGO_WEIGHT_NORMAL: return "Regular"; - case GNOME_FONT_BOLD: + case PANGO_WEIGHT_BOLD: return "Bold"; default: return "?"; } } -GnomeFontWeight +PangoWeight gl_util_string_to_weight (const gchar *string) { if (g_strcasecmp (string, "Regular") == 0) { - return GNOME_FONT_BOOK; + return PANGO_WEIGHT_NORMAL; } else if (g_strcasecmp (string, "Bold") == 0) { - return GNOME_FONT_BOLD; + return PANGO_WEIGHT_BOLD; } else { - return GNOME_FONT_BOOK; + return PANGO_WEIGHT_NORMAL; } } @@ -303,3 +302,52 @@ gl_util_combo_box_add_text_model (GtkComboBox *combo) NULL); } +/****************************************************************************/ +/* Get list of available font families. */ +/****************************************************************************/ +GList * +gl_util_get_font_family_list (void) +{ + GList *list = NULL; + PangoFontMap *fontmap; + PangoContext *context; + PangoFontFamily **families; + gint n; + gint i; + gchar *name; + + fontmap = pango_cairo_font_map_new (); + context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); + + pango_context_list_families (context, &families, &n); + + for ( i=0; inext) { + g_free (p->data); + p->data = NULL; + } + + g_list_free (list); +} + + diff --git a/glabels2/src/util.h b/glabels2/src/util.h index 7b55867b..89fb800d 100644 --- a/glabels2/src/util.h +++ b/glabels2/src/util.h @@ -23,9 +23,9 @@ #ifndef __UTIL_H__ #define __UTIL_H__ -#include +#include #include -#include +#include G_BEGIN_DECLS @@ -36,11 +36,11 @@ gchar *gl_util_make_absolute (const gchar *filename); gchar *gl_util_fraction (gdouble x); -const gchar *gl_util_just_to_string (GtkJustification just); -GtkJustification gl_util_string_to_just (const gchar *string); +const gchar *gl_util_align_to_string (PangoAlignment align); +PangoAlignment gl_util_string_to_align (const gchar *string); -const gchar *gl_util_weight_to_string (GnomeFontWeight weight); -GnomeFontWeight gl_util_string_to_weight (const gchar *string); +const gchar *gl_util_weight_to_string (PangoWeight weight); +PangoWeight gl_util_string_to_weight (const gchar *string); void gl_util_combo_box_set_strings (GtkComboBox *combo, GList *list); @@ -48,6 +48,9 @@ void gl_util_combo_box_set_active_text (GtkComboBox *combo, const gchar *text); void gl_util_combo_box_add_text_model (GtkComboBox *combo); +GList *gl_util_get_font_family_list (void); +void gl_util_font_family_list_free (GList *list); + G_END_DECLS #endif /* __UTIL_H__ */ diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index b6b50339..d18ae686 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -325,7 +325,7 @@ update_object_from_editor_cb (glObjectEditor *editor, GnomeFontWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; gdouble text_line_spacing; gboolean auto_shrink; gboolean shadow_state; @@ -349,7 +349,7 @@ update_object_from_editor_cb (glObjectEditor *editor, font_weight = gl_object_editor_get_font_weight (editor); font_italic_flag = gl_object_editor_get_font_italic_flag (editor); color_node = gl_object_editor_get_text_color (editor); - just = gl_object_editor_get_text_alignment (editor); + align = gl_object_editor_get_text_alignment (editor); text_line_spacing = gl_object_editor_get_text_line_spacing (editor); auto_shrink = gl_object_editor_get_text_auto_shrink (editor); @@ -359,7 +359,7 @@ update_object_from_editor_cb (glObjectEditor *editor, gl_label_object_set_font_weight (object, font_weight); gl_label_object_set_font_italic_flag (object, font_italic_flag); gl_label_object_set_text_color (object, color_node); - gl_label_object_set_text_alignment (object, just); + gl_label_object_set_text_alignment (object, align); gl_label_object_set_text_line_spacing (object, text_line_spacing); gl_label_text_set_auto_shrink (GL_LABEL_TEXT (object), auto_shrink); @@ -434,7 +434,7 @@ update_editor_from_object_cb (glLabelObject *object, GnomeFontWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; gdouble text_line_spacing; gboolean auto_shrink; gboolean shadow_state; @@ -454,7 +454,7 @@ update_editor_from_object_cb (glLabelObject *object, font_weight = gl_label_object_get_font_weight (object); font_italic_flag = gl_label_object_get_font_italic_flag (object); color_node = gl_label_object_get_text_color (object); - just = gl_label_object_get_text_alignment (object); + align = gl_label_object_get_text_alignment (object); text_line_spacing = gl_label_object_get_text_line_spacing (object); auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object)); @@ -463,7 +463,7 @@ update_editor_from_object_cb (glLabelObject *object, gl_object_editor_set_font_weight (editor, font_weight); gl_object_editor_set_font_italic_flag (editor, font_italic_flag); gl_object_editor_set_text_color (editor, (merge != NULL), color_node); - gl_object_editor_set_text_alignment (editor, just); + gl_object_editor_set_text_alignment (editor, align); gl_object_editor_set_text_line_spacing (editor, text_line_spacing); gl_object_editor_set_text_auto_shrink (editor, auto_shrink); @@ -707,7 +707,7 @@ draw_hacktext (glViewText *view_text) gdouble font_size; gdouble text_line_spacing; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; GnomeFont *font; GnomeGlyphList *glyphlist; ArtDRect bbox; @@ -737,7 +737,7 @@ draw_hacktext (glViewText *view_text) { color_node->color = GL_COLOR_MERGE_DEFAULT; } - just = gl_label_object_get_text_alignment (object); + align = gl_label_object_get_text_alignment (object); buffer = gl_label_text_get_buffer(GL_LABEL_TEXT(object)); gtk_text_buffer_get_bounds (buffer, &start, &end); text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); @@ -790,14 +790,14 @@ draw_hacktext (glViewText *view_text) gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox); w = bbox.x1; - switch (just) { - case GTK_JUSTIFY_LEFT: + switch (align) { + case PANGO_ALIGN_LEFT: x_offset = GL_LABEL_TEXT_MARGIN; break; - case GTK_JUSTIFY_CENTER: + case PANGO_ALIGN_CENTER: x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; - case GTK_JUSTIFY_RIGHT: + case PANGO_ALIGN_RIGHT: x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: @@ -837,14 +837,14 @@ draw_hacktext (glViewText *view_text) gnome_glyphlist_bbox (glyphlist, affine, 0, &bbox); w = bbox.x1; - switch (just) { - case GTK_JUSTIFY_LEFT: + switch (align) { + case PANGO_ALIGN_LEFT: x_offset = GL_LABEL_TEXT_MARGIN; break; - case GTK_JUSTIFY_CENTER: + case PANGO_ALIGN_CENTER: x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; - case GTK_JUSTIFY_RIGHT: + case PANGO_ALIGN_RIGHT: x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: @@ -899,7 +899,7 @@ draw_cursor (glViewText *view_text) gboolean font_italic_flag; gdouble font_size; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; GnomeFont *font; GnomeGlyphList *glyphlist; ArtDRect bbox; @@ -923,7 +923,7 @@ draw_cursor (glViewText *view_text) font_weight = gl_label_object_get_font_weight (object); font_italic_flag = gl_label_object_get_font_italic_flag (object); color_node = gl_label_object_get_text_color (object); - just = gl_label_object_get_text_alignment (object); + align = gl_label_object_get_text_alignment (object); buffer = gl_label_text_get_buffer(GL_LABEL_TEXT(object)); gtk_text_buffer_get_bounds (buffer, &start, &end); text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); @@ -960,14 +960,14 @@ draw_cursor (glViewText *view_text) gnome_glyphlist_unref (glyphlist); w = bbox.x1; - switch (just) { - case GTK_JUSTIFY_LEFT: + switch (align) { + case PANGO_ALIGN_LEFT: x_offset = GL_LABEL_TEXT_MARGIN; break; - case GTK_JUSTIFY_CENTER: + case PANGO_ALIGN_CENTER: x_offset = (object_w - GL_LABEL_TEXT_MARGIN - w) / 2.0; break; - case GTK_JUSTIFY_RIGHT: + case PANGO_ALIGN_RIGHT: x_offset = object_w - GL_LABEL_TEXT_MARGIN - w; break; default: diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 9c0eb9a4..3ec7d13c 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ /* * (GLABELS) Label and Business Card Creation program for GNOME @@ -2840,7 +2840,7 @@ gl_view_set_selection_font_italic_flag (glView *view, /*****************************************************************************/ void gl_view_set_selection_text_alignment (glView *view, - GtkJustification text_alignment) + PangoAlignment text_alignment) { GList *p; glLabelObject *object; @@ -3829,7 +3829,7 @@ gl_view_set_default_text_color (glView *view, /****************************************************************************/ void gl_view_set_default_text_alignment (glView *view, - GtkJustification text_alignment) + PangoAlignment text_alignment) { gl_debug (DEBUG_VIEW, "START"); @@ -3991,12 +3991,12 @@ gl_view_get_default_text_color (glView *view) /****************************************************************************/ /* Get default text alignment. */ /****************************************************************************/ -GtkJustification +PangoAlignment gl_view_get_default_text_alignment (glView *view) { gl_debug (DEBUG_VIEW, "START"); - g_return_val_if_fail (view && GL_IS_VIEW (view), GTK_JUSTIFY_LEFT); + g_return_val_if_fail (view && GL_IS_VIEW (view), PANGO_ALIGN_LEFT); gl_debug (DEBUG_VIEW, "END"); diff --git a/glabels2/src/view.h b/glabels2/src/view.h index 28c6d436..9006ec88 100644 --- a/glabels2/src/view.h +++ b/glabels2/src/view.h @@ -26,7 +26,6 @@ #define __VIEW_H__ #include -#include #include #include @@ -85,7 +84,7 @@ struct _glView { GnomeFontWeight default_font_weight; gboolean default_font_italic_flag; guint default_text_color; - GtkJustification default_text_alignment; + PangoAlignment default_text_alignment; gdouble default_text_line_spacing; /* Default object line properties */ @@ -227,7 +226,7 @@ void gl_view_set_selection_font_italic_flag (glView *view, gboolean font_italic_flag); void gl_view_set_selection_text_alignment (glView *view, - GtkJustification text_alignment); + PangoAlignment text_alignment); void gl_view_set_selection_text_color (glView *view, glColorNode *text_color_node); @@ -287,7 +286,7 @@ void gl_view_set_default_text_color (glView *view, guint text_color); void gl_view_set_default_text_alignment (glView *view, - GtkJustification text_alignment); + PangoAlignment text_alignment); void gl_view_set_default_line_width (glView *view, gdouble line_width); @@ -312,7 +311,7 @@ gboolean gl_view_get_default_font_italic_flag (glView *view); guint gl_view_get_default_text_color (glView *view); -GtkJustification gl_view_get_default_text_alignment (glView *view); +PangoAlignment gl_view_get_default_text_alignment (glView *view); gdouble gl_view_get_default_text_line_spacing (glView *view); diff --git a/glabels2/src/xml-label-04.c b/glabels2/src/xml-label-04.c index c5eb9a76..a0c5515b 100644 --- a/glabels2/src/xml-label-04.c +++ b/glabels2/src/xml-label-04.c @@ -34,6 +34,7 @@ #include "label-barcode.h" #include +#include "util.h" #include "debug.h" static gboolean xml04_parse_media_description (xmlNodePtr node, @@ -194,10 +195,10 @@ xml04_parse_text_props (xmlNodePtr object_node, { xmlChar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; xmlNodePtr line_node, text_node; glTextNode *node_text; GList *nodes, *lines; @@ -214,7 +215,7 @@ xml04_parse_text_props (xmlNodePtr object_node, font_italic_flag = gl_xml_get_prop_boolean (object_node, "font_italic", FALSE); string = xmlGetProp (object_node, (xmlChar *)"justify"); - just = gl_util_string_to_just (string); + align = gl_util_string_to_align (string); xmlFree (string); color_node = gl_color_node_new_default (); @@ -225,7 +226,7 @@ xml04_parse_text_props (xmlNodePtr object_node, gl_label_object_set_font_weight (GL_LABEL_OBJECT(object), font_weight); gl_label_object_set_font_italic_flag (GL_LABEL_OBJECT(object), font_italic_flag); gl_label_object_set_text_color (GL_LABEL_OBJECT(object), color_node); - gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just); + gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), align); gl_color_node_free (&color_node); @@ -282,15 +283,15 @@ xml04_parse_text_props (xmlNodePtr object_node, /* Adjust location. In 0.4.x, text was anchored at x,y */ gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - switch (just) { - case GTK_JUSTIFY_LEFT: + switch (align) { + case PANGO_ALIGN_LEFT: /* nothing */ break; - case GTK_JUSTIFY_CENTER: + case PANGO_ALIGN_CENTER: x -= w/2.0; gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); break; - case GTK_JUSTIFY_RIGHT: + case PANGO_ALIGN_RIGHT: x -= w; gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); break; diff --git a/glabels2/src/xml-label-191.c b/glabels2/src/xml-label-191.c index 0b580b7c..21479da0 100644 --- a/glabels2/src/xml-label-191.c +++ b/glabels2/src/xml-label-191.c @@ -269,10 +269,10 @@ xml191_parse_text_props (xmlNodePtr object_node, gdouble w, h; xmlChar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; xmlNodePtr line_node, text_node; glTextNode *node_text; GList *nodes; @@ -296,7 +296,7 @@ xml191_parse_text_props (xmlNodePtr object_node, font_italic_flag = gl_xml_get_prop_boolean (object_node, "font_italic", FALSE); string = xmlGetProp (object_node, (xmlChar *)"justify"); - just = gl_util_string_to_just ((gchar *)string); + align = gl_util_string_to_align ((gchar *)string); xmlFree (string); color_node = gl_color_node_new_default (); @@ -347,7 +347,7 @@ xml191_parse_text_props (xmlNodePtr object_node, gl_label_object_set_font_weight (GL_LABEL_OBJECT(object), font_weight); gl_label_object_set_font_italic_flag (GL_LABEL_OBJECT(object), font_italic_flag); gl_label_object_set_text_color (GL_LABEL_OBJECT(object), color_node); - gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just); + gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), align); gl_color_node_free (&color_node); gl_text_node_lines_free (&lines); diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index 71ce6ba8..2234bf3b 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -421,7 +421,7 @@ xml_parse_object_text (xmlNodePtr node, gdouble x, y; gdouble w, h; gchar *string; - GtkJustification just; + PangoAlignment align; gboolean auto_shrink; xmlNodePtr child; @@ -441,9 +441,9 @@ xml_parse_object_text (xmlNodePtr node, /* justify attr */ string = gl_xml_get_prop_string (node, "justify", NULL); - just = gl_util_string_to_just (string); + align = gl_util_string_to_align (string); g_free (string); - gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), just); + gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), align); /* auto_shrink attr */ auto_shrink = gl_xml_get_prop_boolean (node, "auto_shrink", FALSE); @@ -899,7 +899,7 @@ xml_parse_toplevel_span (xmlNodePtr node, { gchar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; gdouble text_line_spacing; @@ -1221,7 +1221,7 @@ xml_create_object_text (xmlNodePtr root, xmlNodePtr node; gdouble x, y; gdouble w, h; - GtkJustification just; + PangoAlignment align; gboolean auto_shrink; gl_debug (DEBUG_XML, "START"); @@ -1239,8 +1239,8 @@ xml_create_object_text (xmlNodePtr root, gl_xml_set_prop_length (node, "h", h); /* justify attr */ - just = gl_label_object_get_text_alignment (object); - gl_xml_set_prop_string (node, "justify", gl_util_just_to_string (just)); + align = gl_label_object_get_text_alignment (object); + gl_xml_set_prop_string (node, "justify", gl_util_align_to_string (align)); /* auto_shrink attr */ auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object)); @@ -1675,10 +1675,10 @@ xml_create_toplevel_span (xmlNodePtr root, xmlNodePtr node; gchar *font_family; gdouble font_size; - GnomeFontWeight font_weight; + PangoWeight font_weight; gboolean font_italic_flag; glColorNode *color_node; - GtkJustification just; + PangoAlignment align; gdouble text_line_spacing; GList *lines, *p_line, *p_node; glTextNode *text_node; @@ -1704,7 +1704,7 @@ xml_create_toplevel_span (xmlNodePtr root, } gl_color_node_free (&color_node); - just = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object_text)); + align = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object_text)); gl_xml_set_prop_string (node, "font_family", font_family); gl_xml_set_prop_double (node, "font_size", font_size); gl_xml_set_prop_string (node, "font_weight", gl_util_weight_to_string (font_weight)); -- 2.39.5