Пример #1
0
static void
populate_popup (GtkTextView *textview, GtkMenu *menu, GeditAutomaticSpellChecker *spell)
{
	GtkWidget *img, *mi;
	GtkTextIter start, end;
	char *word;

	/* we need to figure out if they picked a misspelled word. */
	get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);

	/* if our highlight algorithm ever messes up,
	 * this isn't correct, either. */
	if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
		return; /* word wasn't misspelled. */

	/* menu separator comes first. */
	mi = gtk_separator_menu_item_new ();
	gtk_widget_show (mi);
	gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);

	/* then, on top of it, the suggestions menu. */
	img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
	mi = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions..."));
	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);

	word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);
	gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi),
				   build_suggestion_menu (spell, word));
	g_free(word);

	gtk_widget_show_all (mi);
	gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
}
Пример #2
0
static void
replace_word (GtkWidget *menuitem, GeditAutomaticSpellChecker *spell)
{
	gchar *oldword;
	const gchar *newword;

	GtkTextIter start, end;

	get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);

	oldword = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), &start, &end, FALSE);

	newword =  g_object_get_qdata (G_OBJECT (menuitem), suggestion_id);
	g_return_if_fail (newword != NULL);

	gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (spell->doc));

	gtk_text_buffer_delete (GTK_TEXT_BUFFER (spell->doc), &start, &end);
	gtk_text_buffer_insert (GTK_TEXT_BUFFER (spell->doc), &start, newword, -1);

	gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (spell->doc));

	gedit_spell_checker_set_correction (spell->spell_checker,
				oldword, strlen (oldword),
				newword, strlen (newword));

	g_free (oldword);
}
Пример #3
0
static void
ignore_all (GtkWidget *menuitem, GeditAutomaticSpellChecker *spell)
{
	gchar *word;

	GtkTextIter start, end;

	get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);

	word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc),
					 &start,
					 &end,
					 FALSE);

	gedit_spell_checker_add_word_to_session (spell->spell_checker, word, -1);

	g_free (word);
}
static void
add_to_dictionary (GtkWidget *menuitem, PlumaAutomaticSpellChecker *spell) 
{
	gchar *word;
	
	GtkTextIter start, end;
	
	get_word_extents_from_mark (GTK_TEXT_BUFFER (spell->doc), &start, &end, spell->mark_click);	

	word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), 
					 &start, 
					 &end, 
					 FALSE);
	
	pluma_spell_checker_add_word_to_personal (spell->spell_checker, word, -1);

	g_free (word);
}