Merge "custom eail widget implementation" into tizen
[platform/core/uifw/eail.git] / eail / eail_icon.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_icon.c
22  * @brief EailIcon implementation
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_icon.h"
28
29 /**
30  * @brief EailIcon type definition
31  */
32 G_DEFINE_TYPE(EailIcon, eail_icon, EAIL_TYPE_IMAGE);
33
34 /**
35  * @brief EailIcon initializer
36  *
37  * @param obj AtkObject instance
38  * @param data initialization data
39  */
40 static void
41 eail_icon_initialize(AtkObject *obj, gpointer data)
42 {
43    ATK_OBJECT_CLASS(eail_icon_parent_class)->initialize(obj, data);
44
45    obj->role = ATK_ROLE_ICON;
46 }
47
48 /**
49  * @brief Gets the name of obj
50  *
51  * Returns obj's name or obj's icon file path if obj has no assigned name,
52  * or null if none of the previous applies.
53  *
54  * @param obj AtkObject instance
55  * @returns string representing obj's name or its file path,
56  * or null if obj doesn't have a name or an a file path
57  */
58 static const gchar*
59 eail_icon_get_name(AtkObject *obj)
60 {
61    const gchar *name;
62    Evas_Object *widget = NULL;
63
64    name = ATK_OBJECT_CLASS(eail_icon_parent_class)->get_name(obj);
65    if (name != NULL) return name;
66
67    widget = eail_widget_get_widget(EAIL_WIDGET(obj));
68    if (widget)
69      {
70         name = (const gchar*)elm_icon_standard_get(widget);
71         if (!name) elm_image_file_get(widget, &name, NULL);
72      }
73
74    return name;
75 }
76
77 /**
78  * @brief EailIcon instance initializer
79  *
80  * @param icon EailIcon instance
81  */
82 static void
83 eail_icon_init(EailIcon *icon)
84 {
85 }
86
87 /**
88  * @brief EailItem class initializer
89  * @param klass EailIconClass instance
90  */
91 static void
92 eail_icon_class_init(EailIconClass *klass)
93 {
94    AtkObjectClass *atk_class = ATK_OBJECT_CLASS(klass);
95
96    atk_class->initialize = eail_icon_initialize;
97    atk_class->get_name = eail_icon_get_name;
98 }