static void tag_table_changed (GtkTextTagTable *table, GeditAutomaticSpellChecker *spell) { g_return_if_fail (spell->tag_highlight != NULL); gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (table) - 1); }
static void set_priority_tags (int id, gint priority) { GtkTextTag *tag; int i, p; p = priority; for (i = 0; i < HIGHLIGHT_MATCHES; i++) { tag = gtk_text_tag_table_lookup (highlight_tag_table, mangle_name (id, i)); if (tag != NULL) { if (p != priority + i) { debug ("Missing a tag\n"); } gtk_text_tag_set_priority (tag, p); } } }
static void highlight_add_tag (const char *name, const GdkRGBA *text, const GdkRGBA *background, const char *font) { GtkTextTag *tag; g_assert (highlight_tag_table != NULL); tag = gtk_text_tag_table_lookup (highlight_tag_table, name); g_assert (tag == NULL); tag = gtk_text_tag_new (name); g_object_set (G_OBJECT (tag), "foreground-rgba", text, "background-rgba", background, "font", font, NULL); gtk_text_tag_table_add (highlight_tag_table, tag); gtk_text_tag_set_priority (tag, next_priority); next_priority++; }
GeditAutomaticSpellChecker * gedit_automatic_spell_checker_new (GeditDocument *doc, GeditSpellChecker *checker) { GeditAutomaticSpellChecker *spell; GtkTextTagTable *tag_table; GtkTextIter start, end; g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL); g_return_val_if_fail (GEDIT_IS_SPELL_CHECKER (checker), NULL); g_return_val_if_fail ((spell = gedit_automatic_spell_checker_get_from_document (doc)) == NULL, spell); /* attach to the widget */ spell = g_new0 (GeditAutomaticSpellChecker, 1); spell->doc = doc; spell->spell_checker = g_object_ref (checker); if (automatic_spell_checker_id == 0) { automatic_spell_checker_id = g_quark_from_string ("GeditAutomaticSpellCheckerID"); } if (suggestion_id == 0) { suggestion_id = g_quark_from_string ("GeditAutoSuggestionID"); } g_object_set_qdata_full (G_OBJECT (doc), automatic_spell_checker_id, spell, (GDestroyNotify)gedit_automatic_spell_checker_free_internal); g_signal_connect (doc, "insert-text", G_CALLBACK (insert_text_before), spell); g_signal_connect_after (doc, "insert-text", G_CALLBACK (insert_text_after), spell); g_signal_connect_after (doc, "delete-range", G_CALLBACK (delete_range_after), spell); g_signal_connect (doc, "mark-set", G_CALLBACK (mark_set), spell); g_signal_connect (doc, "highlight-updated", G_CALLBACK (highlight_updated), spell); g_signal_connect (spell->spell_checker, "add_word_to_session", G_CALLBACK (add_word_signal_cb), spell); g_signal_connect (spell->spell_checker, "add_word_to_personal", G_CALLBACK (add_word_signal_cb), spell); g_signal_connect (spell->spell_checker, "clear_session", G_CALLBACK (clear_session_cb), spell); g_signal_connect (spell->spell_checker, "set_language", G_CALLBACK (set_language_cb), spell); spell->tag_highlight = gtk_text_buffer_create_tag ( GTK_TEXT_BUFFER (doc), "gtkspell-misspelled", "underline", PANGO_UNDERLINE_ERROR, NULL); g_object_weak_ref (G_OBJECT (spell->tag_highlight), (GWeakNotify)spell_tag_destroyed, spell); tag_table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (doc)); gtk_text_tag_set_priority (spell->tag_highlight, gtk_text_tag_table_get_size (tag_table) - 1); g_signal_connect (tag_table, "tag-added", G_CALLBACK (tag_added_or_removed), spell); g_signal_connect (tag_table, "tag-removed", G_CALLBACK (tag_added_or_removed), spell); g_signal_connect (tag_table, "tag-changed", G_CALLBACK (tag_changed), spell); /* we create the mark here, but we don't use it until text is * inserted, so we don't really care where iter points. */ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc), &start, &end); spell->mark_insert_start = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-insert-start"); if (spell->mark_insert_start == NULL) { spell->mark_insert_start = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-insert-start", &start, TRUE); } else { gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_start, &start); } spell->mark_insert_end = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-insert-end"); if (spell->mark_insert_end == NULL) { spell->mark_insert_end = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-insert-end", &start, TRUE); } else { gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_insert_end, &start); } spell->mark_click = gtk_text_buffer_get_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-click"); if (spell->mark_click == NULL) { spell->mark_click = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (doc), "gedit-automatic-spell-checker-click", &start, TRUE); } else { gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (doc), spell->mark_click, &start); } spell->deferred_check = FALSE; return spell; }
static VALUE rg_set_priority(VALUE self, VALUE priority) { gtk_text_tag_set_priority(RVAL2GTKTEXTTAG(self), NUM2INT(priority)); return priority; }
static VALUE set_priority(VALUE self, VALUE priority) { gtk_text_tag_set_priority(GTK_TEXT_TAG(RVAL2GOBJ(self)), NUM2INT(priority)); return priority; }