## PolKitGnomeContext

PolKitGnomeContext — Convenience functions for using PolicyKit from GTK+ and GNOME applications.

## Synopsis

    #define             POLKIT_GNOME_CONTEXT_ERROR
    enum                PolKitGnomeContextError;
                        PolKitGnomeContextPrivate;
                        PolKitGnomeContext;
    PolKitGnomeContext* polkit_gnome_context_get            (GError **error);
    GQuark              polkit_gnome_context_error_quark    (void);

## Object Hierarchy

      GObject
       +----PolKitGnomeContext

## Signals

      "config-changed"                                 : Run Last
      "console-kit-db-changed"                         : Run Last

## Description

This class provides convenience functions for using PolicyKit from GTK+ and GNOME applications including setting up main loop integration and system bus connections. Rather than using callbacks, GObject signals are provided when external factors change (e.g. the PolicyKit.conf configuration file changes or ConsoleKit reports activity changes).

Actual usage of PolicyKit is still through the main PolicyKit API through the public pk_context and pk_tracker variables.

This class is implemented as a singleton meaning that several callers will share the underlying PolKitContext and PolKitTracker objects. Do not use any of the life cycle methods of these objects; only use them to gather information.

## Details

### POLKIT_GNOME_CONTEXT_ERROR

    #define POLKIT_GNOME_CONTEXT_ERROR polkit_gnome_context_error_quark ()

Error domain for using the GNOME PolicyKit context. Errors in this domain will be from the PolKitGnomeContextError enumeration. See GError for information on error domains.

### enum PolKitGnomeContextError

    typedef enum
    {
            POLKIT_GNOME_CONTEXT_ERROR_FAILED
    } PolKitGnomeContextError;

Error codes describing how PolKitGnomeContext can fail.

`POLKIT_GNOME_CONTEXT_ERROR_FAILED` | General error

### PolKitGnomeContextPrivate

    typedef struct _PolKitGnomeContextPrivate PolKitGnomeContextPrivate;

### PolKitGnomeContext

    typedef struct {
            PolKitContext *pk_context;
            PolKitTracker *pk_tracker;
    } PolKitGnomeContext;

Provide access to PolKitContext and PolKitTracker instances shared among many callers.

PolKitContext *`pk_context`; | for interfacing with PolicyKit; e.g. typically `polkit_context_can_caller_do_action()`
PolKitTracker *`pk_tracker`; | this is used for effieciently obtaining PolKitCaller objects

### polkit_gnome_context_get ()

    PolKitGnomeContext* polkit_gnome_context_get            (GError **error);

Returns a PolKitGnomeContext object. The context is a global singleton that may be shared with other callers of this function.

This operation can fail if the system message bus is not available.

When done with using this object, call `g_object_unref()`. This is such that resources can be freed when all callers have unreffed it.

`error` : | return location for error
Returns : | a new PolKitGnomeContext or NULL if error is set

### polkit_gnome_context_error_quark ()

    GQuark              polkit_gnome_context_error_quark    (void);

Returns : |

## Signal Details

### The `"config-changed"` signal

    void                user_function                      (PolKitGnomeContext *context,
                                                            gpointer            user_data)      : Run Last

The ::config-changed signal is emitted when PolicyKit configuration (e.g. /etc/PolicyKit/PolicyKit.conf or .policy files) changes content.

As this is one contributing factor to what answer PolicyKit will return, the caller should act on this signal and query PolicyKit for any actions it cares about.

`context` : | the object
`user_data` : | user data set when the signal handler was connected.

### The `"console-kit-db-changed"` signal

    void                user_function                      (PolKitGnomeContext *context,
                                                            gpointer            user_data)      : Run Last

The ::console-kit-db-changed signal is emitted when ConsoleKit configuration changes; e.g. when a session becomes active or inactive.

As this is one contributing factor to what answer PolicyKit will return, the caller should act on this signal and query PolicyKit for any actions it cares about.

`context` : | the object
`user_data` : | user data set when the signal handler was connected.