summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-12-05 01:43:48 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-12-05 01:43:48 +0000
commit6b1407a3eccd772a6ad25e058bd0b0a9881f9ccb (patch)
tree75861622240b902dfe2e85cc5c2419f7a1abae2f /gtk
parenta7bab735ad1ef4d8e5736f58b50c9003aa244e8f (diff)
downloadgtk+-6b1407a3eccd772a6ad25e058bd0b0a9881f9ccb.tar.gz
remove g_assert_not_reached() that was bogus, since we demand-create the
2001-12-04 Havoc Pennington <hp@redhat.com> * gtk/gtktextbtree.c (gtk_text_btree_remove_tag_info): remove g_assert_not_reached() that was bogus, since we demand-create the tag info. reported by Chris Phelps Jump through assorted hoops to fix bug from Chris Phelps where removing tags from the table resulted in btree trying to access tag->table * gtk/gtktextbuffer.c: set up mechanics of adding/removing ourselves to the tag table * gtk/gtktexttagtable.c (_gtk_text_tag_table_add_buffer) (_gtk_text_tag_table_remove_buffer): private cruft to let us notify buffer of disappearing tags * gtk/gtktexttag.h: remove BTreeNode typedef from this public header, put it in tagprivate * gtk/gtktextbtree.c (_gtk_text_btree_new): don't connect to tag_removed; it's emitted too late. (_gtk_text_btree_notify_will_remove_tag): rename tag_remove_cb to this Padding for ABI-compat expansion * gtk/gtktexttag.h (struct _GtkTextAttributes): pad this (struct _GtkTextAppearance): one pad in here too * gtk/gtktextlayout.h (struct _GtkTextLayoutClass): padding here * gtk/gtktextview.h (struct _GtkTextViewClass): more padding, since action signals etc. seem pretty likely * gtk/gtktextbuffer.h (struct _GtkTextBufferClass): padding * gtk/gtktexttag.h (struct _GtkTextTagClass): padding * gtk/gtktexttagtable.h (struct _GtkTextTagTableClass): padding
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktextbtree.c23
-rw-r--r--gtk/gtktextbtree.h4
-rw-r--r--gtk/gtktextbuffer.c28
-rw-r--r--gtk/gtktextbuffer.h10
-rw-r--r--gtk/gtktextlayout.h3
-rw-r--r--gtk/gtktexttag.h21
-rw-r--r--gtk/gtktexttagprivate.h2
-rw-r--r--gtk/gtktexttagtable.c35
-rw-r--r--gtk/gtktexttagtable.h13
-rw-r--r--gtk/gtktextview.h5
10 files changed, 116 insertions, 28 deletions
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index 44cf702c3c..87713ff40b 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -184,7 +184,7 @@ struct _GtkTextBTree {
BTreeView *views;
GSList *tag_infos;
guint tag_changed_handler;
- guint tag_removed_handler;
+
/* Incremented when a segment with a byte size > 0
* is added to or removed from the tree (i.e. the
* length of a line may have changed, and lines may
@@ -315,9 +315,6 @@ static void tag_changed_cb (GtkTextTagTable *table,
GtkTextTag *tag,
gboolean size_changed,
GtkTextBTree *tree);
-static void tag_removed_cb (GtkTextTagTable *table,
- GtkTextTag *tag,
- GtkTextBTree *tree);
static void cleanup_line (GtkTextLine *line);
static void recompute_node_counts (GtkTextBTree *tree,
GtkTextBTreeNode *node);
@@ -436,11 +433,6 @@ _gtk_text_btree_new (GtkTextTagTable *table,
G_CALLBACK (tag_changed_cb),
tree);
- tree->tag_removed_handler = g_signal_connect (G_OBJECT (tree->table),
- "tag_removed",
- G_CALLBACK (tag_removed_cb),
- tree);
-
tree->mark_table = g_hash_table_new (g_str_hash, g_str_equal);
tree->child_anchor_table = NULL;
@@ -519,9 +511,6 @@ _gtk_text_btree_unref (GtkTextBTree *tree)
g_signal_handler_disconnect (G_OBJECT (tree->table),
tree->tag_changed_handler);
- g_signal_handler_disconnect (G_OBJECT (tree->table),
- tree->tag_removed_handler);
-
g_object_unref (G_OBJECT (tree->table));
g_free (tree);
@@ -5480,10 +5469,9 @@ tag_changed_cb (GtkTextTagTable *table,
}
}
-static void
-tag_removed_cb (GtkTextTagTable *table,
- GtkTextTag *tag,
- GtkTextBTree *tree)
+void
+_gtk_text_btree_notify_will_remove_tag (GtkTextBTree *tree,
+ GtkTextTag *tag)
{
/* Remove the tag from the tree */
@@ -5852,9 +5840,6 @@ gtk_text_btree_remove_tag_info (GtkTextBTree *tree,
list = g_slist_next (list);
}
-
- g_assert_not_reached ();
- return;
}
static void
diff --git a/gtk/gtktextbtree.h b/gtk/gtktextbtree.h
index 2736fa6988..5b0b6c2b0c 100644
--- a/gtk/gtktextbtree.h
+++ b/gtk/gtktextbtree.h
@@ -292,6 +292,10 @@ void _gtk_change_node_toggle_count (GtkTextBTreeNode *node,
void _gtk_text_btree_release_mark_segment (GtkTextBTree *tree,
GtkTextLineSegment *segment);
+/* for coordination with the tag table */
+void _gtk_text_btree_notify_will_remove_tag (GtkTextBTree *tree,
+ GtkTextTag *tag);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c
index 011bedf73b..715153c9ad 100644
--- a/gtk/gtktextbuffer.c
+++ b/gtk/gtktextbuffer.c
@@ -327,6 +327,8 @@ gtk_text_buffer_new (GtkTextTagTable *table)
text_buffer->tag_table = table;
g_object_ref (G_OBJECT (text_buffer->tag_table));
+
+ _gtk_text_tag_table_add_buffer (table, text_buffer);
}
return text_buffer;
@@ -344,6 +346,7 @@ gtk_text_buffer_finalize (GObject *object)
if (buffer->tag_table)
{
+ _gtk_text_tag_table_remove_buffer (buffer->tag_table, buffer);
g_object_unref (G_OBJECT (buffer->tag_table));
buffer->tag_table = NULL;
}
@@ -366,7 +369,10 @@ static GtkTextTagTable*
get_table (GtkTextBuffer *buffer)
{
if (buffer->tag_table == NULL)
- buffer->tag_table = gtk_text_tag_table_new ();
+ {
+ buffer->tag_table = gtk_text_tag_table_new ();
+ _gtk_text_tag_table_add_buffer (buffer->tag_table, buffer);
+ }
return buffer->tag_table;
}
@@ -376,7 +382,7 @@ get_btree (GtkTextBuffer *buffer)
{
if (buffer->btree == NULL)
buffer->btree = _gtk_text_btree_new (gtk_text_buffer_get_tag_table (buffer),
- buffer);
+ buffer);
return buffer->btree;
}
@@ -3502,6 +3508,19 @@ _gtk_text_buffer_get_line_log_attrs (GtkTextBuffer *buffer,
return cache->entries[0].attrs;
}
+void
+_gtk_text_buffer_notify_will_remove_tag (GtkTextBuffer *buffer,
+ GtkTextTag *tag)
+{
+ /* This removes tag from the buffer, but DOESN'T emit the
+ * remove_tag signal, because we can't afford to have user
+ * code messing things up at this point; the tag MUST be removed
+ * entirely.
+ */
+ if (buffer->btree)
+ _gtk_text_btree_notify_will_remove_tag (buffer->btree, tag);
+}
+
/*
* Debug spew
*/
@@ -3511,8 +3530,3 @@ _gtk_text_buffer_spew (GtkTextBuffer *buffer)
{
_gtk_text_btree_spew (get_btree (buffer));
}
-
-
-
-
-
diff --git a/gtk/gtktextbuffer.h b/gtk/gtktextbuffer.h
index 24311f8885..d2cf2c7448 100644
--- a/gtk/gtktextbuffer.h
+++ b/gtk/gtktextbuffer.h
@@ -125,6 +125,13 @@ struct _GtkTextBufferClass
/* Called at the start and end of an atomic user action */
void (* begin_user_action) (GtkTextBuffer *buffer);
void (* end_user_action) (GtkTextBuffer *buffer);
+
+ GtkFunction pad1;
+ GtkFunction pad2;
+ GtkFunction pad3;
+ GtkFunction pad4;
+ GtkFunction pad5;
+ GtkFunction pad6;
};
GType gtk_text_buffer_get_type (void) G_GNUC_CONST;
@@ -361,6 +368,9 @@ const PangoLogAttr* _gtk_text_buffer_get_line_log_attrs (GtkTextBuffer *buff
const GtkTextIter *anywhere_in_line,
gint *char_len);
+void _gtk_text_buffer_notify_will_remove_tag (GtkTextBuffer *buffer,
+ GtkTextTag *tag);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gtk/gtktextlayout.h b/gtk/gtktextlayout.h
index 81881ef18d..5e52f7d32b 100644
--- a/gtk/gtktextlayout.h
+++ b/gtk/gtktextlayout.h
@@ -205,6 +205,9 @@ struct _GtkTextLayoutClass
GtkWidget *child,
gint x,
gint y);
+
+ GtkFunction pad1;
+ GtkFunction pad2;
};
struct _GtkTextAttrAppearance
diff --git a/gtk/gtktexttag.h b/gtk/gtktexttag.h
index 3020e8b6e5..544c0955dc 100644
--- a/gtk/gtktexttag.h
+++ b/gtk/gtktexttag.h
@@ -9,7 +9,6 @@ extern "C" {
#endif /* __cplusplus */
typedef struct _GtkTextIter GtkTextIter;
-typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
typedef struct _GtkTextTagTable GtkTextTagTable;
typedef struct _GtkTextAttributes GtkTextAttributes;
@@ -47,7 +46,7 @@ struct _GtkTextTag
*/
GtkTextAttributes *values;
-
+
/* Flags for whether a given value is set; if a value is unset, then
* this tag does not affect it.
*/
@@ -85,6 +84,9 @@ struct _GtkTextTagClass
GObject *event_object, /* widget, canvas item, whatever */
GdkEvent *event, /* the event itself */
const GtkTextIter *iter); /* location of event in buffer */
+
+ GtkFunction pad1;
+ GtkFunction pad2;
};
GType gtk_text_tag_get_type (void) G_GNUC_CONST;
@@ -112,6 +114,11 @@ struct _GtkTextAppearance
/* super/subscript rise, can be negative */
gint rise;
+
+ /* I'm not sure this can really be used without breaking some things
+ * an app might do :-/
+ */
+ gpointer padding1;
guint underline : 4; /* PangoUnderline */
guint strikethrough : 1;
@@ -129,6 +136,11 @@ struct _GtkTextAppearance
*/
guint inside_selection : 1;
guint is_text : 1;
+
+ guint pad1 : 1;
+ guint pad2 : 1;
+ guint pad3 : 1;
+ guint pad4 : 1;
};
struct _GtkTextAttributes
@@ -166,6 +178,11 @@ struct _GtkTextAttributes
PangoLanguage *language;
+ /* I'm not sure this can really be used without breaking some things
+ * an app might do :-/
+ */
+ gpointer padding1;
+
/* hide the text */
guint invisible : 1;
diff --git a/gtk/gtktexttagprivate.h b/gtk/gtktexttagprivate.h
index a7305f5c42..20c0ae5c54 100644
--- a/gtk/gtktexttagprivate.h
+++ b/gtk/gtktexttagprivate.h
@@ -3,6 +3,8 @@
#include <gtk/gtktexttag.h>
+typedef struct _GtkTextBTreeNode GtkTextBTreeNode;
+
/* values should already have desired defaults; this function will override
* the defaults with settings in the given tags, which should be sorted in
* ascending order of priority
diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c
index 7336e792fd..70c690092d 100644
--- a/gtk/gtktexttagtable.c
+++ b/gtk/gtktexttagtable.c
@@ -2,6 +2,7 @@
#include "gtktexttagtable.h"
#include "gtkmarshalers.h"
#include "gtksignal.h"
+#include "gtktextbuffer.h" /* just for the lame notify_will_remove_tag hack */
#include <stdlib.h>
@@ -154,6 +155,8 @@ gtk_text_tag_table_finalize (GObject *object)
g_hash_table_destroy (table->hash);
g_slist_free (table->anonymous);
+ g_slist_free (table->buffers);
+
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void
@@ -277,10 +280,24 @@ void
gtk_text_tag_table_remove (GtkTextTagTable *table,
GtkTextTag *tag)
{
+ GSList *tmp;
+
g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
g_return_if_fail (tag->table == table);
+ /* Our little bad hack to be sure buffers don't still have the tag
+ * applied to text in the buffer
+ */
+ tmp = table->buffers;
+ while (tmp != NULL)
+ {
+ _gtk_text_buffer_notify_will_remove_tag (GTK_TEXT_BUFFER (tmp->data),
+ tag);
+
+ tmp = tmp->next;
+ }
+
/* Set ourselves to the highest priority; this means
when we're removed, there won't be any gaps in the
priorities of the tags in the table. */
@@ -368,3 +385,21 @@ gtk_text_tag_table_get_size (GtkTextTagTable *table)
return g_hash_table_size (table->hash) + table->anon_count;
}
+
+void
+_gtk_text_tag_table_add_buffer (GtkTextTagTable *table,
+ gpointer buffer)
+{
+ g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
+
+ table->buffers = g_slist_prepend (table->buffers, buffer);
+}
+
+void
+_gtk_text_tag_table_remove_buffer (GtkTextTagTable *table,
+ gpointer buffer)
+{
+ g_return_if_fail (GTK_IS_TEXT_TAG_TABLE (table));
+
+ table->buffers = g_slist_remove (table->buffers, buffer);
+}
diff --git a/gtk/gtktexttagtable.h b/gtk/gtktexttagtable.h
index 32abde0363..4e0a4d9f86 100644
--- a/gtk/gtktexttagtable.h
+++ b/gtk/gtktexttagtable.h
@@ -26,6 +26,8 @@ struct _GtkTextTagTable {
GHashTable *hash;
GSList *anonymous;
gint anon_count;
+
+ GSList *buffers;
};
struct _GtkTextTagTableClass {
@@ -34,6 +36,9 @@ struct _GtkTextTagTableClass {
void (* tag_changed) (GtkTextTagTable *table, GtkTextTag *tag, gboolean size_changed);
void (* tag_added) (GtkTextTagTable *table, GtkTextTag *tag);
void (* tag_removed) (GtkTextTagTable *table, GtkTextTag *tag);
+
+ GtkFunction pad1;
+ GtkFunction pad2;
};
GType gtk_text_tag_table_get_type (void) G_GNUC_CONST;
@@ -51,6 +56,14 @@ void gtk_text_tag_table_foreach (GtkTextTagTable *table,
gint gtk_text_tag_table_get_size (GtkTextTagTable *table);
+/* INTERNAL private stuff - not even exported from the library on
+ * many platforms
+ */
+void _gtk_text_tag_table_add_buffer (GtkTextTagTable *table,
+ gpointer buffer);
+void _gtk_text_tag_table_remove_buffer (GtkTextTagTable *table,
+ gpointer buffer);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index 33b17e8adc..bc755b3fa6 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -189,6 +189,11 @@ struct _GtkTextViewClass
GtkFunction pad2;
GtkFunction pad3;
GtkFunction pad4;
+
+ GtkFunction pad5;
+ GtkFunction pad6;
+ GtkFunction pad7;
+ GtkFunction pad8;
};
GtkType gtk_text_view_get_type (void) G_GNUC_CONST;