2 * Copyright (C) Massimo Cora' 2005 <maxcvs@email.it>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include <libanjuta/anjuta-debug.h>
21 #include <libanjuta/interfaces/ianjuta-document-manager.h>
22 #include <libanjuta/interfaces/ianjuta-symbol-manager.h>
25 #include "class-callbacks.h"
26 #include "class-inherit.h"
31 on_canvas_event (GnomeCanvasItem
*item
, GdkEvent
*event
, gpointer data
)
33 AnjutaClassInheritance
*plugin
;
34 plugin
= ANJUTA_PLUGIN_CLASS_INHERITANCE (data
);
38 case GDK_BUTTON_PRESS
:
39 if (event
->button
.button
== 3)
41 g_return_val_if_fail (plugin
->menu
!= NULL
, FALSE
);
43 gtk_menu_popup (GTK_MENU (plugin
->menu
), NULL
, NULL
, NULL
, NULL
,
44 event
->button
.button
, event
->button
.time
);
56 on_toggled_menuitem_clicked (GtkCheckMenuItem
*checkmenuitem
,
60 node
= (NodeData
*)data
;
62 if (node
->name
== NULL
|| g_str_equal (node
->name
, ""))
66 node
->anchored
= FALSE
;
68 /* remove the key from the hash table, if present */
69 if (g_hash_table_lookup (node
->plugin
->expansion_node_list
, node
->name
)) {
70 g_hash_table_remove (node
->plugin
->expansion_node_list
, node
->name
);
74 NodeExpansionStatus
*node_status
;
75 node
->anchored
= TRUE
;
77 node_status
= g_new0 (NodeExpansionStatus
, 1);
78 node_status
->name
= g_strdup (node
->name
);
79 /* set to half. This will display at least NODE_HALF_DISPLAY_ELEM_NUM.
80 * User will decide whether to show all elements or not. */
81 node_status
->expansion_status
= NODE_HALF_EXPANDED
;
83 /* insert the class name to the hash_table */
84 g_hash_table_insert (node
->plugin
->expansion_node_list
,
85 g_strdup (node
->name
),
89 class_inheritance_update_graph (node
->plugin
);
93 on_member_menuitem_clicked (GtkMenuItem
*menuitem
, gpointer data
)
99 node
= (NodeData
*)data
;
100 uri
= g_object_get_data (G_OBJECT (menuitem
), "__uri");
101 line
= GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem
), "__line"));
105 IAnjutaDocumentManager
*dm
;
106 dm
= anjuta_shell_get_interface (ANJUTA_PLUGIN (node
->plugin
)->shell
,
107 IAnjutaDocumentManager
, NULL
);
110 ianjuta_document_manager_goto_uri_line (dm
, uri
, line
, NULL
);
116 on_nodedata_expanded_event (GnomeCanvasItem
*item
, GdkEvent
*event
, gpointer data
)
118 AnjutaClassInheritance
*plugin
;
120 nodedata
= (NodeData
*)data
;
121 plugin
= nodedata
->plugin
;
125 case GDK_2BUTTON_PRESS
: /* double click */
128 case GDK_BUTTON_PRESS
: /* single click */
129 if (event
->button
.button
== 1) {
130 NodeExpansionStatus
*node_status
;
131 if ( (node_status
= (NodeExpansionStatus
*)g_hash_table_lookup (plugin
->expansion_node_list
,
132 nodedata
->name
)) == NULL
) {
136 if (strcmp (nodedata
->sub_item
, NODE_SHOW_ALL_MEMBERS_STR
) == 0) {
137 node_status
->expansion_status
= NODE_FULL_EXPANDED
;
138 class_inheritance_update_graph (plugin
);
141 if (strcmp (nodedata
->sub_item
, NODE_SHOW_NORMAL_VIEW_STR
) == 0) {
142 g_hash_table_remove (plugin
->expansion_node_list
, nodedata
->name
);
143 class_inheritance_update_graph (plugin
);
145 else { /* it's a class member. Take line && uri of definition
150 uri
= g_object_get_data (G_OBJECT (item
), "__uri");
151 line
= GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item
), "__line"));
154 IAnjutaDocumentManager
*dm
;
155 dm
= anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin
)->shell
,
156 IAnjutaDocumentManager
, NULL
);
158 ianjuta_document_manager_goto_uri_line (dm
, uri
, line
, NULL
);
165 case GDK_ENTER_NOTIFY
: /* mouse entered in item's area */
166 gnome_canvas_item_set (nodedata
->canvas_item
,
168 &plugin
->canvas
->style
->base
[GTK_STATE_PRELIGHT
],
172 case GDK_LEAVE_NOTIFY
: /* mouse exited item's area */
173 gnome_canvas_item_set (nodedata
->canvas_item
,
175 &plugin
->canvas
->style
->base
[GTK_STATE_ACTIVE
],
188 on_nodedata_event (GnomeCanvasItem
*item
, GdkEvent
*event
, gpointer data
)
190 AnjutaClassInheritance
*plugin
;
193 nodedata
= (NodeData
*)data
;
194 plugin
= nodedata
->plugin
;
198 case GDK_2BUTTON_PRESS
: /* double click */
201 case GDK_BUTTON_PRESS
: /* single click */
202 if (event
->button
.button
== 1 && !nodedata
->anchored
)
204 class_inheritance_show_dynamic_class_popup_menu (event
, data
);
208 case GDK_ENTER_NOTIFY
: /* mouse entered in item's area */
209 /* Make the outline wide */
210 gnome_canvas_item_set (nodedata
->canvas_item
,
213 &plugin
->canvas
->style
->base
[GTK_STATE_PRELIGHT
],
215 &plugin
->canvas
->style
->text
[GTK_STATE_PRELIGHT
],
219 case GDK_LEAVE_NOTIFY
: /* mouse exited item's area */
220 /* Make the outline thin */
221 gnome_canvas_item_set (nodedata
->canvas_item
,
224 &plugin
->canvas
->style
->base
[GTK_STATE_NORMAL
],
226 &plugin
->canvas
->style
->text
[GTK_STATE_NORMAL
],
237 /*----------------------------------------------------------------------------
238 * callback for the canvas' right-click menu - update button.
241 on_update_menu_item_selected (GtkMenuItem
*item
,
242 AnjutaClassInheritance
*plugin
)
244 class_inheritance_update_graph (plugin
);
247 /*----------------------------------------------------------------------------
248 * callback for theme/colors changes
251 on_style_set (GtkWidget
*widget
, GtkStyle
*previous_style
,
252 AnjutaClassInheritance
*plugin
)
254 class_inheritance_update_graph (plugin
);