~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to shell/rb-play-order-linear.c

Tags: upstream-0.9.2cvs20060102
ImportĀ upstreamĀ versionĀ 0.9.2cvs20060102

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
static RhythmDBEntry* rb_linear_play_order_get_next (RBPlayOrder* method);
31
31
static RhythmDBEntry* rb_linear_play_order_get_previous (RBPlayOrder* method);
32
32
 
33
 
GType
34
 
rb_linear_play_order_get_type (void)
35
 
{
36
 
        static GType rb_linear_play_order_type = 0;
37
 
 
38
 
        if (rb_linear_play_order_type == 0)
39
 
        {
40
 
                static const GTypeInfo our_info =
41
 
                {
42
 
                        sizeof (RBLinearPlayOrderClass),
43
 
                        NULL,
44
 
                        NULL,
45
 
                        (GClassInitFunc) rb_linear_play_order_class_init,
46
 
                        NULL,
47
 
                        NULL,
48
 
                        sizeof (RBLinearPlayOrder),
49
 
                        0,
50
 
                        NULL
51
 
                };
52
 
 
53
 
                rb_linear_play_order_type = g_type_register_static (RB_TYPE_PLAY_ORDER,
54
 
                                "RBLinearPlayOrder",
55
 
                                &our_info, 0);
56
 
        }
57
 
 
58
 
        return rb_linear_play_order_type;
59
 
}
 
33
G_DEFINE_TYPE (RBLinearPlayOrder, rb_linear_play_order, RB_TYPE_PLAY_ORDER)
60
34
 
61
35
RBPlayOrder *
62
36
rb_linear_play_order_new (RBShellPlayer *player)
78
52
        porder->get_previous = rb_linear_play_order_get_previous;
79
53
}
80
54
 
 
55
static void
 
56
rb_linear_play_order_init (RBLinearPlayOrder *porder)
 
57
{
 
58
}
 
59
 
81
60
static RhythmDBEntry* 
82
61
rb_linear_play_order_get_next (RBPlayOrder* porder)
83
62
{
84
 
        RBEntryView *entry_view;
 
63
        RhythmDBQueryModel *model;
85
64
        RhythmDBEntry *entry;
86
65
 
87
66
        g_return_val_if_fail (porder != NULL, NULL);
88
67
        g_return_val_if_fail (RB_IS_LINEAR_PLAY_ORDER (porder), NULL);
89
68
 
90
 
        entry_view = rb_play_order_get_entry_view (porder);
91
 
        /* Does this interfere with starting from not playing? */
92
 
        if (entry_view == NULL)
 
69
        model = rb_play_order_get_query_model (porder);
 
70
        if (model == NULL)
93
71
                return NULL;
94
72
 
95
 
        rb_debug ("choosing next linked entry");
96
 
        entry = rb_entry_view_get_next_entry (entry_view);
97
 
 
98
 
        if (entry == NULL
99
 
                        && rb_entry_view_get_playing_entry (entry_view) == NULL) {
100
 
                rb_debug ("Player is stopped, picking first entry");
101
 
                entry = rb_entry_view_get_first_entry (entry_view);
 
73
        g_object_get (porder, "playing-entry", &entry, NULL);
 
74
        if (entry) {
 
75
                return rhythmdb_query_model_get_next_from_entry (model, entry);
 
76
        } else {
 
77
                GtkTreeIter iter;
 
78
                if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
 
79
                        return NULL;
 
80
                return rhythmdb_query_model_iter_to_entry (model, &iter);
102
81
        }
103
 
 
104
 
        return entry;
105
82
}
106
83
 
107
84
static RhythmDBEntry*
108
85
rb_linear_play_order_get_previous (RBPlayOrder* porder)
109
86
{
110
 
        RBEntryView *entry_view;
 
87
        RhythmDBQueryModel *model;
 
88
        RhythmDBEntry *entry;
111
89
 
112
90
        g_return_val_if_fail (porder != NULL, NULL);
113
91
        g_return_val_if_fail (RB_IS_LINEAR_PLAY_ORDER (porder), NULL);
114
92
 
115
 
        entry_view = rb_play_order_get_entry_view (porder);
116
 
        g_return_val_if_fail (entry_view != NULL, NULL);
 
93
        model = rb_play_order_get_query_model (porder);
 
94
        if (model == NULL)
 
95
                return NULL;
117
96
 
118
 
        rb_debug ("choosing previous linked entry");
119
 
        return rb_entry_view_get_previous_entry (entry_view);
 
97
        g_object_get (porder, "playing-entry", &entry, NULL);
 
98
        if (entry == NULL)
 
99
                return NULL;
 
100
        return rhythmdb_query_model_get_previous_from_entry (model, entry);
120
101
}