GwyTool

GwyTool — Base class for tools

Synopsis

#include <app/gwyapp.h>

struct              GwyTool;
struct              GwyToolClass;
enum                GwyToolResponseType;
void                gwy_tool_add_hide_button            (GwyTool *tool,
                                                         gboolean set_default);
void                gwy_tool_show                       (GwyTool *tool);
void                gwy_tool_hide                       (GwyTool *tool);
gboolean            gwy_tool_is_visible                 (GwyTool *tool);
void                gwy_tool_data_switched              (GwyTool *tool,
                                                         GwyDataView *data_view);
void                gwy_tool_spectra_switched           (GwyTool *tool,
                                                         GwySpectra *spectra);
const gchar *       gwy_tool_class_get_title            (GwyToolClass *klass);
const gchar *       gwy_tool_class_get_stock_id         (GwyToolClass *klass);
const gchar *       gwy_tool_class_get_tooltip          (GwyToolClass *klass);

Object Hierarchy

  GObject
   +----GwyTool
         +----GwyPlainTool

Description

Details

struct GwyTool

struct GwyTool;


struct GwyToolClass

struct GwyToolClass {
    GObjectClass parent_class;

    const gchar *stock_id;
    const gchar *tooltip;
    const gchar *title;
    const gchar *prefix;

    gint default_width;
    gint default_height;

    void (*show)(GwyTool *tool);
    void (*hide)(GwyTool *tool);
    void (*data_switched)(GwyTool *tool,
                          GwyDataView *data_view);
    void (*response)(GwyTool *tool,
                     gint response_id);

    void (*spectra_switched)(GwyTool *tool,
                             GwySpectra *spectra);
    void (*reserved2)(void);
    void (*reserved3)(void);
    void (*reserved4)(void);
};

Tool class.

The fields default_width and default_height should be set only if a tool dialog requires a different initial size from it would request (due to shrinkable widgets). Since GwyTool keeps dialog sizes stored in settings and restores them automatically, these values essentially apply only to the first use of a tool.

GObjectClass parent_class;

const gchar *stock_id;

Tool icon stock id.

const gchar *tooltip;

Tooltip.

const gchar *title;

Tool dialog title.

const gchar *prefix;

Prefix in settings to store automatically remembered tool state under, should be of the form "/module/mytool".

gint default_width;

Default initial window width, normally unset.

gint default_height;

Default initial window height, normally unset.

show ()

Tool show virtual method. Most tools do not need to override it, unless they wish to handle lazy updates themselves.

hide ()

Tool hide virtual method. Most tools do not need to override it.

data_switched ()

Data switched virtual method.

response ()

Dialog response virtual method. Hiding an closing is normally handled in the base class, particular tools can handle only responses from their specific buttons.

spectra_switched ()

reserved2 ()

reserved3 ()

reserved4 ()


enum GwyToolResponseType

typedef enum {
    GWY_TOOL_RESPONSE_CLEAR  = 1,
    GWY_TOOL_RESPONSE_UPDATE = 2,
} GwyToolResponseType;

Common tool dialog responses.

They do not have any special meaning for GwyTool (yet?), nonetheless you are encouraged to use them for consistency.

GWY_TOOL_RESPONSE_CLEAR

Clear selection response.

GWY_TOOL_RESPONSE_UPDATE

Update calculated values (if not instant) response.

gwy_tool_add_hide_button ()

void                gwy_tool_add_hide_button            (GwyTool *tool,
                                                         gboolean set_default);

Adds a Hide button to a tool dialog.

All tools should have a Hide button added by this method. The reason why it is not added automatically is because the usual placement of the Hide button is next to the execution button (Apply), which is not present for informational-only tools. In that case Hide should become the default dialog button.

tool :

A tool.

set_default :

Whether hide should become the default tool dialog response.

gwy_tool_show ()

void                gwy_tool_show                       (GwyTool *tool);

Shows a tool's dialog.

tool :

A tool.

gwy_tool_hide ()

void                gwy_tool_hide                       (GwyTool *tool);

Hides a tool's dialog.

tool :

A tool.

gwy_tool_is_visible ()

gboolean            gwy_tool_is_visible                 (GwyTool *tool);

Checks whether a tool dialog is visible.

tool :

A tool.

Returns :

TRUE if tool dialog is visible, FALSE if it is hidden.

gwy_tool_data_switched ()

void                gwy_tool_data_switched              (GwyTool *tool,
                                                         GwyDataView *data_view);

Instructs a tool to switch to another data view.

This involves set up of the top layer of data_view and/or its selection to the mode appropriate for tool.

tool :

A tool.

data_view :

A data view. It can be NULL, too.

gwy_tool_spectra_switched ()

void                gwy_tool_spectra_switched           (GwyTool *tool,
                                                         GwySpectra *spectra);

Instructs a tool to switch to another spectra object.

Bad things may happen when the spectra does not belong to the same container as the currently active channel.

tool :

A tool.

spectra :

A spectra object. It can be NULL, too.

Since 2.7


gwy_tool_class_get_title ()

const gchar *       gwy_tool_class_get_title            (GwyToolClass *klass);

Gets the title of a tool class (this is a class method).

The title is normally used as a tool dialog title.

klass :

A tool class.

Returns :

The title as a string owned by the tool class, untranslated.

gwy_tool_class_get_stock_id ()

const gchar *       gwy_tool_class_get_stock_id         (GwyToolClass *klass);

Gets the icon stock id of a tool class (this is a class method).

klass :

A tool class.

Returns :

The stock id as a string owned by the tool class.

gwy_tool_class_get_tooltip ()

const gchar *       gwy_tool_class_get_tooltip          (GwyToolClass *klass);

Gets the title of a tool class (this is a class method).

klass :

A tool class.

Returns :

The tooltip as a string owned by the tool class, untranslated.