diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 61866e81f8..d3e785c286 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -481,6 +481,7 @@ gtk_private_h_sources = \ gtkimcontextsimpleseqs.h \ gtkintl.h \ gtkkeyhash.h \ + gtklockbuttonprivate.h \ gtkmenubuttonprivate.h \ gtkmenuprivate.h \ gtkmenuitemprivate.h \ diff --git a/gtk/a11y/gtklockbuttonaccessible.c b/gtk/a11y/gtklockbuttonaccessible.c index ee1cccd434..a24e3109b1 100644 --- a/gtk/a11y/gtklockbuttonaccessible.c +++ b/gtk/a11y/gtklockbuttonaccessible.c @@ -17,15 +17,29 @@ #include "config.h" -#include -#include +#include "gtk/gtklockbuttonprivate.h" #include "gtklockbuttonaccessible.h" G_DEFINE_TYPE (GtkLockButtonAccessible, _gtk_lock_button_accessible, GTK_TYPE_BUTTON_ACCESSIBLE) +static const gchar * +gtk_lock_button_accessible_get_name (AtkObject *obj) +{ + GtkLockButton *lockbutton; + + lockbutton = GTK_LOCK_BUTTON (gtk_accessible_get_widget (GTK_ACCESSIBLE (obj))); + if (lockbutton == NULL) + return NULL; + + return _gtk_lock_button_get_current_text (lockbutton); +} + static void _gtk_lock_button_accessible_class_init (GtkLockButtonAccessibleClass *klass) { + AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass); + + atk_object_class->get_name = gtk_lock_button_accessible_get_name; } static void diff --git a/gtk/gtklockbutton.c b/gtk/gtklockbutton.c index 6fc45367b8..9cb828b843 100644 --- a/gtk/gtklockbutton.c +++ b/gtk/gtklockbutton.c @@ -18,7 +18,7 @@ #include "config.h" -#include "gtklockbutton.h" +#include "gtklockbuttonprivate.h" #include "gtkbox.h" #include "gtkimage.h" #include "gtklabel.h" @@ -564,3 +564,19 @@ gtk_lock_button_set_permission (GtkLockButton *button, g_object_notify (G_OBJECT (button), "permission"); } } + +const char * +_gtk_lock_button_get_current_text (GtkLockButton *button) +{ + GtkLockButtonPrivate *priv; + + g_return_val_if_fail (GTK_IS_LOCK_BUTTON (button), NULL); + + priv = button->priv; + + if (gtk_widget_get_visible (priv->label_lock)) + return gtk_label_get_text (GTK_LABEL (priv->label_lock)); + else + return gtk_label_get_text (GTK_LABEL (priv->label_unlock)); +} + diff --git a/gtk/gtklockbuttonprivate.h b/gtk/gtklockbuttonprivate.h new file mode 100644 index 0000000000..f029bf8b67 --- /dev/null +++ b/gtk/gtklockbuttonprivate.h @@ -0,0 +1,30 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2010 Red Hat, Inc. + * Author: Matthias Clasen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library. If not, see . + */ + +#ifndef __GTK_LOCK_BUTTON_PRIVATE_H__ +#define __GTK_LOCK_BUTTON_PRIVATE_H__ + +#include "gtklockbutton.h" + +G_BEGIN_DECLS + +const char * _gtk_lock_button_get_current_text (GtkLockButton *button); + +G_END_DECLS + +#endif /* __GTK_LOCK_BUTTON_PRIVATE_H__ */