/* $Id$ */ /* * Cantus Tag Editor * Copyright © 2002-2004 by Samuel Abels * Copyright © 2007 by Tim Huetz * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see **/ /* be sure that we include the config.h (if we have one) */ #ifdef HAVE_CONFIG_H # include #endif /* needed includes */ #include #include #include #include #include #include #include #include #include Mainwindow mainwindow; Controller controller; // This also inits gthreads! GUIController guicontroller; int main( int argc, char **argv ) { /* if we're creating a localizable build, setup the needed stuff */ #if defined( ENABLE_NLS ) bindtextdomain( GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR ); bind_textdomain_codeset( GETTEXT_PACKAGE, "UTF-8" ); textdomain( GETTEXT_PACKAGE ); #endif /* initialize the gtk application */ Gtk::Main gtkmain( argc, argv ); Gtk::Window * pwindow = mainwindow.create(); std::string configfile = getenv("HOME"); configfile.append("/.cantus3rc"); /* be sure that the main windows was created and initialize the gui controller */ g_assert(pwindow != NULL); guicontroller.init(); /* set the default preferences */ controller.preferences->set_bool( "General:UnicodeEnabled", TRUE ); controller.preferences->set_bool( "UIGTK2:Pluginarea1:Visible", FALSE ); controller.preferences->set_bool( "UIGTK2:Pluginarea2:Visible", TRUE ); controller.preferences->set_bool( "UIGTK2:Browser:UseDefaultdir", FALSE ); controller.preferences->set_char( "UIGTK2:Browser:Defaultdir", getenv("PWD") ); controller.preferences->set_char( "UIGTK2:Browser:Filetypes", "*.mp3,*.ogg" ); controller.preferences->commit(); /* initialize the configuration file */ controller.configfile->set_filename( configfile ); if( controller.configfile->check() != 0 && controller.configfile_save() != 0 ) { std::cerr << "Error: Configfile initialization failed (" << configfile << "). Aborting.\n"; return 1; } /* now, the configuration file *must* exist. Load the config */ if( controller.configfile_load() != 0 ) { std::cerr << "Error: Failed to load config. (" << configfile << ")\n"; return 1; } if( !controller.preferences->commit() ) { std::cerr << "Error: Invalid configfile. (" << configfile << ")\n"; return 1; } /* load plugins */ controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_id3v1.so", 1 ); controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_id3v2.so", 2 ); controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_vorbis.so", 3 ); controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_id3copier.so", 4 ); controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_mpegheader.so", 5 ); controller.pluginhandler->reg( PACKAGE_LIB_DIR "/libcantusplugin_tag2filename.so", 6 ); /* apply the preferences */ controller.preferences->commit(); if( controller.preferences->get_bool( "UIGTK2:Browser:UseDefaultdir" ) ) { mainwindow.m_fileBrowser->set_dir( controller.preferences->get_char( "UIGTK2:Browser:Defaultdir" ) ); } else { mainwindow.m_fileBrowser->set_dir( getenv( "PWD" ) ); } /* run the application */ gtkmain.run( *pwindow ); /* save the configuration */ if( controller.configfile_save() != 0 ) { std::cerr << "Error: Unable to save config (" << configfile << ").\n"; return 1; } /* anything ok */ return( 0 ); }