Commit 1a755b2d authored by Michael Natterer's avatar Michael Natterer 😴

app: add a View -> Rotate menu

Which so far has "Reset", "90°", "-90°" and "180°" entries.
parent 855fa3aa
......@@ -57,6 +57,8 @@
static void view_actions_set_zoom (GimpActionGroup *group,
GimpDisplayShell *shell);
static void view_actions_set_rotate (GimpActionGroup *group,
GimpDisplayShell *shell);
static void view_actions_check_type_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpActionGroup *group);
......@@ -66,6 +68,7 @@ static const GimpActionEntry view_actions[] =
{
{ "view-menu", NULL, NC_("view-action", "_View") },
{ "view-zoom-menu", NULL, NC_("view-action", "_Zoom") },
{ "view-rotate-menu", NULL, NC_("view-action", "_Rotate") },
{ "view-padding-color-menu", NULL, NC_("view-action", "_Padding Color") },
{ "view-move-to-screen-menu", GIMP_STOCK_MOVE_TO_SCREEN,
NC_("view-action", "Move to Screen"), NULL, NULL, NULL,
......@@ -101,6 +104,12 @@ static const GimpActionEntry view_actions[] =
G_CALLBACK (view_zoom_revert_cmd_callback),
GIMP_HELP_VIEW_ZOOM_REVERT },
{ "view-rotate-reset", NULL,
NC_("view-action", "_Reset to 0°"), NULL,
NC_("view-action", "Reset the angle of rotation to 0°"),
G_CALLBACK (view_rotate_reset_cmd_callback),
GIMP_HELP_VIEW_ROTATE_RESET },
{ "view-navigation-window", GIMP_STOCK_NAVIGATION,
NC_("view-action", "Na_vigation Window"), NULL,
NC_("view-action", "Show an overview window for this image"),
......@@ -379,6 +388,27 @@ static const GimpRadioActionEntry view_zoom_explicit_actions[] =
GIMP_HELP_VIEW_ZOOM_OTHER }
};
static const GimpEnumActionEntry view_rotate_actions[] =
{
{ "view-rotate-90", GIMP_STOCK_ROTATE_90,
NC_("view-action", "Rotate 90° _clockwise"), NULL,
NC_("view-action", "Rotate 90 degrees to the right"),
GIMP_ROTATE_90, FALSE,
GIMP_HELP_VIEW_ROTATE_90 },
{ "view-rotate-180", GIMP_STOCK_ROTATE_180,
NC_("view-action", "Rotate _180°"), NULL,
NC_("view-action", "Turn upside-down"),
GIMP_ROTATE_180, FALSE,
GIMP_HELP_VIEW_ROTATE_180 },
{ "view-rotate-270", GIMP_STOCK_ROTATE_270,
NC_("view-action", "Rotate 90° counter-clock_wise"), NULL,
NC_("view-action", "Rotate 90 degrees to the left"),
GIMP_ROTATE_270, FALSE,
GIMP_HELP_VIEW_ROTATE_270 }
};
static const GimpEnumActionEntry view_padding_color_actions[] =
{
{ "view-padding-color-theme", NULL,
......@@ -515,6 +545,11 @@ view_actions_setup (GimpActionGroup *group)
10000,
G_CALLBACK (view_zoom_explicit_cmd_callback));
gimp_action_group_add_enum_actions (group, "view-rotate-action",
view_rotate_actions,
G_N_ELEMENTS (view_rotate_actions),
G_CALLBACK (view_rotate_cmd_callback));
gimp_action_group_add_enum_actions (group, "view-padding-color",
view_padding_color_actions,
G_N_ELEMENTS (view_padding_color_actions),
......@@ -630,8 +665,16 @@ view_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("view-zoom-1-16", image);
SET_SENSITIVE ("view-zoom-other", image);
SET_SENSITIVE ("view-rotate-reset", image);
SET_SENSITIVE ("view-rotate-90", image);
SET_SENSITIVE ("view-rotate-180", image);
SET_SENSITIVE ("view-rotate-270", image);
if (image)
view_actions_set_zoom (group, shell);
{
view_actions_set_zoom (group, shell);
view_actions_set_rotate (group, shell);
}
SET_SENSITIVE ("view-navigation-window", image);
SET_SENSITIVE ("view-display-filters", image);
......@@ -764,6 +807,17 @@ view_actions_set_zoom (GimpActionGroup *group,
g_free (str);
}
static void
view_actions_set_rotate (GimpActionGroup *group,
GimpDisplayShell *shell)
{
gchar *label;
label = g_strdup_printf (_("_Rotate (%d°)"), (gint) shell->rotate_angle);
gimp_action_group_set_action_label (group, "view-rotate-menu", label);
g_free (label);
}
static void
view_actions_check_type_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
......
......@@ -45,6 +45,7 @@
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-appearance.h"
#include "display/gimpdisplayshell-filter-dialog.h"
#include "display/gimpdisplayshell-rotate.h"
#include "display/gimpdisplayshell-scale.h"
#include "display/gimpdisplayshell-scale-dialog.h"
#include "display/gimpdisplayshell-scroll.h"
......@@ -281,6 +282,41 @@ view_dot_for_dot_cmd_callback (GtkAction *action,
}
}
void
view_rotate_reset_cmd_callback (GtkAction *action,
gpointer data)
{
GimpDisplay *display;
GimpDisplayShell *shell;
return_if_no_display (display, data);
shell = gimp_display_get_shell (display);
gimp_display_shell_rotate_to (shell, 0.0);
}
void
view_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data)
{
GimpDisplay *display;
GimpDisplayShell *shell;
gdouble delta = 0.0;
return_if_no_display (display, data);
shell = gimp_display_get_shell (display);
switch ((GimpRotationType) value)
{
case GIMP_ROTATE_90: delta = 90; break;
case GIMP_ROTATE_180: delta = 180; break;
case GIMP_ROTATE_270: delta = -90; break;
}
gimp_display_shell_rotate (shell, delta);
}
void
view_scroll_horizontal_cmd_callback (GtkAction *action,
gint value,
......
......@@ -48,6 +48,12 @@ void view_scroll_vertical_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void view_rotate_reset_cmd_callback (GtkAction *action,
gpointer data);
void view_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void view_navigation_window_cmd_callback (GtkAction *action,
gpointer data);
void view_display_filters_cmd_callback (GtkAction *action,
......
......@@ -85,6 +85,10 @@
#define GIMP_HELP_VIEW_ZOOM_FIT_IN "gimp-view-zoom-fit-in"
#define GIMP_HELP_VIEW_ZOOM_FILL "gimp-view-zoom-fill"
#define GIMP_HELP_VIEW_ZOOM_OTHER "gimp-view-zoom-other"
#define GIMP_HELP_VIEW_ROTATE_RESET "gimp-view-rotate-reset"
#define GIMP_HELP_VIEW_ROTATE_90 "gimp-view-rotate-90"
#define GIMP_HELP_VIEW_ROTATE_180 "gimp-view-rotate-180"
#define GIMP_HELP_VIEW_ROTATE_270 "gimp-view-rotate-270"
#define GIMP_HELP_VIEW_SHOW_SELECTION "gimp-view-show-selection"
#define GIMP_HELP_VIEW_SHOW_LAYER_BOUNDARY "gimp-view-show-layer-boundary"
#define GIMP_HELP_VIEW_SHOW_GUIDES "gimp-view-show-guides"
......
......@@ -269,6 +269,13 @@
<separator />
<menuitem action="view-zoom-other" />
</menu>
<menu action="view-rotate-menu" name="Rotate">
<menuitem action="view-rotate-reset" />
<separator />
<menuitem action="view-rotate-90" />
<menuitem action="view-rotate-270" />
<menuitem action="view-rotate-180" />
</menu>
<separator />
<menuitem action="view-shrink-wrap" />
<menuitem action="view-fullscreen" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment