|
[+] programowanie z pomocą glade i c
szuwar7 - 11-02-2010 11:13
Próbuję nauczyć się programowania przy użyciu glade. Chcę napisać jakikolwiek program np. wyświetlanie okna. Kompiluje się bez problemu ale po uruchomieniu wyświetla następujące błędy (okno też się nie wyświetla):
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
(process:10491368): libglade-CRITICAL **: glade_xml_construct: assertion `self != NULL' failed
(process:10491368): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(process:10491368): libglade-CRITICAL **: glade_xml_signal_autoconnect: assertion `self != NULL' failed
(process:10491368): libglade-CRITICAL **: glade_xml_get_widget: assertion `self != NULL' failed
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:10491368): GLib-GObject-CRITICAL **: /home/joss/deb/pkg-gnome/desktop/lenny/build-area/glib2.0-2.16.6/gobject/gtype.c:2248: initialization assertion failed, use IA__g_type_init() prior to this function
(process:10491368): GLib-GObject-CRITICAL **: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:10491368): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed
Oto program:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> #include <glade/glade.h>
int main(int argc, char *argv[]) {
GladeXML *xml; GtkWidget *window1;
xml = glade_xml_new("projekt2.glade", "MyWindow", 0);
glade_xml_signal_autoconnect (xml);
window1 = glade_xml_get_widget (xml, "window1"); gtk_widget_show (window1);
gtk_main ();
}
Kod wygenerowany przez glade:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<glade-interface> <widget class="GtkWindow" id="window1"> <child> <placeholder/> </child> </widget> </glade-interface>
Kompiluję przez:
gcc -o progr2.o progr2.c `pkg-config --cflags --libs libglade-2.0`
grzesiek - 11-02-2010 11:20
Zapewne chodzi o to, że nie wywołujesz
gtk_init(&argc,&argv);
Kiedyś to opisałem http://pl.wikibooks.org/wiki/GTK%2B/...czy_interfejsu
szuwar7 - 11-02-2010 11:24
Dodałem i teraz mam:
(progr2.o:10491472): libglade-CRITICAL **: glade_xml_build_interface: assertion `wid != NULL' failed
(progr2.o:10491472): Gtk-CRITICAL **: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)' failed
Dla potomnych.
Zły argument w glade_xml_new. powinno być:
xml = glade_xml_new("/home/mduczkowski/projekt2.glade", NULL,NULL);
Teraz działa.
zanotowane.pldoc.pisz.plpdf.pisz.plminister.pev.pl
|