[cairo-commit] goocanvas/src goocanvastext.c, 1.18, 1.19 goocanvastext.h, 1.7, 1.8

Damon Chaplin commit at pdx.freedesktop.org
Thu Mar 8 04:32:06 PST 2007


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv27470/src

Modified Files:
	goocanvastext.c goocanvastext.h 
Log Message:
2007-03-08  Damon Chaplin  <damon at gnome.org>

	* src/goocanvastext.[hc]: added ellipsize property, and used bit flags
	to cut down on memory use a bit.

	* demo/demo.c (setup_texts): added test for ellipsized text.

	* demo/mv-demo.c: 
	* demo/mv-demo-table.c: 
	* demo/mv-demo-clipping.c: updated model-view demos, adding new stuff
	from simple demo.



Index: goocanvastext.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastext.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- goocanvastext.c	6 Mar 2007 13:21:26 -0000	1.18
+++ goocanvastext.c	8 Mar 2007 12:31:59 -0000	1.19
@@ -40,7 +40,8 @@
   PROP_TEXT,
   PROP_USE_MARKUP,
   PROP_ANCHOR,
-  PROP_ALIGN
+  PROP_ALIGN,
+  PROP_ELLIPSIZE
 };
 
 static void goo_canvas_text_finalize     (GObject            *object);
@@ -78,6 +79,14 @@
 							 FALSE,
 							 G_PARAM_READWRITE));
 
+  g_object_class_install_property (gobject_class, PROP_ELLIPSIZE,
+                                   g_param_spec_enum ("ellipsize",
+                                                      _("Ellipsize"),
+                                                      _("The preferred place to ellipsize the string, if the label does not have enough room to display the entire string"),
+						      PANGO_TYPE_ELLIPSIZE_MODE,
+						      PANGO_ELLIPSIZE_NONE,
+                                                      G_PARAM_READWRITE));
+
   /* Position */
   g_object_class_install_property (gobject_class, PROP_X,
 				   g_param_spec_double ("x",
@@ -127,6 +136,7 @@
   text->text_data = g_slice_new0 (GooCanvasTextData);
   text->text_data->width = -1.0;
   text->text_data->anchor = GTK_ANCHOR_NW;
+  text->text_data->ellipsize = PANGO_ELLIPSIZE_NONE;
 
   text->layout_width = -1.0;
 }
@@ -247,6 +257,9 @@
     case PROP_USE_MARKUP:
       g_value_set_boolean (value, text_data->use_markup);
       break;
+    case PROP_ELLIPSIZE:
+      g_value_set_enum (value, text_data->ellipsize);
+      break;
     case PROP_ANCHOR:
       g_value_set_enum (value, text_data->anchor);
       break;
@@ -298,6 +311,9 @@
     case PROP_USE_MARKUP:
       text_data->use_markup = g_value_get_boolean (value);
       break;
+    case PROP_ELLIPSIZE:
+      text_data->ellipsize = g_value_get_enum (value);
+      break;
     case PROP_ANCHOR:
       text_data->anchor = g_value_get_enum (value);
       break;
@@ -385,6 +401,8 @@
   if (text_data->alignment != PANGO_ALIGN_LEFT)
     pango_layout_set_alignment (layout, text_data->alignment);
 
+  pango_layout_set_ellipsize (layout, text_data->ellipsize);
+
   if (bounds)
     {
       /* Get size of the text, so we can position it according to anchor. */
@@ -781,7 +799,9 @@
 static void
 goo_canvas_text_model_init (GooCanvasTextModel *tmodel)
 {
-
+  tmodel->text_data.width = -1.0;
+  tmodel->text_data.anchor = GTK_ANCHOR_NW;
+  tmodel->text_data.ellipsize = PANGO_ELLIPSIZE_NONE;
 }
 
 

Index: goocanvastext.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastext.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- goocanvastext.h	6 Mar 2007 12:08:15 -0000	1.7
+++ goocanvastext.h	8 Mar 2007 12:31:59 -0000	1.8
@@ -18,11 +18,11 @@
 struct _GooCanvasTextData
 {
   gchar *text;
-  gboolean use_markup;
-
   gdouble x, y, width;
-  GtkAnchorType anchor;
-  PangoAlignment alignment;
+  guint use_markup		: 1;
+  guint anchor			: 5;	/* GtkAnchorType */
+  guint alignment		: 3;	/* PangoAlignment */
+  guint ellipsize		: 3;	/* PangoEllipsizeMode */
 };
 
 



More information about the cairo-commit mailing list