gtksourceview r2025 - in trunk: . gtksourceview
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gtksourceview r2025 - in trunk: . gtksourceview
- Date: Mon, 11 Aug 2008 00:29:10 +0000 (UTC)
Author: pborelli
Date: Mon Aug 11 00:29:10 2008
New Revision: 2025
URL: http://svn.gnome.org/viewvc/gtksourceview?rev=2025&view=rev
Log:
2008-08-11 Paolo Borelli <paolo borelli katamail com>
* gtksourceview/gtksourcebuffer.c:
track when the object has been constructed so that we know the
tag-table is there and we can check bracket matches etc.
Modified:
trunk/ChangeLog
trunk/gtksourceview/gtksourcebuffer.c
Modified: trunk/gtksourceview/gtksourcebuffer.c
==============================================================================
--- trunk/gtksourceview/gtksourcebuffer.c (original)
+++ trunk/gtksourceview/gtksourcebuffer.c Mon Aug 11 00:29:10 2008
@@ -85,6 +85,8 @@
gint highlight_syntax:1;
gint highlight_brackets:1;
+ gint constructed:1;
+
GtkTextTag *bracket_match_tag;
GtkTextMark *bracket_mark;
guint bracket_found:1;
@@ -103,6 +105,9 @@
static guint buffer_signals[LAST_SIGNAL];
+static GObject *gtk_source_buffer_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_param);
static void gtk_source_buffer_finalize (GObject *object);
static void gtk_source_buffer_dispose (GObject *object);
static void gtk_source_buffer_set_property (GObject *object,
@@ -144,6 +149,7 @@
object_class = G_OBJECT_CLASS (klass);
tb_class = GTK_TEXT_BUFFER_CLASS (klass);
+ object_class->constructor = gtk_source_buffer_constructor;
object_class->finalize = gtk_source_buffer_finalize;
object_class->dispose = gtk_source_buffer_dispose;
object_class->get_property = gtk_source_buffer_get_property;
@@ -307,6 +313,23 @@
buffer);
}
+static GObject *
+gtk_source_buffer_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_param)
+{
+ GObject *object;
+
+ object = G_OBJECT_CLASS(gtk_source_buffer_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_param);
+
+ /* we need to know that the tag-table was set */
+ GTK_SOURCE_BUFFER (object)->priv->constructed = TRUE;
+
+ return object;
+}
+
static void
gtk_source_buffer_finalize (GObject *object)
{
@@ -1055,9 +1078,16 @@
buffer->priv->highlight_brackets = highlight;
- mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
- gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &iter, mark);
- gtk_source_buffer_move_cursor (GTK_TEXT_BUFFER (buffer), &iter, mark);
+ /* try to see if there is already a bracket match at the
+ * current position, but only if the tag table is already set
+ * otherwise we have problems when calling this function
+ * on init (get_insert creates the tag table as a side effect */
+ if (buffer->priv->constructed)
+ {
+ mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &iter, mark);
+ gtk_source_buffer_move_cursor (GTK_TEXT_BUFFER (buffer), &iter, mark);
+ }
g_object_notify (G_OBJECT (buffer), "highlight-matching-brackets");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]