diff options
author | Chris Toshok <toshok@ximian.com> | 2002-12-09 09:01:38 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2002-12-09 09:01:38 +0800 |
commit | cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9 (patch) | |
tree | d393785c5a3de0898395b67ebe56969d7a29ab3f /addressbook/gui | |
parent | 24b06cb2a4030282763c8f60ba3b0b8b806d15d3 (diff) | |
download | gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar.gz gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar.bz2 gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar.lz gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar.xz gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.tar.zst gsoc2013-evolution-cca7f7dd64b65a4a17f2cee9f9ec426934bf65c9.zip |
this uses pango now. (addressbook_height): same.
2002-12-08 Chris Toshok <toshok@ximian.com>
* gui/widgets/e-addressbook-reflow-adapter.c (text_height): this
uses pango now.
(addressbook_height): same.
svn path=/trunk/; revision=19058
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-reflow-adapter.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c index 3c2bb20386..8b70de2734 100644 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c @@ -11,8 +11,6 @@ #include "e-addressbook-util.h" #include "e-minicard.h" -#include <gal/widgets/e-unicode.h> -#include <gal/widgets/e-font.h> #include <gal/widgets/e-popup-menu.h> #include <gal/widgets/e-gui-utils.h> #include "e-contact-save-as.h" @@ -78,27 +76,14 @@ unlink_model(EAddressbookReflowAdapter *adapter) static int -count_lines (const gchar *text) +text_height (PangoLayout *layout, const gchar *text) { - int num_lines = 1; - gunichar unival; - - for (text = e_unicode_get_utf8 (text, &unival); (unival && text); text = e_unicode_get_utf8 (text, &unival)) { - if (unival == '\n') { - num_lines ++; - } - } + int height; - return num_lines; -} + pango_layout_set_text (layout, text, -1); -static int -text_height (GnomeCanvas *canvas, const gchar *text) -{ - EFont *font = e_font_from_gdk_font (gtk_style_get_font (gtk_widget_get_style (GTK_WIDGET (canvas)))); - gint height = e_font_height (font) * count_lines (text) / canvas->pixels_per_unit; + pango_layout_get_pixel_size (layout, NULL, &height); - e_font_unref (font); return height; } @@ -125,10 +110,12 @@ addressbook_count (EReflowModel *erm) return e_addressbook_model_card_count (priv->model); } -/* This function returns the number of items in our EReflowModel. */ +/* This function returns the height of the minicard in question */ static int addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) { + /* XXX ugh, an extra pango layout step for every minicard + whether it's displayed or not? */ EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); EAddressbookReflowAdapterPrivate *priv = adapter->priv; /* FIXME */ @@ -137,9 +124,10 @@ addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) int height; char *string; ECardSimple *simple = e_card_simple_new (e_addressbook_model_card_at (priv->model, i)); + PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (parent)->canvas), ""); string = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS); - height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, string ? string : "") + 10.0; + height = text_height (layout, string ? string : "") + 10.0; g_free(string); for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING && count < 5; field++) { @@ -152,9 +140,9 @@ addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) int this_height; int field_text_height; - this_height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, e_card_simple_get_name(simple, field)); + this_height = text_height (layout, e_card_simple_get_name(simple, field)); - field_text_height = text_height (GNOME_CANVAS_ITEM (parent)->canvas, string); + field_text_height = text_height (layout, string); if (this_height < field_text_height) this_height = field_text_height; @@ -168,6 +156,7 @@ addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) height += 2; g_object_unref (simple); + g_object_unref (layout); return height; } |