gwyoptionmenus

gwyoptionmenus — Option menu constructors for enums

Synopsis




GtkWidget*  gwy_menu_gradient               (GCallback callback,
                                             gpointer cbdata);
GtkWidget*  gwy_menu_gl_material            (GCallback callback,
                                             gpointer cbdata);
GtkWidget*  gwy_option_menu_gradient        (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *current);
GtkWidget*  gwy_option_menu_gl_material     (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *current);
GtkWidget*  gwy_option_menu_interpolation   (GCallback callback,
                                             gpointer cbdata,
                                             GwyInterpolationType current);
GtkWidget*  gwy_option_menu_windowing       (GCallback callback,
                                             gpointer cbdata,
                                             GwyWindowingType current);
GtkWidget*  gwy_option_menu_2dcwt           (GCallback callback,
                                             gpointer cbdata,
                                             Gwy2DCWTWaveletType current);
GtkWidget*  gwy_option_menu_dwt             (GCallback callback,
                                             gpointer cbdata,
                                             GwyDWTType current);
GtkWidget*  gwy_option_menu_sfunctions_output
                                            (GCallback callback,
                                             gpointer cbdata,
                                             GwySFOutputType current);
GtkWidget*  gwy_option_menu_orientation     (GCallback callback,
                                             gpointer cbdata,
                                             GwyOrientation current);
GtkWidget*  gwy_option_menu_merge_type      (GCallback callback,
                                             gpointer cbdata,
                                             GwyMergeType current);
GtkWidget*  gwy_option_menu_indentor        (GCallback callback,
                                             gpointer cbdata,
                                             GwyIndentorType current);
GtkWidget*  gwy_option_menu_metric_unit     (GCallback callback,
                                             gpointer cbdata,
                                             gint from,
                                             gint to,
                                             const gchar *unit,
                                             gint current);
GtkWidget*  gwy_option_menu_create          (const GwyEnum *entries,
                                             gint nentries,
                                             const gchar *key,
                                             GCallback callback,
                                             gpointer cbdata,
                                             gint current);
gboolean    gwy_option_menu_set_history     (GtkWidget *option_menu,
                                             const gchar *key,
                                             gint current);
gint        gwy_option_menu_get_history     (GtkWidget *option_menu,
                                             const gchar *key);

Description

Option menus can be easily constructed from GwyEnum's with gwy_option_menu_create() specifying a key that will be used to define value of each item so that it can be either fetched with g_object_get_data() in a callback function or with gwy_option_menu_get_history().

Here's how a option menu can be constructed:

typedef enum {
   MY_ENUM_FOO, MY_ENUM_BAR, MY_ENUM_BAZ
} MyEnum;

static GwyEnum my_enum_fields[] = {
    { N_("Foo"), MY_ENUM_FOO },
    { N_("Bar"), MY_ENUM_BAR },
    { N_("Baz"), MY_ENUM_BAZ },
};

static void
menu_callback(GObject *item, gpointer cbdata)
{
    MyEnum value;

    value = GPOINTER_TO_UINT(g_object_get_data(item, "my-enum-type"));
    ...
}

static void
function(void) {
    GtkWidget *omenu;
    ...

    omenu = gwy_option_menu_create(fields, G_N_ELEMENTS(fields),
                                   "my-enum-type",
                                   G_CALLBACK(menu_callback), NULL,
                                   MY_ENUM_FOO);
    ...
}

Predefined option menus (and menus) for most standard Gwyddion enums are also provided -- gwy_option_menu_interpolation(), gwy_option_menu_windowin(), etc. Palette and GL material menus can be constructed with gwy_option_menu_palette() (or gwy_menu_palette() for a normal menu), and gwy_option_menu_gl_material() (or gwy_menu_gl_material() for a normal menu).

Details

gwy_menu_gradient ()

GtkWidget*  gwy_menu_gradient               (GCallback callback,
                                             gpointer cbdata);

Creates a pop-up gradient menu.

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
Returns : The newly created pop-up menu as GtkWidget.

gwy_menu_gl_material ()

GtkWidget*  gwy_menu_gl_material            (GCallback callback,
                                             gpointer cbdata);

Creates a pop-up OpenGL material menu.

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
Returns : The newly created pop-up menu as GtkWidget.

gwy_option_menu_gradient ()

GtkWidget*  gwy_option_menu_gradient        (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *current);

Creates a GtkOptionMenu of gradients, alphabetically sorted, with names and small sample images.

It sets object data "gradient-name" to gradient definition name for each menu item.

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : Gradient name to be shown as currently selected (or NULL to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_gl_material ()

GtkWidget*  gwy_option_menu_gl_material     (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *current);

Creates a GtkOptionMenu of OpenGL materials.

It sets object data "material-name" to material definition name for each menu item.

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : Palette definition name to be shown as currently selected (or NULL to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_interpolation ()

GtkWidget*  gwy_option_menu_interpolation   (GCallback callback,
                                             gpointer cbdata,
                                             GwyInterpolationType current);

Creates a GtkOptionMenu of interpolation types i.e., values of GwyInterpolationType.

It sets object data "interpolation-type" to interpolation type for each menu item (use GPOINTER_TO_INT() when retrieving it)..

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : Interpolation type to be shown as currently selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_windowing ()

GtkWidget*  gwy_option_menu_windowing       (GCallback callback,
                                             gpointer cbdata,
                                             GwyWindowingType current);

Creates a GtkOptionMenu of windowing types i.e., values of GwyWindowingType.

It sets object data "windowing-type" to windowing type for each menu item (use GPOINTER_TO_INT() when retrieving it)..

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : Windowing type to be shown as currently selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_2dcwt ()

GtkWidget*  gwy_option_menu_2dcwt           (GCallback callback,
                                             gpointer cbdata,
                                             Gwy2DCWTWaveletType current);

Creates a GtkOptionMenu of available wavelet types.

It sets object data "2dcwt-wavelet-type" to 2D CWT wavelet type for each menu item (use GPOINTER_TO_INT() when retrieving it)..

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : 2D CWT wavelet type to be shown as currently selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_dwt ()

GtkWidget*  gwy_option_menu_dwt             (GCallback callback,
                                             gpointer cbdata,
                                             GwyDWTType current);

Creates a GtkOptionMenu of available wavelet types.

It sets object data "dwt-wavelet-type" to DWT wavelet type for each menu item (use GPOINTER_TO_INT() when retrieving it)..

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : DWT wavelet type to be shown as currently selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_sfunctions_output ()

GtkWidget*  gwy_option_menu_sfunctions_output
                                            (GCallback callback,
                                             gpointer cbdata,
                                             GwySFOutputType current);

Creates a GtkOptionMenu of available one-dimensional statistical functions.

It sets object data "sf-output-type" to statistical functions output type for each menu item (use GPOINTER_TO_INT() when retrieving it).

callback : A callback called when a menu item is activated (or NULL for none).
cbdata : User data passed to the callback.
current : Statistical function output type to be shown as currently selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_orientation ()

GtkWidget*  gwy_option_menu_orientation     (GCallback callback,
                                             gpointer cbdata,
                                             GwyOrientation current);

Creates a GtkOptionMenu of datafield computation orientation available.

It sets object data "orientation-type" to orientation type for each menu item (use GPOINTER_TO_INT() when retrieving it).

callback : A callback called when a menu item is activated (or NULL for
cbdata : User data passed to the callback.
current : Direction selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_merge_type ()

GtkWidget*  gwy_option_menu_merge_type      (GCallback callback,
                                             gpointer cbdata,
                                             GwyMergeType current);

Creates a GtkOptionMenu of available grain merging modes

It sets object data "merge-type" to merge type for each menu item (use GPOINTER_TO_INT() when retrieving it).

callback : A callback called when a menu item is activated (or NULL for
cbdata : User data passed to the callback.
current : Grain merging selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_indentor ()

GtkWidget*  gwy_option_menu_indentor        (GCallback callback,
                                             gpointer cbdata,
                                             GwyIndentorType current);

Creates a GtkOptionMenu of available indentor types

It sets object data "indentor-type" to line fit for each menu item (use GPOINTER_TO_INT() when retrieving it).

callback : A callback called when a menu item is activated (or NULL for
cbdata : User data passed to the callback.
current : Indentor type selected (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_metric_unit ()

GtkWidget*  gwy_option_menu_metric_unit     (GCallback callback,
                                             gpointer cbdata,
                                             gint from,
                                             gint to,
                                             const gchar *unit,
                                             gint current);

Creates a GtkOptionMenu of units with SI prefixes in given range.

It sets object data "metric-unit" to the exponents of 10 for each menu item (use GPOINTER_TO_INT() when retrieving it).

callback : A callback called when a menu item is activated (or NULL for
cbdata : User data passed to the callback.
from : The exponent of 10 the menu should start at (a multiple of 3, will be rounded towards zero if isn't).
to : The exponent of 10 the menu should end at (a multiple of 3, will be rounded towards zero if isn't).
unit : The unit to be prefixed.
current : Exponent of 10 selected (a multiple of 3) (or -1 to use what happens to appear first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_create ()

GtkWidget*  gwy_option_menu_create          (const GwyEnum *entries,
                                             gint nentries,
                                             const gchar *key,
                                             GCallback callback,
                                             gpointer cbdata,
                                             gint current);

Creates an option menu for an enum.

It sets object data identified by key for each menu item to its value. Try to avoid -1 as an enum value.

entries : Option menu items.
nentries : The number of items.
key : Value object data key.
callback : A callback called when a menu item is activated (or NULL for no callback).
cbdata : User data passed to the callback.
current : Value to be shown as currently selected (-1 to use what happens to be first).
Returns : The newly created option menu as GtkWidget.

gwy_option_menu_set_history ()

gboolean    gwy_option_menu_set_history     (GtkWidget *option_menu,
                                             const gchar *key,
                                             gint current);

Sets option menu history based on integer item object data (as set by gwy_option_menu_create()).

option_menu : An option menu created by gwy_option_menu_create().
key : Value object data key. Either the key you specified when called gwy_option_menu_create(), or the key listed in description of particular option menu constructor.
current : Value to be shown as currently selected.
Returns : TRUE if the history was set, FALSE if current was not found.

gwy_option_menu_get_history ()

gint        gwy_option_menu_get_history     (GtkWidget *option_menu,
                                             const gchar *key);

Gets the integer enum value corresponding to currently selected item.

option_menu : An option menu created by gwy_option_menu_create().
key : Value object data key. Either the key you specified when called gwy_option_menu_create(), or the key listed in description of particular option menu constructor.
Returns : The enum value corresponding to currently selected item. In case of failure -1 is returned.

See Also

Radio button constructors