More register work. Fix various bugs.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3414 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-01-09 02:13:47 +00:00
parent 5d34abf7f6
commit 2b35ce6d71
9 changed files with 285 additions and 223 deletions

View File

@@ -851,13 +851,13 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
else if (!info->hint_set_by_traverse)
{
/* The transaction where we are moving to */
new_trans = xaccSRGetTrans(reg, new_virt_loc.vcell_loc);
new_trans = xaccSRGetTrans (reg, new_virt_loc.vcell_loc);
/* The split we are moving to */
new_split = sr_get_split(reg, new_virt_loc.vcell_loc);
new_split = sr_get_split (reg, new_virt_loc.vcell_loc);
/* The split at the transaction line we are moving to */
new_trans_split = xaccSRGetTransSplit(reg, new_virt_loc.vcell_loc, NULL);
new_trans_split = xaccSRGetTransSplit (reg, new_virt_loc.vcell_loc, NULL);
new_class = xaccSplitRegisterGetCursorClass (reg, new_virt_loc.vcell_loc);
}
@@ -904,15 +904,14 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
result = gnc_verify_dialog_parented (xaccSRGetParent (reg),
message, TRUE);
if (result)
{
new_trans = old_trans;
new_split = old_split;
new_trans_split = old_trans_split;
new_class = old_class;
new_virt_loc = table->current_cursor_loc;
}
else
new_trans = old_trans;
new_split = old_split;
new_trans_split = old_trans_split;
new_class = old_class;
new_virt_loc = table->current_cursor_loc;
if (!result)
{
xaccTransScrubImbalance (old_trans, gncGetCurrentGroup ());
saved = TRUE;
@@ -951,6 +950,11 @@ LedgerMoveCursor (Table *table, VirtualLocation *p_new_virt_loc)
}
else
new_virt_loc.vcell_loc = reg->table->current_cursor_loc.vcell_loc;
new_trans = xaccSRGetTrans (reg, new_virt_loc.vcell_loc);
new_split = sr_get_split (reg, new_virt_loc.vcell_loc);
new_trans_split = xaccSRGetTransSplit (reg, new_virt_loc.vcell_loc, NULL);
new_class = xaccSplitRegisterGetCursorClass (reg, new_virt_loc.vcell_loc);
}
else if (info->traverse_to_new)
{
@@ -2408,9 +2412,9 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
void
xaccSREmptyCurrentTrans (SplitRegister *reg)
{
SRInfo *info = xaccSRGetInfo(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
SRInfo *info = xaccSRGetInfo (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans = xaccTransLookup (&info->pending_trans_guid);
Transaction *trans;
Account *account;
GList *splits;
@@ -2418,7 +2422,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
Split *split;
/* get the current split based on cursor position */
split = xaccSRGetCurrentSplit(reg);
split = xaccSRGetCurrentSplit (reg);
if (split == NULL)
return;
@@ -2428,12 +2432,12 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
if (split == blank_split)
{
trans = xaccSplitGetParent (blank_split);
account = xaccSplitGetAccount(split);
account = xaccSplitGetAccount (split);
/* Make sure we don't commit this later on */
if (trans == pending_trans)
{
info->pending_trans_guid = *xaccGUIDNULL();
info->pending_trans_guid = *xaccGUIDNULL ();
pending_trans = NULL;
}
@@ -2443,7 +2447,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);
info->blank_split_guid = *xaccGUIDNULL();
info->blank_split_guid = *xaccGUIDNULL ();
blank_split = NULL;
gnc_resume_gui_refresh ();
@@ -2455,26 +2459,26 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
/* make a copy of all of the accounts that will be
* affected by this deletion, so that we can update
* their register windows after the deletion. */
trans = xaccSplitGetParent(split);
trans = xaccSplitGetParent (split);
splits = xaccTransGetSplitList (trans);
splits = g_list_copy (xaccTransGetSplitList (trans));
xaccTransBeginEdit(trans);
xaccTransBeginEdit (trans);
for (node = splits; node; node = node->next)
if (node->data != split)
xaccSplitDestroy(node->data);
xaccTransCommitEdit(trans);
xaccSplitDestroy (node->data);
xaccTransCommitEdit (trans);
/* Check pending transaction */
if (trans == pending_trans)
{
info->pending_trans_guid = *xaccGUIDNULL();
info->pending_trans_guid = *xaccGUIDNULL ();
pending_trans = NULL;
}
gnc_resume_gui_refresh ();
g_list_free(splits);
g_list_free (splits);
}
/* ======================================================== */

View File

@@ -278,6 +278,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root)
{
Account *account;
GList *node;
imbalance = xaccTransGetImbalance (trans);
if (gnc_numeric_zero_p (imbalance))
@@ -285,12 +286,26 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root)
account = GetOrMakeAccount (root, trans, _("Imbalance"));
/* put split into account before setting split value */
balance_split = xaccMallocSplit();
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
Split *split = node->data;
xaccAccountBeginEdit (account);
xaccAccountInsertSplit (account, balance_split);
xaccAccountCommitEdit (account);
if (xaccSplitGetAccount (split) == account)
{
balance_split = split;
break;
}
}
/* put split into account before setting split value */
if (!balance_split)
{
balance_split = xaccMallocSplit();
xaccAccountBeginEdit (account);
xaccAccountInsertSplit (account, balance_split);
xaccAccountCommitEdit (account);
}
}
PINFO ("unbalanced transaction: %s",
@@ -318,19 +333,32 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root)
new_value = gnc_numeric_sub_fixed (new_value, imbalance);
xaccSplitSetValue (balance_split, new_value);
if (gnc_numeric_zero_p (new_value))
{
xaccSplitDestroy (balance_split);
balance_split = NULL;
}
}
commodity = xaccAccountGetSecurity (account);
if (gnc_commodity_equiv (common_currency, commodity))
if (balance_split && gnc_commodity_equiv (common_currency, commodity))
{
gnc_numeric new_share_amount = xaccSplitGetShareAmount (balance_split);
new_share_amount = gnc_numeric_sub_fixed (new_share_amount, imbalance);
xaccSplitSetShareAmount (balance_split, new_share_amount);
if (gnc_numeric_zero_p (new_share_amount))
{
xaccSplitDestroy (balance_split);
balance_split = NULL;
}
}
xaccTransAppendSplit (trans, balance_split);
if (balance_split)
xaccTransAppendSplit (trans, balance_split);
if (!trans_was_open)
xaccTransCommitEdit (trans);

View File

@@ -1510,25 +1510,29 @@ void
xaccSplitDestroy (Split *split)
{
Transaction *trans;
gboolean ismember = FALSE;
if (!split) return;
trans = split->parent;
assert (trans);
assert (trans->splits);
check_open (trans);
xaccRemoveEntity (&split->guid);
ismember = (g_list_find (trans->splits, split) != NULL);
assert (ismember);
if (trans)
{
gboolean ismember = (g_list_find (trans->splits, split) != NULL);
assert (ismember);
}
mark_split (split);
xaccTransRemoveSplit (trans, split);
if (trans)
xaccTransRemoveSplit (trans, split);
xaccAccountRemoveSplit (split->acc, split);
xaccAccountRecomputeBalance (split->acc);
xaccFreeSplit (split);
}

View File

@@ -726,18 +726,47 @@ moveCombo (BasicCell *bcell, VirtualLocation virt_loc)
{
PopBox *box = bcell->gui_private;
combo_disconnect_signals((ComboCell *) bcell);
combo_disconnect_signals ((ComboCell *) bcell);
gnome_canvas_item_set(GNOME_CANVAS_ITEM(box->item_edit),
"is_combo", FALSE, NULL);
item_edit_set_list(box->item_edit, NULL);
item_edit_set_popup (box->item_edit, NULL, NULL,
NULL, NULL, NULL, NULL);
box->list_popped = FALSE;
}
/* =============================================== */
static int
get_popup_height (GnomeCanvasItem *item,
int space_available,
int row_height,
gpointer user_data)
{
return (space_available / row_height) * row_height;
}
static void
popup_autosize (GnomeCanvasItem *item,
gpointer user_data)
{
gnc_item_list_autosize (GNC_ITEM_LIST (item));
}
static void
popup_set_focus (GnomeCanvasItem *item,
gpointer user_data)
{
gtk_widget_grab_focus (GTK_WIDGET (GNC_ITEM_LIST (item)->clist));
}
static void
popup_post_show (GnomeCanvasItem *item,
gpointer user_data)
{
gnc_item_list_autosize (GNC_ITEM_LIST (item));
gnc_item_list_show_selected (GNC_ITEM_LIST (item));
}
static gboolean
enterCombo (BasicCell *bcell,
int *cursor_position,
@@ -748,22 +777,22 @@ enterCombo (BasicCell *bcell,
PopBox *box = bcell->gui_private;
if ((box->ignore_string != NULL) &&
(safe_strcmp(bcell->value, box->ignore_string) == 0))
(safe_strcmp (bcell->value, box->ignore_string) == 0))
return FALSE;
gnc_combo_sync_edit_list (box);
gnc_combo_sort_edit_list (box);
item_edit_set_list(box->item_edit, box->item_list);
gnome_canvas_item_set(GNOME_CANVAS_ITEM(box->item_edit),
"is_combo", TRUE, NULL);
item_edit_set_popup (box->item_edit,
GNOME_CANVAS_ITEM (box->item_list),
get_popup_height, popup_autosize,
popup_set_focus, popup_post_show, NULL);
block_list_signals (cell);
gnc_item_list_select (box->item_list, bcell->value);
unblock_list_signals (cell);
combo_connect_signals((ComboCell *) bcell);
combo_connect_signals (cell);
*cursor_position = -1;
*start_selection = 0;
@@ -779,12 +808,10 @@ leaveCombo (BasicCell *bcell)
{
PopBox *box = bcell->gui_private;
combo_disconnect_signals((ComboCell *) bcell);
combo_disconnect_signals ((ComboCell *) bcell);
gnome_canvas_item_set(GNOME_CANVAS_ITEM(box->item_edit),
"is_combo", FALSE, NULL);
item_edit_set_list(box->item_edit, NULL);
item_edit_set_popup (box->item_edit, NULL, NULL, NULL,
NULL, NULL, NULL);
box->list_popped = FALSE;

View File

@@ -159,6 +159,7 @@ DateCellHelpValue (BasicCell *bcell)
time.tm_min = 0;
time.tm_hour = 0;
time.tm_isdst = -1;
mktime (&time);
}
@@ -760,16 +761,37 @@ moveDate (BasicCell *bcell, VirtualLocation virt_loc)
date_picker_disconnect_signals ((DateCell *) bcell);
gnome_canvas_item_set (GNOME_CANVAS_ITEM (box->item_edit),
"is_date", FALSE, NULL);
item_edit_set_date_picker (box->item_edit, NULL);
item_edit_set_popup (box->item_edit, NULL, NULL, NULL, NULL, NULL, NULL);
box->calendar_popped = FALSE;
}
/* =============================================== */
static int
get_popup_height (GnomeCanvasItem *item,
int space_available,
int row_height,
gpointer user_data)
{
GtkWidget *cal = GTK_WIDGET (GNC_DATE_PICKER (item)->calendar);
GtkRequisition req;
req.height = 0;
req.width = 0;
gtk_widget_size_request (cal, &req);
return req.height;
}
static void
popup_set_focus (GnomeCanvasItem *item,
gpointer user_data)
{
gtk_widget_grab_focus (GTK_WIDGET (GNC_DATE_PICKER (item)->calendar));
}
static gboolean
enterDate (BasicCell *bcell,
int *cursor_position,
@@ -779,10 +801,8 @@ enterDate (BasicCell *bcell,
DateCell *cell = (DateCell *) bcell;
PopBox *box = bcell->gui_private;
item_edit_set_date_picker (box->item_edit, box->date_picker);
gnome_canvas_item_set (GNOME_CANVAS_ITEM(box->item_edit),
"is_date", TRUE, NULL);
item_edit_set_popup (box->item_edit, GNOME_CANVAS_ITEM (box->date_picker),
get_popup_height, NULL, popup_set_focus, NULL, NULL);
block_picker_signals (cell);
gnc_date_picker_set_date (box->date_picker,
@@ -805,10 +825,7 @@ leaveDate (BasicCell *bcell)
date_picker_disconnect_signals ((DateCell *) bcell);
gnome_canvas_item_set (GNOME_CANVAS_ITEM(box->item_edit),
"is_date", FALSE, NULL);
item_edit_set_date_picker (box->item_edit, NULL);
item_edit_set_popup (box->item_edit, NULL, NULL, NULL, NULL, NULL, NULL);
box->calendar_popped = FALSE;
}

View File

@@ -43,8 +43,6 @@ enum {
ARG_0,
ARG_SHEET, /* The Sheet argument */
ARG_GTK_ENTRY, /* The GtkEntry argument */
ARG_IS_COMBO, /* Should this be a combo? */
ARG_IS_DATE, /* Should this be a date? */
};
/* values for selection info */
@@ -210,7 +208,7 @@ item_edit_draw_info(ItemEdit *item_edit, int x, int y, TextDrawInfo *info)
info->bg_rect.width = wd - (2 * CELL_HPADDING);
info->bg_rect.height = hd - (2 * CELL_VPADDING - info->font->descent);
toggle_space = (item_edit->is_combo || item_edit->is_date) ?
toggle_space = item_edit->is_popup ?
item_edit->popup_toggle.toggle_offset : 0;
info->text_rect.x = dx;
@@ -376,8 +374,8 @@ item_edit_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path,
int flags)
{
ItemEdit *item_edit = ITEM_EDIT (item);
gint x, y, w, h;
gint toggle_x, toggle_y, toggle_width, toggle_height;
gint x, y, w, h;
if (GNOME_CANVAS_ITEM_CLASS (item_edit_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS(item_edit_parent_class)->update)
@@ -390,7 +388,7 @@ item_edit_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path,
item->x2 = x + w;
item->y2 = y + h;
if (!item_edit->is_combo && !item_edit->is_date)
if (!item_edit->is_popup)
return;
toggle_height = h - 10;
@@ -448,8 +446,7 @@ item_edit_init (ItemEdit *item_edit)
item_edit->clipboard = NULL;
item_edit->has_selection = FALSE;
item_edit->is_combo = FALSE;
item_edit->is_date = FALSE;
item_edit->is_popup = FALSE;
item_edit->show_popup = FALSE;
item_edit->popup_toggle.toggle_button = NULL;
@@ -458,7 +455,12 @@ item_edit_init (ItemEdit *item_edit)
item_edit->popup_toggle.arrow = NULL;
item_edit->popup_toggle.signals_connected = FALSE;
item_edit->item_list = NULL;
item_edit->popup_item = NULL;
item_edit->get_popup_height = NULL;
item_edit->popup_autosize = NULL;
item_edit->popup_set_focus = NULL;
item_edit->popup_post_show = NULL;
item_edit->popup_user_data = NULL;
item_edit->gc = NULL;
item_edit->style = NULL;
@@ -678,6 +680,10 @@ item_edit_configure (ItemEdit *item_edit)
item_edit->virt_loc.phys_row_offset = cursor->row;
item_edit->virt_loc.phys_col_offset = cursor->col;
if (!gnc_table_is_popup (item_edit->sheet->table, item_edit->virt_loc))
item_edit_set_popup (item_edit, NULL, NULL, NULL,
NULL, NULL, NULL);
item_edit_update (GNOME_CANVAS_ITEM(item_edit), NULL, NULL, 0);
}
@@ -799,43 +805,45 @@ item_edit_paste_primary (ItemEdit *item_edit, guint32 time)
static void
item_edit_show_popup_toggle (ItemEdit *item_edit, gint x, gint y,
gint width, gint height, GtkAnchorType anchor)
item_edit_show_popup_toggle (ItemEdit *item_edit,
gint x, gint y,
gint width, gint height,
GtkAnchorType anchor)
{
g_return_if_fail(IS_ITEM_EDIT(item_edit));
g_return_if_fail (IS_ITEM_EDIT (item_edit));
gnome_canvas_item_raise_to_top
(item_edit->popup_toggle.toggle_button_item);
gnome_canvas_item_set(item_edit->popup_toggle.toggle_button_item,
"x", (gdouble) x,
"y", (gdouble) y,
"width", (gdouble) width,
"height", (gdouble) height,
"anchor", anchor,
NULL);
gnome_canvas_item_set (item_edit->popup_toggle.toggle_button_item,
"x", (gdouble) x,
"y", (gdouble) y,
"width", (gdouble) width,
"height", (gdouble) height,
"anchor", anchor,
NULL);
}
static void
item_edit_hide_popup_toggle (ItemEdit *item_edit)
{
g_return_if_fail(IS_ITEM_EDIT(item_edit));
g_return_if_fail (IS_ITEM_EDIT(item_edit));
/* safely out of the way */
gnome_canvas_item_set(item_edit->popup_toggle.toggle_button_item,
"x", -10000.0, NULL);
gnome_canvas_item_set (item_edit->popup_toggle.toggle_button_item,
"x", -10000.0, NULL);
}
static gboolean
key_press_popup_cb (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
ItemEdit *item_edit = ITEM_EDIT(data);
ItemEdit *item_edit = ITEM_EDIT (data);
gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "key_press_event");
gtk_widget_event(GTK_WIDGET(item_edit->sheet), (GdkEvent *) event);
gtk_widget_event (GTK_WIDGET(item_edit->sheet), (GdkEvent *) event);
return TRUE;
}
@@ -844,7 +852,7 @@ key_press_popup_cb (GtkWidget *widget, GdkEventKey *event, gpointer data)
static void
item_edit_popup_toggled (GtkToggleButton *button, gpointer data)
{
ItemEdit *item_edit = ITEM_EDIT(data);
ItemEdit *item_edit = ITEM_EDIT (data);
item_edit->show_popup = gtk_toggle_button_get_active (button);
@@ -940,48 +948,6 @@ item_edit_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
item_edit_set_editor (item_edit, GTK_VALUE_POINTER (*arg));
break;
case ARG_IS_COMBO:
item_edit->is_combo = GTK_VALUE_BOOL (*arg);
if (!item_edit->is_combo)
{
item_edit->show_popup = FALSE;
disconnect_popup_toggle_signals (item_edit);
item_edit_hide_popup (item_edit);
item_edit_hide_popup_toggle (item_edit);
}
else
{
g_assert (!item_edit->is_date);
connect_popup_toggle_signals (item_edit);
}
item_edit_configure (item_edit);
break;
case ARG_IS_DATE:
item_edit->is_date = GTK_VALUE_BOOL (*arg);
if (!item_edit->is_date)
{
item_edit->show_popup = FALSE;
disconnect_popup_toggle_signals (item_edit);
item_edit_hide_popup (item_edit);
item_edit_hide_popup_toggle (item_edit);
}
else
{
g_assert (!item_edit->is_combo);
connect_popup_toggle_signals (item_edit);
}
item_edit_configure (item_edit);
break;
default:
break;
}
@@ -1006,10 +972,6 @@ item_edit_class_init (ItemEditClass *item_edit_class)
GTK_ARG_WRITABLE, ARG_SHEET);
gtk_object_add_arg_type ("ItemEdit::GtkEntry", GTK_TYPE_POINTER,
GTK_ARG_WRITABLE, ARG_GTK_ENTRY);
gtk_object_add_arg_type ("ItemEdit::is_combo", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_IS_COMBO);
gtk_object_add_arg_type ("ItemEdit::is_date", GTK_TYPE_BOOL,
GTK_ARG_WRITABLE, ARG_IS_DATE);
object_class->set_arg = item_edit_set_arg;
object_class->destroy = item_edit_destroy;
@@ -1140,7 +1102,6 @@ item_edit_show_popup (ItemEdit *item_edit)
{
GtkToggleButton *toggle;
GtkAnchorType popup_anchor;
GnomeCanvasItem *item;
GnucashSheet *sheet;
gint x, y, w, h;
gint y_offset;
@@ -1153,18 +1114,12 @@ item_edit_show_popup (ItemEdit *item_edit)
g_return_if_fail (item_edit != NULL);
g_return_if_fail (IS_ITEM_EDIT(item_edit));
if (!item_edit->is_combo && !item_edit->is_date)
return;
if (item_edit->is_combo && !item_edit->item_list)
return;
if (item_edit->is_date && !item_edit->date_picker)
if (!item_edit->is_popup)
return;
sheet = item_edit->sheet;
view_height = GTK_WIDGET(sheet)->allocation.height;
gnome_canvas_get_scroll_offsets(GNOME_CANVAS(sheet), NULL, &y_offset);
view_height = GTK_WIDGET (sheet)->allocation.height;
gnome_canvas_get_scroll_offsets (GNOME_CANVAS(sheet), NULL, &y_offset);
item_edit_get_pixel_coords (item_edit, &x, &y, &w, &h);
popup_x = x;
@@ -1185,36 +1140,16 @@ item_edit_show_popup (ItemEdit *item_edit)
popup_height = down_height;
}
if (item_edit->is_combo)
{
if (up_height > down_height)
popup_height = up_height;
else
popup_height = down_height;
if (item_edit->get_popup_height)
popup_height = item_edit->get_popup_height
(item_edit->popup_item, popup_height, h,
item_edit->popup_user_data);
popup_height = (popup_height / h) * h;
if (item_edit->popup_autosize)
item_edit->popup_autosize (item_edit->popup_item,
item_edit->popup_user_data);
item = GNOME_CANVAS_ITEM(item_edit->item_list);
}
else
{
GtkWidget *cal = GTK_WIDGET (item_edit->date_picker->calendar);
GtkRequisition req;
req.height = 0;
req.width = 0;
gtk_widget_size_request (cal, &req);
popup_height = req.height;
item = GNOME_CANVAS_ITEM (item_edit->date_picker);
}
if (item_edit->is_combo)
gnc_item_list_autosize (item_edit->item_list);
gnome_canvas_item_set (item,
gnome_canvas_item_set (item_edit->popup_item,
"x", (gdouble) popup_x,
"y", (gdouble) popup_y,
"height", (gdouble) popup_height,
@@ -1233,22 +1168,17 @@ item_edit_show_popup (ItemEdit *item_edit)
gtk_arrow_set (item_edit->popup_toggle.arrow,
GTK_ARROW_UP, GTK_SHADOW_OUT);
if (item_edit->is_combo)
gtk_widget_grab_focus
(GTK_WIDGET (item_edit->item_list->clist));
else
gtk_widget_grab_focus
(GTK_WIDGET (item_edit->date_picker->calendar));
if (item_edit->popup_set_focus)
item_edit->popup_set_focus (item_edit->popup_item,
item_edit->popup_user_data);
/* Make sure the popup gets shown/sized correctly */
while (gtk_events_pending())
gtk_main_iteration();
if (item_edit->is_combo)
{
gnc_item_list_autosize (item_edit->item_list);
gnc_item_list_show_selected (item_edit->item_list);
}
if (item_edit->popup_post_show)
item_edit->popup_post_show (item_edit->popup_item,
item_edit->popup_user_data);
}
@@ -1258,17 +1188,11 @@ item_edit_hide_popup (ItemEdit *item_edit)
g_return_if_fail(item_edit != NULL);
g_return_if_fail(IS_ITEM_EDIT(item_edit));
if (item_edit->item_list)
gnome_canvas_item_set
(GNOME_CANVAS_ITEM(item_edit->item_list),
"x", -10000.0, NULL);
else if (item_edit->date_picker)
gnome_canvas_item_set
(GNOME_CANVAS_ITEM(item_edit->date_picker),
"x", -10000.0, NULL);
else
if (!item_edit->is_popup)
return;
gnome_canvas_item_set (item_edit->popup_item, "x", -10000.0, NULL);
gtk_arrow_set (item_edit->popup_toggle.arrow,
GTK_ARROW_DOWN, GTK_SHADOW_IN);
@@ -1278,35 +1202,47 @@ item_edit_hide_popup (ItemEdit *item_edit)
(item_edit->popup_toggle.toggle_button, FALSE);
}
void
item_edit_set_list (ItemEdit *item_edit, GNCItemList *item_list)
item_edit_set_popup (ItemEdit *item_edit,
GnomeCanvasItem *popup_item,
GetPopupHeight get_popup_height,
PopupAutosize popup_autosize,
PopupSetFocus popup_set_focus,
PopupPostShow popup_post_show,
gpointer popup_user_data)
{
g_return_if_fail(IS_ITEM_EDIT(item_edit));
g_return_if_fail((item_list == NULL) || IS_GNC_ITEM_LIST(item_list));
g_return_if_fail (IS_ITEM_EDIT(item_edit));
if (item_edit->is_popup)
item_edit_hide_popup (item_edit);
item_edit->is_popup = popup_item != NULL;
item_edit->popup_item = popup_item;
item_edit->get_popup_height = get_popup_height;
item_edit->popup_autosize = popup_autosize;
item_edit->popup_set_focus = popup_set_focus;
item_edit->popup_post_show = popup_post_show;
item_edit->popup_user_data = popup_user_data;
if (item_edit->is_popup)
connect_popup_toggle_signals (item_edit);
else
{
disconnect_popup_toggle_signals (item_edit);
item_edit_hide_popup (item_edit);
item_edit_hide_popup_toggle (item_edit);
}
item_edit_hide_popup (item_edit);
item_edit->item_list = item_list;
item_edit_update (GNOME_CANVAS_ITEM (item_edit), NULL, NULL, 0);
}
void
item_edit_set_date_picker (ItemEdit *item_edit, GNCDatePicker *gdp)
{
g_return_if_fail(IS_ITEM_EDIT(item_edit));
g_return_if_fail((gdp == NULL) || IS_GNC_DATE_PICKER(gdp));
item_edit_hide_popup (item_edit);
item_edit->date_picker = gdp;
item_edit_update (GNOME_CANVAS_ITEM (item_edit), NULL, NULL, 0);
}
void
item_edit_set_has_selection (ItemEdit *item_edit, gboolean has_selection)
{
g_return_if_fail(item_edit != NULL);
g_return_if_fail(IS_ITEM_EDIT(item_edit));
g_return_if_fail (item_edit != NULL);
g_return_if_fail (IS_ITEM_EDIT (item_edit));
item_edit->has_selection = has_selection;
}

View File

@@ -32,6 +32,21 @@
#define IS_ITEM_EDIT(o) (GTK_CHECK_TYPE((o), item_edit_get_type ()))
typedef int (*GetPopupHeight) (GnomeCanvasItem *item,
int space_available,
int row_height,
gpointer user_data);
typedef void (*PopupAutosize) (GnomeCanvasItem *item,
gpointer user_data);
typedef void (*PopupSetFocus) (GnomeCanvasItem *item,
gpointer user_data);
typedef void (*PopupPostShow) (GnomeCanvasItem *item,
gpointer user_data);
typedef struct _PopupToggle PopupToggle;
struct _PopupToggle
{
@@ -61,14 +76,17 @@ typedef struct
gboolean has_selection;
gboolean is_combo;
gboolean is_date;
gboolean is_popup;
gboolean show_popup;
PopupToggle popup_toggle;
GNCItemList *item_list;
GNCDatePicker *date_picker;
GnomeCanvasItem *popup_item;
GetPopupHeight get_popup_height;
PopupAutosize popup_autosize;
PopupSetFocus popup_set_focus;
PopupPostShow popup_post_show;
gpointer popup_user_data;
GdkGC *gc;
@@ -93,8 +111,13 @@ GnomeCanvasItem *item_edit_new (GnomeCanvasGroup *parent,
GNCItemList * item_edit_new_list (ItemEdit *item_edit);
GNCDatePicker * item_edit_new_date_picker (ItemEdit *item_edit);
void item_edit_set_list (ItemEdit *item_edit, GNCItemList *item_list);
void item_edit_set_date_picker (ItemEdit *item_edit, GNCDatePicker *gdp);
void item_edit_set_popup (ItemEdit *item_edit,
GnomeCanvasItem *popup_item,
GetPopupHeight get_popup_height,
PopupAutosize popup_autosize,
PopupSetFocus popup_set_focus,
PopupPostShow popup_post_show,
gpointer popup_user_data);
void item_edit_show_popup (ItemEdit *item_edit);
void item_edit_hide_popup (ItemEdit *item_edit);

View File

@@ -305,6 +305,27 @@ gnc_table_get_align (Table *table, VirtualLocation virt_loc)
/* ==================================================== */
gboolean
gnc_table_is_popup (Table *table, VirtualLocation virt_loc)
{
VirtualCell *vcell;
CellBlockCell *cb_cell;
vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
if (vcell == NULL)
return FALSE;
cb_cell = gnc_cellblock_get_cell (vcell->cellblock,
virt_loc.phys_row_offset,
virt_loc.phys_col_offset);
if (cb_cell == NULL || cb_cell->cell == NULL)
return FALSE;
return cb_cell->cell->is_popup;
}
/* ==================================================== */
void
gnc_table_set_size (Table * table, int virt_rows, int virt_cols)
{

View File

@@ -302,6 +302,8 @@ void gnc_table_get_borders (Table *table, VirtualLocation virt_loc,
CellAlignment gnc_table_get_align (Table *table, VirtualLocation virt_loc);
gboolean gnc_table_is_popup (Table *table, VirtualLocation virt_loc);
/* Return the virtual cell of the header */
VirtualCell * gnc_table_get_header_cell (Table *table);