Reduce number of parameters (mostly unused), just pass the event pointer.
authorLaurent Monin <geeqie@norz.org>
Sat, 28 Jun 2008 07:43:37 +0000 (07:43 +0000)
committerLaurent Monin <geeqie@norz.org>
Sat, 28 Jun 2008 07:43:37 +0000 (07:43 +0000)
src/image.c
src/image.h
src/img-view.c
src/info.c
src/layout_image.c
src/typedefs.h

index cbe1e97..aaae255 100644 (file)
@@ -67,8 +67,7 @@ static void image_click_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer d
 
        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 @@ static void image_drag_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer da
 
        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 @@ static gint image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer d
        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_state_func(ImageWindow *imd,
 
 
 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_button_func(ImageWindow *imd,
 }
 
 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_drag_func(ImageWindow *imd,
 }
 
 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;
index 98ecc53..e0d6dde 100644 (file)
@@ -25,13 +25,13 @@ void image_set_update_func(ImageWindow *imd,
                           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),
index 5986d79..d547cd9 100644 (file)
@@ -597,14 +597,12 @@ static gint view_window_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpoi
  * 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 @@ static void button_cb(ImageWindow *imd, gint button, guint32 time,
                        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 @@ static void scroll_cb(ImageWindow *imd, GdkScrollDirection direction, guint32 ti
                }
        else
                {
-               switch (direction)
+               switch (event->direction)
                        {
                        case GDK_SCROLL_UP:
                                view_step_prev(vw);
index daecbac..1cf9dd6 100644 (file)
@@ -765,27 +765,25 @@ static void info_window_next_cb(GtkWidget *widget, gpointer data)
        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);
                }
index a36c667..57c2f13 100644 (file)
@@ -1573,13 +1573,12 @@ static gint image_idx(LayoutWindow *lw, ImageWindow *imd)
 }
 
 
-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 @@ static void layout_image_button_cb(ImageWindow *imd, gint button, guint32 time,
                                {
                                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 @@ static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection directio
                }
 
 
-       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 @@ static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection directio
                }
        else
                {
-               switch (direction)
+               switch (event->direction)
                        {
                        case GDK_SCROLL_UP:
                                layout_image_prev(lw);
@@ -1664,36 +1662,33 @@ static void layout_image_scroll_cb(ImageWindow *imd, GdkScrollDirection directio
                }
 }
 
-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 @@ static void layout_image_button_inactive_cb(ImageWindow *imd, gint button, guint
                layout_image_activate(lw, i);
                }
 
-       switch (button)
+       switch (event->button)
                {
                case MOUSE_BUTTON_RIGHT:
                        menu = layout_image_pop_menu(lw);
@@ -1712,7 +1707,7 @@ static void layout_image_button_inactive_cb(ImageWindow *imd, gint button, guint
                                {
                                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_button_inactive_cb(ImageWindow *imd, gint button, guint
 
 }
 
-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 @@ static void layout_image_drag_inactive_cb(ImageWindow *imd, gint button, guint32
                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);
 }
 
 
index 623b3f7..0f56332 100644 (file)
@@ -376,12 +376,9 @@ struct _ImageWindow
        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;