1
0
mirror of https://github.com/irssi/irssi.git synced 2024-10-27 05:20:20 -04:00

show initial nick and name on first start

This commit is contained in:
ailin-nemui 2017-11-01 15:48:35 +01:00
parent 7e619ed990
commit b0fa4dd46d
8 changed files with 85 additions and 26 deletions

View File

@ -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 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_INT(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, GINT_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);

View File

@ -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 \

View File

@ -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;

View File

@ -0,0 +1,6 @@
#ifndef __FE_CHANNELS_H
#define __FE_CHANNELS_H
void fe_settings_set_print(const char *key);
#endif

View File

@ -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;

View File

@ -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 }
};

View File

@ -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
};

View File

@ -116,14 +116,17 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
static void init_userinfo(void)
{
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 |= 1<<0;
}
/* 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 |= 1<<1;
}
/* 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 |= 1<<2;
}
/* 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 |= 1<<3;
}
}
signal_emit("irssi init userinfo changed", 1, GINT_TO_POINTER(changed));
}
static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node)