[gtk-list] TextBox



Hello,
	Sorry about the empty mail. I hit Ctrl-Z by accident..:).
I want to make a textbox that i can have command's output print on it.
I tried frame containing a label, but labe expands the frame, so there's no
scrolling. So text widget seems to be the right thing to use. The test codes i
did here appends text to the box and the text can only be seen if i resize the
window bigger as it prints. My callback func is definitely bad here. 
       I'll be much appreciated if anyone can point now what i did is
wrong..Thanks

/* BAD callback func, text's appended and seen only when resized */

void callback(GtkWidget *widget,gpointer data)
{
    static GdkFont *font;

    font=gdk_font_load("-*-helvetica-medium-r-normal-*-*-100-*-*-*-*-*-*");
    gtk_widget_realize(GTK_WIDGET(data));
    gtk_text_insert(GTK_TEXT(data),font,NULL,NULL,
                    "THIS IS A TEST...TESTING..TESTING...\n", -1);
}
int main(int argc,char *argv[])
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *vsb;
    GtkWidget *table;
    GtkWidget *text;
    GtkAdjustment *vadj;

    gtk_init(&argc,&argv);
    window = gtk_dialog_new();

    vadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
    vsb = gtk_vscrollbar_new(vadj);

    text = gtk_text_new(NULL,vadj);
    gtk_text_set_editable(GTK_TEXT(text),FALSE);
    gtk_widget_set_usize(text,300,400);

    table = gtk_table_new(1,2,FALSE);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox),table,TRUE,TRUE,0);
    gtk_table_attach(GTK_TABLE(table),vsb,1,2,0,1,
                     GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);
    gtk_table_attach(GTK_TABLE(table),text,0,1,0,1,
                     GTK_EXPAND|GTK_FILL,GTK_FILL, 0, 0);

    button = gtk_button_new_with_label("PRINT");
    gtk_signal_connect(GTK_OBJECT(button),"clicked",
                       GTK_SIGNAL_FUNC(callback),(gpointer)text);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area),button,TRUE,
                       TRUE,0);
    gtk_widget_show(button);
    gtk_widget_show(vsb);
    gtk_widget_show(text);
    gtk_widget_show(table);
    gtk_widget_show(window);
    gtk_main();
    return(0);
}	
						Thanks in advance,
						     alt



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]