int main(int argc, char *argv[]) { gboolean root_override=FALSE, open_in_new_window = FALSE; GList *filenames = NULL, *projectfiles=NULL; gint linenumber = -1; Tbfwin *firstbfwin; #ifndef NOSPLASH GtkWidget *splash_window; #endif /* #ifndef NOSPLASH */ #ifdef ENABLE_NLS setlocale(LC_ALL,""); bindtextdomain(PACKAGE,LOCALEDIR); DEBUG_MSG("set bindtextdomain for %s to %s\n",PACKAGE,LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #ifdef HAVE_ATLEAST_GNOMEUI_2_6 gnome_init(PACKAGE, VERSION, argc, argv); #else gtk_init(&argc, &argv); #endif /* HAVE_ATLEAST_GNOMEUI_2_6 */ main_v = g_new0(Tmain, 1); main_v->session = g_new0(Tsessionvars,1); DEBUG_MSG("main, main_v is at %p\n", main_v); rcfile_check_directory(); rcfile_parse_main(); parse_commandline(argc, argv, &root_override, &filenames, &projectfiles, &open_in_new_window, &linenumber); #ifdef WITH_MSG_QUEUE if (((filenames || projectfiles) && (main_v->props.view_bars & MODE_REUSE_WINDOW)) || open_in_new_window) { msg_queue_start(filenames, projectfiles, linenumber, open_in_new_window); } #endif /* WITH_MSG_QUEUE */ #ifndef NOSPLASH /* start splash screen somewhere here */ splash_window = start_splash_screen(); splash_screen_set_label(_("parsing highlighting file...")); #endif /* #ifndef NOSPLASH */ { gchar *filename = g_strconcat(g_get_home_dir(), "/.winefish/dir_history", NULL); main_v->recent_directories = get_stringlist(filename, NULL); g_free(filename); } rcfile_parse_global_session(); rcfile_parse_highlighting(); #ifndef NOSPLASH splash_screen_set_label(_("compiling highlighting patterns...")); #endif /* #ifndef NOSPLASH */ hl_init(); #ifndef NOSPLASH splash_screen_set_label(_("initialize some other things...")); #endif /* #ifndef NOSPLASH */ filebrowserconfig_init(); filebrowser_filters_rebuild(); autoclosing_init(); #ifndef NOSPLASH splash_screen_set_label(_("parsing autotext and words file...")); #endif /* #ifndef NOSPLASH */ autotext_init(); completion_init(); #ifndef NOSPLASH splash_screen_set_label(_("parsing custom menu file...")); #endif /* #ifndef NOSPLASH */ rcfile_parse_custom_menu(FALSE,FALSE); #ifdef SNOOPER2 #ifndef NOSPLASH splash_screen_set_label(_("parsing keymap and initializing function list...")); #endif /* #ifndef NOSPLASH */ funclist_init(); keymap_init(); #endif /* SNOOPER2 */ main_v->tooltips = gtk_tooltips_new(); /* initialize the completion window */ /* main_v->completion.window = NULL; */ fref_init(); bmark_init(); #ifdef WITH_MSG_QUEUE if (!filenames && !projectfiles && (main_v->props.view_bars & MODE_REUSE_WINDOW)) { msg_queue_start(NULL, NULL, -1, open_in_new_window); } #endif /* WITH_MSG_QUEUE */ #ifndef NOSPLASH splash_screen_set_label(_("creating main gui...")); #endif /* #ifndef NOSPLASH */ /* create the first window */ firstbfwin = g_new0(Tbfwin,1); firstbfwin->session = main_v->session; firstbfwin->bookmarkstore = main_v->bookmarkstore; main_v->bfwinlist = g_list_append(NULL, firstbfwin); gui_create_main(firstbfwin, filenames, linenumber); bmark_reload(firstbfwin); #ifndef NOSPLASH splash_screen_set_label(_("showing main gui...")); #endif /* #ifndef NOSPLASH */ /* set GTK settings, must be AFTER the menu is created */ { gchar *shortcutfilename; GtkSettings* gtksettings = gtk_settings_get_default(); g_object_set(G_OBJECT(gtksettings), "gtk-can-change-accels", TRUE, NULL); shortcutfilename = g_strconcat(g_get_home_dir(), "/.winefish/menudump_2", NULL); gtk_accel_map_load(shortcutfilename); g_free(shortcutfilename); } gui_show_main(firstbfwin); /* if (main_v->props.view_html_toolbar && main_v->globses.quickbar_items == NULL) { info_dialog(firstbfwin->main_window, _("Winefish tip:"), _("This message is shown since you DONOT have any items in the QuickBar.\n\nIf you right-click a button in the Standard toolbars you can add buttons to the Quickbar.")); } */ if (projectfiles) { GList *tmplist = g_list_first(projectfiles); while (tmplist) { project_open_from_file(firstbfwin, tmplist->data, linenumber); tmplist = g_list_next(tmplist); } } #ifndef NOSPLASH DEBUG_MSG("destroy splash\n"); flush_queue(); { static struct timespec const req = { 0, 10000000}; nanosleep(&req, NULL); } gtk_widget_destroy(splash_window); #endif /* #ifndef NOSPLASH */ /* snooper must be installed after the main gui has shown; otherwise the program may be aborted */ #ifndef SNOOPER2 snooper_install(); #endif /* SNOOPER2 */ DEBUG_MSG("main, before gtk_main()\n"); gtk_main(); DEBUG_MSG("main, after gtk_main()\n"); #ifdef WITH_MSG_QUEUE /* do the cleanup */ msg_queue_cleanup(); #endif /* WITH_MSG_QUEUE */ DEBUG_MSG("Winefish: exiting cleanly\n"); return 0; }
int main(int argc, char *argv[]) { GdkPixbuf *icon; /* Redirect standard output to a file - printing to the Windows terminal slows operation down way too much */ #ifdef __WIN32__ gchar *tmp; FILE *log_file; tmp = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S, LOG_FILE, NULL); log_file = g_fopen(tmp, "wt"); g_free(tmp); if (log_file != NULL) g_log_set_default_handler(&default_log_handler, log_file); #endif // Force GLib 2.32+ to print info and debug messages like older versions did, unless this variable is already set. // No effect on earlier GLib versions. g_setenv("G_MESSAGES_DEBUG", "all", /* overwrite = */ FALSE); /* Init the tilp core */ tilp_init(&argc, &argv); /* Init GTK+ */ gtk_init(&argc, &argv); add_pixmap_directory(inst_paths.pixmap_dir); add_pixmap_directory(inst_paths.icon_dir); splash_screen_start(); /* Get rid of glib, gdk, gtk warnings when compiled in Release mode */ #if !defined(_DEBUG) g_log_set_handler ("GLib", G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, my_blackhole_log_handler, NULL); g_log_set_handler ("Gdk", G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, my_blackhole_log_handler, NULL); g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, my_blackhole_log_handler, NULL); g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION, my_blackhole_log_handler, NULL); #endif /* Init the GUI-independent functions */ tilp_gif_set_gtk(); tilp_update_set_gtk(); /* Create the main window */ if(!(working_mode & MODE_CMD)) { #if WITH_KDE splash_screen_set_label(_("Initializing KDE...")); sp_kde_init(argc, argv, "tilp", _("TiLP"), VERSION, _("Tilp Is a Linking Program"), "Copyright (c) 1999-2008 Romain Lievin", "http://lpg.ticalc.org/prj_tilp/", "*****@*****.**"); atexit(sp_kde_finish); // Not needed unless we want to add a DCOP interface. // g_timeout_add(26, sp_kde_process_qt_events, NULL); #endif splash_screen_set_label(_("Loading GUI...")); main_wnd = display_tilp_dbox(); } /* Do a local directory list */ g_free(local.cwdir); local.cwdir = g_get_current_dir(); /* Update the local view (not visible yet) */ if(!(working_mode & MODE_CMD)) { clist_refresh(); labels_refresh(); } /* Inits are done ! */ working_mode &= ~MODE_INI; tilp_err(0); // pop errors (display console mode) /* In cmdline, does not display the entire window, only the pbar */ if(!(working_mode & MODE_CMD)) { gtk_widget_show(main_wnd); toolbar_refresh_buttons(); icon = create_pixbuf("tilp.xpm"); gtk_window_set_icon(GTK_WINDOW(main_wnd), icon); gdk_window_set_icon_name(main_wnd->window, _("TiLP2")); } /* If variables have been passed on the command line in GUI mode then send them */ if((working_mode & MODE_GUI) && (working_mode & MODE_CMD)) { splash_screen_set_label(_("Command line...")); if(local.selection0 || local.selection2 || local.selection5) on_tilp_send(""); else if(local.selection4) tilp_cmdline_send(); } /* GTK main loop */ splash_screen_stop(); if(!(working_mode & MODE_CMD)) gtk_main(); tilp_exit(); return 0; }