From 5655e63a4fa7078d461cd9074e6a34d22ebecdce Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sun, 13 Aug 2023 18:16:17 +0000 Subject: [PATCH] menu: Add option to change transparency type in View menu This allows quicker access rather than repeatedly going to the Preferences dialogue. --- app/actions/view-actions.c | 58 +++++++++++++++++++++++++++++++++++++ app/actions/view-commands.c | 16 ++++++++++ app/actions/view-commands.h | 3 ++ app/widgets/gimphelp-ids.h | 1 + menus/image-menu.ui.in.in | 12 ++++++++ 5 files changed, 90 insertions(+) diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c index a2873e05e4a..d3bb99862cf 100644 --- a/app/actions/view-actions.c +++ b/app/actions/view-actions.c @@ -588,6 +588,51 @@ static const GimpToggleActionEntry view_padding_color_toggle_actions[] = GIMP_HELP_VIEW_PADDING_COLOR } }; +static const GimpEnumActionEntry view_check_style_actions[] = +{ + { "view-check-style-light-checks", NULL, + NC_("view-check-style", "_Light checks"), NULL, { NULL }, + NC_("view-check-style", "Use light check style for transparency"), + GIMP_CHECK_TYPE_LIGHT_CHECKS, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-midtone-checks", NULL, + NC_("view-check-style", "_Mid-tone checks"), NULL, { NULL }, + NC_("view-check-style", "Use mid-tone check style for transparency"), + GIMP_CHECK_TYPE_GRAY_CHECKS, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-dark-checks", NULL, + NC_("view-check-style", "_Dark checks"), NULL, { NULL }, + NC_("view-check-style", "Use dark check style for transparency"), + GIMP_CHECK_TYPE_DARK_CHECKS, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-white-checks", NULL, + NC_("view-check-style", "_White only"), NULL, { NULL }, + NC_("view-check-style", "Use solid white for transparency"), + GIMP_CHECK_TYPE_WHITE_ONLY, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-gray-checks", NULL, + NC_("view-check-style", "_Gray only"), NULL, { NULL }, + NC_("view-check-style", "Use solid gray for transparency"), + GIMP_CHECK_TYPE_GRAY_ONLY, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-black-checks", NULL, + NC_("view-check-style", "_Black only"), NULL, { NULL }, + NC_("view-check-style", "Use solid black for transparency"), + GIMP_CHECK_TYPE_BLACK_ONLY, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE }, + + { "view-check-style-custom-checks", NULL, + NC_("view-check-style", "_Custom checks"), NULL, { NULL }, + NC_("view-check-style", "Use custom check colors for transparency"), + GIMP_CHECK_TYPE_CUSTOM_CHECKS, FALSE, + GIMP_HELP_VIEW_CHECK_STYLE } +}; + static const GimpEnumActionEntry view_scroll_horizontal_actions[] = { { "view-scroll-horizontal", NULL, @@ -716,6 +761,11 @@ view_actions_setup (GimpActionGroup *group) view_padding_color_toggle_actions, G_N_ELEMENTS (view_padding_color_toggle_actions)); + gimp_action_group_add_enum_actions (group, "view-check-style", + view_check_style_actions, + G_N_ELEMENTS (view_check_style_actions), + view_check_style_cmd_callback); + gimp_action_group_add_enum_actions (group, "view-action", view_scroll_horizontal_actions, G_N_ELEMENTS (view_scroll_horizontal_actions), @@ -954,6 +1004,14 @@ view_actions_update (GimpActionGroup *group, SET_SENSITIVE ("view-padding-color-in-show-all", image); SET_ACTIVE ("view-padding-color-in-show-all", display && options->padding_in_show_all); + SET_SENSITIVE ("view-check-style-light-checks", image); + SET_SENSITIVE ("view-check-style-midtone-checks", image); + SET_SENSITIVE ("view-check-style-dark-checks", image); + SET_SENSITIVE ("view-check-style-white-checks", image); + SET_SENSITIVE ("view-check-style-gray-checks", image); + SET_SENSITIVE ("view-check-style-black-checks", image); + SET_SENSITIVE ("view-check-style-custom-checks", image); + SET_SENSITIVE ("view-show-menubar", image); SET_ACTIVE ("view-show-menubar", display && options->show_menubar); SET_SENSITIVE ("view-show-rulers", image); diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c index dbc5e8911b5..5c944d52cb2 100644 --- a/app/actions/view-commands.c +++ b/app/actions/view-commands.c @@ -1120,6 +1120,22 @@ view_padding_color_cmd_callback (GimpAction *action, } } +void +view_check_style_cmd_callback (GimpAction *action, + GVariant *value, + gpointer data) +{ + GimpCheckType check_style; + GimpDisplay *display; + return_if_no_display (display, data); + + check_style = (GimpCheckType) g_variant_get_int32 (value); + + g_object_set (display->config, + "transparency-type", check_style, + NULL); +} + void view_padding_color_in_show_all_cmd_callback (GimpAction *action, GVariant *value, diff --git a/app/actions/view-commands.h b/app/actions/view-commands.h index c7c7e930e3d..4ec3670c9ac 100644 --- a/app/actions/view-commands.h +++ b/app/actions/view-commands.h @@ -166,6 +166,9 @@ void view_snap_to_equidistance_cmd_callback (GimpAction *action, void view_padding_color_cmd_callback (GimpAction *action, GVariant *value, gpointer data); +void view_check_style_cmd_callback (GimpAction *action, + GVariant *value, + gpointer data); void view_padding_color_in_show_all_cmd_callback (GimpAction *action, GVariant *value, gpointer data); diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index c050234b651..8a18cea23e4 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -121,6 +121,7 @@ #define GIMP_HELP_VIEW_SHOW_SCROLLBARS "gimp-view-show-scrollbars" #define GIMP_HELP_VIEW_SHOW_STATUSBAR "gimp-view-show-statusbar" #define GIMP_HELP_VIEW_PADDING_COLOR "gimp-view-padding-color" +#define GIMP_HELP_VIEW_CHECK_STYLE "gimp-view-check-style" #define GIMP_HELP_VIEW_SHRINK_WRAP "gimp-view-shrink-wrap" #define GIMP_HELP_VIEW_FULLSCREEN "gimp-view-fullscreen" #define GIMP_HELP_VIEW_CHANGE_SCREEN "gimp-view-change-screen" diff --git a/menus/image-menu.ui.in.in b/menus/image-menu.ui.in.in index 094e2be3dfb..e703a0543a0 100644 --- a/menus/image-menu.ui.in.in +++ b/menus/image-menu.ui.in.in @@ -295,6 +295,18 @@ app.view-padding-color-prefs + + Check St_yle +
+ app.view-check-style-light-checks + app.view-check-style-midtone-checks + app.view-check-style-dark-checks + app.view-check-style-white-checks + app.view-check-style-gray-checks + app.view-check-style-black-checks + app.view-check-style-custom-checks +
+
app.view-show-menubar app.view-show-rulers app.view-show-scrollbars -- GitLab