Include a Other Software section in Help file
[geeqie.git] / src / image.c
index e66227c..c81b1c5 100644 (file)
@@ -29,6 +29,7 @@
 #include "exif.h"
 #include "metadata.h"
 #include "histogram.h"
+#include "history_list.h"
 #include "image-load.h"
 #include "image-overlay.h"
 #include "layout.h"
@@ -44,7 +45,7 @@
 
 static GList *image_list = NULL;
 
-static void image_update_title(ImageWindow *imd);
+void image_update_title(ImageWindow *imd);
 static void image_read_ahead_start(ImageWindow *imd);
 static void image_cache_set(ImageWindow *imd, FileData *fd);
 
@@ -332,7 +333,7 @@ static void image_zoom_cb(PixbufRenderer *pr, gdouble zoom, gpointer data)
  *-------------------------------------------------------------------
  */
 
-static void image_update_title(ImageWindow *imd)
+void image_update_title(ImageWindow *imd)
 {
        gchar *title = NULL;
        gchar *zoom = NULL;
@@ -564,7 +565,7 @@ static void image_post_process_tile_color_cb(PixbufRenderer *pr, GdkPixbuf **pix
        ImageWindow *imd = (ImageWindow *)data;
        if (imd->cm) color_man_correct_region(imd->cm, *pixbuf, x, y, w, h);
        if (imd->desaturate) pixbuf_desaturate_rect(*pixbuf, x, y, w, h);
-
+       if (imd->overunderexposed) pixbuf_highlight_overunderexposed(*pixbuf, x, y, w, h);
 }
 
 void image_alter_orientation(ImageWindow *imd, FileData *fd_n, AlterType type)
@@ -658,7 +659,7 @@ void image_alter_orientation(ImageWindow *imd, FileData *fd_n, AlterType type)
 void image_set_desaturate(ImageWindow *imd, gboolean desaturate)
 {
        imd->desaturate = desaturate;
-       if (imd->cm || imd->desaturate)
+       if (imd->cm || imd->desaturate || imd->overunderexposed)
                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);
@@ -670,6 +671,26 @@ gboolean image_get_desaturate(ImageWindow *imd)
        return imd->desaturate;
 }
 
+void image_set_overunderexposed(ImageWindow *imd, gboolean overunderexposed)
+{
+       imd->overunderexposed = overunderexposed;
+       if (imd->cm || imd->desaturate || imd->overunderexposed)
+               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);
+       pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation);
+}
+
+gboolean image_get_overunderexposed(ImageWindow *imd)
+{
+       return imd->overunderexposed;
+}
+
+void image_set_ignore_alpha(ImageWindow *imd, gboolean ignore_alpha)
+{
+   pixbuf_renderer_set_ignore_alpha((PixbufRenderer *)imd->pr, ignore_alpha);
+}
+
 /*
  *-------------------------------------------------------------------
  * read ahead (prebuffer)
@@ -856,10 +877,11 @@ static void image_load_done_cb(ImageLoader *il, gpointer data)
                                break;
                        case FORMAT_CLASS_VIDEO:
                                pixbuf = pixbuf_inline(PIXBUF_INLINE_VIDEO);
+                               break;
                        case FORMAT_CLASS_COLLECTION:
                                pixbuf = pixbuf_inline(PIXBUF_INLINE_COLLECTION);
                                break;
-                       case FORMAT_CLASS_PDF:
+                       case FORMAT_CLASS_DOCUMENT:
                                pixbuf = pixbuf_inline(PIXBUF_INLINE_ICON_PDF);
                                break;
                        default:
@@ -1136,12 +1158,47 @@ static gboolean image_focus_in_cb(GtkWidget *widget, GdkEventFocus *event, gpoin
 static gboolean image_scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer data)
 {
        ImageWindow *imd = data;
+       gboolean in_lw = FALSE;
+       gint i = 0;
+       LayoutWindow *lw = NULL;
 
-       if (imd->func_scroll &&
-           event && event->type == GDK_SCROLL)
+       if (imd->func_scroll && event && event->type == GDK_SCROLL)
                {
-               imd->func_scroll(imd, event, imd->data_scroll);
-               return TRUE;
+               layout_valid(&lw);
+               /* check if the image is in a layout window */
+               for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+                       {
+                       if (imd == lw->split_images[i])
+                               {
+                               in_lw = TRUE;
+                               break;
+                               }
+                       }
+
+               if (in_lw)
+                       {
+                       if (lw->options.split_pane_sync)
+                               {
+                               for (i = 0; i < MAX_SPLIT_IMAGES; i++)
+                                       {
+                                       if (lw->split_images[i])
+                                               {
+                                               layout_image_activate(lw, i, FALSE);
+                                               imd->func_scroll(lw->split_images[i], event, lw->split_images[i]->data_scroll);
+                                               }
+                                       }
+                               }
+                       else
+                               {
+                               imd->func_scroll(imd, event, imd->data_scroll);
+                               }
+                       return TRUE;
+                       }
+               else
+                       {
+                       imd->func_scroll(imd, event, imd->data_scroll);
+                       return TRUE;
+                       }
                }
 
        return FALSE;
@@ -1167,7 +1224,7 @@ void image_attach_window(ImageWindow *imd, GtkWidget *window,
 
        lw = layout_find_by_image(imd);
 
-       if (!(options->image.fit_window_to_image && lw && lw->options.tools_float)) window = NULL;
+       if (!(options->image.fit_window_to_image && lw && (lw->options.tools_float || lw->options.tools_hidden))) window = NULL;
 
        pixbuf_renderer_set_parent((PixbufRenderer *)imd->pr, (GtkWindow *)window);
 
@@ -1295,6 +1352,7 @@ GdkPixbuf *image_get_pixbuf(ImageWindow *imd)
 
 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy)
 {
+       LayoutWindow *lw;
        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
@@ -1344,12 +1402,14 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboo
 
        if (pixbuf) g_object_unref(pixbuf);
 
-       if (imd->color_profile_enable)
+       /* Color correction takes too much time for an animated gif */
+       lw = layout_find_by_image(imd);
+       if (imd->color_profile_enable && lw && !lw->animation)
                {
-               image_post_process_color(imd, 0, FALSE); /* TODO: error handling */
+               image_post_process_color(imd, 0, FALSE); /** @todo error handling */
                }
 
-       if (imd->cm || imd->desaturate)
+       if (imd->cm || imd->desaturate || imd->overunderexposed)
                pixbuf_renderer_set_post_process_func((PixbufRenderer *)imd->pr, image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
 
        image_state_set(imd, IMAGE_STATE_IMAGE);
@@ -1369,6 +1429,11 @@ void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectI
                collection_table_unselect_all(cw->table);
                collection_table_select(cw->table,info);
                }
+
+       if (info->fd)
+               {
+               image_chain_append_end(info->fd->path);
+               }
 }
 
 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info)
@@ -1467,7 +1532,7 @@ void image_move_from_image(ImageWindow *imd, ImageWindow *source)
 
        pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
 
-       if (imd->cm || imd->desaturate)
+       if (imd->cm || imd->desaturate || imd->overunderexposed)
                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);
@@ -1529,7 +1594,7 @@ void image_copy_from_image(ImageWindow *imd, ImageWindow *source)
 
        pixbuf_renderer_copy(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
 
-       if (imd->cm || imd->desaturate)
+       if (imd->cm || imd->desaturate || imd->overunderexposed)
                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);
@@ -1751,7 +1816,7 @@ static void image_notify_cb(FileData *fd, NotifyType type, gpointer data)
        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
+                  modified files should be detacted anyway and NOTIFY_REREAD should be received
                   or they are removed from the filelist completely on "move" and "delete"
                */
                DEBUG_1("Notify image: %s %04x", fd->path, type);
@@ -2098,6 +2163,7 @@ void image_set_frame(ImageWindow *imd, gboolean frame)
        if (frame)
                {
                imd->frame = gtk_frame_new(NULL);
+               DEBUG_NAME(imd->frame);
                g_object_ref(imd->pr);
                if (imd->has_frame != -1) gtk_container_remove(GTK_CONTAINER(imd->widget), imd->pr);
                gtk_container_add(GTK_CONTAINER(imd->frame), imd->pr);
@@ -2152,10 +2218,12 @@ ImageWindow *image_new(gboolean frame)
        imd->orientation = 1;
 
        imd->pr = GTK_WIDGET(pixbuf_renderer_new());
+       DEBUG_NAME(imd->pr);
 
        image_options_set(imd);
 
        imd->widget = gtk_vbox_new(0, 0);
+       DEBUG_NAME(imd->widget);
 
        image_set_frame(imd, frame);