[grisbi-cvs] [SCM] grisbi branch, grisbi-gtk3, updated. upstream_version_0_9_4-148-g6a54898

Pierre Biava nobody at users.sourceforge.net
Sun Jan 1 22:10:29 CET 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".

The branch, grisbi-gtk3 has been updated
       via  6a54898108a719032315801b4b3382d835270c1e (commit)
       via  244acaa35c00e4ae3909acf9575a242b4e80ea20 (commit)
       via  439c884f04a3485df43d7d36ee772691b615782d (commit)
       via  2b2f7d3c42651bb3f53582b251b6276ed25b58bc (commit)
      from  d6e280725c9ce311eb9efbf0f4ce489037e31229 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6a54898108a719032315801b4b3382d835270c1e
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Jan 1 22:01:02 2012 +0100

    .gitignore: minor change

commit 244acaa35c00e4ae3909acf9575a242b4e80ea20
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Jan 1 22:00:36 2012 +0100

    Changing the alert message when the version is in development

commit 439c884f04a3485df43d7d36ee772691b615782d
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Jan 1 21:58:03 2012 +0100

    erreur.h: formatting of code

commit 2b2f7d3c42651bb3f53582b251b6276ed25b58bc
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Jan 1 21:56:05 2012 +0100

    deleting files parse_cmdline. Replacement by GOption commandline parser

-----------------------------------------------------------------------

Changes:
diff --git a/.gitignore b/.gitignore
index dba73d3..37bb157 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,7 +21,7 @@ m4
 .anjuta*
 depcomp
 grisbi.anjuta
-grisbi.spec.mageia
+grisbi.spec.mageia*
 TODO*
 NEWS.new
 doxygen/
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 43fb910..ff73d07 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -117,7 +117,6 @@ src/meta_payee.c
 src/metatree.c
 src/navigation.c
 src/parametres.c
-src/parse_cmdline.c
 src/plugins/gnucash/gnucash.c
 src/plugins/ofx/ofx.c
 src/plugins/openssl/openssl.c
diff --git a/src/Makefile.am b/src/Makefile.am
index a6c706b..e081bd8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -130,7 +130,6 @@ libgrisbi_la_SOURCES = \
 	metatree.c		\
 	navigation.c		\
 	parametres.c		\
-	parse_cmdline.c		\
 	print_dialog_config.c		\
 	print_report.c		\
 	print_transactions_list.c		\
@@ -284,7 +283,6 @@ libgrisbi_la_SOURCES = \
 	mouse.h                 \
 	navigation.h		\
 	parametres.h		\
-	parse_cmdline.h		\
 	print_dialog_config.h	\
 	print_report.h		\
 	print_transactions_list.h	\
diff --git a/src/dialog.c b/src/dialog.c
index 5c791d6..6ba3fee 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -103,11 +103,11 @@ struct conditional_message messages[] =
       N_("In previous versions, Grisbi did not save start date, end date and balance for "
       "reconciliation.  This is now done, so Grisbi will try to guess values from your "
       "accounts.  Thought this can not harm data coherence, false values can be guessed. "
-      "Please check in the Preferences window for more information."), 
+      "Please check in the Preferences window for more information."),
       FALSE, FALSE, },
 
-    { "development-version", N_("You are running Grisbi version %s"), 
-      N_("Warning, please be aware that the version you run is a DEVELOPMENT version. "
+    { "development-version", N_("You are using a development version of Grisbi"),
+      N_("Warning, please be aware that the version %s you run is a DEVELOPMENT version. "
       "Never use your original file grisbi: you could make it unusable.\n"
       "Make a copy now."),
       FALSE, FALSE },
diff --git a/src/erreur.c b/src/erreur.c
index 14e4786..847b740 100644
--- a/src/erreur.c
+++ b/src/erreur.c
@@ -56,7 +56,7 @@
 
 /*START_STATIC*/
 static gchar *get_debug_time ( void );
-static GtkWidget * print_backtrace ( void );
+static GtkWidget *print_backtrace ( void );
 /*END_STATIC*/
 
 /*START_EXTERN*/
@@ -69,14 +69,20 @@ static gint debugging_grisbi;
  * this values should not be freed when begin a new file to continue the log */
 static FILE *debug_file = NULL;
 
-/*************************************************************************************************************/
+/**
+ * Traitement des erreurs de segmentation
+ *
+ * \param gint numéro de signal
+ *
+ * \return
+ */
 void traitement_sigsegv ( gint signal_nb )
 {
     gchar *gsb_file_default_dir;
     gchar *errmsg = g_strdup ( "" );
-	gchar *old_errmsg;
+    gchar *old_errmsg;
     gchar *tmpstr;
-    GtkWidget * dialog;
+    GtkWidget *dialog;
 #ifdef HAVE_BACKTRACE
     GtkWidget * expander;
 #endif
@@ -178,56 +184,43 @@ void traitement_sigsegv ( gint signal_nb )
     exit(1);
 }
 
-/*************************************************************************************************************/
-/* initialise show_grisbi_debug a TRUE si on souhaite le debug																							 */
-/*************************************************************************************************************/
+/**
+ * initialise show_grisbi_debug a TRUE si on souhaite le debug
+ *
+ * \param
+ *
+ * \return
+ */
 void initialize_debugging ( void )
 {
     /* un int pour stocker le level de debug et une chaine qui contient sa version texte */
-    gint debug_variable=0;
-    gchar *debug_level="";
-	gchar* tmpstr1;
-	gchar* tmpstr2;
+    gchar *debug_level = "";
+    gchar *tmpstr1;
+    gchar *tmpstr2;
 
-    if (getenv ("DEBUG_GRISBI"))
+    
+    if ( ( debugging_grisbi = gsb_main_get_debug_level ( ) ) )
     {
-	/* on choppe la variable d'environnement */
-	debug_variable=utils_str_atoi (getenv ("DEBUG_GRISBI"));
+        /* on renseigne le texte du level de debug */
+        switch ( debugging_grisbi )
+        {
+            case DEBUG_LEVEL_ALERT: { debug_level = "Alert"; break; }
+            case DEBUG_LEVEL_IMPORTANT: { debug_level = "Important"; break; }
+            case DEBUG_LEVEL_NOTICE: { debug_level = "Notice"; break; }
+            case DEBUG_LEVEL_INFO: { debug_level = "Info"; break; }
+            case DEBUG_LEVEL_DEBUG: { debug_level = "Debug"; break; }
+        }
 
-	/* on verifie que la variable est cohérente */
-	if (debug_variable > 0 && debug_variable <= MAX_DEBUG_LEVEL) 
-	{
-	    /* on renseigne le texte du level de debug */
-	    debugging_grisbi = debug_variable;
-	    switch(debug_variable)
-	    {
-		case DEBUG_LEVEL_ALERT: { debug_level="Alert"; break; }
-		case DEBUG_LEVEL_IMPORTANT: { debug_level="Important"; break; }
-		case DEBUG_LEVEL_NOTICE: { debug_level="Notice"; break; }
-		case DEBUG_LEVEL_INFO: { debug_level="Info"; break; }
-		case DEBUG_LEVEL_DEBUG: { debug_level="Debug"; break; }
-	    }
-
-	    /* on affiche un message de debug pour indiquer que le debug est actif */
-	    tmpstr1 = g_strdup_printf(_("GRISBI %s Debug"),VERSION);
-	    tmpstr2 = g_strdup_printf(_("Debug enabled, level is '%s'"),debug_level);
-	    debug_message_string ( tmpstr1 , 
-				   __FILE__, __LINE__, __PRETTY_FUNCTION__,
-				   tmpstr2,
-				   DEBUG_LEVEL_INFO, TRUE);
-	    g_free ( tmpstr1 );
-	    g_free ( tmpstr2 );
-	}
-	else
-	{
-	    /* on affiche un message de debug pour indiquer que le debug est actif */
-	    gchar* tmpstr = g_strdup_printf(_("GRISBI %s Debug"),VERSION);
-	    debug_message_string (tmpstr , 
-				  __FILE__, __LINE__, __PRETTY_FUNCTION__,
-				  _("Wrong debug level, please check DEBUG_GRISBI environnement variable"),
-				  DEBUG_LEVEL_INFO, TRUE);
-	    g_free ( tmpstr );
-	}
+        /* on affiche un message de debug pour indiquer que le debug est actif */
+        tmpstr1 = g_strdup_printf ( _("GRISBI %s Debug"),VERSION );
+        tmpstr2 = g_strdup_printf ( _("Debug enabled, level is '%s'"), debug_level );
+        debug_message_string ( tmpstr1,
+                        __FILE__, __LINE__, __PRETTY_FUNCTION__,
+                        tmpstr2,
+                        DEBUG_LEVEL_INFO,
+                        TRUE );
+        g_free ( tmpstr1 );
+        g_free ( tmpstr2 );
     }
 }
 
diff --git a/src/erreur.h b/src/erreur.h
index c22318b..f7a0ef3 100644
--- a/src/erreur.h
+++ b/src/erreur.h
@@ -1,30 +1,34 @@
 #ifndef _ERREUR_H
 #define _ERREUR_H (1)
+
 /* START_INCLUDE_H */
 #include "gsb_real.h"
 /* END_INCLUDE_H */
 
-/* constante de debug originale, obsolete il faudrait utiliser maintenant */
-/* la variable globale debugging_grisbi, voir erreur.c */
-#define DEBUG utils_str_atoi (getenv ("DEBUG_GRISBI"))
-
 /* constantes definissant le niveau de debug */
-#define	DEBUG_LEVEL_ALERT			1		/* grave probleme */
-#define DEBUG_LEVEL_IMPORTANT			2		/* probleme moins grave */
-#define DEBUG_LEVEL_NOTICE			3		/* probleme encore moins grave :) */
-#define DEBUG_LEVEL_INFO			4		/* autre information */
-#define DEBUG_LEVEL_DEBUG			5		/* information de debug */
-#define MAX_DEBUG_LEVEL				5		/* ignore higher debug levels */
+#define DEBUG_LEVEL_ALERT       1   /* grave probleme */
+#define DEBUG_LEVEL_IMPORTANT   2   /* probleme moins grave */
+#define DEBUG_LEVEL_NOTICE      3   /* probleme encore moins grave :) */
+#define DEBUG_LEVEL_INFO        4   /* autre information */
+#define DEBUG_LEVEL_DEBUG       5   /* information de debug */
+#define MAX_DEBUG_LEVEL         5   /* ignore higher debug levels */
 
-#define devel_debug_int(x) debug_message_int("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
-#define devel_debug_real(x) debug_message_real("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
-#define devel_debug(x) debug_message_string("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
-#define notice_debug(x) debug_message_string("Info",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_INFO,FALSE)
-#define warning_debug(x) debug_message_string("Warning",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_NOTICE,FALSE)
-#define important_debug(x) debug_message_string("Important",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_IMPORTANT,FALSE)
-#define alert_debug(x) debug_message_string("Alert",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_ALERT,FALSE)
-#define DEBUG_WHERE_AM_I g_strdup_printf("%s line %05d",__FILE__,__LINE__)
-#define devel_print_str(x) debug_print_log_string("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
+#define devel_debug_int(x)  debug_message_int \
+                        ("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
+#define devel_debug_real(x) debug_message_real \
+                        ("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
+#define devel_debug(x)      debug_message_string \
+                        ("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_DEBUG,FALSE)
+#define notice_debug(x)     debug_message_string \
+                        ("Info",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_INFO,FALSE)
+#define warning_debug(x)    debug_message_string \
+                        ("Warning",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_NOTICE,FALSE)
+#define important_debug(x)  debug_message_string \
+                        ("Important",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_IMPORTANT,FALSE)
+#define alert_debug(x)      debug_message_string \
+                        ("Alert",__FILE__,__LINE__,__PRETTY_FUNCTION__,x,DEBUG_LEVEL_ALERT,FALSE)
+#define DEBUG_WHERE_AM_I    g_strdup_printf ("%s line %05d",__FILE__,__LINE__)
+#define devel_print_str(x)  debug_print_log_string ("Debug",__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
 
 /* START_DECLARATION */
 void debug_message_int ( gchar *prefixe,
diff --git a/src/main.c b/src/main.c
index 6967d82..25aa095 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,7 +5,7 @@
 /*                                                                               */
 /*     Copyright (C)    2000-2008 Cédric Auger (cedric at grisbi.org)               */
 /*                      2003-2008 Benjamin Drieu (bdrieu at april.org)              */
-/*          2008-2010 Pierre Biava (grisbi at pierre.biava.name)                    */
+/*          2008-2012 Pierre Biava (grisbi at pierre.biava.name)                    */
 /*          http://www.grisbi.org                                                */
 /*                                                                               */
 /*     This program is free software; you can redistribute it and/or modify      */
@@ -50,11 +50,11 @@
 #include "gsb_status.h"
 #include "import.h"
 #include "menu.h"
-#include "parse_cmdline.h"
 #include "structures.h"
 #include "tip.h"
 #include "traitement_variables.h"
 #include "utils.h"
+#include "utils_str.h"
 #include "erreur.h"
 /*END_INCLUDE*/
 
@@ -94,8 +94,10 @@ static gboolean gsb_grisbi_change_state_window ( GtkWidget *window,
                         gpointer null );
 static GtkWidget *gsb_grisbi_create_main_menu ( GtkWidget *vbox );
 static GtkWidget *gsb_main_create_main_window ( void );
+static gint gsb_main_set_debug_level ( void );
+static void gsb_main_show_version ( void );
 static gboolean gsb_grisbi_init_app ( void );
-static void gsb_grisbi_load_file_if_necessary ( cmdline_options *opt );
+static void gsb_main_load_file_if_necessary ( gchar *filename );
 static gboolean gsb_grisbi_print_environment_var ( void );
 static void gsb_grisbi_trappe_signal_sigsegv ( void );
 static void main_mac_osx ( int argc, char **argv );
@@ -109,6 +111,23 @@ static void main_window_set_size_and_position ( void );
 /* Fenetre principale de grisbi */
 static GtkWidget *main_window = NULL;
 
+/* Options pour grisbi */
+static gint debug_level = -1;
+static gchar *file = NULL;
+
+
+static const GOptionEntry options [] =
+{
+    { "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+     gsb_main_show_version, N_("Show the application's version"), NULL },
+
+    { "debug", 'd', 0, G_OPTION_ARG_INT, &debug_level, N_("Debug mode: level 0-5"), NULL },
+
+    { "file", 'f', 0, G_OPTION_ARG_FILENAME, &file, N_("[FILE]"), NULL },
+
+    {NULL}
+};
+
 /*START_EXTERN*/
 extern gchar *nom_fichier_comptes;
 extern gchar *titre_fichier;
@@ -127,10 +146,6 @@ struct gsb_run_t run;
  */
 int main ( int argc, char **argv )
 {
-#if IS_DEVELOPMENT_VERSION == 1
-        initialize_debugging ( );
-#endif
-
 #if GSB_GMEMPROFILE
     g_mem_set_vtable(glib_mem_profiler_table);
 #endif
@@ -157,39 +172,67 @@ int main ( int argc, char **argv )
  * */
 void main_linux ( int argc, char **argv )
 {
+    GOptionContext *context;
     GtkWidget *vbox;
     gboolean first_use = FALSE;
-    cmdline_options  opt;
-    gint status = CMDLINE_SYNTAX_OK;
+    GError *error = NULL;
 
+    /* Init type system */
+    g_type_init ();
+
+    /* initialisation des différents répertoires */
+    gsb_dirs_init ( );
+
+    /* Setup locale/gettext */
+    setlocale (LC_ALL, "");
     bindtextdomain ( PACKAGE, gsb_dirs_get_locale_dir ( ) );
     bind_textdomain_codeset ( PACKAGE, "UTF-8" );
     textdomain ( PACKAGE );
 
-    /* Setup locale/gettext */
-    setlocale (LC_ALL, "");
+    /* Setup command line options */
+    context = g_option_context_new ( _("- Personnal finances manager") );
+
+    g_option_context_set_summary ( context,
+                        N_("Grisbi can manage the accounts of a family or a small association.") );
+    g_option_context_set_translation_domain ( context, PACKAGE );
+
+    g_option_context_add_main_entries ( context, options, PACKAGE );
+    g_option_context_add_group ( context, gtk_get_option_group ( FALSE ));
+    g_option_context_set_translation_domain ( context, PACKAGE );
+
+    if ( !g_option_context_parse ( context, &argc, &argv, &error ) )
+    {
+        g_option_context_free ( context );
+        if (error)
+        {
+            g_print ("option parsing failed: %s\n", error->message);
+            g_error_free ( error );
+        }
+
+      exit (1);
+    }
+
+    /* initialisation de la variable locale pour les devises */
     gsb_locale_init ( );
 
-#if IS_DEVELOPMENT_VERSION == 1
-    gsb_grisbi_print_environment_var ( );
-#endif
+    /* initialisation du mode de débogage */
+    if ( gsb_main_set_debug_level ( ) )
+    {
+        initialize_debugging ( );
+        gsb_grisbi_print_environment_var ( );
+    }
 
-    gtk_init ( &argc, &argv );
+    /* initialisation de gtk. arguments à NULL car traités au dessus */
+    gtk_init ( NULL, NULL );
 
     /* initialisation libgoffice */
     libgoffice_init ( );
-    /* Initialize plugins manager */
+    /* Initialize plugins manager pour goffice */
     go_plugins_init (NULL, NULL, NULL, NULL, TRUE, GO_TYPE_PLUGIN_LOADER_MODULE);
 
-    /* initialisation des différents répertoires */
-    gsb_dirs_init ( );
-
     /* on commence par détourner le signal SIGSEGV */
     gsb_grisbi_trappe_signal_sigsegv ( );
 
-    /* parse command line parameter, exit with correct error code when needed */
-    if ( !parse_options (argc, argv, &opt, &status ) )
-        exit ( status );
     /* initialise les données de l'application */
     first_use = gsb_grisbi_init_app ( );
 
@@ -200,12 +243,11 @@ void main_linux ( int argc, char **argv )
 
     gtk_widget_show ( main_window );
 
-#if IS_DEVELOPMENT_VERSION == 1
-    dialog_message ( "development-version", VERSION );
-#endif
+    if ( IS_DEVELOPMENT_VERSION )
+        dialog_message ( "development-version", VERSION );
 
     /* check the command line, if there is something to open */
-    gsb_grisbi_load_file_if_necessary ( &opt );
+    gsb_main_load_file_if_necessary ( file );
 
     if ( first_use && !nom_fichier_comptes )
         gsb_assistant_first_run ();
@@ -265,6 +307,9 @@ void main_mac_osx ( int argc, char **argv )
     /* init the app */
     theApp = g_object_new ( GTK_TYPE_OSX_APPLICATION, NULL );
 
+    /* initialisation des différents répertoires */
+    gsb_dirs_init ( );
+
     bindtextdomain ( PACKAGE,  gsb_dirs_get_locale_dir ( ) );
     bind_textdomain_codeset ( PACKAGE, "UTF-8" );
     textdomain ( PACKAGE );
@@ -273,9 +318,6 @@ void main_mac_osx ( int argc, char **argv )
     setlocale (LC_ALL, "");
     gsb_locale_init ( );
 
-    /* initialisation des différents répertoires */
-    gsb_dirs_init ( );
-
     /* on commence par détourner le signal SIGSEGV */
     gsb_grisbi_trappe_signal_sigsegv ( );
 
@@ -384,6 +426,9 @@ void main_win_32 (  int argc, char **argv )
      /* needed to be able to use the "common" installation of GTK libraries */
     win32_make_sure_the_gtk2_dlls_path_is_in_PATH();
 
+    /* initialisation des différents répertoires */
+    gsb_dirs_init ( );
+
     bindtextdomain ( PACKAGE, gsb_dirs_get_locale_dir ( ) );
     bind_textdomain_codeset ( PACKAGE, "UTF-8" );
     textdomain ( PACKAGE );
@@ -402,9 +447,6 @@ void main_win_32 (  int argc, char **argv )
 
     win32_parse_gtkrc ( "gtkrc" );
 
-    /* initialisation des différents répertoires */
-    gsb_dirs_init ( );
-
     /* parse command line parameter, exit with correct error code when needed */
     if ( !parse_options (argc, argv, &opt, &status ) )
         exit ( status );
@@ -640,20 +682,16 @@ void gsb_grisbi_trappe_signal_sigsegv ( void )
  *
  *
  * */
-void gsb_grisbi_load_file_if_necessary ( cmdline_options  *opt )
+void gsb_main_load_file_if_necessary ( gchar *filename )
 {
-    gchar *tmp_str = NULL;
-
     /* check the command line, if there is something to open */
-    if ( opt -> fichier )
+    if ( filename )
     {
-        tmp_str = opt -> fichier;
-
-        if ( gsb_file_open_file ( tmp_str ) )
+        if ( gsb_file_open_file ( filename ) )
         {
             if ( nom_fichier_comptes )
                 g_free ( nom_fichier_comptes );
-            nom_fichier_comptes = tmp_str;
+            nom_fichier_comptes = g_strdup ( filename );
         }
         else
         {
@@ -924,6 +962,71 @@ GtkWidget *gsb_main_get_main_window ( void )
     return main_window;
 }
 
+/**
+ * renvoie la version de Grisbi
+ *
+ * \param
+ *
+ * \return
+ */
+void gsb_main_show_version ( void )
+{
+#ifdef HAVE_PLUGINS
+    gsb_plugins_scan_dir ( gsb_dirs_get_plugins_dir ( ) );
+#endif
+
+g_print ( N_("Grisbi version %s, %s\n"), VERSION, gsb_plugin_get_list ( ) );
+
+    exit ( 0 );
+}
+
+
+/**
+ * renvoie la version mineure de Grisbi
+ *
+ * \param
+ *
+ * \return TRUE if minor number is an odd number
+ */
+gint gsb_main_get_debug_level ( void )
+{
+    return debug_level;
+}
+
+
+/**
+ * positionne la variable debug_mode à 0 si version stable et
+ * à DEBUG_GRISBI ou une valeur passée en paramètre
+ *
+ * \param
+ *
+ * \return debug_mode
+ */
+gint gsb_main_set_debug_level ( void )
+{
+    gchar **tab;
+    gint number = 0;
+    gint number_1;
+
+    tab = g_strsplit ( VERSION, ".", 3 );
+    number_1 = utils_str_atoi ( tab[1] );
+
+    number = number_1 % 2;
+    /* on garde le niveau mini de débogage si $DEBUG_GRISBI n'existe pas */
+    if ( number )
+    {
+        if ( getenv ( "DEBUG_GRISBI" ) )
+            number = utils_str_atoi ( getenv ( "DEBUG_GRISBI" ) );
+    }
+    if ( debug_level == -1 )
+        debug_level = number;
+
+    if ( debug_level > MAX_DEBUG_LEVEL )
+        debug_level = MAX_DEBUG_LEVEL;
+
+    return debug_level;
+}
+
 
 /* Local Variables: */
 /* c-basic-offset: 4 */
diff --git a/src/main.h b/src/main.h
index 04d2ef2..a2367b9 100644
--- a/src/main.h
+++ b/src/main.h
@@ -9,10 +9,11 @@
 
 /* START_DECLARATION */
 gboolean gsb_main_grisbi_close ( void );
-int main (int argc, char **argv);
+gboolean gsb_main_get_debug_level ( void );
 gchar *gsb_main_get_print_locale_var ( void );
 gchar *gsb_main_get_print_dir_var ( void );
 GtkWidget *gsb_main_get_main_window ( void );
 gboolean gsb_main_set_grisbi_title ( gint account_number );
+int main (int argc, char **argv);
 /* END_DECLARATION */
 #endif
diff --git a/src/parametres.c b/src/parametres.c
index 09fa31e..5d979f6 100644
--- a/src/parametres.c
+++ b/src/parametres.c
@@ -704,7 +704,7 @@ GtkWidget *onglet_messages_and_warnings ( void )
             tmpstr = g_strdup_printf ( _(messages[i] . hint),
                         g_path_get_basename ( nom_fichier_comptes ) );
         else if ( g_utf8_collate ( messages[i].name, "development-version" ) == 0 )
-            tmpstr = g_strdup_printf ( _(messages[i] . hint), VERSION );
+            tmpstr = g_strdup_printf ( _(messages[i] . message), VERSION );
         else
             tmpstr = g_strdup ( _(messages[i] . hint) );
 
diff --git a/src/parse_cmdline.c b/src/parse_cmdline.c
deleted file mode 100644
index 1427b51..0000000
--- a/src/parse_cmdline.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/* *******************************************************************************/
-/*                                                                               */
-/*     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 2 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, write to the Free Software               */
-/*     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-/*                                                                               */
-/* *******************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "include.h"
-#include <glib/gi18n.h>
-#include <getopt.h>
-
-/*START_INCLUDE*/
-#include "parse_cmdline.h"
-#include "gsb_plugins.h"
-#include "main.h"
-#include "utils_str.h"
-#include "structures.h"
-#include "utils.h"
-#include "gsb_dirs.h"
-/*END_INCLUDE*/
-
-/*START_STATIC*/
-static gboolean is_valid_window_number(gint w);
-static CMDLINE_ERRNO parse_tab_parameters(char *tab_parameters, cmdline_options* pOpt);
-static void show_errstr(gint errval, gchar* extra);
-static void show_help(void);
-static void show_usage ( gint errval, gchar* extra );
-static void show_version(void);
-/*END_STATIC*/
-
-
-static char*         short_options  = "t:vh"; /*!< configure the list of 'short' options using getopt syntax */
-static struct option long_options[] =           /*!< configure the list of 'long'  options using getopt syntax */
-{
-    {"version", no_argument,       0, 'V'},     /*!< '--version   */
-    {"help"   , no_argument,       0, 'H'},     /*!< '--help'     */
-    {0, 0, 0, 0} /* end of long arg list DO NOT REMOVE */
-};
-
-/* Please make sure to keep consistency between short_options/long_options and USAGE_STRING/HELP_STRING definition */
-#define   GET_DETAIL N_("Try grisbi --help for details\n\n")
-#define   USAGE_STRING N_("Usage: grisbi [--version | -v] | [--help | -?]\n")
-
-#define   HELP_STRING  				                               \
- N_("grisbi [options] [file]\n"                                                 \
-    "  --help                    Show this help message and exit\n"        \
-    "  -v, --version             Show version number and exit\n"           \
-   )
-
-/**
- *
- * Parse command line arguments using getopt feature for options.
- *
- * \param argc main() argc (or argn) parameter.
- * \param argv main() argv parameter.
- * \param pOpt pointer to the options structure to store configuration in.
- * \param errval pointer to put the operation status:
- *
- * \return TRUE when the application can continue, FALSEthe application should stop
- *
- * \note  See short_options and long_options variables to have possible options.
- */
-gboolean  parse_options(int argc, char **argv, cmdline_options *pOpt, gint* pErrval)
-{
-    gboolean still_args_to_treat = TRUE; /*!< used to stop treating the command line args using getopt */ 
-    int      option_index        = 0;    /*!< Index of the field of argv to compute */
-    gboolean app_must_stop       = FALSE;
-	
-    *pErrval = CMDLINE_ERROR(CMDLINE_SYNTAX_OK);
-	/* init param de retour */
-	pOpt->demande_page         = 0;
-	pOpt->fichier              = NULL;
-	pOpt->report_no            = -1;
-	pOpt->customization_tab_no = -1;
-	pOpt->subcustom_tab_no     = -1;
-
-    while ((CMDLINE_SYNTAX_OK==CMDLINE_ERROR(*pErrval)) && (still_args_to_treat) && (!app_must_stop))
-	{
-        int c;
-        switch (c = getopt_long(argc, argv, short_options,long_options, &option_index))
-		{
-            /* special getopt return values */
-            case ':':/* missing parameter for one of the  options */
-                *pErrval = CMDLINE_ERROR(CMDLINE_MISSING_PARAMETER);
-                show_usage( (gint)(*pErrval), argv[option_index]);
-                break;
-            default: /* unmanaged options */
-                *pErrval = CMDLINE_ERROR(CMDLINE_SYNTAX_ERROR);
-                show_usage( (gint)(*pErrval), argv[option_index]);
-                break;
-            case '?':/* unknown option character */
-                *pErrval = CMDLINE_ERROR(CMDLINE_UNKNOWN_OPTION);
-                show_usage( (gint)(*pErrval), argv[option_index]);
-                break;
-            case EOF:/* all options parsed */
-                still_args_to_treat = FALSE;
-                break;
-            
-            /* configured returned values */
-            /* -h : short help = usage */
-            case 'v' : /* -v */
-            case 'V' : /* --version */
-                app_must_stop       = TRUE; /* stopping here! */
-                show_version();    
-                break;
-            case 'h':  /* -h */
-            case 'H':  /* --help */
-                app_must_stop       = TRUE; /* stopping here! */
-                show_help();
-                break; 
-            case 't': /* -t <str> */
-            case 'T': /* --tab[=]<optarg> */
-                if (!optarg)
-                {
-                    /* Denote a getopt configuration error, arg is required should never happend, but ... */
-                    *pErrval = CMDLINE_ERROR(CMDLINE_GETOPT_CONFIGURATION_ERROR);
-                    show_usage((gint)(*pErrval),"");
-			} 
-                else
-			{
-                    /* optarg contains argument parameter */
-                    if (CMDLINE_SYNTAX_OK != (*pErrval = parse_tab_parameters(optarg, pOpt)))
-                        show_usage((gint)(*pErrval),"");
-			} 
-                break; 
-				}
-			}
-    /* Manual management of command line arguments */
-    if(optind >= argc) /* no more arguments */
-			{
-			}
-    else while (optind < argc)
-		{
-        /* first found arg should be a gsb file */
-        /* so if Opt->fichier is not NULL, we have more than one extra arg! */
-        if (pOpt->fichier != NULL)
-			{
-            show_usage(CMDLINE_ERROR(CMDLINE_TOO_MANY_PARAMETERS),argv[optind]);
-            break;
-			}
-        pOpt->fichier = g_strdup(argv[optind]);
-        optind++;
-		}
-		
-    return ((gboolean)((*pErrval)==0)&&(!app_must_stop));
-	
-}
-
-
-
-/**
- * 
- * Display grisbi version after synoptic
- *
- *
- **/
-void show_version(void)
-{
-#ifdef HAVE_PLUGINS
-    gsb_plugins_scan_dir ( gsb_dirs_get_plugins_dir ( ) );
-#endif
-
-    g_print(N_("Grisbi version %s, %s\n"), VERSION, gsb_plugin_get_list());
-}
-
-
-/**
- *
- * Display complete help message
- *
- * \private
- */
-void show_help(void)
-{
-    show_usage(0,NULL);
-    g_print(HELP_STRING);
-}
-
-
-/**
- *
- * Display usage line
- * 
- * \param errval  error code to pass to show_errstr
- * \param extra  extra information to pass to show_errstr
- *
- * \private
- */
-void show_usage ( gint errval, gchar* extra )
-{
-    show_errstr(errval,extra);
-    g_printerr(USAGE_STRING);
-}
-
-
-/**
- *
- * Display a string corresponding to error code 
- *
- * \param errval  error code to inform the user why this message is displayed
- * \param extra  extra information to complete error code
- *
- * \private
- */
-void show_errstr(gint errval, gchar* extra)
-{
-    switch (CMDLINE_ERROR(errval))
-    {
-        case CMDLINE_SYNTAX_OK:/* do nothing!*/
-            break;
-        case CMDLINE_MISSING_PARAMETER:
-            g_printerr(_("Missing parameter for option %s\n\n"),extra);
-            break;
-        case CMDLINE_SYNTAX_ERROR:
-            g_printerr(_("Syntax error (%s)\n\n"),extra);
-            break;
-        case CMDLINE_UNKNOWN_OPTION:
-             g_printerr(_("Unknown option (%s)\n\n"),extra);
-            break;
-        case CMDLINE_TOO_MANY_PARAMETERS:
-            g_printerr(_("Too many parameters (%s)\n\n"),extra);
-            break;
-        case CMDLINE_TAB_ID_OUT_OF_RANGE:
-            g_printerr(_("Tab is is out of range (%s)\n\n"),extra);
-            break;
-        case CMDLINE_GETOPT_CONFIGURATION_ERROR:
-            g_printerr(_("Something strange happend (%s)\n\n"),extra);
-            break;            
-        default:
-            g_printerr(_("Syntax error!\n\n"));
-            break;
-    }
-}
-
-
-/**
- * Analyse tab argument parameter to extra information.
- *
- * \param tab_parameters string of tab parameters (the one given by getopt!)
- * \param pOpt pointer to the configuration structure to fill
- *
- * \return status of the operation is CMDLINE_ERRNO values
- * \retval CMDLINE_SYNTAX_OK
- * \retval CMDLINE_MISSING_PARAMETER
- * \retval CMDLINE_TAB_ID_OUT_OF_RANGE
- *
- */
-CMDLINE_ERRNO parse_tab_parameters(char *tab_parameters, cmdline_options* pOpt)
-{
-	gchar **split_chiffres;
-	gint    w, x, y, z;
-	
-	w = x = y = z = -1;
-
-    split_chiffres = g_strsplit ( tab_parameters, ",", 0 );
-	
-	if (split_chiffres[0] == NULL)
-	{
-		/* on s'attend à avoir au moins un numero d'onglet */
-        return CMDLINE_MISSING_PARAMETER;
-	}
-	
-	w = utils_str_atoi(split_chiffres[0]); 
-	if ( !is_valid_window_number(w) )
-	{
-        return CMDLINE_TAB_ID_OUT_OF_RANGE;
-	}
-
-	if (w == 7)
-	{
-		/* Fenetre des etats. Lit parametres restant si il y en a. */
-		if (split_chiffres[1]) 
-		{
-			x = utils_str_atoi(split_chiffres[1]);
-		
-			if (split_chiffres[2]) 
-			{
-				y = utils_str_atoi(split_chiffres[2]);
-				if (split_chiffres[3]) 
-				{
-					z = utils_str_atoi(split_chiffres[3]);
-				}
-			}
-		}
-	}
-	
-
-	/* Tout c'est bien passé, on peut ranger les valeurs dans la var. de retour */
-	pOpt->demande_page         = 1;
-	
-	pOpt->page_w               = w;
-	pOpt->report_no            = x;
-	pOpt->customization_tab_no = y;
-	pOpt->subcustom_tab_no     = z;
-	
-    return CMDLINE_SYNTAX_OK;
-
-}
-
-	
-
-
-#define  NB_MAX_ONGLET    8 
-/**
- * 
- * Check if a value can be a tab index.
- * 
- * A Tab index is in -1 (config dialog) to NB_MAX_ONGLET-1.
- *
- * \param w value to check 
- *
- * \return TRUE is w can be a tab index, FALSE otherwise.
- */
-gboolean is_valid_window_number(gint w)
-{
-	/* Valeurs valides:
-	 * 1)  -1: fenêtre de configuration
-	 * 2)  0..NB_MAX_ONGLET-1: onglet
-	 */
-	return ((w >= -1) && (w < NB_MAX_ONGLET));
-}
-
-
-/* Local Variables: */
-/* c-basic-offset: 4 */
-/* End: */
diff --git a/src/parse_cmdline.h b/src/parse_cmdline.h
deleted file mode 100644
index b9af118..0000000
--- a/src/parse_cmdline.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* *******************************************************************************/
-/*                                                                               */
-/*     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 2 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, write to the Free Software               */
-/*     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
-/*                                                                               */
-/* *******************************************************************************/
-#ifndef   __PARSE_CMDLINE_H
-#define   __PARSE_CMDLINE_H (1)
-/*START_INCLUDE*/
-#include <glib.h>
-/*END_INCLUDE*/
-
-typedef struct _cmdline_options 
-{
-
-    gint        demande_page;
-    gint        page_w;
-    
-    /* quand page_w correspond à la page des états */
-    gint        report_no;            /* no etat. -1 si non spécifié dans les options */
-    gint        customization_tab_no; /* onglet de personalisation. -1 si non spécifié dans les options */
-    gint        subcustom_tab_no;     /* sous-onglet de personalisation. -1 si non spécifié dans les options */
-    
-    gchar      *fichier;
-    
-} cmdline_options;
-
-typedef enum
-{
-    CMDLINE_SYNTAX_OK = 0,
-    CMDLINE_MISSING_PARAMETER,
-    CMDLINE_SYNTAX_ERROR,
-    CMDLINE_UNKNOWN_OPTION,
-    CMDLINE_TOO_MANY_PARAMETERS,
-    CMDLINE_TAB_ID_OUT_OF_RANGE,
-    CMDLINE_GETOPT_CONFIGURATION_ERROR,
-    CMDLINE_OTHER
-} CMDLINE_ERRNO;
-#define CMDLINE_ERROR(err)  (gint)(-err)
-
-
-/*START_DECLARATION*/
-gboolean  parse_options(int argc, char **argv, cmdline_options *pOpt, gint* pErrval);
-/*END_DECLARATION*/
-
-
-#endif  /* ifndef __PARSE_CMDLINE_H */
-
-


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list