GtkToolPalette

Description

A tool palette with categories

Methods and Functions

gtkToolPaletteNew(show = TRUE)
gtkToolPaletteGetExclusive(object, group)
gtkToolPaletteSetExclusive(object, group, exclusive)
gtkToolPaletteGetExpand(object, group)
gtkToolPaletteSetExpand(object, group, expand)
gtkToolPaletteGetGroupPosition(object, group)
gtkToolPaletteSetGroupPosition(object, group, position)
gtkToolPaletteGetIconSize(object)
gtkToolPaletteSetIconSize(object, icon.size)
gtkToolPaletteUnsetIconSize(object)
gtkToolPaletteGetStyle(object)
gtkToolPaletteSetStyle(object, style)
gtkToolPaletteUnsetStyle(object)
gtkToolPaletteAddDragDest(object, widget, flags, targets, actions)
gtkToolPaletteGetDragItem(object, selection)
gtkToolPaletteGetDragTargetGroup()
gtkToolPaletteGetDragTargetItem()
gtkToolPaletteGetDropGroup(object, x, y)
gtkToolPaletteGetDropItem(object, x, y)
gtkToolPaletteSetDragSource(object, targets)
gtkToolPaletteGetHadjustment(object)
gtkToolPaletteGetVadjustment(object)
gtkToolPalette(show = TRUE)

Hierarchy

1
2
3
4
5
6
GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkToolPalette

Interfaces

GtkToolPalette implements AtkImplementorIface, GtkBuildable and GtkOrientable.

Detailed Description

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

A GtkToolPalette is created with a call to gtkToolPaletteNew. GtkToolItems cannot be added directly to a GtkToolPalette - instead they are added to a GtkToolItemGroup which can than be added to a GtkToolPalette. To add a GtkToolItemGroup to a GtkToolPalette, use gtkContainerAdd.

1
2
3
4
5
6
7
8
9
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_from_stock (GTK_STOCK_OK);
gtk_tool_item_group_insert (GTK_TOOL_ITEM_GROUP (group), item, -1);

The easiest way to use drag and drop with GtkToolPalette is to call gtkToolPaletteAddDragDest with the desired drag source palette and the desired drag target widget. Then gtkToolPaletteGetDragItem can be used to get the dragged item in the "drag-data-received" signal handler of the drag target.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);

Structures

GtkToolPalette

This should not be accessed directly. Use the accessor functions below.

Convenient Construction

gtkToolPalette is the equivalent of gtkToolPaletteNew.

Enums and Flags

GtkToolPaletteDragTargets

Flags used to specify the supported drag targets.

items

Support drag of items.

groups

Support drag of groups.

Signals

set-scroll-adjustments(widget, hadjustment, vadjustment, user.data)

Set the scroll adjustments for the viewport. Usually scrolled containers like GtkScrolledWindow will emit this signal to connect two instances of GtkScrollbar to the scroll directions of the GtkToolpalette. Since 2.20

widget

the GtkToolPalette that received the signal

hadjustment

The horizontal adjustment

vadjustment

The vertical adjustment

user.data

user data set when the signal handler was connected.

Properties

icon-size [GtkIconSize : Read / Write]

The size of the icons in a tool palette is normally determined by the "toolbar-icon-size" setting. When this property is set, it overrides the 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. Default value: GTK_ICON_SIZE_SMALL_TOOLBAR Since 2.20

icon-size-set [logical : Read / Write]

Is TRUE if the "icon-size" property has been set. Default value: FALSE Since 2.20

toolbar-style [GtkToolbarStyle : Read / Write]

The style of items in the tool palette. Default value: GTK_TOOLBAR_ICONS Since 2.20

Author(s)

Derived by RGtkGen from GTK+ documentation

References

http://library.gnome.org/devel//gtk/GtkToolPalette.html

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.