Embedding the VTE Virtual Terminal
- From: Stevenix <steve gnulinux gmail com>
- To: gtk-devel-list gnome org
- Subject: Embedding the VTE Virtual Terminal
- Date: Thu, 26 Nov 2009 06:07:36 -0800 (PST)
Hi,
I'm writing a Gui+Terminal application, where VTE is embedded on window, and
the GUI Menu Items.
And i'm trying to call this action...
... calls to this action from the menu... (just fork a 'ls' command)
But i'm unable to get the 'ls' listing ...
void VimWindow (GtkWidget *widget, gpointer gdata)
{
GtkWidget *vte;
vte = vte_terminal_new();
[b]vte_terminal_fork_command(VTE_TERMINAL(vte), "ls", NULL,
NULL, ".", FALSE, FALSE, FALSE);[/b]
}
All the source;
#include <gtk/gtk.h>
#include <vte/vte.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
/* gcc -Wall -g term.c -o term `pkg-config --cflags --libs gtk+-2.0 vte`
*/
/*-- This function allows the program to exit properly when the window
is closed --*/
gint destroyapp (GtkWidget *widget, gpointer gdata)
{
g_print ("Quitting...\n");
gtk_main_quit();
return (FALSE);
}
/*-- This function allows the program to exit properly when the window
is closed --*/
gint ClosingAppWindow (GtkWidget *widget, gpointer gdata)
{
g_print ("Quitting...\n");
gtk_main_quit();
return (FALSE);
}
void VimWindow (GtkWidget *widget, gpointer gdata)
{
GtkWidget *vte;
vte = vte_terminal_new();
vte_terminal_fork_command(VTE_TERMINAL(vte), "ls", NULL, NULL,
".", FALSE, FALSE, FALSE);
}
long size;
char *buf;
char *ptr;
int main( int argc, char *argv[] )
{
size = pathconf(".", _PC_PATH_MAX);
if ((buf = (char *)malloc((size_t)size)) != NULL) ptr = getcwd(buf,
(size_t)size);
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *menuFile;
GtkWidget *menuEdit;
GtkWidget *menuApp;
GtkWidget *menuHelp;
GtkWidget *menubar;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *vte;
GtkWidget *notebook;
GtkWidget *scrolled_window;
GtkWidget *label;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (GTK_WIDGET (window), 800, 600);
gtk_window_set_title (GTK_WINDOW (window), "gnomenus v0.1");
g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK
(gtk_main_quit), NULL);
vbox = gtk_vbox_new(FALSE,0);
gtk_container_add (GTK_CONTAINER (window), vbox);
menubar = gtk_menu_bar_new();
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
gtk_widget_show(menubar);
/*---------------- Create File menu items ------------------*/
menuFile = gtk_menu_item_new_with_label ("File");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuFile);
gtk_widget_show(menuFile);
/*-- Create File submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuFile), menu);
/*-- Create New menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Open Tab CTRL+T");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*-- Create Open menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Open");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*-- Create Exit menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Exit");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (ClosingAppWindow), NULL);
gtk_widget_show (menuitem);
/*---------------- End File menu declarations ----------------*/
/*---------------- Create Edit menu items --------------------*/
menuEdit = gtk_menu_item_new_with_label ("Edit");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuEdit);
gtk_widget_show(menuEdit);
/*-- Create File submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuEdit), menu);
/*-- Create Undo menu item under Edit submenu --*/
menuitem = gtk_menu_item_new_with_label ("Undo");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*-- Create Copy menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Copy");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*-- Create Cut menu item under File submenu --*/
menuitem = gtk_menu_item_new_with_label ("Cut");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*---------------- End Edit menu declarations ----------------*/
/*---------------- Start App menu declarations ----------------*/
menuApp = gtk_menu_item_new_with_label ("App");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuApp);
gtk_widget_show(menuApp);
/*-- Create App submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuApp), menu);
/*-- Create About menu item under Help submenu --*/
menuitem = gtk_menu_item_new_with_label ("Vim");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show (menuitem);
/*---------------- Start Help menu declarations ----------------*/
menuHelp = gtk_menu_item_new_with_label ("Help");
gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuHelp);
gtk_widget_show(menuHelp);
/*-- Create Help submenu --*/
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuHelp), menu);
/*-- Create About menu item under Help submenu --*/
menuitem = gtk_menu_item_new_with_label ("About");
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_signal_connect(GTK_OBJECT (menuitem), "activate",
GTK_SIGNAL_FUNC (VimWindow), NULL);
gtk_widget_show (menuitem);
/*---------------- End Help menu declarations ----------------*/
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_BOTTOM);
gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE, 0);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
label = gtk_label_new ("term1");
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window,
label);
vte = vte_terminal_new();
vte_terminal_set_background_transparent(VTE_TERMINAL(vte), FALSE);
vte_terminal_set_size(VTE_TERMINAL(vte), 80, 25);
vte_terminal_fork_command(VTE_TERMINAL(vte), NULL, NULL, NULL, ptr,
TRUE, TRUE,TRUE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL (vte), TRUE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
(scrolled_window), vte);
gtk_widget_show (label);
gtk_widget_show (notebook);
gtk_widget_show (scrolled_window);
gtk_widget_show (vte);
gtk_widget_show (vbox);
gtk_widget_show (window);
gtk_main ();
return 0;
}
--
View this message in context: http://old.nabble.com/Embedding-the-VTE-Virtual-Terminal-tp26529933p26529933.html
Sent from the Gtk+ - Dev - General mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]