Re: showing a txt file in a dialog
- From: rupert <rupertt gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: showing a txt file in a dialog
- Date: Tue, 14 Mar 2006 08:51:41 +0100
Ok, it was the wrong way, goob it wroking with a function that creates a new
window,
so the last question is how iu can call a quit signal to close this window
and leave the main window open?
void show_readme(GtkTreeSelection *auswahl, gpointer data){
GtkTreeIter iter;
GtkTreeModel *model = NULL;
//DIALOG
GtkWindow *window2;
GtkDialog *dialog;
GtkHBox *dialog_hbox;
GtkImage *dialog_icon;
GtkLabel *dialog_text;
GtkTextTagTable *tags;
GtkTextView *ansicht2;
GtkScrolledWindow *rollen2;
GtkVBox *vbox2;
GtkWidget *hbuttonbox;
GtkWidget *quit2;
GtkTextBuffer *puffer;
GtkWidget *quit;
if(gtk_tree_selection_get_selected(auswahl, &model, &iter))
{
gchar *name;
gchar test_ex="bla";
gtk_tree_model_get(model, &iter, 1, &name, -1);
gchar info[128];
window2 = g_object_new(GTK_TYPE_WINDOW, "title", name, "default-width",
500, "default-height", 500, NULL);
//g_signal_connect(window2 , "delete_event", G_CALLBACK(delete_event),
NULL);
// g_signal_connect(window2 , "destroy", G_CALLBACK(ende), NULL);
/* Tagtabelle und Puffer anlegen */
tags = gtk_text_tag_table_new();
puffer = gtk_text_buffer_new(tags);
/* Ansicht auf den Puffer anlegen */
ansicht2 = gtk_text_view_new_with_buffer(puffer);
g_object_set(ansicht2,"wrap-mode", GTK_WRAP_WORD, NULL);
/* Text einfügen */
sprintf(info, "/media/Data/README/%s.txt", name);
// g_print("%s", info);;
FILE *fp = fopen(info, "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);
quit = gtk_button_new_with_mnemonic(("Quit"));
gtk_box_pack_start(GTK_BOX(hbuttonbox), GTK_WIDGET(quit), TRUE, TRUE,
10);
g_signal_connect_swapped(quit,"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_container_add(GTK_CONTAINER(window2), GTK_WIDGET(vbox2));
gtk_widget_show_all(GTK_WIDGET(window2));
}
}
void quit_readme(GtkWidget *widget, gpointer daten){
gtk_main_quit();
}
On 3/13/06, rupert <rupertt gmail com> wrote:
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]