}
}
+static void image_drag_cb(PixbufRenderer *pr, GdkEventButton *event, gpointer data)
+{
+ ImageWindow *imd = data;
+
+ if (imd->func_drag)
+ {
+ imd->func_drag(imd, event->button, event->time,
+ event->x, event->y, event->state,
+ event->x - pr->drag_last_x, event->y - pr->drag_last_y,
+ imd->data_button);
+ }
+}
+
static void image_scroll_notify_cb(PixbufRenderer *pr, gpointer data)
{
ImageWindow *imd = data;
imd->data_button = 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),
+ gpointer data)
+{
+ imd->func_drag = func;
+ imd->data_drag = data;
+}
+
void image_set_scroll_func(ImageWindow *imd,
void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer),
gpointer data)
G_CALLBACK(image_zoom_cb), imd);
g_signal_connect(G_OBJECT(imd->pr), "render_complete",
G_CALLBACK(image_render_complete_cb), imd);
+ g_signal_connect(G_OBJECT(imd->pr), "drag",
+ G_CALLBACK(image_drag_cb), imd);
image_list = g_list_append(image_list, imd);
void image_set_button_func(ImageWindow *imd,
void (*func)(ImageWindow *, gint button, guint32 time, gdouble x, gdouble y, guint state, 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),
+ gpointer data);
void image_set_scroll_func(ImageWindow *imd,
void (*func)(ImageWindow *, GdkScrollDirection direction, guint32 time, gdouble x, gdouble y, guint state, gpointer),
gpointer data);
}
}
-static void layout_image_scroll_notify_cb(ImageWindow *imd, gint x, gint y, gint width, gint height, gpointer data)
+static void layout_image_drag_cb(ImageWindow *imd, gint button, guint32 time,
+ gdouble x, gdouble y, guint state, gdouble dx, gdouble dy, gpointer data)
{
gint i;
- printf("scroll cb %d %d %d %d\n", x,y,width, height);
LayoutWindow *lw = data;
gdouble x, gdouble y, guint state, gpointer data)
{
LayoutWindow *lw = data;
+ GtkWidget *menu;
gint i = image_idx(lw, imd);
if (i != -1)
printf("image activate %d\n", i);
layout_image_activate(lw, i);
}
+
+ switch (button)
+ {
+ case 3:
+ menu = layout_image_pop_menu(lw);
+ if (imd == lw->image)
+ {
+ g_object_set_data(G_OBJECT(menu), "click_parent", imd->widget);
+ }
+ gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, time);
+ break;
+ default:
+ break;
+ }
+
}
+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)
+{
+ LayoutWindow *lw = data;
+
+ gint i = image_idx(lw, imd);
+
+ if (i != -1)
+ {
+ printf("image activate %d\n", i);
+ layout_image_activate(lw, i);
+ }
+
+
+ for (i=0; i < MAX_SPLIT_IMAGES; i++)
+ {
+ if (lw->split_images[i] && lw->split_images[i] != imd)
+// if (lw->connect_zoom)
+// image_sync_zoom_from_image(lw->split_images[i], imd);
+ if (lw->connect_scroll)
+ image_sync_scroll_from_image_absolute(lw->split_images[i], imd);
+ }
+}
+
+
static void layout_image_set_buttons(LayoutWindow *lw)
{
image_set_button_func(lw->image, layout_image_button_cb, lw);
if (!lw->split_images[i]) return;
image_set_update_func(lw->split_images[i], NULL, NULL);
layout_image_set_buttons_inactive(lw, i);
- image_set_scroll_notify_func(lw->split_images[i], NULL, NULL);
+ image_set_drag_func(lw->image, layout_image_drag_inactive_cb, lw);
image_attach_window(lw->split_images[i], NULL, NULL, NULL, FALSE);
image_select(lw->split_images[i], FALSE);
image_set_update_func(lw->image, layout_image_update_cb, lw);
layout_image_set_buttons(lw);
- image_set_scroll_notify_func(lw->image, layout_image_scroll_notify_cb, lw);
+ image_set_drag_func(lw->image, layout_image_drag_cb, lw);
image_attach_window(lw->image, lw->window, NULL, "GQview", FALSE);
SIGNAL_CLICKED,
SIGNAL_SCROLL_NOTIFY,
SIGNAL_RENDER_COMPLETE,
+ SIGNAL_DRAG,
SIGNAL_COUNT
};
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[SIGNAL_DRAG] =
+ g_signal_new("drag",
+ G_OBJECT_CLASS_TYPE(gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(PixbufRendererClass, drag),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ GDK_TYPE_EVENT);
}
static void pixbuf_renderer_init(PixbufRenderer *pr)
}
}
+static void pr_drag_signal(PixbufRenderer *pr, GdkEventButton *bevent)
+{
+ g_signal_emit(pr, signals[SIGNAL_DRAG], 0, bevent);
+}
+
/*
*-------------------------------------------------------------------
* sync and clamp
pixbuf_renderer_scroll(pr, (pr->drag_last_x - bevent->x) * accel,
(pr->drag_last_y - bevent->y) * accel);
+ pr_drag_signal(pr, bevent);
+
pr->drag_last_x = bevent->x;
pr->drag_last_y = bevent->y;
void (* scroll_notify) (PixbufRenderer *pr);
void (* render_complete)(PixbufRenderer *pr);
+ void (* drag) (PixbufRenderer *pr, GdkEventButton *event);
};
/* 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);
gpointer data_button;
+ gpointer data_drag;
gpointer data_scroll;
/* scroll notification (for scroll bar implementation) */