[grisbi-cvs] grisbi/src balance_estimate_config.c, 1.3, 1.4 balance_estimate_tab.c, 1.36, 1.37 gsb_data_transaction.c, 1.80, 1.81 gsb_data_transaction.h, 1.36, 1.37 gsb_form_transaction.c, 1.54, 1.55 gsb_form_widget.c, 1.46, 1.47 gsb_transactions_list.c, 1.194, 1.195 gtk_combofix.c, 1.68, 1.69 utils.c, 1.58, 1.59 utils.h, 1.27, 1.28

Pierre Biava pbiava at users.sourceforge.net
Sat Jan 30 18:04:14 CET 2010


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

Modified Files:
	balance_estimate_config.c balance_estimate_tab.c 
	gsb_data_transaction.c gsb_data_transaction.h 
	gsb_form_transaction.c gsb_form_widget.c 
	gsb_transactions_list.c gtk_combofix.c utils.c utils.h 
Log Message:
fix bug 867 and minor corrections

Index: gsb_data_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- gsb_data_transaction.c	16 Jan 2010 15:00:31 -0000	1.80
+++ gsb_data_transaction.c	30 Jan 2010 17:04:12 -0000	1.81
@@ -2125,11 +2125,13 @@
  * 
  * \param source_transaction_number the transaction we want to copy
  * \param target_transaction_number the trnasaction we want to fill with the content of the first one
+ * \param reset transaction_id, marked, reconcile number and archive number
  * 
  * \return TRUE if ok, FALSE else
  * */
 gboolean gsb_data_transaction_copy_transaction ( gint source_transaction_number,
-                        gint target_transaction_number )
+                        gint target_transaction_number,
+                        gboolean reset_mark )
 {
     struct_transaction *source_transaction;
     struct_transaction *target_transaction;
@@ -2150,10 +2152,13 @@
 	     sizeof ( struct_transaction ));
     target_transaction -> transaction_number = target_transaction_number;
     target_transaction -> account_number = target_transaction_account_number;
-    target_transaction -> reconcile_number = 0;
-    target_transaction -> marked_transaction = 0;
-    target_transaction -> transaction_id = NULL;
-    target_transaction -> archive_number = 0;
+    if ( reset_mark )
+    {
+        target_transaction -> reconcile_number = 0;
+        target_transaction -> marked_transaction = 0;
+        target_transaction -> transaction_id = NULL;
+        target_transaction -> archive_number = 0;
+    }
 
     /* make a new copy of all the pointers */
     if ( target_transaction -> notes)
@@ -2172,8 +2177,8 @@
 	target_transaction -> value_date = gsb_date_copy (source_transaction -> value_date);
 
     if ( target_transaction -> method_of_payment_content)
-	target_transaction -> method_of_payment_content = my_strdup ( source_transaction -> method_of_payment_content );
-
+	target_transaction -> method_of_payment_content = my_strdup (
+                        source_transaction -> method_of_payment_content );
     return TRUE;
 }
 

Index: gtk_combofix.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gtk_combofix.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- gtk_combofix.c	11 Jan 2010 19:46:35 -0000	1.68
+++ gtk_combofix.c	30 Jan 2010 17:04:12 -0000	1.69
@@ -153,6 +153,7 @@
  * */
 GtkWidget *gtk_combofix_new_complex ( GSList *list )
 {
+    GtkTreeIter iter;
     GSList *tmp_list;
     gint list_number = 0;
     gint length;
@@ -168,32 +169,47 @@
     combofix -> visible_items = 0;
     combofix -> case_sensitive = FALSE;
 
+    gtk_tree_store_append ( combofix -> store, &iter, NULL );
+    gtk_tree_store_set ( combofix -> store,
+                        &iter,
+                        COMBOFIX_COL_VISIBLE_STRING, "",
+                        COMBOFIX_COL_REAL_STRING, "",
+                        COMBOFIX_COL_VISIBLE, TRUE,
+                        COMBOFIX_COL_LIST_NUMBER, list_number,
+                        -1 );
+    list_number++;
+    gtk_tree_store_append ( combofix -> store, &iter, NULL );
+    gtk_tree_store_set ( combofix -> store,
+             &iter,
+             COMBOFIX_COL_LIST_NUMBER, list_number,
+             COMBOFIX_COL_SEPARATOR, TRUE,
+             -1 );
+    list_number ++;
+
     tmp_list = list;
     length = g_slist_length (list);
 
     while ( tmp_list )
     {
-	GtkTreeIter iter;
-
-	gtk_combofix_fill_store ( combofix,
-				  tmp_list -> data,
-				  list_number );
+        gtk_combofix_fill_store ( combofix,
+                      tmp_list -> data,
+                      list_number );
 
-	/* set the separator */
-	if (list_number < (length-1))
-	{
-	    gtk_tree_store_append ( combofix -> store,
-				    &iter,
-				    NULL );
-	    gtk_tree_store_set ( combofix -> store,
-				 &iter,
-				 COMBOFIX_COL_LIST_NUMBER, list_number,
-				 COMBOFIX_COL_SEPARATOR, TRUE,
-				 -1 );
-	}
+        /* set the separator */
+        if (list_number < (length-1))
+        {
+            gtk_tree_store_append ( combofix -> store,
+                        &iter,
+                        NULL );
+            gtk_tree_store_set ( combofix -> store,
+                     &iter,
+                     COMBOFIX_COL_LIST_NUMBER, list_number,
+                     COMBOFIX_COL_SEPARATOR, TRUE,
+                     -1 );
+        }
 
-	list_number++;
-	tmp_list = tmp_list -> next;
+        list_number++;
+        tmp_list = tmp_list -> next;
     }
 
     return ( GTK_WIDGET ( combofix ) );

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- gsb_form_widget.c	28 Jan 2010 20:20:54 -0000	1.46
+++ gsb_form_widget.c	30 Jan 2010 17:04:12 -0000	1.47
@@ -1031,11 +1031,12 @@
         return FALSE;
 
     gtk_tree_model_get ( model, &iter, 1, &tmp_str, -1 );
+
+    widget = gsb_form_widget_get_widget ( element_number );
+    g_object_set_data_full ( G_OBJECT ( widget ), "combo_text", tmp_str, g_free );
+
     if ( tmp_str && strlen ( tmp_str ) )
     {
-        widget = gsb_form_widget_get_widget ( element_number );
-        g_object_set_data_full ( G_OBJECT ( widget ), "combo_text", tmp_str, g_free );
-
         switch ( element_number )
         {
         case TRANSACTION_FORM_CATEGORY:

Index: balance_estimate_config.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_config.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- balance_estimate_config.c	28 Jan 2010 20:25:12 -0000	1.3
+++ balance_estimate_config.c	30 Jan 2010 17:04:12 -0000	1.4
@@ -74,6 +74,7 @@
 extern GtkTreeModel *bet_fyear_model_filter;
 /*END_EXTERN*/
 
+
 /**
  *
  *

Index: utils.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- utils.h	26 Dec 2009 16:57:13 -0000	1.27
+++ utils.h	30 Jan 2010 17:04:12 -0000	1.28
@@ -16,15 +16,13 @@
                         GdkEventMotion *event,
                         gpointer pointeur );
 GtkWidget *new_paddingbox_with_title (GtkWidget * parent, gboolean fill, gchar * title);
-GtkWidget *new_vbox_with_title_and_icon ( gchar * title,
-                        gchar * image_filename);
+GtkWidget *new_vbox_with_title_and_icon ( gchar * title, gchar * image_filename);
 GtkWidget *new_vbox_with_title_and_image ( gchar * title, GtkWidget *image );
 gboolean radio_set_active_linked_widgets ( GtkWidget * widget );
 void register_button_as_linked ( GtkWidget * widget, GtkWidget * linked );
-gboolean sens_desensitive_pointeur ( GtkWidget *bouton,
-                        GtkWidget *widget );
-gboolean sensitive_widget ( gpointer object,
-                        GtkWidget *widget );
+gboolean sens_desensitive_pointeur ( GtkWidget *bouton, GtkWidget *widget );
+gboolean sensitive_widget ( gpointer object, GtkWidget *widget );
+GtkWidget *utils_get_child_widget_by_name ( GtkWidget *ancestor, const gchar *name );
 void update_ecran ( void );
 /* END_DECLARATION */
 #endif

Index: gsb_form_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_transaction.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- gsb_form_transaction.c	13 Jan 2010 19:30:15 -0000	1.54
+++ gsb_form_transaction.c	30 Jan 2010 17:04:12 -0000	1.55
@@ -300,7 +300,7 @@
 
 	    new_child_number = gsb_data_transaction_new_transaction ( gsb_data_transaction_get_account_number (new_transaction_number));
 	    gsb_data_transaction_copy_transaction ( transaction_number_tmp,
-						    new_child_number );
+						    new_child_number, TRUE );
 	    gsb_data_transaction_set_mother_transaction_number ( new_child_number,
 								 new_transaction_number);
 	    gsb_data_transaction_set_date ( new_child_number,
@@ -430,30 +430,31 @@
 	/* it's a modification of a transaction */
 
 	/* as we will do a transfer, the category number is null */
-	gsb_data_transaction_set_category_number ( transaction_number,
-						   0 );
-	gsb_data_transaction_set_sub_category_number ( transaction_number,
-						       0 );
-	contra_transaction_number = gsb_data_transaction_get_contra_transaction_number (transaction_number);
+	gsb_data_transaction_set_category_number ( transaction_number, 0 );
+	gsb_data_transaction_set_sub_category_number ( transaction_number, 0 );
+	contra_transaction_number = gsb_data_transaction_get_contra_transaction_number (
+                        transaction_number);
 
 	if (contra_transaction_number > 0)
 	{
 	    /* the transaction is a transfer */
 
-	    /* if the contra transaction was a child of split, copying/deleting it will remove the information
-	     * of the mother, so we get it here */
-	    contra_mother_number = gsb_data_transaction_get_mother_transaction_number (contra_transaction_number);
+	    /* if the contra transaction was a child of split, copying/deleting it
+	     * will remove the information of the mother, so we get it here */
+	    contra_mother_number = gsb_data_transaction_get_mother_transaction_number (
+                        contra_transaction_number);
 
 	    /* check if we change the account targe */
-	    if ( gsb_data_transaction_get_contra_transaction_account (transaction_number) != account_transfer )
+	    if ( gsb_data_transaction_get_contra_transaction_account (
+                        transaction_number) != account_transfer )
 	    {
-		/* it was a transfer and the user changed the target account so we delete the last contra transaction
-		 * contra_transaction_transfer has just been set */
+            /* it was a transfer and the user changed the target account so we delete
+             * the last contra transaction contra_transaction_transfer has just been set */
 
-		gsb_data_transaction_set_contra_transaction_number ( contra_transaction_number,
-								       0);
-		gsb_transactions_list_delete_transaction (contra_transaction_number, FALSE);
-		new_transaction = 1;
+            gsb_data_transaction_set_contra_transaction_number (
+                            contra_transaction_number, 0);
+            gsb_transactions_list_delete_transaction (contra_transaction_number, FALSE);
+            new_transaction = 1;
 	    }
 	}
 	else
@@ -469,10 +470,10 @@
      * already set */
 
     if ( new_transaction )
-	contra_transaction_number = gsb_data_transaction_new_transaction (account_transfer);
+        contra_transaction_number = gsb_data_transaction_new_transaction (account_transfer);
 
     gsb_data_transaction_copy_transaction ( transaction_number,
-					    contra_transaction_number );
+					    contra_transaction_number, new_transaction );
 
     /* contra_mother_number contains the mother number of the contra transaction if it was a modification
      * and that contra-transaction was a child of split, and if not it is 0, and it's a good thing because

Index: gsb_transactions_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_transactions_list.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- gsb_transactions_list.c	21 Jan 2010 22:16:52 -0000	1.194
+++ gsb_transactions_list.c	30 Jan 2010 17:04:12 -0000	1.195
@@ -2432,7 +2432,7 @@
     /* dupplicate the transaction */
     new_transaction_number = gsb_data_transaction_new_transaction ( gsb_data_transaction_get_account_number (transaction_number));
     gsb_data_transaction_copy_transaction ( transaction_number,
-					    new_transaction_number );
+					    new_transaction_number, TRUE );
 
     if (gsb_data_transaction_get_mother_transaction_number (transaction_number)
 	&&

Index: gsb_data_transaction.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- gsb_data_transaction.h	10 Dec 2009 22:02:32 -0000	1.36
+++ gsb_data_transaction.h	30 Jan 2010 17:04:12 -0000	1.37
@@ -21,7 +21,8 @@
 gint gsb_data_transaction_check_content_payment ( gint payment_number,
                         gint number );
 gboolean gsb_data_transaction_copy_transaction ( gint source_transaction_number,
-                        gint target_transaction_number );
+                        gint target_transaction_number,
+                        gboolean reset_mark );
 gint gsb_data_transaction_find_by_id ( gchar *id, gint account_number );
 gint gsb_data_transaction_find_by_payment_content ( const gchar *string,
                         gint account_number );

Index: utils.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- utils.c	26 Dec 2009 16:57:13 -0000	1.58
+++ utils.c	30 Jan 2010 17:04:12 -0000	1.59
@@ -3,6 +3,7 @@
 /*          2003-2008 Benjamin Drieu (bdrieu at april.org)                       */
 /*          2003-2004 Alain Portal (aportal at univ-montp2.fr)                   */
 /*          2003-2004 Francois Terrot (francois.terrot at grisbi.org)            */
+/*          2008-2010 Pierre Biava (grisbi at pierre.biava.name)                 */
 /*          http://www.grisbi.org                                             */
 /*                                                                            */
 /*  This program is free software; you can redistribute it and/or modify      */
@@ -460,6 +461,50 @@
 	return version;
 }
 
+/**
+ *  This function returns a child widget whose name is passed as parameter
+ *
+ * /parameter ancestor
+ * /parameter name of the child
+ *
+ * /return the child or NULL
+ */
+GtkWidget *utils_get_child_widget_by_name ( GtkWidget *ancestor, const gchar *name )
+{
+    GtkWidget *widget;
+    GList *list;
+
+    list = gtk_container_get_children ( GTK_CONTAINER ( ancestor ) );
+    if ( list == NULL )
+        return NULL;
+
+    do
+    {
+        const gchar *tmp_str;
+
+        widget = list -> data;
+
+        tmp_str = gtk_widget_get_name ( GTK_WIDGET ( widget ) );
+        if ( tmp_str && g_strcmp0 ( name, tmp_str ) == 0 )
+            return widget;
+
+        if ( GTK_IS_CONTAINER ( widget ) )
+        {
+            widget = utils_get_child_widget_by_name ( widget, name );
+            if ( widget )
+            {
+                tmp_str = gtk_widget_get_name ( GTK_WIDGET ( widget ) );
+                if ( tmp_str && g_strcmp0 ( name, tmp_str ) == 0 )
+                    return widget;
+            }
+        }
+
+        list = g_list_next ( list );
+    } while ( list );
+
+    return NULL;
+}
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: balance_estimate_tab.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/balance_estimate_tab.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- balance_estimate_tab.c	29 Jan 2010 18:21:06 -0000	1.36
+++ balance_estimate_tab.c	30 Jan 2010 17:04:12 -0000	1.37
@@ -58,6 +58,7 @@
 #include "./structures.h"
 #include "./traitement_variables.h"
 #include "./erreur.h"
+#include "./utils.h"
 /*END_INCLUDE*/
 
 
@@ -573,32 +574,73 @@
  */
 static void bet_duration_period_clicked ( GtkWidget *togglebutton, GtkWidget *button )
 {
+    GtkWidget *ancestor;
+    GtkWidget *widget;
     const gchar *name;
+
 devel_debug (NULL);
-    g_signal_handlers_block_by_func ( G_OBJECT ( button ),
+    if ( button )
+        g_signal_handlers_block_by_func ( G_OBJECT ( button ),
                         G_CALLBACK (bet_duration_period_clicked),
                         button );
 
+    ancestor = g_object_get_data ( G_OBJECT ( bet_container ), "bet_account_duration" );
+    
     name = gtk_widget_get_name ( GTK_WIDGET ( togglebutton ) );
     if ( g_strcmp0 ( name, "button_1" ) == 0 )
     {
         etat.bet_deb_period = 1;
         etat.bet_end_period = 1;
+        if ( gtk_widget_is_ancestor ( togglebutton, ancestor ) == FALSE )
+        {
+            widget = utils_get_child_widget_by_name ( ancestor, name );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE );
+            widget = utils_get_child_widget_by_name ( ancestor, "button_3" );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE ); 
+        }
         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ), TRUE );
     }
     else if ( g_strcmp0 ( name, "button_2" ) == 0 )
     {
         etat.bet_deb_period = 2;
         etat.bet_end_period = 2;
+        if ( gtk_widget_is_ancestor ( togglebutton, ancestor ) == FALSE )
+        {
+            widget = utils_get_child_widget_by_name ( ancestor, name );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE );
+            widget = utils_get_child_widget_by_name ( ancestor, "button_4" );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE ); 
+        }
         gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ), TRUE );
     }
     else if ( g_strcmp0 ( name, "button_3" ) == 0 )
+    {
         etat.bet_end_period = 1;
+        if ( gtk_widget_is_ancestor ( togglebutton, ancestor ) == FALSE )
+        {
+            widget = utils_get_child_widget_by_name ( ancestor, name );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE );
+        }
+    }
 
     else if ( g_strcmp0 ( name, "button_4" ) == 0 )
+    {
         etat.bet_end_period = 2;
+        if ( gtk_widget_is_ancestor ( togglebutton, ancestor ) == FALSE )
+        {
+            widget = utils_get_child_widget_by_name ( ancestor, name );
+            if ( widget )
+                gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ), TRUE );
+        }
+    }
 
-    g_signal_handlers_unblock_by_func ( G_OBJECT ( button ),
+    if ( button )
+        g_signal_handlers_unblock_by_func ( G_OBJECT ( button ),
                         G_CALLBACK (bet_duration_period_clicked),
                         button );
 
@@ -905,6 +947,8 @@
     GtkWidget *vbox;
     GtkWidget *hbox;
     GtkWidget *tree_view;
+    GtkWidget *duration;
+
 devel_debug (NULL);
     widget = gtk_label_new ( _("Choice the prevision") );
     gtk_widget_show ( GTK_WIDGET ( widget ) );
@@ -941,7 +985,8 @@
     g_object_set_data ( G_OBJECT ( notebook ), "bet_account_treeview", tree_view );
 
     /* create duration selection */
-    bet_estimate_get_duration_widget ( vbox, FALSE );
+    duration = bet_estimate_get_duration_widget ( vbox, FALSE );
+    g_object_set_data ( G_OBJECT ( notebook ), "bet_account_duration", duration );
 }
 
 



More information about the cvs mailing list