| 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 (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
- 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
newtype ToolPalette Source #
Memory-managed wrapper type.
Constructors
| ToolPalette (ManagedPtr ToolPalette) |
Instances
| GObject ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette Methods gobjectType :: ToolPalette -> IO GType # | |
| IsImplementorIface ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsObject ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsBuildable ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsOrientable ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsScrollable ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsContainer ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsWidget ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsToolPalette ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
class GObject o => IsToolPalette o Source #
Type class for types which can be safely cast to ToolPalette, for instance with toToolPalette.
Instances
| (GObject a, (UnknownAncestorError ToolPalette a :: Constraint)) => IsToolPalette a Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
| IsToolPalette ToolPalette Source # | |
Defined in GI.Gtk.Objects.ToolPalette | |
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.
noToolPalette :: Maybe ToolPalette Source #
A convenience alias for Nothing :: Maybe ToolPalette.
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
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
settoolPalette [ #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
settoolPalette [ #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
settoolPalette [ #toolbarStyle:=value ]