chiark / gitweb /
Add a 'deselect all tracks' option to Disobedience, using the same
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 20 Jan 2008 12:43:32 +0000 (12:43 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 20 Jan 2008 12:43:32 +0000 (12:43 +0000)
shift+ctrl+a accelerator the Gimp uses for this operation.

CHANGES
disobedience/choose.c
disobedience/disobedience.h
disobedience/menu.c
disobedience/queue.c

diff --git a/CHANGES b/CHANGES
index 4297003172c950551cb665f104535598fbb0c282..3ffe570257d7b202cd0818af9dcefe39603e6521 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -34,7 +34,8 @@ Opera 9.
 ** Disobedience
 
 A bug which would cause a crash if you attempt to rearrange the queue
-while no rtack was playing has been fixed.
+while no rtack was playing has been fixed.  There is a new 'deselect all
+tracks' option, mirroring 'select all tracks.
 
 * Changes up to version 2.0
 
index aabc215b1e567cdcc87ad617a9a6313853813683..0d2fc0baef4c50f52cc6d476ce75e44d45b06214 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2006-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1378,6 +1378,14 @@ static int choose_selectall_sensitive(GtkWidget attribute((unused)) *w) {
   return FALSE;
 }
 
+/** @brief Determine whether the edit menu's select none option should be sensitive
+ *
+ * TODO not implemented,  see also choose_selectnone_activate()
+ */
+static int choose_selectnone_sensitive(GtkWidget attribute((unused)) *w) {
+  return FALSE;
+}
+
 /** @brief Called when the edit menu's properties option is activated */
 static void choose_properties_activate(GtkWidget attribute((unused)) *w) {
   activate_track_properties(0, 0);
@@ -1389,12 +1397,20 @@ static void choose_properties_activate(GtkWidget attribute((unused)) *w) {
 static void choose_selectall_activate(GtkWidget attribute((unused)) *w) {
 }
 
+/** @brief Called when the edit menu's select none option is activated
+ *
+ * TODO not implemented, see choose_selectnone_sensitive() */
+static void choose_selectnone_activate(GtkWidget attribute((unused)) *w) {
+}
+
 /** @brief Main menu callbacks for Choose screen */
 static const struct tabtype tabtype_choose = {
   choose_properties_sensitive,
   choose_selectall_sensitive,
+  choose_selectnone_sensitive,
   choose_properties_activate,
   choose_selectall_activate,
+  choose_selectnone_activate,
 };
 
 /* Public entry points ----------------------------------------------------- */
index 999ef3166df136f600cabd66b848609a1567a296..a664d58c4fb86177427176611abb9afccb71b61a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2006-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -86,8 +86,10 @@ struct callbackdata {
 struct tabtype {
   int (*properties_sensitive)(GtkWidget *tab);
   int (*selectall_sensitive)(GtkWidget *tab);
+  int (*selectnone_sensitive)(GtkWidget *tab);
   void (*properties_activate)(GtkWidget *tab);
   void (*selectall_activate)(GtkWidget *tab);
+  void (*selectnone_activate)(GtkWidget *tab);
 };
 
 /** @brief Button definitions */
@@ -211,7 +213,8 @@ void added_update(void);
  * changed */
 
 void queue_select_all(struct queuelike *ql);
-/* Select all on some queue */
+void queue_select_none(struct queuelike *ql);
+/* Select all/none on some queue */
 
 void queue_properties(struct queuelike *ql);
 /* Pop up properties of selected items in some queue */
index 32b3d26189698c56085c12203934f9d0ea4ea105..80e33cdc9f9a35d1f5927a2956d5080440bee264 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2006-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
 #include "disobedience.h"
 
 static GtkWidget *selectall_widget;
+static GtkWidget *selectnone_widget;
 static GtkWidget *properties_widget;
 
 /** @brief Main menu widgets */
@@ -58,6 +59,20 @@ static void select_all(gpointer attribute((unused)) callback_data,
   t->selectall_activate(tab);
 }
 
+/** @brief Called when the select none option is activated
+ *
+ * Calls the per-tab select none function.
+ */
+static void select_none(gpointer attribute((unused)) callback_data,
+                        guint attribute((unused)) callback_action,
+                        GtkWidget attribute((unused)) *menu_item) {
+  GtkWidget *tab = gtk_notebook_get_nth_page
+    (GTK_NOTEBOOK(tabs), gtk_notebook_current_page(GTK_NOTEBOOK(tabs)));
+  const struct tabtype *t = g_object_get_data(G_OBJECT(tab), "type");
+
+  t->selectnone_activate(tab);
+}
+
 /** @brief Called when the track properties option is activated
  *
  * Calls the per-tab properties function.
@@ -97,6 +112,8 @@ void menu_update(int page) {
                             && (disorder_eclient_state(client) & DISORDER_CONNECTED)));
   gtk_widget_set_sensitive(selectall_widget,
                            t->selectall_sensitive(tab));
+  gtk_widget_set_sensitive(selectnone_widget,
+                           t->selectnone_sensitive(tab));
 }
    
 /** @brief Fetch version in order to display the about... popup */
@@ -227,6 +244,14 @@ GtkWidget *menubar(GtkWidget *w) {
       0,                                /* item_type */
       0                                 /* extra_data */
     },
+    {
+      (char *)"/Edit/Deselect all tracks", /* path */
+      (char *)"<CTRL><SHIFT>A",         /* accelerator */
+      select_none,                      /* callback */
+      0,                                /* callback_action */
+      0,                                /* item_type */
+      0                                 /* extra_data */
+    },
     {
       (char *)"/Edit/Track properties", /* path */
       0,                                /* accelerator */
@@ -316,9 +341,12 @@ GtkWidget *menubar(GtkWidget *w) {
   gtk_window_add_accel_group(GTK_WINDOW(w), accel);
   selectall_widget = gtk_item_factory_get_widget(mainmenufactory,
                                                 "<GdisorderMain>/Edit/Select all tracks");
+  selectnone_widget = gtk_item_factory_get_widget(mainmenufactory,
+                                                "<GdisorderMain>/Edit/Deselect all tracks");
   properties_widget = gtk_item_factory_get_widget(mainmenufactory,
                                                  "<GdisorderMain>/Edit/Track properties");
   assert(selectall_widget != 0);
+  assert(selectnone_widget != 0);
   assert(properties_widget != 0);
   m = gtk_item_factory_get_widget(mainmenufactory,
                                   "<GdisorderMain>");
index 73b49abe8bc6e3c84ec7050ac1fb81151c9abd26..6008e4ed32eb91d10d44cd8ef354165f776e8ef9 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2006,  2007 Richard Kettlewell
+ * Copyright (C) 2006-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -703,6 +703,16 @@ void queue_select_all(struct queuelike *ql) {
   set_widget_states(ql);
 }
 
+/** @brief Deselect all entries in a queue */
+void queue_select_none(struct queuelike *ql) {
+  struct queue_entry *qq;
+
+  for(qq = ql->q; qq; qq = qq->next)
+    selection_set(ql->selection, qq->id, 0);
+  ql->last_click = 0;
+  set_widget_states(ql);
+}
+
 /** @brief Pop up properties for selected tracks */
 void queue_properties(struct queuelike *ql) {
   struct vector v;
@@ -1252,6 +1262,21 @@ static void selectall_activate(GtkMenuItem attribute((unused)) *menuitem,
   queue_select_all(mii->ql);
 }
 
+/** @brief Determine whether the select none menu option should be sensitive */
+static int selectnone_sensitive(struct queuelike *ql,
+                                struct queue_menuitem attribute((unused)) *m,
+                                struct queue_entry attribute((unused)) *q) {
+  /* Sensitive if there is anything selected */
+  return hash_count(ql->selection) != 0;
+}
+
+/** @brief Select no tracks */
+static void selectnone_activate(GtkMenuItem attribute((unused)) *menuitem,
+                               gpointer user_data) {
+  const struct menuiteminfo *mii = user_data;
+  queue_select_none(mii->ql);
+}
+
 /** @brief Determine whether the play menu option should be sensitive */
 static int play_sensitive(struct queuelike *ql,
                           struct queue_menuitem attribute((unused)) *m,
@@ -1311,6 +1336,7 @@ static gboolean adjust_sofar(gpointer attribute((unused)) data) {
 static struct queue_menuitem queue_menu[] = {
   { "Track properties", properties_activate, properties_sensitive, 0, 0 },
   { "Select all tracks", selectall_activate, selectall_sensitive, 0, 0 },
+  { "Deselect all tracks", selectnone_activate, selectnone_sensitive, 0, 0 },
   { "Scratch track", scratch_activate, scratch_sensitive, 0, 0 },
   { "Remove track from queue", remove_activate, remove_sensitive, 0, 0 },
   { 0, 0, 0, 0, 0 }
@@ -1383,6 +1409,7 @@ static struct queue_entry *fixup_recent(struct queue_entry *q) {
 static struct queue_menuitem recent_menu[] = {
   { "Track properties", properties_activate, properties_sensitive,0, 0 },
   { "Select all tracks", selectall_activate, selectall_sensitive, 0, 0 },
+  { "Deselect all tracks", selectnone_activate, selectnone_sensitive, 0, 0 },
   { 0, 0, 0, 0, 0 }
 };
 
@@ -1416,6 +1443,7 @@ static struct queue_menuitem added_menu[] = {
   { "Track properties", properties_activate, properties_sensitive, 0, 0 },
   { "Play track", play_activate, play_sensitive, 0, 0 },
   { "Select all tracks", selectall_activate, selectall_sensitive, 0, 0 },
+  { "Deselect all tracks", selectnone_activate, selectnone_sensitive, 0, 0 },
   { 0, 0, 0, 0, 0 }
 };
 
@@ -1474,6 +1502,12 @@ static int queue_selectall_sensitive(GtkWidget *w) {
   return !!queue_count_entries(g_object_get_data(G_OBJECT(w), "queue"));
 }
 
+static int queue_selectnone_sensitive(GtkWidget *w) {
+  struct queuelike *const ql = g_object_get_data(G_OBJECT(w), "queue");
+
+  return hash_count(ql->selection) != 0;
+}
+
 static void queue_properties_activate(GtkWidget *w) {
   queue_properties(g_object_get_data(G_OBJECT(w), "queue"));
 }
@@ -1482,11 +1516,17 @@ static void queue_selectall_activate(GtkWidget *w) {
   queue_select_all(g_object_get_data(G_OBJECT(w), "queue"));
 }
 
+static void queue_selectnone_activate(GtkWidget *w) {
+  queue_select_none(g_object_get_data(G_OBJECT(w), "queue"));
+}
+
 static const struct tabtype tabtype_queue = {
   queue_properties_sensitive,
   queue_selectall_sensitive,
+  queue_selectnone_sensitive,
   queue_properties_activate,
   queue_selectall_activate,
+  queue_selectnone_activate,
 };
 
 /* Other entry points ------------------------------------------------------ */