GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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.nosp@m.@lin.nosp@m.as.or.nosp@m.g
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 452 of file combocell-gnome.c.

453 {
454  PopBox *box;
455  gchar *menu_copy, *value_copy;
456 
457  if (cell == NULL)
458  return;
459  if (menustr == NULL)
460  return;
461 
462  box = cell->cell.gui_private;
463 
464  if (box->item_list != NULL)
465  {
466  block_list_signals (cell);
467 
468  gnc_item_list_append (box->item_list, menustr);
469  if (cell->cell.value)
470  {
471  menu_copy = g_strdelimit(g_strdup(menustr), "-:/\\.", ' ');
472  value_copy =
473  g_strdelimit(g_strdup(cell->cell.value), "-:/\\.", ' ');
474  if (strcmp (menu_copy, value_copy) == 0)
475  {
476  gnc_combo_cell_set_value (cell, menustr);
477  gnc_item_list_select (box->item_list, menustr);
478  }
479  g_free(value_copy);
480  g_free(menu_copy);
481  }
482  unblock_list_signals (cell);
483  }
484 
485  /* If we're going to be using a pre-fab quickfill,
486  * then don't fill it in here */
487  if (FALSE == box->use_quickfill_cache)
488  {
489  gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
490  }
491 }
void gnc_quickfill_insert(QuickFill *qf, const char *text, QuickFillSort sort)
Definition: QuickFill.c:229
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 930 of file combocell-gnome.c.

932 {
933  PopBox *box;
934 
935  if (cell == NULL)
936  return;
937 
938  if (!ignore_string)
939  return;
940 
941  box = cell->cell.gui_private;
942 
943  box->ignore_strings = g_list_prepend (box->ignore_strings,
944  g_strdup (ignore_string));
945 }
void gnc_combo_cell_add_menu_item ( ComboCell cell,
const char *  menustr 
)

Add a menu item to the list.

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

414 {
415  PopBox *box;
416 
417  if (cell == NULL)
418  return;
419  if (menustr == NULL)
420  return;
421 
422  box = cell->cell.gui_private;
423 
424  if (box->item_list != NULL)
425  {
426  block_list_signals (cell);
427 
428  gnc_item_list_append (box->item_list, menustr);
429  if (cell->cell.value &&
430  (strcmp (menustr, cell->cell.value) == 0))
431  gnc_item_list_select (box->item_list, menustr);
432 
433  unblock_list_signals (cell);
434  }
435  else
436  {
437  GtkTreeIter iter;
438 
439  gtk_list_store_append(box->tmp_store, &iter);
440  gtk_list_store_set(box->tmp_store, &iter, 0, menustr, -1);
441  }
442 
443  /* If we're going to be using a pre-fab quickfill,
444  * then don't fill it in here */
445  if (FALSE == box->use_quickfill_cache)
446  {
447  gnc_quickfill_insert (box->qf, menustr, QUICKFILL_ALPHA);
448  }
449 }
void gnc_quickfill_insert(QuickFill *qf, const char *text, QuickFillSort sort)
Definition: QuickFill.c:229
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 948 of file combocell-gnome.c.

949 {
950  PopBox *box;
951 
952  if (!cell)
953  return;
954 
955  box = cell->cell.gui_private;
956  if (!box)
957  return;
958 
959  box->autosize = autosize;
960 }
void gnc_combo_cell_set_complete_char ( ComboCell cell,
gunichar  complete_char 
)

Sets a character used for special completion processing.

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

918 {
919  PopBox *box;
920 
921  if (cell == NULL)
922  return;
923 
924  box = cell->cell.gui_private;
925 
926  box->complete_char = complete_char;
927 }
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 341 of file combocell-gnome.c.

342 {
343  PopBox *box;
344 
345  if (cell == NULL)
346  return;
347 
348  box = cell->cell.gui_private;
349  if (box->item_list == NULL)
350  return;
351 
352  block_list_signals (cell);
353  gnc_item_list_set_sort_enabled(box->item_list, enabled);
354  unblock_list_signals (cell);
355 }
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 904 of file combocell-gnome.c.

905 {
906  PopBox *box;
907 
908  if (cell == NULL)
909  return;
910 
911  box = cell->cell.gui_private;
912 
913  box->strict = strict;
914 }
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 387 of file combocell-gnome.c.

388 {
389  PopBox *box;
390 
391  if (cell == NULL) return;
392 
393  box = cell->cell.gui_private;
394  if (NULL == box) return;
395 
396  if (FALSE == box->use_quickfill_cache)
397  {
398  box->use_quickfill_cache = TRUE;
399  gnc_quickfill_destroy (box->qf);
400  }
401  box->qf = shared_qf;
402 }