[gnome-photos/wip/rishi/zoom: 4/12] Add PhotosImageViewAnimator



commit 2e3dd41dcd77f3c8b6484f7df2fb9c13de6d9e88
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Jun 2 19:22:59 2017 +0200

    Add PhotosImageViewAnimator

 src/Makefile.am                  |    2 +
 src/photos-image-view-animator.c |  135 ++++++++++++++++++++++++++++++++++++++
 src/photos-image-view-animator.h |   39 +++++++++++
 3 files changed, 176 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 6bf99ef..a2a1fa2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -117,6 +117,8 @@ gnome_photos_SOURCES = \
        photos-icons.h \
        photos-image-view.c \
        photos-image-view.h \
+       photos-image-view-animator.c \
+       photos-image-view-animator.h \
        photos-indexing-notification.c \
        photos-indexing-notification.h \
        photos-item-manager.c \
diff --git a/src/photos-image-view-animator.c b/src/photos-image-view-animator.c
new file mode 100644
index 0000000..3e8d564
--- /dev/null
+++ b/src/photos-image-view-animator.c
@@ -0,0 +1,135 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 – 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "photos-image-view-animator.h"
+#include "photos-utils.h"
+
+
+struct _PhotosImageViewAnimator
+{
+  GObject parent_instance;
+  gdouble zoom;
+};
+
+enum
+{
+  PROP_0,
+  PROP_ZOOM
+};
+
+
+G_DEFINE_TYPE (PhotosImageViewAnimator, photos_image_view_animator, G_TYPE_OBJECT);
+
+
+static void
+photos_image_view_animator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+  PhotosImageViewAnimator *self = PHOTOS_IMAGE_VIEW_ANIMATOR (object);
+
+  switch (prop_id)
+    {
+    case PROP_ZOOM:
+      g_value_set_double (value, self->zoom);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_image_view_animator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec 
*pspec)
+{
+  PhotosImageViewAnimator *self = PHOTOS_IMAGE_VIEW_ANIMATOR (object);
+
+  switch (prop_id)
+    {
+    case PROP_ZOOM:
+      {
+        gdouble zoom;
+
+        zoom = g_value_get_double (value);
+        photos_image_view_animator_set_zoom (self, zoom);
+        break;
+      }
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_image_view_animator_init (PhotosImageViewAnimator *self)
+{
+}
+
+
+static void
+photos_image_view_animator_class_init (PhotosImageViewAnimatorClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->get_property = photos_image_view_animator_get_property;
+  object_class->set_property = photos_image_view_animator_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_ZOOM,
+                                   g_param_spec_double ("zoom",
+                                                        "Zoom",
+                                                        "Zoom factor",
+                                                        0.0,
+                                                        100.0,
+                                                        1.0,
+                                                        G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READWRITE));
+}
+
+
+PhotosImageViewAnimator *
+photos_image_view_animator_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_IMAGE_VIEW_ANIMATOR, NULL);
+}
+
+
+gdouble
+photos_image_view_animator_get_zoom (PhotosImageViewAnimator *self)
+{
+  g_return_val_if_fail (PHOTOS_IS_IMAGE_VIEW_ANIMATOR (self), 0.0);
+  return self->zoom;
+}
+
+
+void
+photos_image_view_animator_set_zoom (PhotosImageViewAnimator *self, gdouble zoom)
+{
+  g_return_if_fail (PHOTOS_IS_IMAGE_VIEW_ANIMATOR (self));
+
+  if (photos_utils_equal_double (self->zoom, zoom))
+    return;
+
+  self->zoom = zoom;
+  g_object_notify (G_OBJECT (self), "zoom");
+}
diff --git a/src/photos-image-view-animator.h b/src/photos-image-view-animator.h
new file mode 100644
index 0000000..e9e3c60
--- /dev/null
+++ b/src/photos-image-view-animator.h
@@ -0,0 +1,39 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 – 2017 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_IMAGE_VIEW_ANIMATOR_H
+#define PHOTOS_IMAGE_VIEW_ANIMATOR_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_IMAGE_VIEW_ANIMATOR (photos_image_view_animator_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosImageViewAnimator, photos_image_view_animator, PHOTOS, IMAGE_VIEW_ANIMATOR, 
GObject);
+
+PhotosImageViewAnimator    *photos_image_view_animator_new         (void);
+
+gdouble                     photos_image_view_animator_get_zoom    (PhotosImageViewAnimator *self);
+
+void                        photos_image_view_animator_set_zoom    (PhotosImageViewAnimator *self, gdouble 
zoom);
+
+G_END_DECLS
+
+#endif /* PHOTOS_IMAGE_VIEW_ANIMATOR_H */


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