mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 21:21:21 +00:00
a11y: Simplify GtkProgressBarAccessible
Drop the GtkWidgetAccessibleClass.notify_gtk and the AtkObjectClass.initialize overrides: they don't do anything relevant. Instead, have GtkProgressBar update the accessible state when the fraction changes.
This commit is contained in:
parent
f95d54a13d
commit
ac3f0df083
@ -21,52 +21,28 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtkprogressbaraccessible.h"
|
||||
|
||||
#include "gtkprogressbaraccessibleprivate.h"
|
||||
|
||||
static void atk_value_interface_init (AtkValueIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkProgressBarAccessible, gtk_progress_bar_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
|
||||
G_IMPLEMENT_INTERFACE (ATK_TYPE_VALUE, atk_value_interface_init))
|
||||
|
||||
static void
|
||||
gtk_progress_bar_accessible_initialize (AtkObject *obj,
|
||||
gpointer data)
|
||||
void
|
||||
gtk_progress_bar_accessible_update_value (GtkProgressBarAccessible *self)
|
||||
{
|
||||
ATK_OBJECT_CLASS (gtk_progress_bar_accessible_parent_class)->initialize (obj, data);
|
||||
|
||||
obj->role = ATK_ROLE_PROGRESS_BAR;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_accessible_notify_gtk (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (obj);
|
||||
AtkObject *accessible;
|
||||
|
||||
accessible = gtk_widget_get_accessible (widget);
|
||||
|
||||
if (strcmp (pspec->name, "fraction") == 0)
|
||||
g_object_notify (G_OBJECT (accessible), "accessible-value");
|
||||
else
|
||||
GTK_WIDGET_ACCESSIBLE_CLASS (gtk_progress_bar_accessible_parent_class)->notify_gtk (obj, pspec);
|
||||
g_object_notify (G_OBJECT (self), "accessible-value");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_accessible_class_init (GtkProgressBarAccessibleClass *klass)
|
||||
{
|
||||
AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
|
||||
GtkWidgetAccessibleClass *widget_class = (GtkWidgetAccessibleClass*)klass;
|
||||
|
||||
widget_class->notify_gtk = gtk_progress_bar_accessible_notify_gtk;
|
||||
|
||||
class->initialize = gtk_progress_bar_accessible_initialize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_accessible_init (GtkProgressBarAccessible *bar)
|
||||
gtk_progress_bar_accessible_init (GtkProgressBarAccessible *self)
|
||||
{
|
||||
ATK_OBJECT (self)->role = ATK_ROLE_PROGRESS_BAR;
|
||||
}
|
||||
|
||||
static void
|
||||
|
29
gtk/a11y/gtkprogressbaraccessibleprivate.h
Normal file
29
gtk/a11y/gtkprogressbaraccessibleprivate.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* gtkprogressbaraccessibleprivate.h: Private GtkProgressBarAccessible API
|
||||
*
|
||||
* Copyright 2020 GNOME Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* 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.1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkprogressbaraccessible.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gtk_progress_bar_accessible_update_value (GtkProgressBarAccessible *self);
|
||||
|
||||
G_END_DECLS
|
@ -39,7 +39,7 @@
|
||||
#include "gtkstylecontextprivate.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
#include "a11y/gtkprogressbaraccessible.h"
|
||||
#include "a11y/gtkprogressbaraccessibleprivate.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -732,6 +732,14 @@ gtk_progress_bar_set_fraction (GtkProgressBar *pbar,
|
||||
gtk_widget_queue_allocate (pbar->trough_widget);
|
||||
update_fraction_classes (pbar);
|
||||
|
||||
{
|
||||
AtkObject *accessible =
|
||||
_gtk_widget_peek_accessible (GTK_WIDGET (pbar));
|
||||
|
||||
if (accessible != NULL)
|
||||
gtk_progress_bar_accessible_update_value (GTK_PROGRESS_BAR_ACCESSIBLE (accessible));
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (pbar), progress_props[PROP_FRACTION]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user