[PolicyKit-gnome] Add libpolkit-gtk-1 with a PolkitLockButton widget



commit 6d3bdb0ac349d29202d23e6969e2ac2f1d154372
Author: David Zeuthen <davidz redhat com>
Date:   Sun Jul 26 22:14:53 2009 -0400

    Add libpolkit-gtk-1 with a PolkitLockButton widget

 Makefile.am                                |    2 +-
 configure.ac                               |    9 +-
 docs/Makefile.am                           |   84 +++
 docs/polkit-gtk-1-docs.xml                 |   74 +++
 docs/polkit-gtk-1-sections.txt             |   22 +
 docs/polkit-gtk-1.types                    |    1 +
 docs/polkit-lock-button-locked.png         |  Bin 0 -> 2430 bytes
 docs/polkit-lock-button-not-authorized.png |  Bin 0 -> 2652 bytes
 docs/polkit-lock-button-unlocked.png       |  Bin 0 -> 2642 bytes
 docs/version.xml.in                        |    1 +
 po/POTFILES.in                             |    1 +
 po/POTFILES.skip                           |    2 +-
 polkitgtk/Makefile.am                      |   75 +++
 polkitgtk/example.c                        |   85 +++
 polkitgtk/polkit-gtk-1.pc.in               |   11 +
 polkitgtk/polkitgtk.h                      |   32 +
 polkitgtk/polkitgtktypes.h                 |   34 ++
 polkitgtk/polkitlockbutton.c               |  865 ++++++++++++++++++++++++++++
 polkitgtk/polkitlockbutton.h               |  103 ++++
 19 files changed, 1398 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0697bc6..3caba08 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src po
+SUBDIRS = polkitgtk src po docs
 
 EXTRA_DIST = \
 	autogen.sh		\
diff --git a/configure.ac b/configure.ac
index 522f71e..6b4ed6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,8 @@ AC_ISC_POSIX
 AC_HEADER_STDC
 AC_PROG_LIBTOOL
 
+GTK_DOC_CHECK([1.3])
+
 #### gcc warning flags
 
 if test "x$GCC" = "xyes"; then
@@ -159,8 +161,12 @@ AC_SUBST([AM_LDFLAGS])
 
 AC_CONFIG_FILES([
 Makefile
-src/Makefile
 po/Makefile.in
+polkitgtk/Makefile
+polkitgtk/polkit-gtk-1.pc
+src/Makefile
+docs/version.xml
+docs/Makefile
 ])
 
 AC_OUTPUT
@@ -183,4 +189,5 @@ echo "
         cppflags:                   ${CPPFLAGS}
 
         Maintainer mode:            ${USE_MAINTAINER_MODE}
+        Building api docs:          ${enable_gtk_doc}
 "
diff --git a/docs/Makefile.am b/docs/Makefile.am
new file mode 100644
index 0000000..cab0221
--- /dev/null
+++ b/docs/Makefile.am
@@ -0,0 +1,84 @@
+
+NULL =
+
+AUTOMAKE_OPTIONS = 1.7
+
+# The name of the module.
+DOC_MODULE=polkit-gtk-1
+
+# The top-level SGML file.
+DOC_MAIN_SGML_FILE=polkit-gtk-1-docs.xml
+
+# Extra options to supply to gtkdoc-scan
+SCAN_OPTIONS=--ignore-headers=config.h
+
+# The directory containing the source code. Relative to $(srcdir)
+DOC_SOURCE_DIR=../polkitgtk
+
+# Used for dependencies
+HFILE_GLOB=$(top_srcdir)/polkitgtk/*.h
+CFILE_GLOB=$(top_srcdir)/polkitgtk/*.c
+
+# Headers to ignore
+IGNORE_HFILES= \
+	$(NULL)
+
+# CFLAGS and LDFLAGS for compiling scan program. Only needed
+# if $(DOC_MODULE).types is non-empty.
+INCLUDES = \
+	$(POLKIT_GOBJECT_CFLAGS)				\
+	$(GTK_CFLAGS)						\
+	-I$(top_srcdir)/polkitgtk 				\
+	$(NULL)
+
+GTKDOC_LIBS = \
+	$(POLKIT_GOBJECT_LIBS)					\
+	$(GTK_LIBS)						\
+	$(top_builddir)/polkitgtk/libpolkit-gtk-1.la		\
+	$(NULL)
+
+# Extra options to supply to gtkdoc-mkdb
+MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=polkit
+
+# Extra options to supply to gtkdoc-mktmpl
+MKTMPL_OPTIONS=
+
+# Non-autogenerated SGML files to be included in $(DOC_MAIN_SGML_FILE)
+content_files =  			    			\
+	version.xml			    			\
+	$(NULL)
+
+# Images to copy into HTML directory
+HTML_IMAGES = 							\
+	polkit-lock-button-locked.png				\
+	polkit-lock-button-not-authorized.png			\
+	polkit-lock-button-unlocked.png				\
+	$(NULL)
+
+# Extra options to supply to gtkdoc-fixref
+FIXXREF_OPTIONS=
+
+if ENABLE_GTK_DOC
+include $(top_srcdir)/gtk-doc.make
+else
+CLEANFILES =
+endif
+
+CLEANFILES +=   *~				\
+		polkit-gtk-1-scan.*		\
+		polkit-gtk-1.args		\
+		polkit-gtk-1.hierarchy		\
+		polkit-gtk-1.interfaces		\
+		polkit-gtk-1.prerequisites	\
+		polkit-gtk-1.signals		\
+		*.bak				\
+		polkit-gtk-1-decl-list.txt	\
+		polkit-gtk-1-decl.txt		\
+		polkit-gtk-1-overrides.txt	\
+		polkit-gtk-1-undeclared.txt	\
+		polkit-gtk-1-undocumented.txt	\
+		*.stamp				\
+		version.xml			\
+		-rf html xml			\
+		$(NULL)
+
diff --git a/docs/polkit-gtk-1-docs.xml b/docs/polkit-gtk-1-docs.xml
new file mode 100644
index 0000000..1db29c1
--- /dev/null
+++ b/docs/polkit-gtk-1-docs.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY version SYSTEM "version.xml">
+]>
+<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude";>
+  <bookinfo>
+    <title>PolicyKit-GTK+ Reference Manual</title>
+    <releaseinfo>Version &version;</releaseinfo>
+    <authorgroup>
+      <author>
+        <firstname>David</firstname>
+        <surname>Zeuthen</surname>
+        <affiliation>
+          <address>
+            <email>davidz redhat com</email>
+          </address>
+        </affiliation>
+      </author>
+    </authorgroup>
+
+    <copyright>
+      <year>2008-2009</year>
+      <holder>The PolicyKit Authors</holder>
+    </copyright>
+
+    <legalnotice id="polkit-legal-notice">
+      <para>
+        Permission is granted to copy, distribute and/or modify this
+        document under the terms of the <citetitle>GNU Free
+        Documentation License</citetitle>, Version 1.1 or any later
+        version published by the Free Software Foundation with no
+        Invariant Sections, no Front-Cover Texts, and no Back-Cover
+        Texts. You may obtain a copy of the <citetitle>GNU Free
+        Documentation License</citetitle> from the Free Software
+        Foundation by visiting <ulink type="http"
+        url="http://www.fsf.org";>their Web site</ulink> or by writing
+        to:
+
+        <address>
+          The Free Software Foundation, Inc.,
+          <street>59 Temple Place</street> - Suite 330,
+          <city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
+          <country>USA</country>
+        </address>
+      </para>
+
+      <para>
+        Many of the names used by companies to distinguish their
+        products and services are claimed as trademarks. Where those
+        names appear in any GNOME documentation, and those
+        trademarks are made aware to the members of the
+        GNOME Documentation Project, the names have been
+        printed in caps or initial caps.
+      </para>
+    </legalnotice>
+  </bookinfo>
+
+  <part id="ref-gtk-api">
+    <title>API Reference</title>
+    <xi:include href="xml/polkitlockbutton.xml"/>
+  </part>
+
+
+  <chapter id="polkit-gtk-hierarchy">
+    <title>Object Hierarchy</title>
+      <xi:include href="xml/tree_index.sgml"/>
+  </chapter>
+
+  <index id="polkit-gtk-index">
+    <title>Index</title>
+  </index>
+
+</book>
diff --git a/docs/polkit-gtk-1-sections.txt b/docs/polkit-gtk-1-sections.txt
new file mode 100644
index 0000000..e8597e5
--- /dev/null
+++ b/docs/polkit-gtk-1-sections.txt
@@ -0,0 +1,22 @@
+<SECTION>
+<FILE>polkitlockbutton</FILE>
+PolkitLockButton
+PolkitLockButtonClass
+polkit_lock_button_new
+polkit_lock_button_get_is_authorized
+polkit_lock_button_get_is_authenticating
+polkit_lock_button_get_is_visible
+polkit_lock_button_get_can_obtain
+polkit_lock_button_set_unlock_text
+polkit_lock_button_set_lock_text
+polkit_lock_button_set_not_authorized_text
+<SUBSECTION Standard>
+PolkitLockButtonPrivate
+POLKIT_LOCK_BUTTON
+POLKIT_IS_LOCK_BUTTON
+POLKIT_TYPE_LOCK_BUTTON
+polkit_lock_button_get_type
+POLKIT_LOCK_BUTTON_CLASS
+POLKIT_IS_LOCK_BUTTON_CLASS
+POLKIT_LOCK_BUTTON_GET_CLASS
+</SECTION>
diff --git a/docs/polkit-gtk-1.types b/docs/polkit-gtk-1.types
new file mode 100644
index 0000000..1d1d59c
--- /dev/null
+++ b/docs/polkit-gtk-1.types
@@ -0,0 +1 @@
+polkit_lock_button_get_type
diff --git a/docs/polkit-lock-button-locked.png b/docs/polkit-lock-button-locked.png
new file mode 100644
index 0000000..733cec2
Binary files /dev/null and b/docs/polkit-lock-button-locked.png differ
diff --git a/docs/polkit-lock-button-not-authorized.png b/docs/polkit-lock-button-not-authorized.png
new file mode 100644
index 0000000..8cd4156
Binary files /dev/null and b/docs/polkit-lock-button-not-authorized.png differ
diff --git a/docs/polkit-lock-button-unlocked.png b/docs/polkit-lock-button-unlocked.png
new file mode 100644
index 0000000..cfeec4a
Binary files /dev/null and b/docs/polkit-lock-button-unlocked.png differ
diff --git a/docs/version.xml.in b/docs/version.xml.in
new file mode 100644
index 0000000..d78bda9
--- /dev/null
+++ b/docs/version.xml.in
@@ -0,0 +1 @@
+ VERSION@
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b415350..97b7131 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,7 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
+polkitgtk/polkitlockbutton.c
 src/main.c
 src/polkitgnomeauthenticationdialog.c
 src/polkitgnomeauthenticator.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 480daa6..38984bc 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1 +1 @@
-tools/polkit-gnome-authorization.c
+polkitgtk/example.c
diff --git a/polkitgtk/Makefile.am b/polkitgtk/Makefile.am
new file mode 100644
index 0000000..d8f8d20
--- /dev/null
+++ b/polkitgtk/Makefile.am
@@ -0,0 +1,75 @@
+
+NULL =
+
+lib_LTLIBRARIES=libpolkit-gtk-1.la
+
+libpolkit_gtk_1includedir=$(includedir)/polkit-gtk-1/polkitgtk
+
+libpolkit_gtk_1include_HEADERS =              				\
+	polkitgtk.h							\
+	polkitgtktypes.h						\
+	polkitlockbutton.h						\
+	$(NULL)
+
+libpolkit_gtk_1_la_SOURCES =                 	               		\
+	polkitgtk.h							\
+	polkitgtktypes.h						\
+	polkitlockbutton.h			polkitlockbutton.c	\
+	$(NULL)
+
+libpolkit_gtk_1_la_CPPFLAGS = 				\
+	-I$(top_srcdir)					\
+	-I$(top_builddir)				\
+	-I$(top_srcdir)/polkitgtk			\
+	-I$(top_builddir)/polkitgtk			\
+	-DG_LOG_DOMAIN=\"polkitgtk\"			\
+	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
+	$(DISABLE_DEPRECATED)				\
+	$(AM_CPPFLAGS)					\
+	-DPOLKIT_GTK_COMPILATION			\
+	$(NULL)
+
+libpolkit_gtk_1_la_CFLAGS = 				\
+	$(POLKIT_GOBJECT_CFLAGS)			\
+	$(GTK_CFLAGS)					\
+	$(WARN_CFLAGS)					\
+	$(AM_CFLAGS)					\
+	$(NULL)
+
+libpolkit_gtk_1_la_LIBADD = 				\
+	$(POLKIT_GOBJECT_LIBS)				\
+	$(GTK_LIBS)					\
+	$(INTLLIBS)					\
+	$(NULL)
+
+
+libpolkit_gtk_1_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+		        -export-dynamic -no-undefined -export-symbols-regex '(^polkit_.*)'
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = polkit-gtk-1.pc
+
+noinst_PROGRAMS = example
+
+example_SOURCES = example.c
+example_CFLAGS = 					\
+	-I$(top_srcdir)					\
+	-I$(top_builddir)				\
+	$(POLKIT_GOBJECT_CFLAGS)			\
+	$(GTK_CFLAGS)					\
+	$(WARN_CFLAGS)					\
+	$(AM_CFLAGS)					\
+	$(NULL)
+
+example_LDADD = 					\
+	$(POLKIT_GOBJECT_LIBS)				\
+	$(GTK_LIBS)					\
+	$(INTLLIBS)					\
+	libpolkit-gtk-1.la				\
+	$(NULL)
+
+CLEANFILES = $(BUILT_SOURCES) $(pkgconfig_DATA)
+
+clean-local :
+	rm -f *~ $(BUILT_SOURCES)
+
diff --git a/polkitgtk/example.c b/polkitgtk/example.c
new file mode 100644
index 0000000..1cedbc5
--- /dev/null
+++ b/polkitgtk/example.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2009 Red Hat, 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.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include <polkitgtk/polkitgtk.h>
+
+static void
+on_button_changed (PolkitLockButton *button,
+                   gpointer          user_data)
+{
+  GtkWidget *entry = GTK_WIDGET (user_data);
+
+  gtk_widget_set_sensitive (entry,
+                            polkit_lock_button_get_is_authorized (button));
+}
+
+int
+main (int argc, char *argv[])
+{
+  GtkWidget *window;
+  GtkWidget *label;
+  GtkWidget *button;
+  GtkWidget *entry;
+  GtkWidget *vbox;
+  gchar *s;
+
+  gtk_init (&argc, &argv);
+
+  if (argc != 2)
+    {
+      g_printerr ("usage: %s <action_id>\n", argv[0]);
+      goto out;
+    }
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
+
+  vbox = gtk_vbox_new (FALSE, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (window), 12);
+  gtk_container_add (GTK_CONTAINER (window), vbox);
+
+  s = g_strdup_printf ("Showing PolkitLockButton for action id: %s", argv[1]);
+  label = gtk_label_new (s);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  g_free (s);
+
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+  button = polkit_lock_button_new (argv[1]);
+  g_signal_connect (button,
+                    "changed",
+                    G_CALLBACK (on_button_changed),
+                    entry);
+  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+  gtk_widget_set_sensitive (entry,
+                            polkit_lock_button_get_is_authorized (POLKIT_LOCK_BUTTON (button)));
+
+  gtk_widget_show_all (window);
+  gtk_window_present (GTK_WINDOW (window));
+
+  gtk_main ();
+
+ out:
+  return 0;
+}
diff --git a/polkitgtk/polkit-gtk-1.pc.in b/polkitgtk/polkit-gtk-1.pc.in
new file mode 100644
index 0000000..fdbb6f9
--- /dev/null
+++ b/polkitgtk/polkit-gtk-1.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: polkit-gtk-1
+Description: PolicyKit GTK+ widgets
+Version: @VERSION@
+Libs: -L${libdir} -lpolkit-gtk-1
+Cflags: -I${includedir}/polkit-gtk-1
+Requires: polkit-gobject-1
diff --git a/polkitgtk/polkitgtk.h b/polkitgtk/polkitgtk.h
new file mode 100644
index 0000000..f2e513a
--- /dev/null
+++ b/polkitgtk/polkitgtk.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 Red Hat, 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.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#ifndef __POLKIT_GTK_H
+#define __POLKIT_GTK_H
+
+#define _POLKIT_GTK_INSIDE_POLKIT_GTK_H 1
+
+#include <polkitgtk/polkitgtktypes.h>
+#include <polkitgtk/polkitlockbutton.h>
+
+#undef _POLKIT_GTK_INSIDE_POLKIT_GTK_H
+
+#endif /* __POLKIT_GTK_H */
diff --git a/polkitgtk/polkitgtktypes.h b/polkitgtk/polkitgtktypes.h
new file mode 100644
index 0000000..d31d975
--- /dev/null
+++ b/polkitgtk/polkitgtktypes.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2009 Red Hat, 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.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#if !defined (_POLKIT_GTK_INSIDE_POLKIT_GTK_H) && !defined (POLKIT_GTK_COMPILATION)
+#error "Only <polkitgtk/polkitgtk.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __POLKIT_GTK_TYPES_H
+#define __POLKIT_GTK_TYPES_H
+
+#include <gtk/gtk.h>
+
+struct _PolkitLockButton;
+typedef struct _PolkitLockButton PolkitLockButton;
+
+#endif /* __POLKIT_GTK_TYPES_H */
diff --git a/polkitgtk/polkitlockbutton.c b/polkitgtk/polkitlockbutton.c
new file mode 100644
index 0000000..1ab177e
--- /dev/null
+++ b/polkitgtk/polkitlockbutton.c
@@ -0,0 +1,865 @@
+/*
+ * Copyright (C) 2009 Red Hat, 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.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <string.h>
+#include <polkit/polkit.h>
+
+#include "polkitlockbutton.h"
+
+/**
+ * SECTION:polkitlockbutton
+ * @title: PolkitLockButton
+ * @short_description: Toggle button for obtaining/revoking authorizations
+ * @stability: Stable
+ *
+ * #PolkitLockButton is a widget that can be used in control panels to
+ * allow users to obtain and revoke authorizations needed for the
+ * control panel UI to function.
+ *
+ * If the user lacks the authorization but authorization can be
+ * obtained through authentication, the widget looks like this
+ * <mediaobject id="lock-button-locked">
+ *  <imageobject>
+ *    <imagedata fileref="polkit-lock-button-locked.png" format="PNG"/>
+ *  </imageobject>
+ * </mediaobject>
+ * and the user can click the button to obtain the authorization. This
+ * will pop up an authentication dialog.
+ * Once authorization is obtained, the widget changes to this
+ * <mediaobject id="lock-button-unlocked">
+ *  <imageobject>
+ *    <imagedata fileref="polkit-lock-button-unlocked.png" format="PNG"/>
+ *  </imageobject>
+ * </mediaobject>
+ * 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
+ * <mediaobject id="lock-button-unlocked-not-authorized">
+ *  <imageobject>
+ *    <imagedata fileref="polkit-lock-button-not-authorized.png" format="PNG"/>
+ *  </imageobject>
+ * </mediaobject>
+ * If the user is authorized (either implicitly via the .policy file
+ * defaults or through e.g. Local Authority configuration) and no
+ * authentication is necessary, the widget will be hidden.
+ */
+
+struct _PolkitLockButtonPrivate
+{
+  PolkitAuthority *authority;
+  PolkitSubject *subject;
+  gchar *action_id;
+
+  gchar *text_unlock;
+  gchar *text_lock;
+  gchar *text_not_authorized;
+
+  GtkWidget *toggle_button;
+  GtkWidget *label;
+  gboolean ignore_toggled_signal;
+
+  gboolean can_obtain;
+  gboolean authorized;
+  gboolean hidden;
+
+  /* is non-NULL exactly when we are authorized and have a temporary authorization */
+  gchar *tmp_authz_id;
+
+  /* This is non-NULL exactly when we have a non-interactive check outstanding */
+  GCancellable *check_cancellable;
+
+  /* This is non-NULL exactly when we have an interactive check outstanding */
+  GCancellable *interactive_check_cancellable;
+
+};
+
+enum
+{
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_IS_AUTHORIZED,
+  PROP_IS_VISIBLE,
+  PROP_CAN_OBTAIN,
+  PROP_TEXT_UNLOCK,
+  PROP_TEXT_LOCK,
+  PROP_TEXT_NOT_AUTHORIZED,
+};
+
+enum
+{
+  CHANGED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0, };
+
+static void initiate_check (PolkitLockButton *button);
+static void do_sync_check (PolkitLockButton *button);
+static void update_state (PolkitLockButton *button);
+
+static void on_authority_changed (PolkitAuthority *authority,
+                                  gpointer         user_data);
+
+static void on_toggled (GtkToggleButton *toggle_button,
+                        gpointer         user_data);
+
+G_DEFINE_TYPE (PolkitLockButton, polkit_lock_button, GTK_TYPE_HBOX);
+
+static void
+polkit_lock_button_finalize (GObject *object)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (object);
+
+  g_free (button->priv->action_id);
+  g_free (button->priv->tmp_authz_id);
+  g_object_unref (button->priv->subject);
+
+  if (button->priv->check_cancellable != NULL)
+    {
+      g_cancellable_cancel (button->priv->check_cancellable);
+      g_object_unref (button->priv->check_cancellable);
+    }
+
+  if (button->priv->interactive_check_cancellable != NULL)
+    {
+      g_cancellable_cancel (button->priv->interactive_check_cancellable);
+      g_object_unref (button->priv->interactive_check_cancellable);
+    }
+
+  g_signal_handlers_disconnect_by_func (button->priv->authority,
+                                        on_authority_changed,
+                                        button);
+  g_object_unref (button->priv->authority);
+
+  if (G_OBJECT_CLASS (polkit_lock_button_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_lock_button_parent_class)->finalize (object);
+}
+
+static void
+polkit_lock_button_get_property (GObject    *object,
+                                 guint       property_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (object);
+
+  switch (property_id)
+    {
+    case PROP_ACTION_ID:
+      g_value_set_string (value, button->priv->action_id);
+      break;
+
+    case PROP_IS_AUTHORIZED:
+      g_value_set_boolean (value, button->priv->authorized);
+      break;
+
+    case PROP_IS_VISIBLE:
+      g_value_set_boolean (value, !button->priv->hidden);
+      break;
+
+    case PROP_CAN_OBTAIN:
+      g_value_set_boolean (value, button->priv->can_obtain);
+      break;
+
+    case PROP_TEXT_UNLOCK:
+      g_value_set_string (value, button->priv->text_unlock);
+      break;
+
+    case PROP_TEXT_LOCK:
+      g_value_set_string (value, button->priv->text_lock);
+      break;
+
+    case PROP_TEXT_NOT_AUTHORIZED:
+      g_value_set_string (value, button->priv->text_not_authorized);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_lock_button_set_property (GObject      *object,
+                                 guint         property_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (object);
+
+  switch (property_id)
+    {
+    case PROP_ACTION_ID:
+      button->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_TEXT_UNLOCK:
+      polkit_lock_button_set_unlock_text (button, g_value_get_string (value));
+      break;
+
+    case PROP_TEXT_LOCK:
+      polkit_lock_button_set_lock_text (button, g_value_get_string (value));
+      break;
+
+    case PROP_TEXT_NOT_AUTHORIZED:
+      polkit_lock_button_set_not_authorized_text (button, g_value_get_string (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+
+static void
+polkit_lock_button_init (PolkitLockButton *button)
+{
+  button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
+                                              POLKIT_TYPE_LOCK_BUTTON,
+                                              PolkitLockButtonPrivate);
+
+}
+
+static void
+polkit_lock_button_constructed (GObject *object)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (object);
+  GtkWidget *image;
+
+  gtk_box_set_spacing (GTK_BOX (button), 6);
+
+  button->priv->authority = polkit_authority_get ();
+  g_signal_connect (button->priv->authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    button);
+
+  button->priv->toggle_button = gtk_toggle_button_new ();
+  image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION,
+                                    GTK_ICON_SIZE_BUTTON);
+  gtk_button_set_image (GTK_BUTTON (button->priv->toggle_button), image);
+  g_signal_connect (button->priv->toggle_button,
+                    "toggled",
+                    G_CALLBACK (on_toggled),
+                    button);
+
+  gtk_box_pack_start (GTK_BOX (button),
+                      button->priv->toggle_button,
+                      FALSE,
+                      FALSE,
+                      0);
+
+  button->priv->label = gtk_label_new ("");
+  gtk_box_pack_start (GTK_BOX (button),
+                      button->priv->label,
+                      FALSE,
+                      FALSE,
+                      0);
+
+  /* take control of visibility of child widgets */
+  gtk_widget_set_no_show_all (button->priv->toggle_button, TRUE);
+  gtk_widget_set_no_show_all (button->priv->label, TRUE);
+
+  if (button->priv->subject == NULL)
+    {
+      button->priv->subject = polkit_unix_process_new (getpid ());
+    }
+
+  /* synchronously check on construction - TODO: we could implement GAsyncInitable
+   * in the future to avoid this sync check
+   */
+  do_sync_check (button);
+
+  update_state (button);
+
+  if (G_OBJECT_CLASS (polkit_lock_button_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_lock_button_parent_class)->constructed (object);
+}
+
+static void
+polkit_lock_button_class_init (PolkitLockButtonClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize     = polkit_lock_button_finalize;
+  gobject_class->get_property = polkit_lock_button_get_property;
+  gobject_class->set_property = polkit_lock_button_set_property;
+  gobject_class->constructed  = polkit_lock_button_constructed;
+
+  g_type_class_add_private (klass, sizeof (PolkitLockButtonPrivate));
+
+  /**
+   * PolkitLockButton:action-id:
+   *
+   * The action identifier to use for the button.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        _("Action Identifier"),
+                                                        _("The action identifier to use for the button"),
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:is-authorized:
+   *
+   * Whether the process is authorized.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_IS_AUTHORIZED,
+                                   g_param_spec_boolean ("is-authorized",
+                                                         _("Is Authorized"),
+                                                         _("Whether the process is authorized"),
+                                                         FALSE,
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:is-visible:
+   *
+   * Whether the widget is visible.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_IS_VISIBLE,
+                                   g_param_spec_boolean ("is-visible",
+                                                         _("Is Visible"),
+                                                         _("Whether the widget is visible"),
+                                                         TRUE,
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:can-obtain:
+   *
+   * Whether authorization can be obtained.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_CAN_OBTAIN,
+                                   g_param_spec_boolean ("can-obtain",
+                                                         _("Can Obtain"),
+                                                         _("Whether authorization can be obtained"),
+                                                         FALSE,
+                                                         G_PARAM_READABLE |
+                                                         G_PARAM_STATIC_NAME |
+                                                         G_PARAM_STATIC_NICK |
+                                                         G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:text-unlock:
+   *
+   * The text to display when prompting the user to unlock.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEXT_UNLOCK,
+                                   g_param_spec_string ("text-unlock",
+                                                        _("Unlock Text"),
+                                                        _("The text to display when prompting the user to unlock."),
+                                                        _("Click to make changes"),
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:text-lock:
+   *
+   * The text to display when prompting the user to lock.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEXT_LOCK,
+                                   g_param_spec_string ("text-lock",
+                                                        _("Lock Text"),
+                                                        _("The text to display when prompting the user to lock."),
+                                                        _("Click to prevent changes"),
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton:text-not-authorized:
+   *
+   * The text to display when the user cannot obtain authorization through authentication.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEXT_NOT_AUTHORIZED,
+                                   g_param_spec_string ("text-not-authorized",
+                                                        _("Unlock Text"),
+                                                        _("The text to display when the user cannot obtain authorization through authentication."),
+                                                        _("Not authorized to make changes"),
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  /**
+   * PolkitLockButton::changed:
+   * @button: A #PolkitLockButton.
+   *
+   * Emitted when something on @button changes.
+   */
+  signals[CHANGED_SIGNAL] = g_signal_new ("changed",
+                                          G_TYPE_FROM_CLASS (klass),
+                                          G_SIGNAL_RUN_LAST,
+                                          G_STRUCT_OFFSET (PolkitLockButtonClass, changed),
+                                          NULL,
+                                          NULL,
+                                          g_cclosure_marshal_VOID__VOID,
+                                          G_TYPE_NONE,
+                                          0);
+
+}
+
+/**
+ * polkit_lock_button_new:
+ * @action_id: An action identifer.
+ *
+ * Constructs a #PolkitLockButton for @action_id.
+ *
+ * Returns: A #PolkitLockButton.
+ */
+GtkWidget *
+polkit_lock_button_new (const gchar *action_id)
+{
+  g_return_val_if_fail (action_id != NULL, NULL);
+
+  return GTK_WIDGET (g_object_new (POLKIT_TYPE_LOCK_BUTTON,
+                                   "action-id", action_id,
+                                   NULL));
+}
+
+static void
+update_state (PolkitLockButton *button)
+{
+  const gchar *text;
+  gboolean active;
+  gboolean sensitive;
+  gboolean old_hidden;
+
+  old_hidden = button->priv->hidden;
+  button->priv->hidden = FALSE;
+
+  if (button->priv->authorized)
+    {
+      text = button->priv->text_lock;
+      active = TRUE;
+      sensitive = TRUE;
+      /* if the authorization isn't temporary, then hide all the controls */
+      if (button->priv->tmp_authz_id == NULL)
+        button->priv->hidden = TRUE;
+    }
+  else
+    {
+      active = FALSE;
+      if (button->priv->can_obtain)
+        {
+          text = button->priv->text_unlock;
+          g_free (button->priv->tmp_authz_id);
+          button->priv->tmp_authz_id = NULL;
+          sensitive = TRUE;
+        }
+      else
+        {
+          text = button->priv->text_not_authorized;
+          g_free (button->priv->tmp_authz_id);
+          button->priv->tmp_authz_id = NULL;
+          sensitive = FALSE;
+        }
+    }
+
+  gtk_label_set_text (GTK_LABEL (button->priv->label), text);
+  button->priv->ignore_toggled_signal = TRUE;
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button->priv->toggle_button), active);
+  button->priv->ignore_toggled_signal = FALSE;
+  gtk_widget_set_sensitive (button->priv->toggle_button, sensitive);
+
+  if (button->priv->hidden)
+    {
+      gtk_widget_hide (button->priv->toggle_button);
+      gtk_widget_hide (button->priv->label);
+    }
+  else
+    {
+      gtk_widget_show (button->priv->toggle_button);
+      gtk_widget_show (button->priv->label);
+    }
+
+  if (old_hidden != button->priv->hidden)
+    g_object_notify (G_OBJECT (button), "is-visible");
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+  initiate_check (button);
+}
+
+static void
+process_result (PolkitLockButton          *button,
+                PolkitAuthorizationResult *result)
+{
+  gboolean old_can_obtain;
+  gboolean old_authorized;
+  PolkitDetails *details;
+
+  old_can_obtain = button->priv->can_obtain;
+  old_authorized = button->priv->authorized;
+  button->priv->can_obtain = polkit_authorization_result_get_is_challenge (result);
+  button->priv->authorized = polkit_authorization_result_get_is_authorized (result);
+
+  /* save the temporary authorization id */
+  details = polkit_authorization_result_get_details (result);
+  if (details != NULL)
+    {
+      g_free (button->priv->tmp_authz_id);
+      button->priv->tmp_authz_id = g_strdup (polkit_details_lookup (details,
+                                                                    "polkit.temporary_authorization_id"));
+    }
+
+  update_state (button);
+
+  if (old_can_obtain != button->priv->can_obtain ||
+      old_authorized != button->priv->authorized)
+    {
+      g_signal_emit (button,
+                     signals[CHANGED_SIGNAL],
+                     0);
+    }
+
+  if (old_can_obtain != button->priv->can_obtain)
+    g_object_notify (G_OBJECT (button), "can-obtain");
+
+  if (old_authorized != button->priv->authorized)
+    g_object_notify (G_OBJECT (button), "is-authorized");
+}
+
+static void
+check_cb (GObject       *source_object,
+          GAsyncResult  *res,
+          gpointer       user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+  PolkitAuthorizationResult *result;
+  GError *error;
+
+  error = NULL;
+  result = polkit_authority_check_authorization_finish (authority,
+                                                        res,
+                                                        &error);
+  if (error != NULL)
+    {
+      g_warning ("Error checking authorization for action id `%s': %s",
+                 button->priv->action_id,
+                 error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      process_result (button, result);
+    }
+
+  if (result != NULL)
+    g_object_unref (result);
+
+  if (button->priv->check_cancellable != NULL)
+    {
+      g_object_unref (button->priv->check_cancellable);
+      button->priv->check_cancellable = NULL;
+    }
+}
+
+static void
+initiate_check (PolkitLockButton *button)
+{
+
+  /* if we have a check pending already, then do nothing */
+  if (button->priv->check_cancellable != NULL)
+    goto out;
+
+  button->priv->check_cancellable = g_cancellable_new ();
+
+  polkit_authority_check_authorization (button->priv->authority,
+                                        button->priv->subject,
+                                        button->priv->action_id,
+                                        NULL, /* PolkitDetails */
+                                        POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+                                        button->priv->check_cancellable,
+                                        check_cb,
+                                        button);
+
+ out:
+  ;
+}
+
+static void
+do_sync_check (PolkitLockButton *button)
+{
+  GError *error;
+  PolkitAuthorizationResult *result;
+
+  error = NULL;
+  result = polkit_authority_check_authorization_sync (button->priv->authority,
+                                                      button->priv->subject,
+                                                      button->priv->action_id,
+                                                      NULL, /* PolkitDetails */
+                                                      POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
+                                                      NULL, /* cancellable */
+                                                      &error);
+  if (error != NULL)
+    {
+      g_warning ("Error sync-checking authorization for action id `%s': %s",
+                 button->priv->action_id,
+                 error->message);
+      g_error_free (error);
+    }
+  else
+    {
+      process_result (button, result);
+    }
+
+  if (result != NULL)
+    g_object_unref (result);
+}
+
+static void
+interactive_check_cb (GObject       *source_object,
+                      GAsyncResult  *res,
+                      gpointer       user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+  PolkitAuthorizationResult *result;
+  PolkitDetails *details;
+  GError *error;
+
+  error = NULL;
+  result = polkit_authority_check_authorization_finish (authority,
+                                                        res,
+                                                        &error);
+  if (error != NULL)
+    {
+      g_warning ("Error obtaining authorization for action id `%s': %s",
+                 button->priv->action_id,
+                 error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  /* state is updated in the ::changed signal handler */
+
+  /* save the temporary authorization id */
+  details = polkit_authorization_result_get_details (result);
+  if (details != NULL)
+    {
+      button->priv->tmp_authz_id = g_strdup (polkit_details_lookup (details,
+                                                                    "polkit.temporary_authorization_id"));
+    }
+
+ out:
+  if (result != NULL)
+    g_object_unref (result);
+
+  if (button->priv->interactive_check_cancellable != NULL)
+    {
+      g_object_unref (button->priv->interactive_check_cancellable);
+      button->priv->interactive_check_cancellable = NULL;
+    }
+}
+
+static void
+on_toggled (GtkToggleButton *toggle_button,
+            gpointer         user_data)
+{
+  PolkitLockButton *button = POLKIT_LOCK_BUTTON (user_data);
+
+  if (button->priv->ignore_toggled_signal)
+    goto out;
+
+  if (!button->priv->authorized && button->priv->can_obtain)
+    {
+      /* if we already have a pending interactive check, then do nothing */
+      if (button->priv->interactive_check_cancellable != NULL)
+        goto out;
+
+      button->priv->interactive_check_cancellable = g_cancellable_new ();
+
+      polkit_authority_check_authorization (button->priv->authority,
+                                            button->priv->subject,
+                                            button->priv->action_id,
+                                            NULL, /* PolkitDetails */
+                                            POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+                                            button->priv->interactive_check_cancellable,
+                                            interactive_check_cb,
+                                            button);
+    }
+  else if (button->priv->authorized && button->priv->tmp_authz_id != NULL)
+    {
+      polkit_authority_revoke_temporary_authorization_by_id (button->priv->authority,
+                                                             button->priv->tmp_authz_id,
+                                                             NULL,  /* cancellable */
+                                                             NULL,  /* callback */
+                                                             NULL); /* user_data */
+    }
+
+ out:
+
+  update_state (button);
+}
+
+/**
+ * polkit_lock_button_get_is_authorized:
+ * @button: A #PolkitLockButton.
+ *
+ * Gets whether the process is authorized.
+ *
+ * Returns: %TRUE if authorized.
+ */
+gboolean
+polkit_lock_button_get_is_authorized (PolkitLockButton *button)
+{
+  g_return_val_if_fail (POLKIT_IS_LOCK_BUTTON (button), FALSE);
+  return button->priv->authorized;
+}
+
+/**
+ * polkit_lock_button_get_can_obtain:
+ * @button: A #PolkitLockButton.
+ *
+ * Gets whether the user can obtain an authorization through
+ * authentication.
+ *
+ * Returns: Whether the authorization is obtainable.
+ */
+gboolean
+polkit_lock_button_get_can_obtain (PolkitLockButton *button)
+{
+  g_return_val_if_fail (POLKIT_IS_LOCK_BUTTON (button), FALSE);
+  return button->priv->can_obtain;
+}
+
+/**
+ * polkit_lock_button_get_is_visible:
+ * @button: A #PolkitLockButton.
+ *
+ * Gets whether @button is currently being shown.
+ *
+ * Returns: %TRUE if @button has visible UI elements.
+ */
+gboolean
+polkit_lock_button_get_is_visible (PolkitLockButton *button)
+{
+  g_return_val_if_fail (POLKIT_IS_LOCK_BUTTON (button), FALSE);
+  return ! button->priv->hidden;
+}
+
+/**
+ * polkit_lock_button_set_unlock_text:
+ * @button: A #PolkitLockButton.
+ * @text: The text to set.
+ *
+ * Makes @button display @text when the prompting the user to unlock.
+ */
+void
+polkit_lock_button_set_unlock_text (PolkitLockButton *button,
+                                    const gchar      *text)
+{
+  g_return_if_fail (POLKIT_IS_LOCK_BUTTON (button));
+  g_return_if_fail (text != NULL);
+
+  if (button->priv->text_unlock != NULL)
+    {
+      button->priv->text_unlock = g_strdup (text);
+      update_state (button);
+    }
+  else
+    {
+      button->priv->text_unlock = g_strdup (text);
+    }
+}
+
+/**
+ * polkit_lock_button_set_lock_text:
+ * @button: A #PolkitLockButton.
+ * @text: The text to set.
+ *
+ * Makes @button display @text when the prompting the user to unlock.
+ */
+void
+polkit_lock_button_set_lock_text (PolkitLockButton *button,
+                                  const gchar      *text)
+{
+  g_return_if_fail (POLKIT_IS_LOCK_BUTTON (button));
+  g_return_if_fail (text != NULL);
+
+  if (button->priv->text_lock != NULL)
+    {
+      button->priv->text_lock = g_strdup (text);
+      update_state (button);
+    }
+  else
+    {
+      button->priv->text_lock = g_strdup (text);
+    }
+}
+
+/**
+ * polkit_lock_button_set_not_authorized_text:
+ * @button: A #PolkitLockButton.
+ * @text: The text to set.
+ *
+ * Makes @button display @text when the prompting the user to unlock.
+ */
+void
+polkit_lock_button_set_not_authorized_text (PolkitLockButton *button,
+                                            const gchar      *text)
+{
+  g_return_if_fail (POLKIT_IS_LOCK_BUTTON (button));
+  g_return_if_fail (text != NULL);
+
+  if (button->priv->text_not_authorized != NULL)
+    {
+      button->priv->text_not_authorized = g_strdup (text);
+      update_state (button);
+    }
+  else
+    {
+      button->priv->text_not_authorized = g_strdup (text);
+    }
+}
diff --git a/polkitgtk/polkitlockbutton.h b/polkitgtk/polkitlockbutton.h
new file mode 100644
index 0000000..3a4c6d8
--- /dev/null
+++ b/polkitgtk/polkitlockbutton.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Red Hat, 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.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#if !defined (_POLKIT_GTK_INSIDE_POLKIT_GTK_H) && !defined (POLKIT_GTK_COMPILATION)
+#error "Only <polkitgtk/polkitgtk.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef POLKIT_LOCK_BUTTON_H
+#define POLKIT_LOCK_BUTTON_H
+
+#include <polkitgtk/polkitgtktypes.h>
+
+#define POLKIT_TYPE_LOCK_BUTTON         (polkit_lock_button_get_type ())
+#define POLKIT_LOCK_BUTTON(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TYPE_LOCK_BUTTON, PolkitLockButton))
+#define POLKIT_LOCK_BUTTON_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), POLKIT_LOCK_BUTTON,  PolkitLockButtonClass))
+#define POLKIT_IS_LOCK_BUTTON(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TYPE_LOCK_BUTTON))
+#define POLKIT_IS_LOCK_BUTTON_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TYPE_LOCK_BUTTON))
+#define POLKIT_LOCK_BUTTON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TYPE_LOCK_BUTTON, PolkitLockButtonClass))
+
+typedef struct _PolkitLockButtonClass       PolkitLockButtonClass;
+typedef struct _PolkitLockButtonPrivate     PolkitLockButtonPrivate;
+
+/**
+ * PolkitLockButton:
+ * @parent: The parent instance.
+ *
+ * The #PolkitLockButton structure contains only private data and
+ * should be accessed using the provided API.
+ */
+struct _PolkitLockButton
+{
+  GtkHBox parent;
+
+  /*< private >*/
+  PolkitLockButtonPrivate *priv;
+};
+
+/**
+ * PolkitLockButtonClass:
+ * @parent_class: The parent class structure.
+ * @changed: Signal class handler for the #PolkitLockButton::changed signal.
+ *
+ * Class structure for #PolkitLockButton.
+ */
+struct _PolkitLockButtonClass
+{
+  GtkHBoxClass parent_class;
+
+  /* Signals */
+  void (*changed) (PolkitLockButton *button);
+
+  /*< private >*/
+  /* Padding for future expansion */
+  void (*_polkit_reserved0) (void);
+  void (*_polkit_reserved1) (void);
+  void (*_polkit_reserved2) (void);
+  void (*_polkit_reserved3) (void);
+  void (*_polkit_reserved4) (void);
+  void (*_polkit_reserved5) (void);
+  void (*_polkit_reserved6) (void);
+  void (*_polkit_reserved7) (void);
+  void (*_polkit_reserved8) (void);
+  void (*_polkit_reserved9) (void);
+  void (*_polkit_reserved10) (void);
+  void (*_polkit_reserved11) (void);
+  void (*_polkit_reserved12) (void);
+  void (*_polkit_reserved13) (void);
+  void (*_polkit_reserved14) (void);
+  void (*_polkit_reserved15) (void);
+};
+
+
+GType        polkit_lock_button_get_type              (  void) G_GNUC_CONST;
+GtkWidget   *polkit_lock_button_new                     (const gchar      *action_id);
+gboolean     polkit_lock_button_get_is_authorized       (PolkitLockButton *button);
+gboolean     polkit_lock_button_get_is_visible          (PolkitLockButton *button);
+gboolean     polkit_lock_button_get_can_obtain          (PolkitLockButton *button);
+void         polkit_lock_button_set_unlock_text         (PolkitLockButton *button,
+                                                         const gchar      *text);
+void         polkit_lock_button_set_lock_text           (PolkitLockButton *button,
+                                                         const gchar      *text);
+void         polkit_lock_button_set_not_authorized_text (PolkitLockButton *button,
+                                                         const gchar      *text);
+
+#endif /* POLKIT_LOCK_BUTTON_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]