- gtk_label_set_text(GTK_LABEL(report_label), error);
- } else {
- const char *key = v;
-
- cache_put(&cachetype_string, key, value);
- ++namepart_completions_deferred;
- }
- namepart_completed_or_failed();
-}
-
-/** @brief Called when a length lookup has completed */
-static void length_completed(void *v, const char *error, long l) {
- if(error)
- gtk_label_set_text(GTK_LABEL(report_label), error);
- else {
- const char *key = v;
- long *value;
-
- D(("namepart_completed"));
- value = xmalloc(sizeof *value);
- *value = l;
- cache_put(&cachetype_integer, key, value);
- ++namepart_completions_deferred;
- }
- namepart_completed_or_failed();
-}
-
-/** @brief Arrange to fill in a namepart cache entry */
-static void namepart_fill(const char *track,
- const char *context,
- const char *part,
- const char *key) {
- ++namepart_lookups_outstanding;
- disorder_eclient_namepart(client, namepart_completed,
- track, context, part, (void *)key);
-}
-
-/** @brief Look up a namepart
- *
- * If it is in the cache then just return its value. If not then look it up
- * and arrange for the queues to be updated when its value is available. */
-static const char *namepart(const char *track,
- const char *context,
- const char *part) {
- char *key;
- const char *value;
-
- D(("namepart %s %s %s", track, context, part));
- byte_xasprintf(&key, "namepart context=%s part=%s track=%s",
- context, part, track);
- value = cache_get(&cachetype_string, key);
- if(!value) {
- D(("deferring..."));
- /* stick a value in the cache so we don't issue another lookup if we
- * revisit */
- cache_put(&cachetype_string, key, value = "?");
- namepart_fill(track, context, part, key);
- }
- return value;
-}
-
-/** @brief Called from @ref disobedience/properties.c when we know a name part has changed */
-void namepart_update(const char *track,
- const char *context,
- const char *part) {
- char *key;
-
- byte_xasprintf(&key, "namepart context=%s part=%s track=%s",
- context, part, track);
- /* Only refetch if it's actually in the cache */
- if(cache_get(&cachetype_string, key))
- namepart_fill(track, context, part, key);
-}
-
-/** @brief Look up a track length
- *
- * If it is in the cache then just return its value. If not then look it up
- * and arrange for the queues to be updated when its value is available. */
-static long getlength(const char *track) {
- char *key;
- const long *value;
- static const long bogus = -1;
-
- D(("getlength %s", track));
- byte_xasprintf(&key, "length track=%s", track);
- value = cache_get(&cachetype_integer, key);
- if(!value) {
- D(("deferring..."));;
- cache_put(&cachetype_integer, key, value = &bogus);
- ++namepart_lookups_outstanding;
- disorder_eclient_length(client, length_completed, track, key);
- }
- return *value;
-}
-
-/* Column constructors ----------------------------------------------------- */
-
-/** @brief Format the 'when' column */
-static GtkWidget *column_when(const struct queuelike attribute((unused)) *ql,
- const struct queue_entry *q,
- const char attribute((unused)) *data) {
- char when[64];
- struct tm tm;
- time_t t;
-
- D(("column_when"));
- switch(q->state) {
- case playing_isscratch:
- case playing_unplayed:
- case playing_random:
- t = q->expected;
- break;
- case playing_failed:
- case playing_no_player:
- case playing_ok:
- case playing_scratched:
- case playing_started:
- case playing_paused:
- case playing_quitting:
- t = q->played;
- break;
- default:
- t = 0;
- break;
- }
- if(t)
- strftime(when, sizeof when, "%H:%M", localtime_r(&t, &tm));
- else
- when[0] = 0;
- NW(label);
- return gtk_label_new(when);
-}
-
-/** @brief Format the 'who' column */
-static GtkWidget *column_who(const struct queuelike attribute((unused)) *ql,
- const struct queue_entry *q,
- const char attribute((unused)) *data) {
- D(("column_who"));
- NW(label);
- return gtk_label_new(q->submitter ? q->submitter : "");
-}
-
-/** @brief Format one of the track name columns */
-static GtkWidget *column_namepart(const struct queuelike
- attribute((unused)) *ql,
- const struct queue_entry *q,
- const char *data) {
- D(("column_namepart"));
- NW(label);
- return gtk_label_new(truncate_for_display(namepart(q->track, "display", data),
- config->short_display));
-}
-
-/** @brief Compute the length field */
-static const char *text_length(const struct queue_entry *q) {
- long l;
- time_t now;
- char *played = 0, *length = 0;
-
- /* Work out what to say for the length */
- l = getlength(q->track);
- if(l > 0)
- byte_xasprintf(&length, "%ld:%02ld", l / 60, l % 60);
- else
- byte_xasprintf(&length, "?:??");
- /* For the currently playing track we want to report how much of the track
- * has been played */
- if(q == playing_track) {
- /* log_state() arranges that we re-get the playing data whenever the
- * pause/resume state changes */
- if(last_state & DISORDER_TRACK_PAUSED)
- l = playing_track->sofar;
- else {
- time(&now);
- l = playing_track->sofar + (now - last_playing);
- }
- byte_xasprintf(&played, "%ld:%02ld/%s", l / 60, l % 60, length);
- return played;
- } else
- return length;
-}
-
-/** @brief Format the length column */
-static GtkWidget *column_length(const struct queuelike attribute((unused)) *ql,
- const struct queue_entry *q,
- const char attribute((unused)) *data) {
- D(("column_length"));
- if(q == playing_track) {
- assert(!playing_length_label);
- NW(label);
- playing_length_label = gtk_label_new(text_length(q));
- /* Zot playing_length_label when it is destroyed */
- g_signal_connect(playing_length_label, "destroy",
- G_CALLBACK(gtk_widget_destroyed), &playing_length_label);
- return playing_length_label;
- } else {
- NW(label);
- return gtk_label_new(text_length(q));
- }
-
-}
-
-/** @brief Apply a new queue contents, transferring the selection from the old value */
-static void update_queue(struct queuelike *ql, struct queue_entry *newq) {
- struct queue_entry *q;
-
- D(("update_queue"));
- /* Propagate last_click across the change */
- if(ql->last_click) {
- for(q = newq; q; q = q->next) {
- if(!strcmp(q->id, ql->last_click->id))
- break;
- ql->last_click = q;
- }
- }
- /* Tell every queue entry which queue owns it */
- for(q = newq; q; q = q->next)
- q->ql = ql;
- /* Switch to the new queue */
- ql->q = newq;
- /* Clean up any selected items that have fallen off */
- for(q = ql->q; q; q = q->next)
- selection_live(ql->selection, q->id);
- selection_cleanup(ql->selection);
-}
-
-/** @brief Wrap up a widget for putting into the queue or title
- * @param label Label to contain
- * @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,
- GtkStyle *style,
- int *wp) {
- GtkRequisition req;
- GtkWidget *bg;
-
- D(("wrap_queue_cell"));
- /* Padding should be in the label so there are no gaps in the
- * background */
- gtk_misc_set_padding(GTK_MISC(label), HCELLPADDING, VCELLPADDING);
- /* Event box is just to hold a background color */
- NW(event_box);
- bg = gtk_event_box_new();
- gtk_container_add(GTK_CONTAINER(bg), label);
- if(wp) {
- /* Update maximum width */
- gtk_widget_size_request(label, &req);
- if(req.width > *wp) *wp = req.width;
- }
- /* Set colors */
- gtk_widget_set_style(bg, style);
- gtk_widget_set_style(label, style);
- return bg;
-}
-
-/** @brief Create the wrapped widget for a cell in the queue display */
-static GtkWidget *get_queue_cell(struct queuelike *ql,
- const struct queue_entry *q,
- int row,
- int col,
- 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, style, wp);
-}
-
-/** @brief Add a padding cell to the end of a row */
-static GtkWidget *get_padding_cell(GtkStyle *style) {
- D(("get_padding_cell"));
- NW(label);
- return wrap_queue_cell(gtk_label_new(""), style, 0);
-}
-
-/* User button press and menu ---------------------------------------------- */
-
-/** @brief Update widget states in order to reflect the selection status */
-static void set_widget_states(struct queuelike *ql) {
- struct queue_entry *q;
- int row, col;
-
- for(q = ql->q, row = 0; q; q = q->next, ++row) {
- for(col = 0; col < ql->ncolumns + 1; ++col)
- gtk_widget_set_state(ql->cells[row * (ql->ncolumns + 1) + col],
- selection_selected(ql->selection, q->id) ?
- GTK_STATE_SELECTED : GTK_STATE_NORMAL);
- }
- /* Might need to change sensitivity of 'Properties' in main menu */
- menu_update(-1);
-}
-
-/** @brief Ordering function for queue entries */
-static int queue_before(const struct queue_entry *a,
- const struct queue_entry *b) {
- while(a && a != b)
- a = a->next;
- return !!a;
-}
-
-/** @brief A button was pressed and released */
-static gboolean queuelike_button_released(GtkWidget attribute((unused)) *widget,
- GdkEventButton *event,
- gpointer user_data) {
- struct queue_entry *q = user_data, *qq;
- struct queuelike *ql = q->ql;
- struct menuiteminfo *mii;
- int n;
-
- /* Might be a release left over from a drag */
- if(ql->swallow_release) {
- ql->swallow_release = 0;
- return FALSE; /* propagate */
- }
-
- if(event->type == GDK_BUTTON_PRESS
- && event->button == 3) {
- /* Right button click.
- * If the current item is not selected then switch the selection to just
- * this item */
- if(q && !selection_selected(ql->selection, q->id)) {
- selection_empty(ql->selection);
- selection_set(ql->selection, q->id, 1);
- ql->last_click = q;
- set_widget_states(ql);
- }
- /* Set the sensitivity of each menu item and (re-)establish the signal
- * handlers */
- for(n = 0; ql->menuitems[n].name; ++n) {
- if(ql->menuitems[n].handlerid)
- g_signal_handler_disconnect(ql->menuitems[n].w,
- ql->menuitems[n].handlerid);
- gtk_widget_set_sensitive(ql->menuitems[n].w,
- ql->menuitems[n].sensitive(ql,
- &ql->menuitems[n],
- q));
- mii = xmalloc(sizeof *mii);
- mii->ql = ql;
- mii->q = q;
- ql->menuitems[n].handlerid = g_signal_connect
- (ql->menuitems[n].w, "activate",
- G_CALLBACK(ql->menuitems[n].activate), mii);
- }
- /* Update the menu according to context */
- gtk_widget_show_all(ql->menu);
- gtk_menu_popup(GTK_MENU(ql->menu), 0, 0, 0, 0,
- event->button, event->time);
- return TRUE; /* hide the click from other widgets */
- }
- if(event->type == GDK_BUTTON_RELEASE
- && event->button == 1) {
- /* no modifiers: select this, unselect everything else, set last click
- * +ctrl: flip selection of this, set last click
- * +shift: select from last click to here, don't set last click
- * +ctrl+shift: select from last click to here, set last click
- */
- switch(event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) {
- case 0:
- selection_empty(ql->selection);
- selection_set(ql->selection, q->id, 1);
- ql->last_click = q;
- break;
- case GDK_CONTROL_MASK:
- selection_flip(ql->selection, q->id);
- ql->last_click = q;
- break;
- case GDK_SHIFT_MASK:
- case GDK_SHIFT_MASK|GDK_CONTROL_MASK:
- if(ql->last_click) {
- if(!(event->state & GDK_CONTROL_MASK))
- selection_empty(ql->selection);
- selection_set(ql->selection, q->id, 1);
- qq = q;
- if(queue_before(ql->last_click, q))
- while(qq != ql->last_click) {
- qq = qq->prev;
- selection_set(ql->selection, qq->id, 1);
- }
- else
- while(qq != ql->last_click) {
- qq = qq->next;
- selection_set(ql->selection, qq->id, 1);
- }
- if(event->state & GDK_CONTROL_MASK)
- ql->last_click = q;
- }
- break;
- }
- set_widget_states(ql);
- gtk_widget_queue_draw(ql->mainlayout);
- }
- return FALSE; /* propagate */
-}
-
-/** @brief A button was pressed or released on the mainlayout
- *
- * For debugging only at the moment. */
-static gboolean mainlayout_button(GtkWidget attribute((unused)) *widget,
- GdkEventButton attribute((unused)) *event,
- gpointer attribute((unused)) user_data) {
- return FALSE; /* propagate */
-}
-
-/** @brief Select all entries in a queue */
-void queue_select_all(struct queuelike *ql) {
- struct queue_entry *qq;
-
- for(qq = ql->q; qq; qq = qq->next)
- selection_set(ql->selection, qq->id, 1);
- ql->last_click = 0;
- 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;
- const struct queue_entry *qq;
-
- vector_init(&v);
- for(qq = ql->q; qq; qq = qq->next)
- if(selection_selected(ql->selection, qq->id))
- vector_append(&v, (char *)qq->track);
- if(v.nvec)
- properties(v.nvec, (const char **)v.vec);
-}
-
-/* Drag and drop rearrangement --------------------------------------------- */
-
-/** @brief Return nonzero if @p is a draggable row
- *
- * Only tracks in the main queue are draggable (and the currently playing track
- * is not draggable).
- */
-static int draggable_row(const struct queue_entry *q) {
- return q->ql == &ql_queue && q != playing_track;
-}
-
-/** @brief Called when a drag begings */
-static void queue_drag_begin(GtkWidget attribute((unused)) *widget,
- GdkDragContext attribute((unused)) *dc,
- gpointer data) {
- struct queue_entry *q = data;
- struct queuelike *ql = q->ql;
-
- /* Make sure the playing track is not selected, since it cannot be dragged */
- if(playing_track)
- selection_set(ql->selection, playing_track->id, 0);
- /* If the dragged item is not in the selection then change the selection to
- * just that */
- if(!selection_selected(ql->selection, q->id)) {
- selection_empty(ql->selection);
- selection_set(ql->selection, q->id, 1);
- set_widget_states(ql);
- }
- /* Ignore the eventual button release */
- ql->swallow_release = 1;
- /* Create dropzones */
- add_drag_targets(ql);
-}
-
-/** @brief Convert @p id back into a queue entry and a screen row number */
-static struct queue_entry *findentry(struct queuelike *ql,
- const char *id,
- int *rowp) {
- int row;
- struct queue_entry *q;
-
- if(id) {
- for(q = ql->q, row = 0; q && strcmp(q->id, id); q = q->next, ++row)
- ;
- } else {
- q = 0;
- row = playing_track ? 0 : -1;
- }
- if(rowp) *rowp = row;
- return q;
-}
-
-static void move_completed(void attribute((unused)) *v,
- const char *error) {
- if(error)
- popup_protocol_error(0, error);
-}
-
-/** @brief Called when data is dropped */
-static gboolean queue_drag_drop(GtkWidget attribute((unused)) *widget,
- GdkDragContext *drag_context,
- gint attribute((unused)) x,
- gint attribute((unused)) y,
- guint when,
- gpointer user_data) {
- struct queuelike *ql = &ql_queue;
- const char *id = user_data;
- struct vector vec;
- struct queue_entry *q;
-
- if(!id || (playing_track && !strcmp(id, playing_track->id)))
- id = "";
- vector_init(&vec);
- for(q = ql->q; q; q = q->next)
- if(q != playing_track && selection_selected(ql->selection, q->id))
- vector_append(&vec, (char *)q->id);
- disorder_eclient_moveafter(client, id, vec.nvec, (const char **)vec.vec,
- move_completed, 0/*v*/);
- gtk_drag_finish(drag_context, TRUE, TRUE, when);
- /* Destroy dropzones */
- remove_drag_targets(ql);
- return TRUE;
-}
-
-/** @brief Called when we enter, or move within, a drop zone */
-static gboolean queue_drag_motion(GtkWidget attribute((unused)) *widget,
- GdkDragContext *drag_context,
- gint attribute((unused)) x,
- gint attribute((unused)) y,
- guint when,
- gpointer user_data) {
- struct queuelike *ql = &ql_queue;
- const char *id = user_data;
- int row;
- struct queue_entry *q = findentry(ql, id, &row);
-
- if(!id || q) {
- if(!ql->dragmark) {
- NW(event_box);
- ql->dragmark = gtk_event_box_new();
- 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_set_style(ql->dragmark, drag_style);
- gtk_layout_put(GTK_LAYOUT(ql->mainlayout), ql->dragmark, 0,
- (row + 1) * ql->mainrowheight - !!row);
- } else
- gtk_layout_move(GTK_LAYOUT(ql->mainlayout), ql->dragmark, 0,
- (row + 1) * ql->mainrowheight - !!row);
- gtk_widget_show(ql->dragmark);
- gdk_drag_status(drag_context, GDK_ACTION_MOVE, when);
- return TRUE;
- } else
- /* ID has gone AWOL */
- return FALSE;
-}
-
-/** @brief Called when we leave a drop zone */
-static void queue_drag_leave(GtkWidget attribute((unused)) *widget,
- GdkDragContext attribute((unused)) *drag_context,
- guint attribute((unused)) when,
- gpointer attribute((unused)) user_data) {
- struct queuelike *ql = &ql_queue;
-
- if(ql->dragmark)
- gtk_widget_hide(ql->dragmark);
-}
-
-/** @brief Add a drag target
- * @param ql The queue-like (in practice this is always @ref ql_queue)
- * @param y The Y coordinate to place the drag target
- * @param id Track to insert moved tracks after, or NULL
- *
- * Adds a drop zone at Y coordinate @p y, which is assumed to lie between two
- * tracks (or before the start of the queue or after the end of the queue). If
- * tracks are dragged into this dropzone then they will be moved @em after
- * track @p id, or to the start of the queue if @p id is NULL.
- *
- * We remember all the dropzones in @c ql->dropzones so they can be destroyed
- * later.
- */
-static void add_drag_target(struct queuelike *ql, int y,
- const char *id) {
- GtkWidget *eventbox;
-
- NW(event_box);
- eventbox = gtk_event_box_new();
- /* Make the target zone invisible */
- gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), FALSE);
- /* Make it large enough */
- gtk_widget_set_size_request(eventbox, 10240,
- y ? ql->mainrowheight : ql->mainrowheight / 2);
- /* Position it */
- gtk_layout_put(GTK_LAYOUT(ql->mainlayout), eventbox, 0,
- y ? y - ql->mainrowheight / 2 : 0);
- /* Mark it as capable of receiving drops */
- gtk_drag_dest_set(eventbox,
- 0,
- dragtargets, NDRAGTARGETS, GDK_ACTION_MOVE);
- g_signal_connect(eventbox, "drag-drop",
- G_CALLBACK(queue_drag_drop), (char *)id);
- /* Monitor drag motion */
- g_signal_connect(eventbox, "drag-motion",
- G_CALLBACK(queue_drag_motion), (char *)id);
- g_signal_connect(eventbox, "drag-leave",
- G_CALLBACK(queue_drag_leave), (char *)id);
- /* The widget needs to be shown to receive drags */
- gtk_widget_show(eventbox);
- /* Remember the drag targets */
- ql->dropzones[ql->ndropzones] = eventbox;
- g_signal_connect(eventbox, "destroy",
- G_CALLBACK(gtk_widget_destroyed),
- &ql->dropzones[ql->ndropzones]);
- ++ql->ndropzones;
-}
-
-/** @brief Create dropzones for dragging into */
-static void add_drag_targets(struct queuelike *ql) {
- int y;
- struct queue_entry *q;
-
- /* Create an array to store the widgets */
- ql->dropzones = xcalloc(ql->nrows, sizeof (GtkWidget *));
- ql->ndropzones = 0;
- y = 0;
- /* Add a drag target before the first row provided it's not the playing
- * track */
- if(!playing_track || ql->q != playing_track)
- add_drag_target(ql, 0, 0);
- /* Put a drag target at the bottom of every row */
- for(q = ql->q; q; q = q->next) {
- y += ql->mainrowheight;
- add_drag_target(ql, y, q->id);
- }
-}
-
-/** @brief Remove the dropzones */
-static void remove_drag_targets(struct queuelike *ql) {
- int n;
-
- for(n = 0; n < ql->ndropzones; ++n) {
- if(ql->dropzones[n]) {
- DW(event_box);
- gtk_widget_destroy(ql->dropzones[n]);
- }
- assert(ql->dropzones[n] == 0);
- }
-}
-
-/* Layout ------------------------------------------------------------------ */
-
-/** @brief Redisplay a queue */
-static void redisplay_queue(struct queuelike *ql) {
- struct queue_entry *q;
- int row, col;
- GList *c, *children;
- GtkStyle *style;
- GtkRequisition req;
- GtkWidget *w;
- int maxwidths[MAXCOLUMNS], x, y, titlerowheight;
- int totalwidth = 10240; /* TODO: can we be less blunt */
-
- D(("redisplay_queue"));
- /* Eliminate all the existing widgets and start from scratch */
- for(c = children = gtk_container_get_children(GTK_CONTAINER(ql->mainlayout));
- c;
- c = c->next) {
- /* Destroy both the label and the eventbox */
- if(GTK_BIN(c->data)->child) {
- DW(label);
- gtk_widget_destroy(GTK_BIN(c->data)->child);
- }
- DW(event_box);
- gtk_widget_destroy(GTK_WIDGET(c->data));
- }
- g_list_free(children);
- /* Adjust the row count */
- for(q = ql->q, ql->nrows = 0; q; q = q->next)
- ++ql->nrows;
- /* We need to create all the widgets before we can position them */
- ql->cells = xcalloc(ql->nrows * (ql->ncolumns + 1), sizeof *ql->cells);
- /* Minimum width is given by the column headings */
- for(col = 0; col < ql->ncolumns; ++col) {
- /* Reset size so we don't inherit last iteration's maximum size */
- gtk_widget_set_size_request(GTK_BIN(ql->titlecells[col])->child, -1, -1);
- gtk_widget_size_request(GTK_BIN(ql->titlecells[col])->child, &req);
- maxwidths[col] = req.width;
- }
- /* Find the vertical size of the title bar */
- gtk_widget_size_request(GTK_BIN(ql->titlecells[0])->child, &req);
- titlerowheight = req.height;
- y = 0;
- if(ql->nrows) {
- /* 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) 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, style, &maxwidths[col]);
- else
- w = get_padding_cell(style);
- ql->cells[row * (ql->ncolumns + 1) + col] = w;
- /* Maybe mark it draggable */
- if(draggable_row(q)) {
- gtk_drag_source_set(w, GDK_BUTTON1_MASK,
- dragtargets, NDRAGTARGETS, GDK_ACTION_MOVE);
- g_signal_connect(w, "drag-begin", G_CALLBACK(queue_drag_begin), q);
- }
- /* Catch button presses */
- g_signal_connect(w, "button-release-event",
- G_CALLBACK(queuelike_button_released), q);
- g_signal_connect(w, "button-press-event",
- G_CALLBACK(queuelike_button_released), q);
- }
- }
- /* ...and of each row in the main layout */
- gtk_widget_size_request(GTK_BIN(ql->cells[0])->child, &req);
- ql->mainrowheight = req.height;
- /* Now we know the maximum width of each column we can set the size of
- * everything and position it */
- for(row = 0, q = ql->q; row < ql->nrows; ++row, q = q->next) {
- x = 0;
- for(col = 0; col < ql->ncolumns; ++col) {
- w = ql->cells[row * (ql->ncolumns + 1) + col];
- gtk_widget_set_size_request(GTK_BIN(w)->child,
- maxwidths[col], -1);
- gtk_layout_put(GTK_LAYOUT(ql->mainlayout), w, x, y);
- x += maxwidths[col];
- }
- w = ql->cells[row * (ql->ncolumns + 1) + col];
- gtk_widget_set_size_request(GTK_BIN(w)->child,
- totalwidth - x, -1);
- gtk_layout_put(GTK_LAYOUT(ql->mainlayout), w, x, y);
- y += ql->mainrowheight;
- }
- }
- /* Titles */
- x = 0;
- for(col = 0; col < ql->ncolumns; ++col) {
- gtk_widget_set_size_request(GTK_BIN(ql->titlecells[col])->child,
- maxwidths[col], -1);
- gtk_layout_move(GTK_LAYOUT(ql->titlelayout), ql->titlecells[col], x, 0);
- x += maxwidths[col];
- }
- gtk_widget_set_size_request(GTK_BIN(ql->titlecells[col])->child,
- totalwidth - x, -1);
- gtk_layout_move(GTK_LAYOUT(ql->titlelayout), ql->titlecells[col], x, 0);
- /* Set the states */
- set_widget_states(ql);
- /* Make sure it's all visible */
- gtk_widget_show_all(ql->mainlayout);
- gtk_widget_show_all(ql->titlelayout);
- /* Layouts might shrink to arrange for the area they shrink out of to be
- * redrawn */
- gtk_widget_queue_draw(ql->mainlayout);
- gtk_widget_queue_draw(ql->titlelayout);
- /* Adjust the size of the layout */
- gtk_layout_set_size(GTK_LAYOUT(ql->mainlayout), x, y);
- gtk_layout_set_size(GTK_LAYOUT(ql->titlelayout), x, titlerowheight);
- gtk_widget_set_size_request(ql->titlelayout, -1, titlerowheight);
-}
-
-/** @brief Called with new queue/recent contents */
-static void queuelike_completed(void *v,
- const char *error,
- struct queue_entry *q) {
- if(error)