[]Struct gtk::ToolPalette

pub struct ToolPalette(_, _);

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 ToolPalette::new.

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 ContainerExt::add.

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 ToolPaletteExt::add_drag_dest with the desired drag source palette and the desired drag target widget. Then ToolPaletteExt::get_drag_item can be used to get the dragged item in the Widget::drag-data-received signal handler of the drag target.

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

ToolPalette has a single CSS node named toolpalette.

Implements

ToolPaletteExt, ContainerExt, WidgetExt, glib::object::ObjectExt, BuildableExt, OrientableExt, ScrollableExt, WidgetExtManual, BuildableExtManual

Implementations

impl ToolPalette[src]

pub fn new() -> ToolPalette[src]

Creates a new tool palette.

Returns

a new ToolPalette

pub fn get_drag_target_group() -> Option<TargetEntry>[src]

Get the target entry for a dragged ToolItemGroup.

Returns

the TargetEntry for a dragged group

pub fn get_drag_target_item() -> Option<TargetEntry>[src]

Gets the target entry for a dragged ToolItem.

Returns

the TargetEntry for a dragged item.

Trait Implementations

impl Clone for ToolPalette

impl Debug for ToolPalette

impl Default for ToolPalette[src]

impl Display for ToolPalette[src]

impl Eq for ToolPalette

impl Hash for ToolPalette

impl IsA<Buildable> for ToolPalette

impl IsA<Container> for ToolPalette

impl IsA<Orientable> for ToolPalette

impl IsA<Scrollable> for ToolPalette

impl IsA<Widget> for ToolPalette

impl Ord for ToolPalette

impl<T: ObjectType> PartialEq<T> for ToolPalette

impl<T: ObjectType> PartialOrd<T> for ToolPalette

impl StaticType for ToolPalette

Auto Trait Implementations

impl RefUnwindSafe for ToolPalette

impl !Send for ToolPalette

impl !Sync for ToolPalette

impl Unpin for ToolPalette

impl UnwindSafe for ToolPalette

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *const GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GPtrArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<PtrArray>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.