Mercurial > geeqie
changeset 1566:3d9f5c078521
separated Orientation and Grayscale functions
moved Grayscale to Color management menu
author | nadvornik |
---|---|
date | Sat, 25 Apr 2009 22:08:09 +0000 |
parents | 54bb40066b35 |
children | c776b1310ca6 |
files | src/image.c src/image.h src/img-view.c src/layout_image.c src/layout_image.h src/layout_util.c src/lirc.c src/menu.c src/typedefs.h |
diffstat | 9 files changed, 63 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/image.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/image.c Sat Apr 25 22:08:09 2009 +0000 @@ -363,7 +363,7 @@ } -void image_alter(ImageWindow *imd, AlterType type) +void image_alter_orientation(ImageWindow *imd, AlterType type) { static const gint rotate_90[] = {1, 6, 7, 8, 5, 2, 3, 4, 1}; static const gint rotate_90_cc[] = {1, 8, 5, 6, 7, 4, 1, 2, 3}; @@ -393,19 +393,15 @@ case ALTER_FLIP: imd->orientation = flip[imd->orientation]; break; - case ALTER_DESATURATE: - imd->desaturate = !imd->desaturate; - break; case ALTER_NONE: imd->orientation = imd->image_fd->exif_orientation ? imd->image_fd->exif_orientation : 1; - imd->desaturate = FALSE; break; default: return; break; } - if (type != ALTER_NONE && type != ALTER_DESATURATE) + if (type != ALTER_NONE) { if (imd->image_fd->user_orientation == 0) file_data_ref(imd->image_fd); imd->image_fd->user_orientation = imd->orientation; @@ -417,12 +413,22 @@ } pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); +} + +void image_set_desaturate(ImageWindow *imd, gboolean desaturate) +{ + imd->desaturate = desaturate; 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); + pixbuf_renderer_set_orientation((PixbufRenderer *)imd->pr, imd->orientation); } +gboolean image_get_desaturate(ImageWindow *imd) +{ + return imd->desaturate; +} /* *-------------------------------------------------------------------
--- a/src/image.h Sat Apr 25 20:55:11 2009 +0000 +++ b/src/image.h Sat Apr 25 22:08:09 2009 +0000 @@ -76,7 +76,9 @@ gdouble x_align, gdouble y_align); void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y); void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y); -void image_alter(ImageWindow *imd, AlterType type); +void image_alter_orientation(ImageWindow *imd, AlterType type); +void image_set_desaturate(ImageWindow *imd, gboolean desaturate); +gboolean image_get_desaturate(ImageWindow *imd); /* zoom */ void image_zoom_adjust(ImageWindow *imd, gdouble increment);
--- a/src/img-view.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/img-view.c Sat Apr 25 22:08:09 2009 +0000 @@ -448,16 +448,16 @@ switch (event->keyval) { case 'R': case 'r': - image_alter(imd, ALTER_ROTATE_180); + image_alter_orientation(imd, ALTER_ROTATE_180); break; case 'M': case 'm': - image_alter(imd, ALTER_MIRROR); + image_alter_orientation(imd, ALTER_MIRROR); break; case 'F': case 'f': - image_alter(imd, ALTER_FLIP); + image_alter_orientation(imd, ALTER_FLIP); break; case 'G': case 'g': - image_alter(imd, ALTER_DESATURATE); + image_set_desaturate(imd, !image_get_desaturate(imd)); break; case 'P': case 'p': { @@ -558,10 +558,10 @@ view_overlay_toggle(vw); break; case ']': - image_alter(imd, ALTER_ROTATE_90); + image_alter_orientation(imd, ALTER_ROTATE_90); break; case '[': - image_alter(imd, ALTER_ROTATE_90_CC); + image_alter_orientation(imd, ALTER_ROTATE_90_CC); break; case GDK_Delete: case GDK_KP_Delete: if (options->file_ops.enable_delete_key) @@ -1094,7 +1094,7 @@ type = GPOINTER_TO_INT(data); if (!vw) return; - image_alter(vw->imd, type); + image_alter_orientation(vw->imd, type); } static void view_wallpaper_cb(GtkWidget *widget, gpointer data)
--- a/src/layout_image.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/layout_image.c Sat Apr 25 22:08:09 2009 +0000 @@ -331,7 +331,7 @@ lw = submenu_item_get_data(widget); type = (AlterType)GPOINTER_TO_INT(data); - image_alter(lw->image, type); + image_alter_orientation(lw->image, type); } static void li_pop_menu_new_cb(GtkWidget *widget, gpointer data) @@ -884,13 +884,29 @@ } } -void layout_image_alter(LayoutWindow *lw, AlterType type) +void layout_image_alter_orientation(LayoutWindow *lw, AlterType type) +{ + if (!layout_valid(&lw)) return; + + image_alter_orientation(lw->image, type); +} + +void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate) { if (!layout_valid(&lw)) return; - image_alter(lw->image, type); + image_set_desaturate(lw->image, desaturate); } +gboolean layout_image_get_desaturate(LayoutWindow *lw) +{ + if (!layout_valid(&lw)) return FALSE; + + return image_get_desaturate(lw->image); +} + + + const gchar *layout_image_get_path(LayoutWindow *lw) { if (!layout_valid(&lw)) return NULL;
--- a/src/layout_image.h Sat Apr 25 20:55:11 2009 +0000 +++ b/src/layout_image.h Sat Apr 25 22:08:09 2009 +0000 @@ -51,7 +51,9 @@ void layout_image_zoom_adjust_at_point(LayoutWindow *lw, gdouble increment, gint x, gint y, gboolean connect_zoom); void layout_image_zoom_set(LayoutWindow *lw, gdouble zoom, gboolean connect_zoom); void layout_image_zoom_set_fill_geometry(LayoutWindow *lw, gboolean vertical, gboolean connect_zoom); -void layout_image_alter(LayoutWindow *lw, AlterType type); +void layout_image_alter_orientation(LayoutWindow *lw, AlterType type); +void layout_image_set_desaturate(LayoutWindow *lw, gboolean desaturate); +gboolean layout_image_get_desaturate(LayoutWindow *lw); void layout_image_next(LayoutWindow *lw); void layout_image_prev(LayoutWindow *lw);
--- a/src/layout_util.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/layout_util.c Sat Apr 25 22:08:09 2009 +0000 @@ -319,49 +319,49 @@ { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_ROTATE_90); + layout_image_alter_orientation(lw, ALTER_ROTATE_90); } static void layout_menu_alter_90cc_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_ROTATE_90_CC); + layout_image_alter_orientation(lw, ALTER_ROTATE_90_CC); } static void layout_menu_alter_180_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_ROTATE_180); + layout_image_alter_orientation(lw, ALTER_ROTATE_180); } static void layout_menu_alter_mirror_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_MIRROR); + layout_image_alter_orientation(lw, ALTER_MIRROR); } static void layout_menu_alter_flip_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_FLIP); + layout_image_alter_orientation(lw, ALTER_FLIP); } -static void layout_menu_alter_desaturate_cb(GtkAction *action, gpointer data) +static void layout_menu_alter_desaturate_cb(GtkToggleAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_DESATURATE); + layout_image_set_desaturate(lw, gtk_toggle_action_get_active(action)); } static void layout_menu_alter_none_cb(GtkAction *action, gpointer data) { LayoutWindow *lw = data; - layout_image_alter(lw, ALTER_NONE); + layout_image_alter_orientation(lw, ALTER_NONE); } static void layout_menu_config_cb(GtkAction *action, gpointer data) @@ -1301,7 +1301,7 @@ { "GoMenu", NULL, N_("_Go"), NULL, NULL, NULL }, { "EditMenu", NULL, N_("_Edit"), NULL, NULL, NULL }, { "SelectMenu", NULL, N_("_Select"), NULL, NULL, NULL }, - { "AdjustMenu", NULL, N_("_Adjust"), NULL, NULL, NULL }, + { "OrientationMenu", NULL, N_("_Orientation"), NULL, NULL, NULL }, { "ExternalMenu", NULL, N_("E_xternal Editors"), NULL, NULL, NULL }, { "ViewMenu", NULL, N_("_View"), NULL, NULL, NULL }, { "DirMenu", NULL, N_("_View Directory as"), NULL, NULL, NULL }, @@ -1347,7 +1347,6 @@ { "Rotate180", NULL, N_("Rotate 1_80"), "<shift>R", NULL, CB(layout_menu_alter_180_cb) }, { "Mirror", NULL, N_("_Mirror"), "<shift>M", NULL, CB(layout_menu_alter_mirror_cb) }, { "Flip", NULL, N_("_Flip"), "<shift>F", NULL, CB(layout_menu_alter_flip_cb) }, - { "Grayscale", NULL, N_("Toggle _grayscale"),"<shift>G", NULL, CB(layout_menu_alter_desaturate_cb) }, { "AlterNone", NULL, N_("_Original state"), "<shift>O", NULL, CB(layout_menu_alter_none_cb) }, { "SelectAll", NULL, N_("Select _all"), "<control>A", NULL, CB(layout_menu_select_all_cb) }, @@ -1430,6 +1429,7 @@ { "SlideShow", NULL, N_("Toggle _slideshow"),"S", NULL, CB(layout_menu_slideshow_cb), FALSE }, { "UseColorProfiles", NULL, N_("Use _color profiles"), NULL, NULL, CB(layout_color_menu_enable_cb), FALSE}, { "UseImageProfile", NULL, N_("Use profile from _image"), NULL, NULL, CB(layout_color_menu_use_image_cb), FALSE}, + { "Grayscale", NULL, N_("Toggle _grayscale"),"<shift>G", NULL, CB(layout_menu_alter_desaturate_cb), FALSE}, }; static GtkRadioActionEntry menu_radio_entries[] = { @@ -1512,13 +1512,12 @@ " </menu>" " <placeholder name='EditSection'/>" " <separator/>" -" <menu action='AdjustMenu'>" +" <menu action='OrientationMenu'>" " <menuitem action='RotateCW'/>" " <menuitem action='RotateCCW'/>" " <menuitem action='Rotate180'/>" " <menuitem action='Mirror'/>" " <menuitem action='Flip'/>" -" <menuitem action='Grayscale'/>" " <menuitem action='AlterNone'/>" " </menu>" " <placeholder name='PropertiesSection'/>" @@ -1546,6 +1545,8 @@ " <menuitem action='ColorProfile3'/>" " <menuitem action='ColorProfile4'/>" " <menuitem action='ColorProfile5'/>" +" <separator/>" +" <menuitem action='Grayscale'/>" " </menu>" " <menu action='ZoomMenu'>" " <menuitem action='ZoomIn'/>" @@ -2115,6 +2116,9 @@ gtk_action_set_sensitive(action, !use_image); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), (i == input)); } + + action = gtk_action_group_get_action(lw->action_group, "Grayscale"); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), layout_image_get_desaturate(lw)); } static void layout_util_sync_views(LayoutWindow *lw)
--- a/src/lirc.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/lirc.c Sat Apr 25 22:08:09 2009 +0000 @@ -164,11 +164,11 @@ } else if (g_ascii_strcasecmp("ROTATE_90", cmd) == 0) { - layout_image_alter(lw, ALTER_ROTATE_90); + layout_image_alter_orientation(lw, ALTER_ROTATE_90); } else if (g_ascii_strcasecmp("ROTATE_90_CC", cmd) == 0) { - layout_image_alter(lw, ALTER_ROTATE_90_CC); + layout_image_alter_orientation(lw, ALTER_ROTATE_90_CC); } else if (g_ascii_strcasecmp("INFO", cmd) == 0) {
--- a/src/menu.c Sat Apr 25 20:55:11 2009 +0000 +++ b/src/menu.c Sat Apr 25 22:08:09 2009 +0000 @@ -230,9 +230,6 @@ case ALTER_FLIP: return _("_Flip"); break; - case ALTER_DESATURATE: - return _("Toggle _grayscale"); - break; case ALTER_NONE: return _("_Original state"); break; @@ -271,14 +268,13 @@ submenu_add_alter_item(submenu, func, ALTER_ROTATE_180, accel_group, 'R', GDK_SHIFT_MASK); submenu_add_alter_item(submenu, func, ALTER_MIRROR, accel_group, 'M', GDK_SHIFT_MASK); submenu_add_alter_item(submenu, func, ALTER_FLIP, accel_group, 'F', GDK_SHIFT_MASK); - submenu_add_alter_item(submenu, func, ALTER_DESATURATE, accel_group, 'G', GDK_SHIFT_MASK); submenu_add_alter_item(submenu, func, ALTER_NONE, accel_group, 'O', GDK_SHIFT_MASK); if (menu) { GtkWidget *item; - item = menu_item_add(menu, _("_Adjust"), NULL, NULL); + item = menu_item_add(menu, _("_Orientation"), NULL, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); return item; }