arih wrote:
actually, i am doing the project using glade+gtk+c, but, i have some problem doing it in order, the supervisor need the VTE terminal to be put in the interface for the second version software. I dont know how to make the VTE terminal pop-up in the interface like the popup window....
it means like, i have button for the VTE, and if i click the button, the terminal will show...
anyone can give a help..
thank u so much....
Hello! I think you can do it with my code:
Code:
// vteopener.c by Norbert.
// Compile and run with command:
// gcc vteopener.c -o vteopener `pkg-config --cflags --libs gtk+-2.0 vte` && ./vteopener
#include <gtk/gtk.h>
#include <vte/vte.h>
static void exec_shell_in_vte(GtkWidget *widget)
{
if (!GTK_WIDGET_REALIZED (widget))
return;
vte_terminal_fork_command (VTE_TERMINAL(widget), NULL, NULL, NULL, NULL, 0, 0, 0); // execute a Shell in VTE
}
static void showvte ()
{
GtkWidget *popup_window; // pointer to VTE pop-up windows
GtkWidget *vteterminal; // pointer to VTE widget
popup_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(popup_window), "VTE Pop-up window");
vteterminal = vte_terminal_new (); // create VTE widget
g_signal_connect(vteterminal, "realize",G_CALLBACK(exec_shell_in_vte), popup_window); // creating a signal for execution Shell in VTE after creation of VTE widget
gtk_container_add(GTK_CONTAINER(popup_window), vteterminal);
gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_CENTER);
gtk_widget_realize (vteterminal);
gtk_widget_show_all(popup_window);
}
int main (int argc, char *argv[])
{
GtkWidget *button = NULL; // pointer to Execution button
GtkWidget *win = NULL; // pointer to Window with Execution button
/* Initialize GTK+ */
gtk_init (&argc, &argv);
/* Create the main window */
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (win), 100);
gtk_window_set_title (GTK_WINDOW (win), "VTE opener");
gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER);
gtk_widget_realize (win);
g_signal_connect (win, "destroy", gtk_main_quit, NULL);
/* Create a button */
button = gtk_button_new_from_stock (GTK_STOCK_EXECUTE);
g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (showvte), NULL); // creating a signal for opening VTE pop-up window
gtk_container_add (GTK_CONTAINER (win), button);
/* Enter the main loop */
gtk_widget_show_all (win);
gtk_main ();
return 0;
}
Think more abstactly. It is does not matter which window you open - VTE or other window. It is simply opening one window from another:)