Finish removing the redundant list of valid strings maintained by the

combocell and use the list in the item_edit widget.  Fixes the problem
where account cell contents disappear when focusing in/out of an
account cell.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13609 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2006-03-12 03:52:45 +00:00
parent a010fdf742
commit 5af42fc6b1
4 changed files with 48 additions and 72 deletions

View File

@ -1,3 +1,16 @@
2006-03-11 David Hampton <hampton@employees.org>
* src/register/register-gnome/combocell-gnome.c:
* src/register/register-gnome/gnucash-item-list.[ch]: Finish
removing the redundant list of valid strings maintained by the
combocell and use the list in the item_edit widget. Fixes the
problem where account cell contents disappear when focusing in/out
of an account cell.
* src/gnome-utils/account-quickfill.c: Update the quickfill to
watch for accounts being added/removed from the account
tree. Fixes 152101 and 302682.
2006-03-11 Derek Atkins <derek@ihtfp.com>
* src/gnome-search/dialog-search.c:

View File

@ -50,15 +50,12 @@
typedef struct _PopBox
{
GList *menustrings;
GnucashSheet *sheet;
GncItemEdit *item_edit;
GncItemList *item_list;
gboolean signals_connected; /* list signals connected? */
gboolean list_in_sync; /* list in sync with menustrings? */
gboolean list_popped; /* list is popped up? */
gboolean autosize;
@ -145,9 +142,7 @@ gnc_combo_cell_init (ComboCell *cell)
box->sheet = NULL;
box->item_edit = NULL;
box->item_list = NULL;
box->menustrings = NULL;
box->signals_connected = FALSE;
box->list_in_sync = TRUE;
box->list_popped = FALSE;
box->autosize = FALSE;
@ -305,12 +300,6 @@ gnc_combo_cell_gui_destroy (BasicCell *bcell)
}
}
static void
menustring_free (gpointer string, gpointer user_data)
{
g_free (string);
}
static void
gnc_combo_cell_destroy (BasicCell *bcell)
{
@ -323,10 +312,6 @@ gnc_combo_cell_destroy (BasicCell *bcell)
{
GList *node;
g_list_foreach (box->menustrings, menustring_free, NULL);
g_list_free (box->menustrings);
box->menustrings = NULL;
/* Don't destroy the qf if its not ours to destroy */
if (FALSE == box->use_quickfill_cache)
{
@ -379,12 +364,6 @@ gnc_combo_cell_clear_menu (ComboCell * cell)
box = cell->cell.gui_private;
if (box == NULL)
return;
if (box->menustrings == NULL)
return;
g_list_foreach (box->menustrings, menustring_free, NULL);
g_list_free (box->menustrings);
box->menustrings = NULL;
/* Don't destroy the qf if its not ours to destroy */
if (FALSE == box->use_quickfill_cache)
@ -401,8 +380,6 @@ gnc_combo_cell_clear_menu (ComboCell * cell)
unblock_list_signals (cell);
}
box->list_in_sync = TRUE;
}
void
@ -431,26 +408,6 @@ gnc_combo_cell_use_list_store_cache (ComboCell * cell, gpointer data)
cell->shared_store = data;
}
static void
gnc_append_string_to_list (gpointer _string, gpointer _item_list)
{
char *string = _string;
GncItemList *item_list = GNC_ITEM_LIST (_item_list);
gnc_item_list_append (item_list, string);
}
static void
gnc_combo_sync_edit_list(PopBox *box)
{
if (box->list_in_sync || box->item_list == NULL)
return;
gnc_item_list_clear (box->item_list);
g_list_foreach (box->menustrings, gnc_append_string_to_list,
box->item_list);
}
void
gnc_combo_cell_add_menu_item (ComboCell *cell, char * menustr)
{
@ -462,10 +419,6 @@ gnc_combo_cell_add_menu_item (ComboCell *cell, char * menustr)
return;
box = cell->cell.gui_private;
box->menustrings = g_list_append (box->menustrings,
g_strdup (menustr));
gnc_combo_sync_edit_list(box);
if (box->item_list != NULL)
{
@ -478,8 +431,6 @@ gnc_combo_cell_add_menu_item (ComboCell *cell, char * menustr)
unblock_list_signals (cell);
}
else
box->list_in_sync = FALSE;
/* If we're going to be using a pre-fab quickfill,
* then don't fill it in here */
@ -501,10 +452,6 @@ gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
return;
box = cell->cell.gui_private;
box->menustrings = g_list_append (box->menustrings,
g_strdup (menustr));
gnc_combo_sync_edit_list(box);
if (box->item_list != NULL)
{
@ -524,8 +471,6 @@ gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr)
}
unblock_list_signals (cell);
}
else
box->list_in_sync = FALSE;
/* If we're going to be using a pre-fab quickfill,
* then don't fill it in here */
@ -892,8 +837,6 @@ gnc_combo_cell_enter (BasicCell *bcell,
if (find)
return FALSE;
gnc_combo_sync_edit_list (box);
gnc_item_edit_set_popup (box->item_edit,
GNOME_CANVAS_ITEM (box->item_list),
get_popup_height, popup_autosize,
@ -927,22 +870,15 @@ gnc_combo_cell_leave (BasicCell *bcell)
if (box->strict)
{
GList *find = NULL;
if (bcell->value)
find = g_list_find_custom (box->menustrings,
bcell->value,
(GCompareFunc) strcmp);
if (find)
return;
if (bcell->value)
find = g_list_find_custom (box->ignore_strings,
bcell->value,
(GCompareFunc) strcmp);
if (find)
return;
if (bcell->value) {
if (gnc_item_in_list (box->item_list, bcell->value))
return;
if (g_list_find_custom (box->ignore_strings,
bcell->value,
(GCompareFunc) strcmp))
return;
}
gnc_basic_cell_set_value_internal (bcell, "");
}
}

View File

@ -123,6 +123,29 @@ _gnc_item_find_selection(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *it
return FALSE;
}
gboolean
gnc_item_in_list (GncItemList *item_list, const char *string)
{
FindSelectionData *to_find_data;
gboolean result;
g_return_val_if_fail(item_list != NULL, FALSE);
g_return_val_if_fail(IS_GNC_ITEM_LIST(item_list), FALSE);
to_find_data = (FindSelectionData*)g_new0(FindSelectionData, 1);
to_find_data->item_list = item_list;
to_find_data->string_to_find = string;
gtk_tree_model_foreach(GTK_TREE_MODEL(item_list->list_store),
_gnc_item_find_selection,
to_find_data);
result = (to_find_data->found_path != NULL);
g_free(to_find_data);
return result;
}
void
gnc_item_list_select (GncItemList *item_list, const char *string)
{
@ -432,6 +455,8 @@ gnc_item_list_new(GnomeCanvasGroup *parent, GtkListStore *list_store)
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
GTK_SELECTION_BROWSE);
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(list_store),
0, GTK_SORT_ASCENDING);
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("List"),

View File

@ -67,6 +67,8 @@ void gnc_item_list_append (GncItemList *item_list, char *string);
void gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled);
gboolean gnc_item_in_list (GncItemList *item_list, const char *string);
void gnc_item_list_select (GncItemList *item_list, const char *string);
void gnc_item_list_show_selected (GncItemList *item_list);