diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 4 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-main.c | 4 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 14 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 13 |
4 files changed, 29 insertions, 6 deletions
diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index e0f9e2547..d2230e3dd 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -102,7 +102,9 @@ gui_main_init () if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100)) { gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL, NULL); + ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", + NULL, NULL, + NULL, NULL); if (ptr_buffer) { gui_init_ok = 1; diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c index 19add6ddc..b00ce369f 100644 --- a/src/gui/gtk/gui-gtk-main.c +++ b/src/gui/gtk/gui-gtk-main.c @@ -170,7 +170,9 @@ gui_main_init () if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100)) { gui_current_window = gui_windows; - ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL, NULL); + ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", + NULL, NULL, + NULL, NULL); if (ptr_buffer) { gui_init_ok = 1; diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 4c2df12a1..a5a4bbdc6 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -69,7 +69,10 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name, int (*input_callback)(void *data, struct t_gui_buffer *buffer, char *input_data), - void *input_callback_data) + void *input_callback_data, + int (*close_callback)(void *data, + struct t_gui_buffer *buffer), + void *close_callback_data) { struct t_gui_buffer *new_buffer; struct t_gui_completion *new_completion; @@ -99,6 +102,10 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name, new_buffer->notify_level = GUI_BUFFER_NOTIFY_LEVEL_DEFAULT; new_buffer->num_displayed = 0; + /* close callback */ + new_buffer->close_callback = close_callback; + new_buffer->close_callback_data = close_callback_data; + /* title */ new_buffer->title = NULL; new_buffer->title_refresh_needed = 1; @@ -623,6 +630,11 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another) hook_signal_send ("buffer_close", WEECHAT_HOOK_SIGNAL_POINTER, buffer); + if (buffer->close_callback) + { + (void)(buffer->close_callback) (buffer->close_callback_data, buffer); + } + if (switch_to_another) { for (ptr_window = gui_windows; ptr_window; diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 63fb6dcce..f1fb94c91 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -64,6 +64,11 @@ struct t_gui_buffer /* 3 = highlight + msg + join/part */ int num_displayed; /* number of windows displaying buf. */ + /* close callback */ + int (*close_callback)(void *data, /* called when buffer is closed */ + struct t_gui_buffer *buffer); + void *close_callback_data; /* data for callback */ + /* buffer title */ char *title; /* buffer title */ int title_refresh_needed; /* refresh for title is needed ? */ @@ -87,10 +92,9 @@ struct t_gui_buffer /* inupt */ int input; /* = 1 if input is enabled */ - int (*input_callback)(void *data, + int (*input_callback)(void *data, /* called when user send data */ struct t_gui_buffer *buffer, char *input_data); - /* called when user send data */ void *input_callback_data; /* data for callback */ /* to this buffer */ char *input_nick; /* self nick */ @@ -139,7 +143,10 @@ extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin, int (*input_callback)(void *data, struct t_gui_buffer *buffer, char *input_data), - void *input_callback_data); + void *input_callback_data, + int (*close_callback)(void *data, + struct t_gui_buffer *buffer), + void *close_callback_data); extern int gui_buffer_valid (struct t_gui_buffer *buffer); extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property); extern void gui_buffer_set_category (struct t_gui_buffer *buffer, |