hythmbox-2.98/plugins/audioscrobbler/rb-audioscrobbler-play-order.c

No issues found

  1 /*
  2  *  Copyright (C) 2008  Jonathan Matthew  <jonathan@d14n.org>
  3  *
  4  *  This program is free software; you can redistribute it and/or modify
  5  *  it under the terms of the GNU General Public License as published by
  6  *  the Free Software Foundation; either version 2 of the License, or
  7  *  (at your option) any later version.
  8  *
  9  *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 10  *  GStreamer plugins to be used and distributed together with GStreamer
 11  *  and Rhythmbox. This permission is above and beyond the permissions granted
 12  *  by the GPL license by which Rhythmbox is covered. If you modify this code
 13  *  you may extend this exception to your version of the code, but you are not
 14  *  obligated to do so. If you do not wish to do so, delete this exception
 15  *  statement from your version.
 16  *
 17  *  This program is distributed in the hope that it will be useful,
 18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 20  *  GNU General Public License for more details.
 21  *
 22  *  You should have received a copy of the GNU General Public License
 23  *  along with this program; if not, write to the Free Software
 24  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 25  *
 26  */
 27 
 28 #include "config.h"
 29 
 30 #include "rb-audioscrobbler-play-order.h"
 31 #include "rb-debug.h"
 32 
 33 static void rb_audioscrobbler_play_order_class_init (RBAudioscrobblerPlayOrderClass *klass);
 34 
 35 G_DEFINE_DYNAMIC_TYPE (RBAudioscrobblerPlayOrder, rb_audioscrobbler_play_order, RB_TYPE_PLAY_ORDER)
 36 
 37 RBPlayOrder *
 38 rb_audioscrobbler_play_order_new (RBShellPlayer *player)
 39 {
 40 	RBAudioscrobblerPlayOrder *lorder;
 41 
 42 	lorder = g_object_new (RB_TYPE_AUDIOSCROBBLER_PLAY_ORDER,
 43 			       "player", player,
 44 			       NULL);
 45 
 46 	return RB_PLAY_ORDER (lorder);
 47 }
 48 
 49 static RhythmDBEntry *
 50 rb_audioscrobbler_play_order_get_next (RBPlayOrder *porder)
 51 {
 52 	RhythmDBQueryModel *model;
 53 	RhythmDBEntry *entry;
 54 
 55 	g_return_val_if_fail (porder != NULL, NULL);
 56 	g_return_val_if_fail (RB_IS_AUDIOSCROBBLER_PLAY_ORDER (porder), NULL);
 57 
 58 	model = rb_play_order_get_query_model (porder);
 59 	if (model == NULL)
 60 		return NULL;
 61 
 62         entry = rb_play_order_get_playing_entry (porder);
 63 	if (entry != NULL) {
 64 		RhythmDBEntry *next;
 65 		next = rhythmdb_query_model_get_next_from_entry (model, entry);
 66 		rhythmdb_entry_unref (entry);
 67 		return next;
 68 	} else {
 69 		GtkTreeIter iter;
 70 		if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
 71 			return NULL;
 72 		return rhythmdb_query_model_iter_to_entry (model, &iter);
 73 	}
 74 }
 75 
 76 static RhythmDBEntry *
 77 rb_audioscrobbler_play_order_get_previous (RBPlayOrder *porder)
 78 {
 79 	/* can never go back */
 80 	return NULL;
 81 }
 82 
 83 static void
 84 rb_audioscrobbler_play_order_init (RBAudioscrobblerPlayOrder *porder)
 85 {
 86 }
 87 
 88 static void
 89 rb_audioscrobbler_play_order_class_init (RBAudioscrobblerPlayOrderClass *klass)
 90 {
 91 	RBPlayOrderClass *porder = RB_PLAY_ORDER_CLASS (klass);
 92 	porder->get_next = rb_audioscrobbler_play_order_get_next;
 93 	porder->get_previous = rb_audioscrobbler_play_order_get_previous;
 94 }
 95 
 96 
 97 static void
 98 rb_audioscrobbler_play_order_class_finalize (RBAudioscrobblerPlayOrderClass *klass)
 99 {
100 }
101 
102 void
103 _rb_audioscrobbler_play_order_register_type (GTypeModule *module)
104 {
105 	rb_audioscrobbler_play_order_register_type (module);
106 }