[grisbi-cvs] grisbi/src gsb_form_widget.c,1.45,1.46

Pierre Biava pbiava at users.sourceforge.net
Thu Jan 28 21:20:57 CET 2010


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

Modified Files:
	gsb_form_widget.c 
Log Message:
fixed bug 912

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- gsb_form_widget.c	23 Jan 2010 19:35:10 -0000	1.45
+++ gsb_form_widget.c	28 Jan 2010 20:20:54 -0000	1.46
@@ -60,6 +60,8 @@
                         gint *ptr_origin );
 static gboolean gsb_form_widget_amount_entry_changed ( GtkWidget *entry,
 				        gpointer null );
+static gboolean gsb_form_combo_selection_changed ( GtkTreeSelection *tree_selection,
+						gint *ptr_origin );
 /*END_STATIC*/
 
 /*START_EXTERN*/
@@ -160,6 +162,7 @@
                         gint account_number )
 {
     GtkWidget *widget;
+    GtkTreeSelection *tree_selection;
 
     if (!element_number)
 	return NULL;
@@ -341,22 +344,30 @@
 	{
 	    if ( GTK_IS_COMBOFIX ( widget ))
 	    {
-		g_signal_connect ( G_OBJECT ( GTK_COMBOFIX ( widget ) -> entry ),
-				   "focus-in-event",
-				   G_CALLBACK ( gsb_form_entry_get_focus ),
-				   GINT_TO_POINTER ( element_number ));
-		g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
-				   "focus-out-event",
-				   G_CALLBACK ( gsb_form_entry_lose_focus ),
-				   GINT_TO_POINTER ( element_number ));
-		g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
-				   "button-press-event",
-				   G_CALLBACK ( gsb_form_button_press_event ),
-				   GINT_TO_POINTER ( element_number ));
-		g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
-				   "key-press-event",
-				   G_CALLBACK ( gsb_form_key_press_event ),
-				   GINT_TO_POINTER ( element_number ));
+            tree_selection = gtk_tree_view_get_selection (
+                        GTK_TREE_VIEW ( GTK_COMBOFIX ( widget ) -> tree_view ) );
+
+		    g_signal_connect ( G_OBJECT ( GTK_COMBOFIX ( widget ) -> entry ),
+                       "focus-in-event",
+                       G_CALLBACK ( gsb_form_entry_get_focus ),
+                       GINT_TO_POINTER ( element_number ));
+		    g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
+                       "focus-out-event",
+                       G_CALLBACK ( gsb_form_entry_lose_focus ),
+                       GINT_TO_POINTER ( element_number ));
+		    g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
+                       "button-press-event",
+                       G_CALLBACK ( gsb_form_button_press_event ),
+                       GINT_TO_POINTER ( element_number ));
+            g_signal_connect ( G_OBJECT ( GTK_COMBOFIX (widget ) -> entry ),
+                       "key-press-event",
+                       G_CALLBACK ( gsb_form_key_press_event ),
+                       GINT_TO_POINTER ( element_number ));
+            g_signal_connect ( G_OBJECT ( tree_selection ),
+                       "changed",
+                       G_CALLBACK ( gsb_form_combo_selection_changed ),
+                       GINT_TO_POINTER ( element_number ) );
+
 	    }
 	    else
 		/* neither an entry, neither a combofix */
@@ -365,7 +376,8 @@
 				   G_CALLBACK ( gsb_form_key_press_event ),
 				   GINT_TO_POINTER ( element_number ));
 	}
-    } else {
+    }
+    else {
     	alert_debug ( "Widget should not be NULL" );
     }
     
@@ -994,3 +1006,68 @@
 
     return TRUE;
 }
+
+
+/**
+ *
+ *
+ *
+ *
+ * */
+gboolean gsb_form_combo_selection_changed ( GtkTreeSelection *tree_selection,
+						  gint *ptr_origin )
+{
+    GtkWidget *widget;
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    gchar *tmp_str;
+    gint element_number;
+    gint account_nb;
+
+    element_number = GPOINTER_TO_INT (ptr_origin);
+
+    if ( !gtk_tree_selection_get_selected ( GTK_TREE_SELECTION ( tree_selection ),
+     &model, &iter ) )
+        return FALSE;
+
+    gtk_tree_model_get ( model, &iter, 1, &tmp_str, -1 );
+    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:
+            widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_DEVISE );
+            if ( widget != NULL 
+             && 
+             GTK_WIDGET_VISIBLE (
+             gsb_form_widget_get_widget ( TRANSACTION_FORM_DEVISE) ) )
+            {
+                if ( g_str_has_prefix ( tmp_str, _("Transfer : ") ) )
+                {
+                    account_nb = gsb_form_get_account_number ( );
+                    if ( g_str_has_suffix ( tmp_str,
+                     gsb_data_account_get_name ( account_nb ) ) )
+                        gtk_widget_hide ( gsb_form_widget_get_widget (
+                            TRANSACTION_FORM_CHANGE ) );
+                    else
+                        gtk_widget_show ( gsb_form_widget_get_widget (
+                            TRANSACTION_FORM_CHANGE ) );
+                }
+                else
+                    gtk_widget_hide ( gsb_form_widget_get_widget (
+                        TRANSACTION_FORM_CHANGE ) );
+            }
+            else
+            {
+                widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CHANGE );
+                if ( widget != NULL )
+                    gtk_widget_hide ( widget );
+            }
+            break;
+        }
+    }
+    return FALSE;
+}



More information about the cvs mailing list