summaryrefslogtreecommitdiff
path: root/gtk/gtktextmark.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2000-10-24 22:44:14 +0000
committerHavoc Pennington <hp@src.gnome.org>2000-10-24 22:44:14 +0000
commit2fab0eb1fa92964cca24d55e51203c5af5113c8e (patch)
tree6198960908bd87ef72de178dd3ad0452d825832a /gtk/gtktextmark.c
parent873b316f2346ad4cc928b798337d35f46a0ec716 (diff)
downloadgtk+-2fab0eb1fa92964cca24d55e51203c5af5113c8e.tar.gz
make it a static function
2000-10-24 Havoc Pennington <hp@redhat.com> * gtk/gtktextview.c (gtk_text_view_scroll_to_mark_adjusted): make it a static function * gtk/gtktextbtree.c (gtk_text_btree_tag): Gee, maybe we should redraw text when a tag is applied to it. * gtk/gtktexttag.c (gtk_text_tag_affects_size) (gtk_text_tag_affects_nonsize_appearance): private functions to see if a tag requires various kinds of redraw/layout to be queued up. * gtk/gtktexttag.h (struct _GtkTextTag): Remove relief crackrock * gtk/testtext.c (fill_example_buffer): Put the cursor at the start of the buffer, so search works by default * gtk/gtktextiter.c (lines_match): init match_start always * gtk/gtktextbuffer.c (gtk_text_buffer_get_iter_at_line_index): New function, get iter at a line + a byte index * gtk/gtktextiter.c (gtk_text_iter_set_line_index): New function, to set byte position within a line (gtk_text_iter_check): remove leftover G_BREAKPOINT thing
Diffstat (limited to 'gtk/gtktextmark.c')
-rw-r--r--gtk/gtktextmark.c138
1 files changed, 83 insertions, 55 deletions
diff --git a/gtk/gtktextmark.c b/gtk/gtktextmark.c
index a1a4c6f65f..c66af21e2f 100644
--- a/gtk/gtktextmark.c
+++ b/gtk/gtktextmark.c
@@ -50,47 +50,101 @@
#include "gtktextbtree.h"
-gboolean
-gtk_text_mark_is_visible(GtkTextMark *mark)
+static void gtk_text_mark_init (GtkTextMark *mark);
+static void gtk_text_mark_class_init (GtkTextMarkClass *klass);
+static void gtk_text_mark_finalize (GObject *obj);
+
+
+static gpointer parent_class = NULL;
+
+GType
+gtk_text_mark_get_type (void)
{
- GtkTextLineSegment *seg;
+ static GType object_type = 0;
- seg = (GtkTextLineSegment*)mark;
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GtkTextMarkClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gtk_text_mark_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkTextMark),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gtk_text_mark_init,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GtkTextMark",
+ &object_info);
+ }
+
+ return object_type;
+}
- return seg->body.mark.visible;
+static void
+gtk_text_mark_init (GtkTextMark *mark)
+{
+ mark->segment = NULL;
}
-const char *
-gtk_text_mark_get_name (GtkTextMark *mark)
+static void
+gtk_text_mark_class_init (GtkTextMarkClass *klass)
{
- GtkTextLineSegment *seg;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- seg = (GtkTextLineSegment*)mark;
+ parent_class = g_type_class_peek_parent (klass);
- return seg->body.mark.name;
+ object_class->finalize = gtk_text_mark_finalize;
}
-
-GtkTextMark *
-gtk_text_mark_ref (GtkTextMark *mark)
+static void
+gtk_text_mark_finalize (GObject *obj)
{
+ GtkTextMark *mark;
GtkTextLineSegment *seg;
- seg = (GtkTextLineSegment*)mark;
+ mark = GTK_TEXT_MARK (obj);
- _mark_segment_ref (seg);
+ seg = mark->segment;
- return mark;
+ if (seg)
+ {
+ g_return_if_fail (seg->body.mark.tree == NULL);
+
+ if (seg->body.mark.tree != NULL)
+ g_warning ("GtkTextMark being finalized while still in the buffer; "
+ "someone removed a reference they didn't own! Crash "
+ "impending");
+
+ g_free (seg->body.mark.name);
+ g_free (seg);
+
+ mark->segment = NULL;
+ }
}
-void
-gtk_text_mark_unref (GtkTextMark *mark)
+gboolean
+gtk_text_mark_is_visible(GtkTextMark *mark)
{
GtkTextLineSegment *seg;
- seg = (GtkTextLineSegment*)mark;
-
- _mark_segment_unref (seg);
+ seg = mark->segment;
+
+ return seg->body.mark.visible;
+}
+
+const char *
+gtk_text_mark_get_name (GtkTextMark *mark)
+{
+ GtkTextLineSegment *seg;
+
+ seg = mark->segment;
+
+ return seg->body.mark.name;
}
gboolean
@@ -100,7 +154,10 @@ gtk_text_mark_get_deleted (GtkTextMark *mark)
g_return_val_if_fail (mark != NULL, FALSE);
- seg = (GtkTextLineSegment*)mark;
+ seg = mark->segment;
+
+ if (seg == NULL)
+ return TRUE;
return seg->body.mark.tree == NULL;
}
@@ -127,52 +184,23 @@ _mark_segment_new (GtkTextBTree *tree,
mark->type = &gtk_text_left_mark_type;
else
mark->type = &gtk_text_right_mark_type;
-
+
mark->byte_count = 0;
mark->char_count = 0;
+ mark->body.mark.obj = g_object_new (GTK_TYPE_TEXT_MARK, NULL);
+ mark->body.mark.obj->segment = mark;
+
mark->body.mark.tree = tree;
mark->body.mark.line = NULL;
mark->next = NULL;
- mark->body.mark.refcount = 1;
-
mark->body.mark.visible = FALSE;
mark->body.mark.not_deleteable = FALSE;
return mark;
}
-void
-_mark_segment_ref (GtkTextLineSegment *mark)
-{
- g_return_if_fail (mark != NULL);
- g_return_if_fail (mark->type == &gtk_text_right_mark_type ||
- mark->type == &gtk_text_left_mark_type);
- g_return_if_fail (mark->body.mark.refcount > 0);
-
- mark->body.mark.refcount += 1;
-}
-
-void
-_mark_segment_unref (GtkTextLineSegment *mark)
-{
- g_return_if_fail (mark != NULL);
- g_return_if_fail (mark->type == &gtk_text_right_mark_type ||
- mark->type == &gtk_text_left_mark_type);
- g_return_if_fail (mark->body.mark.refcount > 0);
-
- mark->body.mark.refcount -= 1;
-
- if (mark->body.mark.refcount == 0)
- {
- g_free(mark->body.mark.name);
-
- g_free(mark);
- }
-}
-
-
static int mark_segment_delete_func (GtkTextLineSegment *segPtr,
GtkTextLine *line,
int treeGone);