active image follows keyboard focus
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 28 Mar 2009 15:31:04 +0000 (15:31 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 28 Mar 2009 15:31:04 +0000 (15:31 +0000)
src/image.c
src/image.h
src/layout_image.c
src/typedefs.h

index 497ce96..212d395 100644 (file)
@@ -867,6 +867,11 @@ static gboolean image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpoin
        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 @@ void image_set_scroll_notify_func(ImageWindow *imd,
        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)
index 5c7f3fa..c05eaf1 100644 (file)
@@ -33,6 +33,9 @@ void image_set_drag_func(ImageWindow *imd,
 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);
index d9d9015..6a8f39d 100644 (file)
@@ -1331,6 +1331,19 @@ static gint image_idx(LayoutWindow *lw, ImageWindow *imd)
        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 @@ GtkWidget *layout_image_new(LayoutWindow *lw, gint i)
                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;
index 2dd8664..2b551d4 100644 (file)
@@ -394,10 +394,12 @@ struct _ImageWindow
        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);