GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 9:16 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: VTE Widget is not running script
PostPosted: Wed Jan 02, 2013 4:02 am 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello Everyone,

My VTE Widget is not running /bin/bash. The Window shows with the terminal but there is just a blinking curser. I can't type anything into the window. I am using Ubuntu 12.04, VTE 2.90, GTK 3. Any Ideas in my code where i have gone wrong? I can't find it anywhere. I

Code:



#include <config.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <vte/vte.h>


int main (int argc, char *argv[])
{
   GtkWidget *window;
   GtkWidget *scrollview;
   char** argva=NULL;   
   GError* Err=NULL;
   GtkWidget* term;
   char cmd[200];


#ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
#endif
   
   gtk_init (&argc, &argv);

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "My Title");
   gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
   gtk_window_set_default_size (GTK_WINDOW (window), 900, 600);

   scrollview = gtk_scrolled_window_new( NULL, NULL );

   gtk_container_add(GTK_CONTAINER (window), scrollview);

   sprintf(cmd,"/bin/bash");

   term=vte_terminal_new();
   g_shell_parse_argv(cmd, NULL, &argva, NULL);
   vte_terminal_fork_command_full(VTE_TERMINAL(term), 0, NULL, &argva, NULL, 0, NULL, NULL, NULL, &Err);

   gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollview), GTK_WIDGET (term));

   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

   gtk_widget_show (window);
   gtk_widget_show (term);
   gtk_widget_show (scrollview);

   gtk_main ();

   return 0;
}


Thank You Everyone


Top
 Profile  
 
 Post subject: Re: VTE Widget is not running script
PostPosted: Wed Jan 02, 2013 9:45 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hello,

Your problem was that you are passing the incorrect type for the forth argument of vte_terminal_fork_command_full(). Also you had a minor memory leak which is solved by using g_strfreev() on the allocated argument vector. Below is your edited example which works on my Debian Wheezy system. If you are using "gcc" you can use the compiler option -Wall which gives you a warning for all minor errors like this.
Code:
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <vte/vte.h>

int main (int argc, char *argv[])
{
   GtkWidget *window;
   GtkWidget *scrollview;
   char** argva = NULL;   
   GError* Err = NULL;
   GtkWidget* term;

#ifdef ENABLE_NLS
   bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
#endif
   
   gtk_init (&argc, &argv);

   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "My Title");
   gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
   gtk_window_set_default_size (GTK_WINDOW (window), 900, 600);

   scrollview = gtk_scrolled_window_new( NULL, NULL );

   gtk_container_add(GTK_CONTAINER (window), scrollview);

   term = vte_terminal_new();
   g_shell_parse_argv("/bin/bash", NULL, &argva, NULL);
   vte_terminal_fork_command_full(VTE_TERMINAL(term), 0, NULL, argva, NULL, 0, NULL, NULL, NULL, &Err);
   g_strfreev(argva);

   gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrollview), GTK_WIDGET (term));

   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

   gtk_widget_show_all (window);

   gtk_main ();

   return 0;
}

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group