/*
* Geeqie
* (C) 2006 John Ellis
- * Copyright (C) 2008 - 2010 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
*
* Author: John Ellis
*
}
imd->cm = (gpointer)cm;
-#if 0
- if (run_in_bg) color_man_start_bg(imd->cm, image_post_process_color_cb, imd);
-#endif
}
image_update_util(imd);
image_read_ahead_start(imd);
}
+static void image_load_size_cb(ImageLoader *il, guint width, guint height, gpointer data)
+{
+ ImageWindow *imd = data;
+
+ DEBUG_1("image_load_size_cb: %dx%d", width, height);
+ pixbuf_renderer_set_size_early((PixbufRenderer *)imd->pr, width, height);
+}
+
static void image_load_error_cb(ImageLoader *il, gpointer data)
{
DEBUG_1("%s image error", get_exec_time());
g_signal_connect(G_OBJECT(imd->il), "area_ready", (GCallback)image_load_area_cb, imd);
g_signal_connect(G_OBJECT(imd->il), "error", (GCallback)image_load_error_cb, imd);
g_signal_connect(G_OBJECT(imd->il), "done", (GCallback)image_load_done_cb, imd);
+ g_signal_connect(G_OBJECT(imd->il), "size_prepared", (GCallback)image_load_size_cb, imd);
}
/* this read ahead is located here merely for the callbacks, above */
{
image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), TRUE);
}
-*/
+*/
return TRUE;
}
*-------------------------------------------------------------------
*/
-static void image_focus_paint(ImageWindow *imd, gboolean has_focus, GdkRectangle *area)
-{
- GtkWidget *widget;
-
- widget = imd->widget;
- if (!widget->window) return;
-
- if (has_focus)
- {
- gtk_paint_focus(widget->style, widget->window, GTK_STATE_ACTIVE,
- area, widget, "image_window",
- widget->allocation.x, widget->allocation.y,
- widget->allocation.width - 1, widget->allocation.height - 1);
- }
- else
- {
- gtk_paint_shadow(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- area, widget, "image_window",
- widget->allocation.x, widget->allocation.y,
- widget->allocation.width - 1, widget->allocation.height - 1);
- }
-}
-
-static gboolean image_focus_expose(GtkWidget *widget, GdkEventExpose *event, gpointer data)
-{
- ImageWindow *imd = data;
-
-#if GTK_CHECK_VERSION(2,20,0)
- image_focus_paint(imd, gtk_widget_has_focus(widget), &event->area);
-#else
- image_focus_paint(imd, GTK_WIDGET_HAS_FOCUS(widget), &event->area);
-#endif
- return TRUE;
-}
-
static gboolean image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
ImageWindow *imd = data;
- 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;
}
-static gboolean image_focus_out_cb(GtkWidget *widget, GdkEventFocus *event, gpointer data)
-{
- ImageWindow *imd = data;
-
- GTK_WIDGET_UNSET_FLAGS(imd->widget, GTK_HAS_FOCUS);
- image_focus_paint(imd, FALSE, NULL);
-
- return TRUE;
-}
-
static gboolean image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data)
{
ImageWindow *imd = data;
void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy)
{
-
+ StereoPixbufData stereo_data = STEREO_PIXBUF_DEFAULT;
/* read_exif and similar functions can actually notice that the file has changed and trigger
a notification that removes the pixbuf from cache and unrefs it. Therefore we must ref it
here before it is taken over by the renderer. */
- if (pixbuf) g_object_ref(pixbuf);
+ if (pixbuf) g_object_ref(pixbuf);
if (imd->image_fd)
{
}
}
+ if (pixbuf)
+ {
+ stereo_data = imd->user_stereo;
+ if (stereo_data == STEREO_PIXBUF_DEFAULT)
+ {
+ stereo_data = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(pixbuf), "stereo_data"));
+ }
+ }
+
pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, FALSE);
if (imd->cm)
{
if (lazy)
{
- pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation);
+ pixbuf_renderer_set_pixbuf_lazy((PixbufRenderer *)imd->pr, pixbuf, zoom, imd->orientation, stereo_data);
}
else
{
pixbuf_renderer_set_pixbuf((PixbufRenderer *)imd->pr, pixbuf, zoom);
pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
+ pixbuf_renderer_set_stereo_data((PixbufRenderer *)imd->pr, stereo_data);
}
if (pixbuf) g_object_unref(pixbuf);
}
static void image_loader_sync_data(ImageLoader *il, gpointer old_data, gpointer data)
-{
+{
if (g_signal_handlers_disconnect_by_func(G_OBJECT(il), (GCallback)image_load_area_cb, old_data))
g_signal_connect(G_OBJECT(il), "area_ready", (GCallback)image_load_area_cb, data);
/* this is more like a move function
* it moves most data from source to imd
*/
-void image_change_from_image(ImageWindow *imd, ImageWindow *source)
+void image_move_from_image(ImageWindow *imd, ImageWindow *source)
{
if (imd == source) return;
source->delay_alter_type = ALTER_NONE;
}
+ imd->color_profile_enable = source->color_profile_enable;
+ imd->color_profile_input = source->color_profile_input;
+ imd->color_profile_use_image = source->color_profile_use_image;
+ color_man_free((ColorMan *)imd->cm);
+ imd->cm = NULL;
+
+ file_data_unref(imd->read_ahead_fd);
+ source->read_ahead_fd = NULL;
+
+ imd->orientation = source->orientation;
+ imd->desaturate = source->desaturate;
+
+ imd->user_stereo = source->user_stereo;
+
+ pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
+
+ if (imd->cm || imd->desaturate)
+ pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+ else
+ pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, NULL, NULL, TRUE);
+
+}
+
+/* this is a copy function
+ * source stays unchanged
+ */
+void image_copy_from_image(ImageWindow *imd, ImageWindow *source)
+{
+ if (imd == source) return;
+
+ imd->unknown = source->unknown;
+
+ imd->collection = source->collection;
+ imd->collection_info = source->collection_info;
+
+ image_loader_free(imd->il);
+ imd->il = NULL;
+
+ image_set_fd(imd, image_get_fd(source));
+
+
imd->color_profile_enable = source->color_profile_enable;
imd->color_profile_input = source->color_profile_input;
imd->color_profile_use_image = source->color_profile_use_image;
imd->orientation = source->orientation;
imd->desaturate = source->desaturate;
- pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
+ imd->user_stereo = source->user_stereo;
+
+ pixbuf_renderer_copy(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
if (imd->cm || imd->desaturate)
pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
}
+
/* manipulation */
void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height)
if (vertical)
{
- zoom = (gdouble)pr->window_height / height;
+ zoom = (gdouble)pr->viewport_height / height;
}
else
{
- zoom = (gdouble)pr->window_width / width;
+ zoom = (gdouble)pr->viewport_width / width;
}
if (zoom < 1.0)
return zoom;
}
+/* stereo */
+gint image_stereo_get(ImageWindow *imd)
+{
+ return pixbuf_renderer_stereo_get((PixbufRenderer *)imd->pr);
+}
+
+void image_stereo_set(ImageWindow *imd, gint stereo_mode)
+{
+ DEBUG_1("Setting stereo mode %04x for imd %p", stereo_mode, imd);
+ pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
+}
+
+void image_stereo_swap(ImageWindow *imd)
+{
+ gint stereo_mode = pixbuf_renderer_stereo_get((PixbufRenderer *)imd->pr);
+ stereo_mode ^= PR_STEREO_SWAP;
+ pixbuf_renderer_stereo_set((PixbufRenderer *)imd->pr, stereo_mode);
+}
+
+StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd)
+{
+ return imd->user_stereo;
+}
+
+void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode)
+{
+ imd->user_stereo = stereo_mode;
+ image_reload(imd);
+}
+
/* read ahead */
void image_prebuffer_set(ImageWindow *imd, FileData *fd)
if ((type & NOTIFY_REREAD) && fd == imd->image_fd)
{
- /* there is no need to reload on NOTIFY_CHANGE,
- modified files should be detacted anyway and NOTIFY_REREAD should be recieved
+ /* there is no need to reload on NOTIFY_CHANGE,
+ modified files should be detacted anyway and NOTIFY_REREAD should be recieved
or they are removed from the filelist completely on "move" and "delete"
*/
DEBUG_1("Notify image: %s %04x", fd->path, type);
void image_to_root_window(ImageWindow *imd, gboolean scaled)
{
+#if !GTK_CHECK_VERSION(3,0,0)
GdkScreen *screen;
GdkWindow *rootwindow;
GdkPixmap *pixmap;
screen = gtk_widget_get_screen(imd->widget);
rootwindow = gdk_screen_get_root_window(screen);
- if (gdk_drawable_get_visual(rootwindow) != gdk_visual_get_system()) return;
+ if (gdk_window_get_visual(rootwindow) != gdk_visual_get_system()) return;
if (scaled)
{
g_object_unref(pixmap);
gdk_flush();
+#endif
}
void image_select(ImageWindow *imd, gboolean select)
g_object_set(G_OBJECT(imd->pr), "zoom_quality", options->image.zoom_quality,
"zoom_2pass", options->image.zoom_2pass,
"zoom_expand", options->image.zoom_to_fit_allow_expand,
- "dither_quality", options->image.dither_quality,
"scroll_reset", options->image.scroll_reset_method,
"cache_display", options->image.tile_cache_max,
"window_fit", (imd->top_window_sync && options->image.fit_window_to_image),
NULL);
pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)imd->top_window);
+
+ image_stereo_set(imd, options->stereo.mode);
+ pixbuf_renderer_stereo_fixed_set((PixbufRenderer *)imd->pr,
+ options->stereo.fixed_w, options->stereo.fixed_h,
+ options->stereo.fixed_x1, options->stereo.fixed_y1,
+ options->stereo.fixed_x2, options->stereo.fixed_y2);
}
void image_options_sync(void)
g_free(imd);
}
-static void image_destroy_cb(GtkObject *widget, gpointer data)
+static void image_destroy_cb(GtkWidget *widget, gpointer data)
{
ImageWindow *imd = data;
image_free(imd);
}
+#if GTK_CHECK_VERSION(3,0,0)
+gboolean selectable_frame_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ gtk_paint_flat_box(gtk_widget_get_style(widget),
+ cr,
+ gtk_widget_get_state(widget),
+ gtk_frame_get_shadow_type(GTK_FRAME(widget)),
+ widget,
+ NULL,
+ allocation.x + 3, allocation.y + 3,
+ allocation.width - 6, allocation.height - 6);
+
+ if (gtk_widget_has_focus(widget))
+ {
+ gtk_paint_focus(gtk_widget_get_style(widget), cr, GTK_STATE_ACTIVE,
+ widget, "image_window",
+ allocation.x, allocation.y,
+ allocation.width - 1, allocation.height - 1);
+ }
+ else
+ {
+ gtk_paint_shadow(gtk_widget_get_style(widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_IN,
+ widget, "image_window",
+ allocation.x, allocation.y,
+ allocation.width - 1, allocation.height - 1);
+ }
+ return FALSE;
+}
+#else
gboolean selectable_frame_expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
- gtk_paint_flat_box(widget->style,
- widget->window,
- widget->state,
- (GTK_FRAME(widget))->shadow_type,
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+ gtk_paint_flat_box(gtk_widget_get_style(widget),
+ gtk_widget_get_window(widget),
+ gtk_widget_get_state(widget),
+ gtk_frame_get_shadow_type(GTK_FRAME(widget)),
NULL,
widget,
NULL,
- widget->allocation.x + 3, widget->allocation.y + 3,
- widget->allocation.width - 6, widget->allocation.height - 6);
-
+ allocation.x + 3, allocation.y + 3,
+ allocation.width - 6, allocation.height - 6);
+ if (gtk_widget_has_focus(widget))
+ {
+ gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_ACTIVE,
+ &event->area, widget, "image_window",
+ allocation.x, allocation.y,
+ allocation.width - 1, allocation.height - 1);
+ }
+ else
+ {
+ gtk_paint_shadow(gtk_widget_get_style(widget), gtk_widget_get_window(widget), GTK_STATE_NORMAL, GTK_SHADOW_IN,
+ &event->area, widget, "image_window",
+ allocation.x, allocation.y,
+ allocation.width - 1, allocation.height - 1);
+ }
return FALSE;
}
+#endif
void image_set_frame(ImageWindow *imd, gboolean frame)
if (frame)
{
imd->frame = gtk_frame_new(NULL);
-#if GTK_CHECK_VERSION(2,12,0)
g_object_ref(imd->pr);
-#else
- gtk_widget_ref(imd->pr);
-#endif
if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr);
gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr);
-#if GTK_CHECK_VERSION(2,12,0)
g_object_unref(imd->pr);
+ gtk_widget_set_can_focus(imd->frame, TRUE);
+ gtk_widget_set_app_paintable(imd->frame, TRUE);
+
+#if GTK_CHECK_VERSION(3,0,0)
+ g_signal_connect(G_OBJECT(imd->frame), "draw",
+ G_CALLBACK(selectable_frame_draw_cb), NULL);
#else
- gtk_widget_unref(imd->pr);
-#endif
g_signal_connect(G_OBJECT(imd->frame), "expose_event",
- G_CALLBACK(selectable_frame_expose_cb), NULL);
-
- GTK_WIDGET_SET_FLAGS(imd->frame, GTK_CAN_FOCUS);
+ G_CALLBACK(selectable_frame_expose_cb), NULL);
+#endif
g_signal_connect(G_OBJECT(imd->frame), "focus_in_event",
G_CALLBACK(image_focus_in_cb), imd);
- g_signal_connect(G_OBJECT(imd->frame), "focus_out_event",
- G_CALLBACK(image_focus_out_cb), imd);
-
- g_signal_connect_after(G_OBJECT(imd->frame), "expose_event",
- G_CALLBACK(image_focus_expose), imd);
-#if GTK_CHECK_VERSION(2,14,0)
gtk_box_pack_start(GTK_BOX(imd->widget), imd->frame, TRUE, TRUE, 0);
-#else
- gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->frame);
-#endif
gtk_widget_show(imd->frame);
}
else
{
-#if GTK_CHECK_VERSION(2,12,0)
g_object_ref(imd->pr);
-#else
- gtk_widget_ref(imd->pr);
-#endif
if (imd->frame)
{
gtk_container_remove(GTK_CONTAINER(imd->frame), imd->pr);
gtk_widget_destroy(imd->frame);
imd->frame = NULL;
}
-#if GTK_CHECK_VERSION(2,14,0)
gtk_box_pack_start(GTK_BOX(imd->widget), imd->pr, TRUE, TRUE, 0);
-#else
- gtk_box_pack_start_defaults(GTK_BOX(imd->widget), imd->pr);
-#endif
-#if GTK_CHECK_VERSION(2,12,0)
g_object_unref(imd->pr);
-#else
- gtk_widget_unref(imd->pr);
-#endif
}
gtk_widget_show(imd->pr);