[gthumb] added ability to sort by image/video dimensions



commit 83fa9e621f1e9066508a95e5be76e5a4ced66da1
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jul 4 15:46:29 2010 +0200

    added ability to sort by image/video dimensions
    
    [bug #619299]

 .../gth-metadata-provider-gstreamer.c              |    2 +
 extensions/gstreamer_utils/gstreamer-utils.c       |   10 +++++--
 .../image_viewer/gth-metadata-provider-image.c     |    6 ++++-
 gthumb/gth-main-default-metadata.c                 |    4 +++
 gthumb/gth-main-default-sort-types.c               |   24 ++++++++++++++++++++
 5 files changed, 42 insertions(+), 4 deletions(-)
---
diff --git a/extensions/gstreamer_tools/gth-metadata-provider-gstreamer.c b/extensions/gstreamer_tools/gth-metadata-provider-gstreamer.c
index fd5675f..9a593be 100644
--- a/extensions/gstreamer_tools/gth-metadata-provider-gstreamer.c
+++ b/extensions/gstreamer_tools/gth-metadata-provider-gstreamer.c
@@ -44,6 +44,8 @@ gth_metadata_provider_gstreamer_can_read (GthMetadataProvider  *self,
 	return _g_file_attributes_matches_any_v ("general::title,"
 						 "general::format,"
 						 "general::dimensions,"
+						 "frame::width,"
+			 	 	 	 "frame::height,"
 						 "audio-video::*",
 					         attribute_v);
 }
diff --git a/extensions/gstreamer_utils/gstreamer-utils.c b/extensions/gstreamer_utils/gstreamer-utils.c
index 09accc0..5b0cd7a 100644
--- a/extensions/gstreamer_utils/gstreamer-utils.c
+++ b/extensions/gstreamer_utils/gstreamer-utils.c
@@ -375,22 +375,26 @@ extract_metadata (MetadataExtractor *extractor,
                               g_strdup_printf ("%d", (guint) extractor->audio_bitrate),
                               g_strdup_printf ("%d bps", (guint) extractor->audio_bitrate));
 
-        if (extractor->video_height >= 0)
+        if (extractor->video_height >= 0) {
                 add_metadata (info,
                 	      "audio-video::video::height",
                 	      g_strdup_printf ("%d", (guint) extractor->video_height),
                 	      NULL);
+		g_file_info_set_attribute_int32 (info, "frame::height", extractor->video_height);
+        }
 
-        if (extractor->video_width >= 0)
+        if (extractor->video_width >= 0) {
                 add_metadata (info,
                 	      "audio-video::video::width",
                 	      g_strdup_printf ("%d", (guint) extractor->video_width),
                 	      NULL);
+		g_file_info_set_attribute_int32 (info, "frame::width", extractor->video_width);
+        }
 
         if ((extractor->video_height >= 0) && (extractor->video_width >= 0))
                 add_metadata (info,
                 	      "general::dimensions",
-                	      g_strdup_printf ("%d x %d", (guint) extractor->video_width, (guint) extractor->video_height),
+                	      g_strdup_printf ("%d Ã? %d", (guint) extractor->video_width, (guint) extractor->video_height),
                 	      NULL);
 
         if ((extractor->video_fps_n >= 0) && (extractor->video_fps_d >= 0))
diff --git a/extensions/image_viewer/gth-metadata-provider-image.c b/extensions/image_viewer/gth-metadata-provider-image.c
index 3afff07..da9d19c 100644
--- a/extensions/image_viewer/gth-metadata-provider-image.c
+++ b/extensions/image_viewer/gth-metadata-provider-image.c
@@ -41,7 +41,9 @@ gth_metadata_provider_image_can_read (GthMetadataProvider  *self,
 	return _g_file_attributes_matches_any_v ("general::format,"
 			                         "general::dimensions,"
 						 "image::width,"
-						 "image::height",
+						 "image::height,"
+						 "frame::width,"
+						 "frame::height",
 					         attribute_v);
 }
 
@@ -67,6 +69,8 @@ gth_metadata_provider_image_read (GthMetadataProvider *self,
 
 		g_file_info_set_attribute_int32 (file_data->info, "image::width", width);
 		g_file_info_set_attribute_int32 (file_data->info, "image::height", height);
+		g_file_info_set_attribute_int32 (file_data->info, "frame::width", width);
+		g_file_info_set_attribute_int32 (file_data->info, "frame::height", height);
 
 		size = g_strdup_printf ("%d Ã? %d", width, height);
 		g_file_info_set_attribute_string (file_data->info, "general::dimensions", size);
diff --git a/gthumb/gth-main-default-metadata.c b/gthumb/gth-main-default-metadata.c
index 7391a8c..9ab90d8 100644
--- a/gthumb/gth-main-default-metadata.c
+++ b/gthumb/gth-main-default-metadata.c
@@ -54,6 +54,10 @@ GthMetadataInfo file_metadata_info[] = {
 	{ "general::tags", N_("Tags"), "general", 18, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
 	{ "general::rating", N_("Rating"), "general", 19, NULL, GTH_METADATA_ALLOW_EVERYWHERE },
 
+	{ "image::width", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
+	{ "image::height", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
+	{ "frame::width", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
+	{ "frame::height", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
 	{ "Embedded::Image::Orientation", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
 	{ "Embedded::Photo::DateTimeOriginal", "", "", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
 
diff --git a/gthumb/gth-main-default-sort-types.c b/gthumb/gth-main-default-sort-types.c
index 0349984..b4039bd 100644
--- a/gthumb/gth-main-default-sort-types.c
+++ b/gthumb/gth-main-default-sort-types.c
@@ -77,11 +77,35 @@ gth_file_data_cmp_modified_time (GthFileData *a,
 }
 
 
+static int
+gth_general_data_cmp_dimensions (GthFileData *a,
+				 GthFileData *b)
+{
+	int width_a;
+	int height_a;
+	int width_b;
+	int height_b;
+	int result;
+
+	width_a = g_file_info_get_attribute_int32 (a->info, "frame::width");
+	height_a = g_file_info_get_attribute_int32 (a->info, "frame::height");
+	width_b = g_file_info_get_attribute_int32 (b->info, "frame::width");
+	height_b = g_file_info_get_attribute_int32 (b->info, "frame::height");
+
+	result = width_a * height_a - width_b * height_b;
+	if (result == 0)
+		result = gth_file_data_cmp_filename (a, b);
+
+	return result;
+}
+
+
 GthFileDataSort default_sort_types[] = {
 	{ "file::name", N_("file name"), "standard::display-name", gth_file_data_cmp_filename },
 	{ "file::size", N_("file size"), "standard::size", gth_file_data_cmp_filesize },
 	{ "file::mtime", N_("file modified date"), "time::modified,time::modified-usec", gth_file_data_cmp_modified_time },
 	{ "general::unsorted", N_("no sorting"), "", NULL },
+	{ "general::dimensions", N_("dimensions"), "frame::width,frame::height", gth_general_data_cmp_dimensions },
 };
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]