diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-nicklist.c | 4 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 2 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 93 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 1 |
4 files changed, 90 insertions, 10 deletions
diff --git a/src/gui/curses/gui-curses-nicklist.c b/src/gui/curses/gui-curses-nicklist.c index 1a748561d..5be8c4984 100644 --- a/src/gui/curses/gui-curses-nicklist.c +++ b/src/gui/curses/gui-curses-nicklist.c @@ -56,7 +56,9 @@ gui_nicklist_draw (struct t_gui_buffer *buffer, int erase) if ((ptr_win->buffer == buffer) && (buffer->num_displayed > 0)) { max_length = gui_nicklist_get_max_length (buffer); - if (max_length != buffer->nick_max_length) + if ((max_length != buffer->nick_max_length) + || (buffer->nicklist && !GUI_CURSES(ptr_win)->win_nick) + || (!buffer->nicklist && GUI_CURSES(ptr_win)->win_nick)) { buffer->nick_max_length = max_length; if (gui_window_calculate_pos_size (ptr_win, 0)) diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 2161496fc..2658a53a3 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -200,7 +200,7 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate) return 0; /* init chat & nicklist settings */ - if (cfg_look_nicklist && window->buffer->nicklist) + if (window->buffer->nicklist) { max_length = gui_nicklist_get_max_length (window->buffer); diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 60f0b57f8..09ad6df6c 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -36,13 +36,16 @@ #include "gui-completion.h" #include "gui-history.h" #include "gui-hotlist.h" +#include "gui-input.h" #include "gui-main.h" +#include "gui-nicklist.h" #include "gui-log.h" #include "gui-status.h" #include "gui-window.h" #include "../core/wee-command.h" #include "../core/wee-config.h" #include "../core/wee-log.h" +#include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "../plugins/plugin.h" @@ -207,9 +210,12 @@ gui_buffer_valid (struct t_gui_buffer *buffer) void gui_buffer_set_category (struct t_gui_buffer *buffer, char *category) { - if (buffer->category) - free (buffer->category); - buffer->category = (category) ? strdup (category) : NULL; + if (category && category[0]) + { + if (buffer->category) + free (buffer->category); + buffer->category = strdup (category); + } } /* @@ -219,9 +225,12 @@ gui_buffer_set_category (struct t_gui_buffer *buffer, char *category) void gui_buffer_set_name (struct t_gui_buffer *buffer, char *name) { - if (buffer->name) - free (buffer->name); - buffer->name = (name) ? strdup (name) : NULL; + if (name && name[0]) + { + if (buffer->name) + free (buffer->name); + buffer->name = strdup (name); + } } /* @@ -250,7 +259,17 @@ gui_buffer_set_title (struct t_gui_buffer *buffer, char *new_title) { if (buffer->title) free (buffer->title); - buffer->title = (new_title) ? strdup (new_title) : NULL; + buffer->title = (new_title && new_title[0]) ? strdup (new_title) : NULL; +} + +/* + * gui_buffer_set_nicklist: set nicklist for a buffer + */ + +void +gui_buffer_set_nicklist (struct t_gui_buffer *buffer, int nicklist) +{ + buffer->nicklist = (nicklist) ? 1 : 0; } /* @@ -273,7 +292,65 @@ gui_buffer_set_nick (struct t_gui_buffer *buffer, char *new_nick) { if (buffer->input_nick) free (buffer->input_nick); - buffer->input_nick = (new_nick) ? strdup (new_nick) : NULL; + buffer->input_nick = (new_nick && new_nick[0]) ? strdup (new_nick) : NULL; +} + +/* + * gui_buffer_set: set a property for a buffer + */ + +void +gui_buffer_set (struct t_gui_buffer *buffer, char *property, char *value) +{ + long number; + char *error; + + if (string_strcasecmp (property, "display") == 0) + { + gui_window_switch_to_buffer (gui_current_window, buffer); + gui_window_redraw_buffer (buffer); + } + else if (string_strcasecmp (property, "category") == 0) + { + gui_buffer_set_category (buffer, value); + gui_status_draw (buffer, 1); + } + else if (string_strcasecmp (property, "name") == 0) + { + gui_buffer_set_name (buffer, value); + gui_status_draw (buffer, 1); + } + else if (string_strcasecmp (property, "log") == 0) + { + gui_buffer_set_log (buffer, value); + } + else if (string_strcasecmp (property, "title") == 0) + { + gui_buffer_set_title (buffer, value); + gui_chat_draw_title (buffer, 1); + } + else if (string_strcasecmp (property, "nicklist") == 0) + { + error = NULL; + number = strtol (value, &error, 10); + if (error && (error[0] == '\0')) + { + gui_buffer_set_nicklist (buffer, number); + gui_window_refresh_windows (); + } + } + else if (string_strcasecmp (property, "nick_case_sensitive") == 0) + { + error = NULL; + number = strtol (value, &error, 10); + if (error && (error[0] == '\0')) + gui_buffer_set_nick_case_sensitive (buffer, number); + } + else if (string_strcasecmp (property, "nick") == 0) + { + gui_buffer_set_nick (buffer, value); + gui_input_draw (buffer, 1); + } } /* diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 5380a54f3..9adac88a2 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -151,6 +151,7 @@ extern void gui_buffer_set_log (struct t_gui_buffer *, char *); extern void gui_buffer_set_title (struct t_gui_buffer *, char *); extern void gui_buffer_set_nick_case_sensitive (struct t_gui_buffer *, int); extern void gui_buffer_set_nick (struct t_gui_buffer *, char *); +extern void gui_buffer_set (struct t_gui_buffer *, char *, char *); extern struct t_gui_buffer *gui_buffer_search_main (); extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *, char *); |