[totem/wip/hadess/fix-shortcuts: 4/7] rotation: Fix Ctrl+R/Ctrl+Shift+R not rotating the video




commit adda06390b0369890c8b6e4fd49cd08020a64025
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Aug 22 01:13:00 2020 +0200

    rotation: Fix Ctrl+R/Ctrl+Shift+R not rotating the video
    
    It's not enough to add an accel to the menu item for it to be called
    when pressing those keys, so make sure the accel gets attached to the
    window.

 src/plugins/rotation/totem-rotation.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/src/plugins/rotation/totem-rotation.c b/src/plugins/rotation/totem-rotation.c
index db342df23..183fcd475 100644
--- a/src/plugins/rotation/totem-rotation.c
+++ b/src/plugins/rotation/totem-rotation.c
@@ -226,6 +226,8 @@ impl_activate (PeasActivatable *plugin)
        GMenu *menu;
        GMenuItem *item;
        char *mrl;
+       const char * const rotate_cw[]= { "<Primary>r", NULL };
+       const char * const rotate_ccw[]= { "<Primary><Shift>r", NULL };
 
        priv->totem = g_object_get_data (G_OBJECT (plugin), "object");
        priv->bvw = totem_object_get_video_widget (priv->totem);
@@ -248,12 +250,18 @@ impl_activate (PeasActivatable *plugin)
                          G_CALLBACK (cb_rotate_left), pi);
        g_action_map_add_action (G_ACTION_MAP (priv->totem),
                                 G_ACTION (priv->rotate_left_action));
+       gtk_application_set_accels_for_action (GTK_APPLICATION (priv->totem),
+                                              "app.rotate-left",
+                                              rotate_ccw);
 
        priv->rotate_right_action = g_simple_action_new ("rotate-right", NULL);
        g_signal_connect (G_OBJECT (priv->rotate_right_action), "activate",
                          G_CALLBACK (cb_rotate_right), pi);
        g_action_map_add_action (G_ACTION_MAP (priv->totem),
                                 G_ACTION (priv->rotate_right_action));
+       gtk_application_set_accels_for_action (GTK_APPLICATION (priv->totem),
+                                              "app.rotate-right",
+                                              rotate_cw);
 
        item = g_menu_item_new (_("_Rotate ↷"), "app.rotate-right");
        g_menu_item_set_attribute (item, "accel", "s", "<Primary>R");
@@ -273,6 +281,7 @@ impl_deactivate (PeasActivatable *plugin)
 {
        TotemRotationPlugin *pi = TOTEM_ROTATION_PLUGIN (plugin);
        TotemRotationPluginPrivate *priv = pi->priv;
+       const char * const accels[] = { NULL };
 
        if (priv->cancellable != NULL) {
                g_cancellable_cancel (priv->cancellable);
@@ -282,6 +291,13 @@ impl_deactivate (PeasActivatable *plugin)
        g_signal_handlers_disconnect_by_func (priv->totem, totem_rotation_file_opened, plugin);
        g_signal_handlers_disconnect_by_func (priv->totem, totem_rotation_file_closed, plugin);
 
+       gtk_application_set_accels_for_action (GTK_APPLICATION (priv->totem),
+                                              "app.rotate-right",
+                                              accels);
+       gtk_application_set_accels_for_action (GTK_APPLICATION (priv->totem),
+                                              "app.rotate-left",
+                                              accels);
+
        totem_object_empty_menu_section (priv->totem, "rotation-placeholder");
        g_action_map_remove_action (G_ACTION_MAP (priv->totem), "rotate-left");
        g_action_map_remove_action (G_ACTION_MAP (priv->totem), "rotate-right");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]