summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-14 19:10:17 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-14 19:10:17 +0000
commitcb763a0b5209a9ca96f469cfa1d282a2398f9f56 (patch)
tree9df35985288f606d7f3bdabb028f53e5055e040f /src
parentb500815724149a2183a6c926f1405f9522962cf8 (diff)
downloadirssi-cb763a0b5209a9ca96f469cfa1d282a2398f9f56.zip
"gui dialog" signals can now be safely emitted before the GUI is initialized
- the texts are queued until the GUI initialization is done and re-emitted. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1618 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/core.c35
-rw-r--r--src/core/settings.c25
2 files changed, 45 insertions, 15 deletions
diff --git a/src/core/core.c b/src/core/core.c
index 62bf7904..f023552d 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -49,6 +49,8 @@ void chat_commands_deinit(void);
int irssi_gui;
+static GSList *dialog_type_queue, *dialog_text_queue;
+
static void read_signals(void)
{
#ifndef WIN32
@@ -78,8 +80,37 @@ static void read_signals(void)
#endif
}
+static void sig_gui_dialog(const char *type, const char *text)
+{
+ dialog_type_queue = g_slist_append(dialog_type_queue, g_strdup(type));
+ dialog_text_queue = g_slist_append(dialog_text_queue, g_strdup(text));
+}
+
+static void sig_init_finished(void)
+{
+ GSList *type, *text;
+
+ signal_remove("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
+ signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+
+ /* send the dialog texts that were in queue before irssi
+ was initialized */
+ type = dialog_type_queue;
+ text = dialog_text_queue;
+ for (; text != NULL; text = text->next, type = type->next) {
+ signal_emit("gui dialog", 2, type->data, text->data);
+ g_free(type->data);
+ g_free(text->data);
+ }
+ g_slist_free(dialog_type_queue);
+ g_slist_free(dialog_text_queue);
+}
+
void core_init(void)
{
+ dialog_type_queue = NULL;
+ dialog_text_queue = NULL;
+
modules_init();
#ifndef WIN32
pidwait_init();
@@ -88,6 +119,10 @@ void core_init(void)
net_disconnect_init();
net_sendbuffer_init();
signals_init();
+
+ signal_add_first("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
+ signal_add_first("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+
settings_init();
commands_init();
nickmatch_cache_init();
diff --git a/src/core/settings.c b/src/core/settings.c
index d2482106..983ca7d2 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -32,7 +32,6 @@
CONFIG_REC *mainconfig;
static GString *last_errors;
-static char *last_config_error_msg;
static GSList *last_invalid_modules;
static int fe_initialized;
static int config_changed; /* FIXME: remove after .98 (unless needed again) */
@@ -274,11 +273,6 @@ static void sig_init_finished(void)
g_string_free(last_errors, TRUE);
}
- if (last_config_error_msg != NULL) {
- signal_emit("gui dialog", 2, "error", last_config_error_msg);
- g_free_and_null(last_config_error_msg);
- }
-
if (config_changed) {
/* some backwards compatibility changes were made to
config file, reload it */
@@ -489,7 +483,7 @@ static CONFIG_REC *parse_configfile(const char *fname)
CONFIG_REC *config;
struct stat statbuf;
const char *path;
- char *real_fname;
+ char *real_fname, *str;
real_fname = fname != NULL ? g_strdup(fname) :
g_strdup_printf("%s"G_DIR_SEPARATOR_S".irssi"
@@ -510,9 +504,11 @@ static CONFIG_REC *parse_configfile(const char *fname)
config = config_open(path, -1);
if (config == NULL) {
- last_config_error_msg =
- g_strdup_printf("Error opening configuration file %s: %s",
- path, g_strerror(errno));
+ str = g_strdup_printf("Error opening configuration file %s: %s",
+ path, g_strerror(errno));
+ signal_emit("gui dialog", 2, "error", str);
+ g_free(str);
+
config = config_open(NULL, -1);
}
@@ -549,10 +545,10 @@ static void init_configfile(void)
/* any errors? */
if (config_last_error(mainconfig) != NULL) {
- last_config_error_msg =
- g_strdup_printf("Ignored errors in configuration "
- "file:\n%s",
- config_last_error(mainconfig));
+ str = g_strdup_printf("Ignored errors in configuration file:\n%s",
+ config_last_error(mainconfig));
+ signal_emit("gui dialog", 2, "error", str);
+ g_free(str);
}
signal(SIGTERM, sig_term);
@@ -644,7 +640,6 @@ void settings_init(void)
(GCompareFunc) g_str_equal);
last_errors = NULL;
- last_config_error_msg = NULL;
last_invalid_modules = NULL;
fe_initialized = FALSE;
config_changed = FALSE;