Revision: 485 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=485&view=rev Author: eht16 Date: 2009-02-17 14:32:18 +0000 (Tue, 17 Feb 2009)
Log Message: ----------- Prefix all non-static functions which sc_ to avoid symbol clashes.
Modified Paths: -------------- trunk/spellcheck/ChangeLog trunk/spellcheck/src/gui.c trunk/spellcheck/src/gui.h trunk/spellcheck/src/scplugin.c trunk/spellcheck/src/scplugin.h trunk/spellcheck/src/speller.c trunk/spellcheck/src/speller.h
Modified: trunk/spellcheck/ChangeLog =================================================================== --- trunk/spellcheck/ChangeLog 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/ChangeLog 2009-02-17 14:32:18 UTC (rev 485) @@ -11,6 +11,9 @@ 'check while typing' feature while not being much slower (if ever). * src/gui.c, src/scplugin.c, src/scplugin.h: Display accelerator on the 'Default' menu item. + * src/gui.c, src/gui.h, src/scplugin.c, src/scplugin.h, src/speller.c, + src/speller.h: + Prefix all non-static functions which sc_ to avoid symbol clashes.
2009-02-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/spellcheck/src/gui.c =================================================================== --- trunk/spellcheck/src/gui.c 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/gui.c 2009-02-17 14:32:18 UTC (rev 485) @@ -60,22 +60,9 @@
-void gui_perform_check(GeanyDocument *doc) -{ - editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR); - if (sc->use_msgwin) - { - msgwin_clear_tab(MSG_MESSAGE); - msgwin_switch_tab(MSG_MESSAGE, FALSE); - } - - speller_check_document(doc); -} - - static void print_typing_changed_message(void) { - if (sc->check_while_typing) + if (sc_info->check_while_typing) ui_set_statusbar(FALSE, _("Spell checking while typing is now enabled")); else ui_set_statusbar(FALSE, _("Spell checking while typing is now disabled")); @@ -87,43 +74,43 @@ if (ignore_sc_callback) return;
- sc->check_while_typing = gtk_toggle_tool_button_get_active(button); + sc_info->check_while_typing = gtk_toggle_tool_button_get_active(button);
print_typing_changed_message();
}
-void gui_toolbar_update(void) +void sc_gui_toolbar_update(void) { /* toolbar item is not requested, so remove the item if it exists */ - if (! sc->show_toolbar_item) + if (! sc_info->show_toolbar_item) { - if (sc->toolbar_button != NULL) + if (sc_info->toolbar_button != NULL) { - gtk_widget_hide(GTK_WIDGET(sc->toolbar_button)); + gtk_widget_hide(GTK_WIDGET(sc_info->toolbar_button)); } } else { - if (sc->toolbar_button == NULL) + if (sc_info->toolbar_button == NULL) { - sc->toolbar_button = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_SPELL_CHECK); + sc_info->toolbar_button = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_SPELL_CHECK); #if GTK_CHECK_VERSION(2, 12, 0) - gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(sc->toolbar_button), + gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(sc_info->toolbar_button), _("Toggle spell check while typing")); #endif - plugin_add_toolbar_item(geany_plugin, sc->toolbar_button); - ui_add_document_sensitive(GTK_WIDGET(sc->toolbar_button)); + plugin_add_toolbar_item(geany_plugin, sc_info->toolbar_button); + ui_add_document_sensitive(GTK_WIDGET(sc_info->toolbar_button));
- g_signal_connect(sc->toolbar_button, "toggled", + g_signal_connect(sc_info->toolbar_button, "toggled", G_CALLBACK(toolbar_item_toggled_cb), NULL); } - gtk_widget_show(GTK_WIDGET(sc->toolbar_button)); + gtk_widget_show(GTK_WIDGET(sc_info->toolbar_button));
ignore_sc_callback = TRUE; gtk_toggle_tool_button_set_active( - GTK_TOGGLE_TOOL_BUTTON(sc->toolbar_button), sc->check_while_typing); + GTK_TOGGLE_TOOL_BUTTON(sc_info->toolbar_button), sc_info->check_while_typing); ignore_sc_callback = FALSE; } } @@ -158,7 +145,7 @@ sci_replace_sel(sci, sugg);
/* store the replacement for future checks */ - speller_store_replacement(word, sugg); + sc_speller_store_replacement(word, sugg);
/* remove indicator */ sci_indicator_clear(sci, startword, endword - startword); @@ -168,7 +155,7 @@ }
-static void on_menu_addword_item_activate(GtkMenuItem *menuitem, gpointer gdata) +static void menu_addword_item_activate_cd(GtkMenuItem *menuitem, gpointer gdata) { gint startword, endword, i, doc_len; ScintillaObject *sci; @@ -181,10 +168,10 @@ /* if we ignore the word, we add it to the current session, to ignore it * also for further checks*/ if (ignore) - speller_add_word_to_session(clickinfo.word); + sc_speller_add_word_to_session(clickinfo.word); /* if we do not ignore the word, we add the word to the personal dictionary */ else - speller_add_word(clickinfo.word); + sc_speller_add_word(clickinfo.word);
/* Remove all indicators on the added/ignored word */ sci = clickinfo.doc->editor->sci; @@ -228,16 +215,16 @@ }
-void gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, - GeanyDocument *doc, gpointer user_data) +void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, + GeanyDocument *doc, gpointer user_data) { gchar *search_word;
g_return_if_fail(doc != NULL && doc->is_valid);
/* hide the submenu in any case, we will reshow it again if we actually found something */ - gtk_widget_hide(sc->edit_menu); - gtk_widget_hide(sc->edit_menu_sep); + gtk_widget_hide(sc_info->edit_menu); + gtk_widget_hide(sc_info->edit_menu_sep);
/* if we have a selection, prefer it over the current word */ if (sci_has_selection(doc->editor->sci)) @@ -250,30 +237,30 @@ search_word = g_strdup(word);
/* ignore numbers or words starting with digits and non-text */ - if (! NZV(search_word) || isdigit(*search_word) || ! speller_is_text(doc, pos)) + if (! NZV(search_word) || isdigit(*search_word) || ! sc_speller_is_text(doc, pos)) { g_free(search_word); return; }
- if (speller_dict_check(search_word) != 0) + if (sc_speller_dict_check(search_word) != 0) { GtkWidget *menu_item, *menu; gchar *label; gsize n_suggs, i; gchar **suggs;
- suggs = speller_dict_suggest(search_word, &n_suggs); + suggs = sc_speller_dict_suggest(search_word, &n_suggs);
clickinfo.pos = pos; clickinfo.doc = doc; setptr(clickinfo.word, search_word);
- if (sc->edit_menu_sub != NULL && GTK_IS_WIDGET(sc->edit_menu_sub)) - gtk_widget_destroy(sc->edit_menu_sub); + if (sc_info->edit_menu_sub != NULL && GTK_IS_WIDGET(sc_info->edit_menu_sub)) + gtk_widget_destroy(sc_info->edit_menu_sub);
- sc->edit_menu_sub = menu = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(sc->edit_menu), sc->edit_menu_sub); + 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++) { @@ -299,28 +286,28 @@ { menu_item = gtk_menu_item_new_with_label(_("(No Suggestions)")); gtk_widget_set_sensitive(menu_item, FALSE); - gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item); + gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); } menu_item = gtk_separator_menu_item_new(); - gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), 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_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item); + gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); g_signal_connect(menu_item, "activate", - G_CALLBACK(on_menu_addword_item_activate), GINT_TO_POINTER(0)); + G_CALLBACK(menu_addword_item_activate_cd), GINT_TO_POINTER(0));
menu_item = image_menu_item_new(GTK_STOCK_REMOVE, _("Ignore All")); - gtk_container_add(GTK_CONTAINER(sc->edit_menu_sub), menu_item); + gtk_container_add(GTK_CONTAINER(sc_info->edit_menu_sub), menu_item); g_signal_connect(menu_item, "activate", - G_CALLBACK(on_menu_addword_item_activate), GINT_TO_POINTER(1)); + G_CALLBACK(menu_addword_item_activate_cd), GINT_TO_POINTER(1));
- gtk_widget_show(sc->edit_menu); - gtk_widget_show(sc->edit_menu_sep); - gtk_widget_show_all(sc->edit_menu_sub); + 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) - speller_dict_free_string_list(suggs); + sc_speller_dict_free_string_list(suggs);
g_free(label); } @@ -338,12 +325,12 @@ }
-gboolean gui_editor_notify_cb(GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer data) +gboolean sc_gui_editor_notify_cb(GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer data) { gint start_pos, end_pos, pos; gchar *word;
- if (! sc->check_while_typing || nt->nmhdr.code != SCN_MODIFIED || + if (! sc_info->check_while_typing || nt->nmhdr.code != SCN_MODIFIED || ! (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))) { return FALSE; @@ -360,9 +347,9 @@ end_pos = start_pos + strlen(word);
indicator_clear_on_range(editor, start_pos, end_pos - start_pos); - if (speller_check_word(editor->document, -1, word, start_pos, end_pos) != 0) + if (sc_speller_check_word(editor->document, -1, word, start_pos, end_pos) != 0) { - if (sc->use_msgwin) + if (sc_info->use_msgwin) msgwin_switch_tab(MSG_MESSAGE, FALSE); }
@@ -380,52 +367,52 @@
/* Another language was chosen from the menu item, so make it default for this session. */ if (gdata != NULL) - setptr(sc->default_language, g_strdup(gdata)); + setptr(sc_info->default_language, g_strdup(gdata));
- speller_reinit_enchant_dict(); + sc_speller_reinit_enchant_dict();
editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR); - if (sc->use_msgwin) + if (sc_info->use_msgwin) { msgwin_clear_tab(MSG_MESSAGE); msgwin_switch_tab(MSG_MESSAGE, FALSE); }
- speller_check_document(doc); + sc_speller_check_document(doc); }
-void gui_kb_run_activate_cb(guint key_id) +void sc_gui_kb_run_activate_cb(guint key_id) { menu_item_activate_cb(NULL, NULL); }
-void gui_kb_toggle_typing_activate_cb(guint key_id) +void sc_gui_kb_toggle_typing_activate_cb(guint key_id) { - sc->check_while_typing = ! sc->check_while_typing; + sc_info->check_while_typing = ! sc_info->check_while_typing;
print_typing_changed_message();
- gui_toolbar_update(); + sc_gui_toolbar_update(); }
-void gui_create_edit_menu(void) +void sc_gui_create_edit_menu(void) { - sc->edit_menu = ui_image_menu_item_new(GTK_STOCK_SPELL_CHECK, _("Spelling Suggestions")); - gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc->edit_menu); - gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc->edit_menu, 0); + sc_info->edit_menu = ui_image_menu_item_new(GTK_STOCK_SPELL_CHECK, _("Spelling Suggestions")); + gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc_info->edit_menu); + gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc_info->edit_menu, 0);
- sc->edit_menu_sep = gtk_separator_menu_item_new(); - gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc->edit_menu_sep); - gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc->edit_menu_sep, 1); + sc_info->edit_menu_sep = gtk_separator_menu_item_new(); + gtk_container_add(GTK_CONTAINER(geany->main_widgets->editor_menu), sc_info->edit_menu_sep); + gtk_menu_reorder_child(GTK_MENU(geany->main_widgets->editor_menu), sc_info->edit_menu_sep, 1);
- gtk_widget_show_all(sc->edit_menu); + gtk_widget_show_all(sc_info->edit_menu); }
-GtkWidget *gui_create_menu(GtkWidget *sp_item) +GtkWidget *sc_gui_create_menu(GtkWidget *sp_item) { GtkWidget *menu, *menu_item; guint i; @@ -435,32 +422,32 @@ menu = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(sp_item), menu);
- sc->submenu_item_default = gtk_menu_item_new_with_mnemonic(_("Default")); - gtk_container_add(GTK_CONTAINER(menu), sc->submenu_item_default); - g_signal_connect(sc->submenu_item_default, "activate", G_CALLBACK(menu_item_activate_cb), NULL); + sc_info->submenu_item_default = gtk_menu_item_new_with_mnemonic(_("Default")); + gtk_container_add(GTK_CONTAINER(menu), sc_info->submenu_item_default); + g_signal_connect(sc_info->submenu_item_default, "activate", G_CALLBACK(menu_item_activate_cb), NULL);
menu_item = gtk_separator_menu_item_new(); gtk_container_add(GTK_CONTAINER(menu), menu_item);
- for (i = 0; i < sc->dicts->len; i++) + for (i = 0; i < sc_info->dicts->len; i++) { - menu_item = gtk_menu_item_new_with_label(g_ptr_array_index(sc->dicts, i)); + menu_item = gtk_menu_item_new_with_label(g_ptr_array_index(sc_info->dicts, i)); gtk_container_add(GTK_CONTAINER(menu), menu_item); g_signal_connect(menu_item, "activate", - G_CALLBACK(menu_item_activate_cb), g_ptr_array_index(sc->dicts, i)); + G_CALLBACK(menu_item_activate_cb), g_ptr_array_index(sc_info->dicts, i)); }
return sp_item; }
-void gui_init(void) +void sc_gui_init(void) { clickinfo.word = NULL; }
-void gui_free(void) +void sc_gui_free(void) { g_free(clickinfo.word); }
Modified: trunk/spellcheck/src/gui.h =================================================================== --- trunk/spellcheck/src/gui.h 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/gui.h 2009-02-17 14:32:18 UTC (rev 485) @@ -28,28 +28,29 @@
-void gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, +void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer user_data);
-gboolean gui_key_release_cb(GtkWidget *widget, GdkEventKey *ev, gpointer user_data); +gboolean sc_gui_key_release_cb(GtkWidget *widget, GdkEventKey *ev, gpointer user_data);
-gboolean gui_editor_notify_cb(GObject *obj, GeanyEditor *editor, SCNotification *nt, gpointer data); +gboolean sc_gui_editor_notify_cb(GObject *obj, GeanyEditor *editor, + SCNotification *nt, gpointer data);
-void gui_kb_run_activate_cb(guint key_id); +void sc_gui_kb_run_activate_cb(guint key_id);
-void gui_kb_toggle_typing_activate_cb(guint key_id); +void sc_gui_kb_toggle_typing_activate_cb(guint key_id);
-void gui_create_edit_menu(void); +void sc_gui_create_edit_menu(void);
-GtkWidget *gui_create_menu(GtkWidget *sp_item); +GtkWidget *sc_gui_create_menu(GtkWidget *sp_item);
-void gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, +void sc_gui_update_editor_menu_cb(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, gpointer user_data);
-void gui_toolbar_update(void); +void sc_gui_toolbar_update(void);
-void gui_init(void); +void sc_gui_init(void);
-void gui_free(void); +void sc_gui_free(void);
#endif
Modified: trunk/spellcheck/src/scplugin.c =================================================================== --- trunk/spellcheck/src/scplugin.c 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/scplugin.c 2009-02-17 14:32:18 UTC (rev 485) @@ -60,7 +60,7 @@ _("The Geany developer team"))
-SpellCheck *sc = NULL; +SpellCheck *sc_info = NULL;
@@ -78,8 +78,8 @@
PluginCallback plugin_callbacks[] = { - { "update-editor-menu", (GCallback) &gui_update_editor_menu_cb, FALSE, NULL }, - { "editor-notify", (GCallback) &gui_editor_notify_cb, TRUE, NULL }, + { "update-editor-menu", (GCallback) &sc_gui_update_editor_menu_cb, FALSE, NULL }, + { "editor-notify", (GCallback) &sc_gui_editor_notify_cb, TRUE, NULL }, { NULL, NULL, FALSE, NULL } };
@@ -113,29 +113,29 @@ { GKeyFile *config = g_key_file_new(); gchar *data; - gchar *config_dir = g_path_get_dirname(sc->config_file); + gchar *config_dir = g_path_get_dirname(sc_info->config_file);
- setptr(sc->default_language, gtk_combo_box_get_active_text(GTK_COMBO_BOX( + setptr(sc_info->default_language, gtk_combo_box_get_active_text(GTK_COMBO_BOX( g_object_get_data(G_OBJECT(dialog), "combo")))); - speller_reinit_enchant_dict(); + sc_speller_reinit_enchant_dict();
- sc->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + sc_info->check_while_typing = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_type"))));
- sc->use_msgwin = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + sc_info->use_msgwin = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_msgwin"))));
- sc->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + sc_info->show_toolbar_item = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_toolbar"))));
- g_key_file_load_from_file(config, sc->config_file, G_KEY_FILE_NONE, NULL); - if (sc->default_language != NULL) /* lang may be NULL */ - g_key_file_set_string(config, "spellcheck", "language", sc->default_language); - g_key_file_set_boolean(config, "spellcheck", "check_while_typing", sc->check_while_typing); - g_key_file_set_boolean(config, "spellcheck", "use_msgwin", sc->use_msgwin); - g_key_file_set_boolean(config, "spellcheck", "show_toolbar_item", sc->show_toolbar_item); + g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL); + if (sc_info->default_language != NULL) /* lang may be NULL */ + g_key_file_set_string(config, "spellcheck", "language", sc_info->default_language); + g_key_file_set_boolean(config, "spellcheck", "check_while_typing", sc_info->check_while_typing); + g_key_file_set_boolean(config, "spellcheck", "use_msgwin", sc_info->use_msgwin); + g_key_file_set_boolean(config, "spellcheck", "show_toolbar_item", sc_info->show_toolbar_item);
- gui_toolbar_update(); + sc_gui_toolbar_update();
if (! g_file_test(config_dir, G_FILE_TEST_IS_DIR) && utils_mkdir(config_dir, TRUE) != 0) { @@ -146,7 +146,7 @@ { /* write config to file */ data = g_key_file_to_data(config, NULL, NULL); - utils_write_file(sc->config_file, data); + utils_write_file(sc_info->config_file, data); g_free(data); } g_free(config_dir); @@ -161,42 +161,42 @@ GKeyFile *config = g_key_file_new(); gchar *default_lang;
- default_lang = speller_get_default_lang(); - sc = g_new0(SpellCheck, 1); + default_lang = sc_speller_get_default_lang(); + sc_info = g_new0(SpellCheck, 1);
- sc->config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, + sc_info->config_file = g_strconcat(geany->app->configdir, G_DIR_SEPARATOR_S, "plugins", G_DIR_SEPARATOR_S, "spellcheck", G_DIR_SEPARATOR_S, "spellcheck.conf", NULL);
- g_key_file_load_from_file(config, sc->config_file, G_KEY_FILE_NONE, NULL); - sc->default_language = utils_get_setting_string(config, + g_key_file_load_from_file(config, sc_info->config_file, G_KEY_FILE_NONE, NULL); + sc_info->default_language = utils_get_setting_string(config, "spellcheck", "language", default_lang); - sc->check_while_typing = utils_get_setting_boolean(config, + sc_info->check_while_typing = utils_get_setting_boolean(config, "spellcheck", "check_while_typing", FALSE); - sc->show_toolbar_item = utils_get_setting_boolean(config, + sc_info->show_toolbar_item = utils_get_setting_boolean(config, "spellcheck", "show_toolbar_item", TRUE); - sc->use_msgwin = utils_get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE); + sc_info->use_msgwin = utils_get_setting_boolean(config, "spellcheck", "use_msgwin", FALSE); g_key_file_free(config); g_free(default_lang);
main_locale_init(LOCALEDIR, GETTEXT_PACKAGE);
- sc->menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SPELL_CHECK, NULL); - ui_add_document_sensitive(sc->menu_item); + sc_info->menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_SPELL_CHECK, NULL); + ui_add_document_sensitive(sc_info->menu_item);
- gui_toolbar_update(); + sc_gui_toolbar_update();
- gui_init(); - speller_init(); + sc_gui_init(); + sc_speller_init();
- gui_create_edit_menu(); - sp_item = gui_create_menu(sc->menu_item); + sc_gui_create_edit_menu(); + sp_item = sc_gui_create_menu(sc_info->menu_item); gtk_widget_show_all(sp_item);
/* setup keybindings */ - keybindings_set_item(plugin_key_group, KB_SPELL_CHECK, gui_kb_run_activate_cb, - 0, 0, "spell_check", _("Run Spell Check"), sc->submenu_item_default); + keybindings_set_item(plugin_key_group, KB_SPELL_CHECK, sc_gui_kb_run_activate_cb, + 0, 0, "spell_check", _("Run Spell Check"), sc_info->submenu_item_default); keybindings_set_item(plugin_key_group, KB_SPELL_TOOGLE_TYPING, - gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing", + sc_gui_kb_toggle_typing_activate_cb, 0, 0, "spell_toggle_typing", _("Toggle Check While Typing"), NULL); }
@@ -209,16 +209,16 @@ vbox = gtk_vbox_new(FALSE, 6);
check_type = gtk_check_button_new_with_label(_("Check spelling while typing")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_type), sc->check_while_typing); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_type), sc_info->check_while_typing); gtk_box_pack_start(GTK_BOX(vbox), check_type, FALSE, FALSE, 6);
check_toolbar = gtk_check_button_new_with_label(_("Show toolbar item to toggle spell checking")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_toolbar), sc->show_toolbar_item); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_toolbar), sc_info->show_toolbar_item); gtk_box_pack_start(GTK_BOX(vbox), check_toolbar, FALSE, FALSE, 3);
check_msgwin = gtk_check_button_new_with_label( _("Print misspelled words and suggestions in the messages window")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_msgwin), sc->use_msgwin); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_msgwin), sc_info->use_msgwin); gtk_box_pack_start(GTK_BOX(vbox), check_msgwin, FALSE, FALSE, 3);
label = gtk_label_new(_("Language to use for the spell check:")); @@ -227,20 +227,20 @@
combo = gtk_combo_box_new_text();
- for (i = 0; i < sc->dicts->len; i++) + for (i = 0; i < sc_info->dicts->len; i++) { - gtk_combo_box_append_text(GTK_COMBO_BOX(combo), g_ptr_array_index(sc->dicts, i)); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), g_ptr_array_index(sc_info->dicts, i));
- if (utils_str_equal(g_ptr_array_index(sc->dicts, i), sc->default_language)) + if (utils_str_equal(g_ptr_array_index(sc_info->dicts, i), sc_info->default_language)) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); } /* if the default language couldn't be selected, select the first available language */ if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == -1) gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
- if (sc->dicts->len > 20) + if (sc_info->dicts->len > 20) gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 3); - else if (sc->dicts->len > 10) + else if (sc_info->dicts->len > 10) gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 2); gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 6);
@@ -276,22 +276,22 @@ { guint i;
- for (i = 0; i < sc->dicts->len; i++) + for (i = 0; i < sc_info->dicts->len; i++) { - g_free(g_ptr_array_index(sc->dicts, i)); + g_free(g_ptr_array_index(sc_info->dicts, i)); } - g_ptr_array_free(sc->dicts, TRUE); + g_ptr_array_free(sc_info->dicts, TRUE);
- gtk_widget_destroy(sc->edit_menu); - gtk_widget_destroy(sc->edit_menu_sep); - if (sc->toolbar_button != NULL) - gtk_widget_destroy(GTK_WIDGET(sc->toolbar_button)); + gtk_widget_destroy(sc_info->edit_menu); + gtk_widget_destroy(sc_info->edit_menu_sep); + if (sc_info->toolbar_button != NULL) + gtk_widget_destroy(GTK_WIDGET(sc_info->toolbar_button));
- gui_free(); - speller_free(); + sc_gui_free(); + sc_speller_free();
- g_free(sc->default_language); - g_free(sc->config_file); - gtk_widget_destroy(sc->menu_item); - g_free(sc); + g_free(sc_info->default_language); + g_free(sc_info->config_file); + gtk_widget_destroy(sc_info->menu_item); + g_free(sc_info); }
Modified: trunk/spellcheck/src/scplugin.h =================================================================== --- trunk/spellcheck/src/scplugin.h 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/scplugin.h 2009-02-17 14:32:18 UTC (rev 485) @@ -45,7 +45,7 @@ } SpellCheck;
-extern SpellCheck *sc; +extern SpellCheck *sc_info; extern GeanyPlugin *geany_plugin; extern GeanyData *geany_data; extern GeanyFunctions *geany_functions;
Modified: trunk/spellcheck/src/speller.c =================================================================== --- trunk/spellcheck/src/speller.c 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/speller.c 2009-02-17 14:32:18 UTC (rev 485) @@ -46,8 +46,8 @@
-static EnchantBroker *speller_broker = NULL; -static EnchantDict *speller_dict = NULL; +static EnchantBroker *sc_speller_broker = NULL; +static EnchantDict *sc_speller_dict = NULL;
@@ -59,12 +59,12 @@ }
-gint speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, - gint start_pos, gint end_pos) +gint sc_speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, + gint start_pos, gint end_pos) { gsize n_suggs = 0;
- g_return_val_if_fail(speller_dict != NULL, 0); + g_return_val_if_fail(sc_speller_dict != NULL, 0); g_return_val_if_fail(doc != NULL, 0); g_return_val_if_fail(word != NULL, 0); g_return_val_if_fail(start_pos >= 0 && end_pos >= 0, 0); @@ -77,23 +77,23 @@ return 0;
/* ignore non-text */ - if (! speller_is_text(doc, start_pos)) + if (! sc_speller_is_text(doc, start_pos)) return 0;
/* early out if the word is spelled correctly */ - if (enchant_dict_check(speller_dict, word, -1) == 0) + if (enchant_dict_check(sc_speller_dict, word, -1) == 0) return 0;
editor_indicator_set_on_range(doc->editor, GEANY_INDICATOR_ERROR, start_pos, end_pos);
- if (sc->use_msgwin && line_number != -1) + if (sc_info->use_msgwin && line_number != -1) { gsize j; gchar **suggs; GString *str;
str = g_string_sized_new(256); - suggs = enchant_dict_suggest(speller_dict, word, -1, &n_suggs); + suggs = enchant_dict_suggest(sc_speller_dict, word, -1, &n_suggs); if (suggs != NULL) { g_string_append_printf(str, "line %d: %s | ", line_number + 1, word); @@ -110,7 +110,7 @@ msgwin_msg_add(COLOR_RED, line_number + 1, doc, "%s", str->str);
if (suggs != NULL && n_suggs > 0) - enchant_dict_free_string_list(speller_dict, suggs); + enchant_dict_free_string_list(sc_speller_dict, suggs); } g_string_free(str, TRUE); } @@ -127,7 +127,7 @@ gint suggestions_found = 0; gchar c;
- g_return_val_if_fail(speller_dict != NULL, 0); + g_return_val_if_fail(sc_speller_dict != NULL, 0); g_return_val_if_fail(doc != NULL, 0); g_return_val_if_fail(line != NULL, 0);
@@ -156,7 +156,7 @@
sci_get_text_range(doc->editor->sci, wstart, wend, str->str);
- suggestions_found += speller_check_word(doc, line_number, str->str, wstart, wend); + suggestions_found += sc_speller_check_word(doc, line_number, str->str, wstart, wend);
pos_start = wend + 1; } @@ -166,7 +166,7 @@ }
-void speller_check_document(GeanyDocument *doc) +void sc_speller_check_document(GeanyDocument *doc) { gchar *line; gint i; @@ -174,12 +174,12 @@ gchar *dict_string = NULL; gint suggestions_found = 0;
- g_return_if_fail(speller_dict != NULL); + g_return_if_fail(sc_speller_dict != NULL); g_return_if_fail(doc != NULL);
ui_progress_bar_start(_("Checking"));
- enchant_dict_describe(speller_dict, dict_describe, &dict_string); + enchant_dict_describe(sc_speller_dict, dict_describe, &dict_string);
if (sci_has_selection(doc->editor->sci)) { @@ -188,7 +188,7 @@ last_line = sci_get_line_from_position( doc->editor->sci, sci_get_selection_end(doc->editor->sci));
- if (sc->use_msgwin) + if (sc_info->use_msgwin) msgwin_msg_add(COLOR_BLUE, -1, NULL, _("Checking file "%s" (lines %d to %d using %s):"), DOC_FILENAME(doc), first_line + 1, last_line + 1, dict_string); @@ -199,7 +199,7 @@ { first_line = 0; last_line = sci_get_line_count(doc->editor->sci); - if (sc->use_msgwin) + if (sc_info->use_msgwin) msgwin_msg_add(COLOR_BLUE, -1, NULL, _("Checking file "%s" (using %s):"), DOC_FILENAME(doc), dict_string); g_message("Checking file "%s" (using %s):", DOC_FILENAME(doc), dict_string); @@ -217,7 +217,7 @@
g_free(line); } - if (suggestions_found == 0 && sc->use_msgwin) + if (suggestions_found == 0 && sc_info->use_msgwin) msgwin_msg_add(COLOR_BLUE, -1, NULL, _("The checked text is spelled correctly."));
ui_progress_bar_stop(); @@ -226,7 +226,7 @@
static void broker_init_failed(void) { - const gchar *err = enchant_broker_get_error(speller_broker); + const gchar *err = enchant_broker_get_error(sc_speller_broker); dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("The Enchant library couldn't be initialized (%s)."), (err != NULL) ? err : _("unknown error (maybe the chosen language is not available)")); @@ -237,7 +237,7 @@ { gboolean *supported = user_data;
- if (utils_str_equal(sc->default_language, data)) + if (utils_str_equal(sc_info->default_language, data)) *supported = TRUE; }
@@ -246,49 +246,49 @@ { gboolean supported = FALSE;
- g_ptr_array_foreach(sc->dicts, dict_compare, &supported); + g_ptr_array_foreach(sc_info->dicts, dict_compare, &supported);
return supported; }
-void speller_reinit_enchant_dict(void) +void sc_speller_reinit_enchant_dict(void) { - gchar *lang = sc->default_language; + gchar *lang = sc_info->default_language;
/* Release a previous dict object */ - if (speller_dict != NULL) - enchant_broker_free_dict(speller_broker, speller_dict); + if (sc_speller_dict != NULL) + enchant_broker_free_dict(sc_speller_broker, sc_speller_dict);
/* Check if the stored default dictionary is (still) avaiable, fall back to the first * one in the list if not */ if (! check_default_lang()) { - if (sc->dicts->len > 0) + if (sc_info->dicts->len > 0) { - lang = g_ptr_array_index(sc->dicts, 0); + lang = g_ptr_array_index(sc_info->dicts, 0); g_warning("Stored language ('%s') could not be loaded. Falling back to '%s'", - sc->default_language, lang); + sc_info->default_language, lang); } else - g_warning("Stored language ('%s') could not be loaded.", sc->default_language); + g_warning("Stored language ('%s') could not be loaded.", sc_info->default_language); }
/* Request new dict object */ - speller_dict = enchant_broker_request_dict(speller_broker, lang); - if (speller_dict == NULL) + sc_speller_dict = enchant_broker_request_dict(sc_speller_broker, lang); + if (sc_speller_dict == NULL) { broker_init_failed(); - gtk_widget_set_sensitive(sc->menu_item, FALSE); + gtk_widget_set_sensitive(sc_info->menu_item, FALSE); } else { - gtk_widget_set_sensitive(sc->menu_item, TRUE); + gtk_widget_set_sensitive(sc_info->menu_item, TRUE); } }
-gchar *speller_get_default_lang(void) +gchar *sc_speller_get_default_lang(void) { const gchar *lang = g_getenv("LANG"); gchar *result = NULL; @@ -327,13 +327,13 @@ }
/* find duplicates and skip them */ - for (i = 0; i < sc->dicts->len; i++) + for (i = 0; i < sc_info->dicts->len; i++) { - if (utils_str_equal(g_ptr_array_index(sc->dicts, i), result)) + if (utils_str_equal(g_ptr_array_index(sc_info->dicts, i), result)) return; }
- g_ptr_array_add(sc->dicts, result); + g_ptr_array_add(sc_info->dicts, result); }
@@ -345,86 +345,86 @@
static void create_dicts_array(void) { - sc->dicts = g_ptr_array_new(); + sc_info->dicts = g_ptr_array_new();
- enchant_broker_list_dicts(speller_broker, add_dict_array, sc->dicts); + enchant_broker_list_dicts(sc_speller_broker, add_dict_array, sc_info->dicts);
- g_ptr_array_sort(sc->dicts, sort_dicts); + g_ptr_array_sort(sc_info->dicts, sort_dicts); }
-void speller_dict_free_string_list(gchar **tmp_suggs) +void sc_speller_dict_free_string_list(gchar **tmp_suggs) { - g_return_if_fail(speller_dict != NULL); + g_return_if_fail(sc_speller_dict != NULL);
- enchant_dict_free_string_list(speller_dict, tmp_suggs); + enchant_dict_free_string_list(sc_speller_dict, tmp_suggs); }
-void speller_add_word(const gchar *word) +void sc_speller_add_word(const gchar *word) { - g_return_if_fail(speller_dict != NULL); + g_return_if_fail(sc_speller_dict != NULL); g_return_if_fail(word != NULL);
- enchant_dict_add_to_pwl(speller_dict, word, -1); + enchant_dict_add_to_pwl(sc_speller_dict, word, -1); }
-gboolean speller_dict_check(const gchar *word) +gboolean sc_speller_dict_check(const gchar *word) { - g_return_val_if_fail(speller_dict != NULL, FALSE); + g_return_val_if_fail(sc_speller_dict != NULL, FALSE); g_return_val_if_fail(word != NULL, FALSE);
- return enchant_dict_check(speller_dict, word, -1); + return enchant_dict_check(sc_speller_dict, word, -1); }
-gchar **speller_dict_suggest(const gchar *word, gsize *n_suggs) +gchar **sc_speller_dict_suggest(const gchar *word, gsize *n_suggs) { - g_return_val_if_fail(speller_dict != NULL, NULL); + g_return_val_if_fail(sc_speller_dict != NULL, NULL); g_return_val_if_fail(word != NULL, NULL);
- return enchant_dict_suggest(speller_dict, word, -1, n_suggs); + return enchant_dict_suggest(sc_speller_dict, word, -1, n_suggs); }
-void speller_add_word_to_session(const gchar *word) +void sc_speller_add_word_to_session(const gchar *word) { - g_return_if_fail(speller_dict != NULL); + g_return_if_fail(sc_speller_dict != NULL); g_return_if_fail(word != NULL);
- enchant_dict_add_to_session(speller_dict, word, -1); + enchant_dict_add_to_session(sc_speller_dict, word, -1); }
-void speller_store_replacement(const gchar *old_word, const gchar *new_word) +void sc_speller_store_replacement(const gchar *old_word, const gchar *new_word) { - g_return_if_fail(speller_dict != NULL); + g_return_if_fail(sc_speller_dict != NULL); g_return_if_fail(old_word != NULL); g_return_if_fail(new_word != NULL);
- enchant_dict_store_replacement(speller_dict, old_word, -1, new_word, -1); + enchant_dict_store_replacement(sc_speller_dict, old_word, -1, new_word, -1); }
-void speller_init(void) +void sc_speller_init(void) { - speller_broker = enchant_broker_init(); + sc_speller_broker = enchant_broker_init();
create_dicts_array();
- speller_reinit_enchant_dict(); + sc_speller_reinit_enchant_dict(); }
-void speller_free(void) +void sc_speller_free(void) { - if (speller_dict != NULL) - enchant_broker_free_dict(speller_broker, speller_dict); - enchant_broker_free(speller_broker); + if (sc_speller_dict != NULL) + enchant_broker_free_dict(sc_speller_broker, sc_speller_dict); + enchant_broker_free(sc_speller_broker); }
-gboolean speller_is_text(GeanyDocument *doc, gint pos) +gboolean sc_speller_is_text(GeanyDocument *doc, gint pos) { gint lexer, style;
Modified: trunk/spellcheck/src/speller.h =================================================================== --- trunk/spellcheck/src/speller.h 2009-02-17 14:10:47 UTC (rev 484) +++ trunk/spellcheck/src/speller.h 2009-02-17 14:32:18 UTC (rev 485) @@ -27,31 +27,31 @@ #define SC_SPELLER_H 1
-gint speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, - gint start_pos, gint end_pos); +gint sc_speller_check_word(GeanyDocument *doc, gint line_number, const gchar *word, + gint start_pos, gint end_pos);
-void speller_check_document(GeanyDocument *doc); +void sc_speller_check_document(GeanyDocument *doc);
-void speller_reinit_enchant_dict(void); +void sc_speller_reinit_enchant_dict(void);
-gchar *speller_get_default_lang(void); +gchar *sc_speller_get_default_lang(void);
-void speller_dict_free_string_list(gchar **tmp_suggs); +void sc_speller_dict_free_string_list(gchar **tmp_suggs);
-void speller_add_word(const gchar *word); +void sc_speller_add_word(const gchar *word);
-gboolean speller_dict_check(const gchar *word); +gboolean sc_speller_dict_check(const gchar *word);
-gchar **speller_dict_suggest(const gchar *word, gsize *n_suggs); +gchar **sc_speller_dict_suggest(const gchar *word, gsize *n_suggs);
-gboolean speller_is_text(GeanyDocument *doc, gint pos); +gboolean sc_speller_is_text(GeanyDocument *doc, gint pos);
-void speller_add_word_to_session(const gchar *word); +void sc_speller_add_word_to_session(const gchar *word);
-void speller_store_replacement(const gchar *old_word, const gchar *new_word); +void sc_speller_store_replacement(const gchar *old_word, const gchar *new_word);
-void speller_init(void); +void sc_speller_init(void);
-void speller_free(void); +void sc_speller_free(void);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.