[gnumeric] Use GnmTextView for comment dialog



commit 971e0aee183e04e88a62f3465529b783cc4e808c
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Apr 29 21:17:30 2009 -0600

    Use GnmTextView for comment dialog
    
    2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/sheet-object-cell-comment.h (cell_set_comment): add
    	  markup argument and change all callers
    	* src/sheet-object-cell-comment.c (cell_set_comment): add
    	  markup argument
    	(cell_comment_set_property): comment out invalid call to
    	  foo_canvas_item_set
    	* src/commands.h (cmd_set_comment): add attribute argument
    	* src/commands.c (cmd_set_comment): add attribute argument
    	(cmd_set_comment_apply): ditto and change all callers
    	(cmd_set_comment_finalize): unref attributes
    	* src/gui-util.c (gnumeric_keyed_dialog): remember dialog size for
    	  comment dialog
    
    2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* C/.gitignore: add files created when building the gnumeric
    	  documentation
    
    2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* cell-comment.glade: prepare for GnmTextView and add checkbox
    	* dialog-cell-comment.c (cb_cell_comment_ok_clicked): handle attributes
    	(dialog_cell_comment): ditto
    	(cb_wrap_toggled): new
    	* dialog-so-styled.c (cb_dialog_so_styled_text_widget_changed): use
    	  "attributes" property of GnmTextView
    	(dialog_so_styled_text_widget): ditto
    
    2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gnumeric-text-view.c: replace "buffer" property with "attributes"
    	  property and add "wrap" property
---
 ChangeLog                         |   15 +++
 doc/C/.gitignore                  |   12 +++
 doc/ChangeLog                     |    5 +
 plugins/excel/ms-excel-read.c     |    4 +-
 plugins/html/html_read.c          |    2 +-
 plugins/lotus-123/lotus.c         |    2 +-
 src/commands.c                    |   40 ++++++--
 src/commands.h                    |    3 +-
 src/dialogs/ChangeLog             |   10 ++
 src/dialogs/cell-comment.glade    |  189 ++++++++++++++++---------------------
 src/dialogs/dialog-cell-comment.c |   57 ++++++++----
 src/dialogs/dialog-so-styled.c    |    8 +-
 src/gui-util.c                    |    5 +-
 src/sheet-object-cell-comment.c   |   10 ++-
 src/sheet-object-cell-comment.h   |    3 +-
 src/tools/dao.c                   |    2 +-
 src/widgets/ChangeLog             |    5 +
 src/widgets/gnumeric-text-view.c  |   57 +++++++++---
 src/xml-io.c                      |    3 +-
 19 files changed, 262 insertions(+), 170 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c8a68c1..dd0c877 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/sheet-object-cell-comment.h (cell_set_comment): add
+	  markup argument and change all callers
+	* src/sheet-object-cell-comment.c (cell_set_comment): add
+	  markup argument
+	(cell_comment_set_property): comment out invalid call to 
+	  foo_canvas_item_set
+	* src/commands.h (cmd_set_comment): add attribute argument
+	* src/commands.c (cmd_set_comment): add attribute argument
+	(cmd_set_comment_apply): ditto and change all callers
+	(cmd_set_comment_finalize): unref attributes
+	* src/gui-util.c (gnumeric_keyed_dialog): remember dialog size for 
+	  comment dialog
+
 2009-04-29  Morten Welinder  <terra gnome org>
 
 	* */*.c: Reduce use of gnm_conventions_default and
diff --git a/doc/C/.gitignore b/doc/C/.gitignore
index 33153b4..0d4fdb8 100644
--- a/doc/C/.gitignore
+++ b/doc/C/.gitignore
@@ -7,3 +7,15 @@ func.defs
 gnumeric-*.omf
 gnumeric-*.omf.out
 omf_timestamp
+gnumeric.aux
+gnumeric.cb
+gnumeric.cb2
+gnumeric.glo
+gnumeric.idx
+gnumeric.lof
+gnumeric.log
+gnumeric.lot
+gnumeric.out
+gnumeric.pdf
+gnumeric.tex
+gnumeric.toc
\ No newline at end of file
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 701f88d..1156751 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* C/.gitignore: add files created when building the gnumeric 
+	  documentation
+
 2009-04-06  Jody Goldberg <jody gnome org>
 	From Joseph Pingenot <trelane digitasaru net>
 
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 8d74f8a..0e9fbb1 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -2864,7 +2864,7 @@ excel_read_NOTE (BiffQuery *q, ExcelReadSheet *esheet)
 		} else {
 			/* hmm, how did this happen ? we should have seen
 			 * some escher records earlier */
-			cell_set_comment (sheet, &pos, author, NULL);
+			cell_set_comment (sheet, &pos, author, NULL, NULL);
 		}
 		g_free (author);
 	} else {
@@ -2896,7 +2896,7 @@ excel_read_NOTE (BiffQuery *q, ExcelReadSheet *esheet)
 		d (2, fprintf (stderr,"Comment in %s%d: '%s'\n",
 			      col_name (pos.col), pos.row + 1, comment->str););
 
-		cell_set_comment (sheet, &pos, NULL, comment->str);
+		cell_set_comment (sheet, &pos, NULL, comment->str, NULL);
 		g_string_free (comment, TRUE);
 	}
 }
diff --git a/plugins/html/html_read.c b/plugins/html/html_read.c
index ec228a1..c790d9e 100644
--- a/plugins/html/html_read.c
+++ b/plugins/html/html_read.c
@@ -256,7 +256,7 @@ html_read_row (htmlNodePtr cur, htmlDocPtr doc, GnmHtmlTableCtxt *tc)
 				char *name;
 
 				name = g_strndup (CXML2C (a_buf->content), a_buf->use);
-				cell_set_comment (tc->sheet, &pos, NULL, name);
+				cell_set_comment (tc->sheet, &pos, NULL, name, NULL);
 				g_free (name);
 			}
 			g_string_free (buf, TRUE);
diff --git a/plugins/lotus-123/lotus.c b/plugins/lotus-123/lotus.c
index 06cad5e..11f4a19 100644
--- a/plugins/lotus-123/lotus.c
+++ b/plugins/lotus-123/lotus.c
@@ -2298,7 +2298,7 @@ lotus_read_new (LotusState *state, record_t *r)
 
 			pos.col = col;
 			pos.row = row;
-			cell_set_comment (sheet, &pos, NULL, text);
+			cell_set_comment (sheet, &pos, NULL, text, NULL);
 			g_free (text);
 			break;
 		}
diff --git a/src/commands.c b/src/commands.c
index 39c3671..0d4b873 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -4910,19 +4910,22 @@ typedef struct {
 	GnmCellPos	        pos;
 	gchar		*new_text;
 	gchar		*old_text;
+	PangoAttrList   *old_attributes;
+	PangoAttrList   *new_attributes;
 } CmdSetComment;
 
 MAKE_GNM_COMMAND (CmdSetComment, cmd_set_comment, NULL)
 
 static gboolean
-cmd_set_comment_apply (Sheet *sheet, GnmCellPos *pos, char const *text)
+cmd_set_comment_apply (Sheet *sheet, GnmCellPos *pos, char const *text, PangoAttrList *attributes)
 {
 	GnmComment   *comment;
 
 	comment = sheet_get_comment (sheet, pos);
 	if (comment) {
 		if (text)
-			cell_comment_text_set (comment, text);
+			g_object_set (G_OBJECT (comment), "text", text, 
+				      "markup", attributes, NULL);
 		else {
 			GnmRange const *mr;
 
@@ -4937,7 +4940,7 @@ cmd_set_comment_apply (Sheet *sheet, GnmCellPos *pos, char const *text)
 			}
 		}
 	} else if (text && (strlen (text) > 0))
-		cell_set_comment (sheet, pos, NULL, text);
+		cell_set_comment (sheet, pos, NULL, text, attributes);
 
 	sheet_mark_dirty (sheet);
 	return FALSE;
@@ -4949,7 +4952,7 @@ cmd_set_comment_undo (GnmCommand *cmd,
 {
 	CmdSetComment *me = CMD_SET_COMMENT (cmd);
 
-	return cmd_set_comment_apply (me->sheet, &me->pos, me->old_text);
+	return cmd_set_comment_apply (me->sheet, &me->pos, me->old_text, me->old_attributes);
 }
 
 static gboolean
@@ -4958,7 +4961,7 @@ cmd_set_comment_redo (GnmCommand *cmd,
 {
 	CmdSetComment *me = CMD_SET_COMMENT (cmd);
 
-	return cmd_set_comment_apply (me->sheet, &me->pos, me->new_text);
+	return cmd_set_comment_apply (me->sheet, &me->pos, me->new_text, me->new_attributes);
 }
 
 static void
@@ -4972,13 +4975,24 @@ cmd_set_comment_finalize (GObject *cmd)
 	g_free (me->old_text);
 	me->old_text = NULL;
 
+	if (me->old_attributes != NULL) {
+		pango_attr_list_unref (me->old_attributes);
+		me->old_attributes = NULL;
+	}
+
+	if (me->new_attributes != NULL) {
+		pango_attr_list_unref (me->new_attributes);
+		me->new_attributes = NULL;
+	}
+
 	gnm_command_finalize (cmd);
 }
 
 gboolean
 cmd_set_comment (WorkbookControl *wbc,
-	      Sheet *sheet, GnmCellPos const *pos,
-	      char const *new_text)
+		 Sheet *sheet, GnmCellPos const *pos,
+		 char const *new_text,
+		 PangoAttrList *attr)
 {
 	CmdSetComment *me;
 	GnmComment   *comment;
@@ -4995,6 +5009,9 @@ cmd_set_comment (WorkbookControl *wbc,
 		me->new_text = NULL;
 	else
 		me->new_text    = g_strdup (new_text);
+	if (attr != NULL)
+		pango_attr_list_ref (attr);
+	me->new_attributes = attr;
 	where = undo_cell_pos_name (sheet, pos);
 	me->cmd.cmd_descriptor =
 		g_strdup_printf (me->new_text == NULL ?
@@ -5003,11 +5020,16 @@ cmd_set_comment (WorkbookControl *wbc,
 				 where);
 	g_free (where);
 	me->old_text    = NULL;
+	me->old_attributes = NULL;
 	me->pos         = *pos;
 	me->sheet       = sheet;
 	comment = sheet_get_comment (sheet, pos);
-	if (comment)
-		me->old_text = g_strdup (cell_comment_text_get (comment));
+	if (comment) {
+		g_object_get (G_OBJECT (comment), "text", &(me->old_text), "markup", &(me->old_attributes), NULL);
+		if (me->old_attributes != NULL)
+			pango_attr_list_ref (me->old_attributes);
+		me->old_text = g_strdup (me->old_text);
+	}
 
 	/* Register the command object */
 	return command_push_undo (wbc, G_OBJECT (me));
diff --git a/src/commands.h b/src/commands.h
index a977784..e76a67b 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -94,7 +94,8 @@ gboolean cmd_rename_sheet	(WorkbookControl *wbc, Sheet *sheet,
 				 char const *new_name);
 
 gboolean cmd_set_comment	(WorkbookControl *wbc, Sheet *sheet,
-				 GnmCellPos const *pos, char const *new_text);
+				 GnmCellPos const *pos, char const *new_text,
+				 PangoAttrList *attr);
 
 gboolean cmd_analysis_tool	(WorkbookControl *wbc, Sheet *sheet,
 				 data_analysis_output_t *dao, gpointer specs,
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 4d3c3e4..f32b16c 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,13 @@
+2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* cell-comment.glade: prepare for GnmTextView and add checkbox
+	* dialog-cell-comment.c (cb_cell_comment_ok_clicked): handle attributes
+	(dialog_cell_comment): ditto
+	(cb_wrap_toggled): new
+	* dialog-so-styled.c (cb_dialog_so_styled_text_widget_changed): use 
+	  "attributes" property of GnmTextView
+	(dialog_so_styled_text_widget): ditto
+
 2009-04-28  Jody Goldberg <jody gnome org>
 
 	* dialog-preferences.c (pref_window_page_initializer) : entry for
diff --git a/src/dialogs/cell-comment.glade b/src/dialogs/cell-comment.glade
index db63fec..114bcc1 100644
--- a/src/dialogs/cell-comment.glade
+++ b/src/dialogs/cell-comment.glade
@@ -1,111 +1,82 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkDialog" id="comment_dialog">
-  <property name="border_width">5</property>
-  <property name="title" translatable="yes">Cell Comment</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">True</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="has_separator">False</property>
-
-  <child internal-child="vbox">
-    <widget class="GtkVBox" id="dialog-vbox1">
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">2</property>
-
-      <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="dialog-action_area1">
-	  <property name="visible">True</property>
-	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="help_button">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-help</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="cancel_button">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="ok_button">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="response_id">0</property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">True</property>
-	  <property name="pack_type">GTK_PACK_END</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkScrolledWindow" id="scrolledwindow1">
-	  <property name="border_width">5</property>
-	  <property name="width_request">100</property>
-	  <property name="height_request">100</property>
-	  <property name="visible">True</property>
-	  <property name="can_focus">True</property>
-	  <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-	  <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-	  <property name="shadow_type">GTK_SHADOW_IN</property>
-	  <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
-
-	  <child>
-	    <widget class="GtkTextView" id="textview">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="justification">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap_mode">GTK_WRAP_NONE</property>
-	      <property name="cursor_visible">True</property>
-	      <property name="pixels_above_lines">0</property>
-	      <property name="pixels_below_lines">0</property>
-	      <property name="pixels_inside_wrap">0</property>
-	      <property name="left_margin">0</property>
-	      <property name="right_margin">0</property>
-	      <property name="indent">0</property>
-	      <property name="text" translatable="yes"></property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkDialog" id="comment_dialog">
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Cell Comment</property>
+    <property name="default_width">300</property>
+    <property name="default_height">300</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkCheckButton" id="wrap-check">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="label" translatable="yes">_Wrap in properties window</property>
+            <property name="use_underline">True</property>
+            <property name="response_id">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="help_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-help</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="cancel_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="ok_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>
diff --git a/src/dialogs/dialog-cell-comment.c b/src/dialogs/dialog-cell-comment.c
index 5e9b2d4..85b77c4 100644
--- a/src/dialogs/dialog-cell-comment.c
+++ b/src/dialogs/dialog-cell-comment.c
@@ -31,6 +31,7 @@
 #include <wbc-gtk.h>
 #include <ranges.h>
 #include <commands.h>
+#include <widgets/gnumeric-text-view.h>
 
 #define COMMENT_DIALOG_KEY "cell-comment-dialog"
 
@@ -41,7 +42,7 @@ typedef struct {
 	GtkWidget          *dialog;
 	GtkWidget          *ok_button;
 	GtkWidget          *cancel_button;
-	GtkTextBuffer      *text;
+	GnmTextView        *gtv;
 	GladeXML           *gui;
 } CommentState;
 
@@ -64,23 +65,31 @@ static void
 cb_cell_comment_ok_clicked (G_GNUC_UNUSED GtkWidget *button,
 			    CommentState *state)
 {
-	GtkTextIter start;
-	GtkTextIter end;
 	char *text;
+	PangoAttrList *attr;
 
-	gtk_text_buffer_get_bounds (state->text, &start, &end);
-	text = gtk_text_buffer_get_text (state->text, &start, &end, TRUE);
-
-	if (!cmd_set_comment (WORKBOOK_CONTROL (state->wbcg), state->sheet, state->pos, text))
+	g_object_get (G_OBJECT (state->gtv), "text", &text, 
+		      "attributes", &attr, NULL);
+	if (!cmd_set_comment (WORKBOOK_CONTROL (state->wbcg), 
+			      state->sheet, state->pos, text, attr))
 		gtk_widget_destroy (state->dialog);
 	g_free (text);
+	pango_attr_list_unref (attr);
+}
+
+static void
+cb_wrap_toggled (GtkToggleButton *button, GObject *gtv)
+{
+	g_object_set (gtv, "wrap",
+		      gtk_toggle_button_get_active (button) ? GTK_WRAP_WORD : GTK_WRAP_NONE, 
+		      NULL);
 }
 
 void
 dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 {
 	CommentState	*state;
-	GtkWidget	*textview;
+	GtkWidget	*box, *check;
 	GnmComment	*comment;
 	GladeXML	*gui;
 
@@ -104,20 +113,25 @@ dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 	state->dialog = glade_xml_get_widget (state->gui, "comment_dialog");
 	g_return_if_fail (state->dialog != NULL);
 
-	textview = glade_xml_get_widget (state->gui, "textview");
-	g_return_if_fail (textview != NULL);
-	state->text = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview));
+	box = glade_xml_get_widget (state->gui, "dialog-vbox");
+	g_return_if_fail (box != NULL);
+	state->gtv = gnm_text_view_new ();
+	gtk_widget_show_all (GTK_WIDGET (state->gtv));
+	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (state->gtv), 
+			    TRUE, TRUE, TRUE);
+	g_object_set (state->gtv, "wrap", GTK_WRAP_WORD, NULL); 
 
 	comment = sheet_get_comment (sheet, pos);
 	if (comment) {
-		GtkTextIter start;
-
-		gtk_text_buffer_set_text (state->text, cell_comment_text_get (comment),
-					  -1);
-		gtk_text_buffer_get_start_iter (state->text, &start);
-		gtk_text_buffer_place_cursor (state->text, &start);
+		char *text;
+		PangoAttrList *attr;
+		g_object_get (G_OBJECT (comment), "text", &text, 
+			      "markup", &attr, NULL); 
+		g_object_set (state->gtv, "text", text,
+			      "attributes", attr, NULL);
+		if (attr != NULL)
+			pango_attr_list_unref (attr);
 	}
-
 	state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
 	g_signal_connect (G_OBJECT (state->ok_button),
 		"clicked",
@@ -128,10 +142,15 @@ dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 		"clicked",
 		G_CALLBACK (cb_cell_comment_cancel_clicked), state);
 
+	check = glade_xml_get_widget (state->gui, "wrap-check");
+	g_signal_connect (G_OBJECT (check),
+			  "toggled",
+			  G_CALLBACK (cb_wrap_toggled), state->gtv);
+	cb_wrap_toggled (GTK_TOGGLE_BUTTON (check), G_OBJECT (state->gtv));
+
 	gnumeric_init_help_button (
 		glade_xml_get_widget (state->gui, "help_button"),
 		GNUMERIC_HELP_LINK_CELL_COMMENT);
-	gtk_widget_grab_focus (textview);
 
 	wbc_gtk_attach_guru (state->wbcg, state->dialog);
 	g_object_set_data_full (G_OBJECT (state->dialog),
diff --git a/src/dialogs/dialog-so-styled.c b/src/dialogs/dialog-so-styled.c
index 4d63c05..71e3198 100644
--- a/src/dialogs/dialog-so-styled.c
+++ b/src/dialogs/dialog-so-styled.c
@@ -89,14 +89,12 @@ cb_dialog_so_styled_text_widget_changed (GnmTextView *gtv, DialogSOStyled *state
 {
 	gchar *text;
 	PangoAttrList *attr;
-	GtkTextBuffer *buffer;
 
 	g_object_get (gtv, "text", &text, NULL);
 	g_object_set (state->so, "text", text, NULL);
 	g_free (text);
 
-	g_object_get (gtv, "buffer", &buffer, NULL);	
-	attr = gnm_get_pango_attributes_from_buffer (buffer);	
+	g_object_get (gtv, "attributes", &attr, NULL);	
 	g_object_set (state->so, "markup", attr, NULL);
 	pango_attr_list_unref (attr);
 }
@@ -109,7 +107,6 @@ dialog_so_styled_text_widget (DialogSOStyled *state)
 	GnmTextView *gtv = gnm_text_view_new ();
 	char *strval;
 	PangoAttrList  *markup;
-	GtkTextBuffer *buffer;
 
 	g_object_get (state->so, "text", &strval, NULL);
 	g_object_set (gtv, "text", strval, NULL);
@@ -118,8 +115,7 @@ dialog_so_styled_text_widget (DialogSOStyled *state)
 	g_object_get (state->so, "markup", &markup, NULL);
 	state->orig_attributes = markup;
 	pango_attr_list_ref (state->orig_attributes);
-	g_object_get (gtv, "buffer", &buffer, NULL);	
-	gnm_load_pango_attributes_into_buffer (markup, buffer);
+	g_object_set (gtv, "attributes", markup, NULL);
 
 	g_signal_connect (G_OBJECT (gtv), "changed",
 			  G_CALLBACK (cb_dialog_so_styled_text_widget_changed), state);
diff --git a/src/gui-util.c b/src/gui-util.c
index 9341916..c65c1a4 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -258,8 +258,9 @@ gnumeric_keyed_dialog (WBCGtk *wbcg, GtkWindow *dialog, char const *key)
 	h = g_object_get_data (G_OBJECT (screen), SAVE_SIZES_SCREEN_KEY);
 	allocation = h ? g_hash_table_lookup (h, key) : NULL;
 
-	/* TECHOLOGY PREVIEW -- ZOOM DIALOG ONLY.  */
-	if (strcmp (key, "zoom-dialog") == 0) {
+	/* TECHOLOGY PREVIEW -- ZOOM & COMMENT DIALOG ONLY.  */
+	if ((strcmp (key, "zoom-dialog") == 0) || 
+	    (strcmp (key, "cell-comment-dialog") == 0)) {
 		if (allocation) {
 #if 0
 			g_print ("Restoring %s to %dx%d at (%d,%d)\n",
diff --git a/src/sheet-object-cell-comment.c b/src/sheet-object-cell-comment.c
index ddee507..9441a26 100644
--- a/src/sheet-object-cell-comment.c
+++ b/src/sheet-object-cell-comment.c
@@ -170,8 +170,8 @@ cell_comment_set_property (GObject *obj, guint param_id,
 		return;
 	}
 
-	for (ptr = SHEET_OBJECT (cc)->realized_list; ptr != NULL; ptr = ptr->next)
-		foo_canvas_item_set (ptr->data, "attributes", cc->markup, NULL);
+/* 	for (ptr = SHEET_OBJECT (cc)->realized_list; ptr != NULL; ptr = ptr->next) */
+/* 		foo_canvas_item_set (ptr->data, "attributes", cc->markup, NULL); */
 }
 
 static void
@@ -406,7 +406,8 @@ cell_comment_set_pos (GnmComment *cc, GnmCellPos const *pos)
 
 GnmComment *
 cell_set_comment (Sheet *sheet, GnmCellPos const *pos,
-		  char const *author, char const *text)
+		  char const *author, char const *text,
+		  PangoAttrList *attr)
 {
 	GnmComment *cc;
 
@@ -416,6 +417,9 @@ cell_set_comment (Sheet *sheet, GnmCellPos const *pos,
 	cc = g_object_new (CELL_COMMENT_TYPE, NULL);
 	cc->author = g_strdup (author);
 	cc->text = g_strdup (text);
+	cc->markup = attr;
+	if (cc->markup != NULL)
+		pango_attr_list_ref (cc->markup);
 
 	cell_comment_set_pos (cc, pos);
 
diff --git a/src/sheet-object-cell-comment.h b/src/sheet-object-cell-comment.h
index 848c913..3982c93 100644
--- a/src/sheet-object-cell-comment.h
+++ b/src/sheet-object-cell-comment.h
@@ -21,7 +21,8 @@ void         cell_comment_text_set   (GnmComment       *cc, char const *text);
 /* convenience routine */
 void	     cell_comment_set_pos   (GnmComment *cc, GnmCellPos const *pos);
 GnmComment  *cell_set_comment	    (Sheet *sheet, GnmCellPos const *pos,
-				     char const *author, char const *text);
+				     char const *author, char const *text,
+				     PangoAttrList * markup);
 
 G_END_DECLS
 
diff --git a/src/tools/dao.c b/src/tools/dao.c
index a14ea97..d15df21 100644
--- a/src/tools/dao.c
+++ b/src/tools/dao.c
@@ -630,7 +630,7 @@ dao_set_cell_comment (data_analysis_output_t *dao, int col, int row,
 
 	pos.col = col;
 	pos.row = row;
-	cell_set_comment (dao->sheet, &pos, author, comment);
+	cell_set_comment (dao->sheet, &pos, author, comment, NULL);
 }
 
 
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 9c007e6..04cb706 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gnumeric-text-view.c: replace "buffer" property with "attributes" 
+	  property and add "wrap" property
+
 2009-04-29  Morten Welinder  <terra gnome org>
 
 	* gnumeric-expr-entry.c (gnm_expr_entry_get_scg): New function.
diff --git a/src/widgets/gnumeric-text-view.c b/src/widgets/gnumeric-text-view.c
index 46e90af..76a4f79 100644
--- a/src/widgets/gnumeric-text-view.c
+++ b/src/widgets/gnumeric-text-view.c
@@ -34,6 +34,7 @@ struct _GnmTextView {
 	GtkVBox	parent;
 
 	GtkTextBuffer *buffer;
+	GtkTextView *view;
 	
 	GtkToggleToolButton *italic;
 	GtkToggleToolButton *strikethrough;
@@ -56,7 +57,8 @@ enum {
 enum {
 	PROP_0,
 	PROP_TEXT,
-	PROP_BUFFER
+	PROP_WRAP,
+	PROP_ATTR
 };
 
 static guint signals [LAST_SIGNAL] = { 0 };
@@ -290,6 +292,13 @@ gtv_set_property (GObject      *object,
 		gtk_text_buffer_set_text (gtv->buffer, 
 					  g_value_get_string (value), -1);
 		break;
+	case PROP_WRAP:
+		gtk_text_view_set_wrap_mode (gtv->view, g_value_get_int (value));
+		break;
+	case PROP_ATTR:
+		gnm_load_pango_attributes_into_buffer (g_value_get_boxed (value), 
+						       gtv->buffer);
+	break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	}
@@ -311,9 +320,16 @@ gtv_get_property (GObject      *object,
 		g_free (text);
 	}
 	break;
-	case PROP_BUFFER:
-		g_value_set_object (value, G_OBJECT (gtv->buffer));
-		break;
+	case PROP_WRAP:
+		g_value_set_int (value, gtk_text_view_get_wrap_mode (gtv->view));
+	break;
+	case PROP_ATTR:
+	{
+		PangoAttrList *attr = gnm_get_pango_attributes_from_buffer 
+			(gtv->buffer);
+		g_value_take_boxed (value, attr);
+	}
+	break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 	}
@@ -324,9 +340,10 @@ static void
 gtv_init (GnmTextView *gtv)
 {
 	GtkWidget *tb = gtk_toolbar_new ();
-	GtkWidget *tv = gtk_text_view_new ();
+	GtkWidget *sw = gtk_scrolled_window_new (NULL, NULL);
 
-	gtv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
+	gtv->view = GTK_TEXT_VIEW (gtk_text_view_new ());
+	gtv->buffer = gtk_text_view_get_buffer (gtv->view);
 	gnm_create_std_tags_for_buffer (gtv->buffer);
 
 	gtv->italic = gtv_build_toggle_button (tb, gtv, GTK_STOCK_ITALIC, 
@@ -338,8 +355,11 @@ gtv_init (GnmTextView *gtv)
 	gtk_toolbar_insert(GTK_TOOLBAR(tb), gtk_separator_tool_item_new (), -1);
 	gtv->bold = gtv_build_button_bold (tb, gtv);
 
-	gtk_container_set_border_width (GTK_CONTAINER (tv), 5);
-	gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD_CHAR);
+	gtk_container_set_border_width (GTK_CONTAINER (gtv->view), 5);
+	gtk_text_view_set_wrap_mode (gtv->view, GTK_WRAP_WORD_CHAR);
+
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, 
+					GTK_POLICY_AUTOMATIC);
 	
 	g_signal_connect (G_OBJECT (gtv->buffer), "changed",
 			  G_CALLBACK (cb_gtv_emit_changed), gtv);
@@ -347,7 +367,8 @@ gtv_init (GnmTextView *gtv)
 			  G_CALLBACK (cb_gtv_mark_set), gtv);
 
 	gtk_box_pack_start (GTK_BOX (gtv), tb, FALSE, TRUE, 0);
-	gtk_box_pack_start (GTK_BOX (gtv), tv, TRUE, TRUE, 0);
+	gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (gtv->view));
+	gtk_box_pack_start (GTK_BOX (gtv), sw, TRUE, TRUE, 0);
 
 
 }
@@ -378,11 +399,19 @@ gtv_class_init (GObjectClass *gobject_class)
 			"",
 			GSF_PARAM_STATIC | G_PARAM_READWRITE));
 	g_object_class_install_property (gobject_class,
-		PROP_BUFFER,
-		g_param_spec_object ("buffer", "TextBuffer",
-			"The GtkTextBuffer associated with this view",
-			G_TYPE_OBJECT,
-			GSF_PARAM_STATIC | G_PARAM_READABLE));
+		PROP_WRAP,
+		g_param_spec_int ("wrap", "Wrap",
+				  "The wrapping mode",
+				  GTK_WRAP_NONE, GTK_WRAP_WORD_CHAR, 
+				  GTK_WRAP_WORD,
+				  GSF_PARAM_STATIC | G_PARAM_READWRITE));
+	g_object_class_install_property 
+		(gobject_class, PROP_ATTR,
+		 g_param_spec_boxed 
+		 ("attributes", "PangoAttrList",
+		  "A PangoAttrList derived from the buffer content.",
+		  PANGO_TYPE_ATTR_LIST,	    
+		  GSF_PARAM_STATIC | G_PARAM_READWRITE));
 }
 
 
diff --git a/src/xml-io.c b/src/xml-io.c
index 5021c93..2243a27 100644
--- a/src/xml-io.c
+++ b/src/xml-io.c
@@ -1235,7 +1235,8 @@ xml_read_cell (XmlParseContext *ctxt, xmlNodePtr tree)
 			} else if (!strcmp (child->name, "Comment")) {
 				xmlChar *comment = xmlNodeGetContent (child);
 				cell_set_comment (cell->base.sheet,
-						  &cell->pos, NULL, comment);
+						  &cell->pos, NULL, comment, 
+						  NULL);
 				xmlFree (comment);
 			}
 		}



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