summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-07-14 22:17:36 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-07-14 22:17:36 +0000
commite8451d0463303bbaa3ba3d840d7985f9120ba58a (patch)
tree9ce3e64b7191ea3dc352e101ccd552231e9bbc59 /examples
parent731bd56653de86e2298cd8b04c320fca82bb2f9f (diff)
downloadpango-e8451d0463303bbaa3ba3d840d7985f9120ba58a.tar.gz
Add PangoEllipsizeMode, pango_layout_set_ellipsize(), implement. (#59071)
Wed Jul 14 17:47:38 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-layout.[ch] pango/ellipsize.c pango/Makefile.am: Add PangoEllipsizeMode, pango_layout_set_ellipsize(), implement. (#59071) * pango/pango-layout-private.h pango/pango-layout.c: Move PangoLayout structure into a separate header file. * pango/pango-glyph-item.[ch]: Add pango_glyph_item_free(). * pango/pango-glyph-item-private.h pango/pango-glyph-item.c: Internally export the PangoGlyphItemIter functionality. * examples/renderdemo.[ch]: Add --ellipsize option.
Diffstat (limited to 'examples')
-rw-r--r--examples/renderdemo.c24
-rw-r--r--examples/renderdemo.h1
2 files changed, 24 insertions, 1 deletions
diff --git a/examples/renderdemo.c b/examples/renderdemo.c
index cc18b725..78aa4037 100644
--- a/examples/renderdemo.c
+++ b/examples/renderdemo.c
@@ -54,6 +54,7 @@ char *opt_text = NULL;
gboolean opt_waterfall = FALSE;
int opt_width = -1;
int opt_indent = 0;
+PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE;
/* Text (or markup) to render */
char *text;
@@ -101,7 +102,8 @@ make_layout(PangoContext *context,
pango_layout_set_text (layout, text, -1);
pango_layout_set_auto_dir (layout, opt_auto_dir);
-
+ pango_layout_set_ellipsize (layout, opt_ellipsize);
+
font_description = get_font_description ();
if (size > 0)
pango_font_description_set_size (font_description, size * PANGO_SCALE);
@@ -298,6 +300,24 @@ show_help (ArgContext *context,
}
void
+parse_ellipsis (ArgContext *arg_context,
+ const char *name,
+ const char *arg,
+ gpointer data)
+{
+ static GEnumClass *class = NULL;
+
+ if (!class)
+ class = g_type_class_ref (PANGO_TYPE_ELLIPSIZE_MODE);
+
+ GEnumValue *value = g_enum_get_value_by_nick (class, arg);
+ if (!value)
+ fail ("--ellipsize option must be one of none/start/middle/end");
+
+ opt_ellipsize = value->value;
+}
+
+void
parse_options (int argc, char *argv[])
{
static const ArgDesc args[] = {
@@ -307,6 +327,8 @@ parse_options (int argc, char *argv[])
ARG_BOOL, &opt_display },
{ "dpi", "Set the dpi'",
ARG_INT, &opt_dpi },
+ { "ellipsize", "Ellipsization mode [=none/start/middle/end]",
+ ARG_CALLBACK, NULL, parse_ellipsis },
{ "font", "Set the font name",
ARG_STRING, &opt_font },
{ "header", "Display the options in the output",
diff --git a/examples/renderdemo.h b/examples/renderdemo.h
index 191efe2c..94a27f49 100644
--- a/examples/renderdemo.h
+++ b/examples/renderdemo.h
@@ -53,3 +53,4 @@ extern char *opt_text;
extern gboolean opt_waterfall;
extern int opt_width;
extern int opt_indent;
+extern PangoEllipsizeMode opt_ellipsize;