Commit f54cc702 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Nuke GailAdjustment

This was a fairly trivial wrapper around GtkAdjustment with
no particularly important reason for existence.
parent 1ff2076c
......@@ -5,7 +5,6 @@ noinst_LTLIBRARIES = libgail.la
gail_c_sources = \
gail-private-macros.h \
gail.c \
gailadjustment.c \
gtkarrowaccessible.c \
gailbooleancell.c \
gailbutton.c \
......@@ -56,7 +55,6 @@ gail_c_sources = \
libgailincludedir=$(includedir)/gail-3.0/gail
gail_private_h_sources = \
gailadjustment.h \
gtkarrowaccessible.h \
gailbooleancell.h \
gailbutton.h \
......
......@@ -21,7 +21,6 @@
#include <gtk/gtk.h>
#include "gailscalebutton.h"
#include "gailadjustment.h"
#include "gail-private-macros.h"
#include <string.h>
......@@ -86,28 +85,16 @@ static void
gail_scale_button_real_initialize (AtkObject *obj,
gpointer data)
{
GailScaleButton *scale_button = GAIL_SCALE_BUTTON (obj);
GtkScaleButton *gtk_scale_button;
GtkAdjustment *gtk_adjustment;
GtkAdjustment *adjustment;
ATK_OBJECT_CLASS (gail_scale_button_parent_class)->initialize (obj, data);
gtk_scale_button = GTK_SCALE_BUTTON (data);
gtk_adjustment = gtk_scale_button_get_adjustment (gtk_scale_button);
/*
* If a GtkAdjustment already exists for the scale_button,
* create the GailAdjustment
*/
if (gtk_adjustment)
{
scale_button->adjustment = gail_adjustment_new (gtk_adjustment);
g_signal_connect (gtk_adjustment,
"value-changed",
G_CALLBACK (gail_scale_button_value_changed),
obj);
}
else
scale_button->adjustment = NULL;
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (data));
if (adjustment)
g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gail_scale_button_value_changed),
obj);
obj->role = ATK_ROLE_SLIDER;
}
......@@ -187,90 +174,85 @@ static void
gail_scale_button_get_current_value (AtkValue *obj,
GValue *value)
{
GailScaleButton *scale_button;
g_return_if_fail (GAIL_IS_SCALE_BUTTON (obj));
GtkWidget *widget;
GtkAdjustment *adjustment;
scale_button = GAIL_SCALE_BUTTON (obj);
if (scale_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_current_value (ATK_VALUE (scale_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gail_scale_button_get_maximum_value (AtkValue *obj,
GValue *value)
{
GailScaleButton *scale_button;
g_return_if_fail (GAIL_IS_SCALE_BUTTON (obj));
GtkWidget *widget;
GtkAdjustment *adjustment;
scale_button = GAIL_SCALE_BUTTON (obj);
if (scale_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_maximum_value (ATK_VALUE (scale_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
}
static void
gail_scale_button_get_minimum_value (AtkValue *obj,
GValue *value)
{
GailScaleButton *scale_button;
g_return_if_fail (GAIL_IS_SCALE_BUTTON (obj));
GtkWidget *widget;
GtkAdjustment *adjustment;
scale_button = GAIL_SCALE_BUTTON (obj);
if (scale_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_minimum_value (ATK_VALUE (scale_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gail_scale_button_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GailScaleButton *scale_button;
g_return_if_fail (GAIL_IS_SCALE_BUTTON (obj));
GtkWidget *widget;
GtkAdjustment *adjustment;
scale_button = GAIL_SCALE_BUTTON (obj);
if (scale_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_minimum_increment (ATK_VALUE (scale_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
}
static gboolean
gail_scale_button_set_current_value (AtkValue *obj,
const GValue *value)
{
GailScaleButton *scale_button;
g_return_val_if_fail (GAIL_IS_SCALE_BUTTON (obj), FALSE);
GtkWidget *widget;
GtkAdjustment *adjustment;
scale_button = GAIL_SCALE_BUTTON (obj);
if (scale_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_scale_button_get_adjustment (GTK_SCALE_BUTTON (widget));
if (adjustment == NULL)
return FALSE;
return atk_value_set_current_value (ATK_VALUE (scale_button->adjustment), value);
gtk_adjustment_set_value (adjustment, g_value_get_double (value));
return TRUE;
}
static void
......@@ -287,24 +269,10 @@ gail_scale_button_real_notify_gtk (GObject *obj,
if (strcmp (pspec->name, "adjustment") == 0)
{
/*
* Get rid of the GailAdjustment for the GtkAdjustment
* which was associated with the scale_button.
*/
GtkAdjustment* gtk_adjustment;
if (scale_button->adjustment)
{
g_object_unref (scale_button->adjustment);
scale_button->adjustment = NULL;
}
/*
* Create the GailAdjustment when notify for "adjustment" property
* is received
*/
gtk_adjustment = gtk_scale_button_get_adjustment (gtk_scale_button);
scale_button->adjustment = gail_adjustment_new (gtk_adjustment);
g_signal_connect (gtk_adjustment,
GtkAdjustment* adjustment;
adjustment = gtk_scale_button_get_adjustment (gtk_scale_button);
g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gail_scale_button_value_changed),
scale_button);
......
......@@ -38,8 +38,6 @@ typedef struct _GailScaleButtonClass GailScaleButtonClass;
struct _GailScaleButton
{
GailButton parent;
AtkObject *adjustment;
};
struct _GailScaleButtonClass
......
......@@ -24,7 +24,6 @@
#include <gtk/gtk.h>
#include "gtkprogressbaraccessible.h"
#include "gailadjustment.h"
static void atk_value_interface_init (AtkValueIface *iface);
......
......@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "gtkrangeaccessible.h"
#include "gailadjustment.h"
static void atk_action_interface_init (AtkActionIface *iface);
......@@ -58,14 +57,11 @@ gtk_range_accessible_initialize (AtkObject *obj,
adj = gtk_range_get_adjustment (gtk_range);
if (adj)
{
range->adjustment = gail_adjustment_new (adj);
g_signal_connect (adj,
"value-changed",
G_CALLBACK (gtk_range_accessible_value_changed),
range);
}
else
range->adjustment = NULL;
obj->role = ATK_ROLE_SLIDER;
}
......@@ -74,20 +70,16 @@ static void
gtk_range_accessible_finalize (GObject *object)
{
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (object);
GtkWidget *widget;
GtkAdjustment *adj;
if (range->adjustment)
{
/* The GtkAdjustment may live on so we need to disconnect
* the signal handler
*/
if (GAIL_ADJUSTMENT (range->adjustment)->adjustment)
g_signal_handlers_disconnect_by_func (GAIL_ADJUSTMENT (range->adjustment)->adjustment,
(void *)gtk_range_accessible_value_changed,
range);
g_object_unref (range->adjustment);
range->adjustment = NULL;
}
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
adj = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adj)
g_signal_handlers_disconnect_by_func (adj,
gtk_range_accessible_value_changed,
range);
if (range->action_idle_handler)
{
......@@ -102,26 +94,14 @@ static void
gtk_range_accessible_notify_gtk (GObject *obj,
GParamSpec *pspec)
{
GtkAdjustment *adj;
GtkWidget *widget = GTK_WIDGET (obj);
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (gtk_widget_get_accessible (widget));
GtkAdjustment *adj;
AtkObject *range;
if (strcmp (pspec->name, "adjustment") == 0)
{
/* Get rid of the GailAdjustment for the GtkAdjustment
* which was associated with the range.
*/
if (range->adjustment)
{
g_object_unref (range->adjustment);
range->adjustment = NULL;
}
/* Create the GailAdjustment when notify for "adjustment" property
* is received
*/
range = gtk_widget_get_accessible (widget);
adj = gtk_range_get_adjustment (GTK_RANGE (widget));
range->adjustment = gail_adjustment_new (adj);
g_signal_connect (adj,
"value-changed",
G_CALLBACK (gtk_range_accessible_value_changed),
......@@ -155,37 +135,40 @@ static void
gtk_range_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (obj);
GtkWidget *widget;
GtkAdjustment *adjustment;
if (range->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
atk_value_get_current_value (ATK_VALUE (range->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gtk_range_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (obj);
GtkRange *gtk_range;
GtkAdjustment *gtk_adjustment;
gdouble max = 0;
GtkWidget *widget;
GtkAdjustment *adjustment;
gdouble max;
if (range->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
atk_value_get_maximum_value (ATK_VALUE (range->adjustment), value);
gtk_range = GTK_RANGE (gtk_accessible_get_widget (GTK_ACCESSIBLE (range)));
max = gtk_adjustment_get_upper (adjustment)
- gtk_adjustment_get_page_size (adjustment);
gtk_adjustment = gtk_range_get_adjustment (gtk_range);
max = g_value_get_double (value);
max -= gtk_adjustment_get_page_size (gtk_adjustment);
if (gtk_range_get_restrict_to_fill_level (gtk_range))
max = MIN (max, gtk_range_get_fill_level (gtk_range));
if (gtk_range_get_restrict_to_fill_level (GTK_RANGE (widget)))
max = MIN (max, gtk_range_get_fill_level (GTK_RANGE (widget)));
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, max);
}
......@@ -193,50 +176,51 @@ static void
gtk_range_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (obj);
GtkWidget *widget;
GtkAdjustment *adjustment;
if (range->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
atk_value_get_minimum_value (ATK_VALUE (range->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gtk_range_accessible_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GtkRangeAccessible *range = GTK_RANGE_ACCESSIBLE (obj);
GtkWidget *widget;
GtkAdjustment *adjustment;
if (range->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return;
atk_value_get_minimum_increment (ATK_VALUE (range->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_minimum_increment (adjustment));
}
static gboolean
gtk_range_accessible_set_current_value (AtkValue *obj,
const GValue *value)
{
GtkWidget *widget;
GtkWidget *widget;
GtkAdjustment *adjustment;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
if (adjustment == NULL)
return FALSE;
if (G_VALUE_HOLDS_DOUBLE (value))
{
GtkRange *range = GTK_RANGE (widget);
gdouble new_value;
new_value = g_value_get_double (value);
gtk_range_set_value (range, new_value);
gtk_adjustment_set_value (adjustment, g_value_get_double (value));
return TRUE;
}
else
{
return FALSE;
}
return TRUE;
}
static void
......
......@@ -38,8 +38,7 @@ struct _GtkRangeAccessible
{
GailWidget parent;
AtkObject *adjustment;
guint action_idle_handler;
guint action_idle_handler;
};
struct _GtkRangeAccessibleClass
......
......@@ -22,7 +22,6 @@
#include <string.h>
#include <gtk/gtk.h>
#include "gtkspinbuttonaccessible.h"
#include "gailadjustment.h"
static void atk_value_interface_init (AtkValueIface *iface);
......@@ -49,41 +48,17 @@ gtk_spin_button_accessible_initialize (AtkObject *obj,
gpointer data)
{
GtkAdjustment *adjustment;
GtkSpinButtonAccessible *spin_button = GTK_SPIN_BUTTON_ACCESSIBLE (obj);
GtkSpinButton *gtk_spin_button;
ATK_OBJECT_CLASS (gtk_spin_button_accessible_parent_class)->initialize (obj, data);
gtk_spin_button = GTK_SPIN_BUTTON (data);
/*
* If a GtkAdjustment already exists for the spin_button,
* create the GailAdjustment
*/
adjustment = gtk_spin_button_get_adjustment (gtk_spin_button);
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (data));
if (adjustment)
{
spin_button->adjustment = gail_adjustment_new (adjustment);
g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gtk_spin_button_accessible_value_changed),
obj);
}
else
spin_button->adjustment = NULL;
g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gtk_spin_button_accessible_value_changed),
obj);
obj->role = ATK_ROLE_SPIN_BUTTON;
}
static void
gtk_spin_button_accessible_finalize (GObject *object)
{
GtkSpinButtonAccessible *spin_button = GTK_SPIN_BUTTON_ACCESSIBLE (object);
if (spin_button->adjustment)
g_object_unref (spin_button->adjustment);
G_OBJECT_CLASS (gtk_spin_button_accessible_parent_class)->finalize (object);
}
static void
......@@ -95,25 +70,9 @@ gtk_spin_button_accessible_notify_gtk (GObject *obj,
if (strcmp (pspec->name, "adjustment") == 0)
{
/*
* Get rid of the GailAdjustment for the GtkAdjustment
* which was associated with the spin_button.
*/
GtkAdjustment* adjustment;
GtkSpinButton* gtk_spin_button;
if (spin_button->adjustment)
{
g_object_unref (spin_button->adjustment);
spin_button->adjustment = NULL;
}
/*
* Create the GailAdjustment when notify for "adjustment" property
* is received
*/
gtk_spin_button = GTK_SPIN_BUTTON (widget);
adjustment = gtk_spin_button_get_adjustment (gtk_spin_button);
spin_button->adjustment = gail_adjustment_new (adjustment);
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
g_signal_connect (adjustment,
"value-changed",
G_CALLBACK (gtk_spin_button_accessible_value_changed),
......@@ -128,7 +87,6 @@ gtk_spin_button_accessible_notify_gtk (GObject *obj,
static void
gtk_spin_button_accessible_class_init (GtkSpinButtonAccessibleClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
GailWidgetClass *widget_class;
......@@ -137,8 +95,6 @@ gtk_spin_button_accessible_class_init (GtkSpinButtonAccessibleClass *klass)
widget_class->notify_gtk = gtk_spin_button_accessible_notify_gtk;
class->initialize = gtk_spin_button_accessible_initialize;
gobject_class->finalize = gtk_spin_button_accessible_finalize;
}
static void
......@@ -150,65 +106,85 @@ static void
gtk_spin_button_accessible_get_current_value (AtkValue *obj,
GValue *value)
{
GtkSpinButtonAccessible *spin_button;
GtkWidget *widget;
GtkAdjustment *adjustment;
spin_button = GTK_SPIN_BUTTON_ACCESSIBLE (obj);
if (spin_button->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_current_value (ATK_VALUE (spin_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_value (adjustment));
}
static void
gtk_spin_button_accessible_get_maximum_value (AtkValue *obj,
GValue *value)
{
GtkSpinButtonAccessible *spin_button;
GtkWidget *widget;
GtkAdjustment *adjustment;
spin_button = GTK_SPIN_BUTTON_ACCESSIBLE (obj);
if (spin_button->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_maximum_value (ATK_VALUE (spin_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_upper (adjustment));
}
static void
gtk_spin_button_accessible_get_minimum_value (AtkValue *obj,
GValue *value)
{
GtkSpinButtonAccessible *spin_button;
GtkWidget *widget;
GtkAdjustment *adjustment;
spin_button = GTK_SPIN_BUTTON_ACCESSIBLE (obj);
if (spin_button->adjustment == NULL)
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
if (adjustment == NULL)
return;
atk_value_get_minimum_value (ATK_VALUE (spin_button->adjustment), value);
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, gtk_adjustment_get_lower (adjustment));
}
static void
gtk_spin_button_accessible_get_minimum_increment (AtkValue *obj,
GValue *value)