[Jderobot] Error con GTK al generar canvas
vnieto
victornietolobo en gmail.com
Vie Oct 25 10:29:11 CEST 2013
Hola,
Estoy intentando utilizar canvas de la clase Gtk::DrawingArea, siguiendo el
código de introrob. El problema es que me muestra un error en ejecución y no
me muestra nada en la ventana. Os enseño el código y el error:
#include "gui.h"
namespace componente {
Gui::Gui(Api *api) : gtkmain(0, 0) {
this->api = api;
//Inicializaciones
/*Init OpenGL*/
if (!Gtk::GL::init_check(NULL, NULL)) {
std::cerr << "Couldn't initialize GL\n";
std::exit(1);
}
Gnome::Canvas::init();
std::cout << "Loading glade\n";
refXml = Gnome::Glade::Xml::create("./componentegtk.glade");
//Get widgets
refXml->get_widget("secondarywindow", secondarywindow);
refXml->get_widget("label1", label1);
refXml->get_widget("label2", label2);
refXml->get_widget("boton1", boton1);
refXml->get_widget("canvas1", canvas1);
//Eventos
boton1->signal_clicked().connect(sigc::mem_fun(this,
&Gui::boton1_clicked));
//Inicializacon Drawarea
canvas1->signal_unrealize();
canvas1->signal_realize();
canvas1->set_child_visible(TRUE);
gc_laser = Gdk::GC::create(canvas1->get_window());
colormap = canvas1->get_colormap();
color_white = Gdk::Color("#FFFFFF");
color_black = Gdk::Color("#000000");
color_red = Gdk::Color("#FF0000");
colormap->alloc_color(color_white);
colormap->alloc_color(color_black);
colormap->alloc_color(color_red);
secondarywindow->show();
}
void Gui::display() {
gc_laser->set_foreground(color_black);
canvas1->get_window()->draw_rectangle(gc_laser, true, 0, 0,
360, 180);
gc_laser->set_foreground(color_red);
canvas1->get_window()->draw_line(gc_laser, 180, 165, 180,
180);
gc_laser->set_foreground(color_white);
while (gtkmain.events_pending())
gtkmain.iteration();
}
void Gui::boton1_clicked() {
label2->set_text("Me han pulsadooo");
}
}
La salida del error es:
Loading glade
(componente:2422): Gdk-CRITICAL **: IA__gdk_gc_new: assertion `drawable !=
NULL' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_ref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): Gdk-CRITICAL **: IA__gdk_gc_set_foreground: assertion
`GDK_IS_GC (gc)' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_ref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): Gdk-CRITICAL **: IA__gdk_draw_rectangle: assertion
`GDK_IS_GC (gc)' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): Gdk-CRITICAL **: IA__gdk_gc_set_foreground: assertion
`GDK_IS_GC (gc)' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_ref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): Gdk-CRITICAL **: IA__gdk_draw_line: assertion `GDK_IS_GC
(gc)' failed
(componente:2422): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed
(componente:2422): Gdk-CRITICAL **: IA__gdk_gc_set_foreground: assertion
`GDK_IS_GC (gc)' failed
Un saludo!
--
View this message in context: http://jderobot-developer-list.2315034.n4.nabble.com/Error-con-GTK-al-generar-canvas-tp4641758.html
Sent from the Jderobot Developer List mailing list archive at Nabble.com.
More information about the Jde-developers
mailing list