1 /* plugin.c (C) 2005 Massimo Cora'
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Library General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include <libgnomevfs/gnome-vfs-utils.h>
20 #include <libanjuta/anjuta-shell.h>
21 #include <libanjuta/anjuta-debug.h>
22 #include <libanjuta/anjuta-plugin.h>
25 #include "patch-plugin.h"
27 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-patch.ui"
28 #define ICON_FILE_48 "anjuta-patch-plugin-48.png"
30 static gpointer parent_class
;
33 static gboolean
patch_plugin_activate (AnjutaPlugin
*plugin
);
34 static gboolean
patch_plugin_deactivate (AnjutaPlugin
*plugin
);
36 static void dispose (GObject *obj);
37 static void finalize (GObject *obj);
39 static void patch_plugin_instance_init (GObject
*obj
);
40 static void patch_plugin_class_init (GObjectClass
*klass
);
41 static void on_patch_action_activate (GtkAction
*action
, PatchPlugin
*plugin
);
44 on_patch_action_activate (GtkAction
*action
, PatchPlugin
*plugin
) {
46 patch_show_gui( plugin
);
51 static GtkActionEntry actions_tools
[] = {
53 "ActionMenuTools", /* Action name */
54 NULL
, /* Stock icon, if any */
55 N_("_Tools"), /* Display label */
61 "ActionToolsPatch", /* Action name */
62 "patch-plugin-icon", /* Stock icon, if any */
63 N_("_Patch..."), /* Display label */
66 G_CALLBACK (on_patch_action_activate
) /* action callback */
73 patch_plugin_activate (AnjutaPlugin
*plugin
)
76 PatchPlugin
*p_plugin
;
78 DEBUG_PRINT ("PatchPlugin: Activating Patch plugin...");
80 p_plugin
= ANJUTA_PLUGIN_PATCH (plugin
);
82 p_plugin
->launcher
= anjuta_launcher_new ();
84 ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
87 BEGIN_REGISTER_ICON (plugin
);
88 REGISTER_ICON (ICON_FILE_48
, "patch-plugin-icon");
92 /* Add all our actions */
93 anjuta_ui_add_action_group_entries (ui
, "ActionMenuTools",
94 _("Patch files/directories"),
96 G_N_ELEMENTS (actions_tools
),
97 GETTEXT_PACKAGE
, TRUE
, p_plugin
);
99 p_plugin
->uiid
= anjuta_ui_merge (ui
, UI_FILE
);
106 patch_plugin_deactivate (AnjutaPlugin
*plugin
)
108 AnjutaUI
*ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
109 DEBUG_PRINT ("AnjutaPatchPlugin: Dectivating Patch plugin ...");
111 anjuta_ui_unmerge (ui
, ANJUTA_PLUGIN_PATCH (plugin
)->uiid
);
113 /* FIXME: should launcher be unreferenced? */
119 patch_plugin_finalize (GObject
*obj
)
122 PatchPlugin *p_plugin;
123 p_plugin = ANJUTA_PLUGIN_PATCH (obj);
125 G_OBJECT_CLASS (parent_class)->finalize (obj);
130 patch_plugin_dispose (GObject *obj)
132 G_OBJECT_CLASS (parent_class)->dispose (obj);
137 patch_plugin_instance_init (GObject *obj)
139 PatchPlugin *plugin = ANJUTA_PLUGIN_PATCH (obj);
141 plugin->launcher = NULL;
146 patch_plugin_class_init (GObjectClass *klass)
148 AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
150 parent_class = g_type_class_peek_parent (klass);
152 plugin_class->activate = patch_plugin_activate;
153 plugin_class->deactivate = patch_plugin_deactivate;
154 klass->dispose = patch_plugin_dispose;
155 klass->finalize = patch_plugin_finalize;
158 ANJUTA_PLUGIN_BOILERPLATE (PatchPlugin, patch_plugin);
159 ANJUTA_SIMPLE_PLUGIN (PatchPlugin, patch_plugin);