From 983196fb899e3c882ec1dc8bee52cd9e9f9e4b8d Mon Sep 17 00:00:00 2001 Message-Id: <983196fb899e3c882ec1dc8bee52cd9e9f9e4b8d.1716347700.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 9 Jun 2008 09:21:36 +0100 Subject: [PATCH] Check rights for menu items too Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/choose.c | 7 +++++-- disobedience/queue.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/disobedience/choose.c b/disobedience/choose.c index 9cfcc2e..941e897 100644 --- a/disobedience/choose.c +++ b/disobedience/choose.c @@ -1262,12 +1262,15 @@ static void activate_track_properties(GtkMenuItem attribute((unused)) *menuitem, /** @brief Determine whether the menu's play option should be sensitive */ static gboolean sensitive_track_play(struct choosenode attribute((unused)) *cn) { return (!!files_selected - && (disorder_eclient_state(client) & DISORDER_CONNECTED)); + && (disorder_eclient_state(client) & DISORDER_CONNECTED) + && (last_rights & RIGHT_PLAY)); } /** @brief Determine whether the menu's properties option should be sensitive */ static gboolean sensitive_track_properties(struct choosenode attribute((unused)) *cn) { - return !!files_selected && (disorder_eclient_state(client) & DISORDER_CONNECTED); + return (!!files_selected + && (disorder_eclient_state(client) & DISORDER_CONNECTED) + && (last_rights & RIGHT_PREFS)); } /* Directory menu items ---------------------------------------------------- */ diff --git a/disobedience/queue.c b/disobedience/queue.c index 8ff6b6f..4bf7cc2 100644 --- a/disobedience/queue.c +++ b/disobedience/queue.c @@ -1202,7 +1202,9 @@ static int scratch_sensitive(struct queuelike attribute((unused)) *ql, /* We can scratch if the playing track is selected */ return (playing_track && (disorder_eclient_state(client) & DISORDER_CONNECTED) - && selection_selected(ql->selection, playing_track->id)); + && selection_selected(ql->selection, playing_track->id) + && (last_rights & RIGHT_SCRATCH__MASK)); + /* TODO: rights is more complicated than that */ } /** @brief Called when disorder_eclient_scratch completes */ @@ -1228,7 +1230,9 @@ static int remove_sensitive(struct queuelike *ql, return ((disorder_eclient_state(client) & DISORDER_CONNECTED) && ((q && q != playing_track) - || count_selected_nonplaying(ql))); + || count_selected_nonplaying(ql)) + && (last_rights & RIGHT_REMOVE__MASK)); + /* TODO: rights is more complicated than that */ } static void remove_completed(void attribute((unused)) *v, @@ -1260,7 +1264,8 @@ static int properties_sensitive(struct queuelike *ql, struct queue_entry attribute((unused)) *q) { /* "Properties" is sensitive if at least something is selected */ return (hash_count(ql->selection) > 0 - && (disorder_eclient_state(client) & DISORDER_CONNECTED)); + && (disorder_eclient_state(client) & DISORDER_CONNECTED) + && (last_rights & RIGHT_PREFS)); } /** @brief Pop up properties for the selected tracks */ @@ -1307,7 +1312,8 @@ static int play_sensitive(struct queuelike *ql, struct queue_entry attribute((unused)) *q) { /* "Play" is sensitive if at least something is selected */ return (hash_count(ql->selection) > 0 - && (disorder_eclient_state(client) & DISORDER_CONNECTED)); + && (disorder_eclient_state(client) & DISORDER_CONNECTED) + && (last_rights & RIGHT_PLAY)); } /** @brief Play the selected tracks */ @@ -1524,7 +1530,8 @@ static void added_changed(const char attribute((unused)) *event, static int queue_properties_sensitive(GtkWidget *w) { return (!!queue_count_selected(g_object_get_data(G_OBJECT(w), "queue")) - && (disorder_eclient_state(client) & DISORDER_CONNECTED)); + && (disorder_eclient_state(client) & DISORDER_CONNECTED) + && (last_rights & RIGHT_PREFS)); } static int queue_selectall_sensitive(GtkWidget *w) { -- [mdw]