summaryrefslogtreecommitdiff
path: root/src/gui/gui-bar.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-05-23 22:58:46 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-05-27 17:53:50 +0200
commitcefed2591293873d25718613fcfda460ff32eb49 (patch)
tree2738dd915235cd620023aa76271427620367bc6c /src/gui/gui-bar.c
parent79438c72e190283c72f07f1350017b3857b78251 (diff)
downloadweechat-cefed2591293873d25718613fcfda460ff32eb49.zip
core: add command /item (closes #808)
This allows to create custom bar items with evaluated content (like the script text_item.py does).
Diffstat (limited to 'src/gui/gui-bar.c')
-rw-r--r--src/gui/gui-bar.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c
index d77982207..6c421d003 100644
--- a/src/gui/gui-bar.c
+++ b/src/gui/gui-bar.c
@@ -470,6 +470,9 @@ gui_bar_search_with_option_name (const char *option_name)
char *bar_name, *pos_option;
struct t_gui_bar *ptr_bar;
+ if (!option_name)
+ return NULL;
+
ptr_bar = NULL;
pos_option = strchr (option_name, '.');
@@ -1562,24 +1565,24 @@ gui_bar_alloc (const char *name)
int i;
new_bar = malloc (sizeof (*new_bar));
- if (new_bar)
+ if (!new_bar)
+ return NULL;
+
+ new_bar->name = strdup (name);
+ for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
{
- new_bar->name = strdup (name);
- for (i = 0; i < GUI_BAR_NUM_OPTIONS; i++)
- {
- new_bar->options[i] = NULL;
- }
- new_bar->items_count = 0;
- new_bar->items_array = NULL;
- new_bar->items_buffer = NULL;
- new_bar->items_prefix = NULL;
- new_bar->items_name = NULL;
- new_bar->items_suffix = NULL;
- new_bar->bar_window = NULL;
- new_bar->bar_refresh_needed = 0;
- new_bar->prev_bar = NULL;
- new_bar->next_bar = NULL;
+ new_bar->options[i] = NULL;
}
+ new_bar->items_count = 0;
+ new_bar->items_array = NULL;
+ new_bar->items_buffer = NULL;
+ new_bar->items_prefix = NULL;
+ new_bar->items_name = NULL;
+ new_bar->items_suffix = NULL;
+ new_bar->bar_window = NULL;
+ new_bar->bar_refresh_needed = 0;
+ new_bar->prev_bar = NULL;
+ new_bar->next_bar = NULL;
return new_bar;
}