Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_photo.c
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 /**
21  * @file eail_photo.c
22  * @brief EailPhoto implementation
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_photo.h"
28 #include "eail_priv.h"
29
30 static void atk_image_iface_init(AtkImageIface *iface);
31
32 /**
33  * @brief EailPhoto type definition
34  */
35 G_DEFINE_TYPE_WITH_CODE(EailPhoto, eail_photo, EAIL_TYPE_IMAGE,
36                         G_IMPLEMENT_INTERFACE(ATK_TYPE_IMAGE,
37                                               atk_image_iface_init));
38
39
40 /**
41  * @brief Gets the image size
42  *
43  * @param image AtkImage instance
44  * @param [out] width photo width or -1 if value cannot be obtained
45  * @param [out] height photo height or -1 if value cannot be obtained
46  */
47 static void
48 eail_photo_size_get(AtkImage *image, gint *width, gint *height)
49 {
50    g_return_if_fail(ATK_IS_IMAGE(image));
51
52    Evas_Object *widget = eail_widget_get_widget(EAIL_WIDGET(image));
53    if (!widget)
54      {
55         *width = -1;
56         *height = -1;
57         return;
58      }
59    evas_object_geometry_get(widget, NULL, NULL, width, height);
60 }
61
62 /**
63  * @brief EailPhoto initializer
64  *
65  * @param obj AtkObject instance
66  * @param data initialization data
67  */
68 static void
69 eail_photo_initialize(AtkObject *obj, gpointer data)
70 {
71    ATK_OBJECT_CLASS(eail_photo_parent_class)->initialize(obj, data);
72 }
73
74 /**
75  * @brief EailPhoto class initializer
76  *
77  * @param klass EailPhotoClass instance
78  */
79 static void
80 eail_photo_class_init(EailPhotoClass *klass)
81 {
82    AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
83    atk_class->initialize = eail_photo_initialize;
84 }
85
86 /**
87  * @brief EailPhoto instance initializer
88  *
89  * @param photo EailPhoto instance
90  */
91 static void
92 eail_photo_init(EailPhoto *photo)
93 {
94 }
95
96 /**
97  * @brief AtkImage interface initializer
98  *
99  * @param iface AtkImage interface
100  */
101 static void
102 atk_image_iface_init(AtkImageIface* iface)
103 {
104    if (!iface) return;
105
106    iface->get_image_size = eail_photo_size_get;
107 }
108