diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | doc/en/weechat_dev.en.txt | 1 | ||||
-rw-r--r-- | po/POTFILES.in | 2 | ||||
-rw-r--r-- | po/srcfiles.cmake | 2 | ||||
-rw-r--r-- | src/plugins/aspell/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/plugins/aspell/Makefile.am | 2 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-bar-item.c | 71 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell-bar-item.h | 25 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell.c | 74 | ||||
-rw-r--r-- | src/plugins/aspell/weechat-aspell.h | 1 |
10 files changed, 168 insertions, 12 deletions
@@ -7,6 +7,7 @@ v0.4.0-dev, 2012-10-06 Version 0.4.0 (under dev!) -------------------------- +* aspell: add bar item "aspell_dict" (dictionary used on current buffer) * irc: remove unneeded server disconnect when server buffer is closed and server is already disconnected * relay: add missing "ssl." in output of /relay listrelay diff --git a/doc/en/weechat_dev.en.txt b/doc/en/weechat_dev.en.txt index 6b1839537..8f42ccb09 100644 --- a/doc/en/weechat_dev.en.txt +++ b/doc/en/weechat_dev.en.txt @@ -174,6 +174,7 @@ Plugins | alias-info.c | Info and infolists from alias plugin | aspell/ | Aspell plugin | weechat-aspell.c | Main aspell functions +| weechat-aspell-bar-item.c | Aspell bar items | weechat-aspell-config.c | Aspell config options | weechat-aspell-speller.c | Spellers management | charset/ | Charset plugin diff --git a/po/POTFILES.in b/po/POTFILES.in index 98bb99d93..7bb755b0d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -101,6 +101,8 @@ ./src/plugins/alias/alias-info.h ./src/plugins/aspell/weechat-aspell.c ./src/plugins/aspell/weechat-aspell.h +./src/plugins/aspell/weechat-aspell-bar-item.c +./src/plugins/aspell/weechat-aspell-bar-item.h ./src/plugins/aspell/weechat-aspell-config.c ./src/plugins/aspell/weechat-aspell-config.h ./src/plugins/aspell/weechat-aspell-speller.c diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index a2e05661a..be33e36da 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -102,6 +102,8 @@ SET(WEECHAT_SOURCES ./src/plugins/alias/alias-info.h ./src/plugins/aspell/weechat-aspell.c ./src/plugins/aspell/weechat-aspell.h +./src/plugins/aspell/weechat-aspell-bar-item.c +./src/plugins/aspell/weechat-aspell-bar-item.h ./src/plugins/aspell/weechat-aspell-config.c ./src/plugins/aspell/weechat-aspell-config.h ./src/plugins/aspell/weechat-aspell-speller.c diff --git a/src/plugins/aspell/CMakeLists.txt b/src/plugins/aspell/CMakeLists.txt index 787194da3..709fc0dd8 100644 --- a/src/plugins/aspell/CMakeLists.txt +++ b/src/plugins/aspell/CMakeLists.txt @@ -20,6 +20,7 @@ ADD_LIBRARY(aspell MODULE weechat-aspell.c weechat-aspell.h +weechat-aspell-bar-item.c weechat-aspell-bar-item.h weechat-aspell-config.c weechat-aspell-config.h weechat-aspell-speller.c weechat-aspell-speller.h) SET_TARGET_PROPERTIES(aspell PROPERTIES PREFIX "") diff --git a/src/plugins/aspell/Makefile.am b/src/plugins/aspell/Makefile.am index 4e3b6be2b..472fccd77 100644 --- a/src/plugins/aspell/Makefile.am +++ b/src/plugins/aspell/Makefile.am @@ -26,6 +26,8 @@ lib_LTLIBRARIES = aspell.la aspell_la_SOURCES = weechat-aspell.c \ weechat-aspell.h \ + weechat-aspell-bar-item.c \ + weechat-aspell-bar-item.h \ weechat-aspell-config.c \ weechat-aspell-config.h \ weechat-aspell-speller.c \ diff --git a/src/plugins/aspell/weechat-aspell-bar-item.c b/src/plugins/aspell/weechat-aspell-bar-item.c new file mode 100644 index 000000000..c2be69c0b --- /dev/null +++ b/src/plugins/aspell/weechat-aspell-bar-item.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2012 Nils Görs <weechatter@arcor.de> + * Copyright (C) 2012 Sebastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * weechat-aspell-bar-item.c: bar items for aspell plugin + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "../weechat-plugin.h" +#include "weechat-aspell.h" + + +/* + * weechat_aspell_bar_item_dict: bar item with aspell dictionary used on + * current buffer + */ + +char * +weechat_aspell_bar_item_dict (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window) +{ + struct t_gui_buffer *buffer; + const char *dict_list; + + /* make C compiler happy */ + (void) data; + (void) item; + + if (!window) + window = weechat_current_window (); + + buffer = weechat_window_get_pointer (window, "buffer"); + + if (buffer) + { + dict_list = weechat_aspell_get_dict (buffer); + if (dict_list) + return strdup (dict_list); + } + return NULL; +} + +/* + * weechat_aspell_bar_item_init: initialize aspell bar items + */ + +void +weechat_aspell_bar_item_init () +{ + weechat_bar_item_new ("aspell_dict", &weechat_aspell_bar_item_dict, NULL); +} diff --git a/src/plugins/aspell/weechat-aspell-bar-item.h b/src/plugins/aspell/weechat-aspell-bar-item.h new file mode 100644 index 000000000..019ec4f51 --- /dev/null +++ b/src/plugins/aspell/weechat-aspell-bar-item.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2012 Nils Görs <weechatter@arcor.de> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef __WEECHAT_ASPELL_BAR_ITEM_H +#define __WEECHAT_ASPELL_BAR_ITEM_H 1 + +extern void weechat_aspell_bar_item_init (); + +#endif /* __WEECHAT_ASPELL_BAR_ITEM_H */ diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c index d0e08f84e..8a8faf029 100644 --- a/src/plugins/aspell/weechat-aspell.c +++ b/src/plugins/aspell/weechat-aspell.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2006 Emmanuel Bouthenot <kolter@openics.org> * Copyright (C) 2006-2012 Sebastien Helleu <flashcode@flashtux.org> + * Copyright (C) 2012 Nils Görs <weechatter@arcor.de> * * This file is part of WeeChat, the extensible chat client. * @@ -31,6 +32,7 @@ #include "../weechat-plugin.h" #include "weechat-aspell.h" +#include "weechat-aspell-bar-item.h" #include "weechat-aspell-config.h" #include "weechat-aspell-speller.h" @@ -332,26 +334,27 @@ weechat_aspell_create_spellers (struct t_gui_buffer *buffer) char **argv; int argc, i; - if (buffer) + if (!buffer) + return; + + dict_list = weechat_aspell_get_dict (buffer); + if (!weechat_aspell_spellers_already_ok (dict_list)) { - dict_list = weechat_aspell_get_dict (buffer); - if (!weechat_aspell_spellers_already_ok (dict_list)) + weechat_aspell_speller_free_all (); + if (dict_list) { - weechat_aspell_speller_free_all (); - if (dict_list) + argv = weechat_string_split (dict_list, ",", 0, 0, &argc); + if (argv) { - argv = weechat_string_split (dict_list, ",", 0, 0, &argc); - if (argv) + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) - { - weechat_aspell_speller_new (argv[i]); - } - weechat_string_free_split (argv); + weechat_aspell_speller_new (argv[i]); } + weechat_string_free_split (argv); } } } + weechat_bar_item_update ("aspell_dict"); } /* @@ -1030,6 +1033,46 @@ weechat_aspell_completion_langs_cb (void *data, const char *completion_item, } /* + * weechat_aspell_buffer_switch_cb: called on "buffer_switch" signal + */ + +int +weechat_aspell_buffer_switch_cb (void *data, const char *signal, + const char *type_data, void *signal_data) +{ + /* make C compiler happy */ + (void) data; + (void) signal; + (void) type_data; + (void) signal_data; + + /* refresh bar item "aspell_dict" (for root bars) */ + weechat_bar_item_update ("aspell_dict"); + + return WEECHAT_RC_OK; +} + +/* + * weechat_aspell_window_switch_cb: called on "window_switch" signal + */ + +int +weechat_aspell_window_switch_cb (void *data, const char *signal, + const char *type_data, void *signal_data) +{ + /* make C compiler happy */ + (void) data; + (void) signal; + (void) type_data; + (void) signal_data; + + /* refresh bar item "aspell_dict" (for root bars) */ + weechat_bar_item_update ("aspell_dict"); + + return WEECHAT_RC_OK; +} + +/* * weechat_plugin_init : init aspell plugin */ @@ -1095,6 +1138,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) weechat_hook_modifier ("500|input_text_display", &weechat_aspell_modifier_cb, NULL); + weechat_aspell_bar_item_init (); + + weechat_hook_signal ("buffer_switch", + &weechat_aspell_buffer_switch_cb, NULL); + weechat_hook_signal ("window_switch", + &weechat_aspell_window_switch_cb, NULL); + return WEECHAT_RC_OK; } diff --git a/src/plugins/aspell/weechat-aspell.h b/src/plugins/aspell/weechat-aspell.h index 3c950743e..a6cf2c518 100644 --- a/src/plugins/aspell/weechat-aspell.h +++ b/src/plugins/aspell/weechat-aspell.h @@ -36,5 +36,6 @@ extern struct t_weechat_plugin *weechat_aspell_plugin; extern int aspell_enabled; extern void weechat_aspell_create_spellers (struct t_gui_buffer *buffer); +extern const char *weechat_aspell_get_dict (struct t_gui_buffer *buffer); #endif /* __WEECHAT_ASPELL_H */ |