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
|
/*
* Copyright 2008 Codethink Ltd.
* 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 Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <glib.h>
#include <string.h>
#include <atk/atk.h>
#include <stdio.h>
#include "my-atk-object.h"
#include "my-atk-value.h"
typedef struct _MyAtkValueInfo MyAtkValueInfo;
static void atk_value_interface_init (AtkValueIface *iface);
G_DEFINE_TYPE_WITH_CODE (MyAtkValue,
my_atk_value,
MY_TYPE_ATK_OBJECT,
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE,
atk_value_interface_init));
guint
my_atk_set_value (AtkValue *obj, gdouble min, gdouble cur, gdouble max, gdouble step)
{
MyAtkValue *self = MY_ATK_VALUE (obj);
g_return_val_if_fail (MY_IS_ATK_VALUE (obj), -1);
self->min = min;
self->cur = cur;
self->max = max;
self->step = step;
return 0;
}
static void
my_atk_value_get_value_and_text (AtkValue *obj, gdouble *value, gchar **text)
{
MyAtkValue *self = MY_ATK_VALUE (obj);
g_return_if_fail (MY_IS_ATK_VALUE (obj));
*value = self->cur;
*text = g_strdup_printf ("%f", self->cur);
}
static AtkRange*
my_atk_value_get_range (AtkValue *obj)
{
MyAtkValue *self = MY_ATK_VALUE (obj);
g_return_val_if_fail (MY_IS_ATK_VALUE (obj), NULL);
return atk_range_new (self->min, self->max, NULL);
}
static gdouble
my_atk_value_get_increment (AtkValue *obj)
{
MyAtkValue *self = MY_ATK_VALUE (obj);
g_return_val_if_fail (MY_IS_ATK_VALUE (obj), 0);
return self->step;
}
static GSList*
my_atk_value_get_sub_ranges (AtkValue *obj)
{
g_return_val_if_fail (MY_IS_ATK_VALUE (obj), NULL);
return NULL;
}
static void
my_atk_value_set_value (AtkValue *obj, const gdouble val)
{
MyAtkValue *self = MY_ATK_VALUE (obj);
g_return_if_fail (MY_IS_ATK_VALUE (obj));
if ( self->min < val && val < self->max )
self->cur = val;
return;
}
static void
atk_value_interface_init (AtkValueIface *iface)
{
if (!iface) return;
iface->get_value_and_text = my_atk_value_get_value_and_text;
iface->get_range = my_atk_value_get_range;
iface->get_increment = my_atk_value_get_increment;
iface->get_sub_ranges = my_atk_value_get_sub_ranges;
iface->set_value = my_atk_value_set_value;
}
static void
my_atk_value_init (MyAtkValue *self)
{
self->min = 0;
self->cur = 0;
self->max = 0;
self->step = 0;
}
static void
my_atk_value_class_initialize (AtkObject *obj, gpointer data)
{
}
static void
my_atk_value_class_finalize (GObject *obj)
{
}
static void
my_atk_value_class_init(MyAtkValueClass *my_class)
{
AtkObjectClass *atk_class = ATK_OBJECT_CLASS(my_class);
GObjectClass *gobject_class = G_OBJECT_CLASS(my_class);
gobject_class->finalize = my_atk_value_class_finalize;
atk_class->initialize = my_atk_value_class_initialize;
}
|