1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Massimo Cora' 2005 <maxcvs@email.it>
6 * plugin.c is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2, or (at your option) any later version.
12 * plugin.c is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with plugin.c. See the file "COPYING". If not,
19 * write to: The Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
25 #include <libanjuta/anjuta-shell.h>
26 #include <libgnomevfs/gnome-vfs-utils.h>
27 #include <libgnome/gnome-i18n.h>
28 #include <libanjuta/interfaces/ianjuta-document-manager.h>
29 #include <libanjuta/interfaces/ianjuta-project-manager.h>
30 #include <libanjuta/anjuta-debug.h>
33 #include "class-inherit.h"
35 #define ICON_FILE "anjuta-class-inheritance-plugin-48.png"
37 static gpointer parent_class
;
40 project_root_added (AnjutaPlugin
*plugin
, const gchar
*name
,
41 const GValue
*value
, gpointer user_data
)
43 AnjutaClassInheritance
*ci_plugin
;
44 const gchar
*root_uri
;
46 ci_plugin
= ANJUTA_PLUGIN_CLASS_INHERITANCE (plugin
);
47 root_uri
= g_value_get_string (value
);
51 gchar
*root_dir
= gnome_vfs_get_local_path_from_uri (root_uri
);
54 ci_plugin
->top_dir
= g_strdup(root_dir
);
57 ci_plugin
->top_dir
= NULL
;
61 ci_plugin
->top_dir
= NULL
;
63 /* let's update the graph */
64 class_inheritance_update_graph (ci_plugin
);
68 project_root_removed (AnjutaPlugin
*plugin
, const gchar
*name
,
71 AnjutaClassInheritance
*ci_plugin
;
72 ci_plugin
= ANJUTA_PLUGIN_CLASS_INHERITANCE (plugin
);
74 /* clean up the canvas */
75 class_inheritance_clean_canvas (ci_plugin
);
77 /* destroy and re-initialize the hashtable */
78 class_inheritance_hash_table_clear (ci_plugin
);
80 if (ci_plugin
->top_dir
)
81 g_free(ci_plugin
->top_dir
);
82 ci_plugin
->top_dir
= NULL
;
86 register_stock_icons (AnjutaPlugin
*plugin
)
88 static gboolean registered
= FALSE
;
94 BEGIN_REGISTER_ICON (plugin
);
95 REGISTER_ICON (PACKAGE_PIXMAPS_DIR
"/"ICON_FILE
,
96 "class-inheritance-plugin-icon");
101 activate_plugin (AnjutaPlugin
*plugin
)
103 AnjutaClassInheritance
*class_inheritance
;
104 static gboolean initialized
= FALSE
;
106 DEBUG_PRINT ("AnjutaClassInheritance: Activating plugin ...");
108 register_stock_icons (plugin
);
110 class_inheritance
= ANJUTA_PLUGIN_CLASS_INHERITANCE (plugin
);
112 class_inheritance_base_gui_init (class_inheritance
);
114 anjuta_shell_add_widget (plugin
->shell
, class_inheritance
->widget
,
115 "AnjutaClassInheritance", _("Inheritance Graph"),
116 "class-inheritance-plugin-icon",
117 ANJUTA_SHELL_PLACEMENT_CENTER
, NULL
);
118 class_inheritance
->top_dir
= NULL
;
120 /* set up project directory watch */
121 class_inheritance
->root_watch_id
= anjuta_plugin_add_watch (plugin
,
124 project_root_removed
, NULL
);
131 deactivate_plugin (AnjutaPlugin
*plugin
)
133 DEBUG_PRINT ("AnjutaClassInheritance: Dectivating plugin ...");
134 AnjutaClassInheritance
* class_inheritance
;
135 class_inheritance
= ANJUTA_PLUGIN_CLASS_INHERITANCE (plugin
);
137 /* clean up the canvas [e.g. destroys it's elements */
138 class_inheritance_clean_canvas (class_inheritance
);
140 /* destroy the nodestatus hash table */
141 if (class_inheritance
->expansion_node_list
) {
142 g_hash_table_destroy (class_inheritance
->expansion_node_list
);
143 class_inheritance
->expansion_node_list
= NULL
;
146 /* Container holds the last ref to this widget so it will be destroyed as
147 * soon as removed. No need to separately destroy it. */
148 /* In most cases, only toplevel widgets (windows) require explicit
149 * destruction, because when you destroy a toplevel its children will
150 * be destroyed as well. */
151 anjuta_shell_remove_widget (plugin
->shell
,
152 class_inheritance
->widget
,
156 anjuta_plugin_remove_watch (plugin
,
157 class_inheritance
->root_watch_id
,
163 class_inheritance_finalize (GObject
*obj
)
165 AnjutaClassInheritance
*ci_plugin
;
166 ci_plugin
= ANJUTA_PLUGIN_CLASS_INHERITANCE (obj
);
168 if (ci_plugin
->top_dir
)
169 g_free (ci_plugin
->top_dir
);
171 /* Finalization codes here */
172 GNOME_CALL_PARENT (G_OBJECT_CLASS
, finalize
, (obj
));
176 class_inheritance_dispose (GObject
*obj
)
178 /* Disposition codes */
179 GNOME_CALL_PARENT (G_OBJECT_CLASS
, dispose
, (obj
));
183 class_inheritance_instance_init (GObject
*obj
)
185 AnjutaClassInheritance
*plugin
= ANJUTA_PLUGIN_CLASS_INHERITANCE (obj
);
189 plugin
->widget
= NULL
;
190 plugin
->graph
= NULL
;
192 plugin
->expansion_node_list
= NULL
;
196 class_inheritance_class_init (GObjectClass
*klass
)
198 AnjutaPluginClass
*plugin_class
= ANJUTA_PLUGIN_CLASS (klass
);
200 parent_class
= g_type_class_peek_parent (klass
);
202 plugin_class
->activate
= activate_plugin
;
203 plugin_class
->deactivate
= deactivate_plugin
;
204 klass
->finalize
= class_inheritance_finalize
;
205 klass
->dispose
= class_inheritance_dispose
;
208 ANJUTA_PLUGIN_BOILERPLATE (AnjutaClassInheritance
, class_inheritance
);
209 ANJUTA_SIMPLE_PLUGIN (AnjutaClassInheritance
, class_inheritance
);