2 * arch-tag: Implementation of linear navigation method
4 * Copyright (C) 2003 Jeffrey Yasskin <jyasskin@mail.utexas.edu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "rb-play-order-linear.h"
27 #include "rb-preferences.h"
28 #include "eel-gconf-extensions.h"
30 static void rb_linear_play_order_class_init (RBLinearPlayOrderClass
*klass
);
32 static RhythmDBEntry
*rb_linear_play_order_get_next (RBPlayOrder
*method
);
33 static RhythmDBEntry
*rb_linear_play_order_get_previous (RBPlayOrder
*method
);
35 G_DEFINE_TYPE (RBLinearPlayOrder
, rb_linear_play_order
, RB_TYPE_PLAY_ORDER
)
38 rb_linear_play_order_new (RBShellPlayer
*player
)
40 RBLinearPlayOrder
*lorder
;
42 lorder
= g_object_new (RB_TYPE_LINEAR_PLAY_ORDER
,
46 return RB_PLAY_ORDER (lorder
);
50 rb_linear_play_order_class_init (RBLinearPlayOrderClass
*klass
)
52 RBPlayOrderClass
*porder
= RB_PLAY_ORDER_CLASS (klass
);
53 porder
->get_next
= rb_linear_play_order_get_next
;
54 porder
->get_previous
= rb_linear_play_order_get_previous
;
58 rb_linear_play_order_init (RBLinearPlayOrder
*porder
)
62 static RhythmDBEntry
*
63 rb_linear_play_order_get_next (RBPlayOrder
*porder
)
65 RhythmDBQueryModel
*model
;
68 g_return_val_if_fail (porder
!= NULL
, NULL
);
69 g_return_val_if_fail (RB_IS_LINEAR_PLAY_ORDER (porder
), NULL
);
71 model
= rb_play_order_get_query_model (porder
);
75 entry
= rb_play_order_get_playing_entry (porder
);
78 next
= rhythmdb_query_model_get_next_from_entry (model
, entry
);
79 rhythmdb_entry_unref (entry
);
83 if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model
), &iter
))
85 return rhythmdb_query_model_iter_to_entry (model
, &iter
);
89 static RhythmDBEntry
*
90 rb_linear_play_order_get_previous (RBPlayOrder
*porder
)
92 RhythmDBQueryModel
*model
;
93 RhythmDBEntry
*entry
, *prev
;
95 g_return_val_if_fail (porder
!= NULL
, NULL
);
96 g_return_val_if_fail (RB_IS_LINEAR_PLAY_ORDER (porder
), NULL
);
98 model
= rb_play_order_get_query_model (porder
);
102 entry
= rb_play_order_get_playing_entry (porder
);
106 prev
= rhythmdb_query_model_get_previous_from_entry (model
, entry
);
107 rhythmdb_entry_unref (entry
);