gedit-plugin.c 2.82 KB
Newer Older
Paolo Maggi's avatar
Paolo Maggi committed
1 2 3 4
/*
 * gedit-plugin.h
 * This file is part of gedit
 *
Paolo Borelli's avatar
Paolo Borelli committed
5
 * Copyright (C) 2002-2005 Paolo Maggi 
Paolo Maggi's avatar
Paolo Maggi committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * 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., 59 Temple Place, Suite 330, 
 * Boston, MA 02111-1307, USA. 
 */
 
/*
Paolo Borelli's avatar
Paolo Borelli committed
24
 * Modified by the gedit Team, 2002-2005. See the AUTHORS file for a 
Paolo Maggi's avatar
Paolo Maggi committed
25 26
 * list of people on the gedit Team.  
 * See the ChangeLog files for a list of changes. 
Paolo Borelli's avatar
Paolo Borelli committed
27 28
 *
 * $Id$
Paolo Maggi's avatar
Paolo Maggi committed
29 30
 */

Paolo Maggi's avatar
Paolo Maggi committed
31 32 33 34
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

Paolo Maggi's avatar
Paolo Maggi committed
35 36
#include "gedit-plugin.h"

Paolo Borelli's avatar
Paolo Borelli committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50
G_DEFINE_TYPE(GeditPlugin, gedit_plugin, G_TYPE_OBJECT)

static void
dummy (GeditPlugin *plugin, GeditWindow *window)
{
	/* Empty */
}

static GtkWidget *
create_configure_dialog	(GeditPlugin *plugin)
{
	return NULL;
}

51 52 53 54 55 56 57
static gboolean
is_configurable (GeditPlugin *plugin)
{
	return (GEDIT_PLUGIN_GET_CLASS (plugin)->create_configure_dialog !=
		create_configure_dialog);
}

Paolo Borelli's avatar
Paolo Borelli committed
58 59 60 61 62 63 64 65
static void 
gedit_plugin_class_init (GeditPluginClass *klass)
{
	klass->activate = dummy;
	klass->deactivate = dummy;
	klass->update_ui = dummy;
	
	klass->create_configure_dialog = create_configure_dialog;
66
	klass->is_configurable = is_configurable;
Paolo Borelli's avatar
Paolo Borelli committed
67 68 69 70 71 72 73 74 75 76 77
}

static void
gedit_plugin_init (GeditPlugin *plugin)
{
	/* Empty */
}

void
gedit_plugin_activate (GeditPlugin *plugin,
		       GeditWindow *window)
Paolo Maggi's avatar
Paolo Maggi committed
78
{
Paolo Borelli's avatar
Paolo Borelli committed
79 80 81 82
	g_return_if_fail (GEDIT_IS_PLUGIN (plugin));
	g_return_if_fail (GEDIT_IS_WINDOW (window));
	
	GEDIT_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
Paolo Maggi's avatar
Paolo Maggi committed
83 84
}

Paolo Borelli's avatar
Paolo Borelli committed
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
void
gedit_plugin_deactivate	(GeditPlugin *plugin,
			 GeditWindow *window)
{
	g_return_if_fail (GEDIT_IS_PLUGIN (plugin));
	g_return_if_fail (GEDIT_IS_WINDOW (window));

	GEDIT_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
}
				 
void
gedit_plugin_update_ui	(GeditPlugin *plugin,
			 GeditWindow *window)
{
	g_return_if_fail (GEDIT_IS_PLUGIN (plugin));
	g_return_if_fail (GEDIT_IS_WINDOW (window));

	GEDIT_PLUGIN_GET_CLASS (plugin)->update_ui (plugin, window);
}

gboolean
gedit_plugin_is_configurable (GeditPlugin *plugin)
{
	g_return_val_if_fail (GEDIT_IS_PLUGIN (plugin), FALSE);

110
	return GEDIT_PLUGIN_GET_CLASS (plugin)->is_configurable (plugin);
Paolo Borelli's avatar
Paolo Borelli committed
111 112 113 114 115 116 117 118 119
}

GtkWidget *
gedit_plugin_create_configure_dialog (GeditPlugin *plugin)
{
	g_return_val_if_fail (GEDIT_IS_PLUGIN (plugin), NULL);
	
	return GEDIT_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
}