Skip to content

Commit

Permalink
Merge Bob Fewell's 'revised-reg-desc' into stable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jralls committed Jun 11, 2023
2 parents 96e349b + f7bfd0b commit 6d60c11
Show file tree
Hide file tree
Showing 14 changed files with 1,121 additions and 141 deletions.
2 changes: 1 addition & 1 deletion gnucash/register/ledger-core/split-register-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ gnc_split_register_layout_add_cells (SplitRegister* reg,

gnc_register_add_cell (layout,
DESC_CELL,
COMBO_CELL_TYPE_NAME,
COMPLETION_CELL_TYPE_NAME,
C_ ("sample", "Description of a transaction"),
CELL_ALIGN_LEFT,
TRUE,
Expand Down
44 changes: 27 additions & 17 deletions gnucash/register/ledger-core/split-register-load.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Transaction.h"
#include "account-quickfill.h"
#include "combocell.h"
#include "completioncell.h"
#include "gnc-component-manager.h"
#include "qof.h"
#include "gnc-ui-util.h"
Expand All @@ -54,7 +55,6 @@ static QofLogModule log_module = GNC_MOD_LEDGER;
static void gnc_split_register_load_xfer_cells (SplitRegister* reg,
Account* base_account);

static void gnc_split_register_load_desc_cells (SplitRegister* reg);
static void
gnc_split_register_load_recn_cells (SplitRegister* reg)
{
Expand Down Expand Up @@ -113,6 +113,21 @@ gnc_split_register_load_type_cells (SplitRegister* reg)
gnc_recn_cell_set_read_only (cell, TRUE);
}

static void
gnc_split_register_load_desc_cells (SplitRegister* reg)
{
CompletionCell *cell;

if (!reg) return;

cell = (CompletionCell *)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL);

if (!cell) return;

gnc_completion_cell_set_sort_enabled (cell, TRUE);
}

/** Add a transaction to the register.
*
* Virtual cells are set up to hold the data, beginning at @a vcell_loc and
Expand Down Expand Up @@ -609,6 +624,13 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
added_blank_trans = TRUE;
}

gnc_completion_cell_clear_menu (
(CompletionCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL));

gnc_completion_cell_reverse_sort (
(CompletionCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
table->model->reverse_sort);

/* populate the table */
for (node = slist; node; node = node->next)
{
Expand Down Expand Up @@ -729,9 +751,10 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
if (info->first_pass)
add_quickfill_completions (reg->table->layout, trans, split, has_last_num);

gnc_combo_cell_add_menu_item_unique (
(ComboCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
xaccTransGetDescription (trans));
gnc_completion_cell_add_menu_item (
(CompletionCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
xaccTransGetDescription (trans));


if (trans == find_trans)
new_trans_row = vcell_loc.virt_row;
Expand Down Expand Up @@ -936,17 +959,4 @@ gnc_split_register_load_xfer_cells (SplitRegister* reg, Account* base_account)
gnc_combo_cell_use_list_store_cache (cell, store);
}

static void
gnc_split_register_load_desc_cells (SplitRegister* reg)
{
ComboCell* cell;
GtkListStore* store = gtk_list_store_new (1, G_TYPE_STRING);

cell = (ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL);

gnc_combo_cell_use_type_ahead_only (cell);

gnc_combo_cell_use_list_store_cache (cell, store);
}
/* ====================== END OF FILE ================================== */
17 changes: 9 additions & 8 deletions gnucash/register/ledger-core/split-register.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <glib/gi18n.h>

#include "combocell.h"
#include "completioncell.h"
#include "datecell.h"
#include "dialog-utils.h"
#include "gnc-component-manager.h"
Expand Down Expand Up @@ -2665,10 +2666,10 @@ gnc_split_register_config_cells (SplitRegister* reg)
((ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), TRUE);

/* the description cell */
gnc_combo_cell_set_autosize
((ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), TRUE);
/* the description cell */
gnc_completion_cell_set_autosize
((CompletionCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), TRUE);

/* Use GNC_COMMODITY_MAX_FRACTION for prices and "exchange rates" */
gnc_price_cell_set_fraction
Expand Down Expand Up @@ -2697,10 +2698,10 @@ gnc_split_register_config_cells (SplitRegister* reg)
((ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, ACTN_CELL), FALSE);

/* The description cell should accept strings not in the list */
gnc_combo_cell_set_strict
((ComboCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), FALSE);
/* The description cell should accept strings not in the list */
gnc_completion_cell_set_strict
((CompletionCell*)
gnc_table_layout_get_cell (reg->table->layout, DESC_CELL), FALSE);

/* number format for share quantities in stock ledgers */
switch (reg->type)
Expand Down
1 change: 1 addition & 0 deletions gnucash/register/register-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set (register_core_HEADERS
cell-factory.h
cellblock.h
combocell.h
completioncell.h
datecell.h
formulacell.h
gtable.h
Expand Down
8 changes: 0 additions & 8 deletions gnucash/register/register-core/combocell.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ void gnc_combo_cell_clear_menu (ComboCell* cell);
void gnc_combo_cell_add_menu_item (ComboCell* cell,
const char* menustr);

/** Add a unique menu item to the list. */
void gnc_combo_cell_add_menu_item_unique (ComboCell* cell,
const char* menustr);

/** Add a 'account name' menu item to the list. When testing for
* equality with the currently selected item, this function will
* ignore the characters normally used to separate account names. */
Expand Down Expand Up @@ -108,9 +104,5 @@ void gnc_combo_cell_use_quickfill_cache (ComboCell* cell,
QuickFill* shared_qf);
void gnc_combo_cell_use_list_store_cache (ComboCell* cell, gpointer data);

/** Set the combocell to use only type ahead search. This will make the
* search to be more like a modified entry completion. */
void gnc_combo_cell_use_type_ahead_only (ComboCell* cell);

/** @} */
#endif
79 changes: 79 additions & 0 deletions gnucash/register/register-core/completioncell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/********************************************************************\
* completion.h -- combo-box used for completion cell *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
* Boston, MA 02110-1301, USA gnu@gnu.org *
* *
\********************************************************************/

/** @addtogroup Cell Cell
* @{
* @file completion.h
* @struct CompletionCell
* @brief The CompletionCell object implements a cell handler with a
* "combination-box" pull-down menu in it.
*
* On output, the currently selected menu item is displayed.
* On input, the user can select from a list in the pull-down menu,
* or use the keyboard to select a menu entry by typing the first
* few menu characters.
*
* @author Copyright (c) 2023 Robert Fewell
*/

#ifndef COMPLETION_CELL_H
#define COMPLETION_CELL_H

#include <glib.h>

#include "basiccell.h"

typedef struct
{
BasicCell cell;
} CompletionCell;


BasicCell * gnc_completion_cell_new (void);
void gnc_completion_cell_init (CompletionCell* cell);

void gnc_completion_cell_set_value (CompletionCell* cell, const char* value);

void gnc_completion_cell_clear_menu (CompletionCell* cell);

/** Add a menu item to the hash table list. */
void gnc_completion_cell_add_menu_item (CompletionCell* cell,
const char* menustr);

/** Enable sorting of the menu item's contents. */
void gnc_completion_cell_set_sort_enabled (CompletionCell* cell,
gboolean enabled);

/** Determines whether the cell will accept strings not in the
* menu. Defaults to strict, i.e., only menu items are accepted. */
void gnc_completion_cell_set_strict (CompletionCell* cell, gboolean strict);

/** Determines whether the popup list autosizes itself or uses
* all available space. FALSE by default. */
void gnc_completion_cell_set_autosize (CompletionCell* cell, gboolean autosize);

/** Register the sort direction. Used to determine in what order the completion should
* present the list. FALSE by default */
void gnc_completion_cell_reverse_sort (CompletionCell* cell, gboolean is_reversed);

/** @} */
#endif
1 change: 1 addition & 0 deletions gnucash/register/register-core/register-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "basiccell.h"
#include "cell-factory.h"
#include "combocell.h"
#include "completioncell.h"
#include "datecell.h"
#include "formulacell.h"
#include "numcell.h"
Expand Down
1 change: 1 addition & 0 deletions gnucash/register/register-core/register-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#define QUICKFILL_CELL_TYPE_NAME "quickfill-cell"
#define FORMULA_CELL_TYPE_NAME "formula-cell"
#define CHECKBOX_CELL_TYPE_NAME "checkbox-cell"
#define COMPLETION_CELL_TYPE_NAME "completion-cell"

void gnc_register_init (void);
void gnc_register_shutdown (void);
Expand Down
1 change: 1 addition & 0 deletions gnucash/register/register-gnome/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include(CheckSymbolExists)

set (register_gnome_SOURCES
combocell-gnome.c
completioncell-gnome.c
datecell-gnome.c
formulacell-gnome.c
gnucash-color.c
Expand Down

0 comments on commit 6d60c11

Please sign in to comment.