Re: Can't use Vte.fork_command_full method because of an array problem



This works in seed

this.get('/Terminal').el.fork_command_full(
                                                                Vte.PtyFlags.DEFAULT,
                                                                target ,
                                                                [], //argv
                                                                [], // env
                                                                0, //spawn flags
                                                                null, // user func
                                                                null, // child setupdata
                                                                out
                                                        );
                                                    var cmd = "firefox file://" + target + "/builder.html  \n";
                                                    this.get('/Terminal').el.feed_child(cmd, cmd.length);
                                                     return false;

I'm not sure it's a Vte issue, it looks like GtkApplicationWindow is not getting created with those arguments, and it's throwing an error.

if you remove the Vte code does it work ok?

Regards
Alan

On Wednesday, May 01, 2013 05:31 AM, Leonard Messier wrote:
Hi there,

I'm struggling to get things working in a very small test application I'm creating. Using the base code I found here :https://developer.gnome.org/gnome-devel-demos/unstable/beginner.js.html.en#tutorials, I created the following :


#!/usr/bin/gjs

// Importing libraries
const GLib   = imports.gi.GLib
    , Gio    = imports.gi.Gio
    , Gtk    = imports.gi.Gtk
    , Lang   = imports.lang
    , Vte    = imports.gi.Vte
;

// Application code
const HelloMe = new Lang.Class({
    // Properties
    Name: "Hello Me"

    // Application initialization
  , _init: function() {
      this.application = new Gtk.Application();

      // Declaring event listeners
      this.application.connect('activate', Lang.bind(this, this.activate));
      this.application.connect('startup', Lang.bind(this, this.startup));
    }

    // Application callbacks
  , activate: function() {
      this._window.present();
    }

  , startup: function() {
      this.render();
    }

  , render: function() {
      var term = new Vte.Terminal()
        , testArray = new Array()
        , anotherTestArray = new Array()
        , pid  
      ;

      anotherTestArray.push('test');
      testArray.push('/bin/bash');

      pid = term.fork_command_full(
          Vte.PtyFlags.DEFAULT
        , '/home/me/' 
        , testArray
        , anotherTestArray
        , null
        , null
        , GLib.SpawnFlags.DO_NOT_REAP_CHILD
        , null
        , null
      );

      term.set_emulation('xterm');
      term.show();

      // Creating application's main window
      this._window = new Gtk.ApplicationWindow({
          application: this.application
        , title:       "Welcome to me"
        , default_height: 200
        , default_width:  400
        , window_position: Gtk.WindowPosition.CENTER
      });

      // Adding the webview to the app and showing
      this._window.add(term);
      this._window.show_all();
    }
});

let app = new HelloMe();
app.application.run(ARGV);

---------------------------------------------

I've been using two things to try and tackle the problem :

The Vte-2.90.gir file on my Ubuntu, located in /usr/lib/gir-1.0 where an automatically generated documentation from the Vte C code source is presented in xml format.
The following site : http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/index.html. Where those xml files are presented in a html format, like a regular api.

Nevertheless, I get the following error : 

 gjs embed-term.js
GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.
    JS ERROR: !!!   Exception was: Error: Unhandled array element type 14
    JS ERROR: !!!     lineNumber = '0'
    JS ERROR: !!!     fileName = '"gjs_throw"'
    JS ERROR: !!!     stack = '"("Unhandled array element type 14")@gjs_throw:0
()@embed-term.js:55
wrapper()@/usr/share/gjs-1.0/lang.js:204
([object _private_Gtk_Application])@embed-term.js:31
wrapper([object _private_Gtk_Application])@/usr/share/gjs-1.0/lang.js:204
@embed-term.js:77
"'
    JS ERROR: !!!     message = '"Unhandled array element type 14"'
    JS ERROR: !!!   Exception was: TypeError: this._window is undefined
    JS ERROR: !!!     lineNumber = '27'
    JS ERROR: !!!     fileName = '"embed-term.js"'
    JS ERROR: !!!     stack = '"([object _private_Gtk_Application])@embed-term.js:27
wrapper([object _private_Gtk_Application])@/usr/share/gjs-1.0/lang.js:204
@embed-term.js:77
"'
    JS ERROR: !!!     message = '"this._window is undefined"'

-----------------------------------------------

I gathered that both array I'm using aren't of the expected type. I tried to look into the source code of Gtk itself, but I couldn't go further than locating the problem to the gjs_array_to_array function in the following file https://git.gnome.org/browse/gjs/tree/gi/arg.c?h=gnome-3-8 at line 876, where the element_type is deduced. 
I couldn't find the place where the function g_type_info_get_tag was.

any help would be appreciated !

Thanks in advance

Léonard Messier


--



_______________________________________________
_javascript_-list mailing list
_javascript_-list gnome org
https://mail.gnome.org/mailman/listinfo/_javascript_-list



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