[Glade-users] problems with glade
- From: albert vorwireless net (Albert)
- Subject: [Glade-users] problems with glade
- Date: 06 Nov 2003 01:41:08 +0100
Hi all, this is my first message in the list, excuse me for my poor
english.
Now I build my first project in glade. It is a button and a text_view. I
want read a text file using fgets and show in the text_view.
I paste de source:
----- interface.c ------------ 8< ------
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
gtk_object_set_data_full (GTK_OBJECT (component), name, \
gtk_widget_ref (widget), (GtkDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
gtk_object_set_data (GTK_OBJECT (component), name, widget)
GtkWidget*
create_tenes777 (void)
{
GtkWidget *tenes777;
GtkWidget *vbox2;
GtkWidget *buto;
GtkWidget *scrolledwindow1;
GtkWidget *textbox;
GtkTextBuffer *buffer;
tenes777 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (tenes777, 300, 300);
gtk_window_set_title (GTK_WINDOW (tenes777), _("Hacklab Tenes777"));
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox2);
gtk_container_add (GTK_CONTAINER (tenes777), vbox2);
buto = gtk_button_new_with_mnemonic (_("recollir"));
gtk_widget_show (buto);
gtk_box_pack_start (GTK_BOX (vbox2), buto, FALSE, FALSE, 0);
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow1);
gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0);
// my code start here:
FILE *correu;
int a, i;
char magatzem[1024];
correu = fopen("/tmp/tenes777","r");
textbox = gtk_text_view_new();
buffer = gtk_text_buffer_new (NULL);
while (!feof(correu)) {
fgets(magatzem, 1000, correu);
a++;
if (strstr(magatzem, "[Tenes777]") != NULL) {
gtk_text_buffer_set_text (buffer, magatzem, -1);
gtk_text_view_set_buffer (GTK_TEXT_VIEW (textbox), buffer);
gtk_widget_show (textbox);
i++;
}
}
///------------end of my code----------------///
gtk_container_add (GTK_CONTAINER (scrolledwindow1), textbox);
gtk_signal_connect (GTK_OBJECT (buto), "clicked",
GTK_SIGNAL_FUNC (on_buto_clicked),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (tenes777, tenes777, "tenes777");
GLADE_HOOKUP_OBJECT (tenes777, vbox2, "vbox2");
GLADE_HOOKUP_OBJECT (tenes777, buto, "buto");
GLADE_HOOKUP_OBJECT (tenes777, scrolledwindow1, "scrolledwindow1");
GLADE_HOOKUP_OBJECT (tenes777, textbox, "textbox");
return tenes777;
}
When execute the program, it returns:
-----------------------------------------8<--------
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
(tenes777:4771): Gtk-CRITICAL **: file gtktextbuffer.c: line 543
(gtk_text_buffer_emit_insert): assertion `g_utf8_validate (text, len,
NULL)' failed
---------------------------------------------------
thanks for you time,
Albert
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]