3444f55a9254d252b307a932eb9a429f76850848
[platform/core/uifw/eail.git] / eail / eail / eail_route.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_route.c
22  * @brief EailRoute implementation
23  */
24
25 #include <Elementary.h>
26
27 #include "eail_route.h"
28
29 static void atk_value_interface_init(AtkValueIface *iface);
30
31 /**
32  * @brief Define EailRoute GObject type
33  */
34 G_DEFINE_TYPE_WITH_CODE(EailRoute,
35                         eail_route,
36                         EAIL_TYPE_WIDGET,
37                         G_IMPLEMENT_INTERFACE(ATK_TYPE_VALUE,
38                                               atk_value_interface_init));
39
40 /**
41  * @brief EailRoute object initialization
42  *
43  * @param obj EailRoute object
44  * @param data user set additional initialization data
45  */
46 static void
47 eail_route_initialize(AtkObject *obj, gpointer data)
48 {
49    ATK_OBJECT_CLASS(eail_route_parent_class)->initialize(obj, data);
50
51    obj->role = ATK_ROLE_IMAGE_MAP;
52 }
53
54 /**
55  * @brief EailRoute instance initialization
56  *
57  * @param route EailRoute instance
58  */
59 static void
60 eail_route_init(EailRoute *route)
61 {
62 }
63
64 /**
65  * @brief GObject type initialization function
66  *
67  * @param klass EailRoute class
68  */
69 static void
70 eail_route_class_init(EailRouteClass *klass)
71 {
72    AtkObjectClass *class = ATK_OBJECT_CLASS(klass);
73
74    class->initialize = eail_route_initialize;
75 }
76
77 /*
78  * Implementation of the *AtkValue* interface
79  */
80
81 /**
82  * @brief Gets obj current value
83  *
84  * @param obj EailRoute instance
85  * @param value EailRoute current value
86  */
87 static void
88 eail_route_get_current_value(AtkValue *obj,
89                              GValue   *value)
90 {
91    double longitude_min, longitude_max;
92    double latitude_min, latitude_max;
93    Evas_Object *widget;
94    gchar buf[200];
95
96    widget = eail_widget_get_widget(EAIL_WIDGET(obj));
97    if (!widget) return;
98
99    elm_route_longitude_min_max_get(widget, &longitude_min, &longitude_max);
100    elm_route_latitude_min_max_get(widget, &latitude_min, &latitude_max);
101
102    g_snprintf(buf, sizeof(buf), "<longitude><min>%0.6f</min><max>%0.6f</max></longitude>\n"
103                                 "<latitude><min>%0.6f</min><max>%0.6f</max></latitude>",
104                                  longitude_min, longitude_max, latitude_min, latitude_max);
105
106    memset(value, 0, sizeof(GValue));
107    g_value_init(value, G_TYPE_STRING);
108    g_value_set_string(value, buf);
109 }
110
111 /**
112  * @brief AtkValue interface initialization
113  *
114  * @param iface an AtkValue interface
115  */
116 static void
117 atk_value_interface_init(AtkValueIface *iface)
118 {
119    g_return_if_fail(iface != NULL);
120
121    iface->get_current_value = eail_route_get_current_value;
122 }