diff options
author | Juan A. Suarez Romero <jasuarez@igalia.com> | 2015-12-15 17:35:16 +0100 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2015-12-16 13:52:54 +0100 |
commit | eb29c13eb2b8d4335341e74f0e8906ac3f6241e3 (patch) | |
tree | d883b4873144bebf60da4969fd5bed03a1b6a2d4 | |
parent | 11c7c84667749a9d6f942744d5eab287e3c73197 (diff) |
core: merge GrlMediaImage into GrlMedia
Get rid of GrlMediaImage and use instead GrlMedia.
https://bugzilla.gnome.org/show_bug.cgi?id=755551
-rw-r--r-- | bindings/vala/grilo-0.3.vapi | 37 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/data/grl-media-image.c | 467 | ||||
-rw-r--r-- | src/data/grl-media-image.h | 156 | ||||
-rw-r--r-- | src/data/grl-media.c | 184 | ||||
-rw-r--r-- | src/data/grl-media.h | 25 | ||||
-rw-r--r-- | src/grilo.c | 1 | ||||
-rw-r--r-- | src/grilo.h | 1 | ||||
-rw-r--r-- | tools/grilo-test-ui/main.c | 6 |
9 files changed, 225 insertions, 654 deletions
diff --git a/bindings/vala/grilo-0.3.vapi b/bindings/vala/grilo-0.3.vapi index 73e5712..87fb236 100644 --- a/bindings/vala/grilo-0.3.vapi +++ b/bindings/vala/grilo-0.3.vapi @@ -125,6 +125,7 @@ namespace Grl { public unowned string get_author (); public unowned string get_author_nth (uint index); public int get_bitrate (); + public unowned string get_camera_model (); public unowned string get_certificate (); public unowned GLib.DateTime get_creation_date (); public unowned string get_description (); @@ -133,14 +134,17 @@ namespace Grl { public int get_duration (); public int get_episode (); public unowned string get_episode_title (); + public float get_exposure_time (); public unowned string get_external_url (); public unowned string get_external_url_nth (uint index); public bool get_favourite (); + public unowned string get_flash_used (); public float get_framerate (); public unowned string get_genre (); public unowned string get_genre_nth (uint index); public int get_height (); public unowned string get_id (); + public float get_iso_speed (); public unowned string get_keyword (); public unowned string get_keyword_nth (uint index); public GLib.DateTime get_last_played (); @@ -156,6 +160,7 @@ namespace Grl { public Grl.MediaType get_media_type (); public unowned string get_mime (); public unowned GLib.DateTime get_modification_date (); + public int get_orientation (); public unowned string get_original_title (); public unowned string get_performer (); public unowned string get_performer_nth (uint index); @@ -186,13 +191,17 @@ namespace Grl { public unowned string get_url_data (out unowned string mime, out int bitrate, float framerate, int width, int height); public unowned string get_url_data_nth (uint index, out unowned string mime, out int bitrate, float framerate, int width, int height); public int get_width (); + [CCode (cname = "grl_media_image_new", has_construct_function = false)] + public Media.image_new (); public bool is_audio (); + public bool is_image (); public bool is_video (); public string serialize (); public void set_album (string album); public void set_artist (string artist); public void set_author (string author); public void set_bitrate (int bitrate); + public void set_camera_model (string camera_model); public void set_certificate (string certificate); public void set_creation_date (GLib.DateTime creation_date); public void set_description (string description); @@ -200,13 +209,16 @@ namespace Grl { public void set_duration (int duration); public void set_episode (int episode); public void set_episode_title (string episode_title); + public void set_exposure_time (float exposure_time); public void set_external_player (string player); public void set_external_url (string url); public void set_favourite (bool favourite); + public void set_flash_used (string flash_used); public void set_framerate (float framerate); public void set_genre (string genre); public void set_height (int height); public void set_id (string id); + public void set_iso_speed (float iso_speed); public void set_keyword (string keyword); public void set_last_played (GLib.DateTime last_played); public void set_last_position (int last_position); @@ -218,6 +230,7 @@ namespace Grl { public void set_mb_track_id (string mb_track_id); public void set_mime (string mime); public void set_modification_date (GLib.DateTime modification_date); + public void set_orientation (int orientation); public void set_original_title (string original_title); public void set_performer (string performer); public void set_play_count (int play_count); @@ -252,30 +265,6 @@ namespace Grl { public int get_childcount (); public void set_childcount (int childcount); } - [CCode (cheader_filename = "grilo.h", type_id = "grl_media_image_get_type ()")] - public class MediaImage : Grl.Media { - [CCode (has_construct_function = false, type = "GrlMedia*")] - public MediaImage (); - public void add_url_data (string url, string mime, int width, int height); - public unowned string get_camera_model (); - public float get_exposure_time (); - public unowned string get_flash_used (); - public int get_height (); - public float get_iso_speed (); - public int get_orientation (); - public unowned string get_url_data (out unowned string mime, int width, int height); - public unowned string get_url_data_nth (uint index, out unowned string mime, int width, int height); - public int get_width (); - public void set_camera_model (string camera_model); - public void set_exposure_time (float exposure_time); - public void set_flash_used (string flash_used); - public void set_height (int height); - public void set_iso_speed (float iso_speed); - public void set_orientation (int orientation); - public void set_size (int width, int height); - public void set_url_data (string url, string mime, int width, int height); - public void set_width (int width); - } [CCode (cheader_filename = "grilo.h", type_id = "grl_operation_options_get_type ()")] public class OperationOptions : GLib.Object { [CCode (has_construct_function = false)] diff --git a/src/Makefile.am b/src/Makefile.am index 1495827..7f63ab0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -72,7 +72,6 @@ data_c_sources = \ data/grl-data.c \ data/grl-related-keys.c \ data/grl-media.c \ - data/grl-media-image.c \ data/grl-media-box.c \ data/grl-config.c @@ -103,7 +102,6 @@ data_h_headers = \ data/grl-related-keys.h \ data/grl-media.h \ data/grl-media-box.h \ - data/grl-media-image.h \ data/grl-config.h lib@GRL_NAME@inc_HEADERS += $(data_h_headers) diff --git a/src/data/grl-media-image.c b/src/data/grl-media-image.c deleted file mode 100644 index e8ecf6a..0000000 --- a/src/data/grl-media-image.c +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Copyright (C) 2010, 2011 Igalia S.L. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Juan A. Suarez Romero <jasuarez@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -/** - * SECTION:grl-media-image - * @short_description: A multimedia data for image - * @see_also: #GrlConfig, #GrlMediaBox, #GrlMediaAudio, #GrlMediaVideo - * - * This high level class represents an image multimedia item. It has methods to - * set and get the size, width and height properties - */ - -#include "grl-media-image.h" - - -static void grl_media_image_finalize (GObject *object); - -G_DEFINE_TYPE (GrlMediaImage, grl_media_image, GRL_TYPE_MEDIA); - -static void -grl_media_image_class_init (GrlMediaImageClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *)klass; - - gobject_class->finalize = grl_media_image_finalize; -} - -static void -grl_media_image_init (GrlMediaImage *self) -{ -} - -static void -grl_media_image_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - G_OBJECT_CLASS (grl_media_image_parent_class)->finalize (object); -} - -/** - * grl_media_image_new: - * - * Creates a new data image object. - * - * Returns: a newly-allocated data image. - * - * Since: 0.1.4 - **/ -GrlMedia * -grl_media_image_new (void) -{ - return GRL_MEDIA (g_object_new (GRL_TYPE_MEDIA_IMAGE, - NULL)); -} - -/** - * grl_media_image_set_size: - * @image: the image instance - * @width: the image's width - * @height: the image's height - * - * Set the size of the image - * - * Since: 0.1.4 - */ -void -grl_media_image_set_size (GrlMediaImage *image, - gint width, - gint height) -{ - g_return_if_fail (GRL_IS_MEDIA_IMAGE (image)); - - grl_media_image_set_width (image, width); - grl_media_image_set_height (image, height); -} - -/** - * grl_media_image_set_width: - * @image: the image instance - * @width: the image's width - * - * Set the width of the image - * - * Since: 0.1.4 - */ -void -grl_media_image_set_width (GrlMediaImage *image, gint width) -{ - grl_data_set_int (GRL_DATA (image), - GRL_METADATA_KEY_WIDTH, - width); -} - -/** - * grl_media_image_set_height: - * @image: the image instance - * @height: the image's height - * - * Set the height of the image - * - * Since: 0.1.4 - */ -void -grl_media_image_set_height (GrlMediaImage *image, gint height) -{ - grl_data_set_int (GRL_DATA (image), - GRL_METADATA_KEY_HEIGHT, - height); -} - -/** - * grl_media_image_set_url_data: - * @image: the media instance - * @url: the image's url - * @mime: image mime-type - * @width: image width, or -1 to ignore - * @height: image height, or -1 to ignore - * - * Sets all the keys related with the URL of an image resource in one go. - * - * Since: 0.1.10 - **/ -void -grl_media_image_set_url_data (GrlMediaImage *image, - const gchar *url, - const gchar *mime, - gint width, - gint height) -{ - GrlRelatedKeys *relkeys; - - g_return_if_fail (GRL_IS_MEDIA_IMAGE (image)); - - relkeys = grl_related_keys_new (); - grl_related_keys_set_string (relkeys, GRL_METADATA_KEY_URL, url); - grl_related_keys_set_string (relkeys, GRL_METADATA_KEY_MIME, mime); - if (width >= 0) { - grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_WIDTH, width); - } - if (height >= 0) { - grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_HEIGHT, height); - } - grl_data_set_related_keys (GRL_DATA (image), relkeys, 0); -} - -/** - * grl_media_image_add_url_data: - * @image: the image instance - * @url: a image's url - * @mime: image mime-type - * @width: image width, or -1 to ignore - * @height: image height, or -1 to ignore - * - * Sets all the keys related with the URL of a media resource and adds it to - * @image (useful for resources with more than one URL). - * - * Since: 0.1.10 - **/ -void -grl_media_image_add_url_data (GrlMediaImage *image, - const gchar *url, - const gchar *mime, - gint width, - gint height) -{ - GrlRelatedKeys *relkeys; - - g_return_if_fail (GRL_IS_MEDIA_IMAGE (image)); - - relkeys = grl_related_keys_new (); - grl_related_keys_set_string (relkeys, GRL_METADATA_KEY_URL, url); - grl_related_keys_set_string (relkeys, GRL_METADATA_KEY_MIME, mime); - if (width >= 0) { - grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_WIDTH, width); - } - if (height >= 0) { - grl_related_keys_set_int (relkeys, GRL_METADATA_KEY_HEIGHT, height); - } - grl_data_add_related_keys (GRL_DATA (image), relkeys); -} - -/** - * grl_media_image_get_width: - * @image: The image instance - * - * Returns: the width of the image - * - * Since: 0.1.4 - */ -gint -grl_media_image_get_width (GrlMediaImage *image) -{ - return grl_data_get_int (GRL_DATA (image), GRL_METADATA_KEY_WIDTH); -} - -/** - * grl_media_image_get_height: - * @image: the image instance - * - * Returns: the height of the image - * - * Since: 0.1.4 - */ -gint -grl_media_image_get_height (GrlMediaImage *image) -{ - return grl_data_get_int (GRL_DATA (image), GRL_METADATA_KEY_HEIGHT); -} - -/** - * grl_media_image_get_url_data: - * @image: the image instance - * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore - * @width: the width, or %NULL to ignore - * @height: the height, or %NULL to ignore - * - * Returns: all the keys related with the URL of an image resource in one go. - * - * Since: 0.1.10 - **/ -const gchar * -grl_media_image_get_url_data (GrlMediaImage *image, - gchar **mime, - gint *width, - gint *height) -{ - return grl_media_image_get_url_data_nth (image, 0, mime, width, height); -} - -/** - * grl_media_image_get_url_data_nth: - * @image: the image instance - * @index: element to retrieve - * @mime: (out) (transfer none): the url mime-type, or %NULL to ignore - * @width: the width, or %NULL to ignore - * @height: the height, or %NULL to ignore - * - * Returns: all the keys related with the URL number @index of an image resource - * in one go. - * - * Since: 0.1.10 - **/ -const gchar * -grl_media_image_get_url_data_nth (GrlMediaImage *image, - guint index, - gchar **mime, - gint *width, - gint *height) -{ - GrlRelatedKeys *relkeys; - - g_return_val_if_fail (GRL_IS_MEDIA_IMAGE (image), NULL); - - relkeys = - grl_data_get_related_keys (GRL_DATA (image), GRL_METADATA_KEY_URL, index); - - if (!relkeys) { - return NULL; - } - - if (mime) { - *mime = (gchar *) grl_related_keys_get_string (relkeys, - GRL_METADATA_KEY_MIME); - } - - if (width) { - *width = grl_related_keys_get_int (relkeys, GRL_METADATA_KEY_WIDTH); - } - - if (height) { - *height = grl_related_keys_get_int (relkeys, GRL_METADATA_KEY_HEIGHT); - } - - return grl_related_keys_get_string (relkeys, GRL_METADATA_KEY_URL); -} - -/** - * grl_media_image_get_camera_model: - * @image: the image instance - * - * Returns: model of camera used to take picture - * - * Since: 0.1.12 - */ -const gchar * -grl_media_image_get_camera_model (GrlMediaImage *image) -{ - return grl_data_get_string (GRL_DATA (image), - GRL_METADATA_KEY_CAMERA_MODEL); -} - -/** - * grl_media_set_camera_model: - * @image: the image instance - * @camera_model: model of camera used to take picture - * - * Set the camera_model of the image - * - * Since: 0.1.12 - */ -void -grl_media_image_set_camera_model (GrlMediaImage *image, - const gchar * camera_model) -{ - grl_data_set_string (GRL_DATA (image), - GRL_METADATA_KEY_CAMERA_MODEL, - camera_model); -} - - -/** - * grl_media_image_get_flash_used: - * @image: the image instance - * - * Returns: whether the flash was used - * See - * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash - * - * Since: 0.1.12 - */ -const gchar * -grl_media_image_get_flash_used (GrlMediaImage *image) -{ - return grl_data_get_string (GRL_DATA (image), - GRL_METADATA_KEY_FLASH_USED); -} - -/** - * grl_media_set_flash_used: - * @image: the image instance - * @flash_used: whether the flash was used - * - * Set the flash_used of the image - * See - * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash - * - * Since: 0.1.12 - */ -void -grl_media_image_set_flash_used (GrlMediaImage *image, - const gchar *flash_used) -{ - grl_data_set_string (GRL_DATA (image), - GRL_METADATA_KEY_FLASH_USED, - flash_used); -} - - -/** - * grl_media_image_get_exposure_time: - * @image: the image instance - * - * Returns: picture's exposure time - * - * Since: 0.1.12 - */ -gfloat -grl_media_image_get_exposure_time (GrlMediaImage *image) -{ - return grl_data_get_float (GRL_DATA (image), - GRL_METADATA_KEY_EXPOSURE_TIME); -} - -/** - * grl_media_set_exposure_time: - * @image: the image instance - * @exposure_time: picture's exposure time - * - * Set the exposure_time of the image - * - * Since: 0.1.12 - */ -void -grl_media_image_set_exposure_time (GrlMediaImage *image, - gfloat exposure_time) -{ - grl_data_set_float (GRL_DATA (image), - GRL_METADATA_KEY_EXPOSURE_TIME, - exposure_time); -} - -/** - * grl_media_image_get_iso_speed: - * @image: the image instance - * - * Returns: picture's iso speed - * - * Since: 0.1.12 - */ -gfloat -grl_media_image_get_iso_speed (GrlMediaImage *image) -{ - return grl_data_get_float (GRL_DATA (image), - GRL_METADATA_KEY_ISO_SPEED); -} - -/** - * grl_media_image_set_iso_speed: - * @image: the image instance - * @iso_speed: picture's iso speed - * - * Set the iso_speed of the image - * - * Since: 0.1.12 - */ -void -grl_media_image_set_iso_speed (GrlMediaImage *image, - gfloat iso_speed) -{ - grl_data_set_float (GRL_DATA (image), - GRL_METADATA_KEY_ISO_SPEED, - iso_speed); -} - -/** - * grl_media_image_get_orientation: - * @image: the image instance - * - * Returns: degrees clockwise orientation of the picture - * - * Since: 0.1.12 - */ -gint -grl_media_image_get_orientation (GrlMediaImage *image) -{ - return grl_data_get_int (GRL_DATA (image), - GRL_METADATA_KEY_ORIENTATION); -} - -/** - * grl_media_image_set_orientation: - * @image: the image instance - * @orientation: degrees clockwise orientation of the picture - * - * Set the orientation of the image - * - * Since: 0.1.12 - */ -void -grl_media_image_set_orientation (GrlMediaImage *image, - gint orientation) -{ - grl_data_set_int (GRL_DATA (image), - GRL_METADATA_KEY_ORIENTATION, - orientation % 360); -} diff --git a/src/data/grl-media-image.h b/src/data/grl-media-image.h deleted file mode 100644 index 4149294..0000000 --- a/src/data/grl-media-image.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2010, 2011 Igalia S.L. - * - * Contact: Iago Toral Quiroga <itoral@igalia.com> - * - * Authors: Juan A. Suarez Romero <jasuarez@igalia.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; version 2.1 of - * the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#if !defined (_GRILO_H_INSIDE_) && !defined (GRILO_COMPILATION) -#error "Only <grilo.h> can be included directly." -#endif - -#ifndef _GRL_MEDIA_IMAGE_H_ -#define _GRL_MEDIA_IMAGE_H_ - -#include <grl-media.h> -#include <grl-definitions.h> - -G_BEGIN_DECLS - -#define GRL_TYPE_MEDIA_IMAGE \ - (grl_media_image_get_type()) - -#define GRL_MEDIA_IMAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GRL_TYPE_MEDIA_IMAGE, \ - GrlMediaImage)) - -#define GRL_MEDIA_IMAGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - GRL_TYPE_MEDIA_IMAGE, \ - GrlMediaImageClass)) - -#define GRL_IS_MEDIA_IMAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - GRL_TYPE_MEDIA_IMAGE)) - -#define GRL_IS_MEDIA_IMAGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - GRL_TYPE_MEDIA_IMAGE)) - -#define GRL_MEDIA_IMAGE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - GRL_TYPE_MEDIA_IMAGE, \ - GrlMediaImageClass)) - -typedef struct _GrlMediaImage GrlMediaImage; -typedef struct _GrlMediaImageClass GrlMediaImageClass; - -struct _GrlMediaImage -{ - GrlMedia parent; - - /*< private >*/ - gpointer _grl_reserved[GRL_PADDING_SMALL]; -}; - -/** - * GrlMediaImageClass: - * @parent_class: the parent class structure - * - * Grilo Media image Class - */ -struct _GrlMediaImageClass -{ - GrlMediaClass parent_class; - - /*< private >*/ - gpointer _grl_reserved[GRL_PADDING]; -}; - -void grl_media_image_set_width (GrlMediaImage *image, gint width); - -void grl_media_image_set_height (GrlMediaImage *image, gint height); - -gint grl_media_image_get_width (GrlMediaImage *image); - -gint grl_media_image_get_height (GrlMediaImage *image); - -const gchar *grl_media_image_get_camera_model (GrlMediaImage *image); - -const gchar *grl_media_image_get_flash_used (GrlMediaImage *image); - -gfloat grl_media_image_get_exposure_time (GrlMediaImage *image); - -gfloat grl_media_image_get_iso_speed (GrlMediaImage *image); - -gint grl_media_image_get_orientation (GrlMediaImage *image); - - -void grl_media_image_set_size (GrlMediaImage *image, - gint width, - gint height); - -const gchar *grl_media_image_get_url_data (GrlMediaImage *image, - gchar **mime, - gint *width, - gint *height); - -const gchar *grl_media_image_get_url_data_nth (GrlMediaImage *image, - guint index, - gchar **mime, - gint *width, - gint *height); - -void grl_media_image_set_url_data (GrlMediaImage *image, - const gchar *url, - const gchar *mime, - gint width, - gint height); - -void grl_media_image_add_url_data (GrlMediaImage *image, - const gchar *url, - const gchar *mime, - gint width, - gint height); - -void grl_media_image_set_camera_model (GrlMediaImage *image, - const gchar *camera_model); - -void grl_media_image_set_flash_used (GrlMediaImage *image, - const gchar *flash_used); - -void grl_media_image_set_exposure_time (GrlMediaImage *image, - gfloat exposure_time); - -void grl_media_image_set_iso_speed (GrlMediaImage *image, - gfloat iso_speed); - -void grl_media_image_set_orientation (GrlMediaImage *image, - gint orientation); - -GType grl_media_image_get_type (void) G_GNUC_CONST; - -GrlMedia *grl_media_image_new (void); - - -G_END_DECLS - -#endif /* _GRL_MEDIA_IMAGE_H_ */ diff --git a/src/data/grl-media.c b/src/data/grl-media.c index 782cffb..a31238c 100644 --- a/src/data/grl-media.c +++ b/src/data/grl-media.c @@ -192,6 +192,22 @@ grl_media_video_new (void) NULL); } +/** + * grl_media_image_new: + * + * Creates a new media image object. + * + * Returns: a newly-allocated media image. + * + * Since: 0.1.4 + **/ +GrlMedia * +grl_media_image_new (void) +{ + return g_object_new (GRL_TYPE_MEDIA, + "media-type", GRL_MEDIA_TYPE_IMAGE, + NULL); +} gboolean grl_media_is_audio (GrlMedia *media) @@ -209,6 +225,14 @@ grl_media_is_video (GrlMedia *media) return (media->priv->media_type == GRL_MEDIA_TYPE_VIDEO); } +gboolean +grl_media_is_image (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), FALSE); + + return (media->priv->media_type == GRL_MEDIA_TYPE_IMAGE); +} + /** * grl_media_set_rating: * @media: a media @@ -1829,6 +1853,93 @@ grl_media_set_original_title (GrlMedia *media, } /** + * grl_media_set_camera_model: + * @media: the media instance + * @camera_model: model of camera used to take picture + * + * Set the camera_model of the media + */ +void +grl_media_set_camera_model (GrlMedia *media, + const gchar *camera_model) +{ + g_return_if_fail (GRL_IS_MEDIA (media)); + grl_data_set_string (GRL_DATA (media), + GRL_METADATA_KEY_CAMERA_MODEL, + camera_model); +} + +/** + * grl_media_set_flash_used: + * @media: the media instance + * @flash_used: whether the flash was used + * + * Set the flash_used of the media + * See + * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash + */ +void +grl_media_set_flash_used (GrlMedia *media, + const gchar *flash_used) +{ + g_return_if_fail (GRL_IS_MEDIA (media)); + grl_data_set_string (GRL_DATA (media), + GRL_METADATA_KEY_FLASH_USED, + flash_used); +} + +/** + * grl_media_set_exposure_time: + * @media: the media instance + * @exposure_time: picture's exposure time + * + * Set the exposure_time of the media + */ +void +grl_media_set_exposure_time (GrlMedia *media, + gfloat exposure_time) +{ + g_return_if_fail (GRL_IS_MEDIA (media)); + grl_data_set_float (GRL_DATA (media), + GRL_METADATA_KEY_EXPOSURE_TIME, + exposure_time); +} + +/** + * grl_media_set_iso_speed: + * @media: the media instance + * @iso_speed: picture's iso speed + * + * Set the iso_speed of the media + */ +void +grl_media_set_iso_speed (GrlMedia *media, + gfloat iso_speed) +{ + g_return_if_fail (GRL_IS_MEDIA (media)); + grl_data_set_float (GRL_DATA (media), + GRL_METADATA_KEY_ISO_SPEED, + iso_speed); +} + +/** + * grl_media_set_orientation: + * @media: the media instance + * @orientation: degrees clockwise orientation of the picture + * + * Set the orientation of the media + */ +void +grl_media_set_orientation (GrlMedia *media, + gint orientation) +{ + g_return_if_fail (GRL_IS_MEDIA (media)); + grl_data_set_int (GRL_DATA (media), + GRL_METADATA_KEY_ORIENTATION, + orientation % 360); +} + +/** * grl_media_get_id: * @media: the media object * @@ -3114,3 +3225,76 @@ grl_media_get_original_title (GrlMedia *media) return grl_data_get_string (GRL_DATA (media), GRL_METADATA_KEY_ORIGINAL_TITLE); } + +/** + * grl_media_get_camera_model: + * @media: the media instance + * + * Returns: model of camera used to take picture + */ +const gchar * +grl_media_get_camera_model (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), NULL); + return grl_data_get_string (GRL_DATA (media), + GRL_METADATA_KEY_CAMERA_MODEL); +} + +/** + * grl_media_get_flash_used: + * @media: the media instance + * + * Returns: whether the flash was used. + + * See + * http://library.gnome.org/devel/ontology/unstable/nmm-classes.html#nmm-Flash + */ +const gchar * +grl_media_get_flash_used (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), NULL); + return grl_data_get_string (GRL_DATA (media), + GRL_METADATA_KEY_FLASH_USED); +} + +/** + * grl_media_get_exposure_time: + * @media: the media instance + * + * Returns: picture's exposure time + */ +gfloat +grl_media_get_exposure_time (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), 0.0); + return grl_data_get_float (GRL_DATA (media), + GRL_METADATA_KEY_EXPOSURE_TIME); +} + +/** + * grl_media_get_iso_speed: + * @media: the media instance + * + * Returns: picture's iso speed + */ +gfloat +grl_media_get_iso_speed (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), 0.0); + return grl_data_get_float (GRL_DATA (media), + GRL_METADATA_KEY_ISO_SPEED); +} + +/** + * grl_media_get_orientation: + * @media: the image instance + * + * Returns: degrees clockwise orientation of the picture + */ +gint +grl_media_get_orientation (GrlMedia *media) +{ + g_return_val_if_fail (GRL_IS_MEDIA (media), 0.0); + return grl_data_get_int (GRL_DATA (media), + GRL_METADATA_KEY_ORIENTATION); +} diff --git a/src/data/grl-media.h b/src/data/grl-media.h index 87609e4..a782424 100644 --- a/src/data/grl-media.h +++ b/src/data/grl-media.h @@ -215,6 +215,16 @@ void grl_media_set_director (GrlMedia *media, const gchar *director); void grl_media_set_original_title (GrlMedia *media, const gchar *original_title); +void grl_media_set_camera_model (GrlMedia *media, const gchar *camera_model); + +void grl_media_set_flash_used (GrlMedia *media, const gchar *flash_used); + +void grl_media_set_exposure_time (GrlMedia *media, gfloat exposure_time); + +void grl_media_set_iso_speed (GrlMedia *media, gfloat iso_speed); + +void grl_media_set_orientation (GrlMedia *media, gint orientation); + void grl_media_add_url_data (GrlMedia *media, const gchar *url, const gchar *mime, gint bitrate, gfloat framerate, gint width, gint height); void grl_media_add_author (GrlMedia *media, const gchar *author); @@ -382,6 +392,16 @@ const gchar *grl_media_get_director_nth (GrlMedia *media, guint index); const gchar *grl_media_get_original_title (GrlMedia *media); +const gchar *grl_media_get_camera_model (GrlMedia *media); + +const gchar *grl_media_get_flash_used (GrlMedia *media); + +gfloat grl_media_get_exposure_time (GrlMedia *media); + +gfloat grl_media_get_iso_speed (GrlMedia *media); + +gint grl_media_get_orientation (GrlMedia *media); + GType grl_media_get_type (void) G_GNUC_CONST; GrlMedia *grl_media_new (void); @@ -390,12 +410,17 @@ GrlMedia *grl_media_audio_new (void); GrlMedia *grl_media_video_new (void); +GrlMedia *grl_media_image_new (void); + gboolean grl_media_is_audio (GrlMedia *media); gboolean grl_media_is_video (GrlMedia *media); +gboolean +grl_media_is_image (GrlMedia *media); + gchar *grl_media_serialize (GrlMedia *media); gchar *grl_media_serialize_extended (GrlMedia *media, diff --git a/src/grilo.c b/src/grilo.c index e5a3db8..a39661b 100644 --- a/src/grilo.c +++ b/src/grilo.c @@ -110,7 +110,6 @@ post_parse_hook_cb (GOptionContext *context, /* Register GrlMedia in glib typesystem */ g_type_class_ref (GRL_TYPE_MEDIA_BOX); - g_type_class_ref (GRL_TYPE_MEDIA_IMAGE); /* Set default plugin directories */ if (!plugin_path) { diff --git a/src/grilo.h b/src/grilo.h index fc48869..2f0db62 100644 --- a/src/grilo.h +++ b/src/grilo.h @@ -34,7 +34,6 @@ #include <grl-metadata-key.h> #include <grl-data.h> #include <grl-media.h> -#include <grl-media-image.h> #include <grl-media-box.h> #include <grl-config.h> #include <grl-related-keys.h> diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c index ff93aef..4b62153 100644 --- a/tools/grilo-test-ui/main.c +++ b/tools/grilo-test-ui/main.c @@ -347,7 +347,7 @@ get_icon_for_media (GrlMedia *media) return g_themed_icon_new ("gnome-mime-video"); } else if (grl_media_is_audio (media)) { return g_themed_icon_new ("gnome-mime-audio"); - } else if (GRL_IS_MEDIA_IMAGE (media)) { + } else if (grl_media_is_image (media)) { return g_themed_icon_new ("gnome-mime-image"); } else { return g_themed_icon_new ("text-x-generic"); @@ -618,7 +618,7 @@ resolve_cb (GrlSource *source, /* Set/unset show button */ if ((grl_media_is_audio (media) || grl_media_is_video (media) || - GRL_IS_MEDIA_IMAGE (media)) && + grl_media_is_image (media)) && (ui_state->last_url = grl_media_get_url (media))) { gtk_widget_set_sensitive (view->show_btn, TRUE); } else { @@ -1079,7 +1079,7 @@ show_btn_clicked_cb (GtkButton *btn, gpointer user_data) if (ui_state->last_url) { GRL_DEBUG ("playing: %s", ui_state->last_url); uri_list = g_list_append (uri_list, (gpointer) ui_state->last_url); - if (GRL_IS_MEDIA_IMAGE (ui_state->cur_md_media)) { + if (grl_media_is_image (ui_state->cur_md_media)) { app = launchers->eog; } else { /* Content from apple-trailers should be opened with mplayer, as they |