2007-12-18 13:51:12 +00:00
|
|
|
/* GAIL - The GNOME Accessibility Implementation Library
|
|
|
|
* Copyright 2001 Sun Microsystems Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2007-12-23 12:27:33 +00:00
|
|
|
|
2007-12-18 13:51:12 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gailscrollbar.h"
|
|
|
|
|
2007-12-23 12:24:59 +00:00
|
|
|
static void gail_scrollbar_class_init (GailScrollbarClass *klass);
|
|
|
|
static void gail_scrollbar_init (GailScrollbar *accessible);
|
2007-12-25 09:29:46 +00:00
|
|
|
static void gail_scrollbar_initialize (AtkObject *accessible,
|
|
|
|
gpointer data);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2007-12-23 12:24:59 +00:00
|
|
|
static gint gail_scrollbar_get_index_in_parent (AtkObject *accessible);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2007-12-23 12:24:59 +00:00
|
|
|
G_DEFINE_TYPE (GailScrollbar, gail_scrollbar, GAIL_TYPE_RANGE)
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gail_scrollbar_class_init (GailScrollbarClass *klass)
|
|
|
|
{
|
|
|
|
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
|
|
|
|
2007-12-25 09:29:46 +00:00
|
|
|
class->initialize = gail_scrollbar_initialize;
|
2007-12-18 13:51:12 +00:00
|
|
|
class->get_index_in_parent = gail_scrollbar_get_index_in_parent;
|
2007-12-23 12:24:59 +00:00
|
|
|
}
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2007-12-23 12:24:59 +00:00
|
|
|
static void
|
|
|
|
gail_scrollbar_init (GailScrollbar *accessible)
|
|
|
|
{
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
|
|
|
|
2007-12-25 09:29:46 +00:00
|
|
|
static void
|
|
|
|
gail_scrollbar_initialize (AtkObject *accessible,
|
|
|
|
gpointer data)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2007-12-25 09:29:46 +00:00
|
|
|
ATK_OBJECT_CLASS (gail_scrollbar_parent_class)->initialize (accessible, data);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
accessible->role = ATK_ROLE_SCROLL_BAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
gail_scrollbar_get_index_in_parent (AtkObject *accessible)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2010-08-15 17:45:13 +00:00
|
|
|
GtkWidget *parent;
|
2011-06-09 04:16:23 +00:00
|
|
|
GtkWidget *child;
|
2007-12-18 13:51:12 +00:00
|
|
|
GtkScrolledWindow *scrolled_window;
|
2011-06-09 04:16:23 +00:00
|
|
|
gint id;
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
2007-12-18 13:51:12 +00:00
|
|
|
|
|
|
|
if (widget == NULL)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* State is defunct
|
|
|
|
*/
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
g_return_val_if_fail (GTK_IS_SCROLLBAR (widget), -1);
|
|
|
|
|
2010-08-15 17:45:13 +00:00
|
|
|
parent = gtk_widget_get_parent (widget);
|
|
|
|
if (!GTK_IS_SCROLLED_WINDOW (parent))
|
2007-12-23 12:24:59 +00:00
|
|
|
return ATK_OBJECT_CLASS (gail_scrollbar_parent_class)->get_index_in_parent (accessible);
|
2007-12-18 13:51:12 +00:00
|
|
|
|
2010-08-15 17:45:13 +00:00
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (parent);
|
2011-06-09 04:16:23 +00:00
|
|
|
id = 0;
|
|
|
|
child = gtk_bin_get_child (GTK_BIN (scrolled_window));
|
|
|
|
if (child)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-09 04:16:23 +00:00
|
|
|
if (widget == child)
|
|
|
|
return id;
|
|
|
|
id++;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
2011-06-09 04:16:23 +00:00
|
|
|
|
|
|
|
child = gtk_scrolled_window_get_hscrollbar (scrolled_window);
|
|
|
|
if (child)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-09 04:16:23 +00:00
|
|
|
if (widget == child)
|
|
|
|
return id;
|
|
|
|
id++;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
2011-06-09 04:16:23 +00:00
|
|
|
child = gtk_scrolled_window_get_vscrollbar (scrolled_window);
|
|
|
|
if (child)
|
2007-12-18 13:51:12 +00:00
|
|
|
{
|
2011-06-09 04:16:23 +00:00
|
|
|
if (widget == child)
|
|
|
|
return id;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|
2011-06-09 04:16:23 +00:00
|
|
|
|
|
|
|
return -1;
|
2007-12-18 13:51:12 +00:00
|
|
|
}
|