gwyoptionmenus

gwyoptionmenus — Option menu constructors for enums

Synopsis




GtkWidget*  gwy_menu_gradient               (GCallback callback,
                                             gpointer cbdata);
GtkWidget*  gwy_gradient_selection_new      (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);
GtkWidget*  gwy_gradient_tree_view_new      (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);
gboolean    gwy_gradient_tree_view_set_active
                                            (GtkWidget *treeview,
                                             const gchar *active);
const gchar* gwy_gradient_selection_get_active
                                            (GtkWidget *selection);
void        gwy_gradient_selection_set_active
                                            (GtkWidget *selection,
                                             const gchar *active);
GtkWidget*  gwy_menu_gl_material            (GCallback callback,
                                             gpointer cbdata);
GtkWidget*  gwy_gl_material_selection_new   (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);
GtkWidget*  gwy_gl_material_tree_view_new   (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);
gboolean    gwy_gl_material_tree_view_set_active
                                            (GtkWidget *treeview,
                                             const gchar *active);
const gchar* gwy_gl_material_selection_get_active
                                            (GtkWidget *selection);
void        gwy_gl_material_selection_set_active
                                            (GtkWidget *selection,
                                             const gchar *active);

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.

Object data "gradient-name" is set to gradient 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.
Returns : The newly created pop-up menu as GtkWidget.

gwy_gradient_selection_new ()

GtkWidget*  gwy_gradient_selection_new      (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);

Creates a gradient selection button.

callback : Callback to connect to "changed" signal of tree view selection (or NULL for none).
cbdata : User data passed to callback.
active : Gradient name to be shown as currently selected (or NULL for default).
Returns : The newly created gradient selection button as GtkWidget.

gwy_gradient_tree_view_new ()

GtkWidget*  gwy_gradient_tree_view_new      (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);

Creates a tree view with gradient list.

callback : Callback to connect to "changed" signal of tree view selection (or NULL for none).
cbdata : User data passed to callback.
active : Gradient name to be shown as currently selected (or NULL for default).
Returns : The newly created gradient tree view as GtkWidget.

gwy_gradient_tree_view_set_active ()

gboolean    gwy_gradient_tree_view_set_active
                                            (GtkWidget *treeview,
                                             const gchar *active);

Selects a gradient in a gradient list and scrolls to make it visible.

treeview : A gradient selector tree view.
active : Gradient name to be shown as currently selected.
Returns : TRUE if active was selected, FALSE if there is no such gradient.

gwy_gradient_selection_get_active ()

const gchar* gwy_gradient_selection_get_active
                                            (GtkWidget *selection);

Gets the name of currently selected gradient of a selection button.

selection : Gradient selection button.
Returns : Name as a string owned by the selected gradient.

gwy_gradient_selection_set_active ()

void        gwy_gradient_selection_set_active
                                            (GtkWidget *selection,
                                             const gchar *active);

Sets the currently selected gradient of a selection button.

selection : Gradient selection button.
active : Gradient name to be shown as currently selected.

gwy_menu_gl_material ()

GtkWidget*  gwy_menu_gl_material            (GCallback callback,
                                             gpointer cbdata);

Creates a pop-up GL material menu.

Object data "gl-material-name" is set to GL material 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.
Returns : The newly created pop-up menu as GtkWidget.

gwy_gl_material_selection_new ()

GtkWidget*  gwy_gl_material_selection_new   (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);

Creates a GL material selection button.

callback : Callback to connect to "changed" signal of tree view selection (or NULL for none).
cbdata : User data passed to callback.
active : GL material name to be shown as currently selected (or NULL for default).
Returns : The newly created GL material selection button as GtkWidget.

gwy_gl_material_tree_view_new ()

GtkWidget*  gwy_gl_material_tree_view_new   (GCallback callback,
                                             gpointer cbdata,
                                             const gchar *active);

Creates a tree view with GL material list.

callback : Callback to connect to "changed" signal of tree view selection (or NULL for none).
cbdata : User data passed to callback.
active : GL material name to be shown as currently selected (or NULL for default).
Returns : The newly created GL material tree view as GtkWidget.

gwy_gl_material_tree_view_set_active ()

gboolean    gwy_gl_material_tree_view_set_active
                                            (GtkWidget *treeview,
                                             const gchar *active);

Selects a GL material in a GL material list and scrolls to make it visible.

treeview : A GL material selector tree view.
active : GL material name to be shown as currently selected.
Returns : TRUE if active was selected, FALSE if there is no such GL material.

gwy_gl_material_selection_get_active ()

const gchar* gwy_gl_material_selection_get_active
                                            (GtkWidget *selection);

Gets the name of currently selected GL material of a selection button.

selection : GL material selection button.
Returns : Name as a string owned by the selected GL material.

gwy_gl_material_selection_set_active ()

void        gwy_gl_material_selection_set_active
                                            (GtkWidget *selection,
                                             const gchar *active);

Sets the currently selected GL material of a selection button.

selection : GL material selection button.
active : GL material name to be shown as currently selected.

See Also

Radio button constructors