+/* valid iso is empoty or 3 capital digit */
+static guint currency_iso_code_valid(gchar *str)
+{
+guint n = 0;
+
+ while( *str )
+ {
+ if( *str >= 'A' && *str <= 'Z' )
+ n++;
+ str++;
+ }
+ return n;
+}
+
+
+static void
+ui_cur_select_custom_validate_cb(GtkWidget *widget, gpointer user_data)
+{
+struct ui_cur_select_dialog_data *data = user_data;
+gboolean custom;
+gboolean valid = TRUE;
+const gchar *iso, *name;
+guint len;
+
+ DB( g_printf("\n[ui_cur_select] custom validate\n") );
+
+ custom = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(data->CM_custom));
+
+ DB( g_print(" custom=%d\n", custom) );
+
+ //custom
+ if( custom == TRUE )
+ {
+ valid = FALSE;
+
+ name = gtk_entry_get_text (GTK_ENTRY (data->ST_custname));
+ iso = gtk_entry_get_text (GTK_ENTRY (data->ST_custiso));
+
+ len = currency_iso_code_valid((gchar *)iso);
+
+ DB( g_print(" name='%d', iso='%d'\n", (gint)strlen(name), len) );
+
+ if( (len==0 || len==3) && (strlen(name) >= 3 ) )
+ {
+ valid = TRUE;
+ // don't allow to enter stand 4217 iso code
+ if( len == 3 )
+ {
+ Currency4217 *stdcur = iso4217format_get((gchar *)iso);
+ if(stdcur != NULL)
+ valid = FALSE;
+ }
+ }
+ }
+
+ gtk_dialog_set_response_sensitive(GTK_DIALOG(data->window), GTK_RESPONSE_ACCEPT, valid);
+
+}
+
+
+static void
+ui_cur_select_custom_activate_cb(GtkWidget *widget, gpointer user_data)
+{
+struct ui_cur_select_dialog_data *data = user_data;
+gboolean custom;
+
+ DB( g_printf("\n[ui_cur_select] custom activate\n") );
+
+ custom = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(data->CM_custom));
+
+ DB( g_print(" custom=%d\n", custom) );
+
+ gtk_widget_set_sensitive(data->ST_search, !custom);
+ gtk_widget_set_sensitive(data->LV_cur, !custom);
+
+ hb_widget_visible (data->LB_custname, custom);
+ hb_widget_visible (data->ST_custname, custom);
+ hb_widget_visible (data->LB_custiso, custom);
+ hb_widget_visible (data->ST_custiso, custom);
+
+ if(custom)
+ {
+ gtk_tree_selection_unselect_all(gtk_tree_view_get_selection (GTK_TREE_VIEW(data->LV_cur)));
+ gtk_window_set_focus(GTK_WINDOW(data->window), data->ST_custname);
+ }
+
+ ui_cur_select_custom_validate_cb(data->window, data);
+
+}
+
+