@ -171,6 +171,53 @@ gnc_import_add_account(GtkWidget *button, AccountPickerDialog *picker)
}
/***********************************************************
* show_placeholder_warning
*
* show the warning when account is a place holder and disable
* OK button
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void
show_placeholder_warning ( AccountPickerDialog * picker , const gchar * name )
{
gchar * text = g_strdup_printf ( _ ( " The account %s is a placeholder account and does not allow "
" transactions. Please choose a different account. " ) , name ) ;
gtk_label_set_text ( GTK_LABEL ( picker - > pwarning ) , text ) ;
gnc_label_set_alignment ( picker - > pwarning , 0.0 , 0.5 ) ;
gtk_widget_show_all ( GTK_WIDGET ( picker - > pwhbox ) ) ;
g_free ( text ) ;
gtk_widget_set_sensitive ( picker - > ok_button , FALSE ) ; // disable OK button
}
/*******************************************************
* account_tree_row_changed_cb
*
* Callback for when user selects a different row
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void
account_tree_row_changed_cb ( GtkTreeSelection * selection ,
AccountPickerDialog * picker )
{
Account * sel_account = gnc_tree_view_account_get_selected_account ( picker - > account_tree ) ;
gtk_widget_set_sensitive ( picker - > ok_button , TRUE ) ; // enable OK button
/* See if the selected account is a placeholder. */
if ( sel_account & & xaccAccountGetPlaceholder ( sel_account ) )
{
const gchar * retval_name = xaccAccountGetName ( sel_account ) ;
show_placeholder_warning ( picker , retval_name ) ;
}
else
gtk_widget_hide ( GTK_WIDGET ( picker - > pwhbox ) ) ; // hide the placeholder warning
}
/*******************************************************
* account_tree_row_activated_cb
*
@ -201,10 +248,7 @@ account_tree_row_activated_cb(GtkTreeView *view, GtkTreePath *path,
/* See if the selected account is a placeholder. */
if ( picker - > retAccount & & xaccAccountGetPlaceholder ( picker - > retAccount ) )
{
gnc_error_dialog ( GTK_WINDOW ( picker - > dialog ) ,
_ ( " The account %s is a placeholder account and does not allow "
" transactions. Please choose a different account. " ) ,
retval_name ) ;
show_placeholder_warning ( picker , retval_name ) ;
}
else if ( picker - > account_online_id_value ! = NULL )
{
@ -251,6 +295,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
Account * retval = NULL ;
const gchar * retval_name = NULL ;
GtkBuilder * builder ;
GtkTreeSelection * selection ;
GtkWidget * online_id_label , * box , * pbox ;
gchar account_description_text [ ACCOUNT_DESCRIPTION_MAX_SIZE + 1 ] = " " ;
gboolean ok_pressed_retval = FALSE ;
@ -314,6 +359,10 @@ Account * gnc_import_select_account(GtkWidget *parent,
PERR ( " Error opening the glade builder interface " ) ;
}
picker - > dialog = GTK_WIDGET ( gtk_builder_get_object ( builder , " account_picker_dialog " ) ) ;
picker - > pwhbox = GTK_WIDGET ( gtk_builder_get_object ( builder , " placeholder_warning_hbox " ) ) ;
picker - > pwarning = GTK_WIDGET ( gtk_builder_get_object ( builder , " placeholder_warning_label " ) ) ;
picker - > ok_button = GTK_WIDGET ( gtk_builder_get_object ( builder , " okbutton " ) ) ;
if ( parent )
gtk_window_set_transient_for ( GTK_WINDOW ( picker - > dialog ) ,
GTK_WINDOW ( parent ) ) ;
@ -349,11 +398,17 @@ Account * gnc_import_select_account(GtkWidget *parent,
}
gtk_label_set_text ( ( GtkLabel * ) online_id_label , account_description_text ) ;
build_acct_tree ( picker ) ;
gnc_tree_view_account_set_selected_account ( picker - > account_tree , default_selection ) ;
gtk_window_set_modal ( GTK_WINDOW ( picker - > dialog ) , TRUE ) ;
g_signal_connect ( picker - > account_tree , " row-activated " ,
G_CALLBACK ( account_tree_row_activated_cb ) , picker ) ;
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( picker - > account_tree ) ) ;
g_signal_connect ( selection , " changed " ,
G_CALLBACK ( account_tree_row_changed_cb ) , picker ) ;
gnc_tree_view_account_set_selected_account ( picker - > account_tree , default_selection ) ;
do
{
response = gtk_dialog_run ( GTK_DIALOG ( picker - > dialog ) ) ;
@ -380,11 +435,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
/* See if the selected account is a placeholder. */
if ( retval & & xaccAccountGetPlaceholder ( retval ) )
{
gnc_error_dialog
( GTK_WINDOW ( picker - > dialog ) ,
_ ( " The account %s is a placeholder account and does not allow "
" transactions. Please choose a different account. " ) ,
retval_name ) ;
show_placeholder_warning ( picker , retval_name ) ;
response = GNC_RESPONSE_NEW ;
break ;
}