[gthumb/ext: 2/18] make a formatted version of the duration field, added the bitrate
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 2/18] make a formatted version of the duration field, added the bitrate
- Date: Fri, 6 Nov 2009 00:15:45 +0000 (UTC)
commit 5874c2b7dc89a2b099473335f4eab9204ddb1d91
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 1 21:41:48 2009 +0100
make a formatted version of the duration field, added the bitrate
extensions/gstreamer/gstreamer-utils.c | 18 ++++++++++++++++
extensions/gstreamer/main.c | 7 ++---
gthumb/glib-utils.c | 35 ++++++++++++++++++++++++++++++++
gthumb/glib-utils.h | 4 +++
4 files changed, 60 insertions(+), 4 deletions(-)
---
diff --git a/extensions/gstreamer/gstreamer-utils.c b/extensions/gstreamer/gstreamer-utils.c
index 66c9ca5..f2f393d 100644
--- a/extensions/gstreamer/gstreamer-utils.c
+++ b/extensions/gstreamer/gstreamer-utils.c
@@ -150,6 +150,21 @@ add_metadata (GFileInfo *info,
if (raw == NULL)
return;
+ if (strcmp (key, "audio-video::general::duration") == 0) {
+ int secs;
+
+ g_free (formatted);
+ sscanf (raw, "%i", &secs);
+ formatted = _g_format_duration_for_display (secs * 1000);
+ }
+ else if (strcmp (key, "audio-video::general::bitrate") == 0) {
+ int bps;
+
+ g_free (formatted);
+ sscanf (raw, "%i", &bps);
+ formatted = g_strdup_printf ("%d kbps", bps / 1000);
+ }
+
metadata = gth_metadata_new ();
g_object_set (metadata,
"id", key,
@@ -284,6 +299,9 @@ tag_iterate (const GstTagList *list,
if (strcmp (tag, "container-format") == 0) {
tag_key = "audio-video::general::container-format";
}
+ else if (strcmp (tag, "bitrate") == 0) {
+ tag_key = "audio-video::general::bitrate";
+ }
else if (strcmp (tag, "encoder") == 0) {
tag_key = "audio-video::general::encoder";
}
diff --git a/extensions/gstreamer/main.c b/extensions/gstreamer/main.c
index 0465225..340c021 100644
--- a/extensions/gstreamer/main.c
+++ b/extensions/gstreamer/main.c
@@ -41,20 +41,19 @@ GthMetadataInfo gstreamer_metadata_info[] = {
{ "audio-video::general::artist", N_("Artist"), "audio-video::general", 2, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::album", N_("Album"), "audio-video::general", 3, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::general::duration", N_("Duration"), "audio-video::general", 4, GTH_METADATA_ALLOW_EVERYWHERE },
- { "audio-video::general::container-format", N_("Container Format"), "audio-video::general", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "audio-video::general::encoder", N_("Encoder"), "audio-video::general", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "audio-video::general::bitrate", N_("Bitrate"), "audio-video::general", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "audio-video::general::container-format", N_("Container Format"), "audio-video::general", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "audio-video::general::encoder", N_("Encoder"), "audio-video::general", 7, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::video::size", N_("Dimensions"), "audio-video::video", 1, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::video::codec", N_("Codec"), "audio-video::video", 2, GTH_METADATA_ALLOW_EVERYWHERE },
{ "audio-video::video::framerate", N_("Framerate"), "audio-video::video", 3, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "audio-video::video::bitrate", N_("Bitrate"), "audio-video::video", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::video::width", N_("Width"), "audio-video::video", 0, GTH_METADATA_ALLOW_NOWHERE },
{ "audio-video::video::height", N_("Height"), "audio-video::video", 0, GTH_METADATA_ALLOW_NOWHERE },
{ "audio-video::audio::codec", N_("Codec"), "audio-video::audio", 1, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::audio::channels", N_("Channels"), "audio-video::audio", 2, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "audio-video::audio::samplerate", N_("Sample rate"), "audio-video::audio", 3, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "audio-video::audio::bitrate", N_("Bitrate"), "audio-video::audio", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ NULL, NULL, NULL, 0, 0 }
};
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index c9167b5..5d25efc 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <glib/gprintf.h>
#include <gio/gio.h>
#include "glib-utils.h"
@@ -2246,3 +2247,37 @@ _g_mime_type_is_audio (const char *mime_type)
return g_content_type_is_a (mime_type, "audio/*");
}
+
+
+/* this is totem_time_to_string renamed, thanks to the authors :) */
+char *
+_g_format_duration_for_display (gint64 msecs)
+{
+ int sec, min, hour, _time;
+
+ _time = (int) (msecs / 1000);
+ sec = _time % 60;
+ _time = _time - sec;
+ min = (_time % (60*60)) / 60;
+ _time = _time - (min * 60);
+ hour = _time / (60*60);
+
+ if (hour > 0)
+ {
+ /* hour:minutes:seconds */
+ /* Translators: This is a time format, like "9:05:02" for 9
+ * hours, 5 minutes, and 2 seconds. You may change ":" to
+ * the separator that your locale uses or use "%Id" instead
+ * of "%d" if your locale uses localized digits.
+ */
+ return g_strdup_printf (C_("long time format", "%d:%02d:%02d"), hour, min, sec);
+ }
+
+ /* minutes:seconds */
+ /* Translators: This is a time format, like "5:02" for 5
+ * minutes and 2 seconds. You may change ":" to the
+ * separator that your locale uses or use "%Id" instead of
+ * "%d" if your locale uses localized digits.
+ */
+ return g_strdup_printf (C_("short time format", "%d:%02d"), min, sec);
+}
diff --git a/gthumb/glib-utils.h b/gthumb/glib-utils.h
index 676ff44..d79a6e5 100644
--- a/gthumb/glib-utils.h
+++ b/gthumb/glib-utils.h
@@ -253,6 +253,10 @@ gboolean _g_mime_type_is_image (const char *mime_type);
gboolean _g_mime_type_is_video (const char *mime_type);
gboolean _g_mime_type_is_audio (const char *mime_type);
+/* Other */
+
+char * _g_format_duration_for_display (gint64 msecs);
+
G_END_DECLS
#endif /* _GLIB_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]