Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: a1794998e1
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 111 lines (96 sloc) 3.547 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
/*
* plugin.vala - This file is part of the Geany MultiTerm plugin
*
* Copyright (c) 2012 Matthew Brush <matt@geany.org>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/

using Gtk;
using Geany;
using MultiTerm;

public Plugin geany_plugin;
public Data geany_data;
public Functions geany_functions;

/* Widgets to clean up when the plugin is unloaded */
private List<Widget> toplevel_widgets = new List<Widget>();

/* Geany calls this to determine min. required API/ABI version */
public int plugin_version_check(int abi_version)
{
return Plugin.version_check(abi_version, 185);
}

/* Geany calls this to get some info about the plugin */
public void plugin_set_info(Plugin.Info info)
{
info.set("MultiTerm",
"Multi-tabbed virtual terminal emulator.",
"0.1", "Matthew Brush <matt@geany.org>");
}

/* Geany will call this when the plugin is loaded */
public void plugin_init(Geany.Data data)
{
string config_file;
string config_dir;
Label label;
Alignment align;
MultiTerm.Notebook notebook;

/* Needed for GObject type system not to freak out about
* unregistering and re-registering new types */
geany_plugin.module_make_resident();

/* Initialize plugin's configuration directory/file */
config_dir = Path.build_filename(geany_data.app.config_dir, "plugins", "multiterm");
config_file = Path.build_filename(config_dir, "multiterm.conf");
    DirUtils.create_with_parents(config_dir, 0755);
try
{
/* Create a default config file if there isn't one yet */
if (!FileUtils.test(config_file, FileTest.EXISTS | FileTest.IS_REGULAR))
FileUtils.set_contents(config_file, default_config);
}
catch (FileError err)
{
warning("Unable to write default config file: %s", err.message);
}

/* Setup the widgets */
align = new Alignment(0.5f, 0.5f, 1.0f, 1.0f);
notebook = new MultiTerm.Notebook(config_file);
align.add(notebook as Gtk.Notebook);
align.show_all();
toplevel_widgets.append(align);

label = new Label("MultiTerm");
notebook.set_data<Label>("label", label);
notebook.set_data<Gtk.Notebook>("msgwin_notebook", data.main_widgets.message_window_notebook);
notebook.set_data<Gtk.Notebook>("sidebar_notebook", data.main_widgets.sidebar_notebook);

if (notebook.cfg.location == "msgwin")
{
data.main_widgets.message_window_notebook.append_page(align, label);
data.main_widgets.message_window_notebook.set_current_page(
data.main_widgets.message_window_notebook.page_num(align));
}
else
{
data.main_widgets.sidebar_notebook.append_page(align, label);
data.main_widgets.sidebar_notebook.set_current_page(
data.main_widgets.sidebar_notebook.page_num(align));
}


/* Activate the new MultiTerm tab */
}

/* Geany will call this when the plugin is unloaded, so be sure to
* free/destroy anything needed here */
public void plugin_cleanup ()
{
foreach (Widget wid in toplevel_widgets)
wid.destroy();
}
Something went wrong with that request. Please try again.