mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Check for plugin win before creating
This commit is contained in:
parent
9a0111c10a
commit
1a7eb00763
@ -302,6 +302,10 @@ api_win_create(
|
|||||||
void(*callback_exec)(PluginWindowCallback *window_callback, const char *tag, const char * const line),
|
void(*callback_exec)(PluginWindowCallback *window_callback, const char *tag, const char * const line),
|
||||||
void(*callback_destroy)(void *callback))
|
void(*callback_destroy)(void *callback))
|
||||||
{
|
{
|
||||||
|
if (callbacks_win_exists(plugin_name, tag)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback));
|
PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback));
|
||||||
window->callback = callback;
|
window->callback = callback;
|
||||||
window->callback_exec = callback_exec;
|
window->callback_exec = callback_exec;
|
||||||
|
@ -206,6 +206,20 @@ callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_fu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
callbacks_win_exists(const char *const plugin_name, const char *tag)
|
||||||
|
{
|
||||||
|
GHashTable *window_callbacks = g_hash_table_lookup(p_window_callbacks, plugin_name);
|
||||||
|
if (window_callbacks) {
|
||||||
|
PluginWindowCallback *cb = g_hash_table_lookup(window_callbacks, tag);
|
||||||
|
if (cb) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback)
|
callbacks_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback)
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,7 @@ void callbacks_close(void);
|
|||||||
|
|
||||||
void callbacks_add_command(const char *const plugin_name, PluginCommand *command);
|
void callbacks_add_command(const char *const plugin_name, PluginCommand *command);
|
||||||
void callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_function);
|
void callbacks_add_timed(const char *const plugin_name, PluginTimedFunction *timed_function);
|
||||||
|
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_add_window_handler(const char *const plugin_name, const char *tag, PluginWindowCallback *window_callback);
|
||||||
void * callbacks_get_window_handler(const char *tag);
|
void * callbacks_get_window_handler(const char *tag);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#include "window_list.h"
|
#include "window_list.h"
|
||||||
#include "plugins/plugins.h"
|
#include "plugins/plugins.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
#include "config/preferences.h"
|
||||||
|
|
||||||
static GHashTable *windows;
|
static GHashTable *windows;
|
||||||
static int current;
|
static int current;
|
||||||
@ -227,26 +227,19 @@ wins_get_plugin(const char *const tag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wins_close_plugin(const char *const tag)
|
wins_close_plugin(char *tag)
|
||||||
{
|
{
|
||||||
GList *values = g_hash_table_get_values(windows);
|
ProfWin *toclose = wins_get_by_string(tag);
|
||||||
GList *curr = values;
|
if (toclose == NULL) {
|
||||||
|
return;
|
||||||
while (curr) {
|
|
||||||
ProfWin *window = curr->data;
|
|
||||||
if (window->type == WIN_PLUGIN) {
|
|
||||||
ProfPluginWin *pluginwin = (ProfPluginWin*)window;
|
|
||||||
if (g_strcmp0(pluginwin->tag, tag) == 0) {
|
|
||||||
int num = wins_get_num(window);
|
|
||||||
wins_close_by_num(num);
|
|
||||||
g_list_free(values);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
curr = g_list_next(curr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free(values);
|
int index = wins_get_num(toclose);
|
||||||
|
ui_close_win(index);
|
||||||
|
|
||||||
|
if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) {
|
||||||
|
wins_tidy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GList*
|
GList*
|
||||||
|
@ -61,7 +61,7 @@ ProfPrivateWin* wins_get_private(const char *const fulljid);
|
|||||||
ProfPluginWin* wins_get_plugin(const char *const tag);
|
ProfPluginWin* wins_get_plugin(const char *const tag);
|
||||||
ProfXMLWin* wins_get_xmlconsole(void);
|
ProfXMLWin* wins_get_xmlconsole(void);
|
||||||
|
|
||||||
void wins_close_plugin(const char *const tag);
|
void wins_close_plugin(char *tag);
|
||||||
|
|
||||||
ProfWin* wins_get_current(void);
|
ProfWin* wins_get_current(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user