From b0fa4dd46d8bf1cf63880fabf2105dd9134100df Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Wed, 1 Nov 2017 15:48:35 +0100 Subject: show initial nick and name on first start --- src/fe-text/irssi.c | 49 ++++++++++++++++++++++---------------------- src/fe-text/module-formats.c | 21 +++++++++++++++++++ src/fe-text/module-formats.h | 6 ++++++ 3 files changed, 52 insertions(+), 24 deletions(-) (limited to 'src/fe-text') diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index b5df47c9..6349ae2a 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 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_INT(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 & (1<<0)) + fe_settings_set_print("real_name"); + if (user_settings_changed & (1<<1)) + fe_settings_set_print("user_name"); + if (user_settings_changed & (1<<2)) + fe_settings_set_print("nick"); + if (user_settings_changed & (1<<3)) + fe_settings_set_print("hostname"); } static void textui_deinit(void) @@ -223,6 +223,7 @@ static void textui_deinit(void) #endif 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(); @@ -249,6 +250,7 @@ static void textui_deinit(void) core_deinit(); } + static void check_files(void) { struct stat statbuf; @@ -259,12 +261,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 }; -- cgit v1.2.3 From 02c677f467b398f8b91b1e90544502ff98a6e0da Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Fri, 10 Nov 2017 22:02:36 +0100 Subject: use enum --- src/fe-text/irssi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/fe-text') diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index 6349ae2a..ef443670 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -81,7 +81,7 @@ static GMainLoop *main_loop; int quitting; static int display_firsttimer = FALSE; -static int user_settings_changed = 0; +static unsigned int user_settings_changed = 0; static void sig_exit(void) @@ -91,7 +91,7 @@ static void sig_exit(void) static void sig_settings_userinfo_changed(gpointer changedp) { - user_settings_changed = GPOINTER_TO_INT(changedp); + user_settings_changed = GPOINTER_TO_UINT(changedp); } /* redraw irssi's screen.. */ @@ -199,13 +199,13 @@ static void textui_finish_init(void) /* see irc-servers-setup.c:init_userinfo */ if (user_settings_changed) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_WELCOME_INIT_SETTINGS); - if (user_settings_changed & (1<<0)) + if (user_settings_changed & USER_SETTINGS_REAL_NAME) fe_settings_set_print("real_name"); - if (user_settings_changed & (1<<1)) + if (user_settings_changed & USER_SETTINGS_USER_NAME) fe_settings_set_print("user_name"); - if (user_settings_changed & (1<<2)) + if (user_settings_changed & USER_SETTINGS_NICK) fe_settings_set_print("nick"); - if (user_settings_changed & (1<<3)) + if (user_settings_changed & USER_SETTINGS_HOSTNAME) fe_settings_set_print("hostname"); } @@ -222,7 +222,7 @@ 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); @@ -250,7 +250,6 @@ static void textui_deinit(void) core_deinit(); } - static void check_files(void) { struct stat statbuf; -- cgit v1.2.3