summaryrefslogtreecommitdiff
path: root/tests/dummyatk/my-atk-image.c
blob: 09b71913c3e8031610269b561e9a6231d89c6152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * AT-SPI - Assistive Technology Service Provider Interface
 * (Gnome Accessibility Project; https://wiki.gnome.org/Accessibility)
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */


#include <stdio.h>
#include <string.h>
#include <atk/atk.h>

#include "my-atk-object.h"
#include "my-atk-image.h"

typedef struct _MyAtkImageInfo MyAtkImageInfo;

static void atk_image_interface_init (AtkImageIface *iface);

G_DEFINE_TYPE_WITH_CODE (MyAtkImage,
                         my_atk_image,
                         MY_TYPE_ATK_OBJECT,
                         G_IMPLEMENT_INTERFACE (ATK_TYPE_IMAGE,
                             atk_image_interface_init));

guint
my_atk_set_image (AtkImage *image,
                  const gchar *desc,
                  const gint x,
                  const gint y,
                  const gint width,
                  const gint height,
                  const gchar *locale)
{
  g_return_val_if_fail (MY_IS_ATK_IMAGE (image), FALSE);

  MyAtkImage *self = MY_ATK_IMAGE (image);

  self->description = g_strdup (desc);
  self->x = x;
  self->y = y;
  self->width = width;
  self->height = height;
  self->locale = g_strdup (locale);

  return 0;
}

static void
my_atk_image_init (MyAtkImage *obj)
{
  MyAtkImage *self = MY_ATK_IMAGE (obj);
  self->description = NULL;
  self->x = -1;
  self->y = -1;
  self->width = -1;
  self->height = -1;
  self->locale = NULL;
}

void my_atk_image_get_image_position (AtkImage *obj, gint *x, gint *y, AtkCoordType coord_type)
{
  g_return_if_fail (MY_IS_ATK_IMAGE (obj));

  MyAtkImage *self = MY_ATK_IMAGE (obj);
  *x = self->x;
  *y = self->y;
}

const gchar*
my_atk_image_get_image_description (AtkImage *obj)
{
  g_return_val_if_fail (MY_IS_ATK_IMAGE (obj), NULL);

  MyAtkImage *self = MY_ATK_IMAGE (obj);

  return g_strdup (self->description);
}

void my_atk_image_get_image_size (AtkImage *obj, gint *width, gint *height)
{
  g_return_if_fail (MY_IS_ATK_IMAGE (obj));

  MyAtkImage *self = MY_ATK_IMAGE (obj);
  *width = self->width;
  *height = self->height;
}

gboolean
my_atk_image_set_image_description (AtkImage *obj, const gchar * desc)
{
  g_return_val_if_fail (MY_IS_ATK_IMAGE (obj), FALSE);

  MyAtkImage *self = MY_ATK_IMAGE (obj);

  g_free (self->description);
  self->description = g_strdup (desc);

  return TRUE;
}

const gchar*
my_atk_image_get_image_locale (AtkImage *obj)
{
  g_return_val_if_fail (MY_IS_ATK_IMAGE (obj), NULL);

  MyAtkImage *self = MY_ATK_IMAGE (obj);

  return self->locale;
}

static void
atk_image_interface_init (AtkImageIface *iface)
{
  if (!iface) return;
  iface->get_image_position = my_atk_image_get_image_position;
  iface->set_image_description = my_atk_image_set_image_description;
  iface->get_image_description = my_atk_image_get_image_description;
  iface->get_image_size = my_atk_image_get_image_size;
  iface->get_image_locale = my_atk_image_get_image_locale;
}

static void
my_atk_image_initialize (AtkObject *obj, gpointer data)
{
}

static void
my_atk_image_finalize (GObject *object)
{
}

static void
my_atk_image_class_init (MyAtkImageClass *my_class)
{
  AtkObjectClass *atk_class = ATK_OBJECT_CLASS (my_class);
  GObjectClass *gobject_class = G_OBJECT_CLASS (my_class);

  gobject_class->finalize = my_atk_image_finalize;

  atk_class->initialize = my_atk_image_initialize;
}