Commit 995efcdf authored by Anders Carlsson's avatar Anders Carlsson Committed by Anders Carlsson

Update to matched changed return value from nautilus_program_chooser_new

2002-01-04  Anders Carlsson  <andersca@gnu.org>

	* libnautilus-private/nautilus-program-choosing.c:
	Update to matched changed return value from
	nautilus_program_chooser_new ().

	* libnautilus-private/nautilus-program-chooser.h:
	* libnautilus-private/nautilus-program-chooser.c:
	Port to GtkTreeView, and make NautilusProgramChooser
	into a real object.

	* components/Makefile.am: Re-enable the music
	view.

	* components/music/nautilus-music-view.c: Port to
	GtkTreeView and GNOME2.
parent eaca3673
2002-01-04 Anders Carlsson <andersca@gnu.org>
* libnautilus-private/nautilus-program-choosing.c:
Update to matched changed return value from
nautilus_program_chooser_new ().
* libnautilus-private/nautilus-program-chooser.h:
* libnautilus-private/nautilus-program-chooser.c:
Port to GtkTreeView, and make NautilusProgramChooser
into a real object.
* components/Makefile.am: Re-enable the music
view.
* components/music/nautilus-music-view.c: Port to
GtkTreeView and GNOME2.
2002-01-03 Andy Hertzfeld <andy@differnet.com>
reviewed by: <darin@bentspoon.com>
......
......@@ -3,6 +3,7 @@ NULL=
SUBDIRS = \
history \
image-viewer \
music \
news \
notes \
sample \
......@@ -14,6 +15,5 @@ XXX=
adapter \
hardware \
loser \
music \
text \
$(NULL)
......@@ -2,6 +2,7 @@
/*
* Copyright (C) 2000, 2001 Eazel, Inc.
* Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -17,7 +18,8 @@
* along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Author: Andy Hertzfeld <andy@eazel.com>
* Authors: Andy Hertzfeld <andy@eazel.com>
* Anders Carlsson <andersca@gnu.org>
*
*/
......@@ -46,8 +48,15 @@
#include <fcntl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkeventbox.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktreeview.h>
#include <libgnomevfs/gnome-vfs-directory.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-directory-background.h>
#include <libnautilus-private/nautilus-directory-notify.h>
#include <libnautilus-private/nautilus-file-attributes.h>
......@@ -71,22 +80,10 @@ typedef enum {
PLAYER_NEXT
} PlayerState;
typedef enum {
TRACK_NUMBER = 0,
TITLE,
ARTIST,
BITRATE,
TIME
} Column;
struct NautilusMusicViewDetails {
NautilusFile *file;
GtkWidget *event_box;
int sort_column;
int sort_reversed;
int selected_index;
int status_timeout;
......@@ -95,10 +92,12 @@ struct NautilusMusicViewDetails {
gboolean slider_dragging;
GtkListStore *list_store;
GtkWidget *tree_view;
GtkVBox *album_container;
GtkWidget *scroll_window;
GtkWidget *album_title;
GtkWidget *song_list;
GtkWidget *album_image;
GtkWidget *image_box;
GtkWidget *dialog;
......@@ -149,6 +148,20 @@ enum {
TARGET_GNOME_URI_LIST
};
/* list columns */
enum {
TRACK_NUMBER_COLUMN,
TITLE_COLUMN,
ARTIST_COLUMN,
BITRATE_COLUMN,
TIME_COLUMN,
SAMPLE_RATE_COLUMN,
YEAR_COLUMN,
COMMENT_COLUMN,
PATH_URI_COLUMN,
ALBUM_COLUMN,
NUM_COLUMNS
};
/* button commands */
enum {
......@@ -176,25 +189,24 @@ static void nautilus_music_view_drag_data_received (GtkWidget
gpointer user_data);
static void nautilus_music_view_class_init (NautilusMusicViewClass *klass);
static void nautilus_music_view_init (NautilusMusicView *view);
static void nautilus_music_view_destroy (GtkObject *object);
static void nautilus_music_view_destroy (BonoboObject *object);
static void nautilus_music_view_finalize (GObject *object);
static void nautilus_music_view_update (NautilusMusicView *music_view);
static void music_view_background_appearance_changed_callback (EelBackground *background,
NautilusMusicView *music_view);
static void music_view_load_location_callback (NautilusView *view,
const char *location,
NautilusMusicView *music_view);
static void selection_callback (EelCList *clist,
int row,
int column,
GdkEventButton *event,
static void selection_changed (GtkTreeSelection *selection,
NautilusMusicView *music_view);
static void row_activated_callback (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
NautilusMusicView *music_view);
static void value_changed_callback (GtkAdjustment *adjustment,
EelCList *clist);
static void nautilus_music_view_set_album_image (NautilusMusicView *music_view,
const char *image_path_uri);
static void click_column_callback (EelCList *clist,
int column,
NautilusMusicView *music_view);
static void image_button_callback (GtkWidget *widget,
NautilusMusicView *music_view);
static void go_to_next_track (NautilusMusicView *music_view);
......@@ -207,10 +219,11 @@ static void stop_playing_file (NautilusMusicView *music_view);
static PlayerState get_player_state (NautilusMusicView *music_view);
static void set_player_state (NautilusMusicView *music_view,
PlayerState state);
static void sort_list (NautilusMusicView *music_view);
static void list_reveal_row (EelCList *clist,
static void list_reveal_row (GtkTreeView *view,
int row_index);
static void nautilus_music_view_load_uri (NautilusMusicView *view,
const char *uri);
......@@ -233,30 +246,156 @@ nautilus_music_view_class_init (NautilusMusicViewClass *klass)
gobject_class->finalize = nautilus_music_view_finalize;
}
static char *
get_cell_text (GtkWidget *widget, int column_index, int cell_width,
EelCListRow *row, GdkFont *font, gpointer data)
static void
track_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
const char *cell_text;
EelCList *clist;
clist = EEL_CLIST (widget);
switch ((EelCellType)row->cell[column_index].type) {
case EEL_CELL_PIXTEXT:
cell_text = EEL_CELL_PIXTEXT (row->cell[column_index])->text;
break;
case EEL_CELL_TEXT:
case EEL_CELL_LINK_TEXT:
cell_text = EEL_CELL_TEXT (row->cell[column_index])->text;
break;
default:
g_assert_not_reached ();
cell_text = NULL;
break;
}
return eel_string_ellipsize (cell_text, font, cell_width, EEL_ELLIPSIZE_END);
int track_number;
char *str;
gtk_tree_model_get (tree_model,
iter,
TRACK_NUMBER_COLUMN, &track_number,
-1);
/* Don't show the track number if it's lower than 1 */
if (track_number < 1) {
str = NULL;
}
else {
str = g_strdup_printf ("%d", track_number);
}
g_object_set (cell,
"text", str,
NULL);
g_free (str);
}
static void
bitrate_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
int bitrate;
char *str;
gtk_tree_model_get (tree_model,
iter,
BITRATE_COLUMN, &bitrate,
-1);
if (bitrate <= 0) {
str = g_strdup (_("Unknown"));
}
else {
str = g_strdup_printf ("%d kbps", bitrate);
}
g_object_set (cell,
"text", str,
NULL);
g_free (str);
}
static void
time_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
{
int time;
int seconds, minutes, remain_seconds;
char *str;
gtk_tree_model_get (tree_model,
iter,
TIME_COLUMN, &time,
-1);
seconds = time;
minutes = seconds / 60;
remain_seconds = seconds - (60 * minutes);
str = g_strdup_printf ("%d:%02d ", minutes, remain_seconds);
g_object_set (cell,
"text", str,
NULL);
g_free (str);
}
static void
set_up_tree_view (NautilusMusicView *music_view)
{
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
GtkTreeView *tree_view;
tree_view = GTK_TREE_VIEW (music_view->details->tree_view);
/* The track number column */
cell = gtk_cell_renderer_text_new ();
g_object_set (cell,
"xalign", 1.0,
NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Track"));
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_cell_data_func (column, cell,
track_cell_data_func,
NULL, NULL);
gtk_tree_view_column_set_sort_column_id (column, TRACK_NUMBER_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (tree_view, column);
/* The name column */
cell = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Title"),
cell,
"text", TITLE_COLUMN,
NULL);
gtk_tree_view_column_set_sort_column_id (column, TITLE_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (tree_view, column);
/* The artist column */
cell = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Artist"),
cell,
"text", ARTIST_COLUMN,
NULL);
gtk_tree_view_column_set_sort_column_id (column, ARTIST_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (tree_view, column);
/* The bitrate column */
cell = gtk_cell_renderer_text_new ();
g_object_set (cell,
"xalign", 1.0,
NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Bit Rate"));
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_cell_data_func (column, cell,
bitrate_cell_data_func,
NULL, NULL);
gtk_tree_view_column_set_sort_column_id (column, BITRATE_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (tree_view, column);
/* The time column */
cell = gtk_cell_renderer_text_new ();
g_object_set (cell,
"xalign", 1.0,
NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Time"));
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_cell_data_func (column, cell,
time_cell_data_func,
NULL, NULL);
gtk_tree_view_column_set_sort_column_id (column, TIME_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (tree_view, column);
}
/* initialize ourselves by connecting to the location change signal and allocating our subviews */
......@@ -268,16 +407,6 @@ nautilus_music_view_init (NautilusMusicView *music_view)
GtkWidget *button;
char *font_name;
int standard_font_size;
GdkFont *font;
guint i;
gpointer foo;
char *titles[] = { N_("Track"), N_("Title"), N_("Artist"), N_("Bit Rate"), N_("Time")};
foo = &selection_callback;
foo = &value_changed_callback;
foo = &click_column_callback;
foo = &get_cell_text;
music_view->details = g_new0 (NautilusMusicViewDetails, 1);
......@@ -313,69 +442,60 @@ nautilus_music_view_init (NautilusMusicView *music_view)
gtk_container_add (GTK_CONTAINER (music_view->details->event_box), GTK_WIDGET (music_view->details->album_container));
/* allocate a widget for the album title */
music_view->details->album_title = eel_label_new ("");
music_view->details->album_title = gtk_label_new ("");
gtk_widget_show (music_view->details->album_title);
eel_label_make_larger (EEL_LABEL (music_view->details->album_title), 8);
gtk_box_pack_start (GTK_BOX (music_view->details->album_container), music_view->details->album_title, FALSE, FALSE, 0);
/* Localize the titles */
for (i = 0; i < G_N_ELEMENTS (titles); i++) {
titles[i] = _(titles[i]);
}
/* allocate a list widget to hold the song list */
music_view->details->song_list = eel_list_new_with_titles (G_N_ELEMENTS (titles), (const char * const *) titles);
/* Create list model*/
music_view->details->list_store = gtk_list_store_new (NUM_COLUMNS,
G_TYPE_INT, /* TRACK_NUMBER_COLUMN */
G_TYPE_STRING, /* TITLE_COLUMN */
G_TYPE_STRING, /* ARTIST_COLUMN */
G_TYPE_INT, /* BITRATE_COLUMN */
G_TYPE_INT, /* TIME_COLUMN */
G_TYPE_INT, /* BITRATE_COLUMN */
G_TYPE_STRING, /* YEAR_COLUMN */
G_TYPE_STRING, /* COMMENT_COLUMN */
G_TYPE_STRING, /* PATH_URI_COLUMN */
G_TYPE_STRING /* ALBUM_COLUMN */);
music_view->details->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (music_view->details->list_store));
g_signal_connect (music_view->details->tree_view,
"row_activated",
G_CALLBACK (row_activated_callback),
music_view);
EEL_CLIST_SET_FLAG (EEL_CLIST (music_view->details->song_list), CLIST_SHOW_TITLES);
g_object_unref (music_view->details->list_store);
set_up_tree_view (music_view);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (music_view->details->tree_view)),
"changed",
G_CALLBACK (selection_changed),
music_view);
gtk_widget_show (music_view->details->song_list);
/* We sort ascending by track number by default */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (music_view->details->list_store),
TRACK_NUMBER_COLUMN, GTK_SORT_ASCENDING);
g_signal_connect (music_view->details->song_list,
"get_cell_text",
G_CALLBACK (get_cell_text),
NULL);
gtk_widget_show (music_view->details->tree_view);
font_name = eel_preferences_get (NAUTILUS_PREFERENCES_LIST_VIEW_FONT);
standard_font_size = eel_preferences_get_integer (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL_FONT_SIZE);
font = nautilus_font_factory_get_font_by_family (font_name, standard_font_size);
#ifdef GNOME2_CONVERSION_COMPLETE
font = nautilus_font_factory_get_font_by_family (font_name, standard_font_size);
eel_gtk_widget_set_font (GTK_WIDGET (music_view->details->song_list), font);
#endif
eel_list_set_anti_aliased_mode (EEL_LIST (music_view->details->song_list), FALSE);
gdk_font_unref (font);
eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), TRACK_NUMBER, 36); /* track number */
eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), TITLE, 204); /* song name */
eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), ARTIST, 96); /* artist */
eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), BITRATE, 42); /* bitrate */
eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), TIME, 42); /* time */
eel_clist_set_column_justification(EEL_CLIST(music_view->details->song_list), TRACK_NUMBER, GTK_JUSTIFY_RIGHT);
eel_clist_set_column_justification(EEL_CLIST(music_view->details->song_list), BITRATE, GTK_JUSTIFY_RIGHT);
eel_clist_set_column_justification(EEL_CLIST(music_view->details->song_list), TIME, GTK_JUSTIFY_RIGHT);
g_signal_connect (music_view->details->song_list,
"select-row", G_CALLBACK (selection_callback), music_view);
music_view->details->scroll_window = gtk_scrolled_window_new (NULL, eel_clist_get_vadjustment (EEL_CLIST (music_view->details->song_list)));
#endif
music_view->details->scroll_window = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (music_view->details->scroll_window);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (music_view->details->scroll_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (music_view->details->scroll_window), music_view->details->song_list);
eel_clist_set_selection_mode (EEL_CLIST (music_view->details->song_list), GTK_SELECTION_BROWSE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (music_view->details->scroll_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (music_view->details->scroll_window),
GTK_SHADOW_ETCHED_IN);
gtk_container_add (GTK_CONTAINER (music_view->details->scroll_window), music_view->details->tree_view);
gtk_box_pack_start (GTK_BOX (music_view->details->album_container), music_view->details->scroll_window, TRUE, TRUE, 0);
/* We have to know when we the adjustment is changed to cause a redraw due to a lame CList bug */
g_signal_connect (eel_clist_get_vadjustment (EEL_CLIST (music_view->details->song_list)),
"value-changed", G_CALLBACK (value_changed_callback), music_view->details->song_list);
/* connect a signal to let us know when the column titles are clicked */
g_signal_connect (music_view->details->song_list, "click_column",
G_CALLBACK (click_column_callback), music_view);
gtk_widget_show (music_view->details->song_list);
/* make an hbox to hold the optional cover and other controls */
music_view->details->control_box = gtk_hbox_new (FALSE, 2);
gtk_widget_show (music_view->details->control_box);
......@@ -402,8 +522,6 @@ eel_clist_set_column_width (EEL_CLIST (music_view->details->song_list), BITRATE,
music_view->details->player_state = PLAYER_STOPPED;
music_view->details->last_player_state = PLAYER_STOPPED;
music_view->details->sort_column = TRACK_NUMBER;
}
static void
......@@ -446,48 +564,67 @@ string_non_empty (char *str)
return (str != NULL && str[0] != '\0');
}
static void
get_tree_iter_for_row (NautilusMusicView *music_view, int row, GtkTreeIter *iter)
{
GtkTreePath *path;
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, row);
gtk_tree_model_get_iter (GTK_TREE_MODEL (music_view->details->list_store), iter, path);
gtk_tree_path_free (path);
}
/* utility to return the text describing a song */
static char *
get_song_text (NautilusMusicView *music_view, int row)
{
SongInfo *info;
char *artist_album_string;
char *song_text;
char *song_title;
GtkTreeIter iter;
char *info_title, *info_album, *info_year, *info_artist;
song_text = NULL;
artist_album_string = NULL;
info = eel_clist_get_row_data (EEL_CLIST (music_view->details->song_list),
row);
if (!string_non_empty (info->title)) {
get_tree_iter_for_row (music_view, row, &iter);
gtk_tree_model_get (GTK_TREE_MODEL (music_view->details->list_store),
&iter,
ARTIST_COLUMN, &info_artist,
TITLE_COLUMN, &info_title,
ALBUM_COLUMN, &info_album,
YEAR_COLUMN, &info_year,
-1);
if (!string_non_empty (info_title)) {
song_title = "-";
} else {
song_title = info->title;
song_title = info_title;
}
if (string_non_empty (info->album)) {
if (string_non_empty (info->artist)) {
artist_album_string = g_strdup_printf ("%s / %s", info->artist, info->album);
if (string_non_empty (info_album)) {
if (string_non_empty (info_artist)) {
artist_album_string = g_strdup_printf ("%s / %s", info_artist, info_album);
} else {
artist_album_string = g_strdup (info->album);
artist_album_string = g_strdup (info_album);
}
} else {
if (string_non_empty (info->artist)) {
artist_album_string = g_strdup (info->artist);
if (string_non_empty (info_artist)) {
artist_album_string = g_strdup (info_artist);
}
}
if (string_non_empty (artist_album_string)) {
if (string_non_empty (info->year)) {
song_text = g_strdup_printf ("%s\n%s (%s)", song_title, artist_album_string, info->year);
if (string_non_empty (info_year)) {
song_text = g_strdup_printf ("%s\n%s (%s)", song_title, artist_album_string, info_year);
} else {
song_text = g_strdup_printf ("%s\n%s", song_title, artist_album_string);
}
} else {
if (string_non_empty (info->year)) {
song_text = g_strdup_printf ("%s (%s)\n-", song_title, info->year);
if (string_non_empty (info_year)) {
song_text = g_strdup_printf ("%s (%s)\n-", song_title, info_year);
} else {
song_text = g_strdup_printf ("%s\n-", song_title);
}
......@@ -506,30 +643,47 @@ music_view_set_selected_song_title (NautilusMusicView *music_view, int row)
char *label_text;
char *temp_str;
label_text = NULL;
temp_str = NULL;
music_view->details->selected_index = row;
label_text = get_song_text (music_view, row);
eel_label_set_text (EEL_LABEL(music_view->details->song_label), label_text);
g_free (label_text);
temp_str = g_strdup_printf ("<span size=\"x-large\">%s</span>", label_text);
eel_clist_get_text (EEL_CLIST(music_view->details->song_list), row, 5, &temp_str);
gtk_label_set_markup (GTK_LABEL(music_view->details->song_label), temp_str);
g_free (label_text);
g_free (temp_str);
}
static void
row_activated_callback (GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, NautilusMusicView *music_view)
{
PlayerState state;
gboolean is_playing_or_paused;
state = get_player_state (music_view);
is_playing_or_paused = (state == PLAYER_PLAYING || state == PLAYER_PAUSED);
play_current_file (music_view, FALSE);
}
/* handle a row being selected in the list view by playing the corresponding song */
static void
selection_callback (EelCList *clist, int row, int column, GdkEventButton *event, NautilusMusicView *music_view)
selection_changed (GtkTreeSelection *selection, NautilusMusicView *music_view)
{
gboolean is_playing_or_paused;
SongInfo *song_info;
PlayerState state;
GtkTreePath *path;
GtkTreeIter iter;
int row;
state = get_player_state (music_view);
is_playing_or_paused = (state == PLAYER_PLAYING || state == PLAYER_PAUSED);
gtk_tree_selection_get_selected (selection, NULL, &iter);
path = gtk_tree_model_get_path (GTK_TREE_MODEL (music_view->details->list_store), &iter);
row = gtk_tree_path_get_indices (path)[0];
gtk_tree_path_free (path);
/* Exit if we are playing and clicked on the row that represents the playing song */
if (is_playing_or_paused && (music_view->details->selected_index == row)) {
return;
......@@ -539,204 +693,10 @@ selection_callback (EelCList *clist, int row, int column, GdkEventButton *event,
stop_playing_file (music_view);
}
song_info = eel_clist_get_row_data (clist, row);
if (song_info == NULL) {
return;
}
music_view_set_selected_song_title (music_view, row);
/* Play if playback was already happening or there was a double click */
if ((is_playing_or_paused) || (event != NULL && event->type == GDK_2BUTTON_PRESS)) {
play_current_file (music_view, FALSE);
}
/* Redraw to fix lame bug EelCList has with setting the wrong GC */
//gtk_widget_queue_draw (GTK_WIDGET (clist));
}
static void
value_changed_callback (GtkAdjustment *adjustment, EelCList *clist)
{
/* Redraw to fix lame bug EelCList has with setting the wrong GC */
//gtk_widget_queue_draw (GTK_WIDGET (clist));
}
static gint
compare_song_numbers (EelCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
EelCListRow *row1, *row2;
SongInfo *info1, *info2;
int result;
row1 = (EelCListRow *) ptr1;
row2 = (EelCListRow *) ptr2;
info1 = row1->data;
info2 = row2->data;
if (info1 == NULL || info2 == NULL) {
return 0;
}
result = info1->track_number - info2->track_number;
return result;
}
static int
compare_song_titles (EelCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
SongInfo *info1, *info2;
EelCListRow *row1, *row2;
int result;
row1 = (EelCListRow *) ptr1;
row2 = (EelCListRow *) ptr2;
info1 = row1->data;
info2 = row2->data;
if (info1 == NULL || info2 == NULL) {
return 0;
}
result = eel_strcoll (info1->title, info2->title);
return result;
}
static int
compare_song_artists (EelCList *clist, gconstpointer ptr1, gconstpointer ptr2)
{
SongInfo *info1, *info2;
EelCListRow *row1, *row2;
int result;
row1 = (EelCListRow *) ptr1;
row2 = (EelCListRow *) ptr2;
info1 = row1->data;
info2 = row2->data;
if (info1 == NULL || info2 == NULL) {
return 0;
}
result = eel_strcoll (info1->artist, info2