mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-01 21:19:16 -06:00
Bug 673193 - Possible Register migration to TreeView
Another update fixing a crash on Windows and Geert's Fedora system git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22541 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
827eb333c3
commit
7915166d53
@ -45,6 +45,13 @@
|
||||
|
||||
#define TREE_MODEL_SPLIT_REG_CM_CLASS "tree-model-split-reg"
|
||||
|
||||
/* Signal codes */
|
||||
enum
|
||||
{
|
||||
REFRESH_SIGNAL,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
/** Static Globals *******************************************************/
|
||||
static QofLogModule log_module = GNC_MOD_GUI;
|
||||
|
||||
@ -54,6 +61,8 @@ static void gnc_tree_model_split_reg_init (GncTreeModelSplitReg *model);
|
||||
static void gnc_tree_model_split_reg_finalize (GObject *object);
|
||||
static void gnc_tree_model_split_reg_dispose (GObject *object);
|
||||
|
||||
static guint gnc_tree_model_split_reg_signals[LAST_SIGNAL] = {0};
|
||||
|
||||
static const gchar *iter_to_string (GtkTreeIter *iter);
|
||||
|
||||
/** Implementation of GtkTreeModel **************************************/
|
||||
@ -261,6 +270,18 @@ gnc_tree_model_split_reg_class_init (GncTreeModelSplitRegClass *klass)
|
||||
/* GObject signals */
|
||||
o_class->finalize = gnc_tree_model_split_reg_finalize;
|
||||
o_class->dispose = gnc_tree_model_split_reg_dispose;
|
||||
|
||||
gnc_tree_model_split_reg_signals[REFRESH_SIGNAL] =
|
||||
g_signal_new("refresh_signal",
|
||||
G_TYPE_FROM_CLASS (o_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GncTreeModelSplitRegClass, refresh_signal),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
klass->refresh_signal = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -539,7 +560,7 @@ gnc_tree_model_split_reg_set_data (GncTreeModelSplitReg *model, gpointer user_da
|
||||
SRGetParentCallback2 get_parent)
|
||||
{
|
||||
GncTreeModelSplitRegPrivate *priv;
|
||||
g_print("gnc_tree_model_split_reg_set_data\n");
|
||||
g_print("gnc_tree_model_split_reg_set_data user_data %p\n", user_data);
|
||||
/*FIXME Not sure if this is needed or what it is for */
|
||||
priv = model->priv;
|
||||
|
||||
@ -579,7 +600,6 @@ get_account_split (GncTreeModelSplitReg *model, Transaction *trans)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************/
|
||||
/* Gnc Tree Model Debugging Utility Function */
|
||||
/************************************************************/
|
||||
@ -976,10 +996,10 @@ gnc_tree_model_split_reg_get_value (GtkTreeModel *tree_model,
|
||||
/* Initializes and sets value to that at column. When done with value,
|
||||
g_value_unset() needs to be called to free any allocated memory. */
|
||||
GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
|
||||
GtkTreePath *path;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
const GncGUID *guid;
|
||||
GList *tnode, *snode;
|
||||
GList *tnode;
|
||||
gint depth, *indices;
|
||||
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model));
|
||||
@ -989,12 +1009,11 @@ gnc_tree_model_split_reg_get_value (GtkTreeModel *tree_model,
|
||||
tnode = (GList *) iter->user_data2;
|
||||
trans = (Transaction *) tnode->data;
|
||||
|
||||
snode = (GList *) iter->user_data3;
|
||||
split = (Split *) snode->data;
|
||||
g_value_init (value, gnc_tree_model_split_reg_get_column_type (tree_model, column));
|
||||
|
||||
g_value_init(value, gnc_tree_model_split_reg_get_column_type (tree_model, column));
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
|
||||
|
||||
indices = gtk_tree_path_get_indices (gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter));
|
||||
indices = gtk_tree_path_get_indices (path);
|
||||
|
||||
switch (column)
|
||||
{
|
||||
@ -1033,6 +1052,7 @@ gnc_tree_model_split_reg_get_value (GtkTreeModel *tree_model,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
@ -1636,10 +1656,11 @@ update_parent (GncTreeModelSplitReg *model, GtkTreePath *path)
|
||||
/* If this is the blank transaction, the only split will be deleteted, hence toggle has child */
|
||||
if (IS_BLANK_TRANS (&iter) && (tnode->data == model->priv->btrans) && (xaccTransCountSplits (model->priv->btrans) == 0))
|
||||
{
|
||||
increment_stamp (model);
|
||||
|
||||
PINFO("toggling has_child at row %s\n", gtk_tree_path_to_string (path));
|
||||
gchar *path_string = gtk_tree_path_to_string (path);
|
||||
PINFO("toggling has_child at row %s\n", path_string);
|
||||
g_free (path_string);
|
||||
|
||||
increment_stamp (model);
|
||||
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
|
||||
}
|
||||
}
|
||||
@ -1751,17 +1772,18 @@ insert_trans (GncTreeModelSplitReg *model, Transaction *trans)
|
||||
//g_print("insert_trans %p\n", trans);
|
||||
model->priv->tlist = g_list_prepend (model->priv->tlist, trans);
|
||||
tnode = g_list_find (model->priv->tlist, trans);
|
||||
|
||||
iter = make_iter (model, TROW1, tnode, NULL);
|
||||
insert_row_at (model, &iter);
|
||||
|
||||
path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
iter = make_iter (model, TROW2, tnode, NULL);
|
||||
insert_row_at (model, &iter);
|
||||
|
||||
path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
//g_print("insert count splits %p %d\n", trans, xaccTransCountSplits (trans));
|
||||
|
||||
@ -1781,7 +1803,6 @@ delete_trans (GncTreeModelSplitReg *model, Transaction *trans)
|
||||
GtkTreeIter iter;
|
||||
GList *tnode = NULL, *snode = NULL;
|
||||
//g_print("delete_trans %p\n", trans);
|
||||
|
||||
tnode = g_list_find (model->priv->tlist, trans);
|
||||
//g_print("tlist length is %d\n", g_list_length (model->priv->tlist));
|
||||
|
||||
@ -2335,7 +2356,8 @@ gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model)
|
||||
GtkTreeIter iter;
|
||||
GList *accts, *ptr;
|
||||
gboolean valid;
|
||||
const gchar *name, *fname;
|
||||
const gchar *name;
|
||||
gchar *fname;
|
||||
gint i;
|
||||
|
||||
priv = model->priv;
|
||||
@ -2357,6 +2379,7 @@ gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model)
|
||||
name = xaccAccountGetName (acc);
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, name, 1, fname, 2, acc, -1);
|
||||
g_free (fname);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2437,6 +2460,17 @@ gnc_tree_model_split_reg_event_handler (QofInstance *entity,
|
||||
//g_print("--Change model %p split %p\n", model, split); //works
|
||||
DEBUG ("change split %p (%s)", split, name);
|
||||
changed_row_at (model, &iter1);
|
||||
|
||||
/* If we change split to different account, remove from view */
|
||||
if (priv->anchor != NULL)
|
||||
{
|
||||
Split *find_split;
|
||||
Transaction *trans;
|
||||
trans = xaccSplitGetParent (split);
|
||||
find_split = xaccTransFindSplitByAccount (trans, priv->anchor);
|
||||
if (find_split == NULL)
|
||||
delete_trans (model, trans);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -2511,6 +2545,7 @@ gnc_tree_model_split_reg_event_handler (QofInstance *entity,
|
||||
DEBUG ("change trans %p (%s)", trans, name);
|
||||
changed_row_at (model, &iter1);
|
||||
changed_row_at (model, &iter2);
|
||||
g_signal_emit_by_name (model, "refresh_signal", NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -2530,8 +2565,9 @@ g_print("--Change blank trans %p\n",priv->btrans); // Not sure this is ever used
|
||||
else if (get_iter (model, trans, NULL, &iter1, &iter2))
|
||||
{
|
||||
//g_print("--Delete model %p trans %p\n", model, trans); //works
|
||||
delete_trans (model, trans);
|
||||
DEBUG("destroy trans %p (%s)", trans, name);
|
||||
delete_trans (model, trans);
|
||||
g_signal_emit_by_name (model, "refresh_signal", NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -2553,7 +2589,9 @@ g_print("--Change blank trans %p\n",priv->btrans); // Not sure this is ever used
|
||||
priv->include_subacc) || acc == priv->anchor))
|
||||
{
|
||||
//g_print("--Insert model %p trans %p\n", model, trans); //works
|
||||
DEBUG("Insert trans %p (%s)", trans, name);
|
||||
insert_trans (model, trans);
|
||||
g_signal_emit_by_name (model, "refresh_signal", NULL);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -137,6 +137,10 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
GncTreeModelClass gnc_tree_model; /**< The parent object data. */
|
||||
|
||||
/* This signal is emitted to refresh the view */
|
||||
void (*refresh_signal) (GncTreeModelSplitReg *model, gpointer user_data);
|
||||
|
||||
} GncTreeModelSplitRegClass;
|
||||
|
||||
/** Callback function type */
|
||||
|
@ -737,8 +737,9 @@ gnc_tree_view_split_reg_default_selection (GncTreeViewSplitReg *view)
|
||||
{
|
||||
GncTreeModelSplitReg *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreePath *path, *path_temp;
|
||||
gint *indices;
|
||||
gint top_row;
|
||||
|
||||
model = get_split_reg_model_from_view (view);
|
||||
|
||||
@ -746,15 +747,23 @@ gnc_tree_view_split_reg_default_selection (GncTreeViewSplitReg *view)
|
||||
|
||||
/* Set the default start position to end of list */
|
||||
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, view->priv->current_path))
|
||||
{
|
||||
indices = gtk_tree_path_get_indices (view->priv->current_path);
|
||||
top_row = indices[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* both values NULL will return last in list */
|
||||
indices = gtk_tree_path_get_indices (gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL));
|
||||
path_temp = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
|
||||
indices = gtk_tree_path_get_indices (path_temp);
|
||||
top_row = indices[0]; // we do this because freeing the path screws the indices
|
||||
gtk_tree_path_free (path_temp);
|
||||
}
|
||||
|
||||
path = gtk_tree_path_new_from_indices (indices[0], -1);
|
||||
path = gtk_tree_path_new_from_indices (top_row, -1);
|
||||
|
||||
g_print(" gnc_tree_view_split_reg_default_selection current_path is %s, new path is %s\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
gtk_tree_path_to_string (path));
|
||||
//g_print("gnc_tree_view_split_reg_default_selection current_path is %s, new path is %s\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
// gtk_tree_path_to_string (path));
|
||||
|
||||
gtk_tree_path_free (view->priv->current_path);
|
||||
view->priv->current_path = gtk_tree_path_copy (path);
|
||||
@ -785,8 +794,8 @@ static gboolean
|
||||
needs_exchange_rate (GncTreeViewSplitReg *view, Transaction *trans, Split *split)
|
||||
{
|
||||
gnc_commodity *split_com, *txn_curr, *reg_com;
|
||||
g_print("needs_exchange_rate - 'always FALSE at the moment' - trans %p and split %p\n", trans, split);
|
||||
if (view->priv->has_rate) return FALSE;
|
||||
g_print("needs_exchange_rate - trans %p and split %p\n", trans, split);
|
||||
// if (view->priv->has_rate) return FALSE;
|
||||
|
||||
txn_curr = xaccTransGetCurrency (trans);
|
||||
split_com = xaccAccountGetCommodity (xaccSplitGetAccount (split));
|
||||
@ -815,9 +824,11 @@ handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Transaction
|
||||
XferDialog *xfer;
|
||||
gboolean rate_split_ok, rate_reg_ok;
|
||||
gnc_numeric rate_split, rate_reg, value;
|
||||
Account *reg_acc = view->priv->anchor;
|
||||
gnc_commodity *xfer_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
|
||||
gnc_commodity *reg_comm = view->priv->reg_comm;
|
||||
gnc_commodity *trans_curr = xaccTransGetCurrency (trans);
|
||||
gboolean expanded;
|
||||
|
||||
g_print("handle_exchange_rate trans %p and split %p\n", trans, split);
|
||||
|
||||
@ -825,7 +836,10 @@ g_print("handle_exchange_rate trans %p and split %p\n", trans, split);
|
||||
rate_split_ok = xaccTransGetRateForCommodity (trans, xfer_comm, split, &rate_split);
|
||||
|
||||
/* Rate from trans-curr to reg-comm */
|
||||
rate_reg_ok = xaccTransGetRateForCommodity(trans, reg_comm, split, &rate_reg);
|
||||
rate_reg_ok = xaccTransGetRateForCommodity (trans, reg_comm, split, &rate_reg);
|
||||
|
||||
/* Are we expnded */
|
||||
expanded = gnc_tree_view_split_reg_current_trans_expanded (view);
|
||||
|
||||
if (rate_reg_ok && rate_split_ok)
|
||||
{
|
||||
@ -838,7 +852,7 @@ g_print("handle_exchange_rate trans %p and split %p\n", trans, split);
|
||||
|
||||
//g_message("reg amt: %s", gnc_numeric_to_string(amount));
|
||||
/* create the exchange-rate dialog */
|
||||
xfer = gnc_xfer_dialog (NULL, NULL); //FIXME: get parent window
|
||||
xfer = gnc_xfer_dialog (NULL, NULL);
|
||||
gnc_xfer_dialog_is_exchange_dialog (xfer, &rate_split);
|
||||
|
||||
/* fill in the dialog entries */
|
||||
@ -848,9 +862,9 @@ g_print("handle_exchange_rate trans %p and split %p\n", trans, split);
|
||||
gnc_xfer_dialog_set_date (xfer, timespecToTime_t (xaccTransRetDatePostedTS (trans)));
|
||||
|
||||
value = amount;
|
||||
/*FIXME if (gnc_xfer_dialog_run_exchange_dialog(
|
||||
xfer, &rate_split, &value, reg_comm, trans, xfer_comm))
|
||||
return FALSE; */
|
||||
if (gnc_xfer_dialog_run_exchange_dialog (
|
||||
xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
|
||||
return FALSE;
|
||||
amount = gnc_numeric_mul (value, rate_split, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
}
|
||||
xaccSplitSetAmount (split, amount);
|
||||
@ -994,10 +1008,10 @@ get_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gboo
|
||||
{
|
||||
if (!gnc_numeric_zero_p (total) && gnc_numeric_check (total) == GNC_ERROR_OK)
|
||||
{
|
||||
/* fixme: if needs conversion? */
|
||||
/* if needs conversion? */
|
||||
gnc_commodity *commodity = view->priv->reg_comm;
|
||||
/*FIXME ?? if (commodity && !gnc_commodity_equiv(commodity, currency))
|
||||
total = xaccSplitConvertAmount(split, commodity); */
|
||||
if (commodity && !gnc_commodity_equiv (commodity, currency))
|
||||
total = xaccSplitConvertAmount (split, view->priv->anchor);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
@ -1026,12 +1040,12 @@ get_rate_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gbool
|
||||
{
|
||||
gnc_numeric num;
|
||||
|
||||
g_print("get_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
|
||||
//g_print("get_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
|
||||
|
||||
num = get_value_for (view, trans, split, is_blank);
|
||||
g_print("get_rate_for get_value_for is %s\n", gnc_numeric_to_string (num));
|
||||
//g_print("get_rate_for get_value_for is %s\n", gnc_numeric_to_string (num));
|
||||
num = gnc_numeric_div ( xaccSplitGetAmount (split), num, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
g_print("get_rate_for return is %s\n", gnc_numeric_to_string (num));
|
||||
//g_print("get_rate_for return is %s\n", gnc_numeric_to_string (num));
|
||||
return num;
|
||||
}
|
||||
|
||||
@ -1044,11 +1058,12 @@ set_rate_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_n
|
||||
gnc_numeric old_rate = get_rate_for (view, trans, split, is_blank);
|
||||
gnc_numeric factor = gnc_numeric_div (input, old_rate, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
split_comm = xaccAccountGetCommodity (xaccSplitGetAccount (split));
|
||||
/*FIXME xaccTransAdjustRateForCommodity(trans, split_comm, factor); */
|
||||
/*FIXME xaccTransAdjustRateForCommodity (trans, split_comm, factor); */
|
||||
|
||||
g_print("set_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
|
||||
//g_print("set_rate_for trans %p and split %p is_blank %d\n", trans, split, is_blank);
|
||||
|
||||
#if JUNK
|
||||
// This is from original
|
||||
reg_comm = view->priv->reg_comm;
|
||||
if (xaccTransGetRateForCommodity (trans, reg_comm, split, ®_rate))
|
||||
{
|
||||
@ -1166,7 +1181,6 @@ g_print("get_split_pair return - trans is %p, osplit is %p and split %p is set t
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* poor name: really means: If this is the blank split, it may now
|
||||
eventually graduate to a real split. The trans must already be
|
||||
opened for editing because the split will be added to the
|
||||
@ -1229,7 +1243,7 @@ get_imbalance (Transaction *trans)
|
||||
|
||||
|
||||
static gboolean
|
||||
get_model_iter_from_view_string(GncTreeViewSplitReg *view,
|
||||
get_model_iter_from_view_string (GncTreeViewSplitReg *view,
|
||||
const gchar *path_string, GtkTreeIter *iter)
|
||||
{
|
||||
GtkTreeModelSort *s_model;
|
||||
@ -1263,7 +1277,6 @@ get_model_iter_from_selection (GncTreeViewSplitReg *view,
|
||||
}
|
||||
|
||||
|
||||
/* Returns TRUE is we have an Account on row */
|
||||
static gboolean
|
||||
gtv_have_account (GncTreeViewSplitReg *view, RowDepth depth, gboolean expanded, Transaction *trans, Split *split)
|
||||
{
|
||||
@ -1298,7 +1311,7 @@ cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
|
||||
GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
|
||||
GncTreeModelSplitReg *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path;
|
||||
GtkTreePath *path, *temp_path;
|
||||
ViewCol viewcol;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
@ -1323,12 +1336,18 @@ cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
|
||||
|
||||
viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
|
||||
|
||||
g_return_if_fail (gnc_tree_model_split_reg_get_split_and_trans(
|
||||
GNC_TREE_MODEL_SPLIT_REG(model), &iter,
|
||||
g_return_if_fail (gnc_tree_model_split_reg_get_split_and_trans (
|
||||
GNC_TREE_MODEL_SPLIT_REG (model), &iter,
|
||||
&is_trow1, &is_trow2, &is_split, &is_blank,
|
||||
&split, &trans));
|
||||
|
||||
depth = gtk_tree_path_get_depth (gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter));
|
||||
temp_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
|
||||
depth = gtk_tree_path_get_depth (temp_path);
|
||||
|
||||
indices = gtk_tree_path_get_indices (temp_path);
|
||||
|
||||
gtk_tree_path_free (temp_path);
|
||||
|
||||
// g_print("cdf split %p, trans %p, is_trow1 = %d, is_trow2 = %d, is_split = %d, is_blank = %d\n",
|
||||
// split, trans, is_trow1, is_trow2, is_split, is_blank);
|
||||
@ -1338,7 +1357,9 @@ cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
|
||||
/* Get the read only model setting */
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, GNC_TREE_MODEL_SPLIT_REG_COL_RO, &read_only, -1);
|
||||
|
||||
indices = gtk_tree_path_get_indices (gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter));
|
||||
/* Voided Transaction. */
|
||||
if (xaccTransHasSplitsInState (trans, VREC))
|
||||
read_only = TRUE;
|
||||
|
||||
//g_print(" cdf path is %s\n", gtk_tree_path_to_string (gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter)));
|
||||
|
||||
@ -1357,7 +1378,7 @@ cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
|
||||
case COL_DATE:
|
||||
/* Column is DATE */
|
||||
if (is_split)
|
||||
g_object_set(cell, "cell-background", "white", (gchar*)NULL);
|
||||
g_object_set (cell, "cell-background", "white", (gchar*)NULL);
|
||||
|
||||
if (is_trow1) {
|
||||
Timespec ts = {0,0};
|
||||
@ -1629,6 +1650,7 @@ cdf (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_model,
|
||||
s = xaccPrintAmount (num, gnc_split_amount_print_info (split, FALSE));
|
||||
editable = !gnc_numeric_zero_p (num) &&
|
||||
gnc_commodity_equiv (split_com, view->priv->reg_comm);
|
||||
g_print("zero %d and equiv %d\n", gnc_numeric_zero_p (num), gnc_commodity_equiv (split_com, view->priv->reg_comm));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1924,6 +1946,14 @@ g_print("begin_edit - blank split, return\n");
|
||||
|
||||
g_print("begin_edit - xaccTransBeginEdit trans %p\n", trans);
|
||||
|
||||
if (!xaccTransGetCurrency (trans))
|
||||
{
|
||||
if (view->priv->anchor)
|
||||
xaccTransSetCurrency (trans, view->priv->reg_comm);
|
||||
else
|
||||
xaccTransSetCurrency (trans, xaccAccountGetCommodity (xaccSplitGetAccount (split)));
|
||||
}
|
||||
|
||||
if (ts.tv_sec == 0)
|
||||
{
|
||||
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
||||
@ -2320,6 +2350,10 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
break;
|
||||
|
||||
case ASSET_REGISTER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Decrease"));
|
||||
break;
|
||||
|
||||
case LIABILITY_REGISTER2:
|
||||
case EQUITY_REGISTER2:
|
||||
case TRADING_REGISTER2:
|
||||
@ -2344,6 +2378,7 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
break;
|
||||
|
||||
case STOCK_REGISTER2:
|
||||
case CURRENCY_REGISTER2:
|
||||
case PORTFOLIO_LEDGER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Sell"));
|
||||
@ -2386,10 +2421,14 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
|
||||
case CASH_REGISTER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Recieve"));
|
||||
gtk_tree_view_column_set_title (tvc, _("Receive"));
|
||||
break;
|
||||
|
||||
case ASSET_REGISTER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Increase"));
|
||||
break;
|
||||
|
||||
case LIABILITY_REGISTER2:
|
||||
case EQUITY_REGISTER2:
|
||||
case TRADING_REGISTER2:
|
||||
@ -2397,11 +2436,6 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
gtk_tree_view_column_set_title (tvc, _("Decrease"));
|
||||
break;
|
||||
|
||||
case CREDIT_REGISTER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Payment"));
|
||||
break;
|
||||
|
||||
case INCOME_REGISTER2:
|
||||
case INCOME_LEDGER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
@ -2414,6 +2448,7 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
break;
|
||||
|
||||
case STOCK_REGISTER2:
|
||||
case CURRENCY_REGISTER2:
|
||||
case PORTFOLIO_LEDGER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Buy"));
|
||||
@ -2424,6 +2459,7 @@ gtv_split_reg_titles (GncTreeViewSplitReg *view, RowDepth depth)
|
||||
gtk_tree_view_column_set_title (tvc, _("Invoice"));
|
||||
break;
|
||||
|
||||
case CREDIT_REGISTER2:
|
||||
case PAYABLE_REGISTER2:
|
||||
if(depth == TRANS1 || depth == TRANS2 || depth == SPLIT3)
|
||||
gtk_tree_view_column_set_title (tvc, _("Payment"));
|
||||
@ -2779,8 +2815,8 @@ if (tabbed == TRUE)
|
||||
|
||||
g_object_get (G_OBJECT (cell), "editable", &editable, NULL);
|
||||
|
||||
g_print("key nav - Path is '%s' edit path is '%s' and viewcol is %d and editable is %d and cell pointer is %p\n", gtk_tree_path_to_string (path),
|
||||
(view->priv->acct_edit_path == NULL) ? "NULL" : gtk_tree_path_to_string (view->priv->acct_edit_path), viewcol, editable, cell);
|
||||
//g_print("key nav - Path is '%s' edit path is '%s' and viewcol is %d and editable is %d and cell pointer is %p\n", gtk_tree_path_to_string (path),
|
||||
// (view->priv->acct_edit_path == NULL) ? "NULL" : gtk_tree_path_to_string (view->priv->acct_edit_path), viewcol, editable, cell);
|
||||
|
||||
|
||||
|
||||
@ -2935,9 +2971,9 @@ g_print("Motion - dirty_trans is %p and dirty_split is %p\n", view->priv->dirty_
|
||||
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
|
||||
|
||||
g_print("Motion - Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
(view->priv->acct_edit_path == NULL) ? "NULL" :
|
||||
gtk_tree_path_to_string (view->priv->acct_edit_path));
|
||||
//g_print("Motion - Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
// (view->priv->acct_edit_path == NULL) ? "NULL" :
|
||||
// gtk_tree_path_to_string (view->priv->acct_edit_path));
|
||||
|
||||
indices_old = gtk_tree_path_get_indices (view->priv->current_path);
|
||||
indices_now = gtk_tree_path_get_indices (path);
|
||||
@ -2962,9 +2998,9 @@ g_print ("Motion - row old is %d and now %d\n", row_old, row_now);
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
g_print("Motion - New Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
(view->priv->acct_edit_path == NULL) ? "NULL" :
|
||||
gtk_tree_path_to_string (view->priv->acct_edit_path));
|
||||
//g_print("Motion - New Current Path is '%s' and edit path is '%s'\n", gtk_tree_path_to_string (view->priv->current_path),
|
||||
// (view->priv->acct_edit_path == NULL) ? "NULL" :
|
||||
// gtk_tree_path_to_string (view->priv->acct_edit_path));
|
||||
|
||||
|
||||
/*FIXME Not sure if will need this here, leave till end */
|
||||
@ -3110,6 +3146,7 @@ g_print("gtv_split_reg_edited_cb New Text is '%s'\n", new_text);
|
||||
Account *root; // do we have this
|
||||
Account *new_acct;
|
||||
gint num_of_splits;
|
||||
gnc_numeric num;
|
||||
|
||||
begin_edit (view, split, trans);
|
||||
|
||||
@ -3129,6 +3166,8 @@ g_print("gtv_split_reg_edited_cb New Text is '%s'\n", new_text);
|
||||
|
||||
num_of_splits = xaccTransCountSplits (trans);
|
||||
|
||||
g_print("num_of_splits is %d\n", num_of_splits);
|
||||
|
||||
if (view->priv->acct_short_names)
|
||||
new_acct = gnc_account_lookup_by_name (root, new_text);
|
||||
else
|
||||
@ -3141,6 +3180,13 @@ g_print("gtv_split_reg_edited_cb New Text is '%s'\n", new_text);
|
||||
|
||||
mark_split_dirty (view, trans, split);
|
||||
|
||||
num = get_value_for (view, trans, split, is_blank);
|
||||
|
||||
g_print("number is %s\n", gnc_numeric_to_string (num));
|
||||
|
||||
if (!gnc_numeric_zero_p (num))
|
||||
set_value_for (view, trans, split, num);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3171,6 +3217,7 @@ g_print("gtv_split_reg_edited_cb New Text is '%s'\n", new_text);
|
||||
break;
|
||||
|
||||
case COL_TYPE:
|
||||
|
||||
break;
|
||||
|
||||
case COL_VALUE:
|
||||
@ -3224,7 +3271,6 @@ g_print("rest3\n");
|
||||
input = gnc_numeric_neg (input);
|
||||
|
||||
//FIXME
|
||||
#ifdef skip
|
||||
if (viewcol == COL_AMOUNT)
|
||||
{
|
||||
set_amount_for (view, trans, split, input);
|
||||
@ -3238,6 +3284,7 @@ g_print("rest3\n");
|
||||
}
|
||||
//FIXME
|
||||
|
||||
|
||||
if ((viewcol == COL_AMTVAL) && is_split)
|
||||
{
|
||||
set_amount_for (view, trans, split, input);
|
||||
@ -3250,7 +3297,7 @@ g_print("rest3\n");
|
||||
break;
|
||||
}
|
||||
//End FIXME
|
||||
#endif
|
||||
|
||||
set_value_for (view, trans, split, input);
|
||||
|
||||
if (osplit)
|
||||
@ -3605,6 +3652,69 @@ g_print("gtv_split_reg_editing_canceled_cb\n\n");
|
||||
^^^^ gtv function call backs ^^^^
|
||||
#####################################################################*/
|
||||
|
||||
void
|
||||
gnc_tree_view_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason)
|
||||
{
|
||||
Transaction *trans;
|
||||
Split *blank_split;
|
||||
Split *split;
|
||||
|
||||
if (!view) return;
|
||||
|
||||
blank_split = gnc_tree_view_split_reg_get_blank_split (view);
|
||||
|
||||
/* get the current split based on cursor position */
|
||||
split = gnc_tree_view_split_reg_get_current_split (view);
|
||||
if (split == NULL)
|
||||
return;
|
||||
|
||||
/* Bail if trying to void the blank split. */
|
||||
if (split == blank_split)
|
||||
return;
|
||||
|
||||
/* already voided. */
|
||||
if (xaccSplitGetReconcile (split) == VREC)
|
||||
return;
|
||||
|
||||
trans = xaccSplitGetParent (split);
|
||||
xaccTransVoid (trans, reason);
|
||||
|
||||
if (xaccTransIsOpen (trans))
|
||||
{
|
||||
PERR("We should not be voiding an open transaction.");
|
||||
xaccTransCommitEdit (trans);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_tree_view_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view)
|
||||
{
|
||||
Transaction *trans;
|
||||
Split *blank_split;
|
||||
Split *split;
|
||||
|
||||
if (!view) return;
|
||||
|
||||
blank_split = gnc_tree_view_split_reg_get_blank_split (view);
|
||||
|
||||
/* get the current split based on cursor position */
|
||||
split = gnc_tree_view_split_reg_get_current_split (view);
|
||||
if (split == NULL)
|
||||
return;
|
||||
|
||||
/* Bail if trying to unvoid the blank split. */
|
||||
if (split == blank_split)
|
||||
return;
|
||||
|
||||
/* not voided. */
|
||||
if (xaccSplitGetReconcile (split) != VREC)
|
||||
return;
|
||||
|
||||
trans = xaccSplitGetParent (split);
|
||||
|
||||
xaccTransUnvoid (trans);
|
||||
}
|
||||
|
||||
|
||||
/* Reinit transaction / delete the splits */
|
||||
|
@ -123,6 +123,10 @@ void gnc_tree_view_split_reg_expand_current_trans (GncTreeViewSplitReg *view, gb
|
||||
|
||||
void gnc_tree_view_split_reg_moved_cb (GncTreeViewSplitReg *view, GFunc cb, gpointer cb_data);
|
||||
|
||||
void gnc_tree_view_split_reg_void_current_trans (GncTreeViewSplitReg *view, const char *reason);
|
||||
|
||||
void gnc_tree_view_split_reg_unvoid_current_trans (GncTreeViewSplitReg *view);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_TREE_VIEW_SPLIT_REG_H */
|
||||
|
@ -2701,11 +2701,11 @@ gnc_plugin_page_register2_cmd_paste_transaction (GtkAction *action,
|
||||
|
||||
static void
|
||||
gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
|
||||
GncPluginPageRegister2 *page)
|
||||
GncPluginPageRegister2 *page) //this works
|
||||
{
|
||||
GncPluginPageRegister2Private *priv;
|
||||
GtkWidget *dialog, *entry;
|
||||
SplitRegister *reg;
|
||||
GncTreeViewSplitReg *view;
|
||||
Transaction *trans;
|
||||
GtkBuilder *builder;
|
||||
const char *reason;
|
||||
@ -2713,62 +2713,62 @@ gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
|
||||
|
||||
ENTER("(action %p, page %p)", action, page);
|
||||
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
|
||||
g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
|
||||
reg = gnc_ledger_display2_get_split_register(priv->ledger);
|
||||
trans = gnc_split_register_get_current_trans(reg);
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
|
||||
view = gnc_ledger_display2_get_split_view_register (priv->ledger);
|
||||
trans = gnc_tree_view_split_reg_get_current_trans (view);
|
||||
if (trans == NULL)
|
||||
return;
|
||||
if (xaccTransHasSplitsInState(trans, VREC))
|
||||
if (xaccTransHasSplitsInState (trans, VREC))
|
||||
return;
|
||||
if (xaccTransHasReconciledSplits(trans) || xaccTransHasSplitsInState(trans, CREC))
|
||||
if (xaccTransHasReconciledSplits (trans) || xaccTransHasSplitsInState (trans, CREC))
|
||||
{
|
||||
gnc_error_dialog(NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits."));
|
||||
gnc_error_dialog (NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gnc_plugin_page_register2_finish_pending(GNC_PLUGIN_PAGE(page)))
|
||||
if (!gnc_plugin_page_register2_finish_pending (GNC_PLUGIN_PAGE (page)))
|
||||
return;
|
||||
|
||||
builder = gtk_builder_new();
|
||||
gnc_builder_add_from_file (builder , "gnc-plugin-page-register2.glade", "Void Transaction");
|
||||
dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Void Transaction"));
|
||||
entry = GTK_WIDGET(gtk_builder_get_object (builder, "reason"));
|
||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Void Transaction"));
|
||||
entry = GTK_WIDGET (gtk_builder_get_object (builder, "reason"));
|
||||
|
||||
result = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
result = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
if (result == GTK_RESPONSE_OK)
|
||||
{
|
||||
reason = gtk_entry_get_text(GTK_ENTRY(entry));
|
||||
reason = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (reason == NULL)
|
||||
reason = "";
|
||||
gnc_split_register_void_current_trans(reg, reason);
|
||||
gnc_tree_view_split_reg_void_current_trans (view, reason);
|
||||
}
|
||||
|
||||
/* All done. Get rid of it. */
|
||||
gtk_widget_destroy(dialog);
|
||||
g_object_unref(G_OBJECT(builder));
|
||||
gtk_widget_destroy (dialog);
|
||||
g_object_unref (G_OBJECT(builder));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_plugin_page_register2_cmd_unvoid_transaction (GtkAction *action,
|
||||
GncPluginPageRegister2 *page)
|
||||
GncPluginPageRegister2 *page) //this works
|
||||
{
|
||||
GncPluginPageRegister2Private *priv;
|
||||
SplitRegister *reg;
|
||||
GncTreeViewSplitReg *view;
|
||||
Transaction *trans;
|
||||
|
||||
ENTER("(action %p, page %p)", action, page);
|
||||
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
|
||||
g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
|
||||
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
|
||||
reg = gnc_ledger_display2_get_split_register(priv->ledger);
|
||||
trans = gnc_split_register_get_current_trans(reg);
|
||||
if (!xaccTransHasSplitsInState(trans, VREC))
|
||||
priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
|
||||
view = gnc_ledger_display2_get_split_view_register (priv->ledger);
|
||||
trans = gnc_tree_view_split_reg_get_current_trans (view);
|
||||
if (!xaccTransHasSplitsInState (trans, VREC))
|
||||
return;
|
||||
gnc_split_register_unvoid_current_trans(reg);
|
||||
gnc_tree_view_split_reg_unvoid_current_trans (view);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,8 @@ gnc_ledger_display2_internal (Account *lead_account, Query *q,
|
||||
|
||||
static void gnc_ledger_display2_refresh_internal (GNCLedgerDisplay2 *ld, GList *splits);
|
||||
|
||||
static void gnc_ledger_display2_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data);
|
||||
|
||||
|
||||
/** Implementations *************************************************/
|
||||
|
||||
@ -612,7 +614,7 @@ refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
*/
|
||||
splits = qof_query_run (ld->query);
|
||||
|
||||
gnc_ledger_display2_set_watches (ld, splits);
|
||||
// gnc_ledger_display2_set_watches (ld, splits);
|
||||
|
||||
gnc_ledger_display2_refresh_internal (ld, splits);
|
||||
LEAVE(" ");
|
||||
@ -820,9 +822,12 @@ gnc_ledger_display2_internal (Account *lead_account, Query *q,
|
||||
|
||||
gnc_tree_model_split_reg_set_data (ld->model, ld, gnc_ledger_display2_parent);
|
||||
|
||||
g_signal_connect (G_OBJECT (ld->model), "refresh_signal",
|
||||
G_CALLBACK ( gnc_ledger_display2_refresh_cb ), ld );
|
||||
|
||||
splits = qof_query_run (ld->query);
|
||||
|
||||
gnc_ledger_display2_set_watches (ld, splits);
|
||||
// gnc_ledger_display2_set_watches (ld, splits);
|
||||
|
||||
gnc_ledger_display2_refresh_internal (ld, splits);
|
||||
|
||||
@ -877,7 +882,7 @@ gnc_ledger_display2_refresh_internal (GNCLedgerDisplay2 *ld, GList *splits)
|
||||
{
|
||||
GtkTreeModel *smodel, *model;
|
||||
|
||||
g_print("gnc_ledger_display2_refresh_internal\n");
|
||||
g_print("gnc_ledger_display2_refresh_internal ledger %p and splits %p\n", ld, splits);
|
||||
|
||||
if (!ld || ld->loading)
|
||||
return;
|
||||
@ -991,6 +996,18 @@ gnc_ledger_display2_set_split_view_refresh (GNCLedgerDisplay2 *ld, gboolean ok)
|
||||
ld->refresh_ok = ok;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_ledger_display2_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data)
|
||||
{
|
||||
GNCLedgerDisplay2 *ld = user_data;
|
||||
//g_print("refresh model %p user_data %p\n", model, user_data);
|
||||
|
||||
/* Refresh the view when idle */
|
||||
g_idle_add ((GSourceFunc)gnc_ledger_display2_refresh, ld);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_ledger_display2_close (GNCLedgerDisplay2 *ld)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user