|
Packit |
98cdb6 |
/* GAIL - The GNOME Accessibility Enabling Library
|
|
Packit |
98cdb6 |
* Copyright 2001, 2002, 2003 Sun Microsystems Inc.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* This library is free software; you can redistribute it and/or
|
|
Packit |
98cdb6 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit |
98cdb6 |
* License as published by the Free Software Foundation; either
|
|
Packit |
98cdb6 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* This library is distributed in the hope that it will be useful,
|
|
Packit |
98cdb6 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
98cdb6 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
98cdb6 |
* Lesser General Public License for more details.
|
|
Packit |
98cdb6 |
*
|
|
Packit |
98cdb6 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
98cdb6 |
* License along with this library; if not, write to the
|
|
Packit |
98cdb6 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
Packit |
98cdb6 |
* Boston, MA 02111-1307, USA.
|
|
Packit |
98cdb6 |
*/
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
#include "config.h"
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
#include <string.h>
|
|
Packit |
98cdb6 |
#include <gtk/gtk.h>
|
|
Packit |
98cdb6 |
#include "gailpaned.h"
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void gail_paned_class_init (GailPanedClass *klass);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void gail_paned_init (GailPaned *paned);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void gail_paned_real_initialize (AtkObject *obj,
|
|
Packit |
98cdb6 |
gpointer data);
|
|
Packit |
98cdb6 |
static void gail_paned_size_allocate_gtk (GtkWidget *widget,
|
|
Packit |
98cdb6 |
GtkAllocation *allocation);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static AtkStateSet* gail_paned_ref_state_set (AtkObject *accessible);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void atk_value_interface_init (AtkValueIface *iface);
|
|
Packit |
98cdb6 |
static void gail_paned_get_current_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value);
|
|
Packit |
98cdb6 |
static void gail_paned_get_maximum_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value);
|
|
Packit |
98cdb6 |
static void gail_paned_get_minimum_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value);
|
|
Packit |
98cdb6 |
static gboolean gail_paned_set_current_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
const GValue *value);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
G_DEFINE_TYPE_WITH_CODE (GailPaned, gail_paned, GAIL_TYPE_CONTAINER,
|
|
Packit |
98cdb6 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_class_init (GailPanedClass *klass)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
class->ref_state_set = gail_paned_ref_state_set;
|
|
Packit |
98cdb6 |
class->initialize = gail_paned_real_initialize;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_init (GailPaned *paned)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static AtkStateSet*
|
|
Packit |
98cdb6 |
gail_paned_ref_state_set (AtkObject *accessible)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
AtkStateSet *state_set;
|
|
Packit |
98cdb6 |
GtkWidget *widget;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
state_set = ATK_OBJECT_CLASS (gail_paned_parent_class)->ref_state_set (accessible);
|
|
Packit |
98cdb6 |
widget = GTK_ACCESSIBLE (accessible)->widget;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
if (widget == NULL)
|
|
Packit |
98cdb6 |
return state_set;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
if (GTK_IS_VPANED (widget))
|
|
Packit |
98cdb6 |
atk_state_set_add_state (state_set, ATK_STATE_VERTICAL);
|
|
Packit |
98cdb6 |
else if (GTK_IS_HPANED (widget))
|
|
Packit |
98cdb6 |
atk_state_set_add_state (state_set, ATK_STATE_HORIZONTAL);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
return state_set;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_real_initialize (AtkObject *obj,
|
|
Packit |
98cdb6 |
gpointer data)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
ATK_OBJECT_CLASS (gail_paned_parent_class)->initialize (obj, data);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
g_signal_connect (data,
|
|
Packit |
98cdb6 |
"size_allocate",
|
|
Packit |
98cdb6 |
G_CALLBACK (gail_paned_size_allocate_gtk),
|
|
Packit |
98cdb6 |
NULL);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
obj->role = ATK_ROLE_SPLIT_PANE;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_size_allocate_gtk (GtkWidget *widget,
|
|
Packit |
98cdb6 |
GtkAllocation *allocation)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
AtkObject *obj = gtk_widget_get_accessible (widget);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
g_object_notify (G_OBJECT (obj), "accessible-value");
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
atk_value_interface_init (AtkValueIface *iface)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
iface->get_current_value = gail_paned_get_current_value;
|
|
Packit |
98cdb6 |
iface->get_maximum_value = gail_paned_get_maximum_value;
|
|
Packit |
98cdb6 |
iface->get_minimum_value = gail_paned_get_minimum_value;
|
|
Packit |
98cdb6 |
iface->set_current_value = gail_paned_set_current_value;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_get_current_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkWidget* widget;
|
|
Packit |
98cdb6 |
gint current_value;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
widget = GTK_ACCESSIBLE (obj)->widget;
|
|
Packit |
98cdb6 |
if (widget == NULL)
|
|
Packit |
98cdb6 |
/* State is defunct */
|
|
Packit |
98cdb6 |
return;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
current_value = gtk_paned_get_position (GTK_PANED (widget));
|
|
Packit |
98cdb6 |
memset (value, 0, sizeof (GValue));
|
|
Packit |
98cdb6 |
g_value_init (value, G_TYPE_INT);
|
|
Packit |
98cdb6 |
g_value_set_int (value,current_value);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_get_maximum_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkWidget* widget;
|
|
Packit |
98cdb6 |
gint maximum_value;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
widget = GTK_ACCESSIBLE (obj)->widget;
|
|
Packit |
98cdb6 |
if (widget == NULL)
|
|
Packit |
98cdb6 |
/* State is defunct */
|
|
Packit |
98cdb6 |
return;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
maximum_value = GTK_PANED (widget)->max_position;
|
|
Packit |
98cdb6 |
memset (value, 0, sizeof (GValue));
|
|
Packit |
98cdb6 |
g_value_init (value, G_TYPE_INT);
|
|
Packit |
98cdb6 |
g_value_set_int (value, maximum_value);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static void
|
|
Packit |
98cdb6 |
gail_paned_get_minimum_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
GValue *value)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkWidget* widget;
|
|
Packit |
98cdb6 |
gint minimum_value;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
widget = GTK_ACCESSIBLE (obj)->widget;
|
|
Packit |
98cdb6 |
if (widget == NULL)
|
|
Packit |
98cdb6 |
/* State is defunct */
|
|
Packit |
98cdb6 |
return;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
minimum_value = GTK_PANED (widget)->min_position;
|
|
Packit |
98cdb6 |
memset (value, 0, sizeof (GValue));
|
|
Packit |
98cdb6 |
g_value_init (value, G_TYPE_INT);
|
|
Packit |
98cdb6 |
g_value_set_int (value, minimum_value);
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
/*
|
|
Packit |
98cdb6 |
* Calling atk_value_set_current_value() is no guarantee that the value is
|
|
Packit |
98cdb6 |
* acceptable; it is necessary to listen for accessible-value signals
|
|
Packit |
98cdb6 |
* and check whether the current value has been changed or check what the
|
|
Packit |
98cdb6 |
* maximum and minimum values are.
|
|
Packit |
98cdb6 |
*/
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
static gboolean
|
|
Packit |
98cdb6 |
gail_paned_set_current_value (AtkValue *obj,
|
|
Packit |
98cdb6 |
const GValue *value)
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
GtkWidget* widget;
|
|
Packit |
98cdb6 |
gint new_value;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
widget = GTK_ACCESSIBLE (obj)->widget;
|
|
Packit |
98cdb6 |
if (widget == NULL)
|
|
Packit |
98cdb6 |
/* State is defunct */
|
|
Packit |
98cdb6 |
return FALSE;
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
if (G_VALUE_HOLDS_INT (value))
|
|
Packit |
98cdb6 |
{
|
|
Packit |
98cdb6 |
new_value = g_value_get_int (value);
|
|
Packit |
98cdb6 |
gtk_paned_set_position (GTK_PANED (widget), new_value);
|
|
Packit |
98cdb6 |
|
|
Packit |
98cdb6 |
return TRUE;
|
|
Packit |
98cdb6 |
}
|
|
Packit |
98cdb6 |
else
|
|
Packit |
98cdb6 |
return FALSE;
|
|
Packit |
98cdb6 |
}
|