From: Jim Evins Date: Tue, 30 Dec 2003 07:25:43 +0000 (+0000) Subject: 2003-12-30 Wayne Schuller X-Git-Tag: glabels-2_3_0~497 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e4a19ad71c510363fa80e14c98f65c10a1f187ac;p=glabels 2003-12-30 Wayne Schuller Added feature: line spacing - allows you to comfortably space a text box to fit a label perfectly. * data/glabels-2.0.dtd: * src/label-object.c: (gl_label_object_set_text_line_spacing), (gl_label_object_get_text_alignment), (gl_label_object_get_text_line_spacing): * src/label-object.h: * src/label-text.c: (gl_label_text_class_init), (gl_label_text_instance_init), (copy), (get_size), (set_text_line_spacing), (get_text_alignment), (get_text_line_spacing): * src/object-editor-private.h: * src/object-editor-text-page.c: (gl_object_editor_prepare_text_page), (gl_object_editor_set_text_line_spacing), (gl_object_editor_get_text_line_spacing): * src/object-editor.glade: * src/object-editor.h: * src/prefs-dialog.c: (construct_object_page), (update_object_page_from_prefs), (update_prefs_from_object_page): * src/prefs-dialog.glade: * src/prefs-model.c: (gl_prefs_model_save_settings), (gl_prefs_model_load_settings), (get_float): * src/prefs-model.h: * src/print.c: (draw_text_object): * src/ui-sidebar.c: * src/view-text.c: (update_object_from_editor_cb), (update_editor_from_object_cb), (gl_view_text_create_event_handler), (draw_hacktext): * src/view.c: (gl_view_construct), (gl_view_set_selection_text_line_spacing), (gl_view_set_default_text_line_spacing), (gl_view_get_default_text_line_spacing): * src/view.h: * src/xml-label.c: (xml_parse_toplevel_span), (xml_create_toplevel_span): git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@398 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 2c2a6bc4..ae921b95 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,43 @@ +2003-12-30 Wayne Schuller + + Added feature: line spacing - allows you to comfortably space a text box to + fit a label perfectly. + + * data/glabels-2.0.dtd: + * src/label-object.c: (gl_label_object_set_text_line_spacing), + (gl_label_object_get_text_alignment), + (gl_label_object_get_text_line_spacing): + * src/label-object.h: + * src/label-text.c: (gl_label_text_class_init), + (gl_label_text_instance_init), (copy), (get_size), + (set_text_line_spacing), (get_text_alignment), + (get_text_line_spacing): + * src/object-editor-private.h: + * src/object-editor-text-page.c: + (gl_object_editor_prepare_text_page), + (gl_object_editor_set_text_line_spacing), + (gl_object_editor_get_text_line_spacing): + * src/object-editor.glade: + * src/object-editor.h: + * src/prefs-dialog.c: (construct_object_page), + (update_object_page_from_prefs), (update_prefs_from_object_page): + * src/prefs-dialog.glade: + * src/prefs-model.c: (gl_prefs_model_save_settings), + (gl_prefs_model_load_settings), (get_float): + * src/prefs-model.h: + * src/print.c: (draw_text_object): + * src/ui-sidebar.c: + * src/view-text.c: (update_object_from_editor_cb), + (update_editor_from_object_cb), + (gl_view_text_create_event_handler), (draw_hacktext): + * src/view.c: (gl_view_construct), + (gl_view_set_selection_text_line_spacing), + (gl_view_set_default_text_line_spacing), + (gl_view_get_default_text_line_spacing): + * src/view.h: + * src/xml-label.c: (xml_parse_toplevel_span), + (xml_create_toplevel_span): + 2003-12-30 Jim Evins * src/template-designer.c: diff --git a/glabels2/data/glabels-2.0.dtd b/glabels2/data/glabels-2.0.dtd index 7132aedb..287dfd3a 100644 --- a/glabels2/data/glabels-2.0.dtd +++ b/glabels2/data/glabels-2.0.dtd @@ -294,6 +294,7 @@ font_weight %FONT_WEIGHT_TYPE; #IMPLIED font_italic %BOOLEAN_TYPE; #IMPLIED color %UINT_TYPE; #IMPLIED + line_spacing %LENGTH_TYPE; #IMPLIED > diff --git a/glabels2/src/label-object.c b/glabels2/src/label-object.c index ebdafab1..1f9b9538 100644 --- a/glabels2/src/label-object.c +++ b/glabels2/src/label-object.c @@ -684,6 +684,27 @@ gl_label_object_set_text_alignment (glLabelObject *object, gl_debug (DEBUG_LABEL, "END"); } +/****************************************************************************/ +/* Set text line spacing for all text contained in object. */ +/****************************************************************************/ +void +gl_label_object_set_text_line_spacing (glLabelObject *object, + gdouble text_line_spacing) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if ( GL_LABEL_OBJECT_GET_CLASS(object)->set_text_line_spacing != NULL ) { + + /* We have an object specific method, use it */ + GL_LABEL_OBJECT_GET_CLASS(object)->set_text_line_spacing (object, text_line_spacing); + + } + + gl_debug (DEBUG_LABEL, "END"); +} + /****************************************************************************/ /* Set text color for all text contained in object. */ /****************************************************************************/ @@ -825,6 +846,30 @@ gl_label_object_get_text_alignment (glLabelObject *object) return ret; } +/****************************************************************************/ +/* Get text line spacing for all text contained in object. */ +/****************************************************************************/ +gdouble +gl_label_object_get_text_line_spacing (glLabelObject *object) +{ + gdouble ret = 0.0; + + gl_debug (DEBUG_LABEL, "START"); + + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), 0.0); + + if ( GL_LABEL_OBJECT_GET_CLASS(object)->get_text_line_spacing != NULL ) { + + /* We have an object specific method, use it */ + ret = GL_LABEL_OBJECT_GET_CLASS(object)->get_text_line_spacing (object); + + } + + gl_debug (DEBUG_LABEL, "END"); + + return ret; +} + /****************************************************************************/ /* Get text color for all text contained in object. */ /****************************************************************************/ diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index d2fe2009..1ffa6209 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -93,6 +93,9 @@ struct _glLabelObjectClass { void (*set_text_alignment) (glLabelObject *object, GtkJustification text_alignment); + void (*set_text_line_spacing) (glLabelObject *object, + gdouble text_line_spacing); + void (*set_text_color) (glLabelObject *object, guint text_color); @@ -115,6 +118,8 @@ struct _glLabelObjectClass { GtkJustification (*get_text_alignment) (glLabelObject *object); + gdouble (*get_text_line_spacing) (glLabelObject *object); + guint (*get_text_color) (glLabelObject *object); guint (*get_fill_color) (glLabelObject *object); @@ -217,6 +222,9 @@ void gl_label_object_set_text_alignment (glLabelObject *object, void gl_label_object_set_text_color (glLabelObject *object, guint text_color); +void gl_label_object_set_text_line_spacing (glLabelObject *object, + gdouble text_line_spacing); + gchar *gl_label_object_get_font_family (glLabelObject *object); @@ -228,6 +236,8 @@ gboolean gl_label_object_get_font_italic_flag (glLabelObject *objec GtkJustification gl_label_object_get_text_alignment (glLabelObject *object); +gdouble gl_label_object_get_text_line_spacing (glLabelObject *object); + guint gl_label_object_get_text_color (glLabelObject *object); diff --git a/glabels2/src/label-text.c b/glabels2/src/label-text.c index 2bd0380c..b85c860d 100644 --- a/glabels2/src/label-text.c +++ b/glabels2/src/label-text.c @@ -39,6 +39,7 @@ #define DEFAULT_FONT_ITALIC_FLAG FALSE #define DEFAULT_JUST GTK_JUSTIFY_LEFT #define DEFAULT_COLOR GNOME_CANVAS_COLOR (0,0,0) +#define DEFAULT_TEXT_LINE_SPACING 1.0 /*========================================================*/ /* Private types. */ @@ -54,6 +55,7 @@ struct _glLabelTextPrivate { gboolean font_italic_flag; GtkJustification just; guint color; + gdouble line_spacing; }; /*========================================================*/ @@ -97,6 +99,9 @@ static void set_font_italic_flag (glLabelObject *object, static void set_text_alignment (glLabelObject *object, GtkJustification text_alignment); +static void set_text_line_spacing (glLabelObject *object, + gdouble text_line_spacing); + static void set_text_color (glLabelObject *object, guint text_color); @@ -110,6 +115,8 @@ static gboolean get_font_italic_flag (glLabelObject *object); static GtkJustification get_text_alignment (glLabelObject *object); +static gdouble get_text_line_spacing (glLabelObject *object); + static guint get_text_color (glLabelObject *object); @@ -158,12 +165,14 @@ gl_label_text_class_init (glLabelTextClass *klass) label_object_class->set_font_weight = set_font_weight; label_object_class->set_font_italic_flag = set_font_italic_flag; label_object_class->set_text_alignment = set_text_alignment; + label_object_class->set_text_line_spacing = set_text_line_spacing; label_object_class->set_text_color = set_text_color; label_object_class->get_font_family = get_font_family; label_object_class->get_font_size = get_font_size; label_object_class->get_font_weight = get_font_weight; label_object_class->get_font_italic_flag = get_font_italic_flag; label_object_class->get_text_alignment = get_text_alignment; + label_object_class->get_text_line_spacing = get_text_line_spacing; label_object_class->get_text_color = get_text_color; object_class->finalize = gl_label_text_finalize; @@ -183,6 +192,7 @@ gl_label_text_instance_init (glLabelText *ltext) ltext->private->font_italic_flag = DEFAULT_FONT_ITALIC_FLAG; ltext->private->just = DEFAULT_JUST; ltext->private->color = DEFAULT_COLOR; + ltext->private->line_spacing = DEFAULT_TEXT_LINE_SPACING; g_signal_connect (G_OBJECT(ltext->private->buffer), "changed", G_CALLBACK(buffer_changed_cb), ltext); @@ -244,6 +254,7 @@ copy (glLabelObject *dst_object, new_ltext->private->font_italic_flag = ltext->private->font_italic_flag; new_ltext->private->color = ltext->private->color; new_ltext->private->just = ltext->private->just; + new_ltext->private->line_spacing = ltext->private->line_spacing; gl_text_node_lines_free (&lines); @@ -377,7 +388,11 @@ get_size (glLabelObject *object, if ( bbox.x1 > *w ) *w = bbox.x1; - *h += ltext->private->font_size; + if (i) { + *h += ltext->private->line_spacing * ltext->private->font_size; + } else { + *h += ltext->private->font_size; + } } @@ -529,6 +544,29 @@ set_text_alignment (glLabelObject *object, gl_debug (DEBUG_LABEL, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. set text line spacing method. */ +/*---------------------------------------------------------------------------*/ +static void +set_text_line_spacing (glLabelObject *object, + gdouble line_spacing) +{ + glLabelText *ltext = (glLabelText *)object; + + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext)); + + if (ltext->private->line_spacing != line_spacing) { + + ltext->private->line_spacing = line_spacing; + gl_label_object_emit_changed (GL_LABEL_OBJECT(ltext)); + + } + + gl_debug (DEBUG_LABEL, "END"); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. set text color method. */ /*---------------------------------------------------------------------------*/ @@ -627,6 +665,21 @@ get_text_alignment (glLabelObject *object) return ltext->private->just; } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. get text line spacing method. */ +/*---------------------------------------------------------------------------*/ +static gdouble +get_text_line_spacing (glLabelObject *object) +{ + glLabelText *ltext = (glLabelText *)object; + + gl_debug (DEBUG_LABEL, ""); + + g_return_val_if_fail (ltext && GL_IS_LABEL_TEXT (ltext), 0.0); + + return ltext->private->line_spacing; +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. get text color method. */ /*---------------------------------------------------------------------------*/ diff --git a/glabels2/src/object-editor-private.h b/glabels2/src/object-editor-private.h index f3672d20..61122cd7 100644 --- a/glabels2/src/object-editor-private.h +++ b/glabels2/src/object-editor-private.h @@ -96,6 +96,7 @@ struct _glObjectEditorPrivate { GtkWidget *text_left_toggle; GtkWidget *text_center_toggle; GtkWidget *text_right_toggle; + GtkWidget *text_line_spacing_spin; GtkWidget *edit_page_vbox; GtkWidget *edit_text_view; diff --git a/glabels2/src/object-editor-text-page.c b/glabels2/src/object-editor-text-page.c index 4a8ce49a..f22b1cd6 100644 --- a/glabels2/src/object-editor-text-page.c +++ b/glabels2/src/object-editor-text-page.c @@ -86,6 +86,8 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) glade_xml_get_widget (editor->priv->gui, "text_center_toggle"); editor->priv->text_right_toggle = glade_xml_get_widget (editor->priv->gui, "text_right_toggle"); + editor->priv->text_line_spacing_spin = + glade_xml_get_widget (editor->priv->gui, "text_line_spacing_spin"); /* Load family names */ family_names = gnome_font_family_list (); @@ -105,6 +107,8 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) gtk_size_group_add_widget (label_size_group, label); label = glade_xml_get_widget (editor->priv->gui, "text_align_label"); gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "text_line_spacing_label"); + gtk_size_group_add_widget (label_size_group, label); /* Un-hide */ gtk_widget_show_all (editor->priv->text_page_vbox); @@ -144,6 +148,11 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) G_CALLBACK (align_toggle_cb), G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_line_spacing_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + gl_debug (DEBUG_EDITOR, "END"); } @@ -496,4 +505,44 @@ gl_object_editor_get_text_color (glObjectEditor *editor) } +/*****************************************************************************/ +/* Set text line spacing. */ +/*****************************************************************************/ +void +gl_object_editor_set_text_line_spacing (glObjectEditor *editor, + gdouble text_line_spacing) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_line_spacing_spin), + gl_object_editor_changed_cb, + editor); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->text_line_spacing_spin), + text_line_spacing); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_line_spacing_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query text line spacing. */ +/*****************************************************************************/ +gdouble +gl_object_editor_get_text_line_spacing (glObjectEditor *editor) +{ + gdouble text_line_spacing; + + gl_debug (DEBUG_EDITOR, "START"); + + text_line_spacing = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->text_line_spacing_spin)); + + gl_debug (DEBUG_EDITOR, "END"); + + return text_line_spacing; +} diff --git a/glabels2/src/object-editor.glade b/glabels2/src/object-editor.glade index b4497479..d2ed9164 100644 --- a/glabels2/src/object-editor.glade +++ b/glabels2/src/object-editor.glade @@ -155,8 +155,8 @@ 0 - False - False + True + True @@ -284,13 +284,16 @@ 12 True False - 12 + 0 - + True + 6 + 2 False - 12 + 12 + 12 @@ -307,61 +310,14 @@ 0 - 0 - False - False - - - - - - True - True - False - False - True - False - - - - True - True - True - True - 0 - - True - * - False - - - - - - True - GTK_SELECTION_BROWSE - - - - - 0 - False - False + 0 + 1 + 0 + 1 + fill + - - - 0 - False - False - - - - - - True - False - 12 @@ -378,43 +334,14 @@ 0 - 0 - False - False - - - - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 1 100 1 10 10 - - - 0 - False - False + 0 + 1 + 1 + 2 + fill + - - - 0 - False - False - - - - - - True - False - 12 @@ -431,83 +358,67 @@ 0 - 0 - False - False + 0 + 1 + 2 + 3 + fill + - + True - True - GTK_RELIEF_NORMAL - False - False - - - - True - gtk-bold - 4 - 0.5 - 0.5 - 0 - 0 - - + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 - 0 - False - False + 0 + 1 + 3 + 4 + fill + - + True - True - GTK_RELIEF_NORMAL - False - False - - - - True - gtk-italic - 4 - 0.5 - 0.5 - 0 - 0 - - + Alignment: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 - 0 - False - False + 0 + 1 + 4 + 5 + fill + - - - 0 - False - False - - - - - - True - False - 12 - + True - Color: + Line Spacing: False False GTK_JUSTIFY_LEFT @@ -519,146 +430,339 @@ 0 - 0 - False - False + 0 + 1 + 5 + 6 + fill + - + True - gl_object_editor_construct_color_combo - 2 - 0 - Sun, 16 Nov 2003 06:52:23 GMT + False + 12 + + + + True + True + False + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 0 + 1 + fill - - - 0 - False - False - - - - - - True - False - 12 - + True - Alignment: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 + False + 12 + + + + True + True + 0.01 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 100 1 10 10 + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill - + True - True - GTK_RELIEF_NORMAL - False - False + False + 12 - + True - gtk-justify-left - 4 - 0.5 - 0.5 - 0 - 0 + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-bold + 4 + 0.5 + 0.5 + 0 + 0 + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-italic + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + - 0 - False - False + 1 + 2 + 2 + 3 + fill + fill - + True - True - GTK_RELIEF_NORMAL - False - False + False + 12 - + True - gtk-justify-center - 4 - 0.5 - 0.5 - 0 - 0 + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-left + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-center + 4 + 0.5 + 0.5 + 0 + 0 + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-right + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + - 0 - False - False + 1 + 2 + 4 + 5 + fill + fill - + True - True - GTK_RELIEF_NORMAL - False - False + False + 12 - + True - gtk-justify-right - 4 - 0.5 - 0.5 - 0 - 0 + gl_object_editor_construct_color_combo + 2 + 0 + Sun, 16 Nov 2003 06:52:23 GMT + + 0 + False + False + - 0 - False - False + 1 + 2 + 3 + 4 + fill + fill - - - 0 - False - False + + + + True + False + 12 + + + + True + True + 0.01 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 5 0.01 0.1 0.1 + + + 0 + False + False + + + + + 1 + 2 + 5 + 6 + fill + fill + + + + + 0 + True + True @@ -695,10 +799,13 @@ 12 - + True + 2 + 2 False - 12 + 12 + 12 @@ -715,64 +822,69 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - True - 0.25 - 2 - True - GTK_UPDATE_ALWAYS - False - False - 1 0.25 4 0.25 1 1 - - - 0 - False - False - - + False + 12 - - - True - points - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + False + False + 1 0.25 4 0.25 1 1 + + + 0 + False + False + + + + + + True + points + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 0 + 1 + fill - - - 0 - False - False - - - - - - True - False - 12 @@ -789,24 +901,43 @@ 0 - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + True - gl_object_editor_construct_color_combo - 1 - 0 - Sat, 15 Nov 2003 22:10:18 GMT + False + 12 + + + + True + gl_object_editor_construct_color_combo + 1 + 0 + Sat, 15 Nov 2003 22:10:18 GMT + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill @@ -850,10 +981,13 @@ 0 - + True + 1 + 2 False - 12 + 12 + 12 @@ -870,32 +1004,50 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - gl_object_editor_construct_color_combo - - 0 - 0 - Sat, 15 Nov 2003 20:47:48 GMT + False + 12 + + + + True + gl_object_editor_construct_color_combo + + 0 + 0 + Sat, 15 Nov 2003 20:47:48 GMT + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 0 + 1 + fill 0 - False - False + True + True @@ -1107,10 +1259,13 @@ 12 - + True + 2 + 2 False - 12 + 12 + 12 @@ -1124,43 +1279,14 @@ True - 0 - False - False - - - - - - True - True - True - True - 0 - - True - * - False - - - 0 - False - False + 0 + 1 + 0 + 1 + fill + - - - 0 - False - False - - - - - - True - False - 12 @@ -1172,26 +1298,25 @@ False False True - data_literal_radio - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + True - False - True - False - True - False + False + 12 - - + + True True True @@ -1202,26 +1327,79 @@ * False + + 0 + False + False + + + + 1 + 2 + 0 + 1 + fill + + - - + + + True + False + 12 + + + True - GTK_SELECTION_BROWSE + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + 0 + False + False + - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill 0 - False - False + True + True @@ -1258,10 +1436,13 @@ 12 - + True + 4 + 2 False - 12 + 12 + 12 @@ -1272,67 +1453,128 @@ GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - False - True - False - True - False + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + - - + + + True + False + 12 + + + True - True - True - True - 0 - - True - * - False + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + 0 + True + True + + + + 1 + 2 + 0 + 1 + fill + fill + + - - + + + True + False + 12 + + + True - GTK_SELECTION_BROWSE + gl_object_editor_construct_color_combo + 1 + 0 + Sun, 16 Nov 2003 07:00:32 GMT + + 0 + False + False + - 0 - True - True + 1 + 2 + 3 + 4 + fill + fill - - - 0 - False - False - - - - - - True - False - 12 @@ -1346,24 +1588,14 @@ True - 0 - False - False + 0 + 2 + 1 + 2 + fill + - - - 0 - False - False - - - - - - True - False - 12 @@ -1377,73 +1609,27 @@ True - 0 - False - False + 0 + 2 + 2 + 3 + fill + 0 - False - False + True + True - - - - True - False - 12 - - - - True - Color: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - gl_object_editor_construct_color_combo - 1 - 0 - Sun, 16 Nov 2003 07:00:32 GMT - - - 0 - False - False - - - - - 0 - False - False - - - - - True - True - - + + + True + True + + @@ -1472,10 +1658,13 @@ 12 - + True + 4 + 2 False - 12 + 12 + 12 @@ -1492,65 +1681,15 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - - - True - True - 0.01 - 2 - True - GTK_UPDATE_ALWAYS - True - False - 1 0 100 0.01 10 10 - - - 0 - False - True - - - - - - True - inches - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - 0 - False - False - - - - - - True - False - 12 - True @@ -1566,64 +1705,125 @@ 0 - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + True - True - 0.01 - 2 - True - GTK_UPDATE_ALWAYS - True - False - 1 0 100 0.01 10 10 + False + 12 + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - 0 - False - True + 1 + 2 + 0 + 1 + fill - + True - inches - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + False + 12 + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill - - - 0 - False - False - - - - - - True - False - 12 @@ -1637,44 +1837,50 @@ True - 0 - False - False + 0 + 2 + 2 + 3 + fill + - - - 0 - False - False - - - - - - True - False - 12 - + True - True - Reset image size - True - GTK_RELIEF_NORMAL + False + 12 + + + + True + True + Reset image size + True + GTK_RELIEF_NORMAL + + + 0 + False + False + + - 0 - False - False + 0 + 2 + 3 + 4 + fill + 0 - False - False + True + True @@ -1711,10 +1917,13 @@ 12 - + True + 2 + 2 False - 12 + 12 + 12 @@ -1731,65 +1940,15 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - - - True - True - 0.01 - 2 - True - GTK_UPDATE_ALWAYS - True - False - 1 0 100 0.01 10 10 - - - 0 - False - True - - - - - - True - inches - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - 0 - False - False - - - - - - True - False - 12 - True @@ -1805,56 +1964,130 @@ 0 - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + True - True - 0.1 - 1 - True - GTK_UPDATE_ALWAYS - True - False - 0 -180 180 0.1 5 5 + False + 12 + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - 0 - False - True + 1 + 2 + 0 + 1 + fill - + True - degrees - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + False + 12 + + + + True + True + 0.01 + 1 + True + GTK_UPDATE_ALWAYS + True + False + 0 -180 180 0.1 5 5 + + + 0 + False + True + + + + + + True + degrees + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 1 + 2 + fill + fill 0 - False - False + True + True @@ -1891,13 +2124,17 @@ 12 - + True + 2 + 3 False - 12 + 12 + 12 + 50 True X: False @@ -1911,28 +2148,36 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - True - 0.01 - 2 - True - GTK_UPDATE_ALWAYS - True + Y: + False + False + GTK_JUSTIFY_LEFT False - 0 0 100 0.01 10 10 + False + 0 + 0.5 + 0 + 0 - 0 - False - True + 0 + 1 + 1 + 2 + fill + @@ -1945,35 +2190,25 @@ GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 - 0 - False - False + 2 + 3 + 0 + 1 + fill + - - - 0 - False - False - - - - - - True - False - 12 - + True - Y: + inches False False GTK_JUSTIFY_LEFT @@ -1985,14 +2220,17 @@ 0 - 0 - False - False + 2 + 3 + 1 + 2 + fill + - + True True 0.01 @@ -2004,37 +2242,41 @@ 0 0 100 0.01 10 10 - 0 - False - True + 1 + 2 + 0 + 1 + + - + True - inches - False - False - GTK_JUSTIFY_LEFT + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True False - False - 0.5 - 0.5 - 0 - 0 + 0 0 100 0.01 10 10 - 0 - False - False + 1 + 2 + 1 + 2 + + 0 - False - False + True + True diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h index d91c46c2..2e13c9fd 100644 --- a/glabels2/src/object-editor.h +++ b/glabels2/src/object-editor.h @@ -199,6 +199,11 @@ void gl_object_editor_set_text_alignment (glObjectEditor *editor, GtkJustification gl_object_editor_get_text_alignment (glObjectEditor *editor); +void gl_object_editor_set_text_line_spacing (glObjectEditor *editor, + gdouble text_line_spacing); + +gdouble gl_object_editor_get_text_line_spacing (glObjectEditor *editor); + void gl_object_editor_set_text_color (glObjectEditor *editor, guint text_color); diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index bff861b1..80324634 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -65,6 +65,7 @@ struct _glPrefsDialogPrivate GtkWidget *text_left_toggle; GtkWidget *text_center_toggle; GtkWidget *text_right_toggle; + GtkWidget *text_line_spacing_spin; /* Default line properties */ GtkWidget *line_width_spin; @@ -341,6 +342,8 @@ construct_object_page (glPrefsDialog *dlg) glade_xml_get_widget (dlg->priv->gui, "text_center_toggle"); dlg->priv->text_right_toggle = glade_xml_get_widget (dlg->priv->gui, "text_right_toggle"); + dlg->priv->text_line_spacing_spin = + glade_xml_get_widget (dlg->priv->gui, "text_line_spacing_spin"); dlg->priv->line_width_spin = glade_xml_get_widget (dlg->priv->gui, "line_width_spin"); @@ -391,6 +394,11 @@ construct_object_page (glPrefsDialog *dlg) G_CALLBACK(align_toggle_cb), G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_line_spacing_spin), + "changed", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->line_width_spin), "changed", G_CALLBACK(update_prefs_from_object_page), @@ -553,6 +561,9 @@ update_object_page_from_prefs (glPrefsDialog *dlg) g_signal_handlers_block_by_func ( G_OBJECT(dlg->priv->text_right_toggle), G_CALLBACK(align_toggle_cb), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_line_spacing_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( G_OBJECT(dlg->priv->line_width_spin), G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); @@ -601,6 +612,8 @@ update_object_page_from_prefs (glPrefsDialog *dlg) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_right_toggle), (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->text_line_spacing_spin), + gl_prefs->default_text_line_spacing); gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->line_width_spin), gl_prefs->default_line_width); @@ -639,6 +652,9 @@ update_object_page_from_prefs (glPrefsDialog *dlg) g_signal_handlers_unblock_by_func ( G_OBJECT(dlg->priv->text_right_toggle), G_CALLBACK(align_toggle_cb), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_line_spacing_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( G_OBJECT(dlg->priv->line_width_spin), G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); @@ -732,6 +748,9 @@ update_prefs_from_object_page (glPrefsDialog *dlg) } + gl_prefs->default_text_line_spacing = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(dlg->priv->text_line_spacing_spin)); + gl_prefs->default_line_width = gtk_spin_button_get_value (GTK_SPIN_BUTTON(dlg->priv->line_width_spin)); diff --git a/glabels2/src/prefs-dialog.glade b/glabels2/src/prefs-dialog.glade index e82ca02f..10d32ea7 100644 --- a/glabels2/src/prefs-dialog.glade +++ b/glabels2/src/prefs-dialog.glade @@ -415,11 +415,110 @@ - - 6 + True + 4 + 2 False - 12 + 12 + 12 + + + + True + Font: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Alignment: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + 90 + True + Line Spacing: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + @@ -427,28 +526,6 @@ False 12 - - - 64 - True - Font: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - True @@ -560,9 +637,11 @@ - 0 - True - True + 1 + 2 + 0 + 1 + fill @@ -572,28 +651,6 @@ False 12 - - - 64 - True - Color: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - True @@ -610,9 +667,12 @@ - 0 - True - True + 1 + 2 + 1 + 2 + fill + fill @@ -622,28 +682,6 @@ False 12 - - - 64 - True - Alignment: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - True @@ -726,9 +764,47 @@ - 0 - True - True + 1 + 2 + 2 + 3 + fill + fill + + + + + + True + False + 40 + + + + True + True + 0.01 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 5 0.01 0.1 0.1 + + + 0 + False + False + + + + + 1 + 2 + 3 + 4 + fill + fill @@ -802,11 +878,62 @@ - - 6 + True + 2 + 2 False - 12 + 12 + 12 + + + + 90 + True + Width: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + @@ -814,33 +941,11 @@ False 12 - - - 64 - True - Width: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - True True - 0.25 + 0.01 2 True GTK_UPDATE_ALWAYS @@ -877,9 +982,11 @@ - 0 - True - True + 1 + 2 + 0 + 1 + fill @@ -889,28 +996,6 @@ False 12 - - - 64 - True - Color: - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - - True @@ -927,9 +1012,12 @@ - 0 - True - True + 1 + 2 + 1 + 2 + fill + fill @@ -1010,14 +1098,17 @@ 12 - + True + 1 + 2 False - 12 + 0 + 0 - 64 + 90 True Color: False @@ -1031,24 +1122,42 @@ 0 - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - gl_object_editor_construct_color_combo - 0 - 0 - Sun, 23 Nov 2003 15:43:12 GMT + False + 12 + + + + True + gl_object_editor_construct_color_combo + 0 + 0 + Sun, 23 Nov 2003 15:43:12 GMT + + + 0 + False + False + + - 0 - False - False + 1 + 2 + 0 + 1 + fill diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index ab285780..0ec867ae 100644 --- a/glabels2/src/prefs-model.c +++ b/glabels2/src/prefs-model.c @@ -46,6 +46,7 @@ #define PREF_DEFAULT_FONT_ITALIC_FLAG "/default-font-italic-flag" #define PREF_DEFAULT_TEXT_COLOR "/default-text-color" #define PREF_DEFAULT_TEXT_ALIGNMENT "/default-text-alignment" +#define PREF_DEFAULT_TEXT_LINE_SPACING "/default-text-line-spacing" #define PREF_DEFAULT_LINE_WIDTH "/default-line-width" #define PREF_DEFAULT_LINE_COLOR "/default-line-color" @@ -78,6 +79,7 @@ #define DEFAULT_FONT_ITALIC_FLAG FALSE #define DEFAULT_TEXT_JUST_STRING gl_util_just_to_string (GTK_JUSTIFY_LEFT) #define DEFAULT_TEXT_COLOR GNOME_CANVAS_COLOR (0,0,0) +#define DEFAULT_TEXT_LINE_SPACING 1.0 #define DEFAULT_LINE_WIDTH 1.0 #define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255) @@ -300,6 +302,10 @@ gl_prefs_model_save_settings (glPrefsModel *prefs_model) gl_util_just_to_string(prefs_model->default_text_alignment), NULL); + gconf_client_set_float (prefs_model->gconf_client, + BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING, + prefs_model->default_text_line_spacing, + NULL); /* Line properties */ gconf_client_set_float (prefs_model->gconf_client, @@ -445,6 +451,12 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) prefs_model->default_text_alignment = gl_util_string_to_just( string ); g_free( string ); + prefs_model->default_text_line_spacing = + get_float (prefs_model->gconf_client, + BASE_KEY PREF_DEFAULT_TEXT_LINE_SPACING, + DEFAULT_TEXT_LINE_SPACING); + + gl_debug (DEBUG_PREFS, "text_line_spacing = %f", prefs_model->default_text_line_spacing); /* Line properties */ prefs_model->default_line_width = @@ -661,7 +673,6 @@ get_float (GConfClient *client, return retval; } else { - return def; } diff --git a/glabels2/src/prefs-model.h b/glabels2/src/prefs-model.h index 8d94ba79..f73ad7e4 100644 --- a/glabels2/src/prefs-model.h +++ b/glabels2/src/prefs-model.h @@ -73,6 +73,7 @@ struct _glPrefsModel { gboolean default_font_italic_flag; guint default_text_color; GtkJustification default_text_alignment; + gdouble default_text_line_spacing; /* Line properties */ gdouble default_line_width; diff --git a/glabels2/src/print.c b/glabels2/src/print.c index ea11e0d4..6a4a73b6 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -726,6 +726,7 @@ draw_text_object (PrintInfo *pi, GnomeGlyphList *glyphlist; ArtDRect bbox; gdouble affine[6]; + gdouble text_line_spacing; gl_debug (DEBUG_PRINT, "START"); @@ -738,6 +739,7 @@ draw_text_object (PrintInfo *pi, font_italic_flag = gl_label_object_get_font_italic_flag (GL_LABEL_OBJECT(object)); color = gl_label_object_get_text_color (GL_LABEL_OBJECT(object)); just = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object)); + text_line_spacing = gl_label_object_get_text_line_spacing (GL_LABEL_OBJECT(object)); font = gnome_font_find_closest_from_weight_slant ( font_family, @@ -782,8 +784,14 @@ draw_text_object (PrintInfo *pi, break; /* shouldn't happen */ } - y_offset = GL_LABEL_TEXT_MARGIN + (i + 1) * font_size - + gnome_font_get_descender (font); + /* Work out the y position to the BOTTOM of the first line */ + y_offset = GL_LABEL_TEXT_MARGIN + + + gnome_font_get_descender (font) + + (i + 1) * font_size * text_line_spacing; + + /* Remove any text line spacing from the first row. */ + y_offset -= font_size * (text_line_spacing - 1); + gnome_print_moveto (pi->pc, x_offset, y_offset); diff --git a/glabels2/src/ui-sidebar.c b/glabels2/src/ui-sidebar.c index 0b237036..6f9ca793 100644 --- a/glabels2/src/ui-sidebar.c +++ b/glabels2/src/ui-sidebar.c @@ -35,7 +35,7 @@ /* Private macros and constants. */ /*============================================================================*/ -#define DEFAULT_SIDEBAR_WIDTH 300 +#define DEFAULT_SIDEBAR_WIDTH 320 /*============================================================================*/ /* Private globals */ diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 01f268ec..0727399b 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -305,6 +305,7 @@ update_object_from_editor_cb (glObjectEditor *editor, gboolean font_italic_flag; guint color; GtkJustification just; + gdouble text_line_spacing; gl_debug (DEBUG_VIEW, "START"); @@ -315,7 +316,6 @@ update_object_from_editor_cb (glObjectEditor *editor, update_editor_from_move_cb, editor); - gl_object_editor_get_position (editor, &x, &y); gl_object_editor_get_size (editor, &w, &h); font_family = gl_object_editor_get_font_family (editor); @@ -324,6 +324,7 @@ update_object_from_editor_cb (glObjectEditor *editor, font_italic_flag = gl_object_editor_get_font_italic_flag (editor); color = gl_object_editor_get_text_color (editor); just = gl_object_editor_get_text_alignment (editor); + text_line_spacing = (gdouble) gl_object_editor_get_text_line_spacing (editor); gl_label_object_set_position (object, x, y); gl_label_object_set_size (object, w, h); @@ -333,6 +334,7 @@ update_object_from_editor_cb (glObjectEditor *editor, gl_label_object_set_font_italic_flag (object, font_italic_flag); gl_label_object_set_text_color (object, color); gl_label_object_set_text_alignment (object, just); + gl_label_object_set_text_line_spacing (object, text_line_spacing); g_free (font_family); @@ -360,6 +362,7 @@ update_editor_from_object_cb (glLabelObject *object, gboolean font_italic_flag; guint color; GtkJustification just; + gdouble text_line_spacing; gl_debug (DEBUG_VIEW, "START"); @@ -372,6 +375,7 @@ update_editor_from_object_cb (glLabelObject *object, font_italic_flag = gl_label_object_get_font_italic_flag (object); color = gl_label_object_get_text_color (object); just = gl_label_object_get_text_alignment (object); + text_line_spacing = gl_label_object_get_text_line_spacing (object); gl_object_editor_set_font_family (editor, font_family); gl_object_editor_set_font_size (editor, font_size); @@ -379,6 +383,7 @@ update_editor_from_object_cb (glLabelObject *object, gl_object_editor_set_font_italic_flag (editor, font_italic_flag); gl_object_editor_set_text_color (editor, color); gl_object_editor_set_text_alignment (editor, just); + gl_object_editor_set_text_line_spacing (editor, text_line_spacing); g_free (font_family); @@ -509,6 +514,8 @@ gl_view_text_create_event_handler (GnomeCanvas *canvas, gl_color_set_opacity (gl_view_get_default_text_color (view), 0.5)); gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), gl_view_get_default_text_alignment (view)); + gl_label_object_set_text_line_spacing (GL_LABEL_OBJECT(object), gl_view_get_default_text_line_spacing (view)); + g_free (family); lines = gl_text_node_lines_new_from_text (_("Text")); gl_label_text_set_lines (GL_LABEL_TEXT(object), lines); @@ -545,6 +552,8 @@ gl_view_text_create_event_handler (GnomeCanvas *canvas, gl_view_get_default_text_color (view)); gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), gl_view_get_default_text_alignment (view)); + gl_label_object_set_text_line_spacing (GL_LABEL_OBJECT(object), gl_view_get_default_text_line_spacing (view)); + g_free (family); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_text)); @@ -589,6 +598,7 @@ draw_hacktext (glViewText *view_text) GnomeFontWeight font_weight; gboolean font_italic_flag; gdouble font_size; + gdouble text_line_spacing; guint color; GtkJustification just; GnomeFont *font; @@ -607,6 +617,7 @@ draw_hacktext (glViewText *view_text) gl_label_object_get_size (object, &object_w, &object_h); font_family = gl_label_object_get_font_family (object); font_size = gl_label_object_get_font_size (object); + text_line_spacing = gl_label_object_get_text_line_spacing (object); font_weight = gl_label_object_get_font_weight (object); font_italic_flag = gl_label_object_get_font_italic_flag (object); color = gl_label_object_get_text_color (object); @@ -658,8 +669,13 @@ draw_hacktext (glViewText *view_text) break; /* shouldn't happen */ } + /* Work out the y position to the BOTTOM of the first line */ y_offset = GL_LABEL_TEXT_MARGIN + - (i + 1) * font_size + gnome_font_get_descender (font); + + gnome_font_get_descender (font) + + (i + 1) * font_size * text_line_spacing; + + /* Remove any text line spacing from the first row. */ + y_offset -= font_size * (text_line_spacing - 1); item = gl_view_object_item_new (GL_VIEW_OBJECT(view_text), gl_canvas_hacktext_get_type (), diff --git a/glabels2/src/view.c b/glabels2/src/view.c index c703a648..5fd87105 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -394,6 +394,7 @@ gl_view_construct (glView *view) gl_view_set_default_font_italic_flag (view, gl_prefs->default_font_italic_flag); gl_view_set_default_text_color (view, gl_prefs->default_text_color); gl_view_set_default_text_alignment (view, gl_prefs->default_text_alignment); + gl_view_set_default_text_line_spacing (view, gl_prefs->default_text_line_spacing); gl_view_set_default_line_width (view, gl_prefs->default_line_width); gl_view_set_default_line_color (view, gl_prefs->default_line_color); gl_view_set_default_fill_color (view, gl_prefs->default_fill_color); @@ -2747,6 +2748,29 @@ gl_view_set_selection_text_alignment (glView *view, gl_debug (DEBUG_VIEW, "END"); } +/*****************************************************************************/ +/* Set text line spacing for all text contained in selected objects. */ +/*****************************************************************************/ +void +gl_view_set_selection_text_line_spacing (glView *view, + gdouble text_line_spacing) +{ + GList *p; + glLabelObject *object; + + gl_debug (DEBUG_VIEW, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + + for (p = view->selected_object_list; p != NULL; p = p->next) { + + object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data)); + gl_label_object_set_text_line_spacing (object, text_line_spacing); + + } + + gl_debug (DEBUG_VIEW, "END"); +} /*****************************************************************************/ /* Set text color for all text contained in selected objects. */ /*****************************************************************************/ @@ -3986,6 +4010,22 @@ gl_view_set_default_text_alignment (glView *view, gl_debug (DEBUG_VIEW, "END"); } +/****************************************************************************/ +/* Set default text line spacing. */ +/****************************************************************************/ +void +gl_view_set_default_text_line_spacing (glView *view, + gdouble text_line_spacing) +{ + gl_debug (DEBUG_VIEW, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + + view->default_text_line_spacing = text_line_spacing; + + gl_debug (DEBUG_VIEW, "END"); +} + /****************************************************************************/ /* Set default line width. */ @@ -4134,6 +4174,22 @@ gl_view_get_default_text_alignment (glView *view) return view->default_text_alignment; } +/****************************************************************************/ +/* Get default text line spacing. */ +/****************************************************************************/ +gdouble +gl_view_get_default_text_line_spacing (glView *view) +{ + gl_debug (DEBUG_VIEW, "START"); + + g_return_val_if_fail (view && GL_IS_VIEW (view), 1.0); + + gl_debug (DEBUG_VIEW, "END"); + + return view->default_text_line_spacing; +} + + /****************************************************************************/ /* Get default line width. */ diff --git a/glabels2/src/view.h b/glabels2/src/view.h index 338cf93f..f086bc24 100644 --- a/glabels2/src/view.h +++ b/glabels2/src/view.h @@ -94,6 +94,7 @@ struct _glView { gboolean default_font_italic_flag; guint default_text_color; GtkJustification default_text_alignment; + gdouble default_text_line_spacing; /* Default object line properties */ gdouble default_line_width; @@ -221,6 +222,9 @@ void gl_view_set_selection_font_size (glView *view, void gl_view_set_selection_font_weight (glView *view, GnomeFontWeight font_weight); +void gl_view_set_selection_text_line_spacing (glView *view, + gdouble text_line_spacing); + void gl_view_set_selection_font_italic_flag (glView *view, gboolean font_italic_flag); @@ -301,6 +305,9 @@ void gl_view_set_default_line_color (glView *view, void gl_view_set_default_fill_color (glView *view, guint fill_color); +void gl_view_set_default_text_line_spacing (glView *view, + gdouble text_line_spacing); + gchar *gl_view_get_default_font_family (glView *view); @@ -315,6 +322,8 @@ guint gl_view_get_default_text_color (glView *view); GtkJustification gl_view_get_default_text_alignment (glView *view); +gdouble gl_view_get_default_text_line_spacing (glView *view); + gdouble gl_view_get_default_line_width (glView *view); guint gl_view_get_default_line_color (glView *view); diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index f2282760..8a97ca68 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -845,6 +845,7 @@ xml_parse_toplevel_span (xmlNodePtr node, GnomeFontWeight font_weight; gboolean font_italic_flag; guint color; + gdouble text_line_spacing; gchar *string; GList *lines, *text_nodes; xmlNodePtr child; @@ -875,6 +876,10 @@ xml_parse_toplevel_span (xmlNodePtr node, color = gl_xml_get_prop_uint (node, "color", 0); gl_label_object_set_text_color (object, color); + /* Text line spacing attr */ + text_line_spacing = gl_xml_get_prop_double (node, "line_spacing", 1.0); + gl_label_object_set_text_line_spacing (object, text_line_spacing); + /* Now descend children, and build lines of text nodes */ lines = NULL; text_nodes = NULL; @@ -1508,6 +1513,7 @@ xml_create_toplevel_span (xmlNodePtr root, gboolean font_italic_flag; guint color; GtkJustification just; + gdouble text_line_spacing; GList *lines, *p_line, *p_node; glTextNode *text_node; xmlNodePtr child; @@ -1517,6 +1523,7 @@ xml_create_toplevel_span (xmlNodePtr root, /* All span attrs at top level. */ font_family = gl_label_object_get_font_family (GL_LABEL_OBJECT(object_text)); font_size = gl_label_object_get_font_size (GL_LABEL_OBJECT(object_text)); + text_line_spacing = gl_label_object_get_text_line_spacing (GL_LABEL_OBJECT(object_text)); font_weight = gl_label_object_get_font_weight (GL_LABEL_OBJECT(object_text)); font_italic_flag = gl_label_object_get_font_italic_flag (GL_LABEL_OBJECT(object_text)); color = gl_label_object_get_text_color (GL_LABEL_OBJECT(object_text)); @@ -1526,6 +1533,7 @@ xml_create_toplevel_span (xmlNodePtr root, xmlSetProp (node, "font_weight", gl_util_weight_to_string (font_weight)); gl_xml_set_prop_boolean (node, "font_italic", font_italic_flag); gl_xml_set_prop_uint_hex (node, "color", color); + gl_xml_set_prop_double (node, "line_spacing", text_line_spacing); /* Build children. */ lines = gl_label_text_get_lines (GL_LABEL_TEXT(object_text));