showing a txt file in a dialog
- From: rupert <rupertt gmail com>
- To: gtk-app-devel-list gnome org
- Subject: showing a txt file in a dialog
- Date: Mon, 13 Mar 2006 21:23:43 +0100
Hello,
im trying to create a dialog that show me the content of a textfile.
I already got it working in a standalone application, now im trying to
intregrate this into my main app.
The text is shown, but in a really small window, i also would like to know
if this is the right way i should
handle/do this. I dont wanna gedit or something.
tags = gtk_text_tag_table_new();
puffer = gtk_text_buffer_new(tags);
ansicht2 = gtk_text_view_new_with_buffer(puffer);
g_object_set(ansicht,"wrap-mode", GTK_WRAP_WORD, NULL);
FILE *fp = fopen("/media/Data/readme.txt", "r");
gchar text2[]="hallo";
gchar line[512];
if (fp)
{
while (fgets(line, sizeof(line), fp))
{
gtk_text_buffer_insert_at_cursor(puffer, line, -1);
}
fclose(fp);
}
rollen2 = g_object_new(GTK_TYPE_SCROLLED_WINDOW, NULL);
gtk_container_add(GTK_CONTAINER(rollen2), GTK_WIDGET(ansicht2));
hbuttonbox = gtk_hbutton_box_new ();
gtk_widget_show (hbuttonbox);
quit2 = gtk_button_new_with_mnemonic(("Quit"));
gtk_box_pack_start(GTK_BOX(hbuttonbox), GTK_WIDGET(quit2), TRUE, TRUE,
10);
g_signal_connect_swapped(quit2,"clicked",G_CALLBACK(ende), NULL);
vbox2 = g_object_new(GTK_TYPE_VBOX, NULL);
gtk_box_pack_start_defaults(GTK_BOX(vbox2), GTK_WIDGET(rollen2));
gtk_box_pack_end(GTK_BOX(vbox2), GTK_WIDGET(hbuttonbox), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(dialog->vbox), GTK_WIDGET(vbox2), FALSE, FALSE,
0);
gtk_container_add(GTK_CONTAINER(dialog), GTK_WIDGET(vbox));
g_signal_connect_swapped(manual,"clicked",G_CALLBACK(gtk_widget_show_all),dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]