Skip to content

Commit

Permalink
Bug 797531 - Improve jumps to filtered registers
Browse files Browse the repository at this point in the history
Currently if a jump to a filtered register is made, this could be from
a report, other register, reconcile window and transaction associations
and the destination split is not shown the jump will end up at the last
active cell. This could be confusing so add a test for the destination
split being visible and warn the user with an option to temporarily
clear the filter.
  • Loading branch information
Bob-IT committed Jun 10, 2020
1 parent f749f13 commit cfc6a6e
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 9 deletions.
4 changes: 4 additions & 0 deletions gnucash/gnome/dialog-assoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ row_selected_trans_cb (GtkTreeView *view, GtkTreePath *path,
gsr = gnc_plugin_page_register_get_gsr (page);
gnc_split_reg_raise (gsr);

// Test for visibility of split
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(page));

gnc_split_reg_jump_to_split (gsr, split);
}

Expand Down
26 changes: 26 additions & 0 deletions gnucash/gnome/gnc-plugin-page-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,22 @@ gnc_plugin_page_register_filter_select_range_cb (GtkRadioButton* button,
LEAVE (" ");
}

void
gnc_plugin_page_register_clear_current_filter (GncPluginPage* plugin_page)
{
GncPluginPageRegisterPrivate* priv;

g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));

priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);

priv->fd.days = 0;
priv->fd.start_time = 0;
priv->fd.end_time = 0;
priv->fd.cleared_match = (gint)g_ascii_strtoll (DEFAULT_FILTER, NULL, 16);

gnc_ppr_update_date_query (GNC_PLUGIN_PAGE_REGISTER(plugin_page));
}

/** This function is called when the "number of days" spin button is
* changed which is then saved and updates the time limitation on
Expand Down Expand Up @@ -4008,6 +4024,11 @@ gnc_plugin_page_register_cmd_reverse_transaction (GtkAction* action,
/* Now jump to new trans */
gsr = gnc_plugin_page_register_get_gsr (GNC_PLUGIN_PAGE (page));
split = xaccTransFindSplitByAccount(new_trans, account);

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(page));

gnc_split_reg_jump_to_split (gsr, split);
LEAVE (" ");
}
Expand Down Expand Up @@ -4781,6 +4802,11 @@ gnc_plugin_page_register_cmd_jump (GtkAction* action,

gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page);
gsr = gnc_plugin_page_register_get_gsr (new_page);

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(new_page));

gnc_split_reg_jump_to_split (gsr, split);
LEAVE (" ");
}
Expand Down
10 changes: 10 additions & 0 deletions gnucash/gnome/gnc-plugin-page-register.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ gnc_plugin_page_register_get_account (GncPluginPageRegister *page);
Transaction *
gnc_plugin_page_register_get_current_txn (GncPluginPageRegister *page);

/** This function clears the registers current filter.
* It is used so jumps to splits from other places can be completed
* otherwise the jump will be to the last active cell.
*
* @param plugin_page A pointer to the GncPluginPageRegister.
*/
void
gnc_plugin_page_register_clear_current_filter (GncPluginPage* plugin_page);


G_END_DECLS
/** @} */
/** @} */
Expand Down
27 changes: 26 additions & 1 deletion gnucash/gnome/gnc-split-reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,32 @@ gnc_split_reg_expand_trans_toolbar_cb (GtkWidget *widget, gpointer data)
gsr_emit_simple_signal( gsr, "expand_ent" );
}

gboolean
gnc_split_reg_clear_filter_for_split (GNCSplitReg *gsr, Split *split)
{
VirtualCellLocation vcell_loc;
SplitRegister *reg;

if (!gsr)
return FALSE;

reg = gnc_ledger_display_get_split_register (gsr->ledger);

if (!gnc_split_register_get_split_virt_loc (reg, split, &vcell_loc))
{
gint response = gnc_ok_cancel_dialog (GTK_WINDOW(gsr->window),
GTK_RESPONSE_CANCEL,
(_("Target split is currently hidden in this register.\n\n%s\n\n"
"Select OK to temporarily clear filter and proceed,\n"
"otherwise the last active cell will be selected.")),
gsr->filter_text);

if (response == GTK_RESPONSE_OK)
return TRUE;
}
return FALSE;
}

/**
* move the cursor to the split, if present in register
**/
Expand All @@ -1799,7 +1825,6 @@ gnc_split_reg_jump_to_split(GNCSplitReg *gsr, Split *split)
gnc_ledger_display_refresh( gsr->ledger );
}


/**
* Move the cursor to the split in the non-blank amount column.
**/
Expand Down
11 changes: 11 additions & 0 deletions gnucash/gnome/gnc-split-reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ void gnc_split_reg_jump_to_blank (GNCSplitReg *gsr);
void gnc_split_reg_jump_to_split(GNCSplitReg *gsr, Split *split);
void gnc_split_reg_jump_to_split_amount(GNCSplitReg *gsr, Split *split);

/** Check if the split is visible and ask if register filter should
* be cleared if split is not visible.
*
* @param gsr A pointer to GNCSplitReg
*
* @param split A pointer to the split to check visibility on
*
* @return TRUE if the register filter should be cleared
**/
gboolean gnc_split_reg_clear_filter_for_split (GNCSplitReg *gsr, Split *split);

/**
* Set the focus of the register to the sheet
**/
Expand Down
10 changes: 7 additions & 3 deletions gnucash/gnome/top-level.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ gnc_html_register_url_cb (const char *location, const char *label,
gnc_main_window_open_page (GNC_MAIN_WINDOW (result->parent), page);
if (split)
{
gsr = gnc_plugin_page_register_get_gsr(page);
gnc_split_reg_jump_to_split( gsr, split );
}
gsr = gnc_plugin_page_register_get_gsr (page);

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (page);

gnc_split_reg_jump_to_split (gsr, split);
}
return TRUE;
}

Expand Down
20 changes: 15 additions & 5 deletions gnucash/gnome/window-reconcile.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct _RecnWindow

GtkUIManager *ui_merge;
GtkActionGroup *action_group;
GncPluginPage *page;

GtkWidget *starting; /* The starting balance */
GtkWidget *ending; /* The ending balance */
Expand Down Expand Up @@ -1019,18 +1020,17 @@ static GNCSplitReg *
gnc_reconcile_window_open_register(RecnWindow *recnData)
{
Account *account = recn_get_account (recnData);
GncPluginPage *page;
GNCSplitReg *gsr;
gboolean include_children;

if (!account)
return(NULL);

include_children = xaccAccountGetReconcileChildrenStatus (account);
page = gnc_plugin_page_register_new (account, include_children);
gnc_main_window_open_page (NULL, page);
gsr = gnc_plugin_page_register_get_gsr(page);
gnc_split_reg_raise(gsr);
recnData->page = gnc_plugin_page_register_new (account, include_children);
gnc_main_window_open_page (NULL, recnData->page);
gsr = gnc_plugin_page_register_get_gsr (recnData->page);
gnc_split_reg_raise (gsr);
return gsr;
}

Expand All @@ -1049,6 +1049,11 @@ gnc_reconcile_window_double_click_cb(GNCReconcileView *view, Split *split,
gsr = gnc_reconcile_window_open_register(recnData);
if (gsr == NULL)
return;

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(recnData->page));

gnc_split_reg_jump_to_split( gsr, split );
}

Expand Down Expand Up @@ -1430,6 +1435,11 @@ gnc_ui_reconcile_window_edit_cb(GtkButton *button, gpointer data)
gsr = gnc_reconcile_window_open_register(recnData);
if (gsr == NULL)
return;

/* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(recnData->page));

gnc_split_reg_jump_to_split_amount( gsr, split );
}

Expand Down

0 comments on commit cfc6a6e

Please sign in to comment.