goocanvas and gtkDialog conflict?



 Hi, I have 2 callback functions, first of them remove previously
created ellipse from a goocanvas, 2nd function creates that ellipse
and places it on the canvas. Everything works just fine if I remove(or
not let it pop up by pressing right mouse button) the GtkDialog widget
(lines 34-47). Once this dialog has poped up everything stops working
properly - I can't anylonger remove ellipse from the canvas, and when
I add a new ellipse its drawn upon already existing one... what's
wrong here?

static gboolean cryoprobe_clicked(GooCanvasItem  *item, GooCanvasItem  *target,
									 GdkEventButton *event, gpointer data)
{
	Surgery *s = (Surgery *) data;
	/* right clicked */
	if (3 == event->button) {
		goo_canvas_item_remove(item);
//		s->getParameters->removeControlpoint(imageNumber, event->x, event->y);
	}
	return TRUE;
}

static gboolean image_clicked(GooCanvasItem  *item, GooCanvasItem  *target,
							  GdkEventButton *event, gpointer data)
{
	Surgery *s = (Surgery *) data;
	GooCanvasItem *ellipse;
	GtkWidget *dialog;

	/* left clicked */
	if (1 == event->button) {
		ellipse = goo_canvas_ellipse_new(item, event->x, event->y, 5, 5,
"fill-color", "red", NULL);
		g_signal_connect(ellipse, "button_press_event",
(GtkSignalFunc)(controlpoint_clicked), s);
//		s->getParameters->addControlpoint(imageNumber, event->x, event->y);
	}
	/* middle clicked */
	if (2 == event->button) {
		ellipse = goo_canvas_ellipse_new(item, event->x, event->y, 5, 5,
"fill-color", "green", NULL);
		g_signal_connect(ellipse, "button_press_event",
(GtkSignalFunc)(thermosensor_clicked), s);
//		s->getParameters->addControlpoint(imageNumber, event->x, event->y);
	}
	/* right clicked */
	if (3 == event->button) {
		dialog = gtk_dialog_new_with_buttons("Adding cryoprobe...",
GTK_WINDOW (s->getGui()->mainWindow), GTK_DIALOG_MODAL,
											 GTK_STOCK_ADD, 1, GTK_STOCK_CANCEL, 2, GTK_STOCK_CLEAR, 3, NULL);
		switch (gtk_dialog_run (GTK_DIALOG (dialog))) {
			case 1:
				g_print("boom 1\n");
				break;
			case 2:
				g_print("boom 2\n");
				break;
			case 3:
				g_print("boom 3\n");
				break;
		}
		gtk_widget_destroy (dialog);
		ellipse = goo_canvas_ellipse_new(item, event->x, event->y, 5, 5,
"fill-color", "blue", NULL);
		g_signal_connect(ellipse, "button_press_event",
(GtkSignalFunc)(cryoprobe_clicked), s);
//		s->getParameters->addControlpoint(imageNumber, event->x, event->y);
	}
	return TRUE;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]