00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <new>
00027 #include <cstring>
00028
00029 #include <locale.h>
00030 #include <libintl.h>
00031
00032 #include <config.h>
00033 #include <libgnome/libgnome.h>
00034 #include <libgnome/gnome-init.h>
00035
00036 #include <gtk/gtkgl.h>
00037
00038 #include "gxsm_app.h"
00039 #include "gxsm_resoucetable.h"
00040 #include "action_id.h"
00041
00042
00043 char xxsmmaincvsrev[]="$Header: /cvsroot/gxsm/Gxsm-2.0/src/gxsm_main.C,v 1.21 2005/04/23 15:36:26 zahl Exp $";
00044 char *cvsmainrev=NULL, *cvsmaindate=NULL;
00045
00046
00047 XSMRESOURCES xsmres;
00048
00049 App *gapp = NULL;
00050 int restarted = 0;
00051 int debug_level = 0;
00052 int pi_debug_level = 0;
00053 int force_gconf_defaults = 0;
00054
00055
00056 int just_exit = 0;
00057
00058
00059 static const struct poptOption options[] = {
00060 { "Hardware-Card", 'h', POPT_ARG_STRING, &xsmres.HardwareTypeCmd, 0,
00061 N_("Hardware Card: no | ... (depends on available HwI plugins)"), N_("default")},
00062 { "User-Unit", 'u', POPT_ARG_STRING, &xsmres.UnitCmd, 0,
00063 N_("XYZ Unit: AA | nm | um | mm | BZ | sec | V | 1 "), N_("default")},
00064 { "disable-plugins", '\0', POPT_ARG_NONE, &xsmres.disableplugins, 0,
00065 N_("Disable default plugin loading on startup"), 0},
00066 { "force-configure", '\0', POPT_ARG_NONE, &xsmres.force_config, 0,
00067 N_("Force to reconfigure Gxsm on startup"), 0},
00068 { "force-rebuild-gconf-defaults", '\0', POPT_ARG_NONE, &force_gconf_defaults, 0,
00069 N_("Forces to restore all GXSM gconf defaults on startup"), 0},
00070 { "debug-level", '\0', POPT_ARG_INT, &debug_level, 0,
00071 N_("Set Gxsm debug level. 0: no debug output on console, 1: normal, 2: more verbose, ...5 increased verbosity"), 0},
00072 { "pi-debug-level", '\0', POPT_ARG_INT, &pi_debug_level, 0,
00073 N_("Set Gxsm-PlugIn debug level. 0: no debug output on console, 1: normal, 2: more verbose, ...5 increased verbosity"), 0},
00074 {NULL, '\0', 0, NULL, 0}
00075 };
00076
00077
00078 int main(int argc, char *argv[])
00079 {
00080 #ifdef G_THREADS_ENABLED
00081
00082 XSM_DEBUG(DBG_L1, "glib thread init.");
00083 g_thread_init (NULL);
00084 gdk_threads_init ();
00085 gdk_threads_enter ();
00086 #else
00087 XSM_DEBUG(DBG_L1, "sorry, no glib thread support, needed for scanning.");
00088 #endif
00089
00090 #ifdef ENABLE_NLS
00091 XSM_DEBUG(DBG_L1, "NLS is enabled.");
00092
00093 bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
00094 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
00095 textdomain(GETTEXT_PACKAGE);
00096 #endif
00097
00098 XSM_DEBUG(DBG_L1, "Gnome program init");
00099 GnomeProgram *my_app = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
00100 GNOME_PARAM_POPT_TABLE, options,
00101 GNOME_PARAM_NONE);
00102
00103 gtk_gl_init (&argc, &argv);
00104
00105 std::cout << "GXSM-DebugLevel/PI-DebugLevel/ForceGDefaults: "
00106 << debug_level << "/"
00107 << pi_debug_level << "/"
00108 << force_gconf_defaults
00109 << std::endl;
00110
00111 XSM_DEBUG(DBG_L1, "Setup dynamic preferences");
00112 gxsm_init_dynamic_res ();
00113
00114 XSM_DEBUG(DBG_L1, "GXSM run druids check");
00115
00116 gxsm_check_new_user_config ();
00117
00118
00119 gapp = NULL;
00120
00121 XSM_DEBUG(DBG_L1, "GXSM CVS versioning");
00122
00123 char *cvsv;
00124 cvsv=strchr(xxsmmaincvsrev,',')+2; *cvsv='V'; cvsmaindate=strchr(cvsv,' ')+1; *strchr(cvsv,' ')=0;
00125 if((cvsv-xxsmmaincvsrev) > 10){ cvsv -= 8; strcpy(cvsv,"Version "); cvsv[8]=' '; }
00126 cvsmainrev=cvsv;
00127 *strchr(strchr(strchr(cvsmaindate,' ')+1,' ')+1,' ')=0;
00128 XSM_DEBUG(DBG_L1, "GXSM init, CVS " << cvsmainrev << ", date: " << cvsmaindate);
00129 XSM_DEBUG(DBG_L1, "GXSM / PlugIn debug level is: " << debug_level << " / " << pi_debug_level);
00130
00131 XSM_DEBUG(DBG_L1, "GXSM: create application");
00132
00133
00134 gapp = new App (restarted);
00135
00136 XSM_DEBUG(DBG_L1, "GXSM: build GUI");
00137 gapp->build_gxsm ();
00138
00139
00140
00141
00142 XSM_DEBUG(DBG_L2, "GXSM: parsing all arguments...");
00143 if (++argv){
00144 int re_use=0;
00145 for (; *argv; argv++) {
00146 XSM_DEBUG(DBG_L2, "Attempt to load/import <" << *argv << ">");
00147 if (re_use)
00148 re_use = gapp->xsm->load(*argv);
00149 else
00150 if(!gapp->xsm->ActivateFreeChannel())
00151
00152 re_use = gapp->xsm->load(*argv);
00153 }
00154 if (re_use)
00155 gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE);
00156 }
00157 XSM_DEBUG(DBG_L2, "All files processed.");
00158 XSM_DEBUG(DBG_L2, "Entering gtk_main loop.");
00159
00160 gtk_main();
00161
00162 gdk_flush ();
00163 gdk_threads_leave ();
00164
00165 XSM_DEBUG(DBG_L2, "GXSM is exiting now.");
00166
00167
00168
00169 delete gapp;
00170 gdk_flush ();
00171
00172
00173
00174 gapp = NULL;
00175 my_app = NULL;
00176
00177 XSM_DEBUG(DBG_L2, "by.");
00178
00179 gtk_exit (0);
00180 return 0;
00181 }
00182