4 Copyright (C) 1999-2000 Timo Sirainen
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "module-formats.h"
29 #include "printtext.h"
30 #include "fe-common-core.h"
31 #include "fe-common-silc.h"
35 #include "gui-entry.h"
36 #include "mainwindows.h"
37 #include "gui-printtext.h"
38 #include "gui-readline.h"
39 #include "statusbar.h"
40 #include "gui-windows.h"
44 #ifdef HAVE_STATIC_PERL
45 void perl_core_init(void);
46 void perl_core_deinit(void);
48 void fe_perl_init(void);
49 void fe_perl_deinit(void);
53 void silc_deinit(void);
55 void gui_expandos_init(void);
56 void gui_expandos_deinit(void);
58 void textbuffer_commands_init(void);
59 void textbuffer_commands_deinit(void);
61 void lastlog_init(void);
62 void lastlog_deinit(void);
64 void mainwindow_activity_init(void);
65 void mainwindow_activity_deinit(void);
67 void mainwindows_save_init(void);
68 void mainwindows_save_deinit(void);
70 static GMainLoop *main_loop;
73 static const char *firsttimer_text =
74 "Looks like this is the first time you run irssi.\n"
75 "This is just a reminder that you really should go read\n"
76 "startup-HOWTO if you haven't already. Irssi's default\n"
77 "settings aren't probably what you've used to, and you\n"
78 "shouldn't judge the whole client as crap based on them.\n\n"
79 "You can find startup-HOWTO and more irssi beginner info at\n"
80 "http://irssi.org/beginner/";
81 static int display_firsttimer = FALSE;
84 static void sig_exit(void)
89 /* redraw irssi's screen.. */
90 void irssi_redraw(void)
98 statusbar_redraw(NULL);
103 static void textui_init(void)
105 static struct poptOption options[] = {
107 { NULL, '\0', 0, NULL }
110 args_register(options);
112 irssi_gui = IRSSI_GUI_TEXT;
115 fe_common_core_init();
116 fe_common_silc_init();
118 theme_register(gui_text_formats);
119 signal_add("gui exit", (SIGNAL_FUNC) sig_exit);
122 static void textui_finish_init(void)
126 screen_refresh_freeze();
128 textbuffer_view_init();
129 textbuffer_commands_init();
132 gui_printtext_init();
136 mainwindow_activity_init();
137 mainwindows_save_init();
143 fe_common_core_finish_init();
145 #ifdef HAVE_STATIC_PERL
149 signal_emit("irssi init finished", 0);
152 if (display_firsttimer) {
153 printtext_window(active_win, MSGLEVEL_CLIENTNOTICE,
154 "%s", firsttimer_text);
158 screen_refresh_thaw();
161 static void textui_deinit(void)
163 signal(SIGINT, SIG_DFL);
165 screen_refresh_freeze();
166 while (modules != NULL)
167 module_unload(modules->data);
169 signal_remove("gui exit", (SIGNAL_FUNC) sig_exit);
173 gui_printtext_deinit();
174 gui_readline_deinit();
175 gui_windows_deinit();
176 mainwindows_save_deinit();
177 mainwindow_activity_deinit();
178 mainwindows_deinit();
179 gui_expandos_deinit();
181 textbuffer_commands_deinit();
182 textbuffer_view_deinit();
185 screen_refresh_thaw();
188 #ifdef HAVE_STATIC_PERL
195 fe_common_silc_deinit();
196 fe_common_core_deinit();
201 static void check_oldcrap(void)
204 char *path, str[256];
207 /* check that default.theme is up-to-date */
208 path = g_strdup_printf("%s/.silc/default.theme", g_get_home_dir());
209 f = fopen(path, "r+");
215 while (!found && fgets(str, sizeof(str), f) != NULL)
216 found = strstr(str, "abstracts = ") != NULL;
224 printf("\nYou seem to have old default.theme in ~/.silc/ directory.\n");
225 printf("Themeing system has changed a bit since last irssi release,\n");
226 printf("you should either delete your old default.theme or manually\n");
227 printf("merge it with the new default.theme.\n\n");
228 printf("Do you want to delete the old theme now? (Y/n)\n");
231 fgets(str, sizeof(str), stdin);
232 if (toupper(str[0]) == 'Y' || str[0] == '\n' || str[0] == '\0')
237 static void check_files(void)
242 path = g_strdup_printf("%s/.silc", g_get_home_dir());
243 if (stat(path, &statbuf) != 0) {
244 /* ~/.irssi doesn't exist, first time running irssi */
245 display_firsttimer = TRUE;
253 static void winsock_init(void)
255 WORD wVersionRequested;
258 wVersionRequested = MAKEWORD(2, 2);
260 if (WSAStartup(wVersionRequested, &wsaData) != 0) {
261 printf("Error initializing winsock\n");
267 int main(int argc, char **argv)
277 /* initialize the i18n stuff */
278 bindtextdomain(PACKAGE, LOCALEDIR);
285 args_execute(argc, argv);
289 g_error("Can't initialize screen handling, quitting.\n");
291 textui_finish_init();
292 main_loop = g_main_new(TRUE);
295 g_main_iteration(TRUE);
296 screen_check_resizes();
299 g_main_destroy(main_loop);