diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-18 18:32:02 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-06-25 16:35:27 +0200 |
commit | 2a5eb1564fa588b79bf4ec81f0185a09d4203be8 (patch) | |
tree | 619b42ef9940a82449074b9aec30f04dad754b54 /src/plugins/fset/fset.c | |
parent | 9de297100afacfa6fe40223c6699ea57af3c3860 (diff) | |
download | weechat-2a5eb1564fa588b79bf4ec81f0185a09d4203be8.zip |
fset: add fset (Fast Set) plugin skeleton (WIP)
Diffstat (limited to 'src/plugins/fset/fset.c')
-rw-r--r-- | src/plugins/fset/fset.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/src/plugins/fset/fset.c b/src/plugins/fset/fset.c new file mode 100644 index 000000000..6f2907c6f --- /dev/null +++ b/src/plugins/fset/fset.c @@ -0,0 +1,135 @@ +/* + * fset.c - Fast set of WeeChat and plugins options + * + * Copyright (C) 2003-2017 Sébastien 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/>. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "../weechat-plugin.h" +#include "fset.h" +#include "fset-bar-item.h" +#include "fset-buffer.h" +#include "fset-command.h" +#include "fset-config.h" +#include "fset-info.h" +#include "fset-mouse.h" +#include "fset-option.h" + + +WEECHAT_PLUGIN_NAME(FSET_PLUGIN_NAME); +WEECHAT_PLUGIN_DESCRIPTION(N_("Fast set of WeeChat and plugins options")); +WEECHAT_PLUGIN_AUTHOR("Sébastien Helleu <flashcode@flashtux.org>"); +WEECHAT_PLUGIN_VERSION(WEECHAT_VERSION); +WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE); +WEECHAT_PLUGIN_PRIORITY(7500); + +struct t_weechat_plugin *weechat_fset_plugin = NULL; + +struct t_hdata *fset_hdata_config_file = NULL; +struct t_hdata *fset_hdata_config_section = NULL; +struct t_hdata *fset_hdata_config_option = NULL; +struct t_hdata *fset_hdata_fset_option = NULL; + + +/* + * Adds the fset bar. + */ + +void +fset_add_bar () +{ + weechat_bar_new (FSET_BAR_NAME, "on", "0", "window", "", "top", + "horizontal", "vertical", "3", "3", + "default", "cyan", "default", "on", + FSET_BAR_ITEM_NAME); +} + +/* + * Initializes fset plugin. + */ + +int +weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) +{ + /* make C compiler happy */ + (void) argc; + (void) argv; + + weechat_plugin = plugin; + + fset_hdata_config_file = weechat_hdata_get ("config_file"); + fset_hdata_config_section = weechat_hdata_get ("config_section"); + fset_hdata_config_option = weechat_hdata_get ("config_option"); + + fset_buffer_init (); + + if (!fset_config_init ()) + return WEECHAT_RC_ERROR; + + fset_config_read (); + + if (!fset_bar_item_init ()) + return WEECHAT_RC_ERROR; + + fset_option_init (); + + fset_command_init (); + + if (weechat_config_boolean (fset_config_look_enabled)) + fset_add_bar (); + + fset_bar_item_update (); + + fset_info_init (); + + fset_hdata_fset_option = weechat_hdata_get ("fset_option"); + + weechat_hook_signal ("window_scrolled", + &fset_buffer_window_scrolled_cb, NULL, NULL); + + fset_mouse_init (); + + return WEECHAT_RC_OK; +} + +/* + * Ends fset plugin. + */ + +int +weechat_plugin_end (struct t_weechat_plugin *plugin) +{ + /* make C compiler happy */ + (void) plugin; + + fset_mouse_end (); + + fset_bar_item_end (); + + fset_buffer_end (); + + fset_option_end (); + + fset_config_write (); + fset_config_free (); + + return WEECHAT_RC_OK; +} |