Change the Placeholder warning in the Account picker

When an account is selected it is checked for being a placeholder and
if it is a warning dialog was created. This was pointed out as being
disruptive so this change controls the sensitivity of the OK button and
displays a warning in the account picker dialog.
pull/507/head
Robert Fewell 7 years ago
parent ea0982eb33
commit e76ebf4c60

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.4 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkImage" id="account_new_icon">
@ -14,6 +14,9 @@
<property name="default_height">600</property>
<property name="type_hint">dialog</property>
<signal name="map" handler="gnc_ui_generic_account_picker_map_cb" swapped="no"/>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="account_picker_vbox">
<property name="visible">True</property>
@ -80,16 +83,43 @@
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
<object class="GtkBox" id="placeholder_warning_hbox">
<property name="can_focus">False</property>
<property name="margin_left">6</property>
<property name="margin_right">6</property>
<property name="margin_top">6</property>
<property name="spacing">6</property>
<child>
<object class="GtkImage" id="placeholder_warning_image">
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="stock">gtk-dialog-warning</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="placeholder_warning_label">
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
@ -165,7 +195,6 @@
<property name="page_increment">10</property>
</object>
<object class="GtkDialog" id="format_picker_dialog">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Choose a format</property>
<property name="resizable">False</property>
@ -173,6 +202,9 @@
<property name="default_width">600</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox16">
<property name="visible">True</property>
@ -301,6 +333,9 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Preferences</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkGrid" id="matcher_prefs">
<property name="visible">True</property>
@ -554,6 +589,9 @@
<property name="default_width">600</property>
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox14">
<property name="visible">True</property>
@ -726,6 +764,9 @@
<property name="resizable">False</property>
<property name="type_hint">dialog</property>
<signal name="close" handler="on_matcher_help_close_clicked" swapped="no"/>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox18">
<property name="visible">True</property>
@ -1119,9 +1160,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkCheckButton" id="show_source_account_button">
<property name="label" translatable="yes">Show the Source Account column</property>
@ -1145,6 +1183,9 @@
<property name="default_height">400</property>
<property name="type_hint">dialog</property>
<signal name="close" handler="on_matcher_cancel_clicked" swapped="no"/>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="transaction_matcher_vbox">
<property name="visible">True</property>

@ -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;
}

@ -40,6 +40,7 @@ typedef struct
GtkWidget *dialog; /* Dialog Widget */
GtkWidget *assistant; /* assistant Widget */
GtkWidget *new_button; /* new account button Widget */
GtkWidget *ok_button; /* ok button Widget */
GncTreeViewAccount *account_tree; /* Account tree */
GtkWidget *account_tree_sw; /* Scroll Window for Account tree */
gboolean auto_create; /* Auto create retAccount, can be used to step over this stage */
@ -50,6 +51,8 @@ typedef struct
GNCAccountType new_account_default_type; /* new account default type, incoming */
Account *default_account; /* default account for selection, incoming */
Account *retAccount; /* Account value returned to caller */
GtkWidget *pwhbox; /* Placeholder Warning HBox */
GtkWidget *pwarning; /* Placeholder Warning Label */
} AccountPickerDialog;
/** Must be called with a string containing a unique identifier for the

Loading…
Cancel
Save