[Xfce4-commits] <parole:bluesabre/gtk3> Make previous/next sensitive only when n_items > 1
Sean Davis
noreply at xfce.org
Mon Sep 16 04:24:01 CEST 2013
Updating branch refs/heads/bluesabre/gtk3
to dea0a2e1675b778b69abffb397622c70938bdccc (commit)
from bde5e5b8f297e66b0ee5026f0a6b70574fa521ad (commit)
commit dea0a2e1675b778b69abffb397622c70938bdccc
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sun Sep 15 22:23:22 2013 -0400
Make previous/next sensitive only when n_items > 1
src/parole-medialist.c | 13 +++++++++++++
src/parole-medialist.h | 3 +++
src/parole-player.c | 9 +++++----
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/parole-medialist.c b/src/parole-medialist.c
index afd783b..f309d47 100644
--- a/src/parole-medialist.c
+++ b/src/parole-medialist.c
@@ -249,6 +249,19 @@ parole_media_list_set_playlist_count (ParoleMediaList *list, gint n_items)
g_signal_emit (G_OBJECT (list), signals [MEDIA_CURSOR_CHANGED], 0, n_items != 0);
}
+gint
+parole_media_list_get_playlist_count (ParoleMediaList *list)
+{
+ if (gtk_notebook_get_current_page(GTK_NOTEBOOK(list->priv->playlist_notebook)) == 0)
+ {
+ return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(list->priv->store), NULL);
+ }
+ else
+ {
+ return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(list->priv->disc_store), NULL);
+ }
+}
+
/**
* parole_media_list_add:
* @ParoleMediaList: a #ParoleMediaList
diff --git a/src/parole-medialist.h b/src/parole-medialist.h
index 7d7fa1b..649d4f6 100644
--- a/src/parole-medialist.h
+++ b/src/parole-medialist.h
@@ -108,6 +108,9 @@ parole_media_list_is_selected_row (ParoleMediaList *list);
gboolean parole_media_list_is_empty (ParoleMediaList *list);
+gint
+parole_media_list_get_playlist_count (ParoleMediaList *list);
+
GtkTreeRowReference
*parole_media_list_get_first_row (ParoleMediaList *list);
diff --git a/src/parole-player.c b/src/parole-player.c
index 1b9d572..1443671 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -1219,6 +1219,11 @@ parole_player_media_cursor_changed_cb (ParoleMediaList *list, gboolean media_sel
gtk_action_set_sensitive (player->priv->media_playpause_action,
media_selected || !parole_media_list_is_empty (player->priv->list));
}
+
+ gtk_action_set_sensitive (player->priv->media_previous_action,
+ parole_media_list_get_playlist_count (player->priv->list) > 1);
+ gtk_action_set_sensitive (player->priv->media_next_action,
+ parole_media_list_get_playlist_count (player->priv->list) > 1);
}
static void
@@ -1352,10 +1357,6 @@ parole_player_playing (ParolePlayer *player, const ParoleStream *stream)
gtk_action_set_sensitive (player->priv->media_playpause_action, TRUE);
- /* FIXME: Better detection for when previous/next should be enabled */
- gtk_action_set_sensitive (player->priv->media_previous_action, TRUE);
- gtk_action_set_sensitive (player->priv->media_next_action, TRUE);
-
parole_player_set_playpause_button_from_stock (player, "gtk-media-pause");
gtk_widget_set_sensitive (player->priv->range, seekable);
More information about the Xfce4-commits
mailing list