[gnome-photos] properties-dialog: Show width, height and flash



commit 6f29888cc051516caf996c066a296a052226d9ed
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Aug 19 16:46:40 2013 +0200

    properties-dialog: Show width, height and flash

 src/photos-base-item.c         |   31 ++++++++++++++++
 src/photos-base-item.h         |    6 +++
 src/photos-properties-dialog.c |   78 ++++++++++++++++++++++++++++++++++++++++
 src/photos-query-builder.c     |    5 ++-
 src/photos-query.h             |    5 ++-
 src/photos-utils.c             |   14 +++++++
 src/photos-utils.h             |    6 +++
 7 files changed, 143 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 6188cde..ad1be25 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -53,6 +53,7 @@ struct _PhotosBaseItemPrivate
   GMutex mutex_download;
   GMutex mutex;
   GQuark equipment;
+  GQuark flash;
   PhotosCollectionIconWatcher *watcher;
   PhotosSelectionController *sel_cntrlr;
   TrackerSparqlCursor *cursor;
@@ -76,7 +77,9 @@ struct _PhotosBaseItemPrivate
   gdouble focal_length;
   gdouble iso_speed;
   gint64 date_created;
+  gint64 height;
   gint64 mtime;
+  gint64 width;
 };
 
 enum
@@ -677,6 +680,7 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
   GTimeVal timeval;
   const gchar *date_created;
   const gchar *equipment;
+  const gchar *flash;
   const gchar *mtime;
   const gchar *title;
   const gchar *uri;
@@ -717,6 +721,9 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
     title = "";
   priv->name = g_strdup (title);
 
+  priv->width = tracker_sparql_cursor_get_integer (cursor, PHOTOS_QUERY_COLUMNS_WIDTH);
+  priv->height = tracker_sparql_cursor_get_integer (cursor, PHOTOS_QUERY_COLUMNS_HEIGHT);
+
   equipment = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_EQUIPMENT, NULL);
   priv->equipment = g_quark_from_string (equipment);
 
@@ -725,6 +732,9 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
   priv->focal_length = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_FOCAL_LENGTH);
   priv->iso_speed = tracker_sparql_cursor_get_double (cursor, PHOTOS_QUERY_COLUMNS_ISO_SPEED);
 
+  flash = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_FLASH, NULL);
+  priv->flash = g_quark_from_string (flash);
+
   photos_base_item_refresh_icon (self);
 }
 
@@ -1036,6 +1046,13 @@ photos_base_item_get_exposure_time (PhotosBaseItem *self)
 }
 
 
+GQuark
+photos_base_item_get_flash (PhotosBaseItem *self)
+{
+  return self->priv->flash;
+}
+
+
 gdouble
 photos_base_item_get_fnumber (PhotosBaseItem *self)
 {
@@ -1050,6 +1067,13 @@ photos_base_item_get_focal_length (PhotosBaseItem *self)
 }
 
 
+gint64
+photos_base_item_get_height (PhotosBaseItem *self)
+{
+  return self->priv->height;
+}
+
+
 GdkPixbuf *
 photos_base_item_get_icon (PhotosBaseItem *self)
 {
@@ -1149,6 +1173,13 @@ photos_base_item_get_where (PhotosBaseItem *self)
 }
 
 
+gint64
+photos_base_item_get_width (PhotosBaseItem *self)
+{
+  return self->priv->width;
+}
+
+
 gboolean
 photos_base_item_is_collection (PhotosBaseItem *self)
 {
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index 5363e26..ec3f5bd 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -108,10 +108,14 @@ GQuark              photos_base_item_get_equipment      (PhotosBaseItem *self);
 
 gdouble             photos_base_item_get_exposure_time  (PhotosBaseItem *self);
 
+GQuark              photos_base_item_get_flash          (PhotosBaseItem *self);
+
 gdouble             photos_base_item_get_fnumber        (PhotosBaseItem *self);
 
 gdouble             photos_base_item_get_focal_length   (PhotosBaseItem *self);
 
+gint64              photos_base_item_get_height         (PhotosBaseItem *self);
+
 GdkPixbuf          *photos_base_item_get_icon           (PhotosBaseItem *self);
 
 const gchar        *photos_base_item_get_id             (PhotosBaseItem *self);
@@ -138,6 +142,8 @@ const gchar        *photos_base_item_get_uri            (PhotosBaseItem *self);
 
 gchar              *photos_base_item_get_where          (PhotosBaseItem *self);
 
+gint64              photos_base_item_get_width          (PhotosBaseItem *self);
+
 gboolean            photos_base_item_is_collection      (PhotosBaseItem *self);
 
 gboolean            photos_base_item_is_favorite        (PhotosBaseItem *self);
diff --git a/src/photos-properties-dialog.c b/src/photos-properties-dialog.c
index 6e53d2f..82d07df 100644
--- a/src/photos-properties-dialog.c
+++ b/src/photos-properties-dialog.c
@@ -149,15 +149,19 @@ photos_properties_dialog_constructed (GObject *object)
   GtkWidget *date_modified_data;
   GtkWidget *date_modified_w;
   GtkWidget *exposure_time_w = NULL;
+  GtkWidget *flash_w = NULL;
   GtkWidget *fnumber_w = NULL;
   GtkWidget *focal_length_w = NULL;
+  GtkWidget *height_w = NULL;
   GtkWidget *iso_speed_w = NULL;
   GtkWidget *item_type;
   GtkWidget *item_type_data;
   GtkWidget *source;
   GtkWidget *source_data;
   GtkWidget *title;
+  GtkWidget *width_w;
   GQuark equipment;
+  GQuark flash;
   PhotosBaseItem *item;
   const gchar *author;
   const gchar *name;
@@ -169,7 +173,9 @@ photos_properties_dialog_constructed (GObject *object)
   gdouble focal_length;
   gdouble iso_speed;
   gint64 ctime;
+  gint64 height;
   gint64 mtime;
+  gint64 width;
 
   G_OBJECT_CLASS (photos_properties_dialog_parent_class)->constructed (object);
 
@@ -257,6 +263,26 @@ photos_properties_dialog_constructed (GObject *object)
   gtk_style_context_add_class (context, "dim-label");
   gtk_container_add (GTK_CONTAINER (priv->grid), item_type);
 
+  width = photos_base_item_get_width (item);
+  if (width > 0)
+    {
+      width_w = gtk_label_new (_("Width"));
+      gtk_widget_set_halign (width_w, GTK_ALIGN_END);
+      context = gtk_widget_get_style_context (width_w);
+      gtk_style_context_add_class (context, "dim-label");
+      gtk_container_add (GTK_CONTAINER (priv->grid), width_w);
+    }
+
+  height = photos_base_item_get_height (item);
+  if (height > 0)
+    {
+      height_w = gtk_label_new (_("Height"));
+      gtk_widget_set_halign (height_w, GTK_ALIGN_END);
+      context = gtk_widget_get_style_context (height_w);
+      gtk_style_context_add_class (context, "dim-label");
+      gtk_container_add (GTK_CONTAINER (priv->grid), height_w);
+    }
+
   equipment = photos_base_item_get_equipment (item);
   photos_camera_cache_get_camera_async (priv->camera_cache,
                                         equipment,
@@ -312,6 +338,16 @@ photos_properties_dialog_constructed (GObject *object)
       gtk_container_add (GTK_CONTAINER (priv->grid), iso_speed_w);
     }
 
+  flash = photos_base_item_get_flash (item);
+  if (flash != 0)
+    {
+      flash_w = gtk_label_new (_("Flash"));
+      gtk_widget_set_halign (flash_w, GTK_ALIGN_END);
+      context = gtk_widget_get_style_context (flash_w);
+      gtk_style_context_add_class (context, "dim-label");
+      gtk_container_add (GTK_CONTAINER (priv->grid), flash_w);
+    }
+
   name = photos_base_item_get_name (item);
 
   if (PHOTOS_IS_LOCAL_ITEM (item))
@@ -410,6 +446,30 @@ photos_properties_dialog_constructed (GObject *object)
   gtk_widget_set_halign (item_type_data, GTK_ALIGN_START);
   gtk_grid_attach_next_to (GTK_GRID (priv->grid), item_type_data, item_type, GTK_POS_RIGHT, 2, 1);
 
+  if (width_w != NULL)
+    {
+      GtkWidget *width_data;
+      gchar *width_str;
+
+      width_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", width);
+      width_data = gtk_label_new (width_str);
+      gtk_widget_set_halign (width_data, GTK_ALIGN_START);
+      gtk_grid_attach_next_to (GTK_GRID (priv->grid), width_data, width_w, GTK_POS_RIGHT, 2, 1);
+      g_free (width_str);
+    }
+
+  if (height_w != NULL)
+    {
+      GtkWidget *height_data;
+      gchar *height_str;
+
+      height_str = g_strdup_printf ("%"G_GINT64_FORMAT" pixels", height);
+      height_data = gtk_label_new (height_str);
+      gtk_widget_set_halign (height_data, GTK_ALIGN_START);
+      gtk_grid_attach_next_to (GTK_GRID (priv->grid), height_data, height_w, GTK_POS_RIGHT, 2, 1);
+      g_free (height_str);
+    }
+
   if (exposure_time_w != NULL)
     {
       GtkWidget *exposure_time_data;
@@ -458,6 +518,24 @@ photos_properties_dialog_constructed (GObject *object)
       g_free (iso_speed_str);
     }
 
+  if (flash_w != NULL)
+    {
+      GtkWidget *flash_data;
+      gchar *flash_str;
+
+      if (flash == PHOTOS_FLASH_OFF)
+        flash_str = g_strdup (_("Off, Did not fire"));
+      else if (flash == PHOTOS_FLASH_ON)
+        flash_str = g_strdup (_("On, Fired"));
+      else
+        g_assert_not_reached ();
+
+      flash_data = gtk_label_new (flash_str);
+      gtk_widget_set_halign (flash_data, GTK_ALIGN_START);
+      gtk_grid_attach_next_to (GTK_GRID (priv->grid), flash_data, flash_w, GTK_POS_RIGHT, 2, 1);
+      g_free (flash_str);
+    }
+
   g_free (date_created_str);
   g_free (date_modified_str);
 }
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index bd8f834..2755876 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -199,11 +199,14 @@ photos_query_builder_query (gboolean global, gint flags)
                         "( EXISTS { ?urn nao:hasTag nao:predefined-tag-favorite } ) "
                         "( EXISTS { ?urn nco:contributor ?contributor FILTER ( ?contributor != ?creator ) } 
) "
                         "tracker:coalesce(nfo:fileCreated (?urn), nie:contentCreated (?urn))"
+                        "nfo:width (?urn)"
+                        "nfo:height (?urn)"
                         "nfo:equipment (?urn)"
                         "nmm:exposureTime (?urn)"
                         "nmm:fnumber (?urn)"
                         "nmm:focalLength (?urn)"
-                        "nmm:isoSpeed (?urn)",
+                        "nmm:isoSpeed (?urn)"
+                        "nmm:flash (?urn)",
                         where_sparql,
                         tail_sparql,
                         NULL);
diff --git a/src/photos-query.h b/src/photos-query.h
index 7529071..5dc2d60 100644
--- a/src/photos-query.h
+++ b/src/photos-query.h
@@ -47,11 +47,14 @@ typedef enum
   PHOTOS_QUERY_COLUMNS_RESOURCE_FAVORITE,
   PHOTOS_QUERY_COLUMNS_RESOURCE_SHARED,
   PHOTOS_QUERY_COLUMNS_DATE_CREATED,
+  PHOTOS_QUERY_COLUMNS_WIDTH,
+  PHOTOS_QUERY_COLUMNS_HEIGHT,
   PHOTOS_QUERY_COLUMNS_EQUIPMENT,
   PHOTOS_QUERY_COLUMNS_EXPOSURE_TIME,
   PHOTOS_QUERY_COLUMNS_FNUMBER,
   PHOTOS_QUERY_COLUMNS_FOCAL_LENGTH,
-  PHOTOS_QUERY_COLUMNS_ISO_SPEED
+  PHOTOS_QUERY_COLUMNS_ISO_SPEED,
+  PHOTOS_QUERY_COLUMNS_FLASH
 } PhotosQueryColumns;
 
 typedef enum
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 0b2b3cd..21929b1 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -411,6 +411,20 @@ photos_utils_filename_strip_extension (const gchar *filename_with_extension)
 }
 
 
+GQuark
+photos_utils_flash_off_quark (void)
+{
+  return g_quark_from_static_string ("http://www.tracker-project.org/temp/nmm#flash-off";);
+}
+
+
+GQuark
+photos_utils_flash_on_quark (void)
+{
+  return g_quark_from_static_string ("http://www.tracker-project.org/temp/nmm#flash-on";);
+}
+
+
 gint
 photos_utils_get_icon_size (void)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 66df5ac..ec36a80 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -35,6 +35,8 @@
 G_BEGIN_DECLS
 
 #define PHOTOS_ERROR (photos_utils_error_quark ())
+#define PHOTOS_FLASH_OFF (photos_utils_flash_off_quark ())
+#define PHOTOS_FLASH_ON (photos_utils_flash_on_quark ())
 
 GIcon           *photos_utils_create_collection_icon      (gint base_size, GList *pixbufs);
 
@@ -55,6 +57,10 @@ GQuark           photos_utils_error_quark                 (void);
 
 gchar           *photos_utils_filename_strip_extension    (const gchar *filename_with_extension);
 
+GQuark           photos_utils_flash_off_quark             (void);
+
+GQuark           photos_utils_flash_on_quark              (void);
+
 gint             photos_utils_get_icon_size               (void);
 
 char*            photos_utils_get_pixbuf_common_suffix    (GdkPixbufFormat *format);


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