chiark / gitweb /
disobedience uses disorder_short_version_string instead of VERSION
[disorder] / disobedience / queue.c
index 6de64831e175e4a3704b038fd83e0337f2949d3a..7565935dce915c2e21bbe6faaf84baa68da253c4 100644 (file)
@@ -55,6 +55,7 @@
  */
 
 #include "disobedience.h"
+#include "charset.h"
 
 /** @brief Horizontal padding for queue cells */
 #define HCELLPADDING 4
@@ -177,7 +178,7 @@ struct queuelike {
   /** @brief Called when an update completes */
   void (*notify)(void);
 
-  /** @brief Called to  fix up the queue after update
+  /** @brief Called to fix up the queue after update
    * @param q The list passed back from the server
    * @return Assigned to @c ql->q
    */
@@ -258,7 +259,7 @@ static void dump_layout(const struct queuelike *ql) {
 static void namepart_completed_or_failed(void) {
   D(("namepart_completed_or_failed"));
   --namepart_lookups_outstanding;
-  if(!namepart_lookups_outstanding || namepart_completions_deferred > 24) {
+  if(!namepart_lookups_outstanding) {
     redisplay_queue(&ql_queue);
     redisplay_queue(&ql_recent);
     redisplay_queue(&ql_added);
@@ -430,7 +431,8 @@ static GtkWidget *column_namepart(const struct queuelike
                                   const char *data) {
   D(("column_namepart"));
   NW(label);
-  return gtk_label_new(namepart(q->track, "display", data));
+  return gtk_label_new(truncate_for_display(namepart(q->track, "display", data),
+                                            config->short_display));
 }
 
 /** @brief Compute the length field */
@@ -508,13 +510,12 @@ static void update_queue(struct queuelike *ql, struct queue_entry *newq) {
 
 /** @brief Wrap up a widget for putting into the queue or title
  * @param label Label to contain
- * @param color Pointer to color
+ * @param style Pointer to style to use
  * @param wp Updated with maximum width (or NULL)
  * @return New widget
  */
 static GtkWidget *wrap_queue_cell(GtkWidget *label,
-                                  const GdkColor *bgcolor,
-                                  const GdkColor *fgcolor,
+                                  GtkStyle *style,
                                   int *wp) {
   GtkRequisition req;
   GtkWidget *bg;
@@ -533,12 +534,8 @@ static GtkWidget *wrap_queue_cell(GtkWidget *label,
     if(req.width > *wp) *wp = req.width;
   }
   /* Set colors */
-  gtk_widget_modify_bg(bg, GTK_STATE_NORMAL, bgcolor);
-  gtk_widget_modify_bg(bg, GTK_STATE_SELECTED, &selected_bg);
-  gtk_widget_modify_bg(bg, GTK_STATE_PRELIGHT, &selected_bg);
-  gtk_widget_modify_fg(label, GTK_STATE_NORMAL, fgcolor);
-  gtk_widget_modify_fg(label, GTK_STATE_SELECTED, &selected_fg);
-  gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &selected_fg);
+  gtk_widget_set_style(bg, style);
+  gtk_widget_set_style(label, style);
   return bg;
 }
 
@@ -547,22 +544,20 @@ static GtkWidget *get_queue_cell(struct queuelike *ql,
                                  const struct queue_entry *q,
                                  int row,
                                  int col,
-                                 const GdkColor *bgcolor,
-                                 const GdkColor *fgcolor,
+                                 GtkStyle *style,
                                  int *wp) {
   GtkWidget *label;
   D(("get_queue_cell %d %d", row, col));
   label = ql->columns[col].widget(ql, q, ql->columns[col].data);
   gtk_misc_set_alignment(GTK_MISC(label), ql->columns[col].xalign, 0);
-  return wrap_queue_cell(label, bgcolor, fgcolor, wp);
+  return wrap_queue_cell(label, style, wp);
 }
 
 /** @brief Add a padding cell to the end of a row */
-static GtkWidget *get_padding_cell(const GdkColor *bgcolor,
-                                   const GdkColor *fgcolor) {
+static GtkWidget *get_padding_cell(GtkStyle *style) {
   D(("get_padding_cell"));
   NW(label);
-  return wrap_queue_cell(gtk_label_new(""), bgcolor, fgcolor, 0);
+  return wrap_queue_cell(gtk_label_new(""), style, 0);
 }
 
 /* User button press and menu ---------------------------------------------- */
@@ -813,7 +808,7 @@ static gboolean queue_drag_motion(GtkWidget attribute((unused)) *widget,
       g_signal_connect(ql->dragmark, "destroy",
                        G_CALLBACK(gtk_widget_destroyed), &ql->dragmark);
       gtk_widget_set_size_request(ql->dragmark, 10240, row ? 4 : 2);
-      gtk_widget_modify_bg(ql->dragmark, GTK_STATE_NORMAL, &drag_target);
+      gtk_widget_set_style(ql->dragmark, drag_style);
       gtk_layout_put(GTK_LAYOUT(ql->mainlayout), ql->dragmark, 0, 
                      (row + 1) * ql->mainrowheight - !!row);
     } else
@@ -915,7 +910,7 @@ static void redisplay_queue(struct queuelike *ql) {
   struct queue_entry *q;
   int row, col;
   GList *c, *children;
-  const GdkColor *bgcolor;
+  GtkStyle *style;
   GtkRequisition req;  
   GtkWidget *w;
   int maxwidths[MAXCOLUMNS], x, y, titlerowheight;
@@ -955,16 +950,15 @@ static void redisplay_queue(struct queuelike *ql) {
     /* Construct the widgets */
     for(q = ql->q, row = 0; q; q = q->next, ++row) {
       /* Figure out the widget name for this row */
-      if(q == playing_track) bgcolor = &active_bg;
-      else bgcolor = row % 2 ? &even_bg : &odd_bg;
+      if(q == playing_track) style = active_style;
+      else style = row % 2 ? even_style : odd_style;
       /* Make the widget for each column */
       for(col = 0; col <= ql->ncolumns; ++col) {
         /* Create and store the widget */
         if(col < ql->ncolumns)
-          w = get_queue_cell(ql, q, row, col, bgcolor, &item_fg,
-                             &maxwidths[col]);
+          w = get_queue_cell(ql, q, row, col, style, &maxwidths[col]);
         else
-          w = get_padding_cell(bgcolor, &item_fg);
+          w = get_padding_cell(style);
         ql->cells[row * (ql->ncolumns + 1) + col] = w;
         /* Maybe mark it draggable */
         if(draggable_row(q)) {
@@ -1086,9 +1080,10 @@ static GtkWidget *queuelike(struct queuelike *ql,
   /* Create the layouts */
   NW(layout);
   ql->mainlayout = gtk_layout_new(0, 0);
-  gtk_widget_modify_bg(ql->mainlayout, GTK_STATE_NORMAL, &layout_bg);
+  gtk_widget_set_style(ql->mainlayout, layout_style);
   NW(layout);
   ql->titlelayout = gtk_layout_new(0, 0);
+  gtk_widget_set_style(ql->titlelayout, title_style);
   /* Scroll the layouts */
   ql->mainscroll = mainscroll = scroll_widget(ql->mainlayout);
   titlescroll = scroll_widget(ql->titlelayout);
@@ -1103,10 +1098,10 @@ static GtkWidget *queuelike(struct queuelike *ql,
     NW(label);
     label = gtk_label_new(ql->columns[col].name);
     gtk_misc_set_alignment(GTK_MISC(label), ql->columns[col].xalign, 0);
-    ql->titlecells[col] = wrap_queue_cell(label, &title_bg, &title_fg, 0);
+    ql->titlecells[col] = wrap_queue_cell(label, title_style, 0);
     gtk_layout_put(GTK_LAYOUT(ql->titlelayout), ql->titlecells[col], 0, 0);
   }
-  ql->titlecells[col] = get_padding_cell(&title_bg, &title_fg);
+  ql->titlecells[col] = get_padding_cell(title_style);
   gtk_layout_put(GTK_LAYOUT(ql->titlelayout), ql->titlecells[col], 0, 0);
   /* Pack the lot together in a vbox */
   NW(vbox);
@@ -1322,7 +1317,7 @@ GtkWidget *queue_widget(void) {
   /* Arrange periodic update of the so-far played field */
   g_timeout_add(1000/*ms*/, adjust_sofar, 0);
   /* Arrange a callback whenever the playing state changes */ 
-  register_monitor(playing_update, 0,  DISORDER_PLAYING|DISORDER_TRACK_PAUSED);
+  register_monitor(playing_update, 0, DISORDER_PLAYING|DISORDER_TRACK_PAUSED);
   register_reset(queue_update);
   /* We pass choose_update() as our notify function since the choose screen
    * marks tracks that are playing/in the queue. */