Tue Nov 28 11:54:30 2006 John Ellis <johne@verizon.net>
authorJohn Ellis <johne@verizon.net>
Tue, 28 Nov 2006 17:06:47 +0000 (17:06 +0000)
committerJohn Ellis <johne@verizon.net>
Tue, 28 Nov 2006 17:06:47 +0000 (17:06 +0000)
        * color-man.[ch]: Allow color manager to work with GdkPixbufs not
        linked to an ImageWindow. Fix missing embedded dummy function when
        compiling without color profile support.
        * image.c: When embedded color profiles is enabled and EXIF ColorSpace
        is set to 1 use sRGB color profile for the image. Also fixed order of
        starting the image read-ahead when color profiles are in use.
        * typedefs.h (ImageWindow): Use gpointer definition correctly so that
        cm is a pointer and not a pointer to a pointer.
        * utilops.c: Pass 0 to vertical fill arg of gtk_table_attach() instead
        of FALSE.

ChangeLog
TODO
src/color-man.c
src/color-man.h
src/image.c
src/typedefs.h
src/utilops.c

index 3204673..a5577a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Tue Nov 28 11:54:30 2006  John Ellis  <johne@verizon.net>
+
+       * color-man.[ch]: Allow color manager to work with GdkPixbufs not
+       linked to an ImageWindow. Fix missing embedded dummy function when
+       compiling without color profile support.
+       * image.c: When embedded color profiles is enabled and EXIF ColorSpace
+       is set to 1 use sRGB color profile for the image. Also fixed order of
+       starting the image read-ahead when color profiles are in use.
+       * typedefs.h (ImageWindow): Use gpointer definition correctly so that
+       cm is a pointer and not a pointer to a pointer.
+       * utilops.c: Pass 0 to vertical fill arg of gtk_table_attach() instead
+       of FALSE.
+
 Mon Nov 27 01:23:23 2006  John Ellis  <johne@verizon.net>
 
        * bar_exif.c, cache-loader.c, pan-view.c: Pass new arg for exif_read().
diff --git a/TODO b/TODO
index 4a525bb..b9c4627 100644 (file)
--- a/TODO
+++ b/TODO
@@ -23,7 +23,7 @@ d> figure out if crash when expanding a folder in the folder tree view when pess
 
  > color profiles:
   d> support profiles embedded in images
-   > check if clamp arg is handled correct in post_process_*()
+  d> check if clamp arg is handled correct in post_process_*()
    > add support in img-view.c
 
   ---
@@ -117,15 +117,11 @@ d> figure out if crash when expanding a folder in the folder tree view when pess
 Minor (non blockers):
 ----------------------------------------------
 
-d> update icon used for window to the (not so) new icon
-
  > fix gtk_table_attach use to not use FALSE for fill vertical arg.
 
  > xv and xpaint are hardly used or even installed by any distro anymore - time
    to remove these (and find alternates?) seems silly to only have gimp.
 
-d> update .desktop MimeType list to match Fedora's patch for missing formats
-
  > allow editor commands to be interrupted (via SIGTERM?)
  > fix hanging editor commands that await user input (how to handle, or even detect this?)
 
@@ -135,8 +131,6 @@ d> update .desktop MimeType list to match Fedora's patch for missing formats
 
  > fix printing of transparent images to not use black for transparency (white or user settable).
 
-d> add [shift]+G to display as greyscale
-
  > fix comment field in keywords bar to a height of 2 or 3 text lines.
 
  > add toolbar to: (UPDATE: these toolbars may not make it into 1.6)
@@ -153,8 +147,6 @@ Wishlist?:
  > Initiating full screen from the command line should not
    show main window until full screen is exited.
 
-d> add --geometry suipport
-
  > Add shortcut to jump to next folder within parent folder.
 
  > add animated image support
index a023725..1113b19 100644 (file)
@@ -302,7 +302,7 @@ static void color_man_correct_region(ColorMan *cm, gint x, gint y, gint w, gint
                cmsDoTransform(cc->transform, pbuf, pbuf, w);
                }
 
-       image_area_changed(cm->imd, x, y, w, h);
+       if (cm->incremental_sync && cm->imd) image_area_changed(cm->imd, x, y, w, h);
 }
 
 static gint color_man_idle_cb(gpointer data)
@@ -311,7 +311,8 @@ static gint color_man_idle_cb(gpointer data)
        gint width, height;
        gint rh;
 
-       if (cm->pixbuf != image_get_pixbuf(cm->imd))
+       if (cm->imd &&
+           cm->pixbuf != image_get_pixbuf(cm->imd))
                {
                cm->idle_id = -1;
                color_man_done(cm, COLOR_RETURN_IMAGE_CHANGED);
@@ -323,6 +324,11 @@ static gint color_man_idle_cb(gpointer data)
 
        if (cm->row > height)
                {
+               if (!cm->incremental_sync && cm->imd)
+                       {
+                       image_area_changed(cm->imd, 0, 0, width, height);
+                       }
+
                cm->idle_id = -1;
                color_man_done(cm, COLOR_RETURN_SUCCESS);
                return FALSE;
@@ -335,24 +341,24 @@ static gint color_man_idle_cb(gpointer data)
        return TRUE;
 }
 
-static ColorMan *color_man_new_real(ImageWindow *imd,
+static ColorMan *color_man_new_real(ImageWindow *imd, GdkPixbuf *pixbuf,
                                    ColorManProfileType input_type, const gchar *input_file,
                                    unsigned char *input_data, guint input_data_len,
                                    ColorManProfileType screen_type, const gchar *screen_file,
                                    ColorManDoneFunc done_func, gpointer done_data)
 {
        ColorMan *cm;
-       GdkPixbuf *pixbuf;
        gint has_alpha;
 
-       if (!imd) return NULL;
-
-       pixbuf = image_get_pixbuf(imd);
+       if (imd) pixbuf = image_get_pixbuf(imd);
        if (!pixbuf) return NULL;
 
        cm = g_new0(ColorMan, 1);
        cm->imd = imd;
        cm->pixbuf = pixbuf;
+       g_object_ref(cm->pixbuf);
+
+       cm->incremental_sync = FALSE;
        cm->row = 0;
        cm->idle_id = -1;
 
@@ -373,23 +379,23 @@ static ColorMan *color_man_new_real(ImageWindow *imd,
        return cm;
 }
 
-ColorMan *color_man_new(ImageWindow *imd,
+ColorMan *color_man_new(ImageWindow *imd, GdkPixbuf *pixbuf,
                        ColorManProfileType input_type, const gchar *input_file,
                        ColorManProfileType screen_type, const gchar *screen_file,
                        ColorManDoneFunc done_func, gpointer done_data)
 {
-       return color_man_new_real(imd,
+       return color_man_new_real(imd, pixbuf,
                                  input_type, input_file, NULL, 0,
                                  screen_type, screen_file,
                                  done_func, done_data);
 }
 
-ColorMan *color_man_new_embedded(ImageWindow *imd,
+ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf,
                                 unsigned char *input_data, guint input_data_len,
                                 ColorManProfileType screen_type, const gchar *screen_file,
                                 ColorManDoneFunc done_func, gpointer done_data)
 {
-       return color_man_new_real(imd,
+       return color_man_new_real(imd, pixbuf,
                                  COLOR_PROFILE_MEM, NULL, input_data, input_data_len,
                                  screen_type, screen_file,
                                  done_func, done_data);
@@ -400,6 +406,7 @@ void color_man_free(ColorMan *cm)
        if (!cm) return;
 
        if (cm->idle_id != -1) g_source_remove(cm->idle_id);
+       if (cm->pixbuf) g_object_unref(cm->pixbuf);
 
        color_man_cache_unref(cm->profile);
 
@@ -415,7 +422,7 @@ void color_man_update(void)
 /*** color support not enabled ***/
 
 
-ColorMan *color_man_new(ImageWindow *imd,
+ColorMan *color_man_new(ImageWindow *imd, GdkPixbuf *pixbuf,
                        ColorManProfileType input_type, const gchar *input_file,
                        ColorManProfileType screen_type, const gchar *screen_file,
                        ColorManDoneFunc don_func, gpointer done_data)
@@ -424,6 +431,15 @@ ColorMan *color_man_new(ImageWindow *imd,
        return NULL;
 }
 
+ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf,
+                                unsigned char *input_data, guint input_data_len,
+                                ColorManProfileType screen_type, const gchar *screen_file,
+                                ColorManDoneFunc done_func, gpointer done_data)
+{
+       /* no op */
+       return NULL;
+}
+
 void color_man_free(ColorMan *cm)
 {
        /* no op */
index e4f6380..e659bf3 100644 (file)
@@ -33,6 +33,7 @@ typedef void (* ColorManDoneFunc)(ColorMan *cm, ColorManReturnType success, gpoi
 struct _ColorMan {
        ImageWindow *imd;
        GdkPixbuf *pixbuf;
+       gint incremental_sync;
        gint row;
 
        gpointer profile;
@@ -44,11 +45,11 @@ struct _ColorMan {
 };
 
 
-ColorMan *color_man_new(ImageWindow *imd,
+ColorMan *color_man_new(ImageWindow *imd, GdkPixbuf *pixbuf,
                        ColorManProfileType input_type, const gchar *input_file,
                        ColorManProfileType screen_type, const gchar *screen_file,
                        ColorManDoneFunc done_func, gpointer done_data);
-ColorMan *color_man_new_embedded(ImageWindow *imd,
+ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf,
                                 unsigned char *input_data, guint input_data_len,
                                 ColorManProfileType screen_type, const gchar *screen_file,
                                 ColorManDoneFunc done_func, gpointer done_data);
index 8881143..687ff8c 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * GQview
- * (C) 2005 John Ellis
+ * (C) 2006 John Ellis
  *
  * Author: John Ellis
  *
@@ -45,6 +45,7 @@ static GList *image_list = NULL;
 
 static void image_update_title(ImageWindow *imd);
 static void image_post_process(ImageWindow *imd, gint clamp);
+static void image_read_ahead_start(ImageWindow *imd);
 
 /*
  *-------------------------------------------------------------------
@@ -263,14 +264,19 @@ static void image_post_process_color_cb(ColorMan *cm, ColorManReturnType type, g
 {
        ImageWindow *imd = data;
 
-       color_man_free((ColorMan *)imd->cm);
+       color_man_free(cm);
+       if (type == COLOR_RETURN_IMAGE_CHANGED)
+               {
+               if (cm == imd->cm) imd->cm = NULL;
+               return;
+               }
+
        imd->cm = NULL;
        imd->state |= IMAGE_STATE_COLOR_ADJ;
 
-       if (type != COLOR_RETURN_IMAGE_CHANGED)
-               {
-               image_post_process_alter(imd, FALSE);
-               }
+       image_post_process_alter(imd, FALSE);
+
+       image_read_ahead_start(imd);
 }
 
 static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData *exif)
@@ -324,19 +330,33 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
        if (imd->color_profile_use_image && exif)
                {
                item = exif_get_item(exif, "ColorProfile");
+               if (!item)
+                       {
+                       gint cs;
+
+                       /* ColorSpace == 1 specifies sRGB per EXIF 2.2 */
+                       if (exif_get_integer(exif, "ColorSpace", &cs) &&
+                           cs == 1)
+                               {
+                               input_type = COLOR_PROFILE_SRGB;
+                               input_file = NULL;
+
+                               if (debug) printf("Found EXIF ColorSpace of sRGB\n");
+                               }
+                       }
                }
        if (item && item->format == EXIF_FORMAT_UNDEFINED)
                {
                if (debug) printf("Found embedded color profile\n");
 
-               cm = color_man_new_embedded(imd,
+               cm = color_man_new_embedded(imd, NULL,
                                            item->data, item->data_len,
                                            screen_type, screen_file,
                                            image_post_process_color_cb, imd);
                }
        else
                {
-               cm = color_man_new(imd,
+               cm = color_man_new(imd, NULL,
                                   input_type, input_file,
                                   screen_type, screen_file,
                                   image_post_process_color_cb, imd);
@@ -493,7 +513,7 @@ static void image_read_ahead_start(ImageWindow *imd)
        if (!imd->read_ahead_path || imd->read_ahead_il || imd->read_ahead_pixbuf) return;
 
        /* still loading ?, do later */
-       if (imd->il) return;
+       if (imd->il || imd->cm) return;
 
        if (debug) printf("read ahead started for :%s\n", imd->read_ahead_path);
 
index cc049d6..818cf7a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * GQview
- * (C) 2004 John Ellis
+ * (C) 2006 John Ellis
  *
  * Author: John Ellis
  *
@@ -289,7 +289,7 @@ struct _ImageWindow
        gint color_profile_input;
        gint color_profile_screen;
        gint color_profile_use_image;
-       gpointer *cm;
+       gpointer cm;
 
        AlterType delay_alter_type;
 
index 64e2ba3..2bfa526 100644 (file)
@@ -2341,7 +2341,7 @@ static void file_util_rename_multiple_do(GList *source_list, GtkWidget *parent)
        pref_table_label(table, 0, 1, _("New name:"), 1.0);
 
        rd->rename_entry = gtk_entry_new();
-       gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, FALSE, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), rd->rename_entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
        generic_dialog_attach_default(GENERIC_DIALOG(rd->fd), rd->rename_entry);
        gtk_widget_grab_focus(rd->rename_entry);
 
@@ -2519,7 +2519,7 @@ static void file_util_rename_single_do(const gchar *source_path, GtkWidget *pare
        pref_table_label(table, 0, 1, _("New name:"), 1.0);
 
        fd->entry = gtk_entry_new();
-       gtk_table_attach(GTK_TABLE(table), fd->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, FALSE, 0, 0);
+       gtk_table_attach(GTK_TABLE(table), fd->entry, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
        generic_dialog_attach_default(GENERIC_DIALOG(fd), fd->entry);
        gtk_widget_grab_focus(fd->entry);