gwymodule-tool

gwymodule-tool — Interactive tool modules

Synopsis




enum        GwyToolSwitchEvent;
struct      GwyToolFuncInfo;
gboolean    (*GwyToolUseFunc)               (GwyDataWindow *data_window,
                                             GwyToolSwitchEvent event);
gboolean    gwy_tool_func_register          (const gchar *modname,
                                             GwyToolFuncInfo *func_info);
gboolean    gwy_tool_func_use               (const guchar *name,
                                             GwyDataWindow *data_window,
                                             GwyToolSwitchEvent event);
GtkWidget*  gwy_tool_func_build_toolbox     (GCallback item_callback,
                                             gint max_width,
                                             const gchar **first_tool);

Description

It is bets to implement interactive tools with the Unitool tool helper.

Details

enum GwyToolSwitchEvent

typedef enum {
    GWY_TOOL_SWITCH_WINDOW = 1,
    GWY_TOOL_SWITCH_TOOL
} GwyToolSwitchEvent;

Tool switch events.

GWY_TOOL_SWITCH_WINDOW The tool should be set for the data window because the user switched windows.
GWY_TOOL_SWITCH_TOOL The tool should be set for the data window because the user switched tools.

struct GwyToolFuncInfo

struct GwyToolFuncInfo {

    const gchar *name;
    const gchar *stock_id;
    const gchar *tooltip;
    gint toolbox_position;
    GwyToolUseFunc use;
};

Information about one tool use function.

const gchar *name An unique tool function name.
const gchar *stock_id Icon stock id or button label (FIXME: more to be said).
const gchar *tooltip Tooltip for this tool.
gint toolbox_position Position in the toolbox, the tools are sorted by this value (and then alphabetically if they are equal). Standard tools are in the range [0,100].
GwyToolUseFunc use The tool use function itself.

GwyToolUseFunc ()

gboolean    (*GwyToolUseFunc)               (GwyDataWindow *data_window,
                                             GwyToolSwitchEvent event);

The type of tool use function.

This function is called to set a tool for a data window, either when the user changes the active tool or switches to another window; the detailed event is given in event.

data_window : A data window the tool should be set for.
event : The tool change event.
Returns : Whether the tool switch succeeded. Under normal circumstances it should always return TRUE.

gwy_tool_func_register ()

gboolean    gwy_tool_func_register          (const gchar *modname,
                                             GwyToolFuncInfo *func_info);

Registeres a tool use function.

The passed func_info must not be an automatic variable.

modname : Module identifier (name).
func_info : Tool use function info.
Returns : TRUE on success, FALSE on failure.

gwy_tool_func_use ()

gboolean    gwy_tool_func_use               (const guchar *name,
                                             GwyDataWindow *data_window,
                                             GwyToolSwitchEvent event);

Sets a tool for a data window.

name : Tool use function name.
data_window : A data window the tool should be set for.
event : The tool change event.
Returns : Whether the tool switch succeeded. Under normal circumstances it always return TRUE.

gwy_tool_func_build_toolbox ()

GtkWidget*  gwy_tool_func_build_toolbox     (GCallback item_callback,
                                             gint max_width,
                                             const gchar **first_tool);

Creates a toolbox with the tools.

item_callback : A callback called when a tool from the toolbox is selected with tool name as the user data.
max_width : The number of columns.
first_tool : Where name of the first tool in the toolbox should be stored.
Returns : The toolbox as a GtkWidget.