+2007-01-19 Jim Evins <evins@snaught.com>
+
+ * 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 <evins@snaught.com>
* src/Makefile.am:
#ifndef __LABEL_BARCODE_H__
#define __LABEL_BARCODE_H__
-#include <gtk/gtkenums.h>
-#include <libgnomeprint/gnome-font.h>
#include "bc.h"
#include "text-node.h"
#include "label-object.h"
+/* -*- 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 <evins@snaught.com>.
+ * Copyright (C) 2001-2007 Jim Evins <evins@snaught.com>.
*
* 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
/****************************************************************************/
void
gl_label_object_set_font_weight (glLabelObject *object,
- GnomeFontWeight font_weight)
+ PangoWeight font_weight)
{
gl_debug (DEBUG_LABEL, "START");
/****************************************************************************/
void
gl_label_object_set_text_alignment (glLabelObject *object,
- GtkJustification text_alignment)
+ PangoAlignment text_alignment)
{
gl_debug (DEBUG_LABEL, "START");
/****************************************************************************/
/* 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 ) {
/****************************************************************************/
/* 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 ) {
+/* -*- 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 <evins@snaught.com>.
+ * Copyright (C) 2001-2007 Jim Evins <evins@snaught.com>.
*
* 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
#define __LABEL_OBJECT_H__
#include <glib-object.h>
-#include <gtk/gtkenums.h>
-#include <libgnomeprint/gnome-font.h>
+#include <pango/pango.h>
G_BEGIN_DECLS
#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;
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);
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);
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);
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);
+/* -*- 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 <evins@snaught.com>.
+ * Copyright (C) 2001-2007 Jim Evins <evins@snaught.com>.
*
* 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
#include <glib/gmem.h>
#include <glib/gstrfuncs.h>
#include <glib/gmessages.h>
-#include <libgnomeprint/gnome-glyphlist.h>
+#include <pango/pango.h>
+
+#include "util.h"
#include "debug.h"
#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. */
/*========================================================*/
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;
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);
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);
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;
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;
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");
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");
}
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 {
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) {
/*---------------------------------------------------------------------------*/
static void
set_font_weight (glLabelObject *object,
- GnomeFontWeight font_weight)
+ PangoWeight font_weight)
{
glLabelText *ltext = (glLabelText *)object;
/*---------------------------------------------------------------------------*/
static void
set_text_alignment (glLabelObject *object,
- GtkJustification text_alignment)
+ PangoAlignment text_alignment)
{
glLabelText *ltext = (glLabelText *)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));
}
/*---------------------------------------------------------------------------*/
/* 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;
}
/*---------------------------------------------------------------------------*/
/* PRIVATE. get text alignment method. */
/*---------------------------------------------------------------------------*/
-static GtkJustification
+static PangoAlignment
get_text_alignment (glLabelObject *object)
{
glLabelText *ltext = (glLabelText *)object;
g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), GTK_JUSTIFY_LEFT);
- return ltext->private->just;
+ return ltext->private->align;
}
/*---------------------------------------------------------------------------*/
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
/*
* (GLABELS) Label and Business Card Creation program for GNOME
*
#ifndef __LABEL_TEXT_H__
#define __LABEL_TEXT_H__
-#include <gtk/gtkenums.h>
#include <gtk/gtktextbuffer.h>
-#include <libgnomeprint/gnome-font.h>
#include "text-node.h"
#include "label-object.h"
#include "prefs.h"
#include "mygal/widget-color-combo.h"
#include "color.h"
+#include "util.h"
#include "object-editor-private.h"
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);
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 {
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);
/*****************************************************************************/
void
gl_object_editor_set_font_weight (glObjectEditor *editor,
- GnomeFontWeight font_weight)
+ PangoWeight font_weight)
{
gl_debug (DEBUG_EDITOR, "START");
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,
/*****************************************************************************/
/* 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");
/*****************************************************************************/
void
gl_object_editor_set_text_alignment (glObjectEditor *editor,
- GtkJustification just)
+ PangoAlignment align)
{
gl_debug (DEBUG_EDITOR, "START");
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,
/*****************************************************************************/
/* 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;
}
/*****************************************************************************/
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");
}
#define __OBJECT_EDITOR_H__
#include <gtk/gtkvbox.h>
-#include <gtk/gtkenums.h>
-#include <libgnomeprint/gnome-font.h>
#include <gtk/gtktextbuffer.h>
#include "text-node.h"
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);
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);
#include "prefs-dialog.h"
#include <glib/gi18n.h>
-#include <libgnomeprint/gnome-font.h>
#include <glade/glade-xml.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkstock.h>
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),
/* 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)) {
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);
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);
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 =
#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
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,
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 =
#define __PREFS_MODEL_H__
#include <glib-object.h>
-#include <gtk/gtkenums.h>
#include <gconf/gconf-client.h>
-#include <libgnomeprint/gnome-font.h>
+#include <pango/pango.h>
#include <libglabels/enums.h>
G_BEGIN_DECLS
/* 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 */
#include <math.h>
#include <time.h>
#include <ctype.h>
-#include <gtk/gtkenums.h>
#include "label.h"
#include "label-text.h"
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];
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);
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;
-/* -*- 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
#include <gtk/gtkspinbutton.h>
#include <gtk/gtktoolbar.h>
#include <gtk/gtktoggletoolbutton.h>
-#include <libgnomeprint/gnome-font.h>
#include <gtk/gtktooltips.h>
#include <string.h>
/* 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);
} 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);
/* 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),
/* 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);
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)) {
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);
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);
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;
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;
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;
}
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
glUIPropertyBar *property_bar)
{
gboolean state;
- GnomeFontWeight weight;
+ PangoWeight weight;
if (property_bar->priv->stop_signals)
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);
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),
-/* -*- 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
#include "ui-sidebar.h"
#include <glib/gi18n.h>
-#include <libgnomeprint/gnome-font.h>
#include "ui-util.h"
#include "object-editor.h"
#include <string.h>
#include <glib.h>
#include <math.h>
-#include <libgnomeprint/gnome-font.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkcelllayout.h>
}
/****************************************************************************/
-/* 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;
}
}
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; i<n; i++ )
+ {
+ name = g_strdup (pango_font_family_get_name (families[i]));
+ list = g_list_append (list, name);
+ }
+
+ g_free (families);
+
+ g_object_unref (context);
+ g_object_unref (fontmap);
+
+ return list;
+}
+
+/****************************************************************************/
+/* Free previosly allocated list of font families. */
+/****************************************************************************/
+void gl_util_font_family_list_free (GList *list)
+{
+ GList *p;
+
+ for (p = list; p != NULL; p = p->next) {
+ g_free (p->data);
+ p->data = NULL;
+ }
+
+ g_list_free (list);
+}
+
+
#ifndef __UTIL_H__
#define __UTIL_H__
-#include <gtk/gtkenums.h>
+#include <glib/glist.h>
#include <gtk/gtkcombobox.h>
-#include <libgnomeprint/gnome-font.h>
+#include <pango/pango.h>
G_BEGIN_DECLS
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);
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__ */
GnomeFontWeight font_weight;
gboolean font_italic_flag;
glColorNode *color_node;
- GtkJustification just;
+ PangoAlignment align;
gdouble text_line_spacing;
gboolean auto_shrink;
gboolean shadow_state;
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);
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);
GnomeFontWeight font_weight;
gboolean font_italic_flag;
glColorNode *color_node;
- GtkJustification just;
+ PangoAlignment align;
gdouble text_line_spacing;
gboolean auto_shrink;
gboolean shadow_state;
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));
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);
gdouble font_size;
gdouble text_line_spacing;
glColorNode *color_node;
- GtkJustification just;
+ PangoAlignment align;
GnomeFont *font;
GnomeGlyphList *glyphlist;
ArtDRect bbox;
{
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);
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:
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:
gboolean font_italic_flag;
gdouble font_size;
glColorNode *color_node;
- GtkJustification just;
+ PangoAlignment align;
GnomeFont *font;
GnomeGlyphList *glyphlist;
ArtDRect bbox;
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);
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:
-/* -*- 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
/*****************************************************************************/
void
gl_view_set_selection_text_alignment (glView *view,
- GtkJustification text_alignment)
+ PangoAlignment text_alignment)
{
GList *p;
glLabelObject *object;
/****************************************************************************/
void
gl_view_set_default_text_alignment (glView *view,
- GtkJustification text_alignment)
+ PangoAlignment text_alignment)
{
gl_debug (DEBUG_VIEW, "START");
/****************************************************************************/
/* 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");
#define __VIEW_H__
#include <gtk/gtkvbox.h>
-#include <gtk/gtkenums.h>
#include <libgnomecanvas/libgnomecanvas.h>
#include <libgnomeprint/gnome-font.h>
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 */
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);
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);
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);
#include "label-barcode.h"
#include <libglabels/xml.h>
+#include "util.h"
#include "debug.h"
static gboolean xml04_parse_media_description (xmlNodePtr 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;
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 ();
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);
/* 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;
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;
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 ();
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);
gdouble x, y;
gdouble w, h;
gchar *string;
- GtkJustification just;
+ PangoAlignment align;
gboolean auto_shrink;
xmlNodePtr child;
/* 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);
{
gchar *font_family;
gdouble font_size;
- GnomeFontWeight font_weight;
+ PangoWeight font_weight;
gboolean font_italic_flag;
glColorNode *color_node;
gdouble text_line_spacing;
xmlNodePtr node;
gdouble x, y;
gdouble w, h;
- GtkJustification just;
+ PangoAlignment align;
gboolean auto_shrink;
gl_debug (DEBUG_XML, "START");
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));
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;
}
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));