## DhLink DhLink — A link inside a DhBook |

## Functions

DhLink * | dh_link_new ()
DhLink * | dh_link_ref ()
void | dh_link_unref ()
DhLinkType | dh_link_get_link_type ()
DhLinkFlags | dh_link_get_flags ()
void | dh_link_set_flags ()
const gchar * | dh_link_get_name ()
const gchar * | dh_link_get_file_name ()
gchar * | dh_link_get_uri ()
const gchar * | dh_link_get_book_name ()
const gchar * | dh_link_get_book_id ()
gint | dh_link_compare ()
const gchar * | dh_link_type_to_string ()

## Types and Values

| DhLink
enum | DhLinkType
enum | DhLinkFlags

## Object Hierarchy

        GBoxed
        ╰── DhLink
        GEnum
        ╰── DhLinkType
        GFlags
        ╰── DhLinkFlags

## Includes

    #include <devhelp/devhelp.h>

## Description

A DhLink represents a link to an HTML page or somewhere inside a page (with an anchor) that is inside a DhBook. The link can point to a specific symbol, or a page, or the top-level page of the DhBook.

A DhLink has a type that can be retrieved with `dh_link_get_link_type()`.

There is exactly one DhLink of type `DH_LINK_TYPE_BOOK` per DhBook object.

## Functions

### dh_link_new ()

    DhLink *
    dh_link_new (DhLinkType type,
                 const gchar *base_path,
                 const gchar *book_id,
                 DhLink *book,
                 const gchar *name,
                 const gchar *relative_url);

Creates a new DhLink.

`base_path` and `book_id` must be provided only for a link of type `DH_LINK_TYPE_BOOK`.

If `type` is not a DH_LINK_TYPE_BOOK, then the `book` link must be provided.

`name` and `relative_url` must always be provided.

#### Parameters

type | the DhLinkType. |
base_path | the base path for the book, or `NULL`. | [nullable]
book_id | the book ID, or `NULL`. | [nullable]
name | the name of the link. |
book | the book that the link is contained in, or `NULL`. | [nullable]
relative_url | the URL relative to the book `base_path` . Can contain an anchor. |

#### Returns

a new DhLink.

### dh_link_ref ()

    DhLink *
    dh_link_ref (DhLink *link);

Increases the reference count of `link` .

#### Parameters

link | a DhLink. |

#### Returns

the `link` .

[transfer full]

### dh_link_unref ()

    void
    dh_link_unref (DhLink *link);

Decreases the reference count of `link` .

#### Parameters

link | a DhLink. |

### dh_link_get_link_type ()

    DhLinkType
    dh_link_get_link_type (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the DhLinkType of `link` .

### dh_link_get_flags ()

    DhLinkFlags
    dh_link_get_flags (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the DhLinkFlags of `link` .

### dh_link_set_flags ()

    void
    dh_link_set_flags (DhLink *link,
                       DhLinkFlags flags);

Sets the flags of the link.

#### Parameters

link | a DhLink. |
flags | the new flags of the link. |

### dh_link_get_name ()

    const gchar *
    dh_link_get_name (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the name of the `link` .

### dh_link_get_file_name ()

    const gchar *
    dh_link_get_file_name (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the name of the file that the `link` is contained in.

### dh_link_get_uri ()

    gchar *
    dh_link_get_uri (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the `link` URI. Free with `g_free()` when no longer needed.

### dh_link_get_book_name ()

    const gchar *
    dh_link_get_book_name (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the name of the book that the `link` is contained in.

### dh_link_get_book_id ()

    const gchar *
    dh_link_get_book_id (DhLink *link);

#### Parameters

link | a DhLink. |

#### Returns

the book ID.

### dh_link_compare ()

    gint
    dh_link_compare (gconstpointer a,
                     gconstpointer b);

Compares the links `a` and `b` . This function is used to determine in which order the links should be displayed.

#### Parameters

a | a DhLink. | [type DhLink]
b | a DhLink. | [type DhLink]

#### Returns

an integer less than zero if `a` should appear before `b` ; zero if there are no preferences; an integer greater than zero if `b` should appear before `a` .

### dh_link_type_to_string ()

    const gchar *
    dh_link_type_to_string (DhLinkType link_type);

#### Parameters

link_type | a DhLinkType. |

#### Returns

a string representation of the DhLinkType, translated in the current language.

## Types and Values

### DhLink

    typedef struct _DhLink DhLink;

### enum DhLinkType

The type of the content the link points to.

#### Members

DH_LINK_TYPE_BOOK | The top-level page of a DhBook. |
DH_LINK_TYPE_PAGE | A page. |
DH_LINK_TYPE_KEYWORD | Another kind of keyword. |
DH_LINK_TYPE_FUNCTION | A function keyword. |
DH_LINK_TYPE_STRUCT | A struct keyword. |
DH_LINK_TYPE_MACRO | A macro keyword. |
DH_LINK_TYPE_ENUM | An enum keyword. |
DH_LINK_TYPE_TYPEDEF | A typedef keyword. |
DH_LINK_TYPE_PROPERTY | A property keyword. |
DH_LINK_TYPE_SIGNAL | A signal keyword. |

### enum DhLinkFlags

#### Members

DH_LINK_FLAGS_NONE | No flags set. |
DH_LINK_FLAGS_DEPRECATED | The symbol that the link points to is deprecated. |