~ubuntu-app-review-contributors/ubuntu-app-reviews/scratch

« back to all changes in this revision

Viewing changes to plugins/bash/bash.vala

  • Committer: App Bot
  • Author(s): Cassidy James
  • Date: 2012-06-15 13:45:49 UTC
  • Revision ID: appbot@holba.ch-20120615134549-6ohty3s8sp9t5nt0
Tags: 1.1-0~707~precise1
Auto build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
/***
 
3
  BEGIN LICENSE
 
4
        
 
5
  Copyright (C) 2011-2012 Mario Guerriero <mefrio.g@gmail.com>
 
6
  This program is free software: you can redistribute it and/or modify it       
 
7
  under the terms of the GNU Lesser General Public License version 3, as published      
 
8
  by the Free Software Foundation.
 
9
        
 
10
  This program is distributed in the hope that it will be useful, but   
 
11
  WITHOUT ANY WARRANTY; without even the implied warranties of  
 
12
  MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR    
 
13
  PURPOSE.  See the GNU General Public License for more details.
 
14
        
 
15
  You should have received a copy of the GNU General Public License along       
 
16
  with this program.  If not, see <http://www.gnu.org/licenses/>        
 
17
  
 
18
  END LICENSE   
 
19
***/
 
20
 
 
21
using Vte;
 
22
 
 
23
public class Scratch.Plugins.Bash : Peas.ExtensionBase,  Peas.Activatable
 
24
{
 
25
    Interface plugins;
 
26
    Vte.Terminal terminal;
 
27
    public Object object { owned get; construct; }
 
28
   
 
29
    public void update_state () {
 
30
    }
 
31
 
 
32
    public void activate () {
 
33
        plugins = (Scratch.Plugins.Interface)object;        
 
34
        plugins.register_function(Interface.Hook.BOTTOMBAR, on_bottombar);
 
35
    }
 
36
 
 
37
    public void deactivate () {
 
38
        if (terminal != null)
 
39
            terminal.destroy ();
 
40
    }
 
41
    
 
42
    void on_bottombar () {
 
43
        if (plugins.bottombar != null && plugins.scratch_app != null) {
 
44
            
 
45
            this.terminal = new Vte.Terminal ();
 
46
            
 
47
            try {
 
48
                this.terminal.fork_command_full (Vte.PtyFlags.DEFAULT, "~/", { Vte.get_user_shell () }, null, GLib.SpawnFlags.SEARCH_PATH, null, null);
 
49
            } catch (GLib.Error e) {
 
50
                warning (e.message);
 
51
            }
 
52
            
 
53
            plugins.bottombar.append_page (terminal, new Gtk.Label ("Bash"));
 
54
        }
 
55
    }
 
56
}
 
57
 
 
58
[ModuleInit]
 
59
public void peas_register_types (GLib.TypeModule module) {
 
60
    var objmodule = module as Peas.ObjectModule;
 
61
    objmodule.register_extension_type (typeof (Peas.Activatable),
 
62
                                     typeof (Scratch.Plugins.Bash));
 
63
}