[rhythmbox] shell: follow the playing track in the track list
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] shell: follow the playing track in the track list
- Date: Wed, 21 Aug 2013 23:08:23 +0000 (UTC)
commit ed78da7b38f7a7a9f62fdcea1d79a20d641d0a25
Author: Jonathan Matthew <jonathan d14n org>
Date: Thu Aug 22 09:05:13 2013 +1000
shell: follow the playing track in the track list
Jump to the new playing track when it changes. There is now a
setting that controls this, and an item in the app menu (under
view) for changing it. While we're here, add an accelerator
key for jumping to the playing track, since that went missing
a while ago.
data/org.gnome.rhythmbox.gschema.xml | 5 ++
data/ui/app-menu.ui | 4 ++
shell/rb-shell.c | 92 +++++++++++++++++++---------------
3 files changed, 60 insertions(+), 41 deletions(-)
---
diff --git a/data/org.gnome.rhythmbox.gschema.xml b/data/org.gnome.rhythmbox.gschema.xml
index c6d6b96..cde93d2 100644
--- a/data/org.gnome.rhythmbox.gschema.xml
+++ b/data/org.gnome.rhythmbox.gschema.xml
@@ -100,6 +100,11 @@
<summary>Whether to show elapsed or remaining time</summary>
<description>If true, the elapsed time will be shown in song duration displays. Otherwise the
remaining time will be shown.</description>
</key>
+ <key name="follow-playing" type="b">
+ <default>true</default>
+ <summary>Whether to follow the playing track in the track list</summary>
+ <description>If true, as the playing track changes, the track list will scroll to show the new
track</description>
+ </key>
</schema>
<schema id="org.gnome.rhythmbox.rhythmdb" path="/org/gnome/rhythmbox/rhythmdb/">
diff --git a/data/ui/app-menu.ui b/data/ui/app-menu.ui
index 5872333..07efd69 100644
--- a/data/ui/app-menu.ui
+++ b/data/ui/app-menu.ui
@@ -38,6 +38,10 @@
<attribute name="label" translatable="yes">Album Art</attribute>
<attribute name="action">win.show-album-art</attribute>
</item>
+ <item>
+ <attribute name="label" translatable="yes">Follow Playing Track</attribute>
+ <attribute name="action">win.follow-playing</attribute>
+ </item>
</section>
<section>
<attribute name="rb-plugin-menu-link">view</attribute>
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index fbc54b8..07934f9 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -159,10 +159,10 @@ static void rb_shell_player_window_title_changed_cb (RBShellPlayer *player,
const char *window_title,
RBShell *shell);
static void rb_shell_playing_changed_cb (RBShellPlayer *player, gboolean playing, RBShell *shell);
+static void rb_shell_playing_song_changed_cb (RBShellPlayer *player, RhythmDBEntry *entry, RBShell *shell);
+static void rb_shell_settings_changed_cb (GSettings *settings, const char *key, RBShell *shell);
-static void rb_shell_jump_to_current (RBShell *shell);
-static void rb_shell_jump_to_entry_with_source (RBShell *shell, RBSource *source,
- RhythmDBEntry *entry);
+static void rb_shell_jump_to_current (RBShell *shell, gboolean select_page);
static void rb_shell_play_entry (RBShell *shell, RhythmDBEntry *entry);
static void rb_shell_load_complete_cb (RhythmDB *db, RBShell *shell);
static void rb_shell_set_visibility (RBShell *shell,
@@ -539,6 +539,10 @@ construct_widgets (RBShell *shell)
"playing-changed",
G_CALLBACK (rb_shell_playing_changed_cb),
shell, 0);
+ g_signal_connect_object (shell->priv->player_shell,
+ "playing-song-changed",
+ G_CALLBACK (rb_shell_playing_song_changed_cb),
+ shell, 0);
shell->priv->clipboard_shell = rb_shell_clipboard_new (shell->priv->db);
shell->priv->display_page_tree = rb_display_page_tree_new (shell);
@@ -1688,6 +1692,7 @@ rb_shell_constructed (GObject *object)
RBShell *shell;
GAction *action;
RBEntryView *view;
+ GApplication *app;
/* need this? */
gtk_init (NULL, NULL);
@@ -1695,6 +1700,7 @@ rb_shell_constructed (GObject *object)
RB_CHAIN_GOBJECT_METHOD (rb_shell_parent_class, constructed, object);
shell = RB_SHELL (object);
+ app = g_application_get_default ();
/* construct enough of the rest of it to display the window if required */
@@ -1740,6 +1746,10 @@ rb_shell_constructed (GObject *object)
shell->priv->statusbar, "visible",
G_SETTINGS_BIND_DEFAULT);
+ action = g_settings_create_action (shell->priv->settings, "follow-playing");
+ g_action_map_add_action (G_ACTION_MAP (shell->priv->window), action);
+ g_signal_connect (shell->priv->settings, "changed", G_CALLBACK (rb_shell_settings_changed_cb), shell);
+
action = G_ACTION (g_simple_action_new_stateful ("party-mode",
NULL,
g_variant_new_boolean (FALSE)));
@@ -1748,12 +1758,14 @@ rb_shell_constructed (GObject *object)
action = G_ACTION (g_simple_action_new ("library-import", NULL));
g_signal_connect (action, "activate", G_CALLBACK (add_music_action_cb), shell);
- g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), action);
+ g_action_map_add_action (G_ACTION_MAP (app), action);
action = G_ACTION (g_simple_action_new ("jump-to-playing", NULL));
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);
+
rb_debug ("shell: syncing with settings");
@@ -2302,6 +2314,24 @@ rb_shell_playing_changed_cb (RBShellPlayer *player, gboolean playing, RBShell *s
}
static void
+rb_shell_playing_song_changed_cb (RBShellPlayer *player, RhythmDBEntry *entry, RBShell *shell)
+{
+ if (g_settings_get_boolean (shell->priv->settings, "follow-playing")) {
+ rb_shell_jump_to_current (shell, FALSE);
+ }
+}
+
+static void
+rb_shell_settings_changed_cb (GSettings *settings, const char *key, RBShell *shell)
+{
+ if (g_strcmp0 (key, "follow-playing") == 0) {
+ if (g_settings_get_boolean (settings, key)) {
+ rb_shell_jump_to_current (shell, FALSE);
+ }
+ }
+}
+
+static void
rb_shell_select_page (RBShell *shell, RBDisplayPage *page)
{
int pagenum;
@@ -2635,35 +2665,7 @@ jump_to_playing_action_cb (GSimpleAction *action, GVariant *parameters, gpointer
{
RBShell *shell = RB_SHELL (data);
rb_debug ("current song");
- rb_shell_jump_to_current (shell);
-}
-
-static void
-rb_shell_jump_to_entry_with_source (RBShell *shell,
- RBSource *source,
- RhythmDBEntry *entry)
-{
- RBEntryView *songs;
-
- g_return_if_fail (entry != NULL);
-
- if ((source == RB_SOURCE (shell->priv->queue_source) &&
- g_settings_get_boolean (shell->priv->settings, "queue-as-sidebar")) ||
- source == NULL) {
- RhythmDBEntryType *entry_type;
- entry_type = rhythmdb_entry_get_entry_type (entry);
- source = rb_shell_get_source_by_entry_type (shell, entry_type);
- }
- if (source == NULL)
- return;
-
- songs = rb_source_get_entry_view (source);
- rb_shell_select_page (shell, RB_DISPLAY_PAGE (source));
-
- if (songs != NULL) {
- rb_entry_view_scroll_to_entry (songs, entry);
- rb_entry_view_select_entry (songs, entry);
- }
+ rb_shell_jump_to_current (shell, TRUE);
}
static void
@@ -2671,24 +2673,32 @@ rb_shell_play_entry (RBShell *shell,
RhythmDBEntry *entry)
{
rb_shell_player_stop (shell->priv->player_shell);
- rb_shell_jump_to_entry_with_source (shell, NULL, entry);
rb_shell_player_play_entry (shell->priv->player_shell, entry, NULL);
}
static void
-rb_shell_jump_to_current (RBShell *shell)
+rb_shell_jump_to_current (RBShell *shell, gboolean select_page)
{
RBSource *source;
- RhythmDBEntry *playing;
+ RhythmDBEntry *entry;
+ RBEntryView *songs;
source = rb_shell_player_get_playing_source (shell->priv->player_shell);
+ if (source == NULL)
+ return;
- g_return_if_fail (source != NULL);
-
- playing = rb_shell_player_get_playing_entry (shell->priv->player_shell);
+ if (select_page) {
+ rb_shell_select_page (shell, RB_DISPLAY_PAGE (source));
+ }
- rb_shell_jump_to_entry_with_source (shell, source, playing);
- rhythmdb_entry_unref (playing);
+ songs = rb_source_get_entry_view (source);
+ if (songs != NULL) {
+ entry = rb_shell_player_get_playing_entry (shell->priv->player_shell);
+ if (entry != NULL) {
+ rb_entry_view_scroll_to_entry (songs, entry);
+ rhythmdb_entry_unref (entry);
+ }
+ }
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]