gwymodule-tool

gwymodule-tool — Interactive tool modules

Synopsis




enum        GwyToolSwitchEvent;
            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);
const gchar* gwy_tool_func_get_tooltip      (const gchar *name);
gboolean    gwy_tool_func_exists            (const gchar *name);

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.

GwyToolFuncInfo

typedef struct {
    const gchar *name;
    const gchar *stock_id;
    const gchar *tooltip;
    gint toolbox_position;
    GwyToolUseFunc use;
} GwyToolFuncInfo;

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.

To keep compatibility with old versions func_info should not be an automatic variable. However, since 1.6 it keeps a copy of func_info.

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.

gwy_tool_func_get_tooltip ()

const gchar* gwy_tool_func_get_tooltip      (const gchar *name);

Gets tool function tooltip.

name : Tool function name.
Returns : The tooltip as a string owned by module loader.

Since 1.9


gwy_tool_func_exists ()

gboolean    gwy_tool_func_exists            (const gchar *name);

Returns whether tool function name exists.

name : Tool function name.
Returns : TRUE if name exists, FALSE otherwise.

Since 1.4.