diff options
author | Mike Kestner <mkestner@ximian.com> | 2003-04-19 03:51:01 +0800 |
---|---|---|
committer | Mike Kestner <mkestner@src.gnome.org> | 2003-04-19 03:51:01 +0800 |
commit | 474763899f9fa6226f793c20ad1a11f55a1681ee (patch) | |
tree | 0904b83918cc123036ecc81eb79afc550d06cd01 /widgets | |
parent | 0407034071219444fc151d6d6d52fbc71b98f1b3 (diff) | |
download | gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar.gz gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar.bz2 gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar.lz gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar.xz gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.tar.zst gsoc2013-evolution-474763899f9fa6226f793c20ad1a11f55a1681ee.zip |
if the layout splits into more than one line, shorten it to a single line
2003-04-18 Mike Kestner <mkestner@ximian.com>
* e-cell-text.c (build_layout): if the layout splits into more
than one line, shorten it to a single line with elipses.
(generate_layout): don't ref NULL layouts
(ect_enter_edit): use g_new0 for the CellEdit
(get_position_from_xy): use generate_layout since edit->layout
isn't necessarily set here.
svn path=/trunk/; revision=20892
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-cell-text.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 5bff9c82a0..4295862c32 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -484,6 +484,21 @@ build_layout (ECellTextView *text_view, int row, const char *text, gint width) if (width > 0) pango_layout_set_width (layout, width * PANGO_SCALE); + pango_layout_set_wrap (layout, PANGO_WRAP_CHAR); + + while (pango_layout_get_line_count (layout) > 1) { + PangoLayoutLine *line = pango_layout_get_line (layout, 0); + gchar *line_text = g_strdup (pango_layout_get_text (layout)); + gchar *last_char = g_utf8_prev_char (line_text + line->length - 1); + gchar *new_text; + while (*last_char == '.') + last_char = g_utf8_prev_char (last_char); + *last_char = '\0'; + new_text = g_strconcat (line_text, " ...", NULL); + pango_layout_set_text (layout, new_text, g_utf8_strlen (new_text, -1)); + g_free (line_text); + g_free (new_text); + } switch (ect->justify) { case GTK_JUSTIFY_RIGHT: @@ -508,7 +523,7 @@ generate_layout (ECellTextView *text_view, int model_col, int view_col, int row, PangoLayout *layout; CellEdit *edit = text_view->edit; - if (edit && edit->model_col == model_col && edit->row == row) { + if (edit && edit->layout && edit->model_col == model_col && edit->row == row) { g_object_ref (edit->layout); if (width > 0) pango_layout_set_width (edit->layout, width * PANGO_SCALE); @@ -974,7 +989,7 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row) ECellText *ect = E_CELL_TEXT(ecell_view->ecell); char *temp; - edit = g_new (CellEdit, 1); + edit = g_new0 (CellEdit, 1); text_view->edit = edit; edit->view_col = -1; @@ -1614,7 +1629,7 @@ get_position_from_xy (CellEdit *edit, gint x, gint y) int index; int trailing; const char *text; - PangoLayout *layout = edit->layout; + PangoLayout *layout = generate_layout (edit->text_view, edit->model_col, edit->view_col, edit->row, edit->cell_width); ECellTextView *text_view = edit->text_view; ECellText *ect = (ECellText *) ((ECellView *)text_view)->ecell; |