git: Fix bgo 687145 - Critical warning when switching git pane
[anjuta.git] / plugins / patch / plugin.c
blob559447e5bcc04838908885f23a2e424864e9acd4
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.
18 #include <config.h>
19 #include <libanjuta/anjuta-shell.h>
20 #include <libanjuta/anjuta-debug.h>
21 #include <libanjuta/anjuta-plugin.h>
23 #include "plugin.h"
24 #include "patch-plugin.h"
26 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-patch.xml"
28 static gpointer parent_class;
31 static gboolean patch_plugin_activate (AnjutaPlugin *plugin);
32 static gboolean patch_plugin_deactivate (AnjutaPlugin *plugin);
34 static void dispose (GObject *obj);
35 static void finalize (GObject *obj);
37 static void patch_plugin_instance_init (GObject *obj);
38 static void patch_plugin_class_init (GObjectClass *klass);
39 static void on_patch_action_activate (GtkAction *action, PatchPlugin *plugin);
41 static void
42 on_patch_action_activate (GtkAction *action, PatchPlugin *plugin) {
44 patch_show_gui( plugin );
49 static GtkActionEntry actions_tools[] = {
51 "ActionMenuTools", /* Action name */
52 NULL, /* Stock icon, if any */
53 N_("_Tools"), /* Display label */
54 NULL, /* Short-cut */
55 NULL, /* Tooltip */
56 NULL /* Callback */
59 "ActionToolsPatch", /* Action name */
60 "patch-plugin-icon", /* Stock icon, if any */
61 N_("_Patch…"), /* Display label */
62 NULL, /* short-cut */
63 NULL, /* Tooltip */
64 G_CALLBACK (on_patch_action_activate) /* action callback */
70 static gboolean
71 patch_plugin_activate (AnjutaPlugin *plugin)
73 AnjutaUI *ui;
74 PatchPlugin *p_plugin;
76 DEBUG_PRINT ("%s", "PatchPlugin: Activating Patch plugin…");
78 p_plugin = ANJUTA_PLUGIN_PATCH (plugin);
80 p_plugin->launcher = anjuta_launcher_new ();
82 ui = anjuta_shell_get_ui (plugin->shell, NULL);
84 /* Register icon */
85 BEGIN_REGISTER_ICON (plugin);
86 REGISTER_ICON (ICON_FILE, "patch-plugin-icon");
87 END_REGISTER_ICON;
90 /* Add all our actions */
91 p_plugin->action_group =
92 anjuta_ui_add_action_group_entries (ui, "ActionMenuTools",
93 _("Patch files/directories"),
94 actions_tools,
95 G_N_ELEMENTS (actions_tools),
96 GETTEXT_PACKAGE, TRUE, p_plugin);
98 p_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
100 return TRUE;
104 static gboolean
105 patch_plugin_deactivate (AnjutaPlugin *plugin)
107 AnjutaUI *ui = anjuta_shell_get_ui (plugin->shell, NULL);
108 DEBUG_PRINT ("%s", "AnjutaPatchPlugin: Dectivating Patch plugin …");
110 anjuta_ui_unmerge (ui, ANJUTA_PLUGIN_PATCH (plugin)->uiid);
111 anjuta_ui_remove_action_group (ui, ANJUTA_PLUGIN_PATCH (plugin)->action_group);
113 /* FIXME: should launcher be unreferenced? */
115 return TRUE;
118 static void
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);
129 static void
130 patch_plugin_dispose (GObject *obj)
132 G_OBJECT_CLASS (parent_class)->dispose (obj);
136 static void
137 patch_plugin_instance_init (GObject *obj)
139 PatchPlugin *plugin = ANJUTA_PLUGIN_PATCH (obj);
140 plugin->uiid = 0;
141 plugin->launcher = NULL;
145 static void
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);