]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktextbtree.c
Patch from Hans-Petter Jansson <hpj@ximian.com> to align the bookmarks
[~andy/gtk] / gtk / gtktextbtree.c
index 0ebe88b16fd078993b4c36a033299c16b5b5d0b4..f9c08fe1130890d3bf16524287cbb48948948b1f 100644 (file)
@@ -57,7 +57,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include "gtksignal.h"
 #include "gtktexttag.h"
 #include "gtktexttagtable.h"
 #include "gtktextlayout.h"
@@ -100,7 +99,7 @@ struct _NodeData {
 
   /* Height and width of this node */
   gint height;
-  gint width : 24;
+  signed int width : 24;
 
   /* boolean indicating whether the lines below this node are in need of validation.
    * However, width/height should always represent the current total width and
@@ -108,7 +107,7 @@ struct _NodeData {
    * width/height on the lines needs recomputing, not whether the totals
    * need recomputing.
    */
-  gint valid : 8;
+  guint valid : 8;             /* Actually a boolean */
 };
 
 
@@ -182,7 +181,7 @@ struct _GtkTextBTree {
   GtkTextBuffer *buffer;
   BTreeView *views;
   GSList *tag_infos;
-  guint tag_changed_handler;
+  gulong tag_changed_handler;
 
   /* Incremented when a segment with a byte size > 0
    * is added to or removed from the tree (i.e. the
@@ -425,9 +424,9 @@ _gtk_text_btree_new (GtkTextTagTable *table,
   tree->end_iter_segment_byte_index = 0;
   tree->end_iter_segment_char_offset = 0;
   
-  g_object_ref (G_OBJECT (tree->table));
+  g_object_ref (tree->table);
 
-  tree->tag_changed_handler = g_signal_connect (G_OBJECT (tree->table),
+  tree->tag_changed_handler = g_signal_connect (tree->table,
                                                "tag_changed",
                                                G_CALLBACK (tag_changed_cb),
                                                tree);
@@ -471,8 +470,8 @@ _gtk_text_btree_new (GtkTextTagTable *table,
 
     seg->body.mark.not_deleteable = TRUE;
 
-    g_object_ref (G_OBJECT (tree->insert_mark));
-    g_object_ref (G_OBJECT (tree->selection_bound_mark));
+    g_object_ref (tree->insert_mark);
+    g_object_ref (tree->selection_bound_mark);
   }
 
   tree->refcount = 1;
@@ -499,10 +498,10 @@ _gtk_text_btree_unref (GtkTextBTree *tree)
 
   if (tree->refcount == 0)
     {      
-      g_signal_handler_disconnect (G_OBJECT (tree->table),
+      g_signal_handler_disconnect (tree->table,
                                    tree->tag_changed_handler);
 
-      g_object_unref (G_OBJECT (tree->table));
+      g_object_unref (tree->table);
       tree->table = NULL;
       
       gtk_text_btree_node_destroy (tree, tree->root_node);
@@ -517,9 +516,9 @@ _gtk_text_btree_unref (GtkTextBTree *tree)
          tree->child_anchor_table = NULL;
        }
 
-      g_object_unref (G_OBJECT (tree->insert_mark));
+      g_object_unref (tree->insert_mark);
       tree->insert_mark = NULL;
-      g_object_unref (G_OBJECT (tree->selection_bound_mark));
+      g_object_unref (tree->selection_bound_mark);
       tree->selection_bound_mark = NULL;
 
       g_free (tree);
@@ -2212,7 +2211,7 @@ _gtk_text_btree_get_text (const GtkTextIter *start_orig,
 
   gtk_text_iter_order (&start, &end);
 
-  retval = g_string_new ("");
+  retval = g_string_new (NULL);
 
   tree = _gtk_text_iter_get_btree (&start);
 
@@ -2656,6 +2655,14 @@ _gtk_text_btree_get_selection_bounds (GtkTextBTree *tree,
 void
 _gtk_text_btree_place_cursor (GtkTextBTree      *tree,
                              const GtkTextIter *iter)
+{
+  _gtk_text_btree_select_range (tree, iter, iter);
+}
+
+void
+_gtk_text_btree_select_range (GtkTextBTree      *tree,
+                             const GtkTextIter *ins,
+                              const GtkTextIter *bound)
 {
   GtkTextIter start, end;
 
@@ -2664,11 +2671,12 @@ _gtk_text_btree_place_cursor (GtkTextBTree      *tree,
 
   /* Move insert AND selection_bound before we redisplay */
   real_set_mark (tree, tree->insert_mark,
-                 "insert", FALSE, iter, TRUE, FALSE);
+                 "insert", FALSE, ins, TRUE, FALSE);
   real_set_mark (tree, tree->selection_bound_mark,
-                 "selection_bound", FALSE, iter, TRUE, FALSE);
+                 "selection_bound", FALSE, bound, TRUE, FALSE);
 }
 
+
 void
 _gtk_text_btree_remove_mark_by_name (GtkTextBTree *tree,
                                     const gchar *name)
@@ -2698,7 +2706,7 @@ _gtk_text_btree_release_mark_segment (GtkTextBTree       *tree,
   /* Remove the ref on the mark, which frees segment as a side effect
    * if this is the last reference.
    */
-  g_object_unref (G_OBJECT (segment->body.mark.obj));
+  g_object_unref (segment->body.mark.obj);
 }
 
 void
@@ -4348,7 +4356,10 @@ _gtk_text_line_previous_could_contain_tag (GtkTextLine  *line,
           line_ancestor = line_ancestor_parent;
           line_ancestor_parent = line_ancestor->parent;
 
-          node = line_ancestor_parent->children.node;
+          if (line_ancestor_parent != NULL)
+            {
+              node = line_ancestor_parent->children.node;
+            }
         }
 
       /* No dice. */
@@ -5778,7 +5789,7 @@ gtk_text_btree_get_tag_info (GtkTextBTree *tree,
       info = g_new (GtkTextTagInfo, 1);
 
       info->tag = tag;
-      g_object_ref (G_OBJECT (tag));
+      g_object_ref (tag);
       info->tag_root = NULL;
       info->toggle_count = 0;
 
@@ -5826,7 +5837,7 @@ gtk_text_btree_remove_tag_info (GtkTextBTree *tree,
           list->next = NULL;
           g_slist_free (list);
 
-          g_object_unref (G_OBJECT (info->tag));
+          g_object_unref (info->tag);
 
           g_free (info);
           return;