Merge Bob Fewell's two bug fixes, PR302, into unstable.

This commit is contained in:
John Ralls 2018-03-10 13:12:54 -08:00
commit fc5dd9d2c8
2 changed files with 41 additions and 8 deletions

View File

@ -3812,13 +3812,11 @@ gtv_sr_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (widget);
GncTreeModelSplitReg *model;
GtkTreeViewColumn *col;
GtkTreePath *spath, *start_spath;
GtkTreePath *spath;
GtkTreePath *start_path, *end_path;
gboolean editing = FALSE;
gboolean step_off = FALSE;
gboolean trans_changed = FALSE;
gint *start_indices;
gint *next_indices;
Transaction *btrans, *ctrans, *hetrans;
gboolean goto_blank = FALSE;
gboolean next_trans = TRUE;
@ -4029,8 +4027,9 @@ gtv_sr_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
while (!editing && !step_off) // lets step over non editable columns
{
// Create a copy of the path we started with.
start_spath = gtk_tree_path_copy (spath);
start_indices = gtk_tree_path_get_indices (start_spath);
GtkTreePath *start_spath = gtk_tree_path_copy (spath);
gint *start_indices = gtk_tree_path_get_indices (start_spath);
gint *next_indices;
{
gchar *string = gtk_tree_path_to_string (start_spath);
@ -4077,6 +4076,7 @@ gtv_sr_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
// Test for transaction changed.
if (gtv_sr_transaction_changed (view))
{
gtk_tree_path_free (start_spath);
gtk_tree_path_free (spath);
return TRUE;
}
@ -4090,8 +4090,8 @@ gtv_sr_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
}
// Is this an editable cell ?
editing = gtv_sr_get_editing (col);
gtk_tree_path_free (start_spath);
}
gtk_tree_path_free (start_spath);
gtk_tree_path_free (spath);
return TRUE;
break;

View File

@ -887,6 +887,34 @@ placeholder_cell_data_func (GtkTreeViewColumn *tree_column,
gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(cell), willbe_placeholder);
}
static void
placeholder_cell_toggled (GtkCellRendererToggle *cell_renderer,
gchar *path, gpointer user_data)
{
gboolean state;
Account *account;
GtkTreePath *treepath;
hierarchy_data *data = (hierarchy_data *)user_data;
g_return_if_fail(data != NULL);
treepath = gtk_tree_path_new_from_string (path);
account = gnc_tree_view_account_get_account_from_path (data->final_account_tree, treepath);
state = gtk_cell_renderer_toggle_get_active (cell_renderer);
if (account)
xaccAccountSetPlaceholder (account, !state);
// if placeholder set, set balance to zero
if (!state)
{
set_final_balance (data->balance_hash, account, gnc_numeric_zero());
qof_event_gen (QOF_INSTANCE(account), QOF_EVENT_MODIFY, NULL);
}
gtk_tree_path_free (treepath);
}
static void
use_existing_account_data_func(GtkTreeViewColumn *tree_column,
@ -985,9 +1013,14 @@ on_final_account_prepare (hierarchy_data *data)
{
renderer = gtk_cell_renderer_toggle_new();
g_object_set(G_OBJECT (renderer),
"activatable", FALSE,
"sensitive", FALSE,
"activatable", TRUE,
"sensitive", TRUE,
NULL);
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK (placeholder_cell_toggled),
data);
column = gtk_tree_view_column_new_with_attributes(_("Placeholder"),
renderer, NULL);
gtk_tree_view_column_set_cell_data_func (column, renderer,