~euclide/euclide/bzr-plugin

« back to all changes in this revision

Viewing changes to bzr.vala

  • Committer: xapantu
  • Date: 2011-08-02 10:56:50 UTC
  • Revision ID: xapantu@gmail.com-20110802105650-yq4ocibzkolo0ysi
New bzr plugin, it launches euclide-bazaar

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using Euclide;
 
2
 
 
3
public class Euclide.Plugins.Bzr : GLib.Object, Euclide.Plugin {
 
4
    Gtk.Toolbar toolbar_widget;
 
5
    Euclide.CMake.Project project;
 
6
    Gtk.ToolButton toolbutton;
 
7
 
 
8
    public Bzr() {
 
9
    }
 
10
 
 
11
    public void activate (Gtk.Notebook notebook)
 
12
    {
 
13
        toolbutton = new Gtk.ToolButton(new Gtk.Image.from_icon_name("bzr-panel", Gtk.IconSize.LARGE_TOOLBAR), "Bazaar");
 
14
        toolbutton.set_sensitive(false);
 
15
    }
 
16
 
 
17
    public void document_changed()
 
18
    {
 
19
 
 
20
    }
 
21
    
 
22
    public void toolbar(Gtk.Toolbar toolbar_w)
 
23
    {
 
24
        toolbar_widget = toolbar_w;
 
25
        toolbar_widget.insert(toolbutton, 4);
 
26
        toolbutton.clicked.connect( () =>
 
27
        {
 
28
            Process.spawn_async_with_pipes(project.project_path,
 
29
                                   {"euclide-bazaar"},
 
30
                                   null,
 
31
                                   SpawnFlags.SEARCH_PATH,
 
32
                                   null,
 
33
                                   null);
 
34
        });
 
35
    }
 
36
 
 
37
    public void project_loaded(Euclide.CMake.Project project)
 
38
    {
 
39
        this.project = project;
 
40
        toolbutton.set_sensitive(is_bzr_branch(project.project_path));
 
41
    }
 
42
 
 
43
    public void deactivate ()
 
44
    {
 
45
        toolbutton.destroy();
 
46
    }
 
47
}
 
48
 
 
49
[ModuleInit]
 
50
public void peas_register_types (GLib.TypeModule module) {
 
51
  var objmodule = module as Peas.ObjectModule;
 
52
  objmodule.register_extension_type (typeof (Euclide.Plugin),
 
53
                                     typeof (Euclide.Plugins.Bzr));
 
54
}