Commit 2f93825e authored by jaycox's avatar jaycox

----------------------------------------------------------------------


 ----------------------------------------------------------------------
 Modified Files:
 	ChangeLog app/brush_select.c
 	app/gimpbrush.c app/gimpbrush.h app/gimpbrushgenerated.c
 	app/gimpbrushlist.c app/gimpbrushlist.h
     removed the index field from GimpBrush.  tweaked the brush renaming
     code

	app/edit_selection.c:
     look ahead in the event queue and process as many arrow keys as we
     can.
 ----------------------------------------------------------------------
parent 33cc34dd
Sun Jul 19 15:26:11 PDT 1998 Jay Cox <jaycox@eartlink.net>
Mon Jul 20 06:27:18 PDT 1998 Jay Cox <jaycox@earthlink.net>
* app/brush_select.c app/gimpbrush.c app/gimpbrush.h
* app/gimpbrushgenerated.c app/gimpbrushlist.c
* app/gimpbrushlist.h
Removed the index field from GimpBrush. Tweaked the
brush renameing code.
* app/edit_selection.c
Look ahead in the event queue and process as many arrow
keys as we can at once.
Sun Jul 19 15:26:11 PDT 1998 Jay Cox <jaycox@earthlink.net>
* app/brush_select.c
recalc the scrollbar when a brush is added/removed.
......
......@@ -339,7 +339,8 @@ brush_select_new ()
{
int old_value = bsp->redraw;
bsp->redraw = FALSE;
brush_select_select (bsp, active->index);
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
bsp->redraw = old_value;
}
......@@ -791,7 +792,7 @@ brush_select_events (GtkWidget *widget,
index = row * NUM_BRUSH_COLUMNS + col;
/* Get the brush and display the popup brush preview */
if ((brush = get_brush_by_index (index)))
if ((brush = gimp_brush_list_get_brush_by_index (brush_list, index)))
{
gdk_pointer_grab (bsp->preview->window, FALSE,
(GDK_POINTER_MOTION_HINT_MASK |
......@@ -913,7 +914,8 @@ brush_select_refresh_callback (GtkWidget *w,
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
/* recalculate scrollbar extents */
preview_calc_scrollbar (bsp);
......@@ -935,7 +937,7 @@ preview_scroll_update (GtkAdjustment *adjustment,
{
BrushSelectP bsp;
GimpBrushP active;
int row, col;
int row, col, index;
bsp = data;
......@@ -947,8 +949,9 @@ preview_scroll_update (GtkAdjustment *adjustment,
active = get_active_brush ();
if (active)
{
row = active->index / NUM_BRUSH_COLUMNS;
col = active->index - row * NUM_BRUSH_COLUMNS;
index = gimp_brush_list_get_brush_index(brush_list, active);
row = index / NUM_BRUSH_COLUMNS;
col = index - row * NUM_BRUSH_COLUMNS;
brush_select_show_selected (bsp, row, col);
}
......
......@@ -77,7 +77,6 @@ gimp_brush_init(GimpBrush *brush)
brush->filename = NULL;
brush->name = NULL;
brush->spacing = 20;
brush->index = 0;
brush->mask = NULL;
}
......@@ -123,7 +122,9 @@ gimp_brush_get_name (GimpBrush *brush)
void
gimp_brush_set_name (GimpBrush *brush, char *name)
{
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
g_return_if_fail(GIMP_IS_BRUSH(brush));
if (strcmp(brush->name, name) == 0)
return;
if (brush->name)
g_free(brush->name);
brush->name = g_strdup(name);
......
......@@ -77,7 +77,6 @@ gimp_brush_init(GimpBrush *brush)
brush->filename = NULL;
brush->name = NULL;
brush->spacing = 20;
brush->index = 0;
brush->mask = NULL;
}
......@@ -123,7 +122,9 @@ gimp_brush_get_name (GimpBrush *brush)
void
gimp_brush_set_name (GimpBrush *brush, char *name)
{
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
g_return_if_fail(GIMP_IS_BRUSH(brush));
if (strcmp(brush->name, name) == 0)
return;
if (brush->name)
g_free(brush->name);
brush->name = g_strdup(name);
......
......@@ -30,7 +30,6 @@ struct _GimpBrush
char * filename; /* actual filename--brush's location on disk */
char * name; /* brush's name--for brush selection dialog */
int spacing; /* brush's spacing */
int index; /* brush's index... */
TempBuf * mask; /* the actual mask... */
};
......
......@@ -224,7 +224,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
{
temp_buf_free(gbrush->mask);
}
/* compute the range of the brush, should do a better job than this */
/* compute the range of the brush. should do a better job than this? */
s = sin(brush->angle*M_PI/180.0);
c = cos(brush->angle*M_PI/180.0);
tx = MAXIMUM(fabs(c*ceil(brush->radius) - s*ceil(brush->radius)
......@@ -238,7 +238,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
if (brush->radius > tx)
width = ceil(tx);
else
width = ceil(brush->radius+1);
width = ceil(brush->radius);
if (brush->radius > ty)
height = ceil(ty);
else
......
......@@ -224,7 +224,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
{
temp_buf_free(gbrush->mask);
}
/* compute the range of the brush, should do a better job than this */
/* compute the range of the brush. should do a better job than this? */
s = sin(brush->angle*M_PI/180.0);
c = cos(brush->angle*M_PI/180.0);
tx = MAXIMUM(fabs(c*ceil(brush->radius) - s*ceil(brush->radius)
......@@ -238,7 +238,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
if (brush->radius > tx)
width = ceil(tx);
else
width = ceil(brush->radius+1);
width = ceil(brush->radius);
if (brush->radius > ty)
height = ceil(ty);
else
......
......@@ -224,7 +224,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
{
temp_buf_free(gbrush->mask);
}
/* compute the range of the brush, should do a better job than this */
/* compute the range of the brush. should do a better job than this? */
s = sin(brush->angle*M_PI/180.0);
c = cos(brush->angle*M_PI/180.0);
tx = MAXIMUM(fabs(c*ceil(brush->radius) - s*ceil(brush->radius)
......@@ -238,7 +238,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
if (brush->radius > tx)
width = ceil(tx);
else
width = ceil(brush->radius+1);
width = ceil(brush->radius);
if (brush->radius > ty)
height = ceil(ty);
else
......
......@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdarg.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "draw_core.h"
......@@ -475,13 +476,87 @@ edit_selection_cursor_update (Tool *tool,
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
}
static int
process_event_queue_keys(GdkEventKey *kevent, ...)
/* GdkKeyType, GdkModifierType, value ... 0
* could move this function to a more central location so it can be used
* by other tools? */
{
#define FILTER_MAX_KEYS 50
va_list argp;
GdkEvent *event;
GList *list = NULL;
guint keys[FILTER_MAX_KEYS];
GdkModifierType modifiers[FILTER_MAX_KEYS];
int values[FILTER_MAX_KEYS];
int i = 0, nkeys = 0, value = 0, done = 0, discard_event;
GtkWidget *orig_widget;
va_start(argp, kevent);
while (nkeys <FILTER_MAX_KEYS && (keys[nkeys] = va_arg (argp, guint)) != 0)
{
modifiers[nkeys] = va_arg (argp, GdkModifierType);
values[nkeys] = va_arg (argp, int);
nkeys++;
}
va_end(argp);
for (i = 0; i < nkeys; i++)
if (kevent->keyval == keys[i] && kevent->state == modifiers[i])
value += values[i];
orig_widget = gtk_get_event_widget((GdkEvent*)kevent);
while (gdk_events_pending() > 0 && !done)
{
discard_event = 0;
event = gdk_event_get();
if (orig_widget != gtk_get_event_widget(event))
{
done = 1;
}
else
{
if (event->any.type == GDK_KEY_PRESS)
{
for (i = 0; i < nkeys; i++)
if (event->key.keyval == keys[i] &&
event->key.state == modifiers[i])
{
discard_event = 1;
value += values[i];
}
if (!discard_event)
done = 1;
}
/* should there be more types here? */
else if (event->any.type != GDK_KEY_RELEASE &&
event->any.type != GDK_MOTION_NOTIFY &&
event->any.type != GDK_EXPOSE)
done = 1;
}
if (!discard_event)
list = g_list_prepend(list, event);
else
gdk_event_free(event);
}
while (list) /* unget the unused events and free the list */
{
gdk_event_put((GdkEvent*)list->data);
gdk_event_free((GdkEvent*)list->data);
list = g_list_remove_link (list, list);
}
return value;
#undef FILTER_MAX_KEYS
}
void
edit_sel_arrow_keys_func (Tool *tool,
GdkEventKey *kevent,
gpointer gdisp_ptr)
{
int inc_x, inc_y;
int inc_x, inc_y, mask_inc_x, mask_inc_y;
GDisplay *gdisp;
Layer *layer;
Layer *floating_layer;
......@@ -492,87 +567,94 @@ edit_sel_arrow_keys_func (Tool *tool,
gdisp = (GDisplay *) gdisp_ptr;
inc_x = inc_y = 0;
inc_x = process_event_queue_keys(kevent,
GDK_Left, 0, -1,
GDK_Left, GDK_SHIFT_MASK, -1*ARROW_VELOCITY,
GDK_Right, 0, 1,
GDK_Right, GDK_SHIFT_MASK, ARROW_VELOCITY,
0);
inc_y = process_event_queue_keys(kevent,
GDK_Up, 0, -1,
GDK_Up, GDK_SHIFT_MASK, -1*ARROW_VELOCITY,
GDK_Down, 0, 1,
GDK_Down, GDK_SHIFT_MASK, ARROW_VELOCITY,
0);
mask_inc_x = process_event_queue_keys(kevent,
GDK_Left, GDK_MOD1_MASK, -1,
GDK_Left, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
-1*ARROW_VELOCITY,
GDK_Right, GDK_MOD1_MASK, 1,
GDK_Right, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
ARROW_VELOCITY,
0);
mask_inc_y = process_event_queue_keys(kevent,
GDK_Up, GDK_MOD1_MASK, -1,
GDK_Up, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
-1*ARROW_VELOCITY,
GDK_Down, GDK_MOD1_MASK, 1,
GDK_Down, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
ARROW_VELOCITY,
0);
if (inc_x == 0 && inc_y == 0 && mask_inc_x == 0 && mask_inc_y == 0)
return;
switch (kevent->keyval)
{
case GDK_Up : inc_y = -1; break;
case GDK_Left : inc_x = -1; break;
case GDK_Right : inc_x = 1; break;
case GDK_Down : inc_y = 1; break;
}
undo_push_group_start (gdisp->gimage, MISC_UNDO);
/* If the shift key is down, move by an accelerated increment */
if (kevent->state & GDK_SHIFT_MASK)
{
inc_y *= ARROW_VELOCITY;
inc_x *= ARROW_VELOCITY;
}
if (mask_inc_x != 0 || mask_inc_y != 0)
gimage_mask_translate (gdisp->gimage, mask_inc_x, mask_inc_y);
if (kevent->state & GDK_MOD1_MASK)
edit_type = MaskTranslate;
else
{
layer = gimage_get_active_layer (gdisp->gimage);
if (layer_is_floating_sel (layer))
edit_type = FloatingSelTranslate;
else
edit_type = LayerTranslate;
}
if (inc_x != 0 || inc_y != 0)
{
layer = gimage_get_active_layer (gdisp->gimage);
if (layer_is_floating_sel (layer))
edit_type = FloatingSelTranslate;
else
edit_type = LayerTranslate;
switch (edit_type)
switch (edit_type)
{
case MaskTranslate:
/* translate the selection */
gimage_mask_translate (gdisp->gimage, inc_x, inc_y);
break;
case MaskToLayerTranslate:
gimage_mask_float (gdisp->gimage,
gimage_active_drawable (gdisp->gimage),
inc_x, inc_y);
break;
case MaskToLayerTranslate:
gimage_mask_float (gdisp->gimage,
gimage_active_drawable (gdisp->gimage),
inc_x, inc_y);
break;
case LayerTranslate:
if ((floating_layer = gimage_floating_sel (gdisp->gimage)))
floating_sel_relax (floating_layer, TRUE);
case LayerTranslate:
/* Push a linked undo group */
undo_push_group_start (gdisp->gimage, LINKED_LAYER_UNDO);
/* translate the layer--and any "linked" layers as well */
layer_list = gdisp->gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (((layer) == gdisp->gimage->active_layer) || layer_linked (layer))
layer_translate (layer, inc_x, inc_y);
layer_list = g_slist_next (layer_list);
}
if ((floating_layer = gimage_floating_sel (gdisp->gimage)))
floating_sel_relax (floating_layer, TRUE);
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
/* translate the layer--and any "linked" layers as well */
layer_list = gdisp->gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (((layer) == gdisp->gimage->active_layer) || layer_linked (layer))
layer_translate (layer, inc_x, inc_y);
layer_list = g_slist_next (layer_list);
}
if (floating_layer)
floating_sel_rigor (floating_layer, TRUE);
/* End the linked undo group */
undo_push_group_end (gdisp->gimage);
break;
break;
case FloatingSelTranslate:
undo_push_group_start (gdisp->gimage, LINKED_LAYER_UNDO);
case FloatingSelTranslate:
floating_sel_relax (layer, TRUE);
floating_sel_relax (layer, TRUE);
layer_translate (layer, inc_x, inc_y);
layer_translate (layer, inc_x, inc_y);
floating_sel_rigor (layer, TRUE);
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gdisp->gimage);
break;
break;
default:
/* this won't occur */
break;
default:
/* this won't occur */
break;
}
}
undo_push_group_end (gdisp->gimage);
gdisplays_flush ();
}
......@@ -77,7 +77,6 @@ gimp_brush_init(GimpBrush *brush)
brush->filename = NULL;
brush->name = NULL;
brush->spacing = 20;
brush->index = 0;
brush->mask = NULL;
}
......@@ -123,7 +122,9 @@ gimp_brush_get_name (GimpBrush *brush)
void
gimp_brush_set_name (GimpBrush *brush, char *name)
{
g_return_val_if_fail(GIMP_IS_BRUSH(brush), NULL);
g_return_if_fail(GIMP_IS_BRUSH(brush));
if (strcmp(brush->name, name) == 0)
return;
if (brush->name)
g_free(brush->name);
brush->name = g_strdup(name);
......
......@@ -30,7 +30,6 @@ struct _GimpBrush
char * filename; /* actual filename--brush's location on disk */
char * name; /* brush's name--for brush selection dialog */
int spacing; /* brush's spacing */
int index; /* brush's index... */
TempBuf * mask; /* the actual mask... */
};
......
......@@ -224,7 +224,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
{
temp_buf_free(gbrush->mask);
}
/* compute the range of the brush, should do a better job than this */
/* compute the range of the brush. should do a better job than this? */
s = sin(brush->angle*M_PI/180.0);
c = cos(brush->angle*M_PI/180.0);
tx = MAXIMUM(fabs(c*ceil(brush->radius) - s*ceil(brush->radius)
......@@ -238,7 +238,7 @@ gimp_brush_generated_generate(GimpBrushGenerated *brush)
if (brush->radius > tx)
width = ceil(tx);
else
width = ceil(brush->radius+1);
width = ceil(brush->radius);
if (brush->radius > ty)
height = ceil(ty);
else
......
......@@ -63,7 +63,6 @@ static int have_default_brush = 0;
static void create_default_brush (void);
static gint brush_compare_func (gconstpointer, gconstpointer);
static void gimp_brush_list_recalc_indexes(GimpBrushList *brush_list);
static void brush_load (char *filename);
/* class functions */
......@@ -145,8 +144,6 @@ brushes_init (int no_data)
create_default_brush ();
else
datafiles_read_directories (brush_path,(datafile_loader_t)brush_load, 0);
gimp_brush_list_recalc_indexes(brush_list);
}
static void
......@@ -236,8 +233,26 @@ create_default_brush ()
int
gimp_brush_list_get_brush_index (GimpBrushList *brush_list,
GimpBrush *brush)
{
int index = 0;
GSList *list;
/* fix me: make a gimp_list function that does this? */
list = GIMP_LIST(brush_list)->list;
while (list)
{
if (list->data == brush)
return index;
index++;
list = list->next;
}
return -1;
}
GimpBrush *
get_brush_by_index (int index)
gimp_brush_list_get_brush_by_index (GimpBrushList *brush_list, int index)
{
GSList *list;
GimpBrush * brush = NULL;
......@@ -249,24 +264,11 @@ get_brush_by_index (int index)
return brush;
}
static void gimp_brush_do_indexes(GimpBrush *brush, int *index)
{
brush->index = (*index)++;
}
static void
gimp_brush_list_recalc_indexes(GimpBrushList *brush_list)
{
int index = 0;
gimp_list_foreach (GIMP_LIST(brush_list), (GFunc)gimp_brush_do_indexes,
&index);
}
static void
gimp_brush_list_uniquefy_brush_name(GimpBrushList *brush_list,
GimpBrush *brush)
{
GSList *list;
GSList *list, *listb;
GimpBrush *brushb;
int number = 1;
char *newname;
......@@ -300,8 +302,28 @@ gimp_brush_list_uniquefy_brush_name(GimpBrushList *brush_list,
ext = &newname[strlen(newname)];
}
sprintf(ext, "#%d", number+1);
listb = GIMP_LIST(brush_list)->list;
while (listb) /* make sure the new name is unique */
{
brushb = GIMP_BRUSH(listb->data);
if (brush != brushb && strcmp(newname,
gimp_brush_get_name(brushb)) == 0)
{
number++;
sprintf(ext, "#%d", number+1);
listb = GIMP_LIST(brush_list)->list;
}
listb = listb->next;
}
gimp_brush_set_name(brush, newname);
g_free(newname);
if (gimp_list_have(GIMP_LIST(brush_list), brush))
{ /* ought to have a better way than this to resort the brush */
gtk_object_ref(GTK_OBJECT(brush));
gimp_brush_list_remove(brush_list, brush);
gimp_brush_list_add(brush_list, brush);
gtk_object_unref(GTK_OBJECT(brush));
}
return;
}
list = list->next;
......@@ -316,12 +338,11 @@ static void brush_renamed(GimpBrush *brush, GimpBrushList *brush_list)
void
gimp_brush_list_add (GimpBrushList *brush_list, GimpBrush * brush)
{
gimp_brush_list_uniquefy_brush_name(brush_list, brush);
gimp_list_add(GIMP_LIST(brush_list), brush);
gtk_object_sink(GTK_OBJECT(brush));
gtk_signal_connect(GTK_OBJECT(brush), "rename",
(GtkSignalFunc)brush_renamed, brush_list);
gimp_brush_list_recalc_indexes(brush_list); /* ugh */
gimp_brush_list_uniquefy_brush_name(brush_list, brush);
}
void
......@@ -329,7 +350,6 @@ gimp_brush_list_remove (GimpBrushList *brush_list, GimpBrush * brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(brush), brush_list);
gimp_list_remove(GIMP_LIST(brush_list), brush);
gimp_brush_list_recalc_indexes(brush_list);
}
int
......@@ -379,7 +399,8 @@ select_brush (GimpBrush * brush)
/* Keep up appearances in the brush dialog */
if (brush_select_dialog)
brush_select_select (brush_select_dialog, brush->index);
brush_select_select (brush_select_dialog,
gimp_brush_list_get_brush_index(brush_list, brush));
device_status_update (current_device);
}
......
......@@ -32,7 +32,9 @@
GimpBrushList *gimp_brush_list_new (void);
GtkType gimp_brush_list_get_type (void);
void gimp_brush_list_add (GimpBrushList *list,
GimpBrush *brush);
GimpBrush *brush);
void gimp_brush_list_remove (GimpBrushList *list,
GimpBrush *brush);
GimpBrushP gimp_brush_list_get_brush(GimpBrushList *list, char *name);
int gimp_brush_list_length (GimpBrushList *list);
......@@ -46,7 +48,8 @@ void brushes_init (int no_data);
void brushes_free (void);
void brush_select_dialog_free (void);
void select_brush (GimpBrushP);
GimpBrushP get_brush_by_index (int);
GimpBrushP gimp_brush_list_get_brush_by_index (GimpBrushList *, int);
int gimp_brush_list_get_brush_index (GimpBrushList *, GimpBrush *);
GimpBrushP get_active_brush (void);
/* TODO: {re}move this function */
......
......@@ -339,7 +339,8 @@ brush_select_new ()
{
int old_value = bsp->redraw;
bsp->redraw = FALSE;
brush_select_select (bsp, active->index);
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
bsp->redraw = old_value;
}
......@@ -791,7 +792,7 @@ brush_select_events (GtkWidget *widget,
index = row * NUM_BRUSH_COLUMNS + col;
/* Get the brush and display the popup brush preview */
if ((brush = get_brush_by_index (index)))
if ((brush = gimp_brush_list_get_brush_by_index (brush_list, index)))
{
gdk_pointer_grab (bsp->preview->window, FALSE,
(GDK_POINTER_MOTION_HINT_MASK |
......@@ -913,7 +914,8 @@ brush_select_refresh_callback (GtkWidget *w,
/* update the active selection */
active = get_active_brush ();
if (active)
brush_select_select (bsp, active->index);
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
/* recalculate scrollbar extents */
preview_calc_scrollbar (bsp);
......@@ -935,7 +937,7 @@ preview_scroll_update (GtkAdjustment *adjustment,
{
BrushSelectP bsp;
GimpBrushP active;
int row, col;
int row, col, index;
bsp = data;
......@@ -947,8 +949,9 @@ preview_scroll_update (GtkAdjustment *adjustment,
active = get_active_brush ();
if (active)
{
row = active->index / NUM_BRUSH_COLUMNS;
col = active->index - row * NUM_BRUSH_COLUMNS;
index = gimp_brush_list_get_brush_index(brush_list, active);
row = index / NUM_BRUSH_COLUMNS;
col = index - row * NUM_BRUSH_COLUMNS;
brush_select_show_selected (bsp, row, col);
}
......
......@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdarg.h>
#include "gdk/gdkkeysyms.h"
#include "appenv.h"
#include "draw_core.h"
......@@ -475,13 +476,87 @@ edit_selection_cursor_update (Tool *tool,
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
}
static int
process_event_queue_keys(GdkEventKey *kevent, ...)
/* GdkKeyType, GdkModifierType, value ... 0
* could move this function to a more central location so it can be used
* by other tools? */
{
#define FILTER_MAX_KEYS 50
va_list argp;
GdkEvent *event;
GList *list = NULL;
guint keys[FILTER_MAX_KEYS];
GdkModifierType modifiers[FILTER_MAX_KEYS];
int values[FILTER_MAX_KEYS];
int i = 0, nkeys = 0, value = 0, done = 0, discard_event;
GtkWidget *orig_widget;
va_start(argp, kevent);
while (nkeys <FILTER_MAX_KEYS && (keys[nkeys] = va_arg (argp, guint)) != 0)
{
modifiers[nkeys] = va_arg (argp, GdkModifierType);
values[nkeys] = va_arg (argp, int);
nkeys++;
}
va_end(argp);
for (i = 0; i < nkeys; i++)
if (kevent->keyval == keys[i] && kevent->state == modifiers[i])
value += values[i];
orig_widget = gtk_get_event_widget((GdkEvent*)kevent);
while (gdk_events_pending() > 0 && !done)
{
discard_event = 0;
event = gdk_event_get();
if (orig_widget != gtk_get_event_widget(event))
{
done = 1;
}
else
{
if (event->any.type == GDK_KEY_PRESS)
{
for (i = 0; i < nkeys; i++)
if (event->key.keyval == keys[i] &&
event->key.state == modifiers[i])
{
discard_event = 1;
value += values[i];
}
if (!discard_event)
done = 1;
}
/* should there be more types here? */
else if (event->any.type != GDK_KEY_RELEASE &&