[grisbi-cvs] grisbi/src gsb_currency.c,1.51,1.52 tip.c,1.29,1.30

Pierre Biava pbiava at users.sourceforge.net
Wed Nov 25 23:23:28 CET 2009


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

Modified Files:
	gsb_currency.c tip.c 
Log Message:
Fixed a bug in the display of tips and updated French translation

Index: gsb_currency.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- gsb_currency.c	24 Nov 2009 05:18:30 -0000	1.51
+++ gsb_currency.c	25 Nov 2009 22:23:26 -0000	1.52
@@ -496,7 +496,7 @@
                         gboolean force )
 {
     GtkWidget *dialog, *label, *entry, *hbox, *fees_entry, *paddingbox, *table;
-    GtkWidget *amount_1_entry, *amount_2_entry, *widget;
+    GtkWidget *amount_entry, *amount_1_entry, *amount_2_entry, *widget;
     struct cached_exchange_rate *cache;
     gint result;
     GtkWidget *combobox_1;
@@ -551,7 +551,7 @@
     combobox_1 = gsb_currency_make_combobox_exchange_dialog (
                         account_currency_number,
                         transaction_currency_number,
-                        1 );
+                        link_currency );
     gtk_table_attach ( GTK_TABLE(table), combobox_1, 1, 2, row, row+1,
                         GTK_SHRINK | GTK_FILL, 0, 0, 0 );
 
@@ -565,11 +565,21 @@
     combobox_2 = gsb_currency_make_combobox_exchange_dialog (
                         account_currency_number,
                         transaction_currency_number,
-                        0 );
+                        !link_currency );
     gtk_table_attach ( GTK_TABLE(table), combobox_2, 3, 4, row, row+1,
                GTK_SHRINK | GTK_FILL, 0, 0, 0 );
     row++;
 
+    /* set the connections */
+    g_signal_connect ( G_OBJECT (combobox_1),
+                        "changed",
+                        G_CALLBACK ( gsb_currency_select_change_currency ),
+                        combobox_2 );
+    g_signal_connect ( G_OBJECT (combobox_2),
+                        "changed",
+                        G_CALLBACK ( gsb_currency_select_change_currency ),
+                        combobox_1);
+
     /* amount line */
     label = gtk_label_new ( COLON(_("Amounts")) );
     gtk_misc_set_alignment ( GTK_MISC ( label ), 0.0, 0.0 );
@@ -593,16 +603,25 @@
     gtk_table_attach ( GTK_TABLE(table), amount_2_entry, 3, 4, row, row+1,
                GTK_SHRINK | GTK_FILL, 0, 0, 0 );
 
-    /* set the connections */
-    g_signal_connect ( G_OBJECT (combobox_1),
-                        "changed",
-                        G_CALLBACK ( gsb_currency_select_change_currency ),
-                        combobox_2 );
-    g_signal_connect ( G_OBJECT (combobox_2),
-                        "changed",
-                        G_CALLBACK ( gsb_currency_select_change_currency ),
-                        combobox_1);
+    /* if amount exist already, fill them here */
+    if ( link_currency )
+        amount_entry = amount_2_entry;
+    else
+        amount_entry = amount_1_entry;
 
+    widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_DEBIT );
+    if ( !gsb_form_widget_check_empty ( widget ) )
+        gtk_entry_set_text ( GTK_ENTRY ( amount_entry ),
+                        gtk_entry_get_text ( GTK_ENTRY ( widget ) ) );
+    else
+    {
+        widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CREDIT );
+        if ( !gsb_form_widget_check_empty ( widget ) )
+            gtk_entry_set_text ( GTK_ENTRY ( amount_entry ),
+                        gtk_entry_get_text ( GTK_ENTRY ( widget ) ) );
+    }
+
+    /* set the connections */
     g_signal_connect ( G_OBJECT ( amount_1_entry ),
                         "changed",
                         G_CALLBACK ( gsb_currency_select_double_amount ),
@@ -612,6 +631,10 @@
                         G_CALLBACK ( gsb_currency_select_double_amount ),
                         amount_1_entry );
     g_object_set_data ( G_OBJECT ( amount_1_entry ), "exchange_rate", entry );
+    g_object_set_data ( G_OBJECT ( amount_1_entry ), "link_currency",
+                        GINT_TO_POINTER ( link_currency ) );
+    
+    
     row++;
 
     /* exchange fees line label */
@@ -632,23 +655,10 @@
     gtk_table_attach ( GTK_TABLE(table), label, 2, 3, row, row+1,
                GTK_SHRINK | GTK_FILL, 0, 0, 0 );
 
-    /* if amount exist already, fill them here */
-    widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_DEBIT );
-    if ( !gsb_form_widget_check_empty ( widget ) )
-        gtk_entry_set_text ( GTK_ENTRY ( amount_1_entry ),
-                        gtk_entry_get_text ( GTK_ENTRY ( widget ) ) );
-    widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CREDIT );
-    if ( !gsb_form_widget_check_empty ( widget ) )
-        gtk_entry_set_text ( GTK_ENTRY ( amount_1_entry ),
-                        gtk_entry_get_text ( GTK_ENTRY ( widget ) ) );
-
     /* if the rate or fees exist already, fill them here */
     if ( exchange_rate.mantissa )
     {
-        if ( link_currency )
-            tmpstr = gsb_real_get_string ( gsb_real_inverse ( exchange_rate ) );
-        else
-            tmpstr = gsb_real_get_string (exchange_rate );
+        tmpstr = gsb_real_get_string ( exchange_rate );
         gtk_entry_set_text ( GTK_ENTRY ( entry ), tmpstr );
         g_free ( tmpstr );
     }
@@ -661,7 +671,7 @@
     }
 
     gtk_widget_show_all ( dialog );
-
+//~ printf ("link_currency = %d\n", link_currency );
     /* show the dialog */
 dialog_return:
     result = gtk_dialog_run ( GTK_DIALOG ( dialog ));
@@ -671,11 +681,7 @@
         gint link_number;
         gint new_link_number;
 
-        if ( link_currency )
-            current_exchange = gsb_real_inverse ( gsb_real_get_from_string (
-                        gtk_entry_get_text ( GTK_ENTRY ( entry ) ) ) );
-        else
-            current_exchange = gsb_real_get_from_string (
+        current_exchange = gsb_real_get_from_string (
                         gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
 
         if ( strlen ( gtk_entry_get_text ( GTK_ENTRY ( fees_entry ) ) ) > 0
@@ -852,14 +858,28 @@
 gboolean gsb_currency_select_double_amount ( GtkWidget *entry_1,
                         GtkWidget *entry_2 )
 {
-    GtkWidget *entry;
+    GtkWidget *entry, *entry_3, *entry_4;
     gsb_real amount_1, amount_2, taux;
+    gboolean link_currency;
 
     entry = g_object_get_data ( G_OBJECT ( entry_1 ), "exchange_rate" );
+    link_currency = GPOINTER_TO_INT ( g_object_get_data (
+                         G_OBJECT ( entry_1 ), "link_currency" ) );
 
-    if ( strlen ( gtk_entry_get_text ( GTK_ENTRY ( entry_1 ) ) ) > 0 )
+    if ( link_currency )
     {
-        if ( !strlen ( gtk_entry_get_text ( GTK_ENTRY ( entry_2 ) ) ) )
+        entry_3 = entry_2;
+        entry_4 = entry_1;
+    }
+    else
+    {
+        entry_3 = entry_1;
+        entry_4 = entry_2;
+    }
+
+    if ( strlen ( gtk_entry_get_text ( GTK_ENTRY ( entry_3 ) ) ) > 0 )
+    {
+        if ( !strlen ( gtk_entry_get_text ( GTK_ENTRY ( entry_4 ) ) ) )
 		{
             gtk_entry_set_text ( GTK_ENTRY ( entry ), "");
 			gtk_widget_set_sensitive ( GTK_WIDGET ( entry ), TRUE );
@@ -871,6 +891,10 @@
             amount_2 = gsb_str_to_real ( gtk_entry_get_text ( GTK_ENTRY ( entry_2 ) ) );
             taux = gsb_real_div ( amount_2, amount_1 );
             gtk_entry_set_text ( GTK_ENTRY ( entry ), gsb_real_get_string ( taux ) );
+            //~ printf ("amount_1 = %s amount_2 = %s taux = %s\n",
+                        //~ gtk_entry_get_text ( GTK_ENTRY ( entry_1 ) ),
+                        //~ gtk_entry_get_text ( GTK_ENTRY ( entry_2 ) ),
+                        //~ gtk_entry_get_text ( GTK_ENTRY ( entry ) ) );
         }
     }
     return FALSE;
@@ -894,7 +918,7 @@
     string = g_strconcat( PIXMAPS_DIR, C_DIRECTORY_SEPARATOR,
                         "flags", C_DIRECTORY_SEPARATOR,
                         gsb_data_currency_get_code_iso4217 (
-                        account_currency_number ),
+                        transaction_currency_number ),
                         ".png", NULL );
     pixbuf = gdk_pixbuf_new_from_file ( string, NULL );
     g_free (string);
@@ -902,13 +926,13 @@
     gtk_list_store_append ( GTK_LIST_STORE ( combobox_store ), &iter );
     gtk_list_store_set ( combobox_store, &iter,
                     0, pixbuf,
-                    1, gsb_data_currency_get_name ( account_currency_number ),
+                    1, gsb_data_currency_get_name ( transaction_currency_number ),
                     -1 );
 
     string = g_strconcat( PIXMAPS_DIR, C_DIRECTORY_SEPARATOR,
                         "flags", C_DIRECTORY_SEPARATOR,
                         gsb_data_currency_get_code_iso4217 (
-                        transaction_currency_number ),
+                        account_currency_number ),
                         ".png", NULL );
     pixbuf = gdk_pixbuf_new_from_file ( string, NULL );
     g_free (string);
@@ -916,7 +940,7 @@
     gtk_list_store_append ( GTK_LIST_STORE ( combobox_store ), &iter );
     gtk_list_store_set ( combobox_store, &iter,
                     0, pixbuf,
-                    1, gsb_data_currency_get_name ( transaction_currency_number ),
+                    1, gsb_data_currency_get_name ( account_currency_number ),
                     -1 );
 
     combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL 

Index: tip.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/tip.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- tip.c	14 Nov 2008 21:27:09 -0000	1.29
+++ tip.c	25 Nov 2009 22:23:26 -0000	1.30
@@ -1,8 +1,9 @@
 /* ************************************************************************** */
-/* Ce fichier s'occupe des astuces					      */
+/* Ce fichier s'occupe des astuces                                            */
 /*                                                                            */
-/*     Copyright (C)	2004-2008 Benjamin Drieu (bdrieu at april.org)	      */
-/* 			http://www.grisbi.org				      */
+/*     Copyright (C)    2004-2008 Benjamin Drieu (bdrieu at april.org)           */
+/*          2009 Pierre Biava (grisbi at pierre.biava.name)                      */
+/*          http://www.grisbi.org                                             */
 /*                                                                            */
 /*  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      */
@@ -61,9 +62,10 @@
     GtkWidget * checkbox;
     GtkWidget * dialog = NULL;
     gchar * tip;
+    gchar *tmpstr;
 
     if ( !force && !etat.show_tip )
-	return;
+        return;
 
     etat.last_tip ++;
     tip = get_next_tip ();
@@ -71,57 +73,71 @@
     // If no tips found ... no dialog will be displayed...
     if (!tip)
     {
-	dialog_message ( "no-tip-available" );
-	return;
+        dialog_message ( "no-tip-available" );
+        return;
     }
     dialog = dialogue_special_no_run ( GTK_MESSAGE_INFO, GTK_BUTTONS_NONE,
-				       make_hint ( _("Did you know that..."),
-						   /* We use the grisbi-tips catalog */
-						   dgettext("grisbi-tips", (tip) ) ) );
+                        make_hint ( _("Did you know that..."),
+                        /* We use the grisbi-tips catalog */
+                        dgettext("grisbi-tips", (tip) ) ) );
     gtk_window_set_modal ( GTK_WINDOW ( dialog ), FALSE );
 
     checkbox = gsb_automem_checkbutton_new ( _("Display tips at next start"), 
-					     &(etat.show_tip), NULL, NULL );
+                        &(etat.show_tip), NULL, NULL );
     gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog) -> vbox ), checkbox, FALSE, FALSE, 6 );
     gtk_widget_show ( checkbox );
 
     gtk_dialog_add_buttons ( GTK_DIALOG(dialog),
-			     GTK_STOCK_GO_BACK, 1,
-			     GTK_STOCK_GO_FORWARD, 2,
-			     GTK_STOCK_CLOSE, 3,
-			     NULL );
+                        GTK_STOCK_GO_BACK, 1,
+                        GTK_STOCK_GO_FORWARD, 2,
+                        GTK_STOCK_CLOSE, 3,
+                        NULL );
  
     /* We iterate as user can select several tips. */
     while ( TRUE )
     {
-	if ( max == etat.last_tip )
-	    change_button_sensitiveness ( dialog, 1, FALSE );
-	if ( etat.last_tip == 1 )
-	    change_button_sensitiveness ( dialog, 0, FALSE );
+    if ( max == etat.last_tip )
+        change_button_sensitiveness ( dialog, 1, FALSE );
+    if ( etat.last_tip == 1 )
+        change_button_sensitiveness ( dialog, 0, FALSE );
 
-	switch ( gtk_dialog_run ( GTK_DIALOG(dialog) ) )
-	{
-	    case 1:
-		if ( etat.last_tip > 1 )
-		    etat.last_tip --;
-		change_button_sensitiveness ( dialog, 1, TRUE ); 
-		gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ), 
-				       make_hint ( _("Did you know that..."),
-						   dgettext("grisbi-tips", get_next_tip ()) ) );
-		break;
+    switch ( gtk_dialog_run ( GTK_DIALOG(dialog) ) )
+    {
+        case 1:
+        if ( etat.last_tip > 1 )
+            etat.last_tip --;
+        change_button_sensitiveness ( dialog, 1, TRUE ); 
+                tmpstr = g_markup_printf_escaped (
+                        g_strconcat ( "<span size=\"larger\" weight=\"bold\">",
+                        _("Did you know that..."),
+                        "</span>\n\n",
+                        dgettext ("grisbi-tips",
+                        get_next_tip () ),
+                        NULL ) );
+        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
+                        tmpstr );
+        g_free ( tmpstr );
+        break;
 
-	    case 2:
-		etat.last_tip ++;
-		gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ), 
-				       make_hint ( _("Did you know that..."),
-						   dgettext("grisbi-tips", get_next_tip () ) ) );
-		change_button_sensitiveness ( dialog, 0, TRUE );
-		break;
+        case 2:
+        etat.last_tip ++;
+        tmpstr = g_markup_printf_escaped (
+                        g_strconcat ( "<span size=\"larger\" weight=\"bold\">",
+                        _("Did you know that..."),
+                        "</span>\n\n",
+                        dgettext ("grisbi-tips",
+                        get_next_tip () ),
+                        NULL ) );
+        gtk_label_set_markup ( GTK_LABEL ( GTK_MESSAGE_DIALOG(dialog) -> label ),
+                        tmpstr );
+        g_free ( tmpstr );
+        change_button_sensitiveness ( dialog, 0, TRUE );
+        break;
 
-	    default:
-		gtk_widget_destroy ( dialog );
-		return;
-	}
+        default:
+        gtk_widget_destroy ( dialog );
+        return;
+    }
     }
 }
 



More information about the cvs mailing list