From 4036bef5604a7c168cd6c7a758687fa3be776378 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sim=C3=B3n=20Pena?= Date: Mon, 17 May 2010 11:47:27 +0200 Subject: [PATCH] WATC Movie: initial commmit The GObject skeleton is added for the WATC Movie, a VO containing the info obtained from the What's After The Credits web service. --- src/mvs-watc-movie.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/mvs-watc-movie.h | 68 +++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 src/mvs-watc-movie.c create mode 100644 src/mvs-watc-movie.h diff --git a/src/mvs-watc-movie.c b/src/mvs-watc-movie.c new file mode 100644 index 0000000..e490122 --- /dev/null +++ b/src/mvs-watc-movie.c @@ -0,0 +1,160 @@ +/* + * mvs-watc-movie.c + * + * This file is part of maevies + * Copyright (C) 2010 Simón Pena + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#include "mvs-watc-movie.h" + +G_DEFINE_TYPE (MvsWatcMovie, mvs_watc_movie, G_TYPE_OBJECT) + +enum { + PROP_0, + PROP_NAME, + PROP_STINGERS, +}; + +#define GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), MVS_TYPE_WATC_MOVIE, MvsWatcMoviePrivate)) + +struct _MvsWatcMoviePrivate { + gchar *name; + gboolean has_stingers; +}; + +static void +mvs_watc_movie_get_property (GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ + MvsWatcMovie *self = MVS_WATC_MOVIE (object); + + switch (property_id) { + case PROP_NAME: + g_value_set_string (value, self->priv->name); + break; + case PROP_STINGERS: + g_value_set_boolean (value, self->priv->has_stingers); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +mvs_watc_movie_set_property (GObject *object, guint property_id, + const GValue *value, GParamSpec *pspec) +{ + MvsWatcMovie *self = MVS_WATC_MOVIE (object); + + switch (property_id) { + case PROP_NAME: + mvs_watc_movie_set_name (self, g_value_get_string (value)); + break; + case PROP_STINGERS: + mvs_watc_movie_set_stingers (self, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +mvs_watc_movie_finalize (GObject *object) +{ + MvsWatcMovie *self = MVS_WATC_MOVIE (object); + + g_free (self->priv->name); + + G_OBJECT_CLASS (mvs_watc_movie_parent_class)->finalize (object); +} + +static void +mvs_watc_movie_class_init (MvsWatcMovieClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (MvsWatcMoviePrivate)); + + object_class->get_property = mvs_watc_movie_get_property; + object_class->set_property = mvs_watc_movie_set_property; + object_class->finalize = mvs_watc_movie_finalize; + + g_object_class_install_property + (object_class, PROP_NAME, + g_param_spec_string ("name", "Movie name", + "The movie name", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property + (object_class, PROP_STINGERS, + g_param_spec_boolean ("stingers", "Movie stingers", + "Tells if movie has stingers", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); +} + +static void +mvs_watc_movie_init (MvsWatcMovie *self) +{ + self->priv = GET_PRIVATE (self); + + self->priv->name = NULL; + self->priv->has_stingers = FALSE; +} + +MvsWatcMovie* +mvs_watc_movie_new (void) +{ + return g_object_new (MVS_TYPE_WATC_MOVIE, NULL); +} + +gboolean +mvs_watc_movie_set_name (MvsWatcMovie *self, const gchar *name) +{ + g_return_val_if_fail (MVS_IS_WATC_MOVIE (self), FALSE); + + g_free (self->priv->name); + + self->priv->name = g_strdup (name); + + return TRUE; +} + +gboolean +mvs_watc_movie_set_stingers (MvsWatcMovie *self, gboolean has_stingers) +{ + g_return_val_if_fail (MVS_IS_WATC_MOVIE (self), FALSE); + + self->priv->has_stingers = has_stingers; + + return TRUE; +} + +const gchar* +mvs_watc_movie_get_name (MvsWatcMovie *self) +{ + g_return_val_if_fail (MVS_IS_WATC_MOVIE (self), NULL); + + return self->priv->name; +} + +gboolean +mvs_watc_movie_get_stingers (MvsWatcMovie *self) +{ + g_return_val_if_fail (MVS_IS_WATC_MOVIE (self), FALSE); + + return self->priv->has_stingers; +} diff --git a/src/mvs-watc-movie.h b/src/mvs-watc-movie.h new file mode 100644 index 0000000..a05f783 --- /dev/null +++ b/src/mvs-watc-movie.h @@ -0,0 +1,68 @@ +/* + * mvs-watc-movie.h + * + * This file is part of maevies + * Copyright (C) 2010 Simón Pena + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + */ + +#ifndef _MVS_WATC_MOVIE +#define _MVS_WATC_MOVIE + +#include + +G_BEGIN_DECLS + +#define MVS_TYPE_WATC_MOVIE mvs_watc_movie_get_type() +#define MVS_WATC_MOVIE(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), MVS_TYPE_WATC_MOVIE, MvsWatcMovie)) +#define MVS_WATC_MOVIE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), MVS_TYPE_WATC_MOVIE, MvsWatcMovieClass)) +#define MVS_IS_WATC_MOVIE(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MVS_TYPE_WATC_MOVIE)) +#define MVS_IS_WATC_MOVIE_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), MVS_TYPE_WATC_MOVIE)) +#define MVS_WATC_MOVIE_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), MVS_TYPE_WATC_MOVIE, MvsWatcMovieClass)) + +typedef struct _MvsWatcMoviePrivate MvsWatcMoviePrivate; + +typedef struct { + GObject parent; + + /* */ + MvsWatcMoviePrivate *priv; +} MvsWatcMovie; + +typedef struct { + GObjectClass parent_class; +} MvsWatcMovieClass; + +GType mvs_watc_movie_get_type (void); +MvsWatcMovie* mvs_watc_movie_new (void); + +gboolean +mvs_watc_movie_set_name (MvsWatcMovie *self, const gchar *name); + +const gchar* +mvs_watch_movie_get_name (MvsWatcMovie *self); + +gboolean +mvs_watc_movie_set_stingers (MvsWatcMovie *self, gboolean has_stingers); + +gboolean +mvs_watch_movie_get_stingers (MvsWatcMovie *self); + +G_END_DECLS + +#endif /* _MVS_WATC_MOVIE */ -- 1.7.9.5