[gnumeric] Remove distinction between label and filled rectangle



commit 792f40cd4e13b7888bc35db06b9c4d3839fa7329
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu May 28 22:08:26 2009 -0600

    Remove distinction between label and filled rectangle
    
        2009-05-28  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        	* src/gnm-so-filled.c (so_filled_view_set_bounds): don't check for
        	  text to be non-null and is_oval to be false
        	(gnm_so_filled_user_config): ditto
        	(cb_gnm_so_filled_style_changed): ditto
        	(gnm_so_filled_draw_cairo): ditto
        	(gnm_so_filled_write_xml_sax): ditto
        	(gnm_so_filled_init): Iniitalize with the empty string rather than NULL
        	  since something in FOOCANVAS doesn't update when we change from NULL to
        	  text.
    
        2009-05-28  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        	* dialog-so-styled.c (dialog_so_styled_text_widget): make sure
        	  the existing text is not NULL.
---
 ChangeLog                      |   12 ++++++++++++
 NEWS                           |    1 +
 src/dialogs/ChangeLog          |    5 +++++
 src/dialogs/dialog-so-styled.c |    2 +-
 src/gnm-so-filled.c            |   39 +++++++++++++++++----------------------
 5 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 67685ea..3578bdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,18 @@
 
 2009-05-28  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/gnm-so-filled.c (so_filled_view_set_bounds): don't check for
+	  text to be non-null and is_oval to be false
+	(gnm_so_filled_user_config): ditto
+	(cb_gnm_so_filled_style_changed): ditto
+	(gnm_so_filled_draw_cairo): ditto
+	(gnm_so_filled_write_xml_sax): ditto
+	(gnm_so_filled_init): Iniitalize with the empty string rather than NULL
+	  since something in FOOCANVAS doesn't update when we change from NULL to 
+	  text.
+
+2009-05-28  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/sheet-object-cell-comment.c (cell_comment_prep_sax_parser):
 	  make sure we are having markup before retrieving it
 
diff --git a/NEWS b/NEWS
index db2a5de..560ec99 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.9.9
 Andreas:
 	* Export some data formats to ODF
 	* Fix comment export to ODF
+	* Remove distinction between label and filled rectangle
 
 Morten:
 	* Add search-for-number.
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index d042ea9..7e7c1ff 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-28  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-so-styled.c (dialog_so_styled_text_widget): make sure 
+	  the existing text is not NULL. 
+
 2009-05-25  Morten Welinder  <terra gnome org>
 
 	* dialog-search.c (search_clicked): Handle number search.
diff --git a/src/dialogs/dialog-so-styled.c b/src/dialogs/dialog-so-styled.c
index 71e3198..3825b7b 100644
--- a/src/dialogs/dialog-so-styled.c
+++ b/src/dialogs/dialog-so-styled.c
@@ -109,7 +109,7 @@ dialog_so_styled_text_widget (DialogSOStyled *state)
 	PangoAttrList  *markup;
 
 	g_object_get (state->so, "text", &strval, NULL);
-	g_object_set (gtv, "text", strval, NULL);
+	g_object_set (gtv, "text", (strval == NULL) ? "" : strval, NULL);
 	state->orig_text = strval;
 
 	g_object_get (state->so, "markup", &markup, NULL);
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index e2f9880..386a871 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -53,9 +53,7 @@ typedef struct {
 	GOStyle  *style;
 	gboolean   is_oval;
 
-	/* Only valid if !is_oval */
 	char *text;
-	/* Only valid if text != NULL && !is_oval */
 	PangoAttrList  *markup;
 	struct {
 		float top, bottom, left, right;
@@ -91,7 +89,7 @@ so_filled_view_set_bounds (SheetObjectView *sov, double const *coords, gboolean
 			"x2", w, "y2", h,
 			NULL);
 
-		if (sof->text != NULL && group->item_list->next) {
+		if (group->item_list->next) {
 			view = FOO_CANVAS_ITEM (group->item_list->next->data);
 			w -= (sof->margin_pts.left + sof->margin_pts.right)
 				* view->canvas->pixels_per_unit;
@@ -168,12 +166,10 @@ static void
 gnm_so_filled_user_config (SheetObject *so, SheetControl *sc)
 {
 	GnmSOFilled *sof = GNM_SO_FILLED (so);
-	gboolean text = (sof->text != NULL);
 	dialog_so_styled (scg_wbcg (SHEET_CONTROL_GUI (sc)), G_OBJECT (so),
 			  sof->style, sof_default_style (),
-			  text ? _("Label Properties") :
 			  _("Filled Object Properties"),
-			  text ? SO_STYLED_TEXT : SO_STYLED_STYLE_ONLY);
+			  SO_STYLED_TEXT);
 }
 
 static void
@@ -212,21 +208,19 @@ cb_gnm_so_filled_changed (GnmSOFilled const *sof,
 {
 	cb_gnm_so_filled_style_changed (group->item_list->data, sof);
 
-	if (!sof->is_oval && sof->text != NULL) {
-		if (group->item_list->next == NULL)
-			foo_canvas_item_new (group, FOO_TYPE_CANVAS_TEXT,
-				"anchor",	GTK_ANCHOR_NW,
-				"clip",		TRUE,
-				"x",		sof->margin_pts.left,
-				"y",		sof->margin_pts.top,
-				"attributes",	sof->markup,
-				NULL);
-		foo_canvas_item_set (FOO_CANVAS_ITEM (group->item_list->next->data),
-				     "text", sof->text,
+	if (group->item_list->next == NULL)
+		foo_canvas_item_new (group, FOO_TYPE_CANVAS_TEXT,
+				     "anchor",	GTK_ANCHOR_NW,
+				     "clip",		TRUE,
+				     "x",		sof->margin_pts.left,
+				     "y",		sof->margin_pts.top,
 				     "attributes",	sof->markup,
+				     "text", sof->text,
 				     NULL);
-	} else if (group->item_list->next != NULL)
-		g_object_unref (group->item_list->next->data);
+	foo_canvas_item_set (FOO_CANVAS_ITEM (group->item_list->next->data),
+			     "text", sof->text,
+			     "attributes",	sof->markup,
+			     NULL);
 }
 
 static SheetObjectView *
@@ -289,7 +283,7 @@ gnm_so_filled_draw_cairo (SheetObject const *so, cairo_t *cr,
 		UINT_RGBA_A(style->outline.color));
 	cairo_stroke (cr);
 	/* Draw the text. */
-	if (sof->text != NULL && !sof->is_oval) {
+	if (*(sof->text) != '\0') {
 		PangoLayout *pl = pango_cairo_create_layout (cr);
 		double pl_height = (height - sof->margin_pts.top
 				    - sof->margin_pts.bottom) * PANGO_SCALE;
@@ -348,7 +342,7 @@ gnm_so_filled_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
 	gsf_xml_out_add_float   (output, "Width", sof->style->outline.width, 2);
 	gnm_xml_out_add_gocolor (output, "OutlineColor", sof->style->outline.color);
 	gnm_xml_out_add_gocolor (output, "FillColor",	 sof->style->fill.pattern.back);
-	if (!sof->is_oval && sof->text != NULL) {
+	if (*(sof->text) != '\0') {
 		gsf_xml_out_add_cstr (output, "Label", sof->text);
 		if (sof->markup != NULL) {
 			GOFormat *fmt = go_format_new_markup	(sof->markup, TRUE);
@@ -547,7 +541,8 @@ gnm_so_filled_init (GObject *obj)
 {
 	GnmSOFilled *sof = GNM_SO_FILLED (obj);
 	sof->style = sof_default_style ();
-	sof->text = NULL;
+	sof->text = g_strdup (""); /* If we initialize with NULL, the canvas item */
+	                           /* does not react on changes */
 	sof->markup = NULL;
 	sof->margin_pts.top  = sof->margin_pts.bottom = 3;
 	sof->margin_pts.left = sof->margin_pts.right  = 5;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]