Skip to content

Commit

Permalink
Import Matcher - select row if none is selected yet when right-clicki…
Browse files Browse the repository at this point in the history
…ng the list of matches
  • Loading branch information
gjanssens committed May 16, 2024
1 parent f7f42bf commit 31095c1
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions gnucash/import-export/import-main-matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1462,15 +1462,27 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
GdkEventButton *event_button = (GdkEventButton *) event;
if (event_button->button == GDK_BUTTON_SECONDARY)
{
DEBUG("Right mouseClick detected- popup the menu.");
// Only pop up the menu if there's more than 1 selected transaction,
// or the selected transaction is an ADD.
GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
DEBUG("Right mouseClick detected - popup the menu.");

auto selection = gtk_tree_view_get_selection (treeview);
auto selected_rows = gtk_tree_selection_count_selected_rows (selection);
/* If no rows are selected yet, select the row that was clicked on
* before proceeding */
if (!selected_rows)
{
GtkTreePath* path = nullptr;
if (gtk_tree_view_get_path_at_pos (treeview, event_button->x,
event_button->y, &path, nullptr, nullptr, nullptr))
{
gtk_tree_selection_select_path (selection, path);
selected_rows++;
gtk_tree_path_free (path);
}
}
if (gtk_tree_selection_count_selected_rows (selection) > 0)
{
GList* selected;
GtkTreeModel *model;
selected = gtk_tree_selection_get_selected_rows (selection, &model);
auto selected = gtk_tree_selection_get_selected_rows (selection, &model);
if (get_action_for_path (static_cast<GtkTreePath*>(selected->data), model) == GNCImport_ADD)
gnc_gen_trans_view_popup_menu (treeview, event, info);
g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);
Expand Down

0 comments on commit 31095c1

Please sign in to comment.