Bug 798760 - SLR OK button to complete value entry

When in the SLR dialog and you are adding a value to a scheduled
transaction, if you do not complete the entry with a tab or enter but
press the 'OK' button the value changes back to 'Need Value'.

This change also completes the entry with the 'OK' button and will move
to the next value to be entered or if none complete the dialog.
This commit is contained in:
Robert Fewell 2023-11-15 15:52:59 +00:00
parent 16c1244a63
commit 5b8d29a7d0

View File

@ -72,6 +72,8 @@ struct _GncSxSinceLastRunDialog
GtkTreeView *instance_view;
GtkToggleButton *review_created_txns_toggle;
GList *created_txns;
GtkCellEditable *temp_ce; // used when editing values
};
/* ------------------------------------------------------------ */
@ -922,6 +924,8 @@ variable_value_changed_cb (GtkCellRendererText *cell,
DEBUG ("variable to [%s] at path [%s]", value, path);
dialog->temp_ce = NULL;
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(dialog->editing_model), &tree_iter, model_path))
{
gtk_tree_path_free (model_path);
@ -956,6 +960,21 @@ variable_value_changed_cb (GtkCellRendererText *cell,
gnc_sx_instance_model_set_variable (dialog->editing_model->instances, inst, var, &parsed_num);
}
static void
variable_value_start_changed_cb (GtkCellRenderer *renderer, GtkCellEditable *editable,
gchar *path, gpointer user_data)
{
GncSxSinceLastRunDialog *dialog = user_data;
dialog->temp_ce = editable;
}
static void
variable_value_cancel_changed_cb (GtkCellRenderer *renderer, gpointer user_data)
{
GncSxSinceLastRunDialog *dialog = user_data;
dialog->temp_ce = NULL;
}
static gint
_transaction_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, GtkTreeIter *iter_b, gpointer user_data)
{
@ -1064,11 +1083,25 @@ _status_sort_func (GtkTreeModel *model, GtkTreeIter *iter_a, GtkTreeIter *iter_b
return rtn;
}
static gboolean
finish_editing_before_ok_cb (GtkWidget *button, GdkEvent *event,
GncSxSinceLastRunDialog *dialog)
{
// finish editing
if (dialog->temp_ce)
gtk_cell_editable_editing_done (dialog->temp_ce);
dialog->temp_ce = NULL;
return FALSE;
}
GncSxSinceLastRunDialog*
gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_instances, GList *auto_created_txn_guids)
{
GncSxSinceLastRunDialog *dialog;
GtkBuilder *builder;
GtkWidget *ok_button;
dialog = g_new0 (GncSxSinceLastRunDialog, 1);
@ -1090,6 +1123,11 @@ gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_insta
dialog->created_txns = auto_created_txn_guids;
ok_button = GTK_WIDGET(gtk_builder_get_object (builder, "okbutton2"));
g_signal_connect (G_OBJECT(ok_button), "button-press-event",
G_CALLBACK(finish_editing_before_ok_cb), dialog);
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
@ -1163,6 +1201,17 @@ gnc_ui_sx_since_last_run_dialog (GtkWindow *parent, GncSxInstanceModel *sx_insta
"edited",
G_CALLBACK(variable_value_changed_cb),
dialog);
g_signal_connect (G_OBJECT(renderer),
"editing-started",
G_CALLBACK(variable_value_start_changed_cb),
dialog);
g_signal_connect (G_OBJECT(renderer),
"editing-canceled",
(GCallback)variable_value_cancel_changed_cb,
dialog);
col = gtk_tree_view_column_new_with_attributes (_("Value"), renderer,
"text", SLR_MODEL_COL_VARAIBLE_VALUE,
"visible", SLR_MODEL_COL_VARIABLE_VISIBILITY,