# HG changeset patch # User nadvornik # Date 1238254264 0 # Node ID 96897bd5f6cdb90e89559f00469859e593958b5c # Parent 077924265c285d707462712e5e6196607ed9a721 active image follows keyboard focus diff -r 077924265c28 -r 96897bd5f6cd src/image.c --- a/src/image.c Sat Mar 28 15:09:09 2009 +0000 +++ b/src/image.c Sat Mar 28 15:31:04 2009 +0000 @@ -867,6 +867,11 @@ GTK_WIDGET_SET_FLAGS(imd->widget, GTK_HAS_FOCUS); image_focus_paint(imd, TRUE, NULL); + if (imd->func_focus_in) + { + imd->func_focus_in(imd, imd->data_focus_in); + } + return TRUE; } @@ -974,6 +979,14 @@ imd->data_scroll_notify = data; } +void image_set_focus_in_func(ImageWindow *imd, + void (*func)(ImageWindow *, gpointer), + gpointer data) +{ + imd->func_focus_in = func; + imd->data_focus_in = data; +} + /* path, name */ const gchar *image_get_path(ImageWindow *imd) diff -r 077924265c28 -r 96897bd5f6cd src/image.h --- a/src/image.h Sat Mar 28 15:09:09 2009 +0000 +++ b/src/image.h Sat Mar 28 15:31:04 2009 +0000 @@ -33,6 +33,9 @@ void image_set_scroll_func(ImageWindow *imd, void (*func)(ImageWindow *, GdkEventScroll *event, gpointer), gpointer data); +void image_set_focus_in_func(ImageWindow *imd, + void (*func)(ImageWindow *, 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), gpointer data); diff -r 077924265c28 -r 96897bd5f6cd src/layout_image.c --- a/src/layout_image.c Sat Mar 28 15:09:09 2009 +0000 +++ b/src/layout_image.c Sat Mar 28 15:31:04 2009 +0000 @@ -1331,6 +1331,19 @@ return -1; } +static void layout_image_focus_in_cb(ImageWindow *imd, gpointer data) +{ + LayoutWindow *lw = data; + + gint i = image_idx(lw, imd); + + if (i != -1) + { + DEBUG_1("image activate focus_in %d", i); + layout_image_activate(lw, i); + } +} + static void layout_image_button_cb(ImageWindow *imd, GdkEventButton *event, gpointer data) { @@ -1604,6 +1617,8 @@ gtk_size_group_add_widget(lw->split_image_sizegroup, lw->split_images[i]->widget); gtk_widget_set_size_request(lw->split_images[i]->widget, IMAGE_MIN_WIDTH, -1); + image_set_focus_in_func(lw->split_images[i], layout_image_focus_in_cb, lw); + } return lw->split_images[i]->widget; diff -r 077924265c28 -r 96897bd5f6cd src/typedefs.h --- a/src/typedefs.h Sat Mar 28 15:09:09 2009 +0000 +++ b/src/typedefs.h Sat Mar 28 15:31:04 2009 +0000 @@ -394,10 +394,12 @@ 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); + void (*func_focus_in)(ImageWindow *, gpointer); gpointer data_button; gpointer data_drag; gpointer data_scroll; + gpointer data_focus_in; /* scroll notification (for scroll bar implementation) */ void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);