Save of bars in main WeeChat config file (weechat.rc)
This commit is contained in:
parent
75e8c9a2f5
commit
324eaa5069
@ -41,6 +41,7 @@
|
||||
#include "wee-util.h"
|
||||
#include "wee-list.h"
|
||||
#include "wee-string.h"
|
||||
#include "../gui/gui-bar.h"
|
||||
#include "../gui/gui-buffer.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../gui/gui-color.h"
|
||||
@ -430,6 +431,73 @@ config_weechat_reload (void *data, struct t_config_file *config_file)
|
||||
return config_file_reload (weechat_config_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_read_bar: read a bar in configuration file
|
||||
*/
|
||||
|
||||
void
|
||||
config_weechat_read_bar (void *data, struct t_config_file *config_file,
|
||||
char *option_name, char *value)
|
||||
{
|
||||
char **argv, *error;
|
||||
int argc, size;
|
||||
long number;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) config_file;
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
if (value && value[0])
|
||||
{
|
||||
argv = string_explode (value, ";", 0, 0, &argc);
|
||||
if (argc == 5)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (error && (error[0] == '\0'))
|
||||
{
|
||||
size = number;
|
||||
gui_bar_new (NULL, option_name, argv[0], argv[1], size,
|
||||
(argv[3][0] == '0') ? 0 : 1,
|
||||
argv[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_write_bars: write bars section in configuration file
|
||||
* Return: 0 = successful
|
||||
* -1 = write error
|
||||
*/
|
||||
|
||||
void
|
||||
config_weechat_write_bars (void *data, struct t_config_file *config_file,
|
||||
char *section_name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
config_file_write_line (config_file, section_name, NULL);
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
config_file_write_line (config_file,
|
||||
ptr_bar->name,
|
||||
"%s;%s;%d;%d;%s",
|
||||
gui_bar_type_str[ptr_bar->type],
|
||||
gui_bar_position_str[ptr_bar->position],
|
||||
ptr_bar->size,
|
||||
ptr_bar->separator,
|
||||
ptr_bar->items);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_read_key: read a key in configuration file
|
||||
*/
|
||||
@ -451,14 +519,14 @@ config_weechat_read_key (void *data, struct t_config_file *config_file,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unbin key if no value given */
|
||||
/* unbind key if no value given */
|
||||
gui_keyboard_unbind (option_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* config_weechat_write_keys: write alias section in configuration file
|
||||
* config_weechat_write_keys: write keys section in configuration file
|
||||
* Return: 0 = successful
|
||||
* -1 = write error
|
||||
*/
|
||||
@ -1289,7 +1357,21 @@ config_weechat_init ()
|
||||
"plugins_save_config_on_unload", "boolean",
|
||||
N_("save configuration files when unloading plugins"),
|
||||
NULL, 0, 0, "on", NULL, NULL);
|
||||
|
||||
|
||||
/* bars */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "bars",
|
||||
&config_weechat_read_bar,
|
||||
NULL,
|
||||
&config_weechat_write_bars,
|
||||
NULL,
|
||||
&config_weechat_write_bars,
|
||||
NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
config_file_free (weechat_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* keys */
|
||||
ptr_section = config_file_new_section (weechat_config_file, "keys",
|
||||
&config_weechat_read_key,
|
||||
|
@ -147,6 +147,7 @@ gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
/*
|
||||
* gui_bar_window_new: create a new "window bar" for a bar, in screen or a window
|
||||
* if window is not NULL, bar window will be in this window
|
||||
* return 1 if ok, 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@ -154,6 +155,9 @@ gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *new_bar_window;
|
||||
|
||||
if (!gui_init_ok)
|
||||
return 0;
|
||||
|
||||
new_bar_window = (struct t_gui_bar_window *) malloc (sizeof (struct t_gui_bar_window));
|
||||
if (new_bar_window)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "../../core/wee-util.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-main.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-bar-item.h"
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui-chat.h"
|
||||
@ -74,6 +75,7 @@ void
|
||||
gui_main_init ()
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
initscr ();
|
||||
|
||||
@ -123,6 +125,20 @@ gui_main_init ()
|
||||
if (CONFIG_BOOLEAN(config_look_set_title))
|
||||
gui_window_title_set ();
|
||||
}
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
/* create bar windows for root bars (they were read from config,
|
||||
but no window was created (GUI was not initialized) */
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if ((ptr_bar->type == GUI_BAR_TYPE_ROOT)
|
||||
&& (!ptr_bar->bar_window))
|
||||
{
|
||||
gui_bar_window_new (ptr_bar, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -159,6 +159,7 @@ gui_bar_new (struct t_weechat_plugin *plugin, char *name, char *type,
|
||||
new_bar->items_count = 0;
|
||||
new_bar->items_array = NULL;
|
||||
}
|
||||
new_bar->bar_window = NULL;
|
||||
|
||||
if (type_value == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user