Hello all,
This is probably a basic question about GTK containers.
I typed out this hierarchy to demonstrate my current interface layout. Upon initial execution of the program, there is only a single textView field within grid. However, as the user inputs a string and presses enter, I would like to populate a new textView right under the previous one. I would like this to occur as many times as the user is willing to input a string and press enter.
layout:
[window]
[Vbox]
[Menubar][/Menubar]
[Scrolled_window]
[grid]
[textView1][/textView1]
[textView2][/textView2]
.
.
.
[textViewN][/textViewN]
[/grid]
[/scrolled_window]
[/Vbox]
[/window]
My question is this possible? It seems like I can only do it upon the initial creation of the window, but not after. Do I have to destroy and recreate the window each time to create the effect I’m looking for?
for example, I have this callback for when a user presses enter on a textview:
gboolean on_key_press (GtkWidget *widget, GdkEventKey* pKey, gpointer userdata){
if (pKey->type == GDK_KEY_PRESS){
g_print("%i\n", pKey->keyval);
switch (pKey->keyval){
case GDK_KEY_Return:
interpretRequest(&widget);
addUserPromptEntry(linecount); //this function will attach a new textview to the grid
break;
case 65362: cycleBuffer(&widget); //up arrow
break;
}
}
return FALSE;
}
void addUserPromptEntry(int x){
linecount++;
GtkWidget *text_view;
text_view = gtk_text_view_new();
g_signal_connect(text_view,"key_press_event", G_CALLBACK(on_key_press), NULL);
gtk_grid_attach(GTK_GRID(master_grid),text_view,0,x,10,1);
}