Revision: 1060 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1060&view=re... Author: eht16 Date: 2009-11-28 13:55:04 +0000 (Sat, 28 Nov 2009)
Log Message: ----------- Prevent looking for very long search terms which most probably will fail anyway.
Modified Paths: -------------- trunk/geany-plugins/spellcheck/ChangeLog trunk/geany-plugins/spellcheck/src/gui.c
Modified: trunk/geany-plugins/spellcheck/ChangeLog =================================================================== --- trunk/geany-plugins/spellcheck/ChangeLog 2009-11-28 13:12:12 UTC (rev 1059) +++ trunk/geany-plugins/spellcheck/ChangeLog 2009-11-28 13:55:04 UTC (rev 1060) @@ -5,6 +5,9 @@ * src/gui.c, src/scplugin.c, src/scplugin.h: Add an option to make the editor menu items for Spelling Suggestions optional. + * src/gui.c: + Prevent looking for very long search terms which most probably + will fail anyway.
2009-09-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany-plugins/spellcheck/src/gui.c =================================================================== --- trunk/geany-plugins/spellcheck/src/gui.c 2009-11-28 13:12:12 UTC (rev 1059) +++ trunk/geany-plugins/spellcheck/src/gui.c 2009-11-28 13:55:04 UTC (rev 1060) @@ -202,6 +202,22 @@ }
+static GtkWidget *init_editor_submenu(void) +{ + if (sc_info->edit_menu_sub != NULL && GTK_IS_WIDGET(sc_info->edit_menu_sub)) + gtk_widget_destroy(sc_info->edit_menu_sub); + + sc_info->edit_menu_sub = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(sc_info->edit_menu), sc_info->edit_menu_sub); + + gtk_widget_show(sc_info->edit_menu); + gtk_widget_show(sc_info->edit_menu_sep); + gtk_widget_show(sc_info->edit_menu_sub); + + return sc_info->edit_menu_sub; +} + + void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer user_data) { @@ -233,6 +249,27 @@ return; }
+ /* ignore too long search words */ + if (strlen(search_word) > 100) + { + gchar *label, *short_search_word; + GtkWidget *menu_item; + + short_search_word = utils_str_middle_truncate(search_word, 30); + label = g_strdup_printf(_("Search term "%s" is too long to check."), short_search_word); + + init_editor_submenu(); + menu_item = gtk_menu_item_new_with_label(label); + gtk_widget_set_sensitive(menu_item, FALSE); + gtk_widget_show(menu_item); + gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); + + g_free(label); + g_free(short_search_word); + g_free(search_word); + return; + } + if (sc_speller_dict_check(search_word) != 0) { GtkWidget *menu_item, *menu; @@ -246,12 +283,8 @@ clickinfo.doc = doc; setptr(clickinfo.word, search_word);
- if (sc_info->edit_menu_sub != NULL && GTK_IS_WIDGET(sc_info->edit_menu_sub)) - gtk_widget_destroy(sc_info->edit_menu_sub); + menu = init_editor_submenu();
- sc_info->edit_menu_sub = menu = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(sc_info->edit_menu), sc_info->edit_menu_sub); - for (i = 0; i < n_suggs; i++) { if (i > 0 && i % 10 == 0) @@ -268,6 +301,7 @@ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), menu); } menu_item = gtk_menu_item_new_with_label(suggs[i]); + gtk_widget_show(menu_item); gtk_container_add(GTK_CONTAINER(menu), menu_item); g_signal_connect(menu_item, "activate", G_CALLBACK(menu_suggestion_item_activate_cb), NULL); @@ -276,26 +310,26 @@ { menu_item = gtk_menu_item_new_with_label(_("(No Suggestions)")); gtk_widget_set_sensitive(menu_item, FALSE); + gtk_widget_show(menu_item); gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); } menu_item = gtk_separator_menu_item_new(); + gtk_widget_show(menu_item); gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item);
label = g_strdup_printf(_("Add "%s" to Dictionary"), search_word); menu_item = image_menu_item_new(GTK_STOCK_ADD, label); + gtk_widget_show(menu_item); gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); g_signal_connect(menu_item, "activate", G_CALLBACK(menu_addword_item_activate_cb), GINT_TO_POINTER(0));
menu_item = image_menu_item_new(GTK_STOCK_REMOVE, _("Ignore All")); + gtk_widget_show(menu_item); gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); g_signal_connect(menu_item, "activate", G_CALLBACK(menu_addword_item_activate_cb), GINT_TO_POINTER(1));
- gtk_widget_show(sc_info->edit_menu); - gtk_widget_show(sc_info->edit_menu_sep); - gtk_widget_show_all(sc_info->edit_menu_sub); - if (suggs != NULL) sc_speller_dict_free_string_list(suggs);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
plugins-commits@lists.geany.org