[grilo] core: merge GrlMediaImage into GrlMedia
- From: Juan A. Suárez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo] core: merge GrlMediaImage into GrlMedia
- Date: Wed, 16 Dec 2015 13:10:52 +0000 (UTC)
commit eb29c13eb2b8d4335341e74f0e8906ac3f6241e3
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Tue Dec 15 17:35:16 2015 +0100
core: merge GrlMediaImage into GrlMedia
Get rid of GrlMediaImage and use instead GrlMedia.
https://bugzilla.gnome.org/show_bug.cgi?id=755551
bindings/vala/grilo-0.3.vapi | 37 ++---
src/Makefile.am | 2 -
src/data/grl-media-image.c | 467 ------------------------------------------
src/data/grl-media-image.h | 156 --------------
src/data/grl-media.c | 184 +++++++++++++++++
src/data/grl-media.h | 25 +++
src/grilo.c | 1 -
src/grilo.h | 1 -
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.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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]