summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-11-15 16:28:22 +0100
committerGitHub <noreply@github.com>2017-11-15 16:28:22 +0100
commit4e8c1548e01c15a9934b1a2d02ce2396ab859957 (patch)
treed86702448fcc2db0a7eb53929e9ccb1a27059496
parent933fac7e9d4d1cea93887cb38bab51c938a8c687 (diff)
parent02c677f467b398f8b91b1e90544502ff98a6e0da (diff)
downloadirssi-4e8c1548e01c15a9934b1a2d02ce2396ab859957.zip
Merge pull request #786 from ailin-nemui/show-inital-nick
show initial nick and name on first start
-rw-r--r--src/common.h2
-rw-r--r--src/core/settings.c10
-rw-r--r--src/core/settings.h7
-rw-r--r--src/fe-common/core/Makefile.am1
-rw-r--r--src/fe-common/core/fe-settings.c7
-rw-r--r--src/fe-common/core/fe-settings.h6
-rw-r--r--src/fe-text/irssi.c50
-rw-r--r--src/fe-text/module-formats.c21
-rw-r--r--src/fe-text/module-formats.h6
-rw-r--r--src/irc/core/irc-servers-setup.c11
10 files changed, 93 insertions, 28 deletions
diff --git a/src/common.h b/src/common.h
index 159f7124..a7eaa7cf 100644
--- a/src/common.h
+++ b/src/common.h
@@ -6,7 +6,7 @@
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
-#define IRSSI_ABI_VERSION 11
+#define IRSSI_ABI_VERSION 12
#define DEFAULT_SERVER_ADD_PORT 6667
#define DEFAULT_SERVER_ADD_TLS_PORT 6697
diff --git a/src/core/settings.c b/src/core/settings.c
index 4e0717cd..3ebb9e4a 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -39,6 +39,7 @@ static GString *last_errors;
static GSList *last_invalid_modules;
static int fe_initialized;
static int config_changed; /* FIXME: remove after .98 (unless needed again) */
+static unsigned int user_settings_changed;
static GHashTable *settings;
static int timeout_tag;
@@ -464,6 +465,11 @@ SETTINGS_REC *settings_get_record(const char *key)
return g_hash_table_lookup(settings, key);
}
+static void sig_init_userinfo_changed(gpointer changedp)
+{
+ user_settings_changed |= GPOINTER_TO_UINT(changedp);
+}
+
static void sig_init_finished(void)
{
fe_initialized = TRUE;
@@ -479,6 +485,8 @@ static void sig_init_finished(void)
"updated, please /SAVE");
signal_emit("setup changed", 0);
}
+
+ signal_emit("settings userinfo changed", 1, GUINT_TO_POINTER(user_settings_changed));
}
static void settings_clean_invalid_module(const char *module)
@@ -875,6 +883,7 @@ void settings_init(void)
timeout_tag = g_timeout_add(SETTINGS_AUTOSAVE_TIMEOUT,
(GSourceFunc) sig_autosave, NULL);
signal_add("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+ signal_add("irssi init userinfo changed", (SIGNAL_FUNC) sig_init_userinfo_changed);
signal_add("gui exit", (SIGNAL_FUNC) sig_autosave);
}
@@ -887,6 +896,7 @@ void settings_deinit(void)
{
g_source_remove(timeout_tag);
signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
+ signal_remove("irssi init userinfo changed", (SIGNAL_FUNC) sig_init_userinfo_changed);
signal_remove("gui exit", (SIGNAL_FUNC) sig_autosave);
g_slist_foreach(last_invalid_modules, (GFunc) g_free, NULL);
diff --git a/src/core/settings.h b/src/core/settings.h
index d174f250..b67a9e44 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -30,6 +30,13 @@ typedef struct {
char **choices;
} SETTINGS_REC;
+enum {
+ USER_SETTINGS_REAL_NAME = 0x1,
+ USER_SETTINGS_USER_NAME = 0x2,
+ USER_SETTINGS_NICK = 0x4,
+ USER_SETTINGS_HOSTNAME = 0x8,
+};
+
/* macros for handling the default Irssi configuration */
#define iconfig_get_str(a, b, c) config_get_str(mainconfig, a, b, c)
#define iconfig_get_int(a, b, c) config_get_int(mainconfig, a, b, c)
diff --git a/src/fe-common/core/Makefile.am b/src/fe-common/core/Makefile.am
index 29cc941a..cf4e8ee3 100644
--- a/src/fe-common/core/Makefile.am
+++ b/src/fe-common/core/Makefile.am
@@ -55,6 +55,7 @@ pkginc_fe_common_core_HEADERS = \
fe-exec.h \
fe-messages.h \
fe-queries.h \
+ fe-settings.h \
fe-tls.h \
formats.h \
hilight-text.h \
diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c
index abbd45a8..de9f67a1 100644
--- a/src/fe-common/core/fe-settings.c
+++ b/src/fe-common/core/fe-settings.c
@@ -26,7 +26,7 @@
#include "misc.h"
#include "lib-config/iconfig.h"
#include "settings.h"
-
+#include "fe-settings.h"
#include "levels.h"
#include "printtext.h"
#include "keyboard.h"
@@ -41,6 +41,11 @@ static void set_print(SETTINGS_REC *rec)
g_free(value);
}
+void fe_settings_set_print(const char *key)
+{
+ set_print(settings_get_record(key));
+}
+
static void set_print_pattern(const char *pattern)
{
GSList *sets, *tmp;
diff --git a/src/fe-common/core/fe-settings.h b/src/fe-common/core/fe-settings.h
new file mode 100644
index 00000000..dd33f223
--- /dev/null
+++ b/src/fe-common/core/fe-settings.h
@@ -0,0 +1,6 @@
+#ifndef __FE_CHANNELS_H
+#define __FE_CHANNELS_H
+
+void fe_settings_set_print(const char *key);
+
+#endif
diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c
index b5df47c9..ef443670 100644
--- a/src/fe-text/irssi.c
+++ b/src/fe-text/irssi.c
@@ -31,6 +31,7 @@
#include "printtext.h"
#include "fe-common-core.h"
+#include "fe-settings.h"
#include "themes.h"
#include "term.h"
@@ -79,25 +80,8 @@ static int dirty, full_redraw;
static GMainLoop *main_loop;
int quitting;
-static const char *banner_text =
- " ___ _\n"
- "|_ _|_ _ _____(_)\n"
- " | || '_(_-<_-< |\n"
- "|___|_| /__/__/_|\n"
- "Irssi v" PACKAGE_VERSION " - http://www.irssi.org";
-
-static const char *firsttimer_text =
- "- - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
- "Hi there! If this is your first time using Irssi, you\n"
- "might want to go to our website and read the startup\n"
- "documentation to get you going.\n\n"
- "Our community and staff are available to assist you or\n"
- "to answer any questions you may have.\n\n"
- "Use the /HELP command to get detailed information about\n"
- "the available commands.\n"
- "- - - - - - - - - - - - - - - - - - - - - - - - - - - -";
-
static int display_firsttimer = FALSE;
+static unsigned int user_settings_changed = 0;
static void sig_exit(void)
@@ -105,6 +89,11 @@ static void sig_exit(void)
quitting = TRUE;
}
+static void sig_settings_userinfo_changed(gpointer changedp)
+{
+ user_settings_changed = GPOINTER_TO_UINT(changedp);
+}
+
/* redraw irssi's screen.. */
void irssi_redraw(void)
{
@@ -161,6 +150,7 @@ static void textui_init(void)
fe_common_irc_init();
theme_register(gui_text_formats);
+ signal_add("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit);
}
@@ -199,14 +189,24 @@ static void textui_finish_init(void)
statusbar_redraw(NULL, TRUE);
if (servers == NULL && lookup_servers == NULL) {
- printtext(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT,
- "%s", banner_text);
+ printformat(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT, TXT_IRSSI_BANNER);
}
if (display_firsttimer) {
- printtext(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT,
- "%s", firsttimer_text);
+ printformat(NULL, NULL, MSGLEVEL_CRAP|MSGLEVEL_NO_ACT, TXT_WELCOME_FIRSTTIME);
}
+
+ /* see irc-servers-setup.c:init_userinfo */
+ if (user_settings_changed)
+ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WELCOME_INIT_SETTINGS);
+ if (user_settings_changed & USER_SETTINGS_REAL_NAME)
+ fe_settings_set_print("real_name");
+ if (user_settings_changed & USER_SETTINGS_USER_NAME)
+ fe_settings_set_print("user_name");
+ if (user_settings_changed & USER_SETTINGS_NICK)
+ fe_settings_set_print("nick");
+ if (user_settings_changed & USER_SETTINGS_HOSTNAME)
+ fe_settings_set_print("hostname");
}
static void textui_deinit(void)
@@ -222,7 +222,8 @@ static void textui_deinit(void)
fe_perl_deinit();
#endif
- dirty_check(); /* one last time to print any quit messages */
+ dirty_check(); /* one last time to print any quit messages */
+ signal_remove("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed);
signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
lastlog_deinit();
@@ -259,12 +260,11 @@ static void check_files(void)
}
}
-
int main(int argc, char **argv)
{
static int version = 0;
static GOptionEntry options[] = {
- { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display irssi version", NULL },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display Irssi version", NULL },
{ NULL }
};
int loglev;
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index 899827c2..c4606197 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -78,5 +78,26 @@ FORMAT_REC gui_text_formats[] =
{ "paste_warning", "Pasting $0 lines to $1. Press Ctrl-K if you wish to do this or Ctrl-C to cancel.", 2, { 1, 0 } },
{ "paste_prompt", "Hit Ctrl-K to paste, Ctrl-C to abort?", 0 },
+ /* ---- */
+ { NULL, "Welcome", 0 },
+
+ { "irssi_banner",
+ " ___ _%:"
+ "|_ _|_ _ _____(_)%:"
+ " | || '_(_-<_-< |%:"
+ "|___|_| /__/__/_|%:"
+ "Irssi v$J - http://www.irssi.org", 0 },
+ { "welcome_firsttime",
+ "- - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
+ "Hi there! If this is your first time using Irssi, you%:"
+ "might want to go to our website and read the startup%:"
+ "documentation to get you going.%:%:"
+ "Our community and staff are available to assist you or%:"
+ "to answer any questions you may have.%:%:"
+ "Use the /HELP command to get detailed information about%:"
+ "the available commands.%:"
+ "- - - - - - - - - - - - - - - - - - - - - - - - - - - -", 0 },
+ { "welcome_init_settings", "The following settings were initialized", 0 },
+
{ NULL, NULL, 0 }
};
diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h
index 3fa8c511..05e9438d 100644
--- a/src/fe-text/module-formats.h
+++ b/src/fe-text/module-formats.h
@@ -52,6 +52,12 @@ enum {
TXT_PASTE_WARNING,
TXT_PASTE_PROMPT,
+ TXT_FILL_5, /* Welcome */
+
+ TXT_IRSSI_BANNER,
+ TXT_WELCOME_FIRSTTIME,
+ TXT_WELCOME_INIT_SETTINGS,
+
TXT_COUNT
};
diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c
index bae7d3b4..e79557ab 100644
--- a/src/irc/core/irc-servers-setup.c
+++ b/src/irc/core/irc-servers-setup.c
@@ -116,14 +116,17 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
static void init_userinfo(void)
{
+ unsigned int changed;
const char *set, *nick, *user_name, *str;
+ changed = 0;
/* check if nick/username/realname wasn't read from setup.. */
set = settings_get_str("real_name");
if (set == NULL || *set == '\0') {
str = g_getenv("IRCNAME");
settings_set_str("real_name",
str != NULL ? str : g_get_real_name());
+ changed |= USER_SETTINGS_REAL_NAME;
}
/* username */
@@ -134,6 +137,7 @@ static void init_userinfo(void)
str != NULL ? str : g_get_user_name());
user_name = settings_get_str("user_name");
+ changed |= USER_SETTINGS_USER_NAME;
}
/* nick */
@@ -143,15 +147,20 @@ static void init_userinfo(void)
settings_set_str("nick", str != NULL ? str : user_name);
nick = settings_get_str("nick");
+ changed |= USER_SETTINGS_NICK;
}
/* host name */
set = settings_get_str("hostname");
if (set == NULL || *set == '\0') {
str = g_getenv("IRCHOST");
- if (str != NULL)
+ if (str != NULL) {
settings_set_str("hostname", str);
+ changed |= USER_SETTINGS_HOSTNAME;
+ }
}
+
+ signal_emit("irssi init userinfo changed", 1, GUINT_TO_POINTER(changed));
}
static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)