2012-10-30 14:21:44 +00:00
|
|
|
/* GTK+ - accessibility implementations
|
2011-06-29 03:13:27 +00:00
|
|
|
* Copyright 2001, 2002, 2003 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2011-06-29 03:13:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gtkscrolledwindowaccessible.h"
|
|
|
|
|
|
|
|
|
2020-05-02 05:48:52 +00:00
|
|
|
G_DEFINE_TYPE (GtkScrolledWindowAccessible, gtk_scrolled_window_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
visibility_changed (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2011-07-10 04:02:02 +00:00
|
|
|
if (!g_strcmp0 (pspec->name, "visible"))
|
2011-06-29 03:13:27 +00:00
|
|
|
{
|
|
|
|
gint index;
|
|
|
|
gint n_children;
|
|
|
|
gboolean child_added = FALSE;
|
|
|
|
AtkObject *child;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkScrolledWindow *scrolled_window;
|
|
|
|
GtkWidget *hscrollbar, *vscrollbar;
|
|
|
|
GtkAccessible *accessible = GTK_ACCESSIBLE (user_data);
|
|
|
|
|
|
|
|
widget = gtk_accessible_get_widget (user_data);
|
|
|
|
if (widget == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
2020-05-02 05:48:52 +00:00
|
|
|
index = n_children = 1;
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
hscrollbar = gtk_scrolled_window_get_hscrollbar (scrolled_window);
|
|
|
|
vscrollbar = gtk_scrolled_window_get_vscrollbar (scrolled_window);
|
|
|
|
|
|
|
|
if ((gpointer) object == (gpointer) (hscrollbar))
|
|
|
|
{
|
|
|
|
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
|
|
|
|
child_added = TRUE;
|
|
|
|
|
|
|
|
child = gtk_widget_get_accessible (hscrollbar);
|
|
|
|
}
|
|
|
|
else if ((gpointer) object == (gpointer) (vscrollbar))
|
|
|
|
{
|
|
|
|
if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
|
|
|
|
child_added = TRUE;
|
|
|
|
|
|
|
|
child = gtk_widget_get_accessible (vscrollbar);
|
|
|
|
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
|
|
|
|
index = n_children + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child_added)
|
2011-07-17 22:47:19 +00:00
|
|
|
g_signal_emit_by_name (accessible, "children-changed::add", index, child, NULL);
|
2011-06-29 03:13:27 +00:00
|
|
|
else
|
2011-07-17 22:47:19 +00:00
|
|
|
g_signal_emit_by_name (accessible, "children-changed::remove", index, child, NULL);
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2011-07-09 20:32:40 +00:00
|
|
|
|
2011-06-29 03:13:27 +00:00
|
|
|
static void
|
|
|
|
gtk_scrolled_window_accessible_initialize (AtkObject *obj,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkScrolledWindow *window;
|
|
|
|
|
2012-12-27 06:04:46 +00:00
|
|
|
ATK_OBJECT_CLASS (gtk_scrolled_window_accessible_parent_class)->initialize (obj, data);
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
window = GTK_SCROLLED_WINDOW (data);
|
|
|
|
|
2017-10-19 18:16:43 +00:00
|
|
|
g_signal_connect_object (gtk_scrolled_window_get_hscrollbar (window), "notify::visible",
|
|
|
|
G_CALLBACK (visibility_changed),
|
|
|
|
obj, 0);
|
|
|
|
g_signal_connect_object (gtk_scrolled_window_get_vscrollbar (window), "notify::visible",
|
|
|
|
G_CALLBACK (visibility_changed),
|
|
|
|
obj, 0);
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
obj->role = ATK_ROLE_SCROLL_PANE;
|
|
|
|
}
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
static int
|
2011-06-29 03:13:27 +00:00
|
|
|
gtk_scrolled_window_accessible_get_n_children (AtkObject *object)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkScrolledWindow *scrolled_window;
|
|
|
|
gint n_children;
|
|
|
|
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (object));
|
|
|
|
if (widget == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
n_children = 0;
|
|
|
|
if (gtk_scrolled_window_get_child (scrolled_window))
|
|
|
|
n_children++;
|
2011-06-29 03:13:27 +00:00
|
|
|
if (gtk_scrolled_window_get_hscrollbar (scrolled_window))
|
|
|
|
n_children++;
|
|
|
|
if (gtk_scrolled_window_get_vscrollbar (scrolled_window))
|
|
|
|
n_children++;
|
|
|
|
|
|
|
|
return n_children;
|
|
|
|
}
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
gtk_scrolled_window_accessible_ref_child (AtkObject *obj,
|
|
|
|
gint child)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkScrolledWindow *scrolled_window;
|
|
|
|
GtkWidget *hscrollbar, *vscrollbar;
|
2020-05-09 12:26:52 +00:00
|
|
|
GtkWidget *c;
|
|
|
|
GtkWidget *chosen = NULL;
|
2011-06-29 03:13:27 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (child >= 0, NULL);
|
|
|
|
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
|
|
|
if (widget == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
scrolled_window = GTK_SCROLLED_WINDOW (widget);
|
2020-05-09 12:26:52 +00:00
|
|
|
c = gtk_scrolled_window_get_child (scrolled_window);
|
2011-06-29 03:13:27 +00:00
|
|
|
hscrollbar = gtk_scrolled_window_get_hscrollbar (scrolled_window);
|
|
|
|
vscrollbar = gtk_scrolled_window_get_vscrollbar (scrolled_window);
|
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
if (child == 2)
|
|
|
|
chosen = vscrollbar;
|
|
|
|
else if (child == 1)
|
|
|
|
chosen = c ? hscrollbar : vscrollbar;
|
|
|
|
else if (child == 0)
|
|
|
|
chosen = c ? c : (hscrollbar ? hscrollbar : vscrollbar);
|
2011-06-29 03:13:27 +00:00
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
if (chosen)
|
|
|
|
return g_object_ref (gtk_widget_get_accessible (chosen));
|
2011-06-29 03:13:27 +00:00
|
|
|
|
2020-05-09 12:26:52 +00:00
|
|
|
return NULL;
|
2011-06-29 03:13:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_scrolled_window_accessible_class_init (GtkScrolledWindowAccessibleClass *klass)
|
2011-06-29 03:13:27 +00:00
|
|
|
{
|
|
|
|
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
class->get_n_children = gtk_scrolled_window_accessible_get_n_children;
|
|
|
|
class->ref_child = gtk_scrolled_window_accessible_ref_child;
|
|
|
|
class->initialize = gtk_scrolled_window_accessible_initialize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-27 06:04:46 +00:00
|
|
|
gtk_scrolled_window_accessible_init (GtkScrolledWindowAccessible *window)
|
2011-06-29 03:13:27 +00:00
|
|
|
{
|
|
|
|
}
|