* 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, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
-#include "gtklockbutton.h"
+#include "gtklockbuttonprivate.h"
#include "gtkbox.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtksizegroup.h"
#include "gtkintl.h"
+#include "a11y/gtklockbuttonaccessibleprivate.h"
/**
* SECTION:gtklockbutton
* preference dialogs to allow users to obtain and revoke authorizations
* needed to operate the controls. The required authorization is represented
* by a #GPermission object. Concrete implementations of #GPermission may use
- * PolicyKit or some other authorization framework.
+ * PolicyKit or some other authorization framework. To obtain a PolicyKit-based
+ * #GPermission, use polkit_permission_new().
*
- * If the user lacks the authorization but authorization can be obtained
- * through authentication, the widget looks like this
+ * If the user is not currently allowed to perform the action, but can obtain
+ * the permission, the widget looks like this
* <informalexample><inlinegraphic fileref="lockbutton-locked.png"></inlinegraphic></informalexample>
- * and the user can click the button to obtain the authorization. Depending
+ * and the user can click the button to request the permission. Depending
* on the platform, this may pop up an authentication dialog or ask the user
- * to authenticate in some other way. Once authorization is obtained, the
- * widget changes to this
+ * to authenticate in some other way. Once the user has obtained the permission,
+ * the widget changes to this
* <informalexample><inlinegraphic fileref="lockbutton-unlocked.png"></inlinegraphic></informalexample>
- * and the authorization can be dropped by clicking the button. If the user
- * is not able to obtain authorization at all, the widget looks like this
+ * and the permission can be dropped again by clicking the button. If the user
+ * is not able to obtain the permission at all, the widget looks like this
* <informalexample><inlinegraphic fileref="lockbutton-sorry.png"></inlinegraphic></informalexample>
- * If the user is authorized and cannot drop the authorization, the button
- * is hidden.
+ * If the user has the permission and cannot drop it, the button is hidden.
*
* The text (and tooltips) that are shown in the various cases can be adjusted
* with the #GtkLockButton:text-lock, #GtkLockButton:text-unlock,
case PROP_TEXT_LOCK:
gtk_label_set_text (GTK_LABEL (priv->label_lock), g_value_get_string (value));
+ _gtk_lock_button_accessible_name_changed (button);
break;
case PROP_TEXT_UNLOCK:
gtk_label_set_text (GTK_LABEL (priv->label_unlock), g_value_get_string (value));
+ _gtk_lock_button_accessible_name_changed (button);
break;
case PROP_TOOLTIP_LOCK:
gtk_lock_button_class_init (GtkLockButtonClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
gobject_class->finalize = gtk_lock_button_finalize;
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_LOCK_BUTTON_ACCESSIBLE);
}
static void
g_assert_not_reached ();
}
- gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon, GTK_ICON_SIZE_BUTTON);
- gtk_widget_set_visible (priv->label_lock, allowed);
- gtk_widget_set_visible (priv->label_unlock, !allowed);
+ gtk_image_set_from_gicon (GTK_IMAGE (priv->image), icon, GTK_ICON_SIZE_MENU);
+ if (gtk_widget_get_visible (priv->label_lock) != allowed)
+ {
+ gtk_widget_set_visible (priv->label_lock, allowed);
+ gtk_widget_set_visible (priv->label_unlock, !allowed);
+ _gtk_lock_button_accessible_name_changed (button);
+ }
gtk_widget_set_tooltip_markup (GTK_WIDGET (button), tooltip);
gtk_widget_set_sensitive (GTK_WIDGET (button), sensitive);
gtk_widget_set_visible (GTK_WIDGET (button), visible);
*
* Obtains the #GPermission object that controls @button.
*
- * Returns: the #GPermission of @button
+ * Returns: (transfer none): the #GPermission of @button
*
* Since: 3.2
*/
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));
+}
+