## AnjutaPreferences AnjutaPreferences — Anjuta Preferences system. |

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <libanjuta/anjuta-preferences.h>

    GtkWidget *         anjuta_property_get_widget          (AnjutaProperty *prop);
    struct              AnjutaPreferences;
    struct              AnjutaPreferencesClass;
    gboolean            (*AnjutaPreferencesCallback)        (AnjutaPreferences *pr,
                                                             const gchar *key,
                                                             gpointer data);
    AnjutaPreferences * anjuta_preferences_new              (AnjutaPluginManager *plugin_manager,
                                                             const gchar *common_schema_id);
    AnjutaPreferences * anjuta_preferences_default          (void);
    void                anjuta_preferences_add_from_builder (AnjutaPreferences *pr,
                                                             GtkBuilder *builder,
                                                             GSettings *settings,
                                                             const gchar *glade_widget_name,
                                                             const gchar *stitle,
                                                             const gchar *icon_filename);
    void                anjuta_preferences_remove_page      (AnjutaPreferences *pr,
                                                             const gchar *page_name);
    void                anjuta_preferences_register_all_properties_from_builder_xml
                                                            (AnjutaPreferences *pr,
                                                             GtkBuilder *builder,
                                                             GSettings *settings,
                                                             GtkWidget *parent);
    gboolean            anjuta_preferences_register_property
                                                            (AnjutaPreferences *pr,
                                                             GSettings *settings,
                                                             GtkWidget *object,
                                                             const gchar *key);
    GtkWidget *         anjuta_preferences_get_dialog       (AnjutaPreferences *pr);
    gboolean            anjuta_preferences_is_dialog_created
                                                            (AnjutaPreferences *pr);
                        AnjutaProperty;
                        AnjutaPreferencesPriv;

## Object Hierarchy

      GObject
       +----AnjutaPreferences

## Description

AnjutaPreferences is a way to let plugins register their preferences. There are mainly two ways a plugin could register its preferences in Anjuta.

First is to not use AnjutaPreferences at all. Simply register a preferences page in AnjutaPreferencesDialog using the function `anjuta_preferences_dialog_add_page()`. The plugin should take care of loading, saving and widgets synchronization of the preferences values. This can be done using GSettings bindings for example.

Second is to use `anjuta_preferences_add_page()`, which will automatically register the preferences keys and values from a glade xml file. The glade xml file contains a preferences page of the plugin. The widget names in the page are given in a particular way (see `anjuta_preferences_add_page()`) to let it know property key details. The preference dialog will automatically setup the bindings between GSettings and the widgets.

## Details

### anjuta_property_get_widget ()

    GtkWidget *         anjuta_property_get_widget          (AnjutaProperty *prop);

### struct AnjutaPreferences

    struct AnjutaPreferences;

### struct AnjutaPreferencesClass

    struct AnjutaPreferencesClass {
    	GObjectClass parent;
    };

### AnjutaPreferencesCallback ()

    gboolean            (*AnjutaPreferencesCallback)        (AnjutaPreferences *pr,
                                                             const gchar *key,
                                                             gpointer data);

### anjuta_preferences_new ()

    AnjutaPreferences * anjuta_preferences_new              (AnjutaPluginManager *plugin_manager,
                                                             const gchar *common_schema_id);

Creates a new AnjutaPreferences object

`plugin_manager` : | AnjutaPluginManager to be used
`common_schema_id` : | Common schema id used for key starting with .
Returns : | A AnjutaPreferences object.

### anjuta_preferences_default ()

    AnjutaPreferences * anjuta_preferences_default          (void);

Get the default instace of anjuta preferences

Returns : | A AnjutaPreferences object.

### anjuta_preferences_add_from_builder ()

    void                anjuta_preferences_add_from_builder (AnjutaPreferences *pr,
                                                             GtkBuilder *builder,
                                                             GSettings *settings,
                                                             const gchar *glade_widget_name,
                                                             const gchar *stitle,
                                                             const gchar *icon_filename);

### anjuta_preferences_remove_page ()

    void                anjuta_preferences_remove_page      (AnjutaPreferences *pr,
                                                             const gchar *page_name);

### anjuta_preferences_register_all_properties_from_builder_xml ()

    void                anjuta_preferences_register_all_properties_from_builder_xml
                                                            (AnjutaPreferences *pr,
                                                             GtkBuilder *builder,
                                                             GSettings *settings,
                                                             GtkWidget *parent);

This will register all the properties names of the format described above without considering the UI. Useful if you have the widgets shown elsewhere but you want them to be part of preferences system.

`pr` : | a AnjutaPreferences Object
`builder` : | GtkBuilder object containing the properties widgets.
`parent` : | Parent widget in the builder object

### anjuta_preferences_register_property ()

    gboolean            anjuta_preferences_register_property
                                                            (AnjutaPreferences *pr,
                                                             GSettings *settings,
                                                             GtkWidget *object,
                                                             const gchar *key);

This registers only one widget. The widget could be shown elsewhere. The widget needs to fulfill the properties described in anjuta_preferences_add_page documentation.

`pr` : | a AnjutaPreferences object
`settings` : | the GSettings object associated with that property
`object` : | Widget to register
`key` : | Property key
Returns : | TRUE if sucessful.

### anjuta_preferences_get_dialog ()

    GtkWidget *         anjuta_preferences_get_dialog       (AnjutaPreferences *pr);

### anjuta_preferences_is_dialog_created ()

    gboolean            anjuta_preferences_is_dialog_created
                                                            (AnjutaPreferences *pr);

### AnjutaProperty

    typedef struct _AnjutaProperty AnjutaProperty;

### AnjutaPreferencesPriv

    typedef struct _AnjutaPreferencesPriv AnjutaPreferencesPriv;

## See Also

AnjutaPreferencesDialog