diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-04-29 23:40:47 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-05-06 22:44:38 -0400 |
commit | 1d647df176b6bf32e84d839cdb60a0f19d0ce2f3 (patch) | |
tree | bfe520cd66664a71d99724f141249ce829d48435 /docs/tools/widgets.c | |
parent | 5cb3f5ff0f184dbca0b155a60da1a9aef8243544 (diff) | |
download | gtk+-1d647df176b6bf32e84d839cdb60a0f19d0ce2f3.tar.gz |
Add a lock button widget
This is a special-purpose button that can be used together with
GPermission objects to control the sensitivity of system settings.
Suitable permission objects can e.g. be obtained from PolicyKit.
http://bugzilla.gnome.org/show_bug.cgi?id=626457
Diffstat (limited to 'docs/tools/widgets.c')
-rw-r--r-- | docs/tools/widgets.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c index 7709e3c993..6731ef0143 100644 --- a/docs/tools/widgets.c +++ b/docs/tools/widgets.c @@ -221,6 +221,54 @@ create_link_button (void) return new_widget_info ("link-button", align, SMALL); } +#define G_TYPE_TEST_PERMISSION (g_test_permission_get_type ()) +#define G_TEST_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_TEST_PERMISSION, \ + GTestPermission)) +#define G_IS_TEST_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_TEST_PERMISSION)) + +typedef struct _GTestPermission GTestPermission; +typedef struct _GTestPermissionClass GTestPermissionClass; + +struct _GTestPermission +{ + GPermission parent; + + gboolean success; +}; + +struct _GTestPermissionClass +{ + GPermissionClass parent_class; +}; + +G_DEFINE_TYPE (GTestPermission, g_test_permission, G_TYPE_PERMISSION) + +static void +g_test_permission_init (GTestPermission *test) +{ + g_permission_impl_update (G_PERMISSION (test), FALSE, TRUE, TRUE); +} + +static void +g_test_permission_class_init (GTestPermissionClass *class) +{ +} + +static WidgetInfo * +create_lockbutton (void) +{ + GtkWidget *widget; + GtkWidget *align; + + widget = gtk_lock_button_new (g_object_new (G_TYPE_TEST_PERMISSION, NULL)); + align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); + gtk_container_add (GTK_CONTAINER (align), widget); + + return new_widget_info ("lock-button", align, SMALL); +} + static WidgetInfo * create_entry (void) { @@ -1152,6 +1200,7 @@ get_all_widgets (void) retval = g_list_prepend (retval, create_switch ()); retval = g_list_prepend (retval, create_appchooserbutton ()); retval = g_list_prepend (retval, create_appchooserdialog ()); + retval = g_list_prepend (retval, create_lockbutton ()); return retval; } |