| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
| Safe Haskell | None |
| Language | Haskell2010 |
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_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.
- newtype ToolPalette = ToolPalette (ManagedPtr ToolPalette)
- class GObject o => IsToolPalette o
- toToolPalette :: (MonadIO m, IsToolPalette o) => o -> m ToolPalette
- noToolPalette :: Maybe ToolPalette
- toolPaletteAddDragDest :: (HasCallStack, MonadIO m, IsToolPalette a, IsWidget b) => a -> b -> [DestDefaults] -> [ToolPaletteDragTargets] -> [DragAction] -> m ()
- toolPaletteGetDragItem :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> SelectionData -> m Widget
- toolPaletteGetDragTargetGroup :: (HasCallStack, MonadIO m) => m TargetEntry
- toolPaletteGetDragTargetItem :: (HasCallStack, MonadIO m) => m TargetEntry
- toolPaletteGetDropGroup :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> Int32 -> Int32 -> m (Maybe ToolItemGroup)
- toolPaletteGetDropItem :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> Int32 -> Int32 -> m (Maybe ToolItem)
- toolPaletteGetExclusive :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> m Bool
- toolPaletteGetExpand :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> m Bool
- toolPaletteGetGroupPosition :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> m Int32
- toolPaletteGetHadjustment :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m Adjustment
- toolPaletteGetIconSize :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m Int32
- toolPaletteGetStyle :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m ToolbarStyle
- toolPaletteGetVadjustment :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m Adjustment
- toolPaletteNew :: (HasCallStack, MonadIO m) => m ToolPalette
- toolPaletteSetDragSource :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> [ToolPaletteDragTargets] -> m ()
- toolPaletteSetExclusive :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> Bool -> m ()
- toolPaletteSetExpand :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> Bool -> m ()
- toolPaletteSetGroupPosition :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) => a -> b -> Int32 -> m ()
- toolPaletteSetIconSize :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> Int32 -> m ()
- toolPaletteSetStyle :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> ToolbarStyle -> m ()
- toolPaletteUnsetIconSize :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m ()
- toolPaletteUnsetStyle :: (HasCallStack, MonadIO m, IsToolPalette a) => a -> m ()
- constructToolPaletteIconSize :: IsToolPalette o => IconSize -> IO (GValueConstruct o)
- getToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> m IconSize
- setToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> IconSize -> m ()
- constructToolPaletteIconSizeSet :: IsToolPalette o => Bool -> IO (GValueConstruct o)
- getToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> m Bool
- setToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> Bool -> m ()
- constructToolPaletteToolbarStyle :: IsToolPalette o => ToolbarStyle -> IO (GValueConstruct o)
- getToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> m ToolbarStyle
- setToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> ToolbarStyle -> m ()
Exported types
class GObject o => IsToolPalette o Source #
Instances
toToolPalette :: (MonadIO m, IsToolPalette o) => o -> m ToolPalette Source #
Methods
addDragDest
toolPaletteAddDragDest Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a, IsWidget b) | |
| => a |
|
| -> b |
|
| -> [DestDefaults] |
|
| -> [ToolPaletteDragTargets] |
|
| -> [DragAction] |
|
| -> 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 |
|
| -> 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 |
Get the target entry for a dragged ToolItemGroup.
Since: 2.20
getDragTargetItem
toolPaletteGetDragTargetItem Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m TargetEntry | Returns: the |
Gets the target entry for a dragged ToolItem.
Since: 2.20
getDropGroup
toolPaletteGetDropGroup Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> Int32 |
|
| -> Int32 |
|
| -> m (Maybe ToolItemGroup) | Returns: the |
Gets the group at position (x, y).
Since: 2.20
getDropItem
toolPaletteGetDropItem Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> Int32 |
|
| -> Int32 |
|
| -> m (Maybe ToolItem) | Returns: the |
Gets the item at position (x, y).
See toolPaletteGetDropGroup.
Since: 2.20
getExclusive
toolPaletteGetExclusive Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) | |
| => a |
|
| -> b |
|
| -> m Bool | Returns: |
Gets whether group is exclusive or not.
See toolPaletteSetExclusive.
Since: 2.20
getExpand
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) | |
| => a |
|
| -> b |
|
| -> m Bool | Returns: |
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 |
|
| -> b |
|
| -> m Int32 | Returns: the index of group or -1 if |
Gets the position of group in palette as index.
See toolPaletteSetGroupPosition.
Since: 2.20
getHadjustment
toolPaletteGetHadjustment Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> m Adjustment | Returns: the horizontal adjustment of |
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 |
|
| -> m Int32 | Returns: the |
Gets the size of icons in the tool palette.
See toolPaletteSetIconSize.
Since: 2.20
getStyle
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> m ToolbarStyle | Returns: the |
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 |
|
| -> m Adjustment | Returns: the vertical adjustment of |
Deprecated: (Since version 3.0)Use scrollableGetVadjustment
Gets the vertical adjustment of the tool palette.
Since: 2.20
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m ToolPalette | Returns: a new |
Creates a new tool palette.
Since: 2.20
setDragSource
toolPaletteSetDragSource Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> [ToolPaletteDragTargets] |
|
| -> 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 |
|
| -> b |
|
| -> Bool |
|
| -> 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
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a, IsToolItemGroup b) | |
| => a |
|
| -> b |
|
| -> Bool |
|
| -> 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 |
|
| -> b |
|
| -> Int32 |
|
| -> 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 |
|
| -> Int32 |
|
| -> m () |
Sets the size of icons in the tool palette.
Since: 2.20
setStyle
Arguments
| :: (HasCallStack, MonadIO m, IsToolPalette a) | |
| => a |
|
| -> ToolbarStyle |
|
| -> 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 |
|
| -> 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 |
|
| -> 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
constructToolPaletteIconSize :: IsToolPalette o => IconSize -> IO (GValueConstruct o) Source #
getToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> m IconSize Source #
setToolPaletteIconSize :: (MonadIO m, IsToolPalette o) => o -> IconSize -> m () Source #
iconSizeSet
constructToolPaletteIconSizeSet :: IsToolPalette o => Bool -> IO (GValueConstruct o) Source #
getToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> m Bool Source #
setToolPaletteIconSizeSet :: (MonadIO m, IsToolPalette o) => o -> Bool -> m () Source #
toolbarStyle
constructToolPaletteToolbarStyle :: IsToolPalette o => ToolbarStyle -> IO (GValueConstruct o) Source #
getToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> m ToolbarStyle Source #
setToolPaletteToolbarStyle :: (MonadIO m, IsToolPalette o) => o -> ToolbarStyle -> m () Source #