mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
"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
This commit is contained in:
parent
b500815724
commit
cb763a0b52
src/core
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user