[gnumeric] Show text formatting in cell comments and add cell name to dialog title



commit 25064cb058531d9407146275637fee87da9257e5
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Apr 30 00:13:18 2009 -0600

    Show text formatting in cell comments and add cell name to dialog title
    
    2009-04-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/sheet-control-gui.c (scg_comment_display):
    	  use comment attributes
    	* src/sheet-object-cell-comment.c (cell_comment_set_property):
    	  remove invalid and unneeded code
    
    2009-04-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-cell-comment.c (dialog_cell_comment): show cell name in
    	  dialog title
---
 ChangeLog                         |    7 +++++++
 NEWS                              |    1 +
 src/dialogs/ChangeLog             |    5 +++++
 src/dialogs/dialog-cell-comment.c |   21 ++++++++++++++++++++-
 src/sheet-control-gui.c           |   36 ++++++++++++++++++++++--------------
 src/sheet-object-cell-comment.c   |    6 ++----
 6 files changed, 57 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dd0c877..69f8375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-04-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* src/sheet-control-gui.c (scg_comment_display):
+	  use comment attributes
+	* src/sheet-object-cell-comment.c (cell_comment_set_property):
+	  remove invalid and unneeded code
+
 2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/sheet-object-cell-comment.h (cell_set_comment): add
diff --git a/NEWS b/NEWS
index de7bdbf..9e0d071 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.9.7
 Andreas:
 	* Fix some divergence between character weight in the label properties
 	  dialog and the label itself.
+	* Add interface to format cell comments
 
 Jody:
 	* XLSX start reading external refs.
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index f32b16c..d5fa5d7 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* dialog-cell-comment.c (dialog_cell_comment): show cell name in 
+	  dialog title
+
 2009-04-29  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* cell-comment.glade: prepare for GnmTextView and add checkbox
diff --git a/src/dialogs/dialog-cell-comment.c b/src/dialogs/dialog-cell-comment.c
index 85b77c4..49a6c95 100644
--- a/src/dialogs/dialog-cell-comment.c
+++ b/src/dialogs/dialog-cell-comment.c
@@ -92,6 +92,10 @@ dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 	GtkWidget	*box, *check;
 	GnmComment	*comment;
 	GladeXML	*gui;
+	char *title, *cell_name;
+	GnmCellRef ref;
+	GnmParsePos pp;
+	GnmConventionsOut out;
 
 	g_return_if_fail (wbcg != NULL);
 	g_return_if_fail (sheet != NULL);
@@ -121,6 +125,14 @@ dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 			    TRUE, TRUE, TRUE);
 	g_object_set (state->gtv, "wrap", GTK_WRAP_WORD, NULL); 
 
+	gnm_cellref_init (&ref, sheet, pos->col, pos->row, FALSE);
+	out.accum = g_string_new (NULL);
+	parse_pos_init_sheet (&pp, sheet);
+	out.pp = &pp;
+	out.convs = sheet->convs;
+	cellref_as_string (&out, &ref, FALSE);
+	cell_name = g_string_free (out.accum, FALSE);
+
 	comment = sheet_get_comment (sheet, pos);
 	if (comment) {
 		char *text;
@@ -131,7 +143,14 @@ dialog_cell_comment (WBCGtk *wbcg, Sheet *sheet, GnmCellPos const *pos)
 			      "attributes", attr, NULL);
 		if (attr != NULL)
 			pango_attr_list_unref (attr);
-	}
+		title = g_strdup_printf (_("Edit Cell Comment (%s)"), 
+					 cell_name);
+	} else
+		title = g_strdup_printf (_("New Cell Comment (%s)"), 
+					 cell_name);
+	gtk_window_set_title (GTK_WINDOW (state->dialog), title);
+	g_free (title);
+
 	state->ok_button = glade_xml_get_widget (state->gui, "ok_button");
 	g_signal_connect (G_OBJECT (state->ok_button),
 		"clicked",
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 503f3cd..49ddfad 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -2489,9 +2489,11 @@ scg_comment_display (SheetControlGUI *scg, GnmComment *cc)
 	if (scg->comment.item == NULL) {
 		GtkWidget *text, *frame;
 		GtkTextBuffer *buffer;
-		GtkTextIter iter;
 		GtkWindow *toplevel = wbcg_toplevel (scg_wbcg (scg));
 		GdkScreen *screen = gtk_window_get_screen (toplevel);
+		char *comment_text;
+		char const *comment_author;
+		PangoAttrList *comment_markup;
 
 		scg->comment.item = gtk_window_new (GTK_WINDOW_POPUP);
 		gtk_window_set_screen (GTK_WINDOW (scg->comment.item), screen);
@@ -2503,21 +2505,27 @@ scg_comment_display (SheetControlGUI *scg, GnmComment *cc)
 		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text), GTK_WRAP_NONE);
 		gtk_text_view_set_editable  (GTK_TEXT_VIEW (text), FALSE);
 		buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text));
-		gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
-
-		if (cell_comment_author_get (cc) != NULL) {
-			gtk_text_buffer_create_tag (buffer, "bold",
-						    "weight", PANGO_WEIGHT_BOLD,
-						    NULL);
-			gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
-				cell_comment_author_get (cc), -1,
-				"bold", NULL);
-			gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+		gnm_create_std_tags_for_buffer (buffer);
+
+		g_object_get (G_OBJECT (cc), "text", &comment_text,
+			      "markup", &comment_markup, NULL);
+
+		if (comment_text != NULL) {
+			gtk_text_buffer_set_text (buffer, comment_text, -1);
+			g_free (comment_text);
+			gnm_load_pango_attributes_into_buffer (comment_markup, buffer);
 		}
 
-		if (cell_comment_text_get (cc) != NULL)
-			gtk_text_buffer_insert (buffer, &iter,
-				cell_comment_text_get (cc), -1);
+		comment_author = cell_comment_author_get (cc);
+		if (comment_author != NULL) {
+			GtkTextIter iter;
+			gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+			gtk_text_buffer_insert_with_tags_by_name 
+				(buffer, &iter, comment_author, -1,
+				 "PANGO_WEIGHT_BOLD", NULL);
+			gtk_text_buffer_insert_with_tags_by_name 
+				(buffer, &iter, ":\n", -1, "PANGO_WEIGHT_BOLD", NULL);
+		}
 
 		frame = gtk_frame_new (NULL);
 		gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
diff --git a/src/sheet-object-cell-comment.c b/src/sheet-object-cell-comment.c
index 9441a26..f311dd9 100644
--- a/src/sheet-object-cell-comment.c
+++ b/src/sheet-object-cell-comment.c
@@ -150,7 +150,6 @@ cell_comment_set_property (GObject *obj, guint param_id,
 			   GValue const *value, GParamSpec *pspec)
 {
 	GnmComment *cc = CELL_COMMENT (obj);
-	GList *ptr;
 
 	switch (param_id) {
 	case CC_PROP_TEXT:
@@ -169,9 +168,6 @@ cell_comment_set_property (GObject *obj, guint param_id,
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		return;
 	}
-
-/* 	for (ptr = SHEET_OBJECT (cc)->realized_list; ptr != NULL; ptr = ptr->next) */
-/* 		foo_canvas_item_set (ptr->data, "attributes", cc->markup, NULL); */
 }
 
 static void
@@ -312,6 +308,8 @@ cell_comment_copy (SheetObject *dst, SheetObject const *src)
 	GnmComment	 *new_comment	= CELL_COMMENT (dst);
 	new_comment->author = g_strdup (comment->author);
 	new_comment->text   = g_strdup (comment->text);
+	new_comment->markup = comment->markup;
+	pango_attr_list_ref (new_comment->markup);
 }
 
 static void



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