[rhythmbox] use gtk_application_set_accels_for_action



commit 9bb6406cc28b14b7142e4f2d2d855652a730134f
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Sep 11 20:32:36 2016 +1000

    use gtk_application_set_accels_for_action
    
    requires glib 2.38 for g_action_print_detailed_name

 configure.ac            |    6 +++---
 shell/rb-application.c  |   14 +++++++++++---
 shell/rb-shell-player.c |   18 +++++++++++++++---
 shell/rb-shell.c        |    7 +++++--
 4 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 16afcff..86034fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,7 @@ GTK_REQS=3.16.0
 
 GST_REQS=1.4.0
 GDK_PIXBUF_REQS=2.18.0
-GLIB_REQS=2.36.0
+GLIB_REQS=2.38.0
 LIBGPOD_REQS=0.6
 TOTEM_PLPARSER_REQS=3.2.0
 VALA_REQS=0.9.4
@@ -512,8 +512,8 @@ else
 fi
 
 dnl Set required and max glib/gdk versions
-AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_36, [minimum glib version])
-AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_36, [maximum glib version])
+AC_DEFINE(GLIB_VERSION_MIN_REQUIRED, GLIB_VERSION_2_38, [minimum glib version])
+AC_DEFINE(GLIB_VERSION_MAX_ALLOWED, GLIB_VERSION_2_38, [maximum glib version])
 AC_DEFINE(GDK_VERSION_MIN_REQUIRED, GDK_VERSION_3_16, [minimum gdk version])
 AC_DEFINE(GDK_VERSION_MAX_ALLOWED, GDK_VERSION_3_16, [maximum gdk version])
 AC_DEFINE(CLUTTER_VERSION_MIN_REQUIRED, CLUTTER_VERSION_1_8, [minimum clutter version])
diff --git a/shell/rb-application.c b/shell/rb-application.c
index 0f0620f..089ae5c 100644
--- a/shell/rb-application.c
+++ b/shell/rb-application.c
@@ -855,6 +855,7 @@ set_accelerator (RBApplication *app, GMenuModel *model, int item, gboolean enabl
        const char *key;
        const char *accel = NULL;
        const char *action = NULL;
+       char *detailed_action;
 
        iter = g_menu_model_iterate_item_attributes (model, item);
        while (g_menu_attribute_iter_get_next (iter, &key, &value)) {
@@ -870,10 +871,17 @@ set_accelerator (RBApplication *app, GMenuModel *model, int item, gboolean enabl
        g_object_unref (iter);
 
        if (accel && action) {
+               const char *accels[2] = {
+                       NULL,
+                       NULL
+               };
+
                if (enable)
-                       gtk_application_add_accelerator (GTK_APPLICATION (app), accel, action, target);
-               else
-                       gtk_application_remove_accelerator (GTK_APPLICATION (app), action, target);
+                       accels[0] = accel;
+
+               detailed_action = g_action_print_detailed_name (action, target);
+               gtk_application_set_accels_for_action (GTK_APPLICATION (app), detailed_action, accels);
+               g_free (detailed_action);
        }
 
        if (target)
diff --git a/shell/rb-shell-player.c b/shell/rb-shell-player.c
index 2ad5de2..d197202 100644
--- a/shell/rb-shell-player.c
+++ b/shell/rb-shell-player.c
@@ -2962,6 +2962,18 @@ rb_shell_player_constructed (GObject *object)
                { "volume-up", play_volume_up_action_cb },
                { "volume-down", play_volume_down_action_cb }
        };
+       const char *play_accels[] = {
+               "<Ctrl>p",
+               NULL
+       };
+       const char *play_repeat_accels[] = {
+               "<Ctrl>r",
+               NULL
+       };
+       const char *play_shuffle_accels[] = {
+               "<Ctrl>u",
+               NULL
+       };
 
        RB_CHAIN_GOBJECT_METHOD (rb_shell_player_parent_class, constructed, object);
 
@@ -2980,9 +2992,9 @@ rb_shell_player_constructed (GObject *object)
        rb_application_add_accelerator (app, "<Ctrl>Down", "app.volume-down", NULL);
 
        /* these take effect regardless of widget key handling */
-       gtk_application_add_accelerator (GTK_APPLICATION (app), "<Ctrl>p", "app.play", NULL);
-       gtk_application_add_accelerator (GTK_APPLICATION (app), "<Ctrl>r", "app.play-repeat", 
g_variant_new_boolean (TRUE));
-       gtk_application_add_accelerator (GTK_APPLICATION (app), "<Ctrl>u", "app.play-shuffle", 
g_variant_new_boolean (TRUE));
+       gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.play", play_accels);
+       gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.play-repeat(true)", 
play_repeat_accels);
+       gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.play-shuffle(true)", 
play_shuffle_accels);
 
        player_settings_changed_cb (player->priv->settings, "transition-time", player);
        player_settings_changed_cb (player->priv->settings, "play-order", player);
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index 0130337..f6a671b 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -1683,6 +1683,10 @@ rb_shell_constructed (GObject *object)
        GAction *action;
        RBEntryView *view;
        GApplication *app;
+       const char *jump_accels[] = {
+               "<Ctrl>j",
+               NULL
+       };
 
        /* need this? */
        gtk_init (NULL, NULL);
@@ -1754,8 +1758,7 @@ rb_shell_constructed (GObject *object)
        g_signal_connect (action, "activate", G_CALLBACK (jump_to_playing_action_cb), shell);
        g_action_map_add_action (G_ACTION_MAP (shell->priv->window), action);
 
-       gtk_application_add_accelerator (GTK_APPLICATION (app), "<Ctrl>j", "win.jump-to-playing", NULL);
-
+       gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.jump-to-playing", jump_accels);
 
        rb_debug ("shell: syncing with settings");
 


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