summaryrefslogtreecommitdiff
path: root/src/core/signals.h
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2002-04-15 13:59:09 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2002-04-15 13:59:09 +0000
commit8b9c4823bfb9a1b60f31aa62eb882143e3dec153 (patch)
tree5370cc87f33e181e8d71933bddd701bb48093050 /src/core/signals.h
parent15667ec7ff00b151fde5e9d9927bb75f00f7c79a (diff)
downloadirssi-8b9c4823bfb9a1b60f31aa62eb882143e3dec153.zip
Rewritten signal handling code - it wasn't supposed to come before 0.9 irssi
but it doesn't break much things and is needed for Qt port :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2682 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/signals.h')
-rw-r--r--src/core/signals.h64
1 files changed, 43 insertions, 21 deletions
diff --git a/src/core/signals.h b/src/core/signals.h
index 795f7327..b3d5f72e 100644
--- a/src/core/signals.h
+++ b/src/core/signals.h
@@ -1,33 +1,43 @@
#ifndef __SIGNAL_H
#define __SIGNAL_H
+#define SIGNAL_PRIORITY_LOW 100
+#define SIGNAL_PRIORITY_DEFAULT 0
+#define SIGNAL_PRIORITY_HIGH -100
+
#define SIGNAL_MAX_ARGUMENTS 6
-typedef void (*SIGNAL_FUNC) (gconstpointer, gconstpointer,
- gconstpointer, gconstpointer,
- gconstpointer, gconstpointer);
+typedef void (*SIGNAL_FUNC) (const void *, const void *,
+ const void *, const void *,
+ const void *, const void *);
-void signals_init(void);
-void signals_deinit(void);
-
-/* signal name -> ID */
-#define signal_get_uniq_id(signal) \
- module_get_uniq_id_str("signals", signal)
-/* signal ID -> name */
-#define signal_get_id_str(signal_id) \
- module_find_id_str("signals", signal_id)
+extern void *signal_user_data; /* use signal_get_user_data() macro to access */
/* bind a signal */
-void signal_add_to(const char *module, int pos,
- const char *signal, SIGNAL_FUNC func);
-void signal_add_to_id(const char *module, int pos,
- int signal, SIGNAL_FUNC func);
-#define signal_add(a, b) signal_add_to(MODULE_NAME, 1, a, b)
-#define signal_add_first(a, b) signal_add_to(MODULE_NAME, 0, a, b)
-#define signal_add_last(a, b) signal_add_to(MODULE_NAME, 2, a, b)
+void signal_add_full(const char *module, int priority,
+ const char *signal, SIGNAL_FUNC func, void *user_data);
+void signal_add_full_id(const char *module, int priority,
+ int signal, SIGNAL_FUNC func, void *user_data);
+#define signal_add(signal, func) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), NULL)
+#define signal_add_first(signal, func) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), NULL)
+#define signal_add_last(signal, func) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), NULL)
+
+#define signal_add_data(signal, func, data) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), data)
+#define signal_add_first_data(signal, func, data) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), data)
+#define signal_add_last_data(signal, func, data) \
+ signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), data)
/* unbind signal */
-void signal_remove(const char *signal, SIGNAL_FUNC func);
-void signal_remove_id(int signal_id, SIGNAL_FUNC func);
+void signal_remove_full(const char *signal, SIGNAL_FUNC func, void *user_data);
+#define signal_remove(signal, func) \
+ signal_remove_full((signal), (SIGNAL_FUNC) (func), NULL)
+#define signal_remove_data(signal, func, data) \
+ signal_remove_full((signal), (SIGNAL_FUNC) (func), data)
+void signal_remove_id(int signal_id, SIGNAL_FUNC func, void *user_data);
/* emit signal */
int signal_emit(const char *signal, int params, ...);
@@ -44,8 +54,20 @@ const char *signal_get_emitted(void);
int signal_get_emitted_id(void);
/* return TRUE if specified signal was stopped */
int signal_is_stopped(int signal_id);
+/* return the user data of the signal function currently being emitted */
+#define signal_get_user_data() signal_user_data
/* remove all signals that belong to `module' */
void signals_remove_module(const char *module);
+/* signal name -> ID */
+#define signal_get_uniq_id(signal) \
+ module_get_uniq_id_str("signals", signal)
+/* signal ID -> name */
+#define signal_get_id_str(signal_id) \
+ module_find_id_str("signals", signal_id)
+
+void signals_init(void);
+void signals_deinit(void);
+
#endif