## gwymodule-graph

gwymodule-graph — Graph modules

## Synopsis

    #include <libgwymodule/gwymodule.h>

    void                (*GwyGraphFunc)                     (GwyGraph *graph,
                                                             const gchar *name);
    gboolean            gwy_graph_func_register             (const gchar *name,
                                                             GwyGraphFunc func,
                                                             const gchar *menu_path,
                                                             const gchar *stock_id,
                                                             guint sens_mask,
                                                             const gchar *tooltip);
    void                gwy_graph_func_run                  (const gchar *name,
                                                             GwyGraph *graph);
    gboolean            gwy_graph_func_exists               (const gchar *name);
    const gchar*        gwy_graph_func_get_menu_path        (const gchar *name);
    const gchar*        gwy_graph_func_get_stock_id         (const gchar *name);
    const gchar*        gwy_graph_func_get_tooltip          (const gchar *name);
    guint               gwy_graph_func_get_sensitivity_mask (const gchar *name);
    void                gwy_graph_func_foreach              (GFunc function,
                                                             gpointer user_data);

## Description

Graph modules implement operations on graphs, e.g., curve fitting.

## Details

### GwyGraphFunc ()

    void                (*GwyGraphFunc)                     (GwyGraph *graph,
                                                             const gchar *name);

The type of graph function.

`graph` : | Graph (a GwyGraph) to operate on.
`name` : | Function name from as registered with `gwy_graph_func_register()` (single-function modules can safely ignore this argument).

### gwy_graph_func_register ()

    gboolean            gwy_graph_func_register             (const gchar *name,
                                                             GwyGraphFunc func,
                                                             const gchar *menu_path,
                                                             const gchar *stock_id,
                                                             guint sens_mask,
                                                             const gchar *tooltip);

Registers a graph function.

Note: the string arguments are not copied as modules are not expected to vanish. If they are constructed (non-constant) strings, do not free them. Should modules ever become unloadable they will get chance to clean-up.

`name` : | Name of function to register. It should be a valid identifier and if a module registers only one function, module and function names should be the same.
`func` : | The function itself.
`menu_path` : | Menu path under Graph menu. The menu path should be marked translatabe, but passed untranslated (to allow merging of translated and untranslated submenus).
`stock_id` : | Stock icon id for toolbar.
`sens_mask` : | Sensitivity mask (a combination of GwyMenuSensFlags flags). Usually it is equal to GWY_MENU_FLAG_GRAPH, but it's possible to set other requirements.
`tooltip` : | Tooltip for this function.
Returns : | Normally `TRUE`; `FALSE` on failure.

### gwy_graph_func_run ()

    void                gwy_graph_func_run                  (const gchar *name,
                                                             GwyGraph *graph);

Runs a graph function identified by `name`.

`name` : | Graph function name.
`graph` : | Graph (a GwyGraph).

### gwy_graph_func_exists ()

    gboolean            gwy_graph_func_exists               (const gchar *name);

Checks whether a graph function exists.

`name` : | Graph function name.
Returns : | `TRUE` if function `name` exists, `FALSE` otherwise.

### gwy_graph_func_get_menu_path ()

    const gchar*        gwy_graph_func_get_menu_path        (const gchar *name);

Gets menu path of a graph function.

The returned menu path is only the tail part registered by the function, i.e., without any leading "/Graph".

`name` : | Graph function name.
Returns : | The menu path. The returned string is owned by the module.

### gwy_graph_func_get_stock_id ()

    const gchar*        gwy_graph_func_get_stock_id         (const gchar *name);

Gets stock icon id of a graph function.

`name` : | Graph function name.
Returns : | The stock icon id. The returned string is owned by the module.

### gwy_graph_func_get_tooltip ()

    const gchar*        gwy_graph_func_get_tooltip          (const gchar *name);

Gets tooltip for a graph function.

`name` : | Graph function name.
Returns : | The tooltip. The returned string is owned by the module.

### gwy_graph_func_get_sensitivity_mask ()

    guint               gwy_graph_func_get_sensitivity_mask (const gchar *name);

Gets menu sensititivy mask for a graph function.

`name` : | Graph function name.
Returns : | The menu item sensitivity mask (a combination of GwyMenuSensFlags flags).

### gwy_graph_func_foreach ()

    void                gwy_graph_func_foreach              (GFunc function,
                                                             gpointer user_data);

Calls a function for each graph function.

`function` : | Function to run for each graph function. It will get function name (constant string owned by module system) as its first argument, `user_data` as the second argument.
`user_data` : | Data to pass to `function`.