chiark / gitweb /
Check rights for menu items too
authorRichard Kettlewell <rjk@greenend.org.uk>
Mon, 9 Jun 2008 08:21:36 +0000 (09:21 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Mon, 9 Jun 2008 08:21:36 +0000 (09:21 +0100)
disobedience/choose.c
disobedience/queue.c

index 9cfcc2e9a85a77857b11fc1759f3ad8b3ec2b7d1..941e89756301c3586a01774f395e7e468c7c4e61 100644 (file)
@@ -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 ---------------------------------------------------- */
index 8ff6b6fcd3c2ba5663ed7a2ec35df5aad0c8d9b8..4bf7cc27c3bbef86afec5a6c8626592d11d6b11b 100644 (file)
@@ -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) {