Make adding symbols to the diagram possible.

This required creating a simple framework for operations to LdCanvas.
It is probable that it's going to require some changes when other
operations are added. The basic idea behind it seems to be good, though.
This commit is contained in:
2011-01-04 09:54:05 +01:00
parent 713f2821e4
commit d3e5483c84
3 changed files with 277 additions and 3 deletions

View File

@@ -761,7 +761,25 @@ on_canvas_button_release (GtkWidget *widget, GdkEventButton *event,
if (event->button != 1)
return FALSE;
/* TODO: Add the selected symbol into the document on the position. */
if (data->active_item != -1)
{
LdDiagramSymbol *symbol;
const gchar *category_name, *symbol_name;
gchar *klass;
category_name = ld_symbol_category_get_name
(g_object_get_data (G_OBJECT (data->active_button), "category"));
symbol_name = ld_symbol_get_name
(data->items[data->active_item].symbol);
klass = g_build_path (LD_LIBRARY_IDENTIFIER_SEPARATOR,
category_name, symbol_name, NULL);
symbol = ld_diagram_symbol_new (klass);
g_free (klass);
ld_canvas_add_object_begin (self->priv->canvas,
LD_DIAGRAM_OBJECT (symbol));
}
/* We've either chosen a symbol or canceled the menu, so hide it. */
if (data->active_button)