mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Remove plugin window on /close
This commit is contained in:
parent
1a7eb00763
commit
5f393a6d9f
@ -313,7 +313,7 @@ api_win_create(
|
||||
|
||||
callbacks_add_window_handler(plugin_name, tag, window);
|
||||
|
||||
wins_new_plugin(tag);
|
||||
wins_new_plugin(plugin_name, tag);
|
||||
|
||||
// set status bar active
|
||||
ProfPluginWin *pluginwin = wins_get_plugin(tag);
|
||||
|
@ -220,6 +220,16 @@ callbacks_win_exists(const char *const plugin_name, const char *tag)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
callbacks_remove_win(const char *const plugin_name, const char *const tag)
|
||||
{
|
||||
GHashTable *window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
|
||||
if (window_callbacks) {
|
||||
g_hash_table_remove(window_callbacks, tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback)
|
||||
{
|
||||
|
@ -72,5 +72,6 @@ void callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *tim
|
||||
gboolean callbacks_win_exists(const char *const plugin_name, const char *tag);
|
||||
void callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback);
|
||||
void * callbacks_get_window_handler(const char *tag);
|
||||
void callbacks_remove_win(const char *const plugin_name, const char *const tag);
|
||||
|
||||
#endif
|
||||
|
@ -286,6 +286,12 @@ plugins_win_process_line(char *win, const char * const line)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
plugins_close_win(const char *const plugin_name, const char *const tag)
|
||||
{
|
||||
callbacks_remove_win(plugin_name, tag);
|
||||
}
|
||||
|
||||
void
|
||||
plugins_on_start(void)
|
||||
{
|
||||
|
@ -134,6 +134,7 @@ char* plugins_pre_priv_message_send(const char *const jid, const char *const mes
|
||||
void plugins_post_priv_message_send(const char *const jid, const char *const message);
|
||||
|
||||
void plugins_win_process_line(char *win, const char *const line);
|
||||
void plugins_close_win(const char *const plugin_name, const char *const tag);
|
||||
|
||||
char* plugins_on_message_stanza_send(const char *const text);
|
||||
gboolean plugins_on_message_stanza_receive(const char *const text);
|
||||
|
@ -344,7 +344,7 @@ ProfWin* win_create_chat(const char *const barejid);
|
||||
ProfWin* win_create_muc(const char *const roomjid);
|
||||
ProfWin* win_create_muc_config(const char *const title, DataForm *form);
|
||||
ProfWin* win_create_private(const char *const fulljid);
|
||||
ProfWin* win_create_plugin(const char *const tag);
|
||||
ProfWin* win_create_plugin(const char *const plugin_name, const char *const tag);
|
||||
void win_update_virtual(ProfWin *window);
|
||||
void win_free(ProfWin *window);
|
||||
gboolean win_notify_remind(ProfWin *window);
|
||||
|
@ -190,6 +190,7 @@ typedef struct prof_xml_win_t {
|
||||
typedef struct prof_plugin_win_t {
|
||||
ProfWin super;
|
||||
char *tag;
|
||||
char *plugin_name;
|
||||
unsigned long memcheck;
|
||||
} ProfPluginWin;
|
||||
|
||||
|
@ -238,13 +238,14 @@ win_create_xmlconsole(void)
|
||||
}
|
||||
|
||||
ProfWin*
|
||||
win_create_plugin(const char *const tag)
|
||||
win_create_plugin(const char *const plugin_name, const char *const tag)
|
||||
{
|
||||
ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin));
|
||||
new_win->super.type = WIN_PLUGIN;
|
||||
new_win->super.layout = _win_create_simple_layout();
|
||||
|
||||
new_win->tag = strdup(tag);
|
||||
new_win->plugin_name = strdup(plugin_name);
|
||||
|
||||
new_win->memcheck = PROFPLUGINWIN_MEMCHECK;
|
||||
|
||||
|
@ -580,6 +580,7 @@ wins_close_by_num(int i)
|
||||
case WIN_PLUGIN:
|
||||
{
|
||||
ProfPluginWin *pluginwin = (ProfPluginWin*)window;
|
||||
plugins_close_win(pluginwin->plugin_name, pluginwin->tag);
|
||||
autocomplete_remove(wins_ac, pluginwin->tag);
|
||||
autocomplete_remove(wins_close_ac, pluginwin->tag);
|
||||
break;
|
||||
@ -681,12 +682,12 @@ wins_new_private(const char *const fulljid)
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
wins_new_plugin(const char * const tag)
|
||||
wins_new_plugin(const char *const plugin_name, const char * const tag)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
g_list_free(keys);
|
||||
ProfWin *newwin = win_create_plugin(tag);
|
||||
ProfWin *newwin = win_create_plugin(plugin_name, tag);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
autocomplete_add(wins_ac, tag);
|
||||
autocomplete_add(wins_close_ac, tag);
|
||||
|
@ -44,7 +44,7 @@ ProfWin* wins_new_chat(const char *const barejid);
|
||||
ProfWin* wins_new_muc(const char *const roomjid);
|
||||
ProfWin* wins_new_muc_config(const char *const roomjid, DataForm *form);
|
||||
ProfWin* wins_new_private(const char *const fulljid);
|
||||
ProfWin* wins_new_plugin(const char *const tag);
|
||||
ProfWin* wins_new_plugin(const char *const plugin_name, const char *const tag);
|
||||
|
||||
gboolean wins_chat_exists(const char *const barejid);
|
||||
GList* wins_get_private_chats(const char *const roomjid);
|
||||
|
@ -497,7 +497,7 @@ ProfWin* win_create_private(const char * const fulljid)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
ProfWin* win_create_plugin(const char * const tag)
|
||||
ProfWin* win_create_plugin(const char *const plugin_name, const char * const tag)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user