gi-gtk-3.0.24: Gtk bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.ToolPalette

Contents

Description

A ToolPalette allows you to add GtkToolItems to a palette-like container with different categories and drag and drop support.

A ToolPalette is created with a call to toolPaletteNew.

GtkToolItems cannot be added directly to a ToolPalette - instead they are added to a ToolItemGroup which can than be added to a ToolPalette. To add a ToolItemGroup to a ToolPalette, use containerAdd.

C code

GtkWidget *palette, *group;
GtkToolItem *item;

palette = gtk_tool_palette_new ();
group = gtk_tool_item_group_new (_("Test Category"));
gtk_container_add (GTK_CONTAINER (palette), group);

item = gtk_tool_button_new (NULL, _("_Open"));
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "document-open");
gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);

The easiest way to use drag and drop with ToolPalette is to call toolPaletteAddDragDest with the desired drag source palette and the desired drag target widget. Then toolPaletteGetDragItem can be used to get the dragged item in the Widget::drag-data-received signal handler of the drag target.

C code

static void
passive_canvas_drag_data_received (GtkWidget        *widget,
                                   GdkDragContext   *context,
                                   gint              x,
                                   gint              y,
                                   GtkSelectionData *selection,
                                   guint             info,
                                   guint             time,
                                   gpointer          data)
{
  GtkWidget *palette;
  GtkWidget *item;

  // Get the dragged item
  palette = gtk_widget_get_ancestor (gtk_drag_get_source_widget (context),
                                     GTK_TYPE_TOOL_PALETTE);
  if (palette != NULL)
    item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette),
                                           selection);

  // Do something with item
}

GtkWidget *target, palette;

palette = gtk_tool_palette_new ();
target = gtk_drawing_area_new ();

g_signal_connect (G_OBJECT (target), "drag-data-received",
                  G_CALLBACK (passive_canvas_drag_data_received), NULL);
gtk_tool_palette_add_drag_dest (GTK_TOOL_PALETTE (palette), target,
                                GTK_DEST_DEFAULT_ALL,
                                GTK_TOOL_PALETTE_DRAG_ITEMS,
                                GDK_ACTION_COPY);

CSS nodes

GtkToolPalette has a single CSS node named toolpalette.

Synopsis

Exported types

class GObject o => IsToolPalette o Source #

Type class for types which can be safely cast to ToolPalette, for instance with toToolPalette.

toToolPalette :: (MonadIO m, IsToolPalette o) => o -> m ToolPalette Source #

Cast to ToolPalette, for types for which this is known to be safe. For general casts, use castTo.

Methods

addDragDest

toolPaletteAddDragDest Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsWidget b) 
=> a

palette: a ToolPalette

-> b

widget: a Widget which should be a drag destination for palette

-> [DestDefaults]

flags: the flags that specify what actions GTK+ should take for drops on that widget

-> [ToolPaletteDragTargets]

targets: the ToolPaletteDragTargets which the widget should support

-> [DragAction]

actions: the GdkDragActions which the widget should suppport

-> m () 

Sets palette as drag source (see toolPaletteSetDragSource) and sets widget as a drag destination for drags from palette. See widgetDragDestSet.

Since: 2.20

getDragItem

toolPaletteGetDragItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> SelectionData

selection: a SelectionData

-> m Widget

Returns: the dragged item in selection

Get the dragged item from the selection. This could be a ToolItem or a ToolItemGroup.

Since: 2.20

getDragTargetGroup

toolPaletteGetDragTargetGroup Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m TargetEntry

Returns: the TargetEntry for a dragged group

Get the target entry for a dragged ToolItemGroup.

Since: 2.20

getDragTargetItem

toolPaletteGetDragTargetItem Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m TargetEntry

Returns: the TargetEntry for a dragged item.

Gets the target entry for a dragged ToolItem.

Since: 2.20

getDropGroup

toolPaletteGetDropGroup Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> Int32

x: the x position

-> Int32

y: the y position

-> m (Maybe ToolItemGroup)

Returns: the ToolItemGroup at position or Nothing if there is no such group

Gets the group at position (x, y).

Since: 2.20

getDropItem

toolPaletteGetDropItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> Int32

x: the x position

-> Int32

y: the y position

-> m (Maybe ToolItem)

Returns: the ToolItem at position or Nothing if there is no such item

Gets the item at position (x, y). See toolPaletteGetDropGroup.

Since: 2.20

getExclusive

toolPaletteGetExclusive Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup which is a child of palette

-> m Bool

Returns: True if group is exclusive

Gets whether group is exclusive or not. See toolPaletteSetExclusive.

Since: 2.20

getExpand

toolPaletteGetExpand Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup which is a child of palette

-> m Bool

Returns: True if group should be given extra space, False otherwise

Gets whether group should be given extra space. See toolPaletteSetExpand.

Since: 2.20

getGroupPosition

toolPaletteGetGroupPosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup

-> m Int32

Returns: the index of group or -1 if group is not a child of palette

Gets the position of group in palette as index. See toolPaletteSetGroupPosition.

Since: 2.20

getHadjustment

toolPaletteGetHadjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m Adjustment

Returns: the horizontal adjustment of palette

Deprecated: (Since version 3.0)Use scrollableGetHadjustment

Gets the horizontal adjustment of the tool palette.

Since: 2.20

getIconSize

toolPaletteGetIconSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m Int32

Returns: the IconSize of icons in the tool palette

Gets the size of icons in the tool palette. See toolPaletteSetIconSize.

Since: 2.20

getStyle

toolPaletteGetStyle Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m ToolbarStyle

Returns: the ToolbarStyle of items in the tool palette.

Gets the style (icons, text or both) of items in the tool palette.

Since: 2.20

getVadjustment

toolPaletteGetVadjustment Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m Adjustment

Returns: the vertical adjustment of palette

Deprecated: (Since version 3.0)Use scrollableGetVadjustment

Gets the vertical adjustment of the tool palette.

Since: 2.20

new

toolPaletteNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m ToolPalette

Returns: a new ToolPalette

Creates a new tool palette.

Since: 2.20

setDragSource

toolPaletteSetDragSource Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> [ToolPaletteDragTargets]

targets: the ToolPaletteDragTargets which the widget should support

-> m () 

Sets the tool palette as a drag source. Enables all groups and items in the tool palette as drag sources on button 1 and button 3 press with copy and move actions. See widgetDragSourceSet.

Since: 2.20

setExclusive

toolPaletteSetExclusive Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup which is a child of palette

-> Bool

exclusive: whether the group should be exclusive or not

-> m () 

Sets whether the group should be exclusive or not. If an exclusive group is expanded all other groups are collapsed.

Since: 2.20

setExpand

toolPaletteSetExpand Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup which is a child of palette

-> Bool

expand: whether the group should be given extra space

-> m () 

Sets whether the group should be given extra space.

Since: 2.20

setGroupPosition

toolPaletteSetGroupPosition Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) 
=> a

palette: a ToolPalette

-> b

group: a ToolItemGroup which is a child of palette

-> Int32

position: a new index for group

-> m () 

Sets the position of the group as an index of the tool palette. If position is 0 the group will become the first child, if position is -1 it will become the last child.

Since: 2.20

setIconSize

toolPaletteSetIconSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> Int32

iconSize: the IconSize that icons in the tool palette shall have

-> m () 

Sets the size of icons in the tool palette.

Since: 2.20

setStyle

toolPaletteSetStyle Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> ToolbarStyle

style: the ToolbarStyle that items in the tool palette shall have

-> m () 

Sets the style (text, icons or both) of items in the tool palette.

Since: 2.20

unsetIconSize

toolPaletteUnsetIconSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m () 

Unsets the tool palette icon size set with toolPaletteSetIconSize, so that user preferences will be used to determine the icon size.

Since: 2.20

unsetStyle

toolPaletteUnsetStyle Source #

Arguments

:: (HasCallStack, MonadIO m, IsToolPalette a) 
=> a

palette: a ToolPalette

-> m () 

Unsets a toolbar style set with toolPaletteSetStyle, so that user preferences will be used to determine the toolbar style.

Since: 2.20

Properties

iconSize

The size of the icons in a tool palette. When this property is set, it overrides the default setting.

This should only be used for special-purpose tool palettes, normal application tool palettes should respect the user preferences for the size of icons.

Since: 2.20

constructToolPaletteIconSize :: IsToolPalette o => IconSize -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “icon-size” property. This is rarely needed directly, but it is used by new.

getToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> m IconSize Source #

Get the value of the “icon-size” property. When overloading is enabled, this is equivalent to

get toolPalette #iconSize

setToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> IconSize -> m () Source #

Set the value of the “icon-size” property. When overloading is enabled, this is equivalent to

set toolPalette [ #iconSize := value ]

iconSizeSet

Is True if the ToolPalette:icon-size property has been set.

Since: 2.20

constructToolPaletteIconSizeSet :: IsToolPalette o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “icon-size-set” property. This is rarely needed directly, but it is used by new.

getToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> m Bool Source #

Get the value of the “icon-size-set” property. When overloading is enabled, this is equivalent to

get toolPalette #iconSizeSet

setToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> Bool -> m () Source #

Set the value of the “icon-size-set” property. When overloading is enabled, this is equivalent to

set toolPalette [ #iconSizeSet := value ]

toolbarStyle

The style of items in the tool palette.

Since: 2.20

constructToolPaletteToolbarStyle :: IsToolPalette o => ToolbarStyle -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “toolbar-style” property. This is rarely needed directly, but it is used by new.

getToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> m ToolbarStyle Source #

Get the value of the “toolbar-style” property. When overloading is enabled, this is equivalent to

get toolPalette #toolbarStyle

setToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> ToolbarStyle -> m () Source #

Set the value of the “toolbar-style” property. When overloading is enabled, this is equivalent to

set toolPalette [ #toolbarStyle := value ]