chiark / gitweb /
Remove tracks from queue with DEL/<--
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 6 Jul 2008 19:43:37 +0000 (20:43 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 6 Jul 2008 19:43:37 +0000 (20:43 +0100)
disobedience/choose.c
disobedience/queue-menu.c
disobedience/queue.c

index 8d8ac08..4cb6f7c 100644 (file)
@@ -505,7 +505,7 @@ static void choose_refill(const char attribute((unused)) *event,
  */
 static gboolean choose_key_event(GtkWidget attribute((unused)) *widget,
                                  GdkEventKey *event,
-                                 gpointer attribute((unused)) user_data) {
+                                 gpointer user_data) {
   /*fprintf(stderr, "choose_key_event type=%d state=%#x keyval=%#x\n",
           event->type, event->state, event->keyval);*/
   switch(event->keyval) {
@@ -535,6 +535,7 @@ static gboolean choose_key_event(GtkWidget attribute((unused)) *widget,
     }
     break;
   }
+  /* Anything not handled we redirected to the search entry field */
   gtk_widget_event(user_data, (GdkEvent *)event);
   return TRUE;                          /* Handled it */
 }
index 75ddeb6..5775ee3 100644 (file)
@@ -127,7 +127,8 @@ static void ql_remove_activate_callback(GtkTreeModel *model,
                                         gpointer attribute((unused)) data) {
   struct queue_entry *q = ql_iter_to_q(model, iter);
 
-  disorder_eclient_remove(client, q->id, ql_remove_completed, q);
+  if(q != playing_track)
+    disorder_eclient_remove(client, q->id, ql_remove_completed, q);
 }
 
 void ql_remove_activate(GtkMenuItem attribute((unused)) *menuitem,
index d69b34d..db013d3 100644 (file)
@@ -326,6 +326,23 @@ static void queue_row_inserted(GtkTreeModel attribute((unused)) *treemodel,
   }
 }
 
+/** @brief Called when a key is pressed in the queue tree view */
+static gboolean queue_key_press(GtkWidget attribute((unused)) *widget,
+                                GdkEventKey *event,
+                                gpointer user_data) {
+  /*fprintf(stderr, "queue_key_press type=%d state=%#x keyval=%#x\n",
+          event->type, event->state, event->keyval);*/
+  switch(event->keyval) {
+  case GDK_BackSpace:
+  case GDK_Delete:
+    if(event->state)
+      break;                            /* Only take unmodified DEL/<-- */
+    ql_remove_activate(0, user_data);
+    return TRUE;                        /* Do not propagate */
+  }
+  return FALSE;                         /* Propagate */
+}
+
 GtkWidget *queue_widget(void) {
   GtkWidget *const w = init_queuelike(&ql_queue);
 
@@ -337,6 +354,9 @@ GtkWidget *queue_widget(void) {
   g_signal_connect(ql_queue.store,
                    "row-deleted",
                    G_CALLBACK(queue_row_deleted), &ql_queue);
+  /* Catch keypresses */
+  g_signal_connect(ql_queue.view, "key-press-event",
+                   G_CALLBACK(queue_key_press), &ql_queue);
   return w;
 }