1 /*
2 * Copyright (c) 2021 gnome-mpv
3 *
4 * This file is part of Celluloid.
5 *
6 * Celluloid 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Celluloid 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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Celluloid. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <gio/gio.h>
21
22 #include "celluloid-playlist-item.h"
23
24 struct _CelluloidPlaylistItem
25 {
26 GObject parent_instance;
27 gchar *title;
28 gchar *uri;
29 gboolean is_current;
30 };
31
32 struct _CelluloidPlaylistItemClass
33 {
34 GObjectClass parent_class;
35 };
36
G_DEFINE_TYPE(CelluloidPlaylistItem,celluloid_playlist_item,G_TYPE_OBJECT)37 G_DEFINE_TYPE(CelluloidPlaylistItem, celluloid_playlist_item, G_TYPE_OBJECT)
38
39 static void
40 finalize(GObject *gobject)
41 {
42 CelluloidPlaylistItem *self = CELLULOID_PLAYLIST_ITEM(gobject);
43
44 g_free(self->title);
45 g_free(self->uri);
46 }
47
48 static void
celluloid_playlist_item_init(CelluloidPlaylistItem * self)49 celluloid_playlist_item_init(CelluloidPlaylistItem *self)
50 {
51 self->title = NULL;
52 self->uri = NULL;
53 self->is_current = FALSE;
54 }
55
56 static void
celluloid_playlist_item_class_init(CelluloidPlaylistItemClass * klass)57 celluloid_playlist_item_class_init(CelluloidPlaylistItemClass *klass)
58 {
59 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
60
61 gobject_class->finalize = finalize;
62 }
63
64 CelluloidPlaylistItem *
celluloid_playlist_item_new_take(gchar * title,gchar * uri,gboolean is_current)65 celluloid_playlist_item_new_take( gchar *title,
66 gchar *uri,
67 gboolean is_current )
68 {
69 CelluloidPlaylistItem *self;
70
71 self = g_object_new(CELLULOID_TYPE_PLAYLIST_ITEM, NULL);
72 self->title = title;
73 self->uri = uri;
74 self->is_current = is_current;
75
76 return self;
77 }
78
79 CelluloidPlaylistItem *
celluloid_playlist_item_new(const gchar * title,const gchar * uri,gboolean is_current)80 celluloid_playlist_item_new( const gchar *title,
81 const gchar *uri,
82 gboolean is_current )
83 {
84 return celluloid_playlist_item_new_take
85 (g_strdup(title), g_strdup(uri), is_current);
86 }
87
88 CelluloidPlaylistItem *
celluloid_playlist_item_copy(CelluloidPlaylistItem * source)89 celluloid_playlist_item_copy(CelluloidPlaylistItem *source)
90 {
91 CelluloidPlaylistItem *self;
92
93 self = g_object_new(CELLULOID_TYPE_PLAYLIST_ITEM, NULL);
94 self->title = source->title;
95 self->uri = source->uri;
96 self->is_current = source->is_current;
97
98 return self;
99 }
100
101 const gchar *
celluloid_playlist_item_get_title(CelluloidPlaylistItem * self)102 celluloid_playlist_item_get_title(CelluloidPlaylistItem *self)
103 {
104 return self->title;
105 }
106
107 const gchar *
celluloid_playlist_item_get_uri(CelluloidPlaylistItem * self)108 celluloid_playlist_item_get_uri(CelluloidPlaylistItem *self)
109 {
110 return self->uri;
111 }
112
113 gboolean
celluloid_playlist_item_get_is_current(CelluloidPlaylistItem * self)114 celluloid_playlist_item_get_is_current(CelluloidPlaylistItem *self)
115 {
116 return self->is_current;
117 }
118
119 void
celluloid_playlist_item_set_is_current(CelluloidPlaylistItem * self,gboolean value)120 celluloid_playlist_item_set_is_current( CelluloidPlaylistItem *self,
121 gboolean value )
122 {
123 self->is_current = value;
124 }
125
126