1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-01 04:14:16 -04:00

Merge pull request #786 from ailin-nemui/show-inital-nick

show initial nick and name on first start
This commit is contained in:
ailin-nemui 2017-11-15 16:28:22 +01:00 committed by GitHub
commit 4e8c1548e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 93 additions and 28 deletions

View File

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

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

View File

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

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

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)
{
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)