diff options
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 21 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 21 | ||||
-rw-r--r-- | demos/gtk-demo/main.c | 22 | ||||
-rw-r--r-- | demos/gtk-demo/textview.c | 5 | ||||
-rw-r--r-- | gtk/gtktextbtree.c | 35 | ||||
-rw-r--r-- | gtk/gtktextbuffer.c | 261 | ||||
-rw-r--r-- | gtk/gtktextbuffer.h | 16 | ||||
-rw-r--r-- | gtk/gtktextchild.c | 8 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 119 | ||||
-rw-r--r-- | gtk/gtktextlayout.c | 135 | ||||
-rw-r--r-- | gtk/gtktextlayout.h | 16 | ||||
-rw-r--r-- | gtk/gtktexttag.c | 1340 | ||||
-rw-r--r-- | gtk/gtktexttag.h | 16 | ||||
-rw-r--r-- | gtk/gtktexttagtable.c | 161 | ||||
-rw-r--r-- | gtk/gtktexttagtable.h | 16 | ||||
-rw-r--r-- | gtk/gtktextview.c | 93 | ||||
-rw-r--r-- | gtk/testtext.c | 85 | ||||
-rw-r--r-- | gtk/testtextbuffer.c | 26 | ||||
-rw-r--r-- | tests/testtext.c | 85 | ||||
-rw-r--r-- | tests/testtextbuffer.c | 26 |
25 files changed, 1558 insertions, 1054 deletions
@@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 642a4e8592..0ea91604e2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,24 @@ +2000-12-16 Havoc Pennington <hp@pobox.com> + + * gtk/gtktextiter.c: General cleanup of the log attr iteration + stuff. This should make e.g. the delete key work again in the + text widget... + (gtk_text_iter_forward_cursor_positions): handle negative count + (gtk_text_iter_backward_cursor_positions): handle negative count + (gtk_text_iter_forward_word_ends): handle negative count + (gtk_text_iter_backward_word_starts): handle negative count + + * gtk/gtktextlayout.h, gtk/gtktextlayout.c, gtk/gtktexttag.h, + gtk/gtktexttag.c, gtk/gtktexttagtable.h, gtk/gtktexttagtable.c, + gtk/gtktextbuffer.h, gtk/gtktextbuffer.c: Convert everything to + GObject. No doubt will cause breakage. + + * demos/gtk-demo/textview.c: remove hacks around + non-GObject-ification of the text objects + + * demos/gtk-demo/main.c (main): use g_object_set() to manipulate + the text tag + 2000-12-14 Havoc Pennington <hp@pobox.com> * configure.in: only AC_DEFINE(HAVE_XFT) if we actually determined diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index f86cd122e9..f49ca363cc 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -274,9 +274,9 @@ button_press_event_cb (GtkTreeView *tree_view, cbdata->path = path; gtk_signal_connect (GTK_OBJECT (window), - "destroy", - window_closed_cb, - cbdata); + "destroy", + window_closed_cb, + cbdata); } else { @@ -426,16 +426,16 @@ main (int argc, char **argv) gtk_label_new ("Source")); tag = gtk_text_buffer_create_tag (info_buffer, "title"); - gtk_object_set (GTK_OBJECT (tag), - "font", "Sans 18", - NULL); + g_object_set (G_OBJECT (tag), + "font", "Sans 18", + NULL); tag = gtk_text_buffer_create_tag (info_buffer, "source"); - gtk_object_set (GTK_OBJECT (tag), - "font", "Courier 10", - "pixels_above_lines", 0, - "pixels_below_lines", 0, - NULL); + g_object_set (G_OBJECT (tag), + "font", "Courier 10", + "pixels_above_lines", 0, + "pixels_below_lines", 0, + NULL); gtk_window_set_default_size (GTK_WINDOW (window), 600, 400); gtk_widget_show_all (window); diff --git a/demos/gtk-demo/textview.c b/demos/gtk-demo/textview.c index a6f6b2206d..6a925fd4c0 100644 --- a/demos/gtk-demo/textview.c +++ b/demos/gtk-demo/textview.c @@ -45,11 +45,6 @@ static char gray50_bits[] = { 0x02, 0x01 }; -/* FIXME once TextTag is a GObject remove these awful hacks ;-) */ -#define g_object_set gtk_object_set -#undef G_OBJECT -#define G_OBJECT(x) ((void*)x) - static void create_tags (GtkTextBuffer *buffer) { diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index f456ff644d..5bd08b9026 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -405,18 +405,19 @@ _gtk_text_btree_new (GtkTextTagTable *table, tree->end_iter_line_stamp = tree->chars_changed_stamp - 1; tree->end_iter_line = NULL; - gtk_object_ref (GTK_OBJECT (tree->table)); - gtk_object_sink (GTK_OBJECT (tree->table)); + g_object_ref (G_OBJECT (tree->table)); - tree->tag_changed_handler = gtk_signal_connect (GTK_OBJECT (tree->table), - "tag_changed", - GTK_SIGNAL_FUNC (tag_changed_cb), - tree); + tree->tag_changed_handler = g_signal_connect_data (G_OBJECT (tree->table), + "tag_changed", + tag_changed_cb, + tree, + NULL, FALSE, FALSE); - tree->tag_removed_handler = gtk_signal_connect (GTK_OBJECT (tree->table), - "tag_removed", - GTK_SIGNAL_FUNC (tag_removed_cb), - tree); + tree->tag_removed_handler = g_signal_connect_data (G_OBJECT (tree->table), + "tag_removed", + tag_removed_cb, + tree, + NULL, FALSE, FALSE); tree->mark_table = g_hash_table_new (g_str_hash, g_str_equal); tree->child_anchor_table = NULL; @@ -505,13 +506,13 @@ _gtk_text_btree_unref (GtkTextBTree *tree) g_object_unref (G_OBJECT (tree->insert_mark)); g_object_unref (G_OBJECT (tree->selection_bound_mark)); - gtk_signal_disconnect (GTK_OBJECT (tree->table), - tree->tag_changed_handler); + g_signal_handler_disconnect (G_OBJECT (tree->table), + tree->tag_changed_handler); - gtk_signal_disconnect (GTK_OBJECT (tree->table), - tree->tag_removed_handler); + g_signal_handler_disconnect (G_OBJECT (tree->table), + tree->tag_removed_handler); - gtk_object_unref (GTK_OBJECT (tree->table)); + g_object_unref (G_OBJECT (tree->table)); g_free (tree); } @@ -5607,7 +5608,7 @@ gtk_text_btree_get_tag_info (GtkTextBTree *tree, info = g_new (GtkTextTagInfo, 1); info->tag = tag; - gtk_object_ref (GTK_OBJECT (tag)); + g_object_ref (G_OBJECT (tag)); info->tag_root = NULL; info->toggle_count = 0; @@ -5643,7 +5644,7 @@ gtk_text_btree_remove_tag_info (GtkTextBTree *tree, list->next = NULL; g_slist_free (list); - gtk_object_unref (GTK_OBJECT (info->tag)); + g_object_unref (G_OBJECT (info->tag)); g_free (info); return; diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 276d77f81a..553d51ab62 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -102,26 +102,30 @@ static void free_log_attr_cache (GtkTextLogAttrCache *cache); static GtkObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GtkType +GType gtk_text_buffer_get_type (void) { - static GtkType our_type = 0; + static GType our_type = 0; if (our_type == 0) { - static const GtkTypeInfo our_info = + static const GTypeInfo our_info = { - "GtkTextBuffer", - sizeof (GtkTextBuffer), sizeof (GtkTextBufferClass), - (GtkClassInitFunc) gtk_text_buffer_class_init, - (GtkObjectInitFunc) gtk_text_buffer_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_text_buffer_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkTextBuffer), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_text_buffer_init }; - our_type = gtk_type_unique (GTK_TYPE_OBJECT, &our_info); + our_type = g_type_register_static (G_TYPE_OBJECT, + "GtkTextBuffer", + &our_info, + 0); } return our_type; @@ -130,12 +134,11 @@ gtk_text_buffer_get_type (void) static void gtk_text_buffer_class_init (GtkTextBufferClass *klass) { - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = gtk_type_class (GTK_TYPE_OBJECT); + parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gtk_text_buffer_finalize; + object_class->finalize = gtk_text_buffer_finalize; klass->insert_text = gtk_text_buffer_real_insert_text; klass->delete_text = gtk_text_buffer_real_delete_text; @@ -144,102 +147,110 @@ gtk_text_buffer_class_init (GtkTextBufferClass *klass) klass->changed = gtk_text_buffer_real_changed; signals[INSERT_TEXT] = - gtk_signal_new ("insert_text", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, insert_text), - gtk_marshal_VOID__BOXED_STRING_INT_BOOLEAN, - GTK_TYPE_NONE, - 4, + g_signal_newc ("insert_text", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, insert_text), + NULL, + gtk_marshal_VOID__BOXED_STRING_INT_BOOLEAN, + GTK_TYPE_NONE, + 4, #if 0 - /* FIXME */ - GTK_TYPE_TEXT_ITER, - GTK_TYPE_STRING, + /* FIXME */ + GTK_TYPE_TEXT_ITER, + GTK_TYPE_STRING, #endif - GTK_TYPE_POINTER, - GTK_TYPE_POINTER, - GTK_TYPE_INT, - GTK_TYPE_BOOL); + GTK_TYPE_POINTER, + GTK_TYPE_POINTER, + GTK_TYPE_INT, + GTK_TYPE_BOOL); signals[DELETE_TEXT] = - gtk_signal_new ("delete_text", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, delete_text), - gtk_marshal_VOID__BOXED_BOXED_BOOLEAN, - GTK_TYPE_NONE, - 3, + g_signal_newc ("delete_text", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, delete_text), + NULL, + gtk_marshal_VOID__BOXED_BOXED_BOOLEAN, + GTK_TYPE_NONE, + 3, #if 0 - /* FIXME */ - GTK_TYPE_TEXT_ITER, - GTK_TYPE_TEXT_ITER, + /* FIXME */ + GTK_TYPE_TEXT_ITER, + GTK_TYPE_TEXT_ITER, #endif - GTK_TYPE_POINTER, - GTK_TYPE_POINTER, - GTK_TYPE_BOOL); + GTK_TYPE_POINTER, + GTK_TYPE_POINTER, + GTK_TYPE_BOOL); signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, changed), - gtk_marshal_VOID__VOID, - GTK_TYPE_NONE, - 0); + g_signal_newc ("changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, changed), + NULL, + gtk_marshal_VOID__VOID, + GTK_TYPE_NONE, + 0); signals[MODIFIED_CHANGED] = - gtk_signal_new ("modified_changed", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, modified_changed), - gtk_marshal_VOID__VOID, - GTK_TYPE_NONE, - 0); + g_signal_newc ("modified_changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, modified_changed), + NULL, + gtk_marshal_VOID__VOID, + GTK_TYPE_NONE, + 0); signals[MARK_SET] = - gtk_signal_new ("mark_set", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, mark_set), - gtk_marshal_VOID__BOXED_OBJECT, - GTK_TYPE_NONE, - 2, - GTK_TYPE_TEXT_ITER, - G_TYPE_OBJECT); + g_signal_newc ("mark_set", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, mark_set), + NULL, + gtk_marshal_VOID__BOXED_OBJECT, + GTK_TYPE_NONE, + 2, + GTK_TYPE_TEXT_ITER, + G_TYPE_OBJECT); signals[MARK_DELETED] = - gtk_signal_new ("mark_deleted", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, mark_deleted), - gtk_marshal_VOID__OBJECT, - GTK_TYPE_NONE, - 1, - G_TYPE_OBJECT); - + g_signal_newc ("mark_deleted", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, mark_deleted), + NULL, + gtk_marshal_VOID__OBJECT, + GTK_TYPE_NONE, + 1, + G_TYPE_OBJECT); + signals[APPLY_TAG] = - gtk_signal_new ("apply_tag", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, apply_tag), - gtk_marshal_VOID__OBJECT_BOXED_BOXED, - GTK_TYPE_NONE, - 3, - G_TYPE_OBJECT, - GTK_TYPE_TEXT_ITER, - GTK_TYPE_TEXT_ITER); + g_signal_newc ("apply_tag", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, apply_tag), + NULL, + gtk_marshal_VOID__OBJECT_BOXED_BOXED, + GTK_TYPE_NONE, + 3, + G_TYPE_OBJECT, + GTK_TYPE_TEXT_ITER, + GTK_TYPE_TEXT_ITER); signals[REMOVE_TAG] = - gtk_signal_new ("remove_tag", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextBufferClass, remove_tag), - gtk_marshal_VOID__OBJECT_BOXED_BOXED, - GTK_TYPE_NONE, - 3, - G_TYPE_OBJECT, - GTK_TYPE_TEXT_ITER, - GTK_TYPE_TEXT_ITER); + g_signal_newc ("remove_tag", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextBufferClass, remove_tag), + NULL, + gtk_marshal_VOID__OBJECT_BOXED_BOXED, + GTK_TYPE_NONE, + 3, + G_TYPE_OBJECT, + GTK_TYPE_TEXT_ITER, + GTK_TYPE_TEXT_ITER); } void @@ -261,18 +272,16 @@ gtk_text_buffer_new (GtkTextTagTable *table) { GtkTextBuffer *text_buffer; - text_buffer = GTK_TEXT_BUFFER (gtk_type_new (gtk_text_buffer_get_type ())); + text_buffer = GTK_TEXT_BUFFER (g_object_new (gtk_text_buffer_get_type (), NULL)); if (table) { text_buffer->tag_table = table; - gtk_object_ref (GTK_OBJECT (text_buffer->tag_table)); - gtk_object_sink (GTK_OBJECT (text_buffer->tag_table)); + g_object_ref (G_OBJECT (text_buffer->tag_table)); } - gtk_object_ref (GTK_OBJECT (text_buffer)); - gtk_object_sink (GTK_OBJECT (text_buffer)); + g_object_ref (G_OBJECT (text_buffer)); return text_buffer; } @@ -292,7 +301,7 @@ gtk_text_buffer_finalize (GObject *object) if (buffer->tag_table) { - gtk_object_unref (GTK_OBJECT (buffer->tag_table)); + g_object_unref (G_OBJECT (buffer->tag_table)); buffer->tag_table = NULL; } @@ -314,12 +323,7 @@ static GtkTextTagTable* get_table (GtkTextBuffer *buffer) { if (buffer->tag_table == NULL) - { - buffer->tag_table = gtk_text_tag_table_new (); - - gtk_object_ref (GTK_OBJECT (buffer->tag_table)); - gtk_object_sink (GTK_OBJECT (buffer->tag_table)); - } + buffer->tag_table = gtk_text_tag_table_new (); return buffer->tag_table; } @@ -415,7 +419,7 @@ gtk_text_buffer_real_insert_text (GtkTextBuffer *buffer, _gtk_text_btree_insert (iter, text, len); - gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]); + g_signal_emit (G_OBJECT (buffer), signals[CHANGED], 0); } static void @@ -436,8 +440,8 @@ gtk_text_buffer_emit_insert (GtkTextBuffer *buffer, if (len > 0) { - gtk_signal_emit (GTK_OBJECT (buffer), signals[INSERT_TEXT], - iter, text, len, interactive); + g_signal_emit (G_OBJECT (buffer), signals[INSERT_TEXT], 0, + iter, text, len, interactive); } } @@ -1063,7 +1067,7 @@ gtk_text_buffer_real_delete_text (GtkTextBuffer *buffer, /* may have deleted the selection... */ gtk_text_buffer_update_primary_selection (buffer); - gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]); + g_signal_emit (G_OBJECT (buffer), signals[CHANGED], 0); } static void @@ -1089,10 +1093,11 @@ gtk_text_buffer_emit_delete (GtkTextBuffer *buffer, * gtktextbtree.c. This is all sort of annoying, but really hard * to fix. */ - gtk_signal_emit (GTK_OBJECT (buffer), - signals[DELETE_TEXT], - start, end, - interactive); + g_signal_emit (G_OBJECT (buffer), + signals[DELETE_TEXT], + 0, + start, end, + interactive); } /** @@ -1346,7 +1351,7 @@ gtk_text_buffer_insert_pixbuf (GtkTextBuffer *buffer, /* FIXME pixbuf-specific signal like insert_text */ - gtk_signal_emit (GTK_OBJECT (buffer), signals[CHANGED]); + g_signal_emit (G_OBJECT (buffer), signals[CHANGED], 0); } /* @@ -1393,10 +1398,11 @@ gtk_text_buffer_mark_set (GtkTextBuffer *buffer, g_object_ref (G_OBJECT (mark)); - gtk_signal_emit (GTK_OBJECT (buffer), - signals[MARK_SET], - location, - mark); + g_signal_emit (G_OBJECT (buffer), + signals[MARK_SET], + 0, + location, + mark); g_object_unref (G_OBJECT (mark)); } @@ -1561,8 +1567,9 @@ gtk_text_buffer_delete_mark (GtkTextBuffer *buffer, * removing the mark, rather than removing the mark in a default * handler. */ - gtk_signal_emit (GTK_OBJECT (buffer), signals[MARK_DELETED], - mark); + g_signal_emit (G_OBJECT (buffer), signals[MARK_DELETED], + 0, + mark); g_object_unref (G_OBJECT (mark)); } @@ -1819,11 +1826,13 @@ gtk_text_buffer_emit_tag (GtkTextBuffer *buffer, gtk_text_iter_reorder (&start_tmp, &end_tmp); if (apply) - gtk_signal_emit (GTK_OBJECT (buffer), signals[APPLY_TAG], - tag, &start_tmp, &end_tmp); + g_signal_emit (G_OBJECT (buffer), signals[APPLY_TAG], + 0, + tag, &start_tmp, &end_tmp); else - gtk_signal_emit (GTK_OBJECT (buffer), signals[REMOVE_TAG], - tag, &start_tmp, &end_tmp); + g_signal_emit (G_OBJECT (buffer), signals[REMOVE_TAG], + 0, + tag, &start_tmp, &end_tmp); } @@ -2010,7 +2019,7 @@ gtk_text_buffer_set_modified (GtkTextBuffer *buffer, else { buffer->modified = fixed_setting; - gtk_signal_emit (GTK_OBJECT (buffer), signals[MODIFIED_CHANGED]); + g_signal_emit (G_OBJECT (buffer), signals[MODIFIED_CHANGED], 0); } } diff --git a/gtk/gtktextbuffer.h b/gtk/gtktextbuffer.h index b54c352d1d..b68b98ea8f 100644 --- a/gtk/gtktextbuffer.h +++ b/gtk/gtktextbuffer.h @@ -47,17 +47,17 @@ typedef struct _GtkTextBTree GtkTextBTree; typedef struct _GtkTextLogAttrCache GtkTextLogAttrCache; #define GTK_TYPE_TEXT_BUFFER (gtk_text_buffer_get_type ()) -#define GTK_TEXT_BUFFER(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBuffer)) -#define GTK_TEXT_BUFFER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass)) -#define GTK_IS_TEXT_BUFFER(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_BUFFER)) -#define GTK_IS_TEXT_BUFFER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_BUFFER)) -#define GTK_TEXT_BUFFER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass)) +#define GTK_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBuffer)) +#define GTK_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass)) +#define GTK_IS_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_BUFFER)) +#define GTK_IS_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_BUFFER)) +#define GTK_TEXT_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_BUFFER, GtkTextBufferClass)) typedef struct _GtkTextBufferClass GtkTextBufferClass; struct _GtkTextBuffer { - GtkObject parent_instance; + GObject parent_instance; GtkTextTagTable *tag_table; GtkTextBTree *btree; @@ -72,7 +72,7 @@ struct _GtkTextBuffer struct _GtkTextBufferClass { - GtkObjectClass parent_class; + GObjectClass parent_class; void (* insert_text) (GtkTextBuffer *buffer, GtkTextIter *pos, @@ -115,7 +115,7 @@ struct _GtkTextBufferClass }; -GtkType gtk_text_buffer_get_type (void) G_GNUC_CONST; +GType gtk_text_buffer_get_type (void) G_GNUC_CONST; diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c index c6075bb60d..ee0537e4a2 100644 --- a/gtk/gtktextchild.c +++ b/gtk/gtktextchild.c @@ -269,16 +269,16 @@ _gtk_widget_segment_unref (GtkTextLineSegment *widget_segment) GtkTextLayout* _gtk_anchored_child_get_layout (GtkWidget *child) { - return gtk_object_get_data (GTK_OBJECT (child), "gtk-text-child-anchor-layout"); + return g_object_get_data (G_OBJECT (child), "gtk-text-child-anchor-layout"); } static void _gtk_anchored_child_set_layout (GtkWidget *child, GtkTextLayout *layout) { - gtk_object_set_data (GTK_OBJECT (child), - "gtk-text-child-anchor-layout", - layout); + g_object_set_data (G_OBJECT (child), + "gtk-text-child-anchor-layout", + layout); } static void gtk_text_child_anchor_init (GtkTextChildAnchor *child_anchor); diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index 226604d821..02bf944361 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -2390,6 +2390,11 @@ typedef gboolean (* FindLogAttrFunc) (const PangoLogAttr *attrs, gint len, gint *found_offset); +typedef gboolean (* TestLogAttrFunc) (const PangoLogAttr *attrs, + gint offset, + gint min_offset, + gint len); + static gboolean find_word_end_func (const PangoLogAttr *attrs, gint offset, @@ -2413,8 +2418,7 @@ static gboolean is_word_end_func (const PangoLogAttr *attrs, gint offset, gint min_offset, - gint len, - gint *found_offset) + gint len) { return attrs[offset].is_word_end; } @@ -2442,8 +2446,7 @@ static gboolean is_word_start_func (const PangoLogAttr *attrs, gint offset, gint min_offset, - gint len, - gint *found_offset) + gint len) { return attrs[offset].is_word_start; } @@ -2452,8 +2455,7 @@ static gboolean inside_word_func (const PangoLogAttr *attrs, gint offset, gint min_offset, - gint len, - gint *found_offset) + gint len) { /* Find next word start or end */ while (offset >= min_offset && @@ -2465,8 +2467,33 @@ inside_word_func (const PangoLogAttr *attrs, static gboolean test_log_attrs (const GtkTextIter *iter, - FindLogAttrFunc func, - gint *found_offset) + TestLogAttrFunc func) +{ + gchar *paragraph; + gint char_len; + const PangoLogAttr *attrs; + int offset; + gboolean result = FALSE; + + g_return_val_if_fail (iter != NULL, FALSE); + + attrs = _gtk_text_buffer_get_line_log_attrs (gtk_text_iter_get_buffer (iter), + iter, &char_len); + + offset = gtk_text_iter_get_line_offset (iter); + + g_assert (char_len > 0); + + if (offset < char_len) + result = (* func) (attrs, offset, 0, char_len); + + return result; +} + +static gboolean +find_line_log_attrs (const GtkTextIter *iter, + FindLogAttrFunc func, + gint *found_offset) { gchar *paragraph; gint char_len; @@ -2503,7 +2530,7 @@ find_by_log_attrs (GtkTextIter *iter, orig = *iter; - found = test_log_attrs (iter, func, &offset); + found = find_line_log_attrs (iter, func, &offset); if (!found) { @@ -2552,7 +2579,12 @@ gtk_text_iter_forward_word_ends (GtkTextIter *iter, gint count) { g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (count > 0, FALSE); + + if (count == 0) + return FALSE; + + if (count < 0) + return gtk_text_iter_backward_word_starts (iter, -count); if (!gtk_text_iter_forward_word_end (iter)) return FALSE; @@ -2572,7 +2604,9 @@ gtk_text_iter_backward_word_starts (GtkTextIter *iter, gint count) { g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (count > 0, FALSE); + + if (count < 0) + return gtk_text_iter_forward_word_ends (iter, -count); if (!gtk_text_iter_backward_word_start (iter)) return FALSE; @@ -2591,46 +2625,62 @@ gtk_text_iter_backward_word_starts (GtkTextIter *iter, gboolean gtk_text_iter_starts_word (const GtkTextIter *iter) { - return test_log_attrs (iter, is_word_start_func, NULL); + return test_log_attrs (iter, is_word_start_func); } gboolean gtk_text_iter_ends_word (const GtkTextIter *iter) { - return test_log_attrs (iter, is_word_end_func, NULL); + return test_log_attrs (iter, is_word_end_func); } gboolean gtk_text_iter_inside_word (const GtkTextIter *iter) { - return test_log_attrs (iter, inside_word_func, NULL); + return test_log_attrs (iter, inside_word_func); } static gboolean -find_cursor_pos_func (const PangoLogAttr *attrs, - gint offset, - gint min_offset, - gint len, - gint *found_offset) +find_forward_cursor_pos_func (const PangoLogAttr *attrs, + gint offset, + gint min_offset, + gint len, + gint *found_offset) { ++offset; /* We always go to the NEXT position */ - /* Find end of next word */ - while (offset < min_offset + len && + while (offset < (min_offset + len) && !attrs[offset].is_cursor_position) ++offset; *found_offset = offset; - return offset < min_offset + len; + return offset < (min_offset + len); +} + +static gboolean +find_backward_cursor_pos_func (const PangoLogAttr *attrs, + gint offset, + gint min_offset, + gint len, + gint *found_offset) +{ + --offset; /* We always go to the NEXT position */ + + while (offset > min_offset && + !attrs[offset].is_cursor_position) + --offset; + + *found_offset = offset; + + return offset >= min_offset; } static gboolean is_cursor_pos_func (const PangoLogAttr *attrs, gint offset, gint min_offset, - gint len, - gint *found_offset) + gint len) { return attrs[offset].is_cursor_position; } @@ -2638,14 +2688,13 @@ is_cursor_pos_func (const PangoLogAttr *attrs, gboolean gtk_text_iter_forward_cursor_position (GtkTextIter *iter) { - return find_by_log_attrs (iter, find_cursor_pos_func, TRUE); - + return find_by_log_attrs (iter, find_forward_cursor_pos_func, TRUE); } gboolean gtk_text_iter_backward_cursor_position (GtkTextIter *iter) { - return find_by_log_attrs (iter, find_cursor_pos_func, FALSE); + return find_by_log_attrs (iter, find_backward_cursor_pos_func, FALSE); } gboolean @@ -2653,8 +2702,13 @@ gtk_text_iter_forward_cursor_positions (GtkTextIter *iter, gint count) { g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (count > 0, FALSE); + if (count == 0) + return FALSE; + + if (count < 0) + return gtk_text_iter_backward_cursor_positions (iter, -count); + if (!gtk_text_iter_forward_cursor_position (iter)) return FALSE; --count; @@ -2673,8 +2727,13 @@ gtk_text_iter_backward_cursor_positions (GtkTextIter *iter, gint count) { g_return_val_if_fail (iter != NULL, FALSE); - g_return_val_if_fail (count > 0, FALSE); + if (count == 0) + return FALSE; + + if (count < 0) + return gtk_text_iter_forward_cursor_positions (iter, -count); + if (!gtk_text_iter_backward_cursor_position (iter)) return FALSE; --count; @@ -2691,7 +2750,7 @@ gtk_text_iter_backward_cursor_positions (GtkTextIter *iter, gboolean gtk_text_iter_is_cursor_position (const GtkTextIter *iter) { - return test_log_attrs (iter, is_cursor_pos_func, NULL); + return test_log_attrs (iter, is_cursor_pos_func); } void diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index e27732be7d..2ee16058cf 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -119,10 +119,9 @@ enum { LAST_ARG }; -static void gtk_text_layout_init (GtkTextLayout *text_layout); +static void gtk_text_layout_init (GtkTextLayout *text_layout); static void gtk_text_layout_class_init (GtkTextLayoutClass *klass); -static void gtk_text_layout_destroy (GtkObject *object); -static void gtk_text_layout_finalize (GObject *object); +static void gtk_text_layout_finalize (GObject *object); static GtkObjectClass *parent_class = NULL; @@ -130,26 +129,30 @@ static guint signals[LAST_SIGNAL] = { 0 }; PangoAttrType gtk_text_attr_appearance_type = 0; -GtkType +GType gtk_text_layout_get_type (void) { - static GtkType our_type = 0; + static GType our_type = 0; if (our_type == 0) { - static const GtkTypeInfo our_info = + static const GTypeInfo our_info = { - "GtkTextLayout", - sizeof (GtkTextLayout), sizeof (GtkTextLayoutClass), - (GtkClassInitFunc) gtk_text_layout_class_init, - (GtkObjectInitFunc) gtk_text_layout_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_text_layout_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkTextLayout), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_text_layout_init }; - our_type = gtk_type_unique (GTK_TYPE_OBJECT, &our_info); + our_type = g_type_register_static (G_TYPE_OBJECT, + "GtkTextLayout", + &our_info, + 0); } return our_type; @@ -158,50 +161,51 @@ gtk_text_layout_get_type (void) static void gtk_text_layout_class_init (GtkTextLayoutClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->destroy = gtk_text_layout_destroy; - gobject_class->finalize = gtk_text_layout_finalize; + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gtk_text_layout_finalize; klass->wrap = gtk_text_layout_real_wrap; klass->invalidate = gtk_text_layout_real_invalidate; klass->free_line_data = gtk_text_layout_real_free_line_data; signals[INVALIDATED] = - gtk_signal_new ("invalidated", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextLayoutClass, invalidated), - gtk_marshal_VOID__VOID, - GTK_TYPE_NONE, - 0); + g_signal_newc ("invalidated", + G_TYPE_FROM_CLASS (object_class), + GTK_RUN_LAST, + G_STRUCT_OFFSET (GtkTextLayoutClass, invalidated), + NULL, + gtk_marshal_VOID__VOID, + GTK_TYPE_NONE, + 0); signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextLayoutClass, changed), - gtk_marshal_VOID__INT_INT_INT, - GTK_TYPE_NONE, - 3, - GTK_TYPE_INT, - GTK_TYPE_INT, - GTK_TYPE_INT); + g_signal_newc ("changed", + G_TYPE_FROM_CLASS (object_class), + GTK_RUN_LAST, + G_STRUCT_OFFSET (GtkTextLayoutClass, changed), + NULL, + gtk_marshal_VOID__INT_INT_INT, + GTK_TYPE_NONE, + 3, + GTK_TYPE_INT, + GTK_TYPE_INT, + GTK_TYPE_INT); signals[ALLOCATE_CHILD] = - gtk_signal_new ("allocate_child", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextLayoutClass, allocate_child), - gtk_marshal_VOID__OBJECT_INT_INT, - GTK_TYPE_NONE, - 3, - GTK_TYPE_OBJECT, - GTK_TYPE_INT, - GTK_TYPE_INT); + g_signal_newc ("allocate_child", + G_TYPE_FROM_CLASS (object_class), + GTK_RUN_LAST, + G_STRUCT_OFFSET (GtkTextLayoutClass, allocate_child), + NULL, + gtk_marshal_VOID__OBJECT_INT_INT, + GTK_TYPE_NONE, + 3, + GTK_TYPE_OBJECT, + GTK_TYPE_INT, + GTK_TYPE_INT); } void @@ -213,7 +217,7 @@ gtk_text_layout_init (GtkTextLayout *text_layout) GtkTextLayout* gtk_text_layout_new (void) { - return GTK_TEXT_LAYOUT (gtk_type_new (gtk_text_layout_get_type ())); + return GTK_TEXT_LAYOUT (g_object_new (gtk_text_layout_get_type (), NULL)); } static void @@ -227,7 +231,7 @@ free_style_cache (GtkTextLayout *text_layout) } static void -gtk_text_layout_destroy (GtkObject *object) +gtk_text_layout_finalize (GObject *object) { GtkTextLayout *layout; @@ -249,17 +253,7 @@ gtk_text_layout_destroy (GtkObject *object) g_object_unref (G_OBJECT (layout->rtl_context)); layout->rtl_context = NULL; } - - (* parent_class->destroy) (object); -} - -static void -gtk_text_layout_finalize (GObject *object) -{ - GtkTextLayout *text_layout; - - text_layout = GTK_TEXT_LAYOUT (object); - + (* G_OBJECT_CLASS (parent_class)->finalize) (object); } @@ -280,7 +274,7 @@ gtk_text_layout_set_buffer (GtkTextLayout *layout, _gtk_text_btree_remove_view (_gtk_text_buffer_get_btree (layout->buffer), layout); - gtk_object_unref (GTK_OBJECT (layout->buffer)); + g_object_unref (G_OBJECT (layout->buffer)); layout->buffer = NULL; } @@ -288,8 +282,7 @@ gtk_text_layout_set_buffer (GtkTextLayout *layout, { layout->buffer = buffer; - gtk_object_sink (GTK_OBJECT (buffer)); - gtk_object_ref (GTK_OBJECT (buffer)); + g_object_ref (G_OBJECT (buffer)); _gtk_text_btree_add_view (_gtk_text_buffer_get_btree (buffer), layout); } @@ -490,7 +483,7 @@ gtk_text_layout_get_size (GtkTextLayout *layout, static void gtk_text_layout_invalidated (GtkTextLayout *layout) { - gtk_signal_emit (GTK_OBJECT (layout), signals[INVALIDATED]); + g_signal_emit (G_OBJECT (layout), signals[INVALIDATED], 0); } void @@ -499,7 +492,8 @@ gtk_text_layout_changed (GtkTextLayout *layout, gint old_height, gint new_height) { - gtk_signal_emit (GTK_OBJECT (layout), signals[CHANGED], y, old_height, new_height); + g_signal_emit (G_OBJECT (layout), signals[CHANGED], 0, + y, old_height, new_height); } void @@ -1481,11 +1475,12 @@ allocate_child_widgets (GtkTextLayout *text_layout, g_print ("extents at %d,%d\n", extents.x, extents.y); - gtk_signal_emit (GTK_OBJECT (text_layout), - signals[ALLOCATE_CHILD], - shaped_object, - PANGO_PIXELS (extents.x) + display->x_offset, - PANGO_PIXELS (extents.y) + display->top_margin); + g_signal_emit (G_OBJECT (text_layout), + signals[ALLOCATE_CHILD], + 0, + shaped_object, + PANGO_PIXELS (extents.x) + display->x_offset, + PANGO_PIXELS (extents.y) + display->top_margin); } } } diff --git a/gtk/gtktextlayout.h b/gtk/gtktextlayout.h index 8977a97eb7..e6cde73f85 100644 --- a/gtk/gtktextlayout.h +++ b/gtk/gtktextlayout.h @@ -100,11 +100,11 @@ typedef struct _GtkTextLine GtkTextLine; typedef struct _GtkTextLineData GtkTextLineData; #define GTK_TYPE_TEXT_LAYOUT (gtk_text_layout_get_type ()) -#define GTK_TEXT_LAYOUT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayout)) -#define GTK_TEXT_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass)) -#define GTK_IS_TEXT_LAYOUT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_LAYOUT)) -#define GTK_IS_TEXT_LAYOUT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_LAYOUT)) -#define GTK_TEXT_LAYOUT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass)) +#define GTK_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayout)) +#define GTK_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass)) +#define GTK_IS_TEXT_LAYOUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_LAYOUT)) +#define GTK_IS_TEXT_LAYOUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_LAYOUT)) +#define GTK_TEXT_LAYOUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_LAYOUT, GtkTextLayoutClass)) typedef struct _GtkTextLayout GtkTextLayout; typedef struct _GtkTextLayoutClass GtkTextLayoutClass; @@ -114,7 +114,7 @@ typedef struct _GtkTextAttrAppearance GtkTextAttrAppearance; struct _GtkTextLayout { - GtkObject parent_instance; + GObject parent_instance; /* width of the display area on-screen, * i.e. pixels we should wrap to fit inside. */ @@ -167,7 +167,7 @@ struct _GtkTextLayout struct _GtkTextLayoutClass { - GtkObjectClass parent_class; + GObjectClass parent_class; /* Some portion of the layout was invalidated */ @@ -239,7 +239,7 @@ struct _GtkTextLineDisplay extern PangoAttrType gtk_text_attr_appearance_type; -GtkType gtk_text_layout_get_type (void) G_GNUC_CONST; +GType gtk_text_layout_get_type (void) G_GNUC_CONST; GtkTextLayout* gtk_text_layout_new (void); void gtk_text_layout_set_buffer (GtkTextLayout *layout, GtkTextBuffer *buffer); diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c index 25f48f42cb..e75e41612b 100644 --- a/gtk/gtktexttag.c +++ b/gtk/gtktexttag.c @@ -53,6 +53,8 @@ #include "gtktexttagtable.h" #include "gtksignal.h" #include "gtkmain.h" +#include "gtkintl.h" +#include "gtktypebuiltins.h" #include <stdlib.h> #include <string.h> @@ -63,111 +65,117 @@ enum { }; enum { - ARG_0, + PROP_0, /* Construct args */ - ARG_NAME, + PROP_NAME, /* Style args */ - ARG_BACKGROUND, - ARG_FOREGROUND, - ARG_BACKGROUND_GDK, - ARG_FOREGROUND_GDK, - ARG_BACKGROUND_STIPPLE, - ARG_FOREGROUND_STIPPLE, - ARG_FONT, - ARG_FONT_DESC, - ARG_FAMILY, - ARG_STYLE, - ARG_VARIANT, - ARG_WEIGHT, - ARG_STRETCH, - ARG_SIZE, - ARG_SIZE_POINTS, - ARG_PIXELS_ABOVE_LINES, - ARG_PIXELS_BELOW_LINES, - ARG_PIXELS_INSIDE_WRAP, - ARG_EDITABLE, - ARG_WRAP_MODE, - ARG_JUSTIFY, - ARG_DIRECTION, - ARG_LEFT_MARGIN, - ARG_INDENT, - ARG_STRIKETHROUGH, - ARG_RIGHT_MARGIN, - ARG_UNDERLINE, - ARG_RISE, - ARG_BG_FULL_HEIGHT, - ARG_LANGUAGE, - ARG_TABS, - ARG_INVISIBLE, + PROP_BACKGROUND, + PROP_FOREGROUND, + PROP_BACKGROUND_GDK, + PROP_FOREGROUND_GDK, + PROP_BACKGROUND_STIPPLE, + PROP_FOREGROUND_STIPPLE, + PROP_FONT, + PROP_FONT_DESC, + PROP_FAMILY, + PROP_STYLE, + PROP_VARIANT, + PROP_WEIGHT, + PROP_STRETCH, + PROP_SIZE, + PROP_SIZE_POINTS, + PROP_PIXELS_ABOVE_LINES, + PROP_PIXELS_BELOW_LINES, + PROP_PIXELS_INSIDE_WRAP, + PROP_EDITABLE, + PROP_WRAP_MODE, + PROP_JUSTIFY, + PROP_DIRECTION, + PROP_LEFT_MARGIN, + PROP_INDENT, + PROP_STRIKETHROUGH, + PROP_RIGHT_MARGIN, + PROP_UNDERLINE, + PROP_RISE, + PROP_BG_FULL_HEIGHT, + PROP_LANGUAGE, + PROP_TABS, + PROP_INVISIBLE, /* Whether-a-style-arg-is-set args */ - ARG_BACKGROUND_SET, - ARG_FOREGROUND_SET, - ARG_BACKGROUND_GDK_SET, - ARG_FOREGROUND_GDK_SET, - ARG_BACKGROUND_STIPPLE_SET, - ARG_FOREGROUND_STIPPLE_SET, - ARG_FAMILY_SET, - ARG_STYLE_SET, - ARG_VARIANT_SET, - ARG_WEIGHT_SET, - ARG_STRETCH_SET, - ARG_SIZE_SET, - ARG_PIXELS_ABOVE_LINES_SET, - ARG_PIXELS_BELOW_LINES_SET, - ARG_PIXELS_INSIDE_WRAP_SET, - ARG_EDITABLE_SET, - ARG_WRAP_MODE_SET, - ARG_JUSTIFY_SET, - ARG_LEFT_MARGIN_SET, - ARG_INDENT_SET, - ARG_STRIKETHROUGH_SET, - ARG_RIGHT_MARGIN_SET, - ARG_UNDERLINE_SET, - ARG_RISE_SET, - ARG_BG_FULL_HEIGHT_SET, - ARG_LANGUAGE_SET, - ARG_TABS_SET, - ARG_INVISIBLE_SET, + PROP_BACKGROUND_SET, + PROP_FOREGROUND_SET, + PROP_BACKGROUND_GDK_SET, + PROP_FOREGROUND_GDK_SET, + PROP_BACKGROUND_STIPPLE_SET, + PROP_FOREGROUND_STIPPLE_SET, + PROP_FAMILY_SET, + PROP_STYLE_SET, + PROP_VARIANT_SET, + PROP_WEIGHT_SET, + PROP_STRETCH_SET, + PROP_SIZE_SET, + PROP_PIXELS_ABOVE_LINES_SET, + PROP_PIXELS_BELOW_LINES_SET, + PROP_PIXELS_INSIDE_WRAP_SET, + PROP_EDITABLE_SET, + PROP_WRAP_MODE_SET, + PROP_JUSTIFY_SET, + PROP_LEFT_MARGIN_SET, + PROP_INDENT_SET, + PROP_STRIKETHROUGH_SET, + PROP_RIGHT_MARGIN_SET, + PROP_UNDERLINE_SET, + PROP_RISE_SET, + PROP_BG_FULL_HEIGHT_SET, + PROP_LANGUAGE_SET, + PROP_TABS_SET, + PROP_INVISIBLE_SET, LAST_ARG }; - -static void gtk_text_tag_init (GtkTextTag *text_tag); -static void gtk_text_tag_class_init (GtkTextTagClass *klass); -static void gtk_text_tag_destroy (GtkObject *object); -static void gtk_text_tag_finalize (GObject *object); -static void gtk_text_tag_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_text_tag_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); - -static GtkObjectClass *parent_class = NULL; +static void gtk_text_tag_init (GtkTextTag *text_tag); +static void gtk_text_tag_class_init (GtkTextTagClass *klass); +static void gtk_text_tag_finalize (GObject *object); +static void gtk_text_tag_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer); +static void gtk_text_tag_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer); + +static GObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GtkType +GType gtk_text_tag_get_type (void) { - static GtkType our_type = 0; + static GType our_type = 0; if (our_type == 0) { - static const GtkTypeInfo our_info = + static const GTypeInfo our_info = { - "GtkTextTag", - sizeof (GtkTextTag), sizeof (GtkTextTagClass), - (GtkClassInitFunc) gtk_text_tag_class_init, - (GtkObjectInitFunc) gtk_text_tag_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_text_tag_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkTextTag), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_text_tag_init }; - our_type = gtk_type_unique (GTK_TYPE_OBJECT, &our_info); + our_type = g_type_register_static (G_TYPE_OBJECT, + "GtkTextTag", + &our_info, + 0); } return our_type; @@ -176,164 +184,445 @@ gtk_text_tag_get_type (void) static void gtk_text_tag_class_init (GtkTextTagClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - parent_class = gtk_type_class (GTK_TYPE_OBJECT); + parent_class = g_type_class_peek_parent (klass); - object_class->set_arg = gtk_text_tag_set_arg; - object_class->get_arg = gtk_text_tag_get_arg; - - object_class->destroy = gtk_text_tag_destroy; - gobject_class->finalize = gtk_text_tag_finalize; + object_class->set_property = gtk_text_tag_set_property; + object_class->get_property = gtk_text_tag_get_property; + + object_class->finalize = gtk_text_tag_finalize; /* Construct */ - gtk_object_add_arg_type ("GtkTextTag::name", GTK_TYPE_STRING, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT_ONLY, - ARG_NAME); + g_object_class_install_property (object_class, + PROP_NAME, + g_param_spec_string ("name", + _("Tag name"), + _("Name used to refer to the text tag"), + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); /* Style args */ - gtk_object_add_arg_type ("GtkTextTag::background", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_BACKGROUND); - /* FIXME GTK_TYPE_GDK_COLOR */ - gtk_object_add_arg_type ("GtkTextTag::background_gdk", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_BACKGROUND_GDK); - gtk_object_add_arg_type ("GtkTextTag::background_full_height", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_BG_FULL_HEIGHT); - gtk_object_add_arg_type ("GtkTextTag::background_stipple", - GDK_TYPE_PIXMAP, - GTK_ARG_READWRITE, ARG_BACKGROUND_STIPPLE); - gtk_object_add_arg_type ("GtkTextTag::direction", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_DIRECTION); - gtk_object_add_arg_type ("GtkTextTag::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - gtk_object_add_arg_type ("GtkTextTag::font", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FONT); - /* FIXME GTK_TYPE_PANGO_FONT_DESCRIPTION */ - gtk_object_add_arg_type ("GtkTextTag::font_desc", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_FONT_DESC); - gtk_object_add_arg_type ("GtkTextTag::family", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FAMILY); - gtk_object_add_arg_type ("GtkTextTag::style", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_STYLE); - gtk_object_add_arg_type ("GtkTextTag::variant", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_VARIANT); - gtk_object_add_arg_type ("GtkTextTag::weight", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_WEIGHT); - gtk_object_add_arg_type ("GtkTextTag::stretch", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_STRETCH); - gtk_object_add_arg_type ("GtkTextTag::size", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_SIZE); - gtk_object_add_arg_type ("GtkTextTag::size_points", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_SIZE_POINTS); - gtk_object_add_arg_type ("GtkTextTag::foreground", GTK_TYPE_STRING, - GTK_ARG_WRITABLE, ARG_FOREGROUND); - /* FIXME GTK_TYPE_GDK_COLOR */ - gtk_object_add_arg_type ("GtkTextTag::foreground_gdk", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_FOREGROUND_GDK); - gtk_object_add_arg_type ("GtkTextTag::foreground_stipple", - GDK_TYPE_PIXMAP, - GTK_ARG_READWRITE, ARG_FOREGROUND_STIPPLE); - gtk_object_add_arg_type ("GtkTextTag::justify", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_JUSTIFY); - gtk_object_add_arg_type ("GtkTextTag::language", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_LANGUAGE); - gtk_object_add_arg_type ("GtkTextTag::left_margin", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_LEFT_MARGIN); - gtk_object_add_arg_type ("GtkTextTag::indent", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_INDENT); - gtk_object_add_arg_type ("GtkTextTag::rise", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_RISE); - gtk_object_add_arg_type ("GtkTextTag::pixels_above_lines", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_PIXELS_ABOVE_LINES); - gtk_object_add_arg_type ("GtkTextTag::pixels_below_lines", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_PIXELS_BELOW_LINES); - gtk_object_add_arg_type ("GtkTextTag::pixels_inside_wrap", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_PIXELS_INSIDE_WRAP); - gtk_object_add_arg_type ("GtkTextTag::right_margin", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_RIGHT_MARGIN); - gtk_object_add_arg_type ("GtkTextTag::strikethrough", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_STRIKETHROUGH); - gtk_object_add_arg_type ("GtkTextTag::underline", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_UNDERLINE); - gtk_object_add_arg_type ("GtkTextTag::wrap_mode", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_WRAP_MODE); - /* FIXME GTK_TYPE_PANGO_TAB_ARRAY */ - gtk_object_add_arg_type ("GtkTextTag::tabs", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_TABS); - gtk_object_add_arg_type ("GtkTextTag::invisible", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_INVISIBLE); + + g_object_class_install_property (object_class, + PROP_BACKGROUND, + g_param_spec_string ("background", + _("Background color name"), + _("Background color as a string"), + NULL, + G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_BACKGROUND_GDK, + g_param_spec_boxed ("background_gdk", + _("Background color"), + _("Background color as a GdkColor"), + GTK_TYPE_GDK_COLOR, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_BG_FULL_HEIGHT, + g_param_spec_boolean ("background_full_height", + _("Background full height"), + _("Whether the background color fills the entire line height or only the height of the tagged characters"), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + - /* Style args are set or not */ - gtk_object_add_arg_type ("GtkTextTag::background_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_BACKGROUND_SET); - gtk_object_add_arg_type ("GtkTextTag::background_full_height_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_BG_FULL_HEIGHT_SET); - gtk_object_add_arg_type ("GtkTextTag::background_gdk_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_BACKGROUND_GDK_SET); - gtk_object_add_arg_type ("GtkTextTag::background_stipple_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_BACKGROUND_STIPPLE_SET); - gtk_object_add_arg_type ("GtkTextTag::editable_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE_SET); - gtk_object_add_arg_type ("GtkTextTag::family_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_FAMILY_SET); - gtk_object_add_arg_type ("GtkTextTag::style_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_STYLE_SET); - gtk_object_add_arg_type ("GtkTextTag::variant_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_VARIANT_SET); - gtk_object_add_arg_type ("GtkTextTag::weight_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_WEIGHT_SET); - gtk_object_add_arg_type ("GtkTextTag::stretch_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_STRETCH_SET); - gtk_object_add_arg_type ("GtkTextTag::size_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_SIZE_SET); - gtk_object_add_arg_type ("GtkTextTag::foreground_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_FOREGROUND_SET); - gtk_object_add_arg_type ("GtkTextTag::foreground_gdk_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_FOREGROUND_GDK_SET); - gtk_object_add_arg_type ("GtkTextTag::foreground_stipple_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_FOREGROUND_STIPPLE_SET); - gtk_object_add_arg_type ("GtkTextTag::justify_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_JUSTIFY_SET); - gtk_object_add_arg_type ("GtkTextTag::language_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_LANGUAGE_SET); - gtk_object_add_arg_type ("GtkTextTag::left_margin_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_LEFT_MARGIN_SET); - gtk_object_add_arg_type ("GtkTextTag::indent_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_INDENT_SET); - gtk_object_add_arg_type ("GtkTextTag::rise_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_RISE_SET); - gtk_object_add_arg_type ("GtkTextTag::pixels_above_lines_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_PIXELS_ABOVE_LINES_SET); - gtk_object_add_arg_type ("GtkTextTag::pixels_below_lines_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_PIXELS_BELOW_LINES_SET); - gtk_object_add_arg_type ("GtkTextTag::pixels_inside_wrap_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_PIXELS_INSIDE_WRAP_SET); - gtk_object_add_arg_type ("GtkTextTag::strikethrough_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_STRIKETHROUGH_SET); - gtk_object_add_arg_type ("GtkTextTag::right_margin_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_RIGHT_MARGIN_SET); - gtk_object_add_arg_type ("GtkTextTag::underline_set", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_UNDERLINE_SET); - gtk_object_add_arg_type ("GtkTextTag::wrap_mode_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_WRAP_MODE_SET); - gtk_object_add_arg_type ("GtkTextTag::tabs_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_TABS_SET); - gtk_object_add_arg_type ("GtkTextTag::invisible_set", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_INVISIBLE_SET); + g_object_class_install_property (object_class, + PROP_BACKGROUND_STIPPLE, + g_param_spec_object ("background_stipple", + _("Background stipple mask"), + _("Bitmap to use as a mask when drawing the text background"), + GDK_TYPE_PIXMAP, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_FOREGROUND, + g_param_spec_string ("foreground", + _("Foreground color name"), + _("Foreground color as a string"), + NULL, + G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_FOREGROUND_GDK, + g_param_spec_boxed ("foreground_gdk", + _("Foreground color"), + _("Foreground color as a GdkColor"), + GTK_TYPE_GDK_COLOR, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_FOREGROUND_STIPPLE, + g_param_spec_object ("foreground_stipple", + _("Foreground stipple mask"), + _("Bitmap to use as a mask when drawing the text foreground"), + GDK_TYPE_PIXMAP, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_DIRECTION, + g_param_spec_enum ("direction", + _("Text direction"), + _("Text direction, e.g. right-to-left or left-to-right"), + GTK_TYPE_TEXT_DIRECTION, + GTK_TEXT_DIR_LTR, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_EDITABLE, + g_param_spec_boolean ("editable", + _("Editable"), + _("Whether the text can be modified by the user"), + TRUE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_FONT, + g_param_spec_string ("font", + _("Font"), + _("Font description as a string"), + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_FONT_DESC, + g_param_spec_boxed ("font_desc", + _("Font"), + _("Font description as a PangoFontDescription struct"), + GTK_TYPE_PANGO_FONT_DESCRIPTION, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_FAMILY, + g_param_spec_string ("family", + _("Font family"), + _("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"), + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_STYLE, + g_param_spec_enum ("style", + _("Font style"), + _("Font style"), + PANGO_TYPE_STYLE, + PANGO_STYLE_NORMAL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_VARIANT, + g_param_spec_enum ("variant", + _("Font variant"), + _("Font variant"), + PANGO_TYPE_VARIANT, + PANGO_VARIANT_NORMAL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_WEIGHT, + g_param_spec_int ("weight", + _("Font weight"), + _("Font weight"), + 0, + G_MAXINT, + PANGO_WEIGHT_NORMAL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_STRETCH, + g_param_spec_enum ("stretch", + _("Font stretch"), + _("Font stretch"), + PANGO_TYPE_STRETCH, + PANGO_STRETCH_NORMAL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_SIZE, + g_param_spec_int ("size", + _("Font size"), + _("Font size"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_SIZE_POINTS, + g_param_spec_double ("size_points", + _("Font points"), + _("Font size in points"), + 0.0, + G_MAXDOUBLE, + 0.0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_JUSTIFY, + g_param_spec_enum ("justify", + _("Justification"), + _("Left, right, or center justification"), + GTK_TYPE_JUSTIFICATION, + GTK_JUSTIFY_LEFT, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_LANGUAGE, + g_param_spec_string ("language", + _("Language"), + _("Language engine code to use for rendering the text"), + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_LEFT_MARGIN, + g_param_spec_int ("left_margin", + _("Left margin"), + _("Width of the left margin in pixels"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_RIGHT_MARGIN, + g_param_spec_int ("right_margin", + _("Right margin"), + _("Width of the right margin in pixels"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_INDENT, + g_param_spec_int ("indent", + _("Indent"), + _("Amount to indent the paragraph, in pixels"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_RISE, + g_param_spec_int ("rise", + _("Rise"), + _("Offset of text above the baseline (below the baseline if rise is negative)"), + -G_MAXINT, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_PIXELS_ABOVE_LINES, + g_param_spec_int ("pixels_above_lines", + _("Pixels above lines"), + _("Pixels of blank space above paragraphs"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_PIXELS_BELOW_LINES, + g_param_spec_int ("pixels_below_lines", + _("Pixels below lines"), + _("Pixels of blank space below paragraphs"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_PIXELS_INSIDE_WRAP, + g_param_spec_int ("pixels_inside_wrap", + _("Pixels inside wrap"), + _("Pixels of blank space between wrapped lines in a paragraph"), + 0, + G_MAXINT, + 0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_STRIKETHROUGH, + g_param_spec_boolean ("strikethrough", + _("Strikethrough"), + _("Whether to strike through the text"), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_UNDERLINE, + g_param_spec_enum ("underline", + _("Underline"), + _("Style of underline for this text"), + PANGO_TYPE_UNDERLINE, + PANGO_UNDERLINE_NONE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_WRAP_MODE, + g_param_spec_enum ("wrap_mode", + _("Wrap mode"), + _("Whether to wrap lines never, at word boundaries, or at character boundaries"), + GTK_TYPE_WRAP_MODE, + GTK_WRAPMODE_NONE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + + g_object_class_install_property (object_class, + PROP_TABS, + g_param_spec_boxed ("tabs", + _("Tabs"), + _("Custom tabs for this text"), + GTK_TYPE_PANGO_TAB_ARRAY, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_INVISIBLE, + g_param_spec_boolean ("invisible", + _("Invisible"), + _("Whether this text is hidden"), + FALSE, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /* Style props are set or not */ + +#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE)) + + ADD_SET_PROP ("background_set", PROP_BACKGROUND_SET, + _("Background set"), + _("Whether this tag affects the background color")); + + ADD_SET_PROP ("background_full_height_set", PROP_BG_FULL_HEIGHT_SET, + _("Background full height set"), + _("Whether this tag affects background height")); + + ADD_SET_PROP ("background_gdk_set", PROP_BACKGROUND_GDK_SET, + _("Background set"), + _("Whether this tag affects the background color")); + + ADD_SET_PROP ("background_stipple_set", PROP_BACKGROUND_STIPPLE_SET, + _("Background stipple set"), + _("Whether this tag affects the background stipple")); + + ADD_SET_PROP ("foreground_set", PROP_FOREGROUND_SET, + _("Foreground set"), + _("Whether this tag affects the foreground color")); + + ADD_SET_PROP ("foreground_gdk_set", PROP_FOREGROUND_GDK_SET, + _("Foreground set"), + _("Whether this tag affects the foreground color")); + + ADD_SET_PROP ("foreground_stipple_set", PROP_FOREGROUND_STIPPLE_SET, + _("Foreground stipple set"), + _("Whether this tag affects the foreground stipple")); + + ADD_SET_PROP ("editable_set", PROP_EDITABLE_SET, + _("Editability set"), + _("Whether this tag affects text editability")); + + ADD_SET_PROP ("family_set", PROP_FAMILY_SET, + _("Font family set"), + _("Whether this tag affects the font family")); + + ADD_SET_PROP ("style_set", PROP_STYLE_SET, + _("Font style set"), + _("Whether this tag affects the font style")); + + ADD_SET_PROP ("variant_set", PROP_VARIANT_SET, + _("Font variant set"), + _("Whether this tag affects the font variant")); + + ADD_SET_PROP ("weight_set", PROP_WEIGHT_SET, + _("Font weight set"), + _("Whether this tag affects the font weight")); + + ADD_SET_PROP ("stretch_set", PROP_STRETCH_SET, + _("Font stretch set"), + _("Whether this tag affects the font stretch")); + + ADD_SET_PROP ("size_set", PROP_SIZE_SET, + _("Font size set"), + _("Whether this tag affects the font size")); + + ADD_SET_PROP ("justify_set", PROP_JUSTIFY_SET, + _("Justification set"), + _("Whether this tag affects paragraph justification")); + + ADD_SET_PROP ("language_set", PROP_LANGUAGE_SET, + _("Language set"), + _("Whether this tag affects the language the text is rendered as")); + + ADD_SET_PROP ("left_margin_set", PROP_LEFT_MARGIN_SET, + _("Left margin set"), + _("Whether this tag affects the left margin")); + + ADD_SET_PROP ("indent_set", PROP_INDENT_SET, + _("Indent set"), + _("Whether this tag affects indentation")); + + ADD_SET_PROP ("rise_set", PROP_RISE_SET, + _("Rise set"), + _("Whether this tag affects the rise")); + + ADD_SET_PROP ("pixels_above_lines_set", PROP_PIXELS_ABOVE_LINES_SET, + _("Pixels above lines set"), + _("Whether this tag affects the number of pixels above lines")); + + ADD_SET_PROP ("pixels_below_lines_set", PROP_PIXELS_BELOW_LINES_SET, + _("Pixels below lines set"), + _("Whether this tag affects the number of pixels above lines")); + + ADD_SET_PROP ("pixels_inside_wrap_set", PROP_PIXELS_INSIDE_WRAP_SET, + _("Pixels inside wrap set"), + _("Whether this tag affects the number of pixels between wrapped lines")); + + ADD_SET_PROP ("strikethrough_set", PROP_STRIKETHROUGH_SET, + _("Strikethrough set"), + _("Whether this tag affects strikethrough")); + + ADD_SET_PROP ("right_margin_set", PROP_RIGHT_MARGIN_SET, + _("Right margin set"), + _("Whether this tag affects the right margin")); + + ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET, + _("Underline set"), + _("Whether this tag affects underlining")); + + ADD_SET_PROP ("wrap_mode_set", PROP_WRAP_MODE_SET, + _("Wrap mode set"), + _("Whether this tag affects line wrap mode")); + + ADD_SET_PROP ("tabs_set", PROP_TABS_SET, + _("Tabs set"), + _("Whether this tag affects tabs")); + + ADD_SET_PROP ("invisible_set", PROP_INVISIBLE_SET, + _("Invisible set"), + _("Whether this tag affects text visibility")); signals[EVENT] = - gtk_signal_new ("event", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextTagClass, event), - gtk_marshal_INT__OBJECT_BOXED_BOXED, - GTK_TYPE_INT, - 3, - G_TYPE_OBJECT, - GTK_TYPE_GDK_EVENT, - GTK_TYPE_TEXT_ITER); + g_signal_newc ("event", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + GTK_SIGNAL_OFFSET (GtkTextTagClass, event), + NULL, + gtk_marshal_INT__OBJECT_BOXED_BOXED, + GTK_TYPE_INT, + 3, + G_TYPE_OBJECT, + GTK_TYPE_GDK_EVENT, + GTK_TYPE_TEXT_ITER); } void @@ -367,7 +656,7 @@ gtk_text_tag_new (const gchar *name) } static void -gtk_text_tag_destroy (GtkObject *object) +gtk_text_tag_finalize (GObject *object) { GtkTextTag *text_tag; @@ -382,17 +671,7 @@ gtk_text_tag_destroy (GtkObject *object) gtk_text_attributes_unref (text_tag->values); text_tag->values = NULL; - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -gtk_text_tag_finalize (GObject *object) -{ - GtkTextTag *text_tag; - - text_tag = GTK_TEXT_TAG (object); - + g_free (text_tag->name); text_tag->name = NULL; @@ -438,21 +717,21 @@ set_font_description (GtkTextTag *text_tag, */ if (font_desc->family_name) - gtk_object_set (GTK_OBJECT (text_tag), - "family", font_desc->family_name, - NULL); + g_object_set (G_OBJECT (text_tag), + "family", font_desc->family_name, + NULL); if (font_desc->size >= 0) - gtk_object_set (GTK_OBJECT (text_tag), - "size", font_desc->size, - NULL); - - gtk_object_set (GTK_OBJECT (text_tag), - "style", font_desc->style, - "variant", font_desc->variant, - "weight", font_desc->weight, - "stretch", font_desc->stretch, + g_object_set (G_OBJECT (text_tag), + "size", font_desc->size, NULL); + + g_object_set (G_OBJECT (text_tag), + "style", font_desc->style, + "variant", font_desc->variant, + "weight", font_desc->weight, + "stretch", font_desc->stretch, + NULL); } else { @@ -466,7 +745,11 @@ set_font_description (GtkTextTag *text_tag, } static void -gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) +gtk_text_tag_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkTextTag *text_tag; gboolean size_changed = FALSE; @@ -475,52 +758,52 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) g_return_if_fail (!text_tag->values->realized); - switch (arg_id) + switch (prop_id) { - case ARG_NAME: + case PROP_NAME: g_return_if_fail (text_tag->name == NULL); - text_tag->name = g_strdup (GTK_VALUE_STRING (*arg)); + text_tag->name = g_strdup (g_value_get_string (value)); break; - case ARG_BACKGROUND: + case PROP_BACKGROUND: { GdkColor color; - if (gdk_color_parse (GTK_VALUE_STRING (*arg), &color)) + if (gdk_color_parse (g_value_get_string (value), &color)) set_bg_color (text_tag, &color); else - g_warning ("Don't know color `%s'", GTK_VALUE_STRING (*arg)); + g_warning ("Don't know color `%s'", g_value_get_string (value)); } break; - case ARG_FOREGROUND: + case PROP_FOREGROUND: { GdkColor color; - if (gdk_color_parse (GTK_VALUE_STRING (*arg), &color)) + if (gdk_color_parse (g_value_get_string (value), &color)) set_fg_color (text_tag, &color); else - g_warning ("Don't know color `%s'", GTK_VALUE_STRING (*arg)); + g_warning ("Don't know color `%s'", g_value_get_string (value)); } break; - case ARG_BACKGROUND_GDK: + case PROP_BACKGROUND_GDK: { - GdkColor *color = GTK_VALUE_POINTER (*arg); + GdkColor *color = g_value_get_as_pointer (value); set_bg_color (text_tag, color); } break; - case ARG_FOREGROUND_GDK: + case PROP_FOREGROUND_GDK: { - GdkColor *color = GTK_VALUE_POINTER (*arg); + GdkColor *color = g_value_get_as_pointer (value); set_fg_color (text_tag, color); } break; - case ARG_BACKGROUND_STIPPLE: + case PROP_BACKGROUND_STIPPLE: { - GdkBitmap *bitmap = GTK_VALUE_POINTER (*arg); + GdkBitmap *bitmap = g_value_get_as_pointer (value); text_tag->bg_stipple_set = TRUE; @@ -537,9 +820,9 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FOREGROUND_STIPPLE: + case PROP_FOREGROUND_STIPPLE: { - GdkBitmap *bitmap = GTK_VALUE_POINTER (*arg); + GdkBitmap *bitmap = g_value_get_as_pointer (value); text_tag->fg_stipple_set = TRUE; @@ -556,12 +839,12 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FONT: + case PROP_FONT: { PangoFontDescription *font_desc = NULL; const gchar *name; - name = GTK_VALUE_STRING (*arg); + name = g_value_get_string (value); if (name) font_desc = pango_font_description_from_string (name); @@ -575,11 +858,11 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FONT_DESC: + case PROP_FONT_DESC: { PangoFontDescription *font_desc; - font_desc = GTK_VALUE_BOXED (*arg); + font_desc = g_value_get_as_pointer (value); set_font_description (text_tag, font_desc); @@ -587,134 +870,134 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FAMILY: + case PROP_FAMILY: if (text_tag->values->font.family_name) g_free (text_tag->values->font.family_name); - text_tag->values->font.family_name = g_strdup (GTK_VALUE_STRING (*arg)); + text_tag->values->font.family_name = g_strdup (g_value_get_string (value)); text_tag->family_set = TRUE; size_changed = TRUE; break; - case ARG_STYLE: - text_tag->values->font.style = GTK_VALUE_ENUM (*arg); + case PROP_STYLE: + text_tag->values->font.style = g_value_get_enum (value); text_tag->style_set = TRUE; size_changed = TRUE; break; - case ARG_VARIANT: - text_tag->values->font.variant = GTK_VALUE_ENUM (*arg); + case PROP_VARIANT: + text_tag->values->font.variant = g_value_get_enum (value); text_tag->variant_set = TRUE; size_changed = TRUE; break; - case ARG_WEIGHT: - text_tag->values->font.weight = GTK_VALUE_ENUM (*arg); + case PROP_WEIGHT: + text_tag->values->font.weight = g_value_get_int (value); text_tag->weight_set = TRUE; size_changed = TRUE; break; - case ARG_STRETCH: - text_tag->values->font.stretch = GTK_VALUE_ENUM (*arg); + case PROP_STRETCH: + text_tag->values->font.stretch = g_value_get_enum (value); text_tag->stretch_set = TRUE; size_changed = TRUE; break; - case ARG_SIZE: - text_tag->values->font.size = GTK_VALUE_INT (*arg); + case PROP_SIZE: + text_tag->values->font.size = g_value_get_int (value); text_tag->size_set = TRUE; size_changed = TRUE; break; - case ARG_SIZE_POINTS: - text_tag->values->font.size = GTK_VALUE_DOUBLE (*arg) * PANGO_SCALE; + case PROP_SIZE_POINTS: + text_tag->values->font.size = g_value_get_double (value) * PANGO_SCALE; text_tag->size_set = TRUE; size_changed = TRUE; break; - case ARG_PIXELS_ABOVE_LINES: + case PROP_PIXELS_ABOVE_LINES: text_tag->pixels_above_lines_set = TRUE; - text_tag->values->pixels_above_lines = GTK_VALUE_INT (*arg); + text_tag->values->pixels_above_lines = g_value_get_int (value); size_changed = TRUE; break; - case ARG_PIXELS_BELOW_LINES: + case PROP_PIXELS_BELOW_LINES: text_tag->pixels_below_lines_set = TRUE; - text_tag->values->pixels_below_lines = GTK_VALUE_INT (*arg); + text_tag->values->pixels_below_lines = g_value_get_int (value); size_changed = TRUE; break; - case ARG_PIXELS_INSIDE_WRAP: + case PROP_PIXELS_INSIDE_WRAP: text_tag->pixels_inside_wrap_set = TRUE; - text_tag->values->pixels_inside_wrap = GTK_VALUE_INT (*arg); + text_tag->values->pixels_inside_wrap = g_value_get_int (value); size_changed = TRUE; break; - case ARG_EDITABLE: + case PROP_EDITABLE: text_tag->editable_set = TRUE; - text_tag->values->editable = GTK_VALUE_BOOL (*arg); + text_tag->values->editable = g_value_get_boolean (value); break; - case ARG_WRAP_MODE: + case PROP_WRAP_MODE: text_tag->wrap_mode_set = TRUE; - text_tag->values->wrap_mode = GTK_VALUE_ENUM (*arg); + text_tag->values->wrap_mode = g_value_get_enum (value); size_changed = TRUE; break; - case ARG_JUSTIFY: + case PROP_JUSTIFY: text_tag->justify_set = TRUE; - text_tag->values->justify = GTK_VALUE_ENUM (*arg); + text_tag->values->justify = g_value_get_enum (value); size_changed = TRUE; break; - case ARG_DIRECTION: - text_tag->values->direction = GTK_VALUE_ENUM (*arg); + case PROP_DIRECTION: + text_tag->values->direction = g_value_get_enum (value); break; - case ARG_LEFT_MARGIN: + case PROP_LEFT_MARGIN: text_tag->left_margin_set = TRUE; - text_tag->values->left_margin = GTK_VALUE_INT (*arg); + text_tag->values->left_margin = g_value_get_int (value); size_changed = TRUE; break; - case ARG_INDENT: + case PROP_INDENT: text_tag->indent_set = TRUE; - text_tag->values->indent = GTK_VALUE_INT (*arg); + text_tag->values->indent = g_value_get_int (value); size_changed = TRUE; break; - case ARG_STRIKETHROUGH: + case PROP_STRIKETHROUGH: text_tag->strikethrough_set = TRUE; - text_tag->values->appearance.strikethrough = GTK_VALUE_BOOL (*arg); + text_tag->values->appearance.strikethrough = g_value_get_boolean (value); break; - case ARG_RIGHT_MARGIN: + case PROP_RIGHT_MARGIN: text_tag->right_margin_set = TRUE; - text_tag->values->right_margin = GTK_VALUE_INT (*arg); + text_tag->values->right_margin = g_value_get_int (value); size_changed = TRUE; break; - case ARG_UNDERLINE: + case PROP_UNDERLINE: text_tag->underline_set = TRUE; - text_tag->values->appearance.underline = GTK_VALUE_ENUM (*arg); + text_tag->values->appearance.underline = g_value_get_enum (value); break; - case ARG_RISE: + case PROP_RISE: text_tag->rise_set = TRUE; - text_tag->values->appearance.rise = GTK_VALUE_INT (*arg); + text_tag->values->appearance.rise = g_value_get_int (value); size_changed = TRUE; break; - case ARG_BG_FULL_HEIGHT: + case PROP_BG_FULL_HEIGHT: text_tag->bg_full_height_set = TRUE; - text_tag->values->bg_full_height = GTK_VALUE_BOOL (*arg); + text_tag->values->bg_full_height = g_value_get_boolean (value); break; - case ARG_LANGUAGE: + case PROP_LANGUAGE: text_tag->language_set = TRUE; - text_tag->values->language = g_strdup (GTK_VALUE_STRING (*arg)); + text_tag->values->language = g_strdup (g_value_get_string (value)); break; - case ARG_TABS: + case PROP_TABS: text_tag->tabs_set = TRUE; if (text_tag->values->tabs) @@ -722,31 +1005,31 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) /* FIXME I'm not sure if this is a memleak or not */ text_tag->values->tabs = - pango_tab_array_copy (GTK_VALUE_POINTER (*arg)); + pango_tab_array_copy (g_value_get_as_pointer (value)); size_changed = TRUE; break; - case ARG_INVISIBLE: + case PROP_INVISIBLE: text_tag->invisible_set = TRUE; - text_tag->values->invisible = GTK_VALUE_BOOL (*arg); + text_tag->values->invisible = g_value_get_boolean (value); size_changed = TRUE; break; /* Whether the value should be used... */ - case ARG_BACKGROUND_SET: - case ARG_BACKGROUND_GDK_SET: - text_tag->bg_color_set = GTK_VALUE_BOOL (*arg); + case PROP_BACKGROUND_SET: + case PROP_BACKGROUND_GDK_SET: + text_tag->bg_color_set = g_value_get_boolean (value); break; - case ARG_FOREGROUND_SET: - case ARG_FOREGROUND_GDK_SET: - text_tag->fg_color_set = GTK_VALUE_BOOL (*arg); + case PROP_FOREGROUND_SET: + case PROP_FOREGROUND_GDK_SET: + text_tag->fg_color_set = g_value_get_boolean (value); break; - case ARG_BACKGROUND_STIPPLE_SET: - text_tag->bg_stipple_set = GTK_VALUE_BOOL (*arg); + case PROP_BACKGROUND_STIPPLE_SET: + text_tag->bg_stipple_set = g_value_get_boolean (value); if (!text_tag->bg_stipple_set && text_tag->values->appearance.bg_stipple) { @@ -755,8 +1038,8 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FOREGROUND_STIPPLE_SET: - text_tag->fg_stipple_set = GTK_VALUE_BOOL (*arg); + case PROP_FOREGROUND_STIPPLE_SET: + text_tag->fg_stipple_set = g_value_get_boolean (value); if (!text_tag->fg_stipple_set && text_tag->values->appearance.fg_stipple) { @@ -765,401 +1048,403 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } break; - case ARG_FAMILY_SET: - text_tag->family_set = GTK_VALUE_BOOL (*arg); + case PROP_FAMILY_SET: + text_tag->family_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_STYLE_SET: - text_tag->style_set = GTK_VALUE_BOOL (*arg); + case PROP_STYLE_SET: + text_tag->style_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_VARIANT_SET: - text_tag->variant_set = GTK_VALUE_BOOL (*arg); + case PROP_VARIANT_SET: + text_tag->variant_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_WEIGHT_SET: - text_tag->weight_set = GTK_VALUE_BOOL (*arg); + case PROP_WEIGHT_SET: + text_tag->weight_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_STRETCH_SET: - text_tag->stretch_set = GTK_VALUE_BOOL (*arg); + case PROP_STRETCH_SET: + text_tag->stretch_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_SIZE_SET: - text_tag->size_set = GTK_VALUE_BOOL (*arg); + case PROP_SIZE_SET: + text_tag->size_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_PIXELS_ABOVE_LINES_SET: - text_tag->pixels_above_lines_set = GTK_VALUE_BOOL (*arg); + case PROP_PIXELS_ABOVE_LINES_SET: + text_tag->pixels_above_lines_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_PIXELS_BELOW_LINES_SET: - text_tag->pixels_below_lines_set = GTK_VALUE_BOOL (*arg); + case PROP_PIXELS_BELOW_LINES_SET: + text_tag->pixels_below_lines_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_PIXELS_INSIDE_WRAP_SET: - text_tag->pixels_inside_wrap_set = GTK_VALUE_BOOL (*arg); + case PROP_PIXELS_INSIDE_WRAP_SET: + text_tag->pixels_inside_wrap_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_EDITABLE_SET: - text_tag->editable_set = GTK_VALUE_BOOL (*arg); + case PROP_EDITABLE_SET: + text_tag->editable_set = g_value_get_boolean (value); break; - case ARG_WRAP_MODE_SET: - text_tag->wrap_mode_set = GTK_VALUE_BOOL (*arg); + case PROP_WRAP_MODE_SET: + text_tag->wrap_mode_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_JUSTIFY_SET: - text_tag->justify_set = GTK_VALUE_BOOL (*arg); + case PROP_JUSTIFY_SET: + text_tag->justify_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_LEFT_MARGIN_SET: - text_tag->left_margin_set = GTK_VALUE_BOOL (*arg); + case PROP_LEFT_MARGIN_SET: + text_tag->left_margin_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_INDENT_SET: - text_tag->indent_set = GTK_VALUE_BOOL (*arg); + case PROP_INDENT_SET: + text_tag->indent_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_STRIKETHROUGH_SET: - text_tag->strikethrough_set = GTK_VALUE_BOOL (*arg); + case PROP_STRIKETHROUGH_SET: + text_tag->strikethrough_set = g_value_get_boolean (value); break; - case ARG_RIGHT_MARGIN_SET: - text_tag->right_margin_set = GTK_VALUE_BOOL (*arg); + case PROP_RIGHT_MARGIN_SET: + text_tag->right_margin_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_UNDERLINE_SET: - text_tag->underline_set = GTK_VALUE_BOOL (*arg); + case PROP_UNDERLINE_SET: + text_tag->underline_set = g_value_get_boolean (value); break; - case ARG_RISE_SET: - text_tag->rise_set = GTK_VALUE_BOOL (*arg); + case PROP_RISE_SET: + text_tag->rise_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_BG_FULL_HEIGHT_SET: - text_tag->bg_full_height_set = GTK_VALUE_BOOL (*arg); + case PROP_BG_FULL_HEIGHT_SET: + text_tag->bg_full_height_set = g_value_get_boolean (value); break; - case ARG_LANGUAGE_SET: - text_tag->language_set = GTK_VALUE_BOOL (*arg); + case PROP_LANGUAGE_SET: + text_tag->language_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_TABS_SET: - text_tag->tabs_set = GTK_VALUE_BOOL (*arg); + case PROP_TABS_SET: + text_tag->tabs_set = g_value_get_boolean (value); size_changed = TRUE; break; - case ARG_INVISIBLE_SET: - text_tag->invisible_set = GTK_VALUE_BOOL (*arg); + case PROP_INVISIBLE_SET: + text_tag->invisible_set = g_value_get_boolean (value); size_changed = TRUE; break; default: - g_assert_not_reached (); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } - /* FIXME I would like to do this after all set_arg in a single - gtk_object_set () have been called. But an idle function - won't work; we need to emit when the tag is changed, not - when we get around to the event loop. So blah, we eat some - inefficiency. */ + /* FIXME I would like to do this after all set_property in a single + * g_object_set () have been called. But an idle function won't + * work; we need to emit when the tag is changed, not when we get + * around to the event loop. So blah, we eat some inefficiency. + */ /* This is also somewhat weird since we emit another object's - signal here, but the two objects are already tightly bound. */ + * signal here, but the two objects are already tightly bound. + */ if (text_tag->table) - gtk_signal_emit_by_name (GTK_OBJECT (text_tag->table), - "tag_changed", - text_tag, size_changed); + g_signal_emit_by_name (G_OBJECT (text_tag->table), + "tag_changed", + text_tag, size_changed); } static void -get_color_arg (GtkArg *arg, GdkColor *orig) +get_color_arg (GValue *value, GdkColor *orig) { GdkColor *color; color = g_new (GdkColor, 1); *color = *orig; - GTK_VALUE_BOXED (*arg) = color; + g_value_init (value, GTK_TYPE_GDK_COLOR); + g_value_set_boxed (value, color); } static void -gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +gtk_text_tag_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkTextTag *tag; tag = GTK_TEXT_TAG (object); - switch (arg_id) + switch (prop_id) { - case ARG_NAME: - GTK_VALUE_STRING (*arg) = g_strdup (tag->name); + case PROP_NAME: + g_value_set_string (value, tag->name); break; - case ARG_BACKGROUND_GDK: - get_color_arg (arg, &tag->values->appearance.bg_color); + case PROP_BACKGROUND_GDK: + get_color_arg (value, &tag->values->appearance.bg_color); break; - case ARG_FOREGROUND_GDK: - get_color_arg (arg, &tag->values->appearance.fg_color); + case PROP_FOREGROUND_GDK: + get_color_arg (value, &tag->values->appearance.fg_color); break; - case ARG_BACKGROUND_STIPPLE: + case PROP_BACKGROUND_STIPPLE: if (tag->bg_stipple_set) - GTK_VALUE_BOXED (*arg) = tag->values->appearance.bg_stipple; - else - GTK_VALUE_BOXED (*arg) = NULL; + g_value_set_boxed (value, tag->values->appearance.bg_stipple); break; - case ARG_FOREGROUND_STIPPLE: + case PROP_FOREGROUND_STIPPLE: if (tag->fg_stipple_set) - GTK_VALUE_BOXED (*arg) = tag->values->appearance.fg_stipple; - else - GTK_VALUE_BOXED (*arg) = NULL; + g_value_set_boxed (value, tag->values->appearance.fg_stipple); break; - case ARG_FONT: + case PROP_FONT: if (tag->family_set && tag->style_set && tag->variant_set && tag->size_set && tag->stretch_set && tag->weight_set) - GTK_VALUE_STRING (*arg) = - pango_font_description_to_string (&tag->values->font); - else - GTK_VALUE_STRING (*arg) = NULL; + { + /* FIXME GValue imposes a totally gratuitous string copy + * here, we could just hand off string ownership + */ + gchar *str = pango_font_description_to_string (&tag->values->font); + g_value_set_string (value, str); + g_free (str); + } break; - case ARG_FONT_DESC: + case PROP_FONT_DESC: if (tag->family_set && tag->style_set && tag->variant_set && tag->size_set && tag->stretch_set && tag->weight_set) - GTK_VALUE_BOXED (*arg) = pango_font_description_copy (&tag->values->font); - else - GTK_VALUE_BOXED (*arg) = NULL; + g_value_set_boxed (value, &tag->values->font); break; - case ARG_FAMILY: - GTK_VALUE_STRING (*arg) = g_strdup (tag->values->font.family_name); + case PROP_FAMILY: + g_value_set_string (value, tag->values->font.family_name); break; - case ARG_STYLE: - GTK_VALUE_ENUM (*arg) = tag->values->font.style; + case PROP_STYLE: + g_value_set_enum (value, tag->values->font.style); break; - case ARG_VARIANT: - GTK_VALUE_ENUM (*arg) = tag->values->font.variant; + case PROP_VARIANT: + g_value_set_enum (value, tag->values->font.variant); break; - case ARG_WEIGHT: - GTK_VALUE_ENUM (*arg) = tag->values->font.weight; + case PROP_WEIGHT: + g_value_set_int (value, tag->values->font.weight); break; - case ARG_STRETCH: - GTK_VALUE_ENUM (*arg) = tag->values->font.stretch; + case PROP_STRETCH: + g_value_set_enum (value, tag->values->font.stretch); break; - case ARG_SIZE: - GTK_VALUE_INT (*arg) = tag->values->font.size; + case PROP_SIZE: + g_value_set_int (value, tag->values->font.size); break; - case ARG_SIZE_POINTS: - GTK_VALUE_DOUBLE (*arg) = ((double)tag->values->font.size) / (double)PANGO_SCALE; + case PROP_SIZE_POINTS: + g_value_set_double (value, ((double)tag->values->font.size) / (double)PANGO_SCALE); break; - case ARG_PIXELS_ABOVE_LINES: - GTK_VALUE_INT (*arg) = tag->values->pixels_above_lines; + case PROP_PIXELS_ABOVE_LINES: + g_value_set_int (value, tag->values->pixels_above_lines); break; - case ARG_PIXELS_BELOW_LINES: - GTK_VALUE_INT (*arg) = tag->values->pixels_below_lines; + case PROP_PIXELS_BELOW_LINES: + g_value_set_int (value, tag->values->pixels_below_lines); break; - case ARG_PIXELS_INSIDE_WRAP: - GTK_VALUE_INT (*arg) = tag->values->pixels_inside_wrap; + case PROP_PIXELS_INSIDE_WRAP: + g_value_set_int (value, tag->values->pixels_inside_wrap); break; - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = tag->values->editable; + case PROP_EDITABLE: + g_value_set_boolean (value, tag->values->editable); break; - case ARG_WRAP_MODE: - GTK_VALUE_ENUM (*arg) = tag->values->wrap_mode; + case PROP_WRAP_MODE: + g_value_set_enum (value, tag->values->wrap_mode); break; - case ARG_JUSTIFY: - GTK_VALUE_ENUM (*arg) = tag->values->justify; + case PROP_JUSTIFY: + g_value_set_enum (value, tag->values->justify); break; - case ARG_LEFT_MARGIN: - GTK_VALUE_INT (*arg) = tag->values->left_margin; + case PROP_LEFT_MARGIN: + g_value_set_int (value, tag->values->left_margin); break; - case ARG_INDENT: - GTK_VALUE_INT (*arg) = tag->values->indent; + case PROP_INDENT: + g_value_set_int (value, tag->values->indent); break; - case ARG_STRIKETHROUGH: - GTK_VALUE_BOOL (*arg) = tag->values->appearance.strikethrough; + case PROP_STRIKETHROUGH: + g_value_set_boolean (value, tag->values->appearance.strikethrough); break; - case ARG_RIGHT_MARGIN: - GTK_VALUE_INT (*arg) = tag->values->right_margin; + case PROP_RIGHT_MARGIN: + g_value_set_int (value, tag->values->right_margin); break; - case ARG_UNDERLINE: - GTK_VALUE_ENUM (*arg) = tag->values->appearance.underline; + case PROP_UNDERLINE: + g_value_set_enum (value, tag->values->appearance.underline); break; - case ARG_RISE: - GTK_VALUE_INT (*arg) = tag->values->appearance.rise; + case PROP_RISE: + g_value_set_int (value, tag->values->appearance.rise); break; - case ARG_BG_FULL_HEIGHT: - GTK_VALUE_BOOL (*arg) = tag->values->bg_full_height; + case PROP_BG_FULL_HEIGHT: + g_value_set_boolean (value, tag->values->bg_full_height); break; - case ARG_LANGUAGE: - GTK_VALUE_STRING (*arg) = g_strdup (tag->values->language); + case PROP_LANGUAGE: + g_value_set_string (value, tag->values->language); break; - case ARG_TABS: - GTK_VALUE_POINTER (*arg) = tag->values->tabs ? - pango_tab_array_copy (tag->values->tabs) : NULL; + case PROP_TABS: + if (tag->values->tabs) + g_value_set_boxed (value, tag->values->tabs); break; - case ARG_BACKGROUND_SET: - case ARG_BACKGROUND_GDK_SET: - GTK_VALUE_BOOL (*arg) = tag->bg_color_set; + case PROP_BACKGROUND_SET: + case PROP_BACKGROUND_GDK_SET: + g_value_set_boolean (value, tag->bg_color_set); break; - case ARG_FOREGROUND_SET: - case ARG_FOREGROUND_GDK_SET: - GTK_VALUE_BOOL (*arg) = tag->fg_color_set; + case PROP_FOREGROUND_SET: + case PROP_FOREGROUND_GDK_SET: + g_value_set_boolean (value, tag->fg_color_set); break; - case ARG_BACKGROUND_STIPPLE_SET: - GTK_VALUE_BOOL (*arg) = tag->bg_stipple_set; + case PROP_BACKGROUND_STIPPLE_SET: + g_value_set_boolean (value, tag->bg_stipple_set); break; - case ARG_FOREGROUND_STIPPLE_SET: - GTK_VALUE_BOOL (*arg) = tag->fg_stipple_set; + case PROP_FOREGROUND_STIPPLE_SET: + g_value_set_boolean (value, tag->fg_stipple_set); break; - case ARG_FAMILY_SET: - GTK_VALUE_BOOL (*arg) = tag->family_set; + case PROP_FAMILY_SET: + g_value_set_boolean (value, tag->family_set); break; - case ARG_STYLE_SET: - GTK_VALUE_BOOL (*arg) = tag->style_set; + case PROP_STYLE_SET: + g_value_set_boolean (value, tag->style_set); break; - case ARG_VARIANT_SET: - GTK_VALUE_BOOL (*arg) = tag->variant_set; + case PROP_VARIANT_SET: + g_value_set_boolean (value, tag->variant_set); break; - case ARG_WEIGHT_SET: - GTK_VALUE_BOOL (*arg) = tag->weight_set; + case PROP_WEIGHT_SET: + g_value_set_boolean (value, tag->weight_set); break; - case ARG_STRETCH_SET: - GTK_VALUE_BOOL (*arg) = tag->stretch_set; + case PROP_STRETCH_SET: + g_value_set_boolean (value, tag->stretch_set); break; - case ARG_SIZE_SET: - GTK_VALUE_BOOL (*arg) = tag->size_set; + case PROP_SIZE_SET: + g_value_set_boolean (value, tag->size_set); break; - case ARG_PIXELS_ABOVE_LINES_SET: - GTK_VALUE_BOOL (*arg) = tag->pixels_above_lines_set; + case PROP_PIXELS_ABOVE_LINES_SET: + g_value_set_boolean (value, tag->pixels_above_lines_set); break; - case ARG_PIXELS_BELOW_LINES_SET: - GTK_VALUE_BOOL (*arg) = tag->pixels_below_lines_set; + case PROP_PIXELS_BELOW_LINES_SET: + g_value_set_boolean (value, tag->pixels_below_lines_set); break; - case ARG_PIXELS_INSIDE_WRAP_SET: - GTK_VALUE_BOOL (*arg) = tag->pixels_inside_wrap_set; + case PROP_PIXELS_INSIDE_WRAP_SET: + g_value_set_boolean (value, tag->pixels_inside_wrap_set); break; - case ARG_EDITABLE_SET: - GTK_VALUE_BOOL (*arg) = tag->editable_set; + case PROP_EDITABLE_SET: + g_value_set_boolean (value, tag->editable_set); break; - case ARG_WRAP_MODE_SET: - GTK_VALUE_BOOL (*arg) = tag->wrap_mode_set; + case PROP_WRAP_MODE_SET: + g_value_set_boolean (value, tag->wrap_mode_set); break; - case ARG_JUSTIFY_SET: - GTK_VALUE_BOOL (*arg) = tag->justify_set; + case PROP_JUSTIFY_SET: + g_value_set_boolean (value, tag->justify_set); break; - case ARG_LEFT_MARGIN_SET: - GTK_VALUE_BOOL (*arg) = tag->left_margin_set; + case PROP_LEFT_MARGIN_SET: + g_value_set_boolean (value, tag->left_margin_set); break; - case ARG_INDENT_SET: - GTK_VALUE_BOOL (*arg) = tag->indent_set; + case PROP_INDENT_SET: + g_value_set_boolean (value, tag->indent_set); break; - case ARG_STRIKETHROUGH_SET: - GTK_VALUE_BOOL (*arg) = tag->strikethrough_set; + case PROP_STRIKETHROUGH_SET: + g_value_set_boolean (value, tag->strikethrough_set); break; - case ARG_RIGHT_MARGIN_SET: - GTK_VALUE_BOOL (*arg) = tag->right_margin_set; + case PROP_RIGHT_MARGIN_SET: + g_value_set_boolean (value, tag->right_margin_set); break; - case ARG_UNDERLINE_SET: - GTK_VALUE_BOOL (*arg) = tag->underline_set; + case PROP_UNDERLINE_SET: + g_value_set_boolean (value, tag->underline_set); break; - case ARG_RISE_SET: - GTK_VALUE_BOOL (*arg) = tag->rise_set; + case PROP_RISE_SET: + g_value_set_boolean (value, tag->rise_set); break; - case ARG_BG_FULL_HEIGHT_SET: - GTK_VALUE_BOOL (*arg) = tag->bg_full_height_set; + case PROP_BG_FULL_HEIGHT_SET: + g_value_set_boolean (value, tag->bg_full_height_set); break; - case ARG_LANGUAGE_SET: - GTK_VALUE_BOOL (*arg) = tag->language_set; + case PROP_LANGUAGE_SET: + g_value_set_boolean (value, tag->language_set); break; - case ARG_TABS_SET: - GTK_VALUE_BOOL (*arg) = tag->tabs_set; + case PROP_TABS_SET: + g_value_set_boolean (value, tag->tabs_set); break; - case ARG_BACKGROUND: - case ARG_FOREGROUND: + case PROP_BACKGROUND: + case PROP_FOREGROUND: default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } - /* FIXME */ - arg->type = GTK_TYPE_INVALID; } /* @@ -1271,12 +1556,13 @@ gtk_text_tag_event (GtkTextTag *tag, g_return_val_if_fail (GTK_IS_OBJECT (event_object), FALSE); g_return_val_if_fail (event != NULL, FALSE); - gtk_signal_emit (GTK_OBJECT (tag), - signals[EVENT], - event_object, - event, - iter, - &retval); + g_signal_emit (G_OBJECT (tag), + signals[EVENT], + 0, + event_object, + event, + iter, + &retval); return retval; } diff --git a/gtk/gtktexttag.h b/gtk/gtktexttag.h index dcf4954672..0e7ef96210 100644 --- a/gtk/gtktexttag.h +++ b/gtk/gtktexttag.h @@ -22,18 +22,18 @@ typedef enum typedef struct _GtkTextAttributes GtkTextAttributes; #define GTK_TYPE_TEXT_TAG (gtk_text_tag_get_type ()) -#define GTK_TEXT_TAG(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag)) -#define GTK_TEXT_TAG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass)) -#define GTK_IS_TEXT_TAG(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_TAG)) -#define GTK_IS_TEXT_TAG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG)) -#define GTK_TEXT_TAG_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass)) +#define GTK_TEXT_TAG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag)) +#define GTK_TEXT_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass)) +#define GTK_IS_TEXT_TAG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_TAG)) +#define GTK_IS_TEXT_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG)) +#define GTK_TEXT_TAG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass)) typedef struct _GtkTextTag GtkTextTag; typedef struct _GtkTextTagClass GtkTextTagClass; struct _GtkTextTag { - GtkObject parent_instance; + GObject parent_instance; GtkTextTagTable *table; @@ -90,7 +90,7 @@ struct _GtkTextTag }; struct _GtkTextTagClass { - GtkObjectClass parent_class; + GObjectClass parent_class; gint (* event) (GtkTextTag *tag, GObject *event_object, /* widget, canvas item, whatever */ @@ -98,7 +98,7 @@ struct _GtkTextTagClass { const GtkTextIter *iter); /* location of event in buffer */ }; -GtkType gtk_text_tag_get_type (void) G_GNUC_CONST; +GType gtk_text_tag_get_type (void) G_GNUC_CONST; GtkTextTag *gtk_text_tag_new (const gchar *name); gint gtk_text_tag_get_priority (GtkTextTag *tag); void gtk_text_tag_set_priority (GtkTextTag *tag, diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c index bf6fc6c998..3ad3668c65 100644 --- a/gtk/gtktexttagtable.c +++ b/gtk/gtktexttagtable.c @@ -15,36 +15,47 @@ enum { LAST_ARG }; -static void gtk_text_tag_table_init (GtkTextTagTable *table); -static void gtk_text_tag_table_class_init (GtkTextTagTableClass *klass); -static void gtk_text_tag_table_destroy (GtkObject *object); -static void gtk_text_tag_table_finalize (GObject *object); -static void gtk_text_tag_table_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void gtk_text_tag_table_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static GtkObjectClass *parent_class = NULL; +static void gtk_text_tag_table_init (GtkTextTagTable *table); +static void gtk_text_tag_table_class_init (GtkTextTagTableClass *klass); +static void gtk_text_tag_table_finalize (GObject *object); +static void gtk_text_tag_table_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer); +static void gtk_text_tag_table_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer); + +static GObjectClass *parent_class = NULL; static guint signals[LAST_SIGNAL] = { 0 }; -GtkType +GType gtk_text_tag_table_get_type (void) { - static GtkType our_type = 0; + static GType our_type = 0; if (our_type == 0) { - static const GtkTypeInfo our_info = + static const GTypeInfo our_info = { - "GtkTextTagTable", - sizeof (GtkTextTagTable), sizeof (GtkTextTagTableClass), - (GtkClassInitFunc) gtk_text_tag_table_class_init, - (GtkObjectInitFunc) gtk_text_tag_table_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gtk_text_tag_table_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkTextTagTable), + 0, /* n_preallocs */ + (GInstanceInitFunc) gtk_text_tag_table_init }; - our_type = gtk_type_unique (GTK_TYPE_OBJECT, &our_info); + our_type = g_type_register_static (G_TYPE_OBJECT, + "GtkTextTagTable", + &our_info, + 0); } return our_type; @@ -53,47 +64,48 @@ gtk_text_tag_table_get_type (void) static void gtk_text_tag_table_class_init (GtkTextTagTableClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->set_arg = gtk_text_tag_table_set_arg; - object_class->get_arg = gtk_text_tag_table_get_arg; + GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->destroy = gtk_text_tag_table_destroy; - gobject_class->finalize = gtk_text_tag_table_finalize; + parent_class = g_type_class_peek_parent (klass); + object_class->set_property = gtk_text_tag_table_set_property; + object_class->get_property = gtk_text_tag_table_get_property; + + object_class->finalize = gtk_text_tag_table_finalize; + signals[TAG_CHANGED] = - gtk_signal_new ("tag_changed", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextTagTableClass, tag_changed), - gtk_marshal_VOID__OBJECT_BOOLEAN, - GTK_TYPE_NONE, - 2, - G_TYPE_OBJECT, - GTK_TYPE_BOOL); + g_signal_newc ("tag_changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextTagTableClass, tag_changed), + NULL, + gtk_marshal_VOID__OBJECT_BOOLEAN, + G_TYPE_NONE, + 2, + G_TYPE_OBJECT, + G_TYPE_BOOLEAN); signals[TAG_ADDED] = - gtk_signal_new ("tag_added", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextTagTableClass, tag_added), - gtk_marshal_VOID__OBJECT, - GTK_TYPE_NONE, - 1, - G_TYPE_OBJECT); + g_signal_newc ("tag_added", + GTK_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextTagTableClass, tag_added), + NULL, + gtk_marshal_VOID__OBJECT, + GTK_TYPE_NONE, + 1, + G_TYPE_OBJECT); signals[TAG_REMOVED] = - gtk_signal_new ("tag_removed", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - GTK_SIGNAL_OFFSET (GtkTextTagTableClass, tag_removed), - gtk_marshal_VOID__OBJECT, - GTK_TYPE_NONE, - 1, - G_TYPE_OBJECT); + g_signal_newc ("tag_removed", + GTK_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkTextTagTableClass, tag_removed), + NULL, + gtk_marshal_VOID__OBJECT, + GTK_TYPE_NONE, + 1, + G_TYPE_OBJECT); } void @@ -115,22 +127,12 @@ gtk_text_tag_table_new (void) { GtkTextTagTable *table; - table = GTK_TEXT_TAG_TABLE (gtk_type_new (gtk_text_tag_table_get_type ())); + table = GTK_TEXT_TAG_TABLE (g_object_new (gtk_text_tag_table_get_type (), NULL)); return table; } static void -gtk_text_tag_table_destroy (GtkObject *object) -{ - GtkTextTagTable *table; - - table = GTK_TEXT_TAG_TABLE (object); - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void foreach_unref (GtkTextTag *tag, gpointer data) { /* We don't want to emit the remove signal here; so we just unparent @@ -155,35 +157,43 @@ gtk_text_tag_table_finalize (GObject *object) (* G_OBJECT_CLASS (parent_class)->finalize) (object); } - static void -gtk_text_tag_table_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) +gtk_text_tag_table_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkTextTagTable *table; table = GTK_TEXT_TAG_TABLE (object); - switch (arg_id) + switch (prop_id) { default: - g_assert_not_reached (); + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } + static void -gtk_text_tag_table_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +gtk_text_tag_table_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec, + const gchar *trailer) { GtkTextTagTable *table; table = GTK_TEXT_TAG_TABLE (object); - switch (arg_id) + switch (prop_id) { default: - arg->type = GTK_TYPE_INVALID; + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } @@ -209,8 +219,7 @@ gtk_text_tag_table_add (GtkTextTagTable *table, g_hash_table_lookup (table->hash, tag->name) == NULL); g_return_if_fail (tag->table == NULL); - gtk_object_ref (GTK_OBJECT (tag)); - gtk_object_sink (GTK_OBJECT (tag)); + g_object_ref (G_OBJECT (tag)); if (tag->name) g_hash_table_insert (table->hash, tag->name, tag); @@ -229,7 +238,7 @@ gtk_text_tag_table_add (GtkTextTagTable *table, g_assert (size > 0); tag->priority = size - 1; - gtk_signal_emit (GTK_OBJECT (table), signals[TAG_ADDED], tag); + g_signal_emit (G_OBJECT (table), signals[TAG_ADDED], 0, tag); } /** @@ -283,9 +292,9 @@ gtk_text_tag_table_remove (GtkTextTagTable *table, table->anon_count -= 1; } - gtk_signal_emit (GTK_OBJECT (table), signals[TAG_REMOVED], tag); + g_signal_emit (G_OBJECT (table), signals[TAG_REMOVED], 0, tag); - gtk_object_unref (GTK_OBJECT (tag)); + g_object_unref (G_OBJECT (tag)); } struct ForeachData diff --git a/gtk/gtktexttagtable.h b/gtk/gtktexttagtable.h index 3ab529faff..5b4837c388 100644 --- a/gtk/gtktexttagtable.h +++ b/gtk/gtktexttagtable.h @@ -12,16 +12,16 @@ extern "C" { typedef void (* GtkTextTagTableForeach) (GtkTextTag *tag, gpointer data); #define GTK_TYPE_TEXT_TAG_TABLE (gtk_text_tag_table_get_type ()) -#define GTK_TEXT_TAG_TABLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTable)) -#define GTK_TEXT_TAG_TABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTableClass)) -#define GTK_IS_TEXT_TAG_TABLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_TAG_TABLE)) -#define GTK_IS_TEXT_TAG_TABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG_TABLE)) -#define GTK_TEXT_TAG_TABLE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTableClass)) +#define GTK_TEXT_TAG_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTable)) +#define GTK_TEXT_TAG_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTableClass)) +#define GTK_IS_TEXT_TAG_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_TAG_TABLE)) +#define GTK_IS_TEXT_TAG_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG_TABLE)) +#define GTK_TEXT_TAG_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG_TABLE, GtkTextTagTableClass)) typedef struct _GtkTextTagTableClass GtkTextTagTableClass; struct _GtkTextTagTable { - GtkObject parent_instance; + GObject parent_instance; GHashTable *hash; GSList *anonymous; @@ -29,14 +29,14 @@ struct _GtkTextTagTable { }; struct _GtkTextTagTableClass { - GtkObjectClass parent_class; + GObjectClass parent_class; void (* tag_changed) (GtkTextTagTable *table, GtkTextTag *tag, gboolean size_changed); void (* tag_added) (GtkTextTagTable *table, GtkTextTag *tag); void (* tag_removed) (GtkTextTagTable *table, GtkTextTag *tag); }; -GtkType gtk_text_tag_table_get_type (void) G_GNUC_CONST; +GType gtk_text_tag_table_get_type (void) G_GNUC_CONST; GtkTextTagTable *gtk_text_tag_table_new (void); void gtk_text_tag_table_add (GtkTextTagTable *table, diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 1a97e93d35..0a44ac1582 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -234,6 +234,9 @@ static void gtk_text_view_forall (GtkContainer *container, /* FIXME probably need the focus methods. */ +/* Hack-around */ +#define g_signal_handlers_disconnect_by_func(obj, func, data) g_signal_handlers_disconnect_matched (obj, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, func, data) + typedef struct _GtkTextViewChild GtkTextViewChild; struct _GtkTextViewChild @@ -814,9 +817,9 @@ gtk_text_view_set_buffer (GtkTextView *text_view, g_slist_free (copy); - gtk_signal_disconnect_by_func (GTK_OBJECT (text_view->buffer), - gtk_text_view_mark_set_handler, text_view); - gtk_object_unref (GTK_OBJECT (text_view->buffer)); + g_signal_handlers_disconnect_by_func (G_OBJECT (text_view->buffer), + gtk_text_view_mark_set_handler, text_view); + g_object_unref (G_OBJECT (text_view->buffer)); text_view->dnd_mark = NULL; } @@ -826,8 +829,7 @@ gtk_text_view_set_buffer (GtkTextView *text_view, { GtkTextIter start; - gtk_object_ref (GTK_OBJECT (buffer)); - gtk_object_sink (GTK_OBJECT (buffer)); + g_object_ref (G_OBJECT (buffer)); if (text_view->layout) gtk_text_layout_set_buffer (text_view->layout, buffer); @@ -844,8 +846,9 @@ gtk_text_view_set_buffer (GtkTextView *text_view, text_view->first_para_pixels = 0; - gtk_signal_connect (GTK_OBJECT (text_view->buffer), "mark_set", - gtk_text_view_mark_set_handler, text_view); + g_signal_connect_data (G_OBJECT (text_view->buffer), "mark_set", + gtk_text_view_mark_set_handler, text_view, + NULL, FALSE, FALSE); } if (GTK_WIDGET_VISIBLE (text_view)) @@ -1633,9 +1636,9 @@ gtk_text_view_finalize (GObject *object) g_return_if_fail (text_view->buffer == NULL); if (text_view->hadjustment) - gtk_object_unref (GTK_OBJECT (text_view->hadjustment)); + g_object_unref (G_OBJECT (text_view->hadjustment)); if (text_view->vadjustment) - gtk_object_unref (GTK_OBJECT (text_view->vadjustment)); + g_object_unref (G_OBJECT (text_view->vadjustment)); text_window_free (text_view->text_window); @@ -1651,7 +1654,7 @@ gtk_text_view_finalize (GObject *object) if (text_view->bottom_window) text_window_free (text_view->bottom_window); - gtk_object_unref (GTK_OBJECT (text_view->im_context)); + g_object_unref (G_OBJECT (text_view->im_context)); (* G_OBJECT_CLASS (parent_class)->finalize) (object); } @@ -1875,7 +1878,7 @@ gtk_text_view_child_allocated (GtkTextLayout *layout, * window coordinates, then size_allocate the child. */ - vc = gtk_object_get_data (GTK_OBJECT (child), + vc = g_object_get_data (G_OBJECT (child), "gtk-text-view-child"); g_assert (vc != NULL); @@ -3746,20 +3749,23 @@ gtk_text_view_ensure_layout (GtkTextView *text_view) text_view->layout = gtk_text_layout_new (); - gtk_signal_connect (GTK_OBJECT (text_view->layout), - "invalidated", - GTK_SIGNAL_FUNC (invalidated_handler), - text_view); - - gtk_signal_connect (GTK_OBJECT (text_view->layout), - "changed", - GTK_SIGNAL_FUNC (changed_handler), - text_view); - - gtk_signal_connect (GTK_OBJECT (text_view->layout), - "allocate_child", - GTK_SIGNAL_FUNC (gtk_text_view_child_allocated), - text_view); + g_signal_connect_data (G_OBJECT (text_view->layout), + "invalidated", + invalidated_handler, + text_view, + NULL, FALSE, FALSE); + + g_signal_connect_data (G_OBJECT (text_view->layout), + "changed", + changed_handler, + text_view, + NULL, FALSE, FALSE); + + g_signal_connect_data (G_OBJECT (text_view->layout), + "allocate_child", + gtk_text_view_child_allocated, + text_view, + NULL, FALSE, FALSE); if (get_buffer (text_view)) gtk_text_layout_set_buffer (text_view->layout, get_buffer (text_view)); @@ -3845,11 +3851,11 @@ gtk_text_view_destroy_layout (GtkTextView *text_view) gtk_text_view_stop_cursor_blink (text_view); gtk_text_view_end_selection_drag (text_view, NULL); - gtk_signal_disconnect_by_func (GTK_OBJECT (text_view->layout), - invalidated_handler, text_view); - gtk_signal_disconnect_by_func (GTK_OBJECT (text_view->layout), - changed_handler, text_view); - gtk_object_unref (GTK_OBJECT (text_view->layout)); + g_signal_handlers_disconnect_by_func (G_OBJECT (text_view->layout), + invalidated_handler, text_view); + g_signal_handlers_disconnect_by_func (G_OBJECT (text_view->layout), + changed_handler, text_view); + g_object_unref (G_OBJECT (text_view->layout)); text_view->layout = NULL; } } @@ -4232,19 +4238,19 @@ gtk_text_view_set_scroll_adjustments (GtkTextView *text_view, if (text_view->hadjustment && (text_view->hadjustment != hadj)) { gtk_signal_disconnect_by_data (GTK_OBJECT (text_view->hadjustment), text_view); - gtk_object_unref (GTK_OBJECT (text_view->hadjustment)); + g_object_unref (G_OBJECT (text_view->hadjustment)); } if (text_view->vadjustment && (text_view->vadjustment != vadj)) { gtk_signal_disconnect_by_data (GTK_OBJECT (text_view->vadjustment), text_view); - gtk_object_unref (GTK_OBJECT (text_view->vadjustment)); + g_object_unref (G_OBJECT (text_view->vadjustment)); } if (text_view->hadjustment != hadj) { text_view->hadjustment = hadj; - gtk_object_ref (GTK_OBJECT (text_view->hadjustment)); + g_object_ref (G_OBJECT (text_view->hadjustment)); gtk_object_sink (GTK_OBJECT (text_view->hadjustment)); gtk_signal_connect (GTK_OBJECT (text_view->hadjustment), "value_changed", @@ -4256,7 +4262,7 @@ gtk_text_view_set_scroll_adjustments (GtkTextView *text_view, if (text_view->vadjustment != vadj) { text_view->vadjustment = vadj; - gtk_object_ref (GTK_OBJECT (text_view->vadjustment)); + g_object_ref (G_OBJECT (text_view->vadjustment)); gtk_object_sink (GTK_OBJECT (text_view->vadjustment)); gtk_signal_connect (GTK_OBJECT (text_view->vadjustment), "value_changed", @@ -4449,7 +4455,7 @@ static void activate_cb (GtkWidget *menuitem, GtkTextView *text_view) { - const gchar *signal = gtk_object_get_data (GTK_OBJECT (menuitem), "gtk-signal"); + const gchar *signal = g_object_get_data (G_OBJECT (menuitem), "gtk-signal"); gtk_signal_emit_by_name (GTK_OBJECT (text_view), signal); } @@ -4461,7 +4467,7 @@ append_action_signal (GtkTextView *text_view, { GtkWidget *menuitem = gtk_menu_item_new_with_label (label); - gtk_object_set_data (GTK_OBJECT (menuitem), "gtk-signal", (char *)signal); + g_object_set_data (G_OBJECT (menuitem), "gtk-signal", (char *)signal); gtk_signal_connect (GTK_OBJECT (menuitem), "activate", activate_cb, text_view); @@ -5282,9 +5288,9 @@ text_view_child_new_anchored (GtkWidget *child, g_object_ref (G_OBJECT (vc->widget)); g_object_ref (G_OBJECT (vc->anchor)); - gtk_object_set_data (GTK_OBJECT (child), - "gtk-text-view-child", - vc); + g_object_set_data (G_OBJECT (child), + "gtk-text-view-child", + vc); gtk_text_child_anchor_register_child (anchor, child, layout); @@ -5319,9 +5325,8 @@ text_view_child_new_window (GtkWidget *child, static void text_view_child_free (GtkTextViewChild *child) { - - gtk_object_remove_data (GTK_OBJECT (child->widget), - "gtk-text-view-child"); + g_object_set_data (G_OBJECT (child->widget), + "gtk-text-view-child", NULL); if (child->anchor) { @@ -5429,8 +5434,8 @@ gtk_text_view_move_child (GtkTextView *text_view, g_return_if_fail (ypos >= 0); g_return_if_fail (child->parent == (GtkWidget*) text_view); - vc = gtk_object_get_data (GTK_OBJECT (child), - "gtk-text-view-child"); + vc = g_object_get_data (G_OBJECT (child), + "gtk-text-view-child"); g_assert (vc != NULL); diff --git a/gtk/testtext.c b/gtk/testtext.c index 50da85b6d2..4cdfbb3f75 100644 --- a/gtk/testtext.c +++ b/gtk/testtext.c @@ -73,7 +73,7 @@ GSList *views = NULL; static void push_active_window (GtkWindow *window) { - gtk_object_ref (GTK_OBJECT (window)); + g_object_ref (G_OBJECT (window)); active_window_stack = g_slist_prepend (active_window_stack, window); } @@ -102,9 +102,9 @@ typedef gboolean (*FileselOKFunc) (const char *filename, gpointer data); static void filesel_ok_cb (GtkWidget *button, GtkWidget *filesel) { - FileselOKFunc ok_func = gtk_object_get_data (GTK_OBJECT (filesel), "ok-func"); - gpointer data = gtk_object_get_data (GTK_OBJECT (filesel), "ok-data"); - gint *result = gtk_object_get_data (GTK_OBJECT (filesel), "ok-result"); + FileselOKFunc ok_func = g_object_get_data (G_OBJECT (filesel), "ok-func"); + gpointer data = g_object_get_data (G_OBJECT (filesel), "ok-data"); + gint *result = g_object_get_data (G_OBJECT (filesel), "ok-result"); gtk_widget_hide (filesel); @@ -137,9 +137,9 @@ filesel_run (GtkWindow *parent, gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), start_file); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-func", func); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-data", data); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-result", &result); + g_object_set_data (G_OBJECT (filesel), "ok-func", func); + g_object_set_data (G_OBJECT (filesel), "ok-data", data); + g_object_set_data (G_OBJECT (filesel), "ok-result", &result); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked", @@ -314,7 +314,7 @@ blink_timeout (gpointer data) tag = GTK_TEXT_TAG (data); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "foreground", flip ? "blue" : "purple", NULL); @@ -388,11 +388,10 @@ tag_event_handler (GtkTextTag *tag, GtkWidget *widget, GdkEvent *event, static void setup_tag (GtkTextTag *tag) { - - gtk_signal_connect (GTK_OBJECT (tag), - "event", - GTK_SIGNAL_FUNC (tag_event_handler), - NULL); + g_signal_connect_data (G_OBJECT (tag), + "event", + tag_event_handler, + NULL, NULL, FALSE, FALSE); } static char *book_closed_xpm[] = { @@ -447,7 +446,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color2.red = 0xfff; color2.blue = 0x0; color2.green = 0; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "foreground_gdk", &color, "background_gdk", &color2, "size_points", 24.0, @@ -459,7 +458,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color.blue = color.green = 0; color.red = 0xffff; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "rise", -4 * PANGO_SCALE, "foreground_gdk", &color, NULL); @@ -470,7 +469,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color.blue = color.red = 0; color.green = 0xffff; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "background_gdk", &color, "size_points", 10.0, NULL); @@ -479,7 +478,7 @@ fill_example_buffer (GtkTextBuffer *buffer) setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "strikethrough", TRUE, NULL); @@ -488,25 +487,25 @@ fill_example_buffer (GtkTextBuffer *buffer) setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "underline", PANGO_UNDERLINE_SINGLE, NULL); setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "underline", PANGO_UNDERLINE_SINGLE, NULL); tag = gtk_text_buffer_create_tag (buffer, "centered"); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "justify", GTK_JUSTIFY_CENTER, NULL); tag = gtk_text_buffer_create_tag (buffer, "rtl_quote"); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "wrap_mode", GTK_WRAPMODE_WORD, "direction", GTK_TEXT_DIR_RTL, "indent", 30, @@ -708,12 +707,12 @@ view_from_widget (GtkWidget *widget) if (GTK_IS_MENU_ITEM (widget)) { GtkItemFactory *item_factory = gtk_item_factory_from_widget (widget); - return gtk_object_get_data (GTK_OBJECT (item_factory), "view"); + return g_object_get_data (G_OBJECT (item_factory), "view"); } else { GtkWidget *app = gtk_widget_get_toplevel (widget); - return gtk_object_get_data (GTK_OBJECT (app), "view"); + return g_object_get_data (G_OBJECT (app), "view"); } } @@ -1089,7 +1088,7 @@ dialog_response_callback (GtkWidget *dialog, gint response_id, gpointer data) return; } - buffer = gtk_object_get_data (GTK_OBJECT (dialog), "buffer"); + buffer = g_object_get_data (G_OBJECT (dialog), "buffer"); gtk_text_buffer_get_bounds (buffer, &start, &end); @@ -1139,7 +1138,7 @@ do_search (gpointer callback_data, search_text, TRUE, TRUE, 0); - gtk_object_set_data (GTK_OBJECT (dialog), "buffer", buffer); + g_object_set_data (G_OBJECT (dialog), "buffer", buffer); gtk_signal_connect (GTK_OBJECT (dialog), "response", @@ -1419,17 +1418,17 @@ create_buffer (void) } buffer->invisible_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->invisible_tag), + g_object_set (G_OBJECT (buffer->invisible_tag), "invisible", TRUE, NULL); buffer->not_editable_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->not_editable_tag), + g_object_set (G_OBJECT (buffer->not_editable_tag), "editable", FALSE, "foreground", "purple", NULL); buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->found_text_tag), + g_object_set (G_OBJECT (buffer->found_text_tag), "foreground", "red", NULL); tabs = pango_tab_array_new_with_positions (4, @@ -1440,7 +1439,7 @@ create_buffer (void) PANGO_TAB_LEFT, 120); buffer->custom_tabs_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->custom_tabs_tag), + g_object_set (G_OBJECT (buffer->custom_tabs_tag), "tabs", tabs, "foreground", "green", NULL); @@ -1588,7 +1587,7 @@ buffer_unref (Buffer *buffer) { buffer_set_colors (buffer, FALSE); buffers = g_slist_remove (buffers, buffer); - gtk_object_unref (GTK_OBJECT (buffer->buffer)); + g_object_unref (G_OBJECT (buffer->buffer)); g_free (buffer->filename); g_free (buffer); } @@ -1720,12 +1719,12 @@ buffer_set_colors (Buffer *buffer, hue_to_color (hue, &color); - gtk_object_set (GTK_OBJECT (tmp->data), + g_object_set (G_OBJECT (tmp->data), "foreground_gdk", &color, NULL); } else - gtk_object_set (GTK_OBJECT (tmp->data), + g_object_set (G_OBJECT (tmp->data), "foreground_set", FALSE, NULL); @@ -1748,9 +1747,9 @@ buffer_cycle_colors (Buffer *buffer) hue_to_color (hue, &color); - gtk_object_set (GTK_OBJECT (tmp->data), - "foreground_gdk", &color, - NULL); + g_object_set (G_OBJECT (tmp->data), + "foreground_gdk", &color, + NULL); hue += 1.0 / N_COLORS; if (hue > 1.0) @@ -2114,14 +2113,14 @@ create_view (Buffer *buffer) buffer_ref (buffer); view->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (view->window), "view", view); + g_object_set_data (G_OBJECT (view->window), "view", view); gtk_signal_connect (GTK_OBJECT (view->window), "delete_event", GTK_SIGNAL_FUNC (delete_event_cb), NULL); view->accel_group = gtk_accel_group_new (); view->item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", view->accel_group); - gtk_object_set_data (GTK_OBJECT (view->item_factory), "view", view); + g_object_set_data (G_OBJECT (view->item_factory), "view", view); gtk_item_factory_create_items (view->item_factory, G_N_ELEMENTS (menu_items), menu_items, view); @@ -2158,10 +2157,10 @@ create_view (Buffer *buffer) GTK_SIGNAL_FUNC (tab_stops_expose), NULL); - gtk_signal_connect (GTK_OBJECT (view->buffer->buffer), - "mark_set", - GTK_SIGNAL_FUNC (cursor_set_callback), - view->text_view); + g_signal_connect_data (G_OBJECT (view->buffer->buffer), + "mark_set", + GTK_SIGNAL_FUNC (cursor_set_callback), + view->text_view, NULL, FALSE, FALSE); /* Draw line numbers in the side windows; we should really be * more scientific about what width we set them to. @@ -2205,8 +2204,8 @@ view_add_example_widgets (View *view) buffer = view->buffer; - anchor = gtk_object_get_data (GTK_OBJECT (buffer->buffer), - "anchor"); + anchor = g_object_get_data (G_OBJECT (buffer->buffer), + "anchor"); if (anchor && !gtk_text_child_anchor_get_deleted (anchor)) { diff --git a/gtk/testtextbuffer.c b/gtk/testtextbuffer.c index e981ce9547..f41e2f5a2f 100644 --- a/gtk/testtextbuffer.c +++ b/gtk/testtextbuffer.c @@ -592,29 +592,29 @@ fill_buffer (GtkTextBuffer *buffer) color2.red = 0xfff; color2.blue = 0x0; color2.green = 0; - gtk_object_set (GTK_OBJECT (tag), - "foreground_gdk", &color, - "background_gdk", &color2, - "font", "-*-courier-bold-r-*-*-30-*-*-*-*-*-*-*", - NULL); + g_object_set (G_OBJECT (tag), + "foreground_gdk", &color, + "background_gdk", &color2, + "font", "-*-courier-bold-r-*-*-30-*-*-*-*-*-*-*", + NULL); tag = gtk_text_buffer_create_tag (buffer, "fg_red"); color.blue = color.green = 0; color.red = 0xffff; - gtk_object_set (GTK_OBJECT (tag), - "rise", -4, - "foreground_gdk", &color, - NULL); + g_object_set (GTK_OBJECT (tag), + "rise", -4, + "foreground_gdk", &color, + NULL); tag = gtk_text_buffer_create_tag (buffer, "bg_green"); color.blue = color.red = 0; color.green = 0xffff; - gtk_object_set (GTK_OBJECT (tag), - "background_gdk", &color, - "font", "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-*", - NULL); + g_object_set (G_OBJECT (tag), + "background_gdk", &color, + "font", "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-*", + NULL); pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm); diff --git a/tests/testtext.c b/tests/testtext.c index 50da85b6d2..4cdfbb3f75 100644 --- a/tests/testtext.c +++ b/tests/testtext.c @@ -73,7 +73,7 @@ GSList *views = NULL; static void push_active_window (GtkWindow *window) { - gtk_object_ref (GTK_OBJECT (window)); + g_object_ref (G_OBJECT (window)); active_window_stack = g_slist_prepend (active_window_stack, window); } @@ -102,9 +102,9 @@ typedef gboolean (*FileselOKFunc) (const char *filename, gpointer data); static void filesel_ok_cb (GtkWidget *button, GtkWidget *filesel) { - FileselOKFunc ok_func = gtk_object_get_data (GTK_OBJECT (filesel), "ok-func"); - gpointer data = gtk_object_get_data (GTK_OBJECT (filesel), "ok-data"); - gint *result = gtk_object_get_data (GTK_OBJECT (filesel), "ok-result"); + FileselOKFunc ok_func = g_object_get_data (G_OBJECT (filesel), "ok-func"); + gpointer data = g_object_get_data (G_OBJECT (filesel), "ok-data"); + gint *result = g_object_get_data (G_OBJECT (filesel), "ok-result"); gtk_widget_hide (filesel); @@ -137,9 +137,9 @@ filesel_run (GtkWindow *parent, gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), start_file); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-func", func); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-data", data); - gtk_object_set_data (GTK_OBJECT (filesel), "ok-result", &result); + g_object_set_data (G_OBJECT (filesel), "ok-func", func); + g_object_set_data (G_OBJECT (filesel), "ok-data", data); + g_object_set_data (G_OBJECT (filesel), "ok-result", &result); gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked", @@ -314,7 +314,7 @@ blink_timeout (gpointer data) tag = GTK_TEXT_TAG (data); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "foreground", flip ? "blue" : "purple", NULL); @@ -388,11 +388,10 @@ tag_event_handler (GtkTextTag *tag, GtkWidget *widget, GdkEvent *event, static void setup_tag (GtkTextTag *tag) { - - gtk_signal_connect (GTK_OBJECT (tag), - "event", - GTK_SIGNAL_FUNC (tag_event_handler), - NULL); + g_signal_connect_data (G_OBJECT (tag), + "event", + tag_event_handler, + NULL, NULL, FALSE, FALSE); } static char *book_closed_xpm[] = { @@ -447,7 +446,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color2.red = 0xfff; color2.blue = 0x0; color2.green = 0; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "foreground_gdk", &color, "background_gdk", &color2, "size_points", 24.0, @@ -459,7 +458,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color.blue = color.green = 0; color.red = 0xffff; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "rise", -4 * PANGO_SCALE, "foreground_gdk", &color, NULL); @@ -470,7 +469,7 @@ fill_example_buffer (GtkTextBuffer *buffer) color.blue = color.red = 0; color.green = 0xffff; - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "background_gdk", &color, "size_points", 10.0, NULL); @@ -479,7 +478,7 @@ fill_example_buffer (GtkTextBuffer *buffer) setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "strikethrough", TRUE, NULL); @@ -488,25 +487,25 @@ fill_example_buffer (GtkTextBuffer *buffer) setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "underline", PANGO_UNDERLINE_SINGLE, NULL); setup_tag (tag); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "underline", PANGO_UNDERLINE_SINGLE, NULL); tag = gtk_text_buffer_create_tag (buffer, "centered"); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "justify", GTK_JUSTIFY_CENTER, NULL); tag = gtk_text_buffer_create_tag (buffer, "rtl_quote"); - gtk_object_set (GTK_OBJECT (tag), + g_object_set (G_OBJECT (tag), "wrap_mode", GTK_WRAPMODE_WORD, "direction", GTK_TEXT_DIR_RTL, "indent", 30, @@ -708,12 +707,12 @@ view_from_widget (GtkWidget *widget) if (GTK_IS_MENU_ITEM (widget)) { GtkItemFactory *item_factory = gtk_item_factory_from_widget (widget); - return gtk_object_get_data (GTK_OBJECT (item_factory), "view"); + return g_object_get_data (G_OBJECT (item_factory), "view"); } else { GtkWidget *app = gtk_widget_get_toplevel (widget); - return gtk_object_get_data (GTK_OBJECT (app), "view"); + return g_object_get_data (G_OBJECT (app), "view"); } } @@ -1089,7 +1088,7 @@ dialog_response_callback (GtkWidget *dialog, gint response_id, gpointer data) return; } - buffer = gtk_object_get_data (GTK_OBJECT (dialog), "buffer"); + buffer = g_object_get_data (G_OBJECT (dialog), "buffer"); gtk_text_buffer_get_bounds (buffer, &start, &end); @@ -1139,7 +1138,7 @@ do_search (gpointer callback_data, search_text, TRUE, TRUE, 0); - gtk_object_set_data (GTK_OBJECT (dialog), "buffer", buffer); + g_object_set_data (G_OBJECT (dialog), "buffer", buffer); gtk_signal_connect (GTK_OBJECT (dialog), "response", @@ -1419,17 +1418,17 @@ create_buffer (void) } buffer->invisible_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->invisible_tag), + g_object_set (G_OBJECT (buffer->invisible_tag), "invisible", TRUE, NULL); buffer->not_editable_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->not_editable_tag), + g_object_set (G_OBJECT (buffer->not_editable_tag), "editable", FALSE, "foreground", "purple", NULL); buffer->found_text_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->found_text_tag), + g_object_set (G_OBJECT (buffer->found_text_tag), "foreground", "red", NULL); tabs = pango_tab_array_new_with_positions (4, @@ -1440,7 +1439,7 @@ create_buffer (void) PANGO_TAB_LEFT, 120); buffer->custom_tabs_tag = gtk_text_buffer_create_tag (buffer->buffer, NULL); - gtk_object_set (GTK_OBJECT (buffer->custom_tabs_tag), + g_object_set (G_OBJECT (buffer->custom_tabs_tag), "tabs", tabs, "foreground", "green", NULL); @@ -1588,7 +1587,7 @@ buffer_unref (Buffer *buffer) { buffer_set_colors (buffer, FALSE); buffers = g_slist_remove (buffers, buffer); - gtk_object_unref (GTK_OBJECT (buffer->buffer)); + g_object_unref (G_OBJECT (buffer->buffer)); g_free (buffer->filename); g_free (buffer); } @@ -1720,12 +1719,12 @@ buffer_set_colors (Buffer *buffer, hue_to_color (hue, &color); - gtk_object_set (GTK_OBJECT (tmp->data), + g_object_set (G_OBJECT (tmp->data), "foreground_gdk", &color, NULL); } else - gtk_object_set (GTK_OBJECT (tmp->data), + g_object_set (G_OBJECT (tmp->data), "foreground_set", FALSE, NULL); @@ -1748,9 +1747,9 @@ buffer_cycle_colors (Buffer *buffer) hue_to_color (hue, &color); - gtk_object_set (GTK_OBJECT (tmp->data), - "foreground_gdk", &color, - NULL); + g_object_set (G_OBJECT (tmp->data), + "foreground_gdk", &color, + NULL); hue += 1.0 / N_COLORS; if (hue > 1.0) @@ -2114,14 +2113,14 @@ create_view (Buffer *buffer) buffer_ref (buffer); view->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_object_set_data (GTK_OBJECT (view->window), "view", view); + g_object_set_data (G_OBJECT (view->window), "view", view); gtk_signal_connect (GTK_OBJECT (view->window), "delete_event", GTK_SIGNAL_FUNC (delete_event_cb), NULL); view->accel_group = gtk_accel_group_new (); view->item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", view->accel_group); - gtk_object_set_data (GTK_OBJECT (view->item_factory), "view", view); + g_object_set_data (G_OBJECT (view->item_factory), "view", view); gtk_item_factory_create_items (view->item_factory, G_N_ELEMENTS (menu_items), menu_items, view); @@ -2158,10 +2157,10 @@ create_view (Buffer *buffer) GTK_SIGNAL_FUNC (tab_stops_expose), NULL); - gtk_signal_connect (GTK_OBJECT (view->buffer->buffer), - "mark_set", - GTK_SIGNAL_FUNC (cursor_set_callback), - view->text_view); + g_signal_connect_data (G_OBJECT (view->buffer->buffer), + "mark_set", + GTK_SIGNAL_FUNC (cursor_set_callback), + view->text_view, NULL, FALSE, FALSE); /* Draw line numbers in the side windows; we should really be * more scientific about what width we set them to. @@ -2205,8 +2204,8 @@ view_add_example_widgets (View *view) buffer = view->buffer; - anchor = gtk_object_get_data (GTK_OBJECT (buffer->buffer), - "anchor"); + anchor = g_object_get_data (G_OBJECT (buffer->buffer), + "anchor"); if (anchor && !gtk_text_child_anchor_get_deleted (anchor)) { diff --git a/tests/testtextbuffer.c b/tests/testtextbuffer.c index e981ce9547..f41e2f5a2f 100644 --- a/tests/testtextbuffer.c +++ b/tests/testtextbuffer.c @@ -592,29 +592,29 @@ fill_buffer (GtkTextBuffer *buffer) color2.red = 0xfff; color2.blue = 0x0; color2.green = 0; - gtk_object_set (GTK_OBJECT (tag), - "foreground_gdk", &color, - "background_gdk", &color2, - "font", "-*-courier-bold-r-*-*-30-*-*-*-*-*-*-*", - NULL); + g_object_set (G_OBJECT (tag), + "foreground_gdk", &color, + "background_gdk", &color2, + "font", "-*-courier-bold-r-*-*-30-*-*-*-*-*-*-*", + NULL); tag = gtk_text_buffer_create_tag (buffer, "fg_red"); color.blue = color.green = 0; color.red = 0xffff; - gtk_object_set (GTK_OBJECT (tag), - "rise", -4, - "foreground_gdk", &color, - NULL); + g_object_set (GTK_OBJECT (tag), + "rise", -4, + "foreground_gdk", &color, + NULL); tag = gtk_text_buffer_create_tag (buffer, "bg_green"); color.blue = color.red = 0; color.green = 0xffff; - gtk_object_set (GTK_OBJECT (tag), - "background_gdk", &color, - "font", "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-*", - NULL); + g_object_set (G_OBJECT (tag), + "background_gdk", &color, + "font", "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-*", + NULL); pixbuf = gdk_pixbuf_new_from_xpm_data (book_closed_xpm); |