void glade_gtk_tool_palette_get_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * property_name, GValue * value) { g_return_if_fail (GTK_IS_TOOL_PALETTE (container)); if (GTK_IS_TOOL_ITEM_GROUP (child) == FALSE) return; if (strcmp (property_name, "position") == 0) { g_value_set_int (value, gtk_tool_palette_get_group_position (GTK_TOOL_PALETTE (container), GTK_TOOL_ITEM_GROUP (child))); } else { /* Chain Up */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_get_property (adaptor, container, child, property_name, value); } }
static void interactive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); GtkWidget *tool_item = NULL; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); /* create a drop indicator when a tool button was found */ g_assert (NULL == drop_item); if (GTK_IS_TOOL_ITEM (tool_item)) { drop_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); gdk_drag_status (context, GDK_ACTION_COPY, time); gtk_widget_queue_draw (widget); } }
void glade_gtk_tool_palette_add_child (GladeWidgetAdaptor * adaptor, GObject * object, GObject * child) { GtkToolPalette *palette; GtkToolItemGroup *group; g_return_if_fail (GTK_IS_TOOL_PALETTE (object)); g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child)); palette = GTK_TOOL_PALETTE (object); group = GTK_TOOL_ITEM_GROUP (child); gtk_container_add (GTK_CONTAINER (palette), GTK_WIDGET (group)); if (glade_util_object_is_loading (object)) { GladeWidget *gchild = glade_widget_get_from_gobject (child); /* Packing props arent around when parenting during a glade_widget_dup() */ if (gchild && glade_widget_get_packing_properties (gchild)) glade_widget_pack_property_set (gchild, "position", gtk_tool_palette_get_group_position (palette, group)); } }
static void interactive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); GtkWidget *tool_item = NULL; CanvasItem *item; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); /* create a canvas item when a tool button was found */ g_assert (NULL == drop_item); if (!GTK_IS_TOOL_ITEM (tool_item)) return; if (drop_item) { canvas_item_free (drop_item); drop_item = NULL; } item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); /* Either create a new item or just create a preview item, depending on why the drag data was requested. */ if(drag_data_requested_for_drop) { canvas_items = g_list_append (canvas_items, item); drop_item = NULL; gtk_drag_finish (context, TRUE, FALSE, time); } else { drop_item = item; gdk_drag_status (context, GDK_ACTION_COPY, time); } gtk_widget_queue_draw (widget); }
static void palette_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { GtkAllocation allocation; GtkToolItemGroup *drop_group = NULL; GtkWidget *drag_palette = gtk_drag_get_source_widget (context); GtkWidget *drag_item = NULL; while (drag_palette && !GTK_IS_TOOL_PALETTE (drag_palette)) drag_palette = gtk_widget_get_parent (drag_palette); if (drag_palette) { drag_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (drag_palette), selection); drop_group = gtk_tool_palette_get_drop_group (GTK_TOOL_PALETTE (widget), x, y); } if (GTK_IS_TOOL_ITEM_GROUP (drag_item)) palette_drop_group (GTK_TOOL_PALETTE (drag_palette), GTK_TOOL_ITEM_GROUP (drag_item), drop_group); else if (GTK_IS_TOOL_ITEM (drag_item) && drop_group) { gtk_widget_get_allocation (GTK_WIDGET (drop_group), &allocation); palette_drop_item (GTK_TOOL_ITEM (drag_item), drop_group, x - allocation.x, y - allocation.y); } }
static void passive_canvas_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time, gpointer data) { /* find the tool button, which is the source of this DnD operation */ GtkWidget *palette = gtk_drag_get_source_widget (context); CanvasItem *canvas_item = NULL; GtkWidget *tool_item = NULL; while (palette && !GTK_IS_TOOL_PALETTE (palette)) palette = gtk_widget_get_parent (palette); if (palette) tool_item = gtk_tool_palette_get_drag_item (GTK_TOOL_PALETTE (palette), selection); g_assert (NULL == drop_item); /* append a new canvas item when a tool button was found */ if (GTK_IS_TOOL_ITEM (tool_item)) canvas_item = canvas_item_new (widget, GTK_TOOL_BUTTON (tool_item), x, y); if (canvas_item) { canvas_items = g_list_append (canvas_items, canvas_item); gtk_widget_queue_draw (widget); } }
void glade_gtk_tool_palette_set_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * property_name, GValue * value) { g_return_if_fail (GTK_IS_TOOL_PALETTE (container)); g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (child)); g_return_if_fail (property_name != NULL || value != NULL); if (strcmp (property_name, "position") == 0) { GtkToolPalette *palette = GTK_TOOL_PALETTE (container); GList *children; gint position, size; children = glade_util_container_get_all_children (GTK_CONTAINER (palette)); size = g_list_length (children); g_list_free (children); position = g_value_get_int (value); if (position >= size) position = size - 1; gtk_tool_palette_set_group_position (palette, GTK_TOOL_ITEM_GROUP (child), position); } else /* Chain Up */ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_set_property (adaptor, container, child, property_name, value); }