GnuCash 2.3.0
Data Structures | Functions
combocell.h File Reference

The ComboCell object implements a cell handler with a "combination-box" pull-down menu in it. More...

#include <glib.h>
#include "basiccell.h"
#include "QuickFill.h"

Go to the source code of this file.

Data Structures

struct  ComboCell

Functions

BasicCellgnc_combo_cell_new (void)
void gnc_combo_cell_init (ComboCell *cell)
void gnc_combo_cell_set_value (ComboCell *cell, const char *value)
void gnc_combo_cell_clear_menu (ComboCell *cell)
void gnc_combo_cell_add_menu_item (ComboCell *cell, const char *menustr)
void gnc_combo_cell_add_account_menu_item (ComboCell *cell, char *menustr)
void gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled)
void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict)
void gnc_combo_cell_set_complete_char (ComboCell *cell, gunichar complete_char)
void gnc_combo_cell_add_ignore_string (ComboCell *cell, const char *ignore_string)
void gnc_combo_cell_set_autosize (ComboCell *cell, gboolean autosize)
void gnc_combo_cell_use_quickfill_cache (ComboCell *cell, QuickFill *shared_qf)
void gnc_combo_cell_use_list_store_cache (ComboCell *cell, gpointer data)

Detailed Description

The ComboCell 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 slect a menu entry by typing the first few menu characters.

Author:
Created Jan 1998 Linas Vepstas
Copyright (c) 1998 Linas Vepstas <linas@linas.org>
Copyright (c) 2000 Dave Peticolas

Definition in file combocell.h.


Function Documentation

void gnc_combo_cell_add_account_menu_item ( ComboCell cell,
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.

Definition at line 453 of file combocell-gnome.c.

{
    PopBox *box;
    gchar *menu_copy, *value_copy;

    if (cell == NULL)
        return;
    if (menustr == NULL)
        return;

    box = cell->cell.gui_private;

    if (box->item_list != NULL)
    {
        block_list_signals (cell);

        gnc_item_list_append (box->item_list, menustr);
        if (cell->cell.value)
        {
            menu_copy = g_strdelimit(g_strdup(menustr), "-:/\\.", ' ');
            value_copy =
                g_strdelimit(g_strdup(cell->cell.value), "-:/\\.", ' ');
            if (strcmp (menu_copy, value_copy) == 0)
            {
                gnc_combo_cell_set_value (cell, menustr);
                gnc_item_list_select (box->item_list, menustr);
            }
            g_free(value_copy);
            g_free(menu_copy);
        }
        unblock_list_signals (cell);
    }

    /* If we're going to be using a pre-fab quickfill,
     * then don't fill it in here */
    if (FALSE == box->use_quickfill_cache)
    {
        gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
    }
}
void gnc_combo_cell_add_ignore_string ( ComboCell cell,
const char *  ignore_string 
)

Add a string to a list of strings which, if the cell has that value, will cause the cell to be uneditable on 'enter'.

Definition at line 932 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL)
        return;

    if (!ignore_string)
        return;

    box = cell->cell.gui_private;

    box->ignore_strings = g_list_prepend (box->ignore_strings,
                                          g_strdup (ignore_string));
}
void gnc_combo_cell_add_menu_item ( ComboCell cell,
const char *  menustr 
)

Add a menu item to the list.

Definition at line 414 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL)
        return;
    if (menustr == NULL)
        return;

    box = cell->cell.gui_private;

    if (box->item_list != NULL)
    {
        block_list_signals (cell);

        gnc_item_list_append (box->item_list, menustr);
        if (cell->cell.value &&
                (strcmp (menustr, cell->cell.value) == 0))
            gnc_item_list_select (box->item_list, menustr);

        unblock_list_signals (cell);
    }
    else
    {
        GtkTreeIter iter;

        gtk_list_store_append(box->tmp_store, &iter);
        gtk_list_store_set(box->tmp_store, &iter, 0, menustr, -1);
    }

    /* If we're going to be using a pre-fab quickfill,
     * then don't fill it in here */
    if (FALSE == box->use_quickfill_cache)
    {
        gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
    }
}
void gnc_combo_cell_set_autosize ( ComboCell cell,
gboolean  autosize 
)

Determines whether the popup list autosizes itself or uses all available space. FALSE by default.

Definition at line 950 of file combocell-gnome.c.

{
    PopBox *box;

    if (!cell)
        return;

    box = cell->cell.gui_private;
    if (!box)
        return;

    box->autosize = autosize;
}
void gnc_combo_cell_set_complete_char ( ComboCell cell,
gunichar  complete_char 
)

Sets a character used for special completion processing.

Definition at line 919 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL)
        return;

    box = cell->cell.gui_private;

    box->complete_char = complete_char;
}
void gnc_combo_cell_set_sort_enabled ( ComboCell cell,
gboolean  enabled 
)

Enable sorting of the menu item's contents. Loading the item is much faster with sorting disabled.

Definition at line 342 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL)
        return;

    box = cell->cell.gui_private;
    if (box->item_list == NULL)
        return;

    block_list_signals (cell);
    gnc_item_list_set_sort_enabled(box->item_list, enabled);
    unblock_list_signals (cell);
}
void gnc_combo_cell_set_strict ( ComboCell cell,
gboolean  strict 
)

Determines whether the cell will accept strings not in the menu. Defaults to strict, i.e., only menu items are accepted.

Definition at line 906 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL)
        return;

    box = cell->cell.gui_private;

    box->strict = strict;
}
void gnc_combo_cell_use_quickfill_cache ( ComboCell cell,
QuickFill shared_qf 
)

Tell the combocell to use a shared QuickFill object. Using this routine can dramatically improve performance when creating combocells with a large number of entries. For example, users with thousands of accounts are complaining about 10-second register startup times, of which 98% of the cpu is spent building the multi-thousand entry quickfill. When a shared quickfill is specified, the combo-cell will not add to nor delete the quickfill; it is the users resonsibility to manage the quickfill object. The combocell will *not* make a copy of teh quickfill.

Definition at line 388 of file combocell-gnome.c.

{
    PopBox *box;

    if (cell == NULL) return;

    box = cell->cell.gui_private;
    if (NULL == box) return;

    if (FALSE == box->use_quickfill_cache)
    {
        box->use_quickfill_cache = TRUE;
        gnc_quickfill_destroy (box->qf);
    }
    box->qf = shared_qf;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines