## NAIContext NAIContext — The Contextual Interface |

## Synopsis

    #include <caja-actions/na-icontext.h>

    #define             NA_TYPE_ICONTEXT
    #define             NA_ICONTEXT_GET_INTERFACE           (instance)
                        NAIContext;
                        NAIContextInterfacePrivate;
                        NAIContextInterface;
    gboolean            na_icontext_are_equal               (const NAIContext *a,
                                                             const NAIContext *b);
    void                na_icontext_check_mimetypes         (const NAIContext *context);
    void                na_icontext_copy                    (NAIContext *context,
                                                             const NAIContext *source);
    gboolean            na_icontext_is_candidate            (const NAIContext *context,
                                                             guint target,
                                                             GList *selection);
    gboolean            na_icontext_is_valid                (const NAIContext *context);
    void                na_icontext_read_done               (NAIContext *context);
    void                na_icontext_set_scheme              (NAIContext *context,
                                                             const gchar *scheme,
                                                             gboolean selected);
    void                na_icontext_set_only_desktop        (NAIContext *context,
                                                             const gchar *desktop,
                                                             gboolean selected);
    void                na_icontext_set_not_desktop         (NAIContext *context,
                                                             const gchar *desktop,
                                                             gboolean selected);
    void                na_icontext_replace_folder          (NAIContext *context,
                                                             const gchar *old,
                                                             const gchar *new);

## Object Hierarchy

      GInterface
       +----NAIContext

## Prerequisites

NAIContext requires GObject.

## Known Implementations

NAIContext is implemented by NAObjectAction, NAObjectMenu and NAObjectProfile.

## Description

This interface is implemented by all NAObject -derived objects whose the display in the Caja context menu is subject to some conditions.

Implementors, typically NAObjectAction, NAObjectProfile and NAObjectMenu, host the required data as NADataBoxed in a dedicated NA_FACTORY_CONDITIONS_GROUP data group.

## Details

### NA_TYPE_ICONTEXT

    #define NA_TYPE_ICONTEXT                      ( na_icontext_get_type())

### NA_ICONTEXT_GET_INTERFACE()

    #define NA_ICONTEXT_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_TYPE_ICONTEXT, NAIContextInterface ))

### NAIContext

    typedef struct _NAIContext NAIContext;

### NAIContextInterfacePrivate

    typedef struct _NAIContextInterfacePrivate NAIContextInterfacePrivate;

### NAIContextInterface

    typedef struct {
    	/**
    	 * is_candidate:
    	 * @object: this NAIContext object.
    	 * @target: the initial target which triggered this function's stack.
    	 *  This target is defined in na-object-item.h.
    	 * @selection: the current selection as a GList of CajaFileInfo.
    	 *
    	 * The NAIContext implementor may take advantage of this
    	 * virtual function to check for its own specific data. Only if the
    	 * implementor does return %TRUE (or just doesn't implement this
    	 * virtual), the conditions themselves will be checked.
    	 *
    	 * Returns: %TRUE if the @object may be a potential candidate, %FALSE
    	 * else.
    	 *
    	 * Since: 2.30
    	 */
    	gboolean ( *is_candidate )( NAIContext *object, guint target, GList *selection );
    } NAIContextInterface;

This interface manages all conditions relevant to a displayable status in Caja.

`is_candidate` () | determines if the given NAObject-derived object is candidate to display in Caja.

### na_icontext_are_equal ()

    gboolean            na_icontext_are_equal               (const NAIContext *a,
                                                             const NAIContext *b);

`a` : | the (original) NAIContext context.
`b` : | the (duplicated) NAIContext context to be checked.
Returns : | `TRUE` if this `a` and `b` are equal, `FALSE` else.

Since 3.1

### na_icontext_check_mimetypes ()

    void                na_icontext_check_mimetypes         (const NAIContext *context);

Check the current list of mimetypes to see if it covers all mimetypes, or all regular files, or something else.

`context` : | the NAIContext object to be checked.

Since 2.30

### na_icontext_copy ()

    void                na_icontext_copy                    (NAIContext *context,
                                                             const NAIContext *source);

Copy specific data from `source` to `context`.

`context` : | the target NAIContext context.
`source` : | the source NAIContext context.

Since 3.1

### na_icontext_is_candidate ()

    gboolean            na_icontext_is_candidate            (const NAIContext *context,
                                                             guint target,
                                                             GList *selection);

Determines if the given object may be candidate to be displayed in the Caja context menu, depending of the list of currently selected items.

This function is called by `build_caja_menus` plugin function for each item found in NAPivot items list, and, when this an action, for each profile of this action.

`context` : | a NAIContext to be checked.
`target` : | the current target.
`selection` : | the currently selected items, as a GList of NASelectedInfo items.
Returns : | `TRUE` if this `context` succeeds to all tests and is so a valid candidate to be displayed in Caja context menu, `FALSE` else.

Since 2.30

### na_icontext_is_valid ()

    gboolean            na_icontext_is_valid                (const NAIContext *context);

`context` : | the NAIContext to be checked.
Returns : | `TRUE` if this `context` is valid, `FALSE` else. This function is part of `NAIDuplicable::check_status` and is called by NAIDuplicable objects which also implement NAIContext interface. It so doesn't make sense of asking the object for its validity status as it has already been checked before calling the function.

Since 2.30

### na_icontext_read_done ()

    void                na_icontext_read_done               (NAIContext *context);

Prepares the specified NAIContext just after it has been read.

- This setup an internal flag when mimetypes is like 'all/all' in order to optimize computation time;

`context` : | the NAIContext to be prepared.

Since 2.30

### na_icontext_set_scheme ()

    void                na_icontext_set_scheme              (NAIContext *context,
                                                             const gchar *scheme,
                                                             gboolean selected);

Sets the status of a `scheme` relative to this `context`.

`context` : | the NAIContext to be updated.
`scheme` : | name of the scheme.
`selected` : | whether this scheme is candidate to this `context`.

Since 2.30

### na_icontext_set_only_desktop ()

    void                na_icontext_set_only_desktop        (NAIContext *context,
                                                             const gchar *desktop,
                                                             gboolean selected);

Sets the status of the `desktop` relative to this `context` for the NotShowIn list.

`context` : | the NAIContext to be updated.
`desktop` : | name of the desktop environment.
`selected` : | whether this `desktop` is candidate to this `context`.

Since 2.30

### na_icontext_set_not_desktop ()

    void                na_icontext_set_not_desktop         (NAIContext *context,
                                                             const gchar *desktop,
                                                             gboolean selected);

### na_icontext_replace_folder ()

    void                na_icontext_replace_folder          (NAIContext *context,
                                                             const gchar *old,
                                                             const gchar *new);

Replaces the `old` URI by the `new` one.

`context` : | the NAIContext to be updated.
`old` : | the old uri.
`new` : | the new uri.

Since 2.30