gtk2-ng/modules/other/gail/gailvalue.h
Daemonratte a116a5d13b gail: implement modern AtkValue interface
Add compile-time support for the modern AtkValue API available since ATK 2.12 while retaining compatibility with older ATK versions.

Implement direct modern value, range, increment and setter methods for adjustments, paned widgets, progress bars, ranges, scale buttons and spin buttons.

Keep the implementation private, avoid per-instance memory overhead and preserve the existing exported ABI.
2026-08-07 08:53:00 +02:00

56 lines
2.9 KiB
C

/* GAIL - The GNOME Accessibility Implementation Library
*
* 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 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.
*/
#ifndef __GAIL_VALUE_H__
#define __GAIL_VALUE_H__
#include <gtk/gtk.h>
#define GAIL_VALUE_ADJUSTMENT(accessible) \
((accessible) != NULL ? GAIL_ADJUSTMENT (accessible)->adjustment : NULL)
#define GAIL_VALUE_MINIMUM_INCREMENT(a) \
((a)->step_increment == 0.0 ? (a)->page_increment : \
(a)->page_increment == 0.0 ? (a)->step_increment : \
ABS ((a)->step_increment) < ABS ((a)->page_increment) \
? (a)->step_increment : (a)->page_increment)
#ifdef HAVE_ATK_VALUE_2_12
#define GAIL_DEFINE_ADJUSTMENT_VALUE_READERS(prefix, a_expr, value_expr, max_expr) \
static void prefix##_get_value_and_text (AtkValue *obj, gdouble *value, gchar **text) \
{ \
GtkAdjustment *adjustment = (a_expr); \
if (text != NULL) *text = NULL; \
if (value != NULL) *value = adjustment != NULL ? (value_expr) : 0.0; \
} \
static AtkRange *prefix##_get_range (AtkValue *obj) \
{ \
GtkAdjustment *adjustment = (a_expr); \
return adjustment != NULL \
? atk_range_new (adjustment->lower, (max_expr), NULL) : NULL; \
}
#define GAIL_DEFINE_ADJUSTMENT_VALUE_INCREMENT(prefix, a_expr, increment_expr) \
static gdouble prefix##_get_increment (AtkValue *obj) \
{ \
GtkAdjustment *adjustment = (a_expr); \
return adjustment != NULL ? (increment_expr) : 0.0; \
}
#define GAIL_DEFINE_WIDGET_VALUE_SETTER(prefix, cast, setter, value_expr) \
static void prefix##_set_value (AtkValue *obj, gdouble value) \
{ \
GtkWidget *widget = GTK_ACCESSIBLE (obj)->widget; \
if (widget != NULL) setter (cast (widget), (value_expr)); \
}
#endif
#endif /* __GAIL_VALUE_H__ */