[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_4-7-g5f6b396

Pierre Biava nobody at users.sourceforge.net
Mon Sep 19 22:11:48 CEST 2011


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, master has been updated
       via  5f6b39676caf125194ca3c62553f18070a6bfe4e (commit)
       via  64b605417e46b483a750ff408d372251c51fab4a (commit)
       via  174b2d62739362d27817f68c72f0340dc656987d (commit)
       via  f92d00867884bdd5fed88061756390a1173834cf (commit)
       via  7e41e9f50388c1a86ec90d7177930a03948a9efa (commit)
       via  66f6da49126cab4817866058378d0fc82d02685e (commit)
       via  40e8e1a47ecf19cd603e8a2fac5548147c22d807 (commit)
      from  93e485e0d0cebedbb0fdd78575dd20e0cbd89ec3 (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 5f6b39676caf125194ca3c62553f18070a6bfe4e
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 21:17:25 2011 +0200

    Adding a bar graph to forecast. Mutualisation of functions for all types of graphic

commit 64b605417e46b483a750ff408d372251c51fab4a
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 21:08:16 2011 +0200

    utils_gtkbuilder: added a function to initialize a GtkBuilder

commit 174b2d62739362d27817f68c72f0340dc656987d
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 08:59:32 2011 +0200

    moving the location of the column headings of forecasts' tree_view  and tree_view of historical data

commit f92d00867884bdd5fed88061756390a1173834cf
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 08:48:01 2011 +0200

    adding a button for graph

commit 7e41e9f50388c1a86ec90d7177930a03948a9efa
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 08:35:22 2011 +0200

    remove a deprecated symbol

commit 66f6da49126cab4817866058378d0fc82d02685e
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Sep 19 08:11:36 2011 +0200

    bet_tab.c: Change sizing property of columns for the treeview

commit 40e8e1a47ecf19cd603e8a2fac5548147c22d807
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Sep 18 20:21:10 2011 +0200

    Fixed a problem of building of rpm for Mandriva 2010.2

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

Changes:
diff --git a/grisbi.spec b/grisbi.spec
index 0e73a34..e667610 100644
--- a/grisbi.spec
+++ b/grisbi.spec
@@ -69,6 +69,7 @@ rm -rf $RPM_BUILD_ROOT
 %_libdir/grisbi
 %dir %_datadir/grisbi
 %_datadir/grisbi/categories
+%_datadir/grisbi/ui/*
 %_datadir/pixmaps/*
 %_datadir/applications/*
 %_mandir/man1/*
@@ -76,6 +77,15 @@ rm -rf $RPM_BUILD_ROOT
 %_iconsdir/hicolor/48x48/apps/%name.png
 
 %changelog
+* Sat Aug 06 2011 Pierre Biava <grisbi at pierre.biava.name> 0.8.8-1mdv2010.2
+- new version 0.8.8
+
+* Sun May 22 2011 Pierre Biava <grisbi at pierre.biava.name> 0.8.6-1mdv2010.2
+- new version 0.8.6
+
+* Wed Apr 13 2011 Pierre Biava <grisbi at pierre.biava.name> 0.8.5-1mdv2010.1
+- new version 0.8.5
+
 * Mon Feb 22 2011 Pierre Biava <grisbi at pierre.biava.name> 0.8.2-1mdv2010.1
 - new version 0.8.2
 
diff --git a/src/accueil.c b/src/accueil.c
index 5bc8e7c..9174093 100644
--- a/src/accueil.c
+++ b/src/accueil.c
@@ -1306,7 +1306,7 @@ void update_liste_echeances_manuelles_accueil ( gboolean force )
 				 NULL );
 	    g_signal_connect ( G_OBJECT ( event_box ),
 				 "button-press-event",
-				 (GtkSignalFunc) saisie_echeance_accueil,
+				 G_CALLBACK ( saisie_echeance_accueil ),
 				 GINT_TO_POINTER (scheduled_number));
 	    gtk_box_pack_start ( GTK_BOX ( hbox ), event_box, TRUE, TRUE, 5 );
 	    gtk_widget_show ( event_box  );
diff --git a/src/bet_config.c b/src/bet_config.c
index 6309faa..a7b5e09 100644
--- a/src/bet_config.c
+++ b/src/bet_config.c
@@ -333,7 +333,7 @@ GtkWidget *bet_config_account_get_select_account ( gchar *title )
 	gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT );
     gtk_box_pack_start ( GTK_BOX (hbox ), label, FALSE, FALSE, 0 );
 
-	combo = gsb_account_create_combo_list ( (GtkSignalFunc) bet_config_change_account,
+	combo = gsb_account_create_combo_list ( G_CALLBACK ( bet_config_change_account ),
                         NULL, FALSE );
     g_object_set_data ( G_OBJECT ( account_page ), "account_combo", combo );
     if ( ( account_number = gsb_gui_navigation_get_current_account ( ) ) == -1 )
diff --git a/src/bet_data.h b/src/bet_data.h
index b11b520..b4e2bfa 100644
--- a/src/bet_data.h
+++ b/src/bet_data.h
@@ -87,6 +87,45 @@ struct _transfert_data
     gint sub_budgetary_number;
 };
 
+/* noms des colonnes du tree_view des previsions */
+enum bet_estimation_tree_columns
+{
+    SPP_ESTIMATE_TREE_SELECT_COLUMN,    /* select column for the balance */
+    SPP_ESTIMATE_TREE_ORIGIN_DATA,      /* origin of data : transaction, scheduled, hist, future */
+    SPP_ESTIMATE_TREE_DIVISION_COLUMN,  /* div_number, transaction_number, futur_number, scheduled_number*/
+    SPP_ESTIMATE_TREE_SUB_DIV_COLUMN,   /* sub_div_nb */
+    SPP_ESTIMATE_TREE_DATE_COLUMN,
+    SPP_ESTIMATE_TREE_DESC_COLUMN,
+    SPP_ESTIMATE_TREE_DEBIT_COLUMN,
+    SPP_ESTIMATE_TREE_CREDIT_COLUMN,
+    SPP_ESTIMATE_TREE_BALANCE_COLUMN,
+    SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
+    SPP_ESTIMATE_TREE_AMOUNT_COLUMN,    /* the amount without currency */
+    SPP_ESTIMATE_TREE_BALANCE_COLOR,
+    SPP_ESTIMATE_TREE_BACKGROUND_COLOR,
+    SPP_ESTIMATE_TREE_COLOR_STRING,
+    SPP_ESTIMATE_TREE_NUM_COLUMNS
+};
+
+/* noms des colonnes du tree_view des données historiques */
+enum bet_historical_data_columns {
+    SPP_HISTORICAL_SELECT_COLUMN,
+    SPP_HISTORICAL_DESC_COLUMN,
+    SPP_HISTORICAL_CURRENT_COLUMN,  /* Accumulation of the current year */
+    SPP_HISTORICAL_BALANCE_COLUMN,
+    SPP_HISTORICAL_AVERAGE_COLUMN,
+    SPP_HISTORICAL_AVERAGE_AMOUNT,  /* average column without currency */
+    SPP_HISTORICAL_RETAINED_COLUMN,
+    SPP_HISTORICAL_RETAINED_AMOUNT, /* retenaid column without currency */
+    SPP_HISTORICAL_BALANCE_COLOR,
+    SPP_HISTORICAL_ACCOUNT_NUMBER,
+    SPP_HISTORICAL_DIV_NUMBER,
+    SPP_HISTORICAL_SUB_DIV_NUMBER,
+    SPP_HISTORICAL_EDITED_COLUMN,
+    SPP_HISTORICAL_BACKGROUND_COLOR,
+    SPP_HISTORICAL_NUM_COLUMNS
+};
+
 
 /* START_DECLARATION */
 GDate *bet_data_array_get_date_max ( gint account_number );
diff --git a/src/bet_graph.c b/src/bet_graph.c
index 9fcb54e..2b707cb 100644
--- a/src/bet_graph.c
+++ b/src/bet_graph.c
@@ -41,38 +41,51 @@
 #include "navigation.h"
 #include "structures.h"
 #include "utils_gtkbuilder.h"
+#include "utils_dates.h"
 #include "utils_str.h"
 #include "erreur.h"
 /*END_INCLUDE*/
 
 
+typedef struct _struct_bet_graph_data    struct_bet_graph_data;
+typedef struct _struct_bet_sectors_data struct_bet_sectors_data;
 
-typedef struct _struct_bet_sectors_data     struct_bet_sectors_data;
-
-struct _struct_bet_sectors_data
+struct _struct_bet_graph_data
 {
     GtkTreeView *tree_view;
     gint account_number;
 
-    /* Données pour les secteurs */
-    GtkWidget *pie;
+    /* Données pour le graphique */
+    GtkWidget *widget;
     gchar *title;
-    gint type_infos;    /* 0 type crédit ou < 0, 1 type débit ou >= 0, -1 tous types */
+    gchar *service_id;          /* définit le type de graphique */
+    gboolean is_legend;
+
+    /* données communes */
     gint nbre_elemnts;
-    gdouble tab_montant[MAX_SEGMENT_CAMEMBERT];
-    gchar tab_libelle[MAX_SEGMENT_CAMEMBERT][TAILLE_MAX_LIBELLE];
+
+    /* données pour les histogrammes et XY */
+    gdouble tab_X[MAX_POINTS_GRAPHIQUE];
+    gdouble tab_Y[MAX_POINTS_GRAPHIQUE];
+
+    /* données pour les camemberts */
+    gint type_infos;    /* 0 type crédit ou < 0, 1 type débit ou >= 0, -1 tous types */
+    gchar tab_libelle[MAX_POINTS_GRAPHIQUE][TAILLE_MAX_LIBELLE];
     gchar **tab_vue_libelle;
-};
 
+};
 
 
 /*START_STATIC*/
-static gboolean bet_graph_affiche_camemberts ( struct_bet_sectors_data *self );
-static void bet_graph_create_pie_canvas  ( struct_bet_sectors_data *self );
+static gboolean bet_graph_affiche_camemberts ( struct_bet_graph_data *self );
+static gboolean bet_graph_affiche_XY_line ( struct_bet_graph_data *self );
+static void bet_graph_create_graph_widget  ( struct_bet_graph_data *self );
+static void bet_graph_create_pie_canvas  ( struct_bet_graph_data *self );
 static GtkWidget *bet_graph_get_canvas  ( void );
-static gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_sectors_data *self );
-static  void struct_free_bet_sectors_data ( struct_bet_sectors_data *self );
-struct_bet_sectors_data *struct_initialise_bet_sectors_data ( void );
+static gboolean bet_graph_populate_lines_by_forecast_data ( struct_bet_graph_data *self );
+static gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_graph_data *self );
+static void struct_free_bet_graph_data ( struct_bet_graph_data *self );
+static struct_bet_graph_data *struct_initialise_bet_graph_data ( void );
 /*END_STATIC*/
 
 /*START_EXTERN*/
@@ -80,6 +93,55 @@ struct_bet_sectors_data *struct_initialise_bet_sectors_data ( void );
 
 static GtkBuilder *bet_graph_builder = NULL;
 
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_graph_create_graph_widget  ( struct_bet_graph_data *self )
+{
+	GtkWidget *w;
+	GogChart *chart;
+	GogGraph *graph;
+	GogLabel *label;
+	GogPlot *plot;
+	GOStyle *style;
+	GOData *data;
+	PangoFontDescription *desc;
+
+	/* Set the graph widget */
+	w = self->widget;
+
+	/* Get the embedded graph */
+	graph = go_graph_widget_get_graph ( GO_GRAPH_WIDGET ( w ) );
+
+    /* set the title */
+    if ( self->title && strlen ( self->title ) )
+    {
+        label = (GogLabel *) g_object_new ( GOG_TYPE_LABEL, NULL );
+        data = go_data_scalar_str_new ( self->title, FALSE );
+        gog_dataset_set_dim ( GOG_DATASET ( label ), 0, data, NULL );
+        gog_object_add_by_name ( GOG_OBJECT ( graph ), "Title", GOG_OBJECT ( label ) );
+
+        /* Change the title font */
+        style = go_styled_object_get_style ( GO_STYLED_OBJECT ( label ) );
+        desc = pango_font_description_from_string ( "Sans bold 12" );
+        go_style_set_font_desc ( style, desc );
+    }
+
+	/* Get the chart created by the widget initialization */
+	chart = go_graph_widget_get_chart ( GO_GRAPH_WIDGET ( w ) );
+
+	/* Create a pie plot and add it to the chart */
+	plot = ( GogPlot *) gog_plot_new_by_name ( self->service_id );
+	gog_object_add_by_name ( GOG_OBJECT ( chart ), "Plot", GOG_OBJECT ( plot ) );
+
+	/* Add a legend to the chart */
+    if ( self->is_legend )
+	    gog_object_add_by_name ( GOG_OBJECT ( chart ), "Legend", NULL);
+}
+
 
 /**
  *
@@ -93,13 +155,11 @@ void bet_graph_sectors_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view
     GtkWidget *label;
     GtkWidget *sw_canvas;
     GtkWidget *box_pie;
-    gchar *filename;
     gchar *title;
     gint result;
     gint account_number;
-    GError *error = NULL;
-    struct_bet_sectors_data *self_credit;
-    struct_bet_sectors_data *self_debit;
+    struct_bet_graph_data *self_credit;
+    struct_bet_graph_data *self_debit;
 
     devel_debug (NULL);
 
@@ -108,42 +168,9 @@ void bet_graph_sectors_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view
     if ( bet_graph_builder == NULL )
         return;
 
-    /* Chargement du XML dans bet_graph_builder */
-    filename = utils_gtkbuilder_get_full_path ( "bet_graph.ui" );
-    if ( !g_file_test ( filename, G_FILE_TEST_EXISTS ) )
-    {
-        gchar* tmpstr = g_strdup_printf ( _("Cannot open file '%s': %s"),
-                        filename,
-                        _("File does not exist") );
-        dialogue_error ( tmpstr );
-        g_free ( tmpstr );
-        g_free ( filename );
-        return;
-    }
-
-    result = gtk_builder_add_from_file ( bet_graph_builder, filename, &error );
+    result = utils_gtkbuilder_merge_ui_data_in_builder ( bet_graph_builder, "bet_graph.ui" );
     if ( result == 0 )
-    {
-        g_error ("%s", error->message);
-        g_free ( filename );
-        g_error_free ( error );
-
         return;
-    }
-    g_free ( filename );
-
-    /* initialisation des structures de données */
-    account_number = gsb_gui_navigation_get_current_account ( );
-
-    self_credit = struct_initialise_bet_sectors_data ( );
-    self_credit -> tree_view = tree_view;
-    self_credit -> account_number = account_number;
-    self_credit -> type_infos = 0;
-
-    self_debit = struct_initialise_bet_sectors_data ( );
-    self_debit -> tree_view = tree_view;
-    self_debit -> account_number = account_number;
-    self_debit -> type_infos = 1;
 
     /* Création de la fenêtre de dialogue pour le graph */
     dialog = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "bet_graph_dialog" ) );
@@ -166,18 +193,35 @@ void bet_graph_sectors_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view
     label = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "label_canvas" ) );
     gtk_label_set_markup ( GTK_LABEL ( label ), title );
     g_free ( title );
-    
+
+    /* initialisation des structures de données */
+    account_number = gsb_gui_navigation_get_current_account ( );
+
     /* Set the graph for credit */
-    self_credit -> pie = go_graph_widget_new ( NULL );
-    self_credit -> title = g_strdup ( _("Credit") );
-    bet_graph_create_pie_canvas ( self_credit );
-    gtk_box_pack_start ( GTK_BOX ( box_pie ), self_credit -> pie, TRUE, TRUE, 0 );
+    self_credit = struct_initialise_bet_graph_data ( );
+    self_credit->tree_view = tree_view;
+    self_credit->account_number = account_number;
+    self_credit->type_infos = 0;
+    self_credit->title = g_strdup ( _("Credit") );
+    self_credit->service_id = "GogPiePlot";
+    self_credit->is_legend = TRUE;
+
+    self_credit->widget = go_graph_widget_new ( NULL );
+    bet_graph_create_graph_widget ( self_credit );
+    gtk_box_pack_start ( GTK_BOX ( box_pie ), self_credit->widget, TRUE, TRUE, 0 );
 
     /* Set the graph for debit */
-    self_debit -> pie = go_graph_widget_new ( NULL );
-    self_debit -> title = g_strdup ( _("Debit") );
-    bet_graph_create_pie_canvas ( self_debit );
-    gtk_box_pack_start ( GTK_BOX ( box_pie ), self_debit -> pie, TRUE, TRUE, 0 );
+    self_debit = struct_initialise_bet_graph_data ( );
+    self_debit->tree_view = tree_view;
+    self_debit->account_number = account_number;
+    self_debit->type_infos = 1;
+    self_debit->title = g_strdup ( _("Debit") );
+    self_debit->service_id = "GogPiePlot";
+    self_debit->is_legend = TRUE;
+
+    self_debit->widget = go_graph_widget_new ( NULL );
+    bet_graph_create_graph_widget ( self_debit );
+    gtk_box_pack_start ( GTK_BOX ( box_pie ), self_debit->widget, TRUE, TRUE, 0 );
 
     /* populate and show the data for credit */
     result = bet_graph_populate_sectors_by_hist_data ( self_credit );
@@ -200,8 +244,8 @@ void bet_graph_sectors_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view
     result = gtk_dialog_run ( GTK_DIALOG ( dialog ) );
 
     /* free the data */
-    struct_free_bet_sectors_data ( self_debit );
-    struct_free_bet_sectors_data ( self_credit );
+    struct_free_bet_graph_data ( self_debit );
+    struct_free_bet_graph_data ( self_credit );
     gtk_widget_destroy ( dialog );
 }
 
@@ -212,76 +256,7 @@ void bet_graph_sectors_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view
  *
  *
  * */
-void bet_graph_create_pie_canvas  ( struct_bet_sectors_data *self )
-{
-	GtkWidget *w;
-	GogChart *chart;
-	GogGraph *graph;
-	GogLabel *label;
-	GogPlot *pie;
-	GogSeries *series;
-	GOStyle *style;
-	GOData *data;
-	GError *error = NULL;
-	PangoFontDescription *desc;
-
-	/* Set the graph widget */
-	w = self -> pie;
-
-	/* Get the embedded graph */
-	graph = go_graph_widget_get_graph ( GO_GRAPH_WIDGET ( w ) );
-
-	label = (GogLabel *) g_object_new ( GOG_TYPE_LABEL, NULL );
-	data = go_data_scalar_str_new ( self -> title, FALSE );
-	gog_dataset_set_dim ( GOG_DATASET ( label ), 0, data, NULL );
-	gog_object_add_by_name ( GOG_OBJECT ( graph ), "Title", GOG_OBJECT ( label ) );
-
-	/* Change the title font */
-	style = go_styled_object_get_style ( GO_STYLED_OBJECT ( label ) );
-	desc = pango_font_description_from_string ( "Sans bold 12" );
-	go_style_set_font_desc ( style, desc );
-
-	/* Get the chart created by the widget initialization */
-	chart = go_graph_widget_get_chart ( GO_GRAPH_WIDGET ( w ) );
-
-	/* Create a pie plot and add it to the chart */
-	pie = ( GogPlot *) gog_plot_new_by_name ( "GogPiePlot" );
-	gog_object_add_by_name ( GOG_OBJECT ( chart ), "Plot", GOG_OBJECT ( pie ) );
-
-	/* Add a legend to the chart */
-	gog_object_add_by_name ( GOG_OBJECT ( chart ), "Legend", NULL);
-
-	/* Create a series for the plot and populate it with some simple data */
-	series = gog_plot_new_series ( pie );
-	data = go_data_vector_str_new ( NULL, 0, NULL );
-	gog_series_set_dim ( series, 0, data, &error );
-    if ( error != NULL )
-    {
-        g_error ("gog_series_set_dim : erreur = %s\n", error -> message);
-        g_error_free ( error );
-        error = NULL;
-
-        return;
-    }
-
-    data = go_data_vector_val_new ( NULL, 0, NULL );
-	gog_series_set_dim ( series, 1, data, &error );
-    if ( error )
-    {
-        g_error ("gog_series_set_dim : erreur = %s\n", error -> message);
-        g_error_free ( error );
-        error = NULL;
-    }
-}
-
-
-/**
- *
- *
- *
- *
- * */
-gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_sectors_data *self )
+gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_graph_data *self )
 {
     GtkTreeModel *model = NULL;
     GtkTreeIter iter;
@@ -295,7 +270,7 @@ gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_sectors_data *self
         gint account_number;
         gchar *libelle_division = self -> tab_libelle[0];
         gchar **tab_libelle_division;
-        gdouble *tab_montant_division = self -> tab_montant;
+        gdouble *tab_montant_division = self -> tab_Y;
 
         tab_libelle_division = &libelle_division;
 
@@ -324,16 +299,13 @@ gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_sectors_data *self
             type_infos = bet_data_get_div_type ( div );
             if ( self -> type_infos == -1 || type_infos == self -> type_infos )
             {
-                if ( self -> nbre_elemnts >= MAX_SEGMENT_CAMEMBERT )
-                    continue;
-
                 strncpy ( &libelle_division[self -> nbre_elemnts * TAILLE_MAX_LIBELLE], desc, TAILLE_MAX_LIBELLE );
                 tab_montant_division[self -> nbre_elemnts] = utils_str_strtod ( ( amount == NULL) ? "0" : amount, NULL );
 
                 self -> nbre_elemnts++;
             }
 
-            if ( self -> nbre_elemnts > MAX_SEGMENT_CAMEMBERT )
+            if ( self -> nbre_elemnts >= MAX_SEGMENT_CAMEMBERT )
                 break;
 
         }
@@ -352,16 +324,16 @@ gboolean bet_graph_populate_sectors_by_hist_data ( struct_bet_sectors_data *self
  *
  *
  * */
-gboolean bet_graph_affiche_camemberts ( struct_bet_sectors_data *self )
+gboolean bet_graph_affiche_camemberts ( struct_bet_graph_data *self )
 {
     GogChart *chart;
     GogObject *cur_plot;
     GogSeries *series;
     GOData *data;
-    GError * error=NULL;
+    GError * error = NULL;
 
     /* Afficher les montants des divisions de type débit dans le camembert */
-    chart = go_graph_widget_get_chart ( GO_GRAPH_WIDGET ( self -> pie ) );
+    chart = go_graph_widget_get_chart ( GO_GRAPH_WIDGET ( self -> widget ) );
     cur_plot = gog_object_get_child_by_name ( GOG_OBJECT ( chart ), "Plot" );
 
     gog_plot_clear_series ( GOG_PLOT ( cur_plot ) );
@@ -377,7 +349,7 @@ gboolean bet_graph_affiche_camemberts ( struct_bet_sectors_data *self )
         return FALSE;
     }
 
-    data = go_data_vector_val_new ( self -> tab_montant, self -> nbre_elemnts, NULL);
+    data = go_data_vector_val_new ( self -> tab_Y, self -> nbre_elemnts, NULL);
 	gog_series_set_dim (series, 1, data, &error);
     if ( error != NULL )
     {
@@ -397,32 +369,216 @@ gboolean bet_graph_affiche_camemberts ( struct_bet_sectors_data *self )
  *
  *
  * */
-struct_bet_sectors_data *struct_initialise_bet_sectors_data ( void )
+void bet_graph_line_graph_new ( GtkWidget *menu_item, GtkTreeView *tree_view )
 {
-    struct_bet_sectors_data *self;
+    GtkWidget *dialog;
+    GtkWidget *label;
+    GtkWidget *sw_canvas;
+    GtkWidget *box_line;
+    gchar *title;
+    gint result;
+    gint account_number;
+    struct_bet_graph_data *self;
+
+    devel_debug (NULL);
+
+    /* Creation d'un nouveau GtkBuilder */
+    bet_graph_builder = gtk_builder_new ( );
+    if ( bet_graph_builder == NULL )
+        return;
+
+    result = utils_gtkbuilder_merge_ui_data_in_builder ( bet_graph_builder, "bet_graph.ui" );
+    if ( result == 0 )
+        return;
+
+    /* initialisation des structures de données */
+    account_number = gsb_gui_navigation_get_current_account ( );
+
+    self = struct_initialise_bet_graph_data ( );
+    self->tree_view = tree_view;
+    self->account_number = account_number;
+    self->service_id = "GogBarColPlot";
+
+    /* Création de la fenêtre de dialogue pour le graph */
+    dialog = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "bet_graph_dialog" ) );
+    gtk_window_set_transient_for ( GTK_WINDOW ( dialog ), GTK_WINDOW ( run.window ) );
+    gtk_widget_set_usize ( dialog, PAGE_WIDTH+30, PAGE_HEIGHT+70 );
+    gtk_signal_connect ( GTK_OBJECT ( dialog ),
+                        "destroy",
+		                GTK_SIGNAL_FUNC ( gtk_widget_destroy ),
+                        NULL);
+
+    sw_canvas = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "sw_canvas" ) );
+    box_line = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "box_line" ) );
+    gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( sw_canvas ), box_line );
+
+    /* set the title */
+    label = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( tree_view ), "label_title") );
+    title = make_pango_attribut ( "weight=\"bold\" size=\"x-large\"",
+                    gtk_label_get_text ( GTK_LABEL ( label ) ) );
+
+    label = GTK_WIDGET ( gtk_builder_get_object ( bet_graph_builder, "label_canvas" ) );
+    gtk_label_set_markup ( GTK_LABEL ( label ), title );
+    g_free ( title );
+
+    /* Set the graph for credit */
+    self->widget = go_graph_widget_new ( NULL );
+    bet_graph_create_graph_widget ( self );
+    gtk_box_pack_start ( GTK_BOX ( box_line ), self->widget, TRUE, TRUE, 0 );
+
+    bet_graph_populate_lines_by_forecast_data ( self );
+    bet_graph_affiche_XY_line ( self );
+    gtk_widget_show_all ( dialog );
+
+    result = gtk_dialog_run ( GTK_DIALOG ( dialog ) );
+
+    /* free the data */
+    struct_free_bet_graph_data ( self );
+    gtk_widget_destroy ( dialog );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_graph_populate_lines_by_forecast_data ( struct_bet_graph_data *self )
+{
+    GtkTreeModel *model = NULL;
+    GtkTreeIter iter;
+
+    model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( self -> tree_view ) );
+    if ( model == NULL )
+        return FALSE;
+
+    if ( gtk_tree_model_get_iter_first ( model, &iter ) )
+    {
+        gchar *libelle_axe_x = self -> tab_libelle[0];
+        gchar **tab_libelle_axe_x;
+        gdouble *tab_X = self -> tab_X;
+        gdouble *tab_Y = self -> tab_Y;
+        gdouble montant = 0.;
+        GDateMonth mois_courant;
+
+/*         gint x_axis = 0;  */
+
+        tab_libelle_axe_x = &libelle_axe_x;
+
+        do
+        {
+            gchar *amount;
+            gchar *str_date;
+            GValue date_value = {0,};
+            GDate *date;
+/*             GDateMonth mois;  */
+
+            gtk_tree_model_get_value ( model,
+                        &iter,
+                        SPP_ESTIMATE_TREE_SORT_DATE_COLUMN, &date_value );
+
+            gtk_tree_model_get ( GTK_TREE_MODEL( model ),
+                        &iter,
+                        SPP_ESTIMATE_TREE_AMOUNT_COLUMN, &amount,
+                        SPP_ESTIMATE_TREE_DATE_COLUMN, &str_date,
+                        -1 );
+            date = g_value_get_boxed ( &date_value );
+
+            montant += (gdouble) utils_str_strtod ( ( amount == NULL) ? "0" : amount, NULL );
+            tab_Y[self->nbre_elemnts] = montant;
+
+            if ( self -> nbre_elemnts == 0 )
+            {
+                g_date_add_days ( date, 1 );
+                mois_courant = g_date_get_month ( date );
+                strncpy ( &libelle_axe_x[self -> nbre_elemnts * TAILLE_MAX_LIBELLE], str_date, TAILLE_MAX_LIBELLE );
+            }
+            else
+            {
+/*                 mois = g_date_get_month ( date );
+ *                 if ( mois == mois_courant )
+ *                 {
+ *                     strncpy ( &libelle_axe_x[self -> nbre_elemnts * TAILLE_MAX_LIBELLE], "", TAILLE_MAX_LIBELLE );
+ *                 }
+ *                 else
+ *                 {
+ */
+                    strncpy ( &libelle_axe_x[self -> nbre_elemnts * TAILLE_MAX_LIBELLE], str_date, TAILLE_MAX_LIBELLE );
+                    mois_courant = g_date_get_month ( date );
+printf ("self -> nbre_elemnts = %d\tdate_value = %s date_texte = %s x = %d y = %.2f\n",
+    self -> nbre_elemnts, gsb_format_gdate (date), str_date, (gint) tab_X[self->nbre_elemnts], tab_Y[self->nbre_elemnts]);
+
+/*                 }                  */
+            }
+
+            self -> nbre_elemnts++;
+
+            if ( self -> nbre_elemnts >= MAX_POINTS_GRAPHIQUE )
+                break;
+        }
+        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
+
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+
+gboolean bet_graph_affiche_XY_line ( struct_bet_graph_data *self )
+{
+    GogChart *chart;
+    GogObject *cur_plot;
+    GogSeries *series;
+    GOData *data;
+    GError * error = NULL;
+
+    /* Afficher données dans le graphique */
+    chart = go_graph_widget_get_chart ( GO_GRAPH_WIDGET ( self->widget ) );
+    cur_plot = gog_object_get_child_by_name ( GOG_OBJECT ( chart ), "Plot" );
+
+    series = GOG_SERIES ( gog_plot_new_series ( GOG_PLOT ( cur_plot ) ) );
+
+    data = go_data_vector_str_new ( (const char * const*) self -> tab_vue_libelle, self -> nbre_elemnts, NULL );
+	gog_series_set_dim (series, 0, data, &error);
+    data = go_data_vector_val_new ( self->tab_Y, self->nbre_elemnts, NULL);
+	gog_series_set_dim (series, 1, data, &error);
+
+    return TRUE;
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+struct_bet_graph_data *struct_initialise_bet_graph_data ( void )
+{
+    struct_bet_graph_data *self;
     gint i;
 
-    self = g_new0 ( struct_bet_sectors_data, 1 );
+    self = g_new0 ( struct_bet_graph_data, 1 );
 
-    self -> tab_vue_libelle = g_malloc ( MAX_SEGMENT_CAMEMBERT * sizeof ( gchar* ) );
+    self -> tab_vue_libelle = g_malloc ( MAX_POINTS_GRAPHIQUE * sizeof ( gchar* ) );
 
-    for ( i = 0; i < MAX_SEGMENT_CAMEMBERT; i++ )
+    for ( i = 0; i < MAX_POINTS_GRAPHIQUE; i++ )
     {
         self -> tab_vue_libelle[i] = self -> tab_libelle[i];
     }
 
-    return self;
+   return self;
 }
 
 
- void struct_free_bet_sectors_data ( struct_bet_sectors_data *self )
+void struct_free_bet_graph_data ( struct_bet_graph_data *self )
 {
-
     g_free ( self -> title );
     g_free ( self -> tab_vue_libelle );
 
     g_free ( self );
-
 }
 
 
diff --git a/src/bet_graph.h b/src/bet_graph.h
index aff31df..7973ac6 100644
--- a/src/bet_graph.h
+++ b/src/bet_graph.h
@@ -8,8 +8,12 @@
 /* Definition de la taille mini de la boite de dialogue */
 #define PAGE_WIDTH 750
 #define PAGE_HEIGHT 550
+
 /* Definition du maximum de segments par camembert */
 #define MAX_SEGMENT_CAMEMBERT 30
+/* Definition du maximum de segments par camembert */
+#define MAX_POINTS_GRAPHIQUE 300
+
 /* Definition de la taille maximum d'un libelle */
 #define TAILLE_MAX_LIBELLE 50
 
diff --git a/src/bet_hist.h b/src/bet_hist.h
index 83d46bb..a923d39 100644
--- a/src/bet_hist.h
+++ b/src/bet_hist.h
@@ -6,24 +6,6 @@
 /* START_INCLUDE_H */
 /* END_INCLUDE_H */
 
-enum bet_historical_data_columns {
-    SPP_HISTORICAL_SELECT_COLUMN,
-    SPP_HISTORICAL_DESC_COLUMN,
-    SPP_HISTORICAL_CURRENT_COLUMN,  /* Accumulation of the current year */
-    SPP_HISTORICAL_BALANCE_COLUMN,
-    SPP_HISTORICAL_AVERAGE_COLUMN,
-    SPP_HISTORICAL_AVERAGE_AMOUNT,  /* average column without currency */
-    SPP_HISTORICAL_RETAINED_COLUMN,
-    SPP_HISTORICAL_RETAINED_AMOUNT, /* retenaid column without currency */
-    SPP_HISTORICAL_BALANCE_COLOR,
-    SPP_HISTORICAL_ACCOUNT_NUMBER,
-    SPP_HISTORICAL_DIV_NUMBER,
-    SPP_HISTORICAL_SUB_DIV_NUMBER,
-    SPP_HISTORICAL_EDITED_COLUMN,
-    SPP_HISTORICAL_BACKGROUND_COLOR,
-    SPP_HISTORICAL_NUM_COLUMNS
-};
-
 /* START_DECLARATION */
 GtkWidget *bet_historical_create_page ( void );
 gint bet_historical_get_fyear_from_combobox ( GtkWidget *combo_box );
diff --git a/src/bet_tab.c b/src/bet_tab.c
index 3ec243f..3ee0fa4 100644
--- a/src/bet_tab.c
+++ b/src/bet_tab.c
@@ -34,6 +34,7 @@
 #include "bet_config.h"
 #include "bet_data.h"
 #include "bet_future.h"
+#include "bet_graph.h"
 #include "bet_hist.h"
 #include "dialog.h"
 #include "export_csv.h"
@@ -170,26 +171,6 @@ static gint bet_array_current_tree_view_width = 0;
 static GtkWidget *bet_array_toolbar;
 
 
-enum bet_estimation_tree_columns
-{
-    SPP_ESTIMATE_TREE_SELECT_COLUMN,    /* select column for the balance */
-    SPP_ESTIMATE_TREE_ORIGIN_DATA,      /* origin of data : transaction, scheduled, hist, future */
-    SPP_ESTIMATE_TREE_DIVISION_COLUMN,  /* div_number, transaction_number, futur_number, scheduled_number*/
-    SPP_ESTIMATE_TREE_SUB_DIV_COLUMN,   /* sub_div_nb */
-    SPP_ESTIMATE_TREE_DATE_COLUMN,
-    SPP_ESTIMATE_TREE_DESC_COLUMN,
-    SPP_ESTIMATE_TREE_DEBIT_COLUMN,
-    SPP_ESTIMATE_TREE_CREDIT_COLUMN,
-    SPP_ESTIMATE_TREE_BALANCE_COLUMN,
-    SPP_ESTIMATE_TREE_SORT_DATE_COLUMN,
-    SPP_ESTIMATE_TREE_AMOUNT_COLUMN,    /* the amount without currency */
-    SPP_ESTIMATE_TREE_BALANCE_COLOR,
-    SPP_ESTIMATE_TREE_BACKGROUND_COLOR,
-    SPP_ESTIMATE_TREE_COLOR_STRING,
-    SPP_ESTIMATE_TREE_NUM_COLUMNS
-};
-
-
 /*
  * Met à jour les données à afficher dans les différentes vues du module
  *
@@ -714,7 +695,7 @@ GtkWidget *bet_array_create_tree_view ( GtkWidget *container )
 
     gtk_tree_view_column_set_alignment ( bet_array_tree_view_columns[i], 1 );
     gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), bet_array_tree_view_columns[i] );
-    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_FIXED );
+    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_GROW_ONLY );
     gtk_tree_view_column_set_resizable ( bet_array_tree_view_columns[i], TRUE );
     g_object_set_data ( G_OBJECT ( bet_array_tree_view_columns[i] ), "num_col_model",
                         GINT_TO_POINTER ( SPP_ESTIMATE_TREE_DEBIT_COLUMN ) );
@@ -732,7 +713,7 @@ GtkWidget *bet_array_create_tree_view ( GtkWidget *container )
 
     gtk_tree_view_column_set_alignment ( bet_array_tree_view_columns[i], 1 );
     gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), bet_array_tree_view_columns[i] );
-    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_FIXED );
+    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_GROW_ONLY );
     gtk_tree_view_column_set_resizable ( bet_array_tree_view_columns[i], TRUE );
     g_object_set_data ( G_OBJECT ( bet_array_tree_view_columns[i] ), "num_col_model",
                         GINT_TO_POINTER ( SPP_ESTIMATE_TREE_CREDIT_COLUMN ) );
@@ -751,7 +732,7 @@ GtkWidget *bet_array_create_tree_view ( GtkWidget *container )
 
     gtk_tree_view_column_set_alignment ( bet_array_tree_view_columns[i], 1 );
     gtk_tree_view_append_column (GTK_TREE_VIEW ( tree_view ), bet_array_tree_view_columns[i] );
-    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_FIXED );
+    gtk_tree_view_column_set_sizing ( bet_array_tree_view_columns[i], GTK_TREE_VIEW_COLUMN_GROW_ONLY );
     gtk_tree_view_column_set_resizable ( bet_array_tree_view_columns[i], TRUE );
     g_object_set_data ( G_OBJECT ( bet_array_tree_view_columns[i] ), "num_col_model",
                         GINT_TO_POINTER ( SPP_ESTIMATE_TREE_BALANCE_COLUMN ) );
@@ -2925,6 +2906,21 @@ GtkWidget *bet_array_list_create_toolbar ( GtkWidget *parent, GtkWidget *tree_vi
                         tree_view );
     gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 5 );
 
+#ifdef HAVE_GOFFICE
+    /* graph button */
+    button = gsb_automem_imagefile_button_new ( etat.display_toolbar,
+                        _("Data graph"),
+                        "graph-line.png",
+                        NULL,
+                        NULL );
+    gtk_widget_set_tooltip_text ( GTK_WIDGET ( button ), _("display the data graph") );
+    g_signal_connect ( G_OBJECT ( button ),
+                        "clicked",
+                        G_CALLBACK ( bet_graph_line_graph_new ),
+                        tree_view );
+    gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 5 );
+#endif
+
     gtk_widget_show_all ( hbox );
 
     return ( hbox );
diff --git a/src/gsb_account.c b/src/gsb_account.c
index 15c91ad..178e3a2 100644
--- a/src/gsb_account.c
+++ b/src/gsb_account.c
@@ -302,7 +302,7 @@ gboolean gsb_account_delete ( void )
  *
  * \return a new GtkCombobox containing the list of the accounts
  */
-GtkWidget *gsb_account_create_combo_list ( GCallback func, 
+GtkWidget *gsb_account_create_combo_list ( GCallback func,
 					   gpointer data,
 					   gboolean include_closed )
 {
@@ -497,7 +497,7 @@ gboolean gsb_account_set_combo_account_number ( GtkWidget *combo_box,
  *
  * \return A newly created menu
  */
-GtkWidget *gsb_account_create_menu_list ( GtkSignalFunc func, 
+GtkWidget *gsb_account_create_menu_list ( GCallback func,
 					  gboolean activate_currrent,
 					  gboolean include_closed )
 {
diff --git a/src/gsb_account.h b/src/gsb_account.h
index 898480e..ff5d020 100644
--- a/src/gsb_account.h
+++ b/src/gsb_account.h
@@ -7,10 +7,10 @@
 
 
 /* START_DECLARATION */
-GtkWidget *gsb_account_create_combo_list ( GCallback func, 
+GtkWidget *gsb_account_create_combo_list ( GCallback func,
 					   gpointer data,
 					   gboolean include_closed );
-GtkWidget *gsb_account_create_menu_list ( GtkSignalFunc func, 
+GtkWidget *gsb_account_create_menu_list ( GCallback func,
 					  gboolean activate_currrent,
 					  gboolean include_closed );
 gboolean gsb_account_delete ( void );
diff --git a/src/gsb_form_config.c b/src/gsb_form_config.c
index d1cbcdc..aa5bf03 100644
--- a/src/gsb_form_config.c
+++ b/src/gsb_form_config.c
@@ -153,7 +153,8 @@ void gsb_form_config_make_configuration_box ( GtkWidget *vbox_parent )
     gtk_box_pack_start ( GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0 );
 
     /* the accounts option_menu */
-    accounts_combobox = gsb_account_create_combo_list ((GtkSignalFunc) gsb_form_config_change_account_choice, NULL, FALSE );
+    accounts_combobox = gsb_account_create_combo_list ( G_CALLBACK ( gsb_form_config_change_account_choice ),
+                        NULL, FALSE );
 
     /*create the scolled window for tree_view */
     sw = gtk_scrolled_window_new ( NULL, NULL);
diff --git a/src/gsb_form_scheduler.c b/src/gsb_form_scheduler.c
index f180288..0ff8f69 100644
--- a/src/gsb_form_scheduler.c
+++ b/src/gsb_form_scheduler.c
@@ -159,8 +159,8 @@ gboolean gsb_form_scheduler_create ( GtkWidget *table )
 	    switch ( element_number )
 	    {
 		case SCHEDULED_FORM_ACCOUNT:
-		    widget = gsb_account_create_combo_list ((GtkSignalFunc) 
-                        gsb_form_scheduler_change_account, NULL, FALSE);
+		    widget = gsb_account_create_combo_list ( G_CALLBACK ( gsb_form_scheduler_change_account ),
+                        NULL, FALSE);
 		    gtk_combo_box_set_active ( GTK_COMBO_BOX (widget), 0 );
 		    tooltip_text = _("Choose the account");
 		    break;
diff --git a/src/ui/bet_graph.ui b/src/ui/bet_graph.ui
index 7d90ab4..4eae64b 100644
--- a/src/ui/bet_graph.ui
+++ b/src/ui/bet_graph.ui
@@ -90,4 +90,14 @@
       <placeholder/>
     </child>
   </object>
+  <object class="GtkVBox" id="box_line">
+    <property name="visible">True</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <placeholder/>
+    </child>
+    <child>
+      <placeholder/>
+    </child>
+  </object>
 </interface>
diff --git a/src/utils_gtkbuilder.c b/src/utils_gtkbuilder.c
index a7f9c7a..fe97af9 100644
--- a/src/utils_gtkbuilder.c
+++ b/src/utils_gtkbuilder.c
@@ -30,6 +30,7 @@
 
 /*START_INCLUDE*/
 #include "utils_gtkbuilder.h"
+#include "dialog.h"
 /*END_INCLUDE*/
 
 /*START_STATIC*/
@@ -40,7 +41,7 @@
 
 
 /**
- * obtient le fichier de l'interface graphique
+ * retourne le nom long du fichier de l'interface graphique
  *
  *
  *
@@ -83,6 +84,45 @@ GtkWidget *utils_gtkbuilder_get_widget_by_name ( GtkBuilder *builder,
 }
 
 
+/**
+ * retourne le nom long du fichier de l'interface graphique
+ *
+ *
+ *
+ * */
+gint utils_gtkbuilder_merge_ui_data_in_builder ( GtkBuilder *builder,
+                    const gchar *ui_name )
+{
+    gchar *filename;
+    gint result;
+    GError *error = NULL;
+
+    /* Chargement du XML dans bet_graph_builder */
+    filename = utils_gtkbuilder_get_full_path ( ui_name );
+    if ( !g_file_test ( filename, G_FILE_TEST_EXISTS ) )
+    {
+        gchar* tmpstr;
+
+        tmpstr = g_strdup_printf ( _("Cannot open file '%s': %s"),
+                        filename,
+                        _("File does not exist") );
+        dialogue_error ( tmpstr );
+        g_free ( tmpstr );
+        g_free ( filename );
+        return 0;
+    }
+
+    result = gtk_builder_add_from_file ( builder, filename, &error );
+    if ( result == 0 )
+    {
+        g_error ("%s", error->message);
+        g_error_free ( error );
+    }
+    g_free ( filename );
+
+    return result;
+}
+
 
 /* Local Variables: */
 /* c-basic-offset: 4 */
diff --git a/src/utils_gtkbuilder.h b/src/utils_gtkbuilder.h
index 69183e7..fc0fa50 100644
--- a/src/utils_gtkbuilder.h
+++ b/src/utils_gtkbuilder.h
@@ -12,6 +12,8 @@ gchar *utils_gtkbuilder_get_full_path ( const gchar *name );
 GtkWidget *utils_gtkbuilder_get_widget_by_name ( GtkBuilder *builder,
                         const gchar *gtk_builder_name,
                         const gchar *optional_name );
+gint utils_gtkbuilder_merge_ui_data_in_builder ( GtkBuilder *builder,
+                    const gchar *ui_name );
 /* END_DECLARATION */
 
 #endif /* _H_UTILS_GTKBUILDER */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list