[grisbi-cvs] grisbi/src balance_estimate_tab.c, 1.30, 1.31 gsb_form_widget.c, 1.43, 1.44 gsb_transactions_list.c, 1.193, 1.194 import.c, 1.318, 1.319 transaction_list.c, 1.56, 1.57 transaction_list.h, 1.10, 1.11 transaction_model.c, 1.4, 1.5 utils_dates.c, 1.62, 1.63

Pierre Biava pbiava at users.sourceforge.net
Thu Jan 21 23:16:54 CET 2010


Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12999/src

Modified Files:
	balance_estimate_tab.c gsb_form_widget.c 
	gsb_transactions_list.c import.c transaction_list.c 
	transaction_list.h transaction_model.c utils_dates.c 
Log Message:
fixed bug 875 and minor corrections

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- gsb_form_widget.c	16 Jan 2010 15:00:32 -0000	1.43
+++ gsb_form_widget.c	21 Jan 2010 22:16:52 -0000	1.44
@@ -981,10 +981,12 @@
         {
             if ( g_unichar_isdefined ( thousands_sep ) )
             {
-                if ( ch != '.' && ch != ',' && ch != thousands_sep )
+                if ( ch != '.' && ch != ',' && ch != '+' && ch != '-'
+                 && ch != thousands_sep
+                  )
                     return FALSE;
             }
-            else if ( ch != '.' && ch != ',' )
+            else if ( ch != '.' && ch != ',' && ch != '+' && ch != '-' )
                     return FALSE;
         }
 

Index: gsb_transactions_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_transactions_list.c,v
retrieving revision 1.193
retrieving revision 1.194
diff -u -d -r1.193 -r1.194
--- gsb_transactions_list.c	8 Jan 2010 19:24:35 -0000	1.193
+++ gsb_transactions_list.c	21 Jan 2010 22:16:52 -0000	1.194
@@ -3300,21 +3300,25 @@
 gboolean gsb_transactions_list_switch_expander ( gint transaction_number )
 {
     GtkTreePath *path;
+    gint last_line;
 
     devel_debug_int (transaction_number);
 
-    if ( !gsb_data_transaction_get_split_of_transaction (transaction_number))
-	return FALSE;
+    if ( !gsb_data_transaction_get_split_of_transaction ( transaction_number ) )
+	    return FALSE;
 
-    path = transaction_model_get_path ( transaction_number,
-					gsb_data_account_get_nb_rows (gsb_gui_navigation_get_current_account ()) -1);
+    last_line = transaction_list_get_last_line (
+                    gsb_data_account_get_nb_rows (
+                    gsb_gui_navigation_get_current_account ( ) ) );
+    path = transaction_model_get_path ( transaction_number, last_line );
 
-    if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (transactions_tree_view), path))
-	gtk_tree_view_collapse_row (GTK_TREE_VIEW (transactions_tree_view), path);
+    if ( gtk_tree_view_row_expanded ( GTK_TREE_VIEW ( transactions_tree_view ), path ) )
+	    gtk_tree_view_collapse_row ( GTK_TREE_VIEW ( transactions_tree_view ), path );
     else
-	gtk_tree_view_expand_row (GTK_TREE_VIEW (transactions_tree_view), path, FALSE);
+	    gtk_tree_view_expand_row ( GTK_TREE_VIEW ( transactions_tree_view ), path, FALSE );
+
+    gtk_tree_path_free ( path );
 
-    gtk_tree_path_free (path);
     return FALSE;
 }
 

Index: transaction_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/transaction_list.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- transaction_list.c	11 Jan 2010 19:46:35 -0000	1.56
+++ transaction_list.c	21 Jan 2010 22:16:52 -0000	1.57
@@ -62,7 +62,6 @@
 static  void transaction_list_append_child ( gint transaction_number );
 static  CustomRecord *transaction_list_create_record ( gint transaction_number,
                         gint line_in_transaction );
-static gint transaction_list_get_last_line ( gint nb_rows );
 static  gboolean transaction_list_update_white_child ( CustomRecord *white_record );
 /*END_STATIC*/
 
@@ -174,7 +173,8 @@
     }
 
     /* get the P position if the transaction is marked */
-    marked_transaction = gsb_data_transaction_get_marked_transaction (transaction_number) != OPERATION_NORMALE;
+    marked_transaction = gsb_data_transaction_get_marked_transaction (
+                        transaction_number) != OPERATION_NORMALE;
     line_p = find_element_line (ELEMENT_MARK);
 
     /* get the new number of the first row in the complete list of row */
@@ -226,23 +226,25 @@
 	    /* the row need to be shown */
 	    GtkTreePath *path;
 	    GtkTreeIter iter;
+        gint last_line_visible;
 
 	    newrecord[i] -> line_visible = TRUE;
 
+        last_line_visible = transaction_list_get_last_line (
+			            custom_list -> nb_rows_by_transaction );
+
 	    newrecord[i] -> filtered_pos = custom_list -> num_visibles_rows;
 	    custom_list -> visibles_rows[newrecord[i] -> filtered_pos] = newrecord[i];
 	    custom_list -> num_visibles_rows++;
 
-	    /* if we are the last line visible and are mother, we set the expander */
-	    if (children_rows
-		&&
-		i == (custom_list -> nb_rows_by_transaction - 1))
+        /* if we are the last line visible and are mother, we set the expander */
+	    if ( children_rows && i == last_line_visible )
 	    {
-		newrecord[i] -> has_expander = TRUE;
-		white_record -> mother_row = newrecord[i];
-        /* set the color of the mother */
-        mother_text_color = &text_color[1];
-        newrecord[i] -> text_color = mother_text_color;
+            newrecord[i] -> has_expander = TRUE;
+            white_record -> mother_row = newrecord[i];
+            /* set the color of the mother */
+            mother_text_color = &text_color[1];
+            newrecord[i] -> text_color = mother_text_color;
 	    }
 
 	    /* inform the tree view */
@@ -254,10 +256,10 @@
 
 	    gtk_tree_model_row_inserted (GTK_TREE_MODEL(custom_list), path, &iter);
 	    /* if there is a child (white line), set the expander */
-	    if (newrecord[i] -> has_expander)
-		gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (custom_list),
-						      path, &iter);
-	    gtk_tree_path_free(path);
+	    if ( newrecord[i] -> has_expander )
+		    gtk_tree_model_row_has_child_toggled ( GTK_TREE_MODEL ( custom_list ),
+						      path, &iter );
+	    gtk_tree_path_free ( path );
 	}
 	else
 	    newrecord[i] -> filtered_pos = -1;
@@ -1788,9 +1790,11 @@
 	/* the mother is visible, inform the tree view we append a child */
 	GtkTreePath *path;
 	GtkTreeIter iter;
+    gint last_line;
 
 	/* we go on the last mother record, wich contains the expander */
-	mother_record = mother_record -> transaction_records[custom_list -> nb_rows_by_transaction - 1];
+    last_line = transaction_list_get_last_line ( custom_list -> nb_rows_by_transaction );
+	mother_record = mother_record -> transaction_records[last_line];
 
 	newrecord -> mother_row = mother_record;
 	/* this is very important to keep to compatibility with the normal transactions */

Index: import.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.c,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- import.c	18 Jan 2010 23:06:34 -0000	1.318
+++ import.c	21 Jan 2010 22:16:52 -0000	1.319
@@ -1263,14 +1263,14 @@
                         GINT_TO_POINTER (IMPORT_MARK_TRANSACTIONS));
 
 	/* set on the right account */
-    account_number = gsb_data_account_get_account_by_id (compte->id_compte);
-    if(account_number >= 0)
+    account_number = gsb_data_account_get_account_by_id ( compte->id_compte );
+    if ( account_number >= 0 )
     {
-    	import_account_action_activated(radio_add_account,IMPORT_ADD_TRANSACTIONS);
-    	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_add_account), TRUE);
+    	import_account_action_activated ( radio_add_account,IMPORT_ADD_TRANSACTIONS );
+    	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( radio_add_account ), TRUE );
 
-		gsb_account_set_combo_account_number (compte -> bouton_compte_add, account_number);
-    	gsb_account_set_combo_account_number (compte -> bouton_compte_mark, account_number);
+		gsb_account_set_combo_account_number ( compte -> bouton_compte_add, account_number );
+    	gsb_account_set_combo_account_number ( compte -> bouton_compte_mark, account_number );
     }
 
     /* Currency */

Index: transaction_list.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/transaction_list.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- transaction_list.h	13 Aug 2009 19:24:49 -0000	1.10
+++ transaction_list.h	21 Jan 2010 22:16:52 -0000	1.11
@@ -25,5 +25,6 @@
                         GValue *value );
 gboolean transaction_list_update_element ( gint element_number );
 gboolean transaction_list_update_transaction ( gint transaction_number );
+gint transaction_list_get_last_line ( gint nb_rows );
 /* END_DECLARATION */
 #endif

Index: utils_dates.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_dates.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- utils_dates.c	19 Jan 2010 16:06:08 -0000	1.62
+++ utils_dates.c	21 Jan 2010 22:16:52 -0000	1.63
@@ -299,10 +299,10 @@
 GDate *gsb_parse_date_string ( const gchar *date_string )
 {
     GDate *date;
-    gchar * string, * format, *sreturn;
-    gchar ** tab_date, ** tab_format;
+    gchar *string, *format;
+    gchar **tab_date;
     gchar date_tokens [ 4 ] = { 0, 0, 0, 0 };
-    int num_tokens = 0, num_fields = 0, i, j, k;
+    int num_tokens = 0, num_fields = 0, i, j;
 
     if ( !date_string
     ||
@@ -317,6 +317,10 @@
 
     /* Obtain date format tokens to compute order. */
 #ifdef _MSC_VER
+    gchar *sreturn;
+    gchar **tab_format;
+    int k;
+
 	sreturn = g_strnfill(81,'\0');
 	GetLocaleInfo(GetThreadLocale(), LOCALE_SSHORTDATE, sreturn, 80);
 	g_strcanon (sreturn, "dMy", '.');

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- balance_estimate_tab.c	18 Jan 2010 22:33:52 -0000	1.30
+++ balance_estimate_tab.c	21 Jan 2010 22:16:52 -0000	1.31
@@ -151,6 +151,7 @@
     SPP_HISTORICAL_PERIOD_COLUMN,
     SPP_HISTORICAL_BALANCE_COLUMN,
     SPP_HISTORICAL_AVERAGE_COLUMN,
+    SPP_HISTORICAL_RETAINED_COLUMN,
     SPP_HISTORICAL_AMOUNT_COLUMN, /* average column without currency */
     SPP_HISTORICAL_BALANCE_COLOR,
     SPP_HISTORICAL_NUM_COLUMNS
@@ -915,6 +916,101 @@
 }
 
 
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean bet_historical_div_toggle_clicked ( GtkCellRendererToggle *renderer,
+                        gchar *path_string,
+                        GtkTreeModel *store )
+{
+    GtkTreeIter iter;
+    gboolean valeur;
+    gint nbre_fils;
+
+    if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( store ), &iter, path_string ) )
+    {
+        gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter, 0, &valeur, -1 );
+        valeur = 1 - valeur;
+        gtk_tree_store_set ( GTK_TREE_STORE ( store ), &iter, 0, valeur, -1 );
+
+        nbre_fils = gtk_tree_model_iter_n_children ( GTK_TREE_MODEL ( store ),
+                        &iter );
+        if ( nbre_fils > 0 )
+        {
+            gint i = 0;
+            GtkTreeIter fils_iter;
+
+            while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( store ),
+                        &fils_iter, &iter, i ) )
+            {
+                gtk_tree_store_set ( GTK_TREE_STORE ( store ), &fils_iter, 0, valeur, -1 );
+                i++;
+            }
+        }
+        else
+        {
+            GtkTreeIter parent;
+            gboolean fils_val;
+            gboolean test = TRUE;
+            gint i = 0;
+
+            if ( gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( store ),
+                        &parent, &iter ) )
+            {
+                while ( gtk_tree_model_iter_nth_child ( GTK_TREE_MODEL ( store ),
+                        &iter, &parent, i ) )
+                {
+                    gtk_tree_model_get ( GTK_TREE_MODEL ( store ), &iter,
+                        0, &fils_val, -1 );
+                    if ( fils_val != valeur )
+                    {
+                        test = FALSE;
+                        break;
+                    }
+                    i++;
+                }
+                if ( test == TRUE )
+                    gtk_tree_store_set ( GTK_TREE_STORE ( store ), &parent, 0, valeur, -1 );
+                else
+                    gtk_tree_store_set ( GTK_TREE_STORE ( store ), &parent, 0, 0, -1 );
+            }
+        }
+    }
+
+    return ( FALSE );
+}
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+void bet_historical_div_cell_edited (GtkCellRendererText *cell,
+                        const gchar *path_string,
+                        const gchar *new_text,
+                        GtkWidget *tree_view )
+{
+    //~ GtkWidget *entry;
+    //~ GtkTreeView *treeview;
+    GtkTreeModel *model;
+    GtkTreePath *path = gtk_tree_path_new_from_string ( path_string );
+    GtkTreeIter iter;
+    //~ GSList *list_tmp;
+    //~ gchar *search_str;
+    //~ gint payee_number;
+
+    printf ("bet_historical_div_cell_edited\n");
+    model = gtk_tree_view_get_model ( tree_view );
+    gtk_tree_model_get_iter (model, &iter, path);
+    //~ gtk_tree_model_get ( model, &iter, SPP_HISTORICAL_RETAINED_COLUMN, &search_str, -1 );
+}
+
+
 /*
  * bet_duration_button changed
  * This function is called when a spin button is changed.
@@ -1464,7 +1560,7 @@
                         G_TYPE_BOOLEAN,G_TYPE_STRING,
                         G_TYPE_STRING, G_TYPE_STRING,
                         G_TYPE_STRING, G_TYPE_STRING,
-                        G_TYPE_STRING );
+                        G_TYPE_STRING, G_TYPE_STRING );
     gtk_tree_view_set_model ( GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL ( tree_model ) );
     g_object_unref ( G_OBJECT ( tree_model ) );
 
@@ -1473,10 +1569,6 @@
 
     tree_selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) );
     gtk_tree_selection_set_mode ( tree_selection, GTK_SELECTION_SINGLE );
-    //~ g_signal_connect ( G_OBJECT ( tree_selection ),
-                        //~ "changed",
-                        //~ G_CALLBACK (bet_account_selection_changed),
-                        //~ NULL );
 
     scrolled_window = gtk_scrolled_window_new ( NULL, NULL );
     gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( scrolled_window ),
@@ -1491,6 +1583,10 @@
     gtk_cell_renderer_toggle_set_radio ( GTK_CELL_RENDERER_TOGGLE ( cell ),
                         FALSE );
     g_object_set (cell, "xalign", 0.5, NULL);
+	g_signal_connect ( cell,
+                        "toggled",
+                        G_CALLBACK (bet_historical_div_toggle_clicked),
+                        tree_model );
 
     column = gtk_tree_view_column_new_with_attributes ( _("Select"),
                         cell,
@@ -1559,13 +1655,13 @@
     /* amount retained column */
     cell = gtk_cell_renderer_text_new ( );
     g_object_set (cell, "editable", TRUE, NULL);
-    //~ g_signal_connect ( cell,
-                        //~ "edited",
-                        //~ G_CALLBACK (gsb_import_associations_cell_edited),
-                        //~ vbox_main );
+    g_signal_connect ( cell,
+                        "edited",
+                        G_CALLBACK (bet_historical_div_cell_edited),
+                        tree_view );
     column = gtk_tree_view_column_new_with_attributes (
                         _("Amount retained"), cell,
-                        "text", SPP_HISTORICAL_AVERAGE_COLUMN,
+                        "text", SPP_HISTORICAL_RETAINED_COLUMN,
                         "foreground", SPP_HISTORICAL_BALANCE_COLOR,
                         NULL);
     gtk_tree_view_append_column ( GTK_TREE_VIEW ( tree_view ),
@@ -1814,6 +1910,7 @@
                         SPP_HISTORICAL_PERIOD_COLUMN, titre,
                         SPP_HISTORICAL_BALANCE_COLUMN, str_balance,
                         SPP_HISTORICAL_AVERAGE_COLUMN, str_average,
+                        SPP_HISTORICAL_RETAINED_COLUMN, str_average,
                         -1);
     g_free ( div_name );
     g_free ( str_balance );

Index: transaction_model.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/transaction_model.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- transaction_model.c	21 May 2009 21:58:55 -0000	1.4
+++ transaction_model.c	21 Jan 2010 22:16:52 -0000	1.5
@@ -149,22 +149,30 @@
     GtkTreeIter iter;
 
     g_return_val_if_fail ( custom_list != NULL, NULL );
-
+printf ("transaction_number = %d line_in_transaction = %d\n", transaction_number, line_in_transaction);
     if (!transaction_model_get_transaction_iter ( &iter,
 						  transaction_number, line_in_transaction ))
+    {
+        printf ("iter == NULL\n");
 	return NULL;
+    }
 
     record = iter.user_data;
     if (!record)
+    {
+        printf ("record == NULL\n");
 	return NULL;
-
+    }
     record = record -> transaction_records[line_in_transaction];
 
     path = gtk_tree_path_new ();
     if (record -> mother_row)
+    {
+        printf ("record -> mother_row -> filtered_pos = %d\n", record -> mother_row -> filtered_pos);
 	/* it's a child, need to get the path of the mother */
 	gtk_tree_path_append_index (path, record -> mother_row -> filtered_pos);
-
+    }
+    printf ("record -> filtered_pos = %d\n", record -> filtered_pos);
     gtk_tree_path_append_index (path, record -> filtered_pos);
 
     return path;



More information about the cvs mailing list