GUsb Reference Manual: GUsbContext

## GUsbContext GUsbContext — Per-thread instance integration for libusb |

## Functions

GQuark | g_usb_context_error_quark ()
GUsbContext * | g_usb_context_new ()
GUsbSource * | g_usb_context_get_source ()
void | g_usb_context_set_debug ()

## Properties

gint | debug-level | Read / Write
gpointer | libusb-context | Read / Write / Construct Only

## Types and Values

#define | G_USB_CONTEXT_ERROR
struct | GUsbContext
struct | GUsbContextClass
enum | GUsbContextError
| GUsbContextPrivate

## Object Hierarchy

        GObject
        ╰── GUsbContext

## Description

This object is used to get a context that is thread safe.

## Functions

### g_usb_context_error_quark ()

    GQuark
    g_usb_context_error_quark (void);

#### Returns

Our personal error quark.

Since 0.1.0

### g_usb_context_new ()

    GUsbContext *
    g_usb_context_new (GError **error);

Creates a new context for accessing USB devices.

#### Parameters

error | a GError, or `NULL` |

#### Returns

a new `GUsbContext` object or `NULL` on error.

Since 0.1.0

### g_usb_context_get_source ()

    GUsbSource *
    g_usb_context_get_source (GUsbContext *context,
                              GMainContext *main_ctx);

Returns a source for this context. The first call actually creates the source and the result is returned in all future calls.

#### Parameters

context | a GUsbContext |
main_ctx | a GMainContext, or `NULL` |

#### Returns

the GUsbSource.

[transfer none]

Since 0.1.0

### g_usb_context_set_debug ()

    void
    g_usb_context_set_debug (GUsbContext *context,
                             GLogLevelFlags flags);

Sets the debug flags which control what is logged to the console.

Using `G_LOG_LEVEL_INFO` will output to standard out, and everything else logs to standard error.

#### Parameters

context | a GUsbContext |
flags | a GLogLevelFlags such as `G_LOG_LEVEL_ERROR` | `G_LOG_LEVEL_INFO`, or 0 |

Since 0.1.0

## Types and Values

### G_USB_CONTEXT_ERROR

    #define G_USB_CONTEXT_ERROR		(g_usb_context_error_quark ())

### struct GUsbContext

    struct GUsbContext;

### struct GUsbContextClass

    struct GUsbContextClass {
    	GObjectClass			 parent_class;
    };

### enum GUsbContextError

#### Members

G_USB_CONTEXT_ERROR_INTERNAL |  |

### GUsbContextPrivate

    typedef struct _GUsbContextPrivate GUsbContextPrivate;

Private GUsbContext data

## Property Details

### The `“debug-level”` property

      “debug-level”              gint

Flags: Read / Write

Allowed values: [0,3]

Default value: 0

### The `“libusb-context”` property

      “libusb-context”           gpointer

Flags: Read / Write / Construct Only