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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "anjuta-patch-plugin.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
);
43 #define REGISTER_ICON(icon, stock_id) \
44 pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"icon, NULL); \
45 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); \
46 gtk_icon_factory_add (icon_factory, stock_id, icon_set); \
47 g_object_unref (pixbuf);
50 on_patch_action_activate (GtkAction
*action
, PatchPlugin
*plugin
) {
52 patch_show_gui( plugin
);
57 static GtkActionEntry actions_tools
[] = {
59 "ActionMenuTools", /* Action name */
60 NULL
, /* Stock icon, if any */
61 N_("_Tools"), /* Display label */
67 "ActionToolsPatch", /* Action name */
68 "patch-plugin-icon", /* Stock icon, if any */
69 N_("_Patch"), /* Display label */
72 G_CALLBACK (on_patch_action_activate
) /* action callback */
79 patch_plugin_activate (AnjutaPlugin
*plugin
)
82 PatchPlugin
*p_plugin
;
83 GtkIconFactory
*icon_factory
;
87 DEBUG_PRINT ("PatchPlugin: Activating Patch plugin...");
89 p_plugin
= PATCH_PLUGIN (plugin
);
91 p_plugin
->launcher
= anjuta_launcher_new ();
93 ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
96 icon_factory
= anjuta_ui_get_icon_factory (ui
);
97 REGISTER_ICON (ICON_FILE
, "patch-plugin-icon");
100 /* Add all our actions */
101 anjuta_ui_add_action_group_entries (ui
, "ActionMenuTools",
102 _("Patch files/directories"),
104 G_N_ELEMENTS (actions_tools
),
105 GETTEXT_PACKAGE
, TRUE
, p_plugin
);
107 p_plugin
->uiid
= anjuta_ui_merge (ui
, UI_FILE
);
114 patch_plugin_deactivate (AnjutaPlugin
*plugin
)
116 AnjutaUI
*ui
= anjuta_shell_get_ui (plugin
->shell
, NULL
);
117 DEBUG_PRINT ("AnjutaPatchPlugin: Dectivating Patch plugin ...");
119 anjuta_ui_unmerge (ui
, PATCH_PLUGIN (plugin
)->uiid
);
121 /* FIXME: should launcher be unreferenced? */
127 patch_plugin_finalize (GObject
*obj
)
130 PatchPlugin *p_plugin;
131 p_plugin = PATCH_PLUGIN (obj);
133 GNOME_CALL_PARENT (G_OBJECT_CLASS, finalize, (obj));
138 patch_plugin_dispose (GObject *obj)
140 GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (obj));
145 patch_plugin_instance_init (GObject *obj)
147 PatchPlugin *plugin = PATCH_PLUGIN (obj);
149 plugin->launcher = NULL;
154 patch_plugin_class_init (GObjectClass *klass)
156 AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
158 parent_class = g_type_class_peek_parent (klass);
160 plugin_class->activate = patch_plugin_activate;
161 plugin_class->deactivate = patch_plugin_deactivate;
162 klass->dispose = patch_plugin_dispose;
163 klass->finalize = patch_plugin_finalize;
166 ANJUTA_PLUGIN_BOILERPLATE (PatchPlugin, patch_plugin);
167 ANJUTA_SIMPLE_PLUGIN (PatchPlugin, patch_plugin);