mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
More work on XIM input.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3441 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9de772e1cc
commit
ed71e80133
@ -329,7 +329,7 @@ xaccSRSetData(SplitRegister *reg, void *user_data,
|
||||
SRGetParentCallback get_parent,
|
||||
SRSetHelpCallback set_help)
|
||||
{
|
||||
SRInfo *info = xaccSRGetInfo(reg);
|
||||
SRInfo *info = xaccSRGetInfo (reg);
|
||||
|
||||
g_return_if_fail (reg != NULL);
|
||||
|
||||
@ -339,19 +339,19 @@ xaccSRSetData(SplitRegister *reg, void *user_data,
|
||||
}
|
||||
|
||||
void
|
||||
xaccSRSetAccountSeparator(char separator)
|
||||
xaccSRSetAccountSeparator (char separator)
|
||||
{
|
||||
account_separator = separator;
|
||||
}
|
||||
|
||||
void
|
||||
xaccSRSetReverseBalanceCallback(SRReverseBalanceCallback callback)
|
||||
xaccSRSetReverseBalanceCallback (SRReverseBalanceCallback callback)
|
||||
{
|
||||
reverse_balance = callback;
|
||||
}
|
||||
|
||||
static int
|
||||
gnc_trans_split_index(Transaction *trans, Split *split)
|
||||
gnc_trans_split_index (Transaction *trans, Split *split)
|
||||
{
|
||||
GList *node;
|
||||
int i;
|
||||
@ -403,15 +403,14 @@ gnc_copy_trans_onto_trans(Transaction *from, Transaction *to,
|
||||
}
|
||||
|
||||
static Split *
|
||||
gnc_find_split_in_trans_by_memo(Transaction *trans, const char *memo,
|
||||
Transaction *dest_trans, gboolean unit_price)
|
||||
gnc_find_split_in_trans_by_memo (Transaction *trans, const char *memo,
|
||||
Transaction *dest_trans, gboolean unit_price)
|
||||
{
|
||||
int num_splits = xaccTransCountSplits(trans);
|
||||
int i;
|
||||
GList *node;
|
||||
|
||||
for (i = num_splits - 1; i >= 0; i--)
|
||||
for (node = xaccTransGetSplitList (trans); node; node = node->next)
|
||||
{
|
||||
Split *split = xaccTransGetSplit(trans, i);
|
||||
Split *split = node->data;
|
||||
|
||||
if (unit_price)
|
||||
{
|
||||
@ -453,9 +452,9 @@ gnc_find_split_in_account_by_memo(Account *account, const char *memo,
|
||||
|
||||
if (account == NULL) return NULL;
|
||||
|
||||
for(slp = g_list_last(xaccAccountGetSplitList(account));
|
||||
slp;
|
||||
slp = slp->prev)
|
||||
for (slp = g_list_last (xaccAccountGetSplitList (account));
|
||||
slp;
|
||||
slp = slp->prev)
|
||||
{
|
||||
Split *split = slp->data;
|
||||
Transaction *trans = xaccSplitGetParent(split);
|
||||
@ -480,14 +479,14 @@ gnc_find_trans_in_account_by_desc(Account *account, const char *description)
|
||||
|
||||
if (account == NULL) return NULL;
|
||||
|
||||
for(slp = g_list_last(xaccAccountGetSplitList(account));
|
||||
slp;
|
||||
slp = slp->prev)
|
||||
for (slp = g_list_last (xaccAccountGetSplitList (account));
|
||||
slp;
|
||||
slp = slp->prev)
|
||||
{
|
||||
Split *split = slp->data;
|
||||
Transaction *trans = xaccSplitGetParent(split);
|
||||
|
||||
if (safe_strcmp(description, xaccTransGetDescription(trans)) == 0)
|
||||
if (safe_strcmp (description, xaccTransGetDescription (trans)) == 0)
|
||||
return trans;
|
||||
}
|
||||
|
||||
@ -495,8 +494,8 @@ gnc_find_trans_in_account_by_desc(Account *account, const char *description)
|
||||
}
|
||||
|
||||
static Split *
|
||||
gnc_find_split_in_reg_by_memo(SplitRegister *reg, const char *memo,
|
||||
Transaction *dest_tran, gboolean unit_price)
|
||||
gnc_find_split_in_reg_by_memo (SplitRegister *reg, const char *memo,
|
||||
Transaction *dest_tran, gboolean unit_price)
|
||||
{
|
||||
int virt_row, virt_col;
|
||||
int num_rows, num_cols;
|
||||
@ -526,8 +525,8 @@ gnc_find_split_in_reg_by_memo(SplitRegister *reg, const char *memo,
|
||||
if (trans == last_trans)
|
||||
continue;
|
||||
|
||||
split = gnc_find_split_in_trans_by_memo(trans, memo, dest_tran,
|
||||
unit_price);
|
||||
split = gnc_find_split_in_trans_by_memo (trans, memo, dest_tran,
|
||||
unit_price);
|
||||
if (split != NULL)
|
||||
return split;
|
||||
|
||||
@ -538,7 +537,7 @@ gnc_find_split_in_reg_by_memo(SplitRegister *reg, const char *memo,
|
||||
}
|
||||
|
||||
static Transaction *
|
||||
gnc_find_trans_in_reg_by_desc(SplitRegister *reg, const char *description)
|
||||
gnc_find_trans_in_reg_by_desc (SplitRegister *reg, const char *description)
|
||||
{
|
||||
int virt_row, virt_col;
|
||||
int num_rows, num_cols;
|
||||
@ -568,7 +567,7 @@ gnc_find_trans_in_reg_by_desc(SplitRegister *reg, const char *description)
|
||||
if (trans == last_trans)
|
||||
continue;
|
||||
|
||||
if (safe_strcmp(description, xaccTransGetDescription(trans)) == 0)
|
||||
if (safe_strcmp (description, xaccTransGetDescription (trans)) == 0)
|
||||
return trans;
|
||||
|
||||
last_trans = trans;
|
||||
|
@ -133,7 +133,7 @@ item_edit_get_pixel_coords (ItemEdit *item_edit,
|
||||
|
||||
|
||||
static void
|
||||
item_edit_draw_info(ItemEdit *item_edit, int x, int y, TextDrawInfo *info)
|
||||
item_edit_draw_info (ItemEdit *item_edit, int x, int y, TextDrawInfo *info)
|
||||
{
|
||||
SheetBlock *block;
|
||||
SheetBlockStyle *style;
|
||||
@ -275,10 +275,10 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
|
||||
return;
|
||||
|
||||
/* Get the measurements for drawing */
|
||||
item_edit_draw_info(item_edit, x, y, &info);
|
||||
item_edit_draw_info (item_edit, x, y, &info);
|
||||
|
||||
/* Draw the background */
|
||||
gdk_gc_set_foreground(item_edit->gc, info.bg_color);
|
||||
gdk_gc_set_foreground (item_edit->gc, info.bg_color);
|
||||
gdk_draw_rectangle (drawable, item_edit->gc, TRUE,
|
||||
info.bg_rect.x, info.bg_rect.y,
|
||||
info.bg_rect.width, info.bg_rect.height);
|
||||
@ -340,7 +340,28 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
|
||||
|
||||
gdk_gc_set_clip_rectangle (item_edit->gc, NULL);
|
||||
|
||||
item_edit_free_draw_info_members(&info);
|
||||
item_edit_free_draw_info_members (&info);
|
||||
|
||||
#ifdef USE_XIM
|
||||
if (gdk_im_ready() && item_edit->ic &&
|
||||
(gdk_ic_get_style (item_edit->ic) & GDK_IM_PREEDIT_POSITION))
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
double winx, winy;
|
||||
|
||||
item = GNOME_CANVAS_ITEM (item_edit);
|
||||
|
||||
gnome_canvas_world_to_window (GNOME_CANVAS (item_edit->sheet),
|
||||
item->x1, item->y2,
|
||||
&winx, &winy);
|
||||
|
||||
item_edit->ic_attr->spot_location.x = winx;
|
||||
item_edit->ic_attr->spot_location.y = winy;
|
||||
|
||||
gdk_ic_set_attr (item_edit->ic,
|
||||
item_edit->ic_attr, GDK_IC_SPOT_LOCATION);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -357,6 +378,7 @@ item_edit_point (GnomeCanvasItem *item, double c_x, double c_y, int cx, int cy,
|
||||
return 10000.0;
|
||||
|
||||
*actual_item = item;
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@ -464,16 +486,21 @@ item_edit_realize (GnomeCanvasItem *item)
|
||||
|
||||
attrmask |= GDK_IC_PREEDIT_FOREGROUND;
|
||||
attrmask |= GDK_IC_PREEDIT_BACKGROUND;
|
||||
attr->preedit_foreground = sheet_widget->style->fg[GTK_STATE_NORMAL];
|
||||
attr->preedit_background = sheet_widget->style->base[GTK_STATE_NORMAL];
|
||||
|
||||
attr->preedit_foreground =
|
||||
sheet_widget->style->fg[GTK_STATE_NORMAL];
|
||||
attr->preedit_background =
|
||||
sheet_widget->style->base[GTK_STATE_NORMAL];
|
||||
|
||||
switch (style & GDK_IM_PREEDIT_MASK)
|
||||
{
|
||||
case GDK_IM_PREEDIT_POSITION:
|
||||
if (sheet_widget->style &&
|
||||
sheet_widget->style->font->type != GDK_FONT_FONTSET)
|
||||
sheet_widget->style->font->type !=
|
||||
GDK_FONT_FONTSET)
|
||||
{
|
||||
g_warning ("over-the-spot style requires fontset");
|
||||
g_warning ("over-the-spot style "
|
||||
"requires fontset");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -488,7 +515,8 @@ item_edit_realize (GnomeCanvasItem *item)
|
||||
attr->preedit_area.y = 0;
|
||||
attr->preedit_area.width = width;
|
||||
attr->preedit_area.height = height;
|
||||
attr->preedit_fontset = sheet_widget->style->font;
|
||||
attr->preedit_fontset =
|
||||
sheet_widget->style->font;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -539,6 +567,29 @@ item_edit_unrealize (GnomeCanvasItem *item)
|
||||
(item_edit_parent_class)->unrealize) (item);
|
||||
}
|
||||
|
||||
void
|
||||
item_edit_focus_in (ItemEdit *item_edit)
|
||||
{
|
||||
g_return_if_fail (item_edit != NULL);
|
||||
g_return_if_fail (IS_ITEM_EDIT(item_edit));
|
||||
|
||||
#ifdef USE_XIM
|
||||
if (item_edit->ic)
|
||||
gdk_im_begin (item_edit->ic,
|
||||
GTK_WIDGET (item_edit->sheet)->window);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
item_edit_focus_out (ItemEdit *item_edit)
|
||||
{
|
||||
g_return_if_fail (item_edit != NULL);
|
||||
g_return_if_fail (IS_ITEM_EDIT(item_edit));
|
||||
|
||||
#ifdef USE_XIM
|
||||
gdk_im_end ();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Instance initialization
|
||||
@ -606,10 +657,10 @@ queue_sync (ItemEdit *item_edit)
|
||||
void
|
||||
item_edit_redraw (ItemEdit *item_edit)
|
||||
{
|
||||
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));
|
||||
|
||||
queue_sync(item_edit);
|
||||
queue_sync (item_edit);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -805,6 +856,24 @@ item_edit_configure (ItemEdit *item_edit)
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
item_edit_update (GNOME_CANVAS_ITEM(item_edit), NULL, NULL, 0);
|
||||
|
||||
#ifdef USE_XIM
|
||||
if (item_edit->ic &&
|
||||
(gdk_ic_get_style (item_edit->ic) & GDK_IM_PREEDIT_POSITION))
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
|
||||
item = GNOME_CANVAS_ITEM (item_edit);
|
||||
|
||||
item_edit->ic_attr->preedit_area.x = item->x1;
|
||||
item_edit->ic_attr->preedit_area.y = item->y1;
|
||||
item_edit->ic_attr->preedit_area.width = item->x2 - item->x1;
|
||||
item_edit->ic_attr->preedit_area.height = item->y2 - item->y1;
|
||||
|
||||
gdk_ic_set_attr (item_edit->ic, item_edit->ic_attr,
|
||||
GDK_IC_PREEDIT_AREA);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1100,9 +1169,9 @@ item_edit_class_init (ItemEditClass *item_edit_class)
|
||||
item_class->update = item_edit_update;
|
||||
item_class->draw = item_edit_draw;
|
||||
item_class->point = item_edit_point;
|
||||
item_class->event = item_edit_event;
|
||||
item_class->realize = item_edit_realize;
|
||||
item_class->unrealize = item_edit_unrealize;
|
||||
item_class->event = item_edit_event;
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,7 +161,12 @@ void item_edit_selection_received (ItemEdit *item_edit,
|
||||
GtkSelectionData *selection_data,
|
||||
guint time);
|
||||
|
||||
typedef struct {
|
||||
void item_edit_focus_in (ItemEdit *item_edit);
|
||||
void item_edit_focus_out (ItemEdit *item_edit);
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GnomeCanvasItemClass parent_class;
|
||||
} ItemEditClass;
|
||||
|
||||
|
@ -1042,6 +1042,29 @@ gnucash_sheet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
|
||||
gnucash_sheet_update_adjustments (sheet);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnucash_sheet_focus_in_event (GtkWidget *widget, GdkEventFocus *event)
|
||||
{
|
||||
GnucashSheet *sheet = GNUCASH_SHEET(widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS(sheet_parent_class)->focus_in_event)
|
||||
(*GTK_WIDGET_CLASS (sheet_parent_class)->focus_in_event)
|
||||
(widget, event);
|
||||
|
||||
item_edit_focus_in (ITEM_EDIT(sheet->item_editor));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnucash_sheet_focus_out_event (GtkWidget *widget, GdkEventFocus *event)
|
||||
{
|
||||
GnucashSheet *sheet = GNUCASH_SHEET(widget);
|
||||
|
||||
if (GTK_WIDGET_CLASS(sheet_parent_class)->focus_out_event)
|
||||
(*GTK_WIDGET_CLASS (sheet_parent_class)->focus_out_event)
|
||||
(widget, event);
|
||||
|
||||
item_edit_focus_out (ITEM_EDIT(sheet->item_editor));
|
||||
}
|
||||
|
||||
static void
|
||||
gnucash_sheet_start_editing_at_cursor (GnucashSheet *sheet)
|
||||
@ -2081,6 +2104,9 @@ gnucash_sheet_class_init (GnucashSheetClass *class)
|
||||
widget_class->size_request = gnucash_sheet_size_request;
|
||||
widget_class->size_allocate = gnucash_sheet_size_allocate;
|
||||
|
||||
widget_class->focus_in_event = gnucash_sheet_focus_in_event;
|
||||
widget_class->focus_out_event = gnucash_sheet_focus_out_event;
|
||||
|
||||
widget_class->key_press_event = gnucash_sheet_key_press_event;
|
||||
widget_class->button_press_event = gnucash_button_press_event;
|
||||
widget_class->button_release_event = gnucash_button_release_event;
|
||||
|
Loading…
Reference in New Issue
Block a user