void gdl_dock_add_item (GdlDock *dock, GdlDockItem *item, GdlDockPlacement placement) { g_return_if_fail (dock != NULL); g_return_if_fail (item != NULL); if (placement == GDL_DOCK_FLOATING) /* Add the item to a new floating dock */ gdl_dock_add_floating_item (dock, item, 0, 0, -1, -1); else { GdlDockItem *best_dock_item; /* Non-floating item. */ if (dock->root) { GdlDockPlacement local_placement; GtkRequisition preferred_size; best_dock_item = gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root), placement, 0); local_placement = gdl_dock_refine_placement (dock, best_dock_item, placement); if(local_placement != placement) gwarn("placement changed"); gdl_dock_object_dock (GDL_DOCK_OBJECT (best_dock_item), GDL_DOCK_OBJECT (item), local_placement, NULL); } else { gdl_dock_object_dock (GDL_DOCK_OBJECT (dock), GDL_DOCK_OBJECT (item), placement, NULL); } } }
/** * gdl_dock_add_item: * @dock: A #GdlDock widget * @item: A #GdlDockItem widget * @placement: A position for the widget * * Dock in @dock, the widget @item at the position defined by @placement. The * function takes care of finding the right parent widget eventually creating * it if needed. */ void gdl_dock_add_item (GdlDock *dock, GdlDockItem *item, GdlDockPlacement placement) { GdlDockObject *placeholder; GdlDockObject *parent = NULL; GdlDockPlacement place; g_return_if_fail (dock != NULL); g_return_if_fail (item != NULL); /* Check if a placeholder widget already exist in the same dock */ placeholder = gdl_dock_master_get_object (GDL_DOCK_MASTER (gdl_dock_object_get_master (GDL_DOCK_OBJECT (dock))), gdl_dock_object_get_name (GDL_DOCK_OBJECT (item))); if ((placeholder != GDL_DOCK_OBJECT (item)) && (placeholder != NULL)) { if (gdl_dock_object_get_toplevel (placeholder) == dock) { parent = gdl_dock_object_get_parent_object (placeholder); } else { gtk_widget_destroy (GTK_WIDGET (placeholder)); } } if (parent && gdl_dock_object_child_placement (parent, placeholder, &place)) { gdl_dock_object_freeze (GDL_DOCK_OBJECT (parent)); gtk_widget_destroy (GTK_WIDGET (placeholder)); gdl_dock_object_dock (GDL_DOCK_OBJECT (parent), GDL_DOCK_OBJECT (item), place, NULL); gdl_dock_object_thaw (GDL_DOCK_OBJECT (parent)); } else if (placement == GDL_DOCK_FLOATING) /* Add the item to a new floating dock */ gdl_dock_add_floating_item (dock, item, 0, 0, -1, -1); else { GdlDockItem *best_dock_item; /* Non-floating item. */ if (dock->priv->root) { GdlDockPlacement local_placement; GtkRequisition preferred_size; best_dock_item = gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->priv->root), placement, 0); local_placement = gdl_dock_refine_placement (dock, best_dock_item, placement); gdl_dock_object_dock (GDL_DOCK_OBJECT (best_dock_item), GDL_DOCK_OBJECT (item), local_placement, NULL); } else { gdl_dock_object_dock (GDL_DOCK_OBJECT (dock), GDL_DOCK_OBJECT (item), placement, NULL); } } }