Mercurial > geeqie.yaz
changeset 1590:69f7270b3b27
improved color management button:
- now cms menu alway can specify whether use profile from file or not.
- current color profile is shown in the tool tip on cms button.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 03 May 2009 02:21:27 +0900 |
parents | 05909b952b06 |
children | 3681f85cd262 |
files | src/color-man.c src/color-man.h src/image.c src/image.h src/layout.c src/layout_image.c src/layout_image.h |
diffstat | 7 files changed, 93 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/color-man.c Fri May 01 15:50:26 2009 +0900 +++ b/src/color-man.c Sun May 03 02:21:27 2009 +0900 @@ -407,6 +407,41 @@ screen_type, screen_file); } +static gchar *color_man_get_profile_name(ColorManProfileType type, cmsHPROFILE profile) +{ + switch (type) + { + case COLOR_PROFILE_SRGB: + return g_strdup(_("sRGB")); + case COLOR_PROFILE_ADOBERGB: + return g_strdup(_("Adobe RGB compatible")); + break; + case COLOR_PROFILE_MEM: + case COLOR_PROFILE_FILE: + if (profile) + { + return g_strdup(cmsTakeProductName(profile)); + } + return g_strdup(_("Custom profile")); + break; + case COLOR_PROFILE_NONE: + default: + return g_strdup(""); + } +} + +gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile) +{ + ColorManCache *cc; + if (!cm) return FALSE; + + cc = cm->profile; + + if (image_profile) *image_profile = color_man_get_profile_name(cc->profile_in_type, cc->profile_in); + if (screen_profile) *screen_profile = color_man_get_profile_name(cc->profile_out_type, cc->profile_out); + return TRUE; +} + void color_man_free(ColorMan *cm) { if (!cm) return; @@ -444,6 +479,11 @@ return NULL; } +gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile) +{ + return FALSE; +} + void color_man_free(ColorMan *cm) { /* no op */
--- a/src/color-man.h Fri May 01 15:50:26 2009 +0900 +++ b/src/color-man.h Sun May 03 02:21:27 2009 +0900 @@ -61,5 +61,7 @@ void color_man_start_bg(ColorMan *cm, ColorManDoneFunc don_func, gpointer done_data); +gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile); + #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- a/src/image.c Fri May 01 15:50:26 2009 +0900 +++ b/src/image.c Sun May 03 02:21:27 2009 +0900 @@ -332,10 +332,9 @@ #if 0 if (run_in_bg) color_man_start_bg(imd->cm, image_post_process_color_cb, imd); #endif - return TRUE; } - - return FALSE; + image_update_util(imd); + return !!cm; } @@ -1495,6 +1494,16 @@ return imd->color_profile_from_image; } +gboolean image_color_profile_get_status(ImageWindow *imd, gchar **image_profile, gchar **screen_profile) + { + ColorMan *cm; + if (!imd) return FALSE; + + cm = imd->cm; + if (!cm) return FALSE; + return color_man_get_status(cm, image_profile, screen_profile); + } + void image_set_delay_flip(ImageWindow *imd, gboolean delay) { if (!imd ||
--- a/src/image.h Fri May 01 15:50:26 2009 +0900 +++ b/src/image.h Sun May 03 02:21:27 2009 +0900 @@ -111,6 +111,7 @@ void image_color_profile_set_use(ImageWindow *imd, gboolean enable); gboolean image_color_profile_get_use(ImageWindow *imd); gint image_color_profile_get_from_image(ImageWindow *imd); +gboolean image_color_profile_get_status(ImageWindow *imd, gchar **image_profile, gchar **screen_profile); /* set delayed page flipping */ void image_set_delay_flip(ImageWindow *imd, gint delay);
--- a/src/layout.c Fri May 01 15:50:26 2009 +0900 +++ b/src/layout.c Sun May 03 02:21:27 2009 +0900 @@ -500,10 +500,10 @@ menu_item_add_divider(menu); - item = menu_item_add_check(menu, _("Use profile from _image"), use_image, - G_CALLBACK(layout_color_menu_use_image_cb), lw); - gtk_widget_set_sensitive(item, image_profile == COLOR_PROFILE_MEM || (image_profile > COLOR_PROFILE_NONE && image_profile < COLOR_PROFILE_FILE)); - + item = menu_item_add_check(menu, _("Use profile from image if available"), + use_image, + G_CALLBACK(layout_color_menu_use_image_cb), lw); + gtk_widget_set_sensitive(item, TRUE); for (i = COLOR_PROFILE_SRGB; i < COLOR_PROFILE_FILE; i++) { const gchar *label; @@ -730,11 +730,13 @@ void layout_status_update_image(LayoutWindow *lw) { guint64 n; + gchar *image_profile; + gchar *screen_profile; if (!layout_valid(&lw) || !lw->image) return; n = layout_list_count(lw, NULL); - + if (!n) { gtk_label_set_text(GTK_LABEL(lw->info_zoom), ""); @@ -765,19 +767,36 @@ else { gint width, height; - + image_get_image_size(lw->image, &width, &height); text = g_strdup_printf(_("( %d x %d ) %s bytes"), width, height, b); } g_signal_emit_by_name (lw->image->pr, "update-pixel"); - + g_free(b); - + gtk_label_set_text(GTK_LABEL(lw->info_details), text); g_free(text); } + + if (layout_image_color_profile_get_status(lw, &image_profile, &screen_profile)) + { + gchar *buf; + gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, TRUE); + buf = g_strdup_printf(_("Image profile: %s\nScreen profile: %s"), image_profile, screen_profile); + /* FIXME: not sure if a tooltip is the best form of presentation */ + gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), buf); + g_free(image_profile); + g_free(screen_profile); + g_free(buf); + } + else + { + gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, FALSE); + gtk_widget_set_tooltip_text(GTK_WIDGET(lw->info_color), NULL); + } } void layout_status_update_all(LayoutWindow *lw)
--- a/src/layout_image.c Fri May 01 15:50:26 2009 +0900 +++ b/src/layout_image.c Sun May 03 02:21:27 2009 +0900 @@ -1082,6 +1082,8 @@ image_color_profile_set_use(lw->image, enable); +/* xxx --yaz */ +#if 0 if (lw->info_color) { #ifndef HAVE_LCMS @@ -1089,6 +1091,7 @@ #endif gtk_widget_set_sensitive(GTK_BIN(lw->info_color)->child, enable); } +#endif } gboolean layout_image_color_profile_get_use(LayoutWindow *lw) @@ -1105,6 +1108,13 @@ return image_color_profile_get_from_image(lw->image); } +gboolean layout_image_color_profile_get_status(LayoutWindow *lw, gchar **image_profile, gchar **screen_profile) + { + if (!layout_valid(&lw)) return FALSE; + + return image_color_profile_get_status(lw->image, image_profile, screen_profile); + } + /* *---------------------------------------------------------------------------- * list walkers
--- a/src/layout_image.h Fri May 01 15:50:26 2009 +0900 +++ b/src/layout_image.h Sun May 03 02:21:27 2009 +0900 @@ -37,6 +37,7 @@ void layout_image_color_profile_set_use(LayoutWindow *lw, gint enable); gboolean layout_image_color_profile_get_use(LayoutWindow *lw); gint layout_image_color_profile_get_from_image(LayoutWindow *lw); +gboolean layout_image_color_profile_get_status(LayoutWindow *lw, gchar **image_profile, gchar **screen_profile); const gchar *layout_image_get_path(LayoutWindow *lw);