Mercurial > geeqie
changeset 868:db6977f8b0f1
Reduce number of parameters (mostly unused), just pass the event pointer.
author | zas_ |
---|---|
date | Sat, 28 Jun 2008 07:43:37 +0000 |
parents | 5169bd198d5a |
children | 371a1c3d4504 |
files | src/image.c src/image.h src/img-view.c src/info.c src/layout_image.c src/typedefs.h |
diffstat | 6 files changed, 64 insertions(+), 82 deletions(-) [+] |
line wrap: on
line diff
--- a/src/image.c Sat Jun 28 00:44:31 2008 +0000 +++ b/src/image.c Sat Jun 28 07:43:37 2008 +0000 @@ -67,8 +67,7 @@ if (imd->func_button) { - imd->func_button(imd, event->button, event->time, - event->x, event->y, event->state, imd->data_button); + imd->func_button(imd, event, imd->data_button); } } @@ -81,10 +80,10 @@ if (imd->func_drag) { - imd->func_drag(imd, event->button, event->time, - event->x, event->y, event->state, - (gfloat)(pr->drag_last_x - event->x) / width, (gfloat)(pr->drag_last_y - event->y) / height, - imd->data_button); + imd->func_drag(imd, event, + (gfloat)(pr->drag_last_x - event->x) / width, + (gfloat)(pr->drag_last_y - event->y) / height, + imd->data_button); } } @@ -880,8 +879,7 @@ if (imd->func_scroll && event && event->type == GDK_SCROLL) { - imd->func_scroll(imd, event->direction, event->time, - event->x, event->y, event->state, imd->data_scroll); + imd->func_scroll(imd, event, imd->data_scroll); return TRUE; } @@ -937,7 +935,7 @@ void image_set_button_func(ImageWindow *imd, - void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer), + void (*func)(ImageWindow *, GdkEventButton *event, gpointer), gpointer data) { imd->func_button = func; @@ -945,7 +943,7 @@ } void image_set_drag_func(ImageWindow *imd, - void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer), + void (*func)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer), gpointer data) { imd->func_drag = func; @@ -953,7 +951,7 @@ } void image_set_scroll_func(ImageWindow *imd, - void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer), + void (*func)(ImageWindow *, GdkEventScroll *event, gpointer), gpointer data) { imd->func_scroll = func;
--- a/src/image.h Sat Jun 28 00:44:31 2008 +0000 +++ b/src/image.h Sat Jun 28 07:43:37 2008 +0000 @@ -25,13 +25,13 @@ void (*func)(ImageWindow *imd, gpointer data), gpointer data); void image_set_button_func(ImageWindow *imd, - void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gpointer), + void (*func)(ImageWindow *, GdkEventButton *event, gpointer), gpointer data); void image_set_drag_func(ImageWindow *imd, - void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer), + void (*func)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer), gpointer data); void image_set_scroll_func(ImageWindow *imd, - void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer), + void (*func)(ImageWindow *, GdkEventScroll *event, gpointer), gpointer data); void image_set_scroll_notify_func(ImageWindow *imd, void (*func)(ImageWindow *imd, gint x, gint y, gint width, gint height, gpointer data),
--- a/src/img-view.c Sat Jun 28 00:44:31 2008 +0000 +++ b/src/img-view.c Sat Jun 28 07:43:37 2008 +0000 @@ -597,14 +597,12 @@ * view window main routines *----------------------------------------------------------------------------- */ - -static void button_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) { ViewWindow *vw = data; GtkWidget *menu; - switch (button) + switch (event->button) { case MOUSE_BUTTON_LEFT: view_step_next(vw); @@ -614,35 +612,34 @@ break; case MOUSE_BUTTON_RIGHT: menu = view_popup_menu(vw); - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); break; default: break; } } -static void scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void scroll_cb(ImageWindow *imd, GdkEventScroll *event, gpointer data) { ViewWindow *vw = data; - if (state & GDK_CONTROL_MASK) + if (event->state & GDK_CONTROL_MASK) { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: - image_zoom_adjust_at_point(imd, get_zoom_increment(), x, y); + image_zoom_adjust_at_point(imd, get_zoom_increment(), event->x, event->y); break; case GDK_SCROLL_DOWN: - image_zoom_adjust_at_point(imd, -get_zoom_increment(), x, y); + image_zoom_adjust_at_point(imd, -get_zoom_increment(), event->x, event->y); break; default: break; } } - else if ( (state & GDK_SHIFT_MASK) != (guint) (options->mousewheel_scrolls)) + else if ( (event->state & GDK_SHIFT_MASK) != (guint) (options->mousewheel_scrolls)) { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); @@ -662,7 +659,7 @@ } else { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: view_step_prev(vw);
--- a/src/info.c Sat Jun 28 00:44:31 2008 +0000 +++ b/src/info.c Sat Jun 28 07:43:37 2008 +0000 @@ -765,27 +765,25 @@ gtk_widget_set_sensitive(id->button_back, TRUE); } -static void info_window_image_button_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void info_window_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) { - if (button == MOUSE_BUTTON_LEFT) + if (event->button == MOUSE_BUTTON_LEFT) { info_window_next_cb(NULL, data); } - else if (button == MOUSE_BUTTON_MIDDLE || button == MOUSE_BUTTON_RIGHT) + else if (event->button == MOUSE_BUTTON_MIDDLE || event->button == MOUSE_BUTTON_RIGHT) { info_window_back_cb(NULL, data); } } -static void info_window_image_scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void info_window_image_scroll_cb(ImageWindow *imd, GdkEventScroll *event, gpointer data) { - if (direction == GDK_SCROLL_UP) + if (event->direction == GDK_SCROLL_UP) { info_window_back_cb(NULL, data); } - else if (direction == GDK_SCROLL_DOWN) + else if (event->direction == GDK_SCROLL_DOWN) { info_window_next_cb(NULL, data); }
--- a/src/layout_image.c Sat Jun 28 00:44:31 2008 +0000 +++ b/src/layout_image.c Sat Jun 28 07:43:37 2008 +0000 @@ -1573,13 +1573,12 @@ } -static void layout_image_button_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) { LayoutWindow *lw = data; GtkWidget *menu; - switch (button) + switch (event->button) { case MOUSE_BUTTON_LEFT: layout_image_next(lw); @@ -1593,15 +1592,14 @@ { g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); } - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); break; default: break; } } -static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void layout_image_scroll_cb(ImageWindow *imd, GdkEventScroll *event, gpointer data) { LayoutWindow *lw = data; @@ -1614,23 +1612,23 @@ } - if (state & GDK_CONTROL_MASK) + if (event->state & GDK_CONTROL_MASK) { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: - layout_image_zoom_adjust_at_point(lw, get_zoom_increment(), x, y); + layout_image_zoom_adjust_at_point(lw, get_zoom_increment(), event->x, event->y); break; case GDK_SCROLL_DOWN: - layout_image_zoom_adjust_at_point(lw, -get_zoom_increment(), x, y); + layout_image_zoom_adjust_at_point(lw, -get_zoom_increment(), event->x, event->y); break; default: break; } } - else if ( (state & GDK_SHIFT_MASK) != (guint) (options->mousewheel_scrolls)) + else if ( (event->state & GDK_SHIFT_MASK) != (guint) (options->mousewheel_scrolls)) { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: image_scroll(imd, 0, -MOUSEWHEEL_SCROLL_SIZE); @@ -1650,7 +1648,7 @@ } else { - switch (direction) + switch (event->direction) { case GDK_SCROLL_UP: layout_image_prev(lw); @@ -1664,36 +1662,33 @@ } } -static void layout_image_drag_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer data) +static void layout_image_drag_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) { gint i; LayoutWindow *lw = data; - - for (i=0; i < MAX_SPLIT_IMAGES; i++) + for (i = 0; i < MAX_SPLIT_IMAGES; i++) { - if (lw->split_images[i] && lw->split_images[i] != imd) - if (lw->connect_scroll) + if (lw->split_images[i] && lw->split_images[i] != imd && lw->connect_scroll) + { + gdouble sx, sy; + + if (event->state & GDK_CONTROL_MASK) { - gdouble sx, sy; - if (state & GDK_CONTROL_MASK) - { - image_get_scroll_center(imd, &sx, &sy); - } - else - { - image_get_scroll_center(lw->split_images[i], &sx, &sy); - sx += dx; - sy += dy; - } - image_set_scroll_center(lw->split_images[i], sx, sy); + image_get_scroll_center(imd, &sx, &sy); } + else + { + image_get_scroll_center(lw->split_images[i], &sx, &sy); + sx += dx; + sy += dy; + } + image_set_scroll_center(lw->split_images[i], sx, sy); + } } } -static void layout_image_button_inactive_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gpointer data) +static void layout_image_button_inactive_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) { LayoutWindow *lw = data; GtkWidget *menu; @@ -1704,7 +1699,7 @@ layout_image_activate(lw, i); } - switch (button) + switch (event->button) { case MOUSE_BUTTON_RIGHT: menu = layout_image_pop_menu(lw); @@ -1712,7 +1707,7 @@ { g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget); } - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time); + gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); break; default: break; @@ -1720,11 +1715,9 @@ } -static void layout_image_drag_inactive_cb(ImageWindow *imd, gint button, guint32 time, - gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer data) +static void layout_image_drag_inactive_cb(ImageWindow *imd, GdkEventButton *event, gdouble dx, gdouble dy, gpointer data) { LayoutWindow *lw = data; - gint i = image_idx(lw, imd); if (i != -1) @@ -1732,9 +1725,8 @@ layout_image_activate(lw, i); } - /* continue as with active image */ - layout_image_drag_cb(imd, button, time, x, y, state, dx, dy, data); + layout_image_drag_cb(imd, event, dx, dy, data); }
--- a/src/typedefs.h Sat Jun 28 00:44:31 2008 +0000 +++ b/src/typedefs.h Sat Jun 28 07:43:37 2008 +0000 @@ -376,12 +376,9 @@ gpointer data_tile; /* button, scroll functions */ - void (*func_button)(ImageWindow *, gint button, - guint32 time, gdouble x, gdouble y, guint state, gpointer); - void (*func_drag)(ImageWindow *, gint button, - guint32 time, gdouble x, gdouble y, guint state, gdouble dx, gdouble dy,gpointer); - void (*func_scroll)(ImageWindow *, GdkScrollDirection direction, - guint32 time, gdouble x, gdouble y, guint state, gpointer); + void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer); + void (*func_drag)(ImageWindow *, GdkEventButton *event, gdouble dx, gdouble dy, gpointer); + void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer); gpointer data_button; gpointer data_drag;