[libgda/gtk3] GdauiRtEditor: insert text as title on a title line



commit ad36021d9553b74231d67c5b78f0d65bb426e3ad
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Dec 14 19:16:31 2010 +0100

    GdauiRtEditor: insert text as title on a title line

 libgda-ui/gdaui-rt-editor.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/libgda-ui/gdaui-rt-editor.c b/libgda-ui/gdaui-rt-editor.c
index 33d6128..69c071c 100644
--- a/libgda-ui/gdaui-rt-editor.c
+++ b/libgda-ui/gdaui-rt-editor.c
@@ -723,6 +723,8 @@ insert_text_after_cb (GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *t
 
 	if ((rte->priv->insert_offset < 0) || rte->priv->show_markup)
 		return;
+
+	/* disable any extra modification while text is being set using gdaui_rt_editor_set_contents() */
 	if (rte->priv->contents_setting)
 		return;
 
@@ -744,12 +746,12 @@ insert_text_after_cb (GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *t
 	}
 	rte->priv->insert_offset = -1;
 
+	gtk_text_iter_set_line_offset (&start, 0);
 	/* add new bullet if already in list */
 	if (*text == '\n') {
 		gchar *text_to_insert = NULL;
 		GtkTextTag *tag;
 		gint index;
-		gtk_text_iter_set_line_offset (&start, 0);
 		tag = iter_begins_list (rte, &start, &index);
 		if (tag)
 			text_to_insert = lists_tokens [index];
@@ -760,6 +762,17 @@ insert_text_after_cb (GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *t
 			gtk_text_buffer_insert (textbuffer, &end, text_to_insert, -1);
 		}
 	}
+	else {
+		GtkTextTag *tag = NULL;
+		end = *location;
+		
+		if (gtk_text_iter_begins_tag (&start, rte->priv->tags[TEXT_TAG_TITLE1].tag))
+			tag = rte->priv->tags[TEXT_TAG_TITLE1].tag;
+		else if (gtk_text_iter_begins_tag (&start, rte->priv->tags[TEXT_TAG_TITLE2].tag))
+			tag = rte->priv->tags[TEXT_TAG_TITLE2].tag;
+		if (tag)
+			gtk_text_buffer_apply_tag (rte->priv->textbuffer, tag, &start, &end);
+	}
 }
 
 static void



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