3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any laterdversion.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "debug_tree.h"
28 #include <libanjuta/anjuta-debug.h>
32 IAnjutaDebugger
*debugger
;
34 DebugTree
*debug_tree
;
39 locals_updated (const gpointer data
, gpointer user_data
, GError
*error
)
41 const GList
*list
= (const GList
*)data
;
42 Locals
*locals
= (Locals
*) user_data
;
44 g_return_if_fail (locals
!= NULL
);
49 if (g_list_length ((GList
*)list
) < 1)
52 debug_tree_replace_list (locals
->debug_tree
, list
);
53 debug_tree_update_all(locals
->debug_tree
);
57 *---------------------------------------------------------------------------*/
60 create_locals_gui (Locals
*l
)
62 if (l
->debug_tree
== NULL
)
64 l
->debug_tree
= debug_tree_new (l
->plugin
);
65 debug_tree_connect (l
->debug_tree
, l
->debugger
);
68 if (l
->main_w
== NULL
)
70 /* Create local window */
73 main_w
= gtk_scrolled_window_new (NULL
, NULL
);
74 gtk_widget_show (main_w
);
75 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_w
),
77 GTK_POLICY_AUTOMATIC
);
78 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (main_w
),
80 gtk_container_add (GTK_CONTAINER (main_w
), debug_tree_get_tree_widget (l
->debug_tree
));
81 gtk_widget_show_all (main_w
);
84 anjuta_shell_add_widget (l
->plugin
->shell
,
86 "AnjutaDebuggerLocals", _("Locals"),
87 "gdb-locals-icon", ANJUTA_SHELL_PLACEMENT_BOTTOM
,
93 destroy_locals_gui (Locals
*l
)
95 if (l
->debug_tree
!= NULL
)
97 debug_tree_free (l
->debug_tree
);
100 if (l
->main_w
!= NULL
)
102 gtk_widget_destroy (GTK_WIDGET (l
->main_w
));
108 *---------------------------------------------------------------------------*/
110 static void locals_update (Locals
*locals
)
112 ianjuta_debugger_list_local (locals
->debugger
, locals_updated
, locals
, NULL
);
116 locals_clear (Locals
*l
)
118 g_return_if_fail (l
!= NULL
);
119 debug_tree_remove_all (l
->debug_tree
);
123 on_program_stopped (Locals
*l
)
129 on_debugger_started (Locals
*l
)
131 create_locals_gui (l
);
135 on_debugger_stopped (Locals
*l
)
138 destroy_locals_gui (l
);
141 /* Constructor & Destructor
142 *---------------------------------------------------------------------------*/
145 locals_new (AnjutaPlugin
*plugin
, IAnjutaDebugger
* debugger
)
147 DebugTree
*debug_tree
;
149 Locals
*locals
= g_new0 (Locals
, 1);
151 debug_tree
= debug_tree_new (plugin
);
153 locals
->debugger
= debugger
;
154 if (debugger
!= NULL
) g_object_ref (debugger
);
155 locals
->plugin
= plugin
;
157 g_signal_connect_swapped (locals
->debugger
, "debugger-started", G_CALLBACK (on_debugger_started
), locals
);
158 g_signal_connect_swapped (locals
->debugger
, "debugger-stopped", G_CALLBACK (on_debugger_stopped
), locals
);
159 g_signal_connect_swapped (locals
->debugger
, "program-stopped", G_CALLBACK (on_program_stopped
), locals
);
165 locals_free (Locals
*l
)
167 g_return_if_fail (l
!= NULL
);
170 destroy_locals_gui (l
);
172 /* Disconnect from debugger */
173 if (l
->debugger
!= NULL
)
175 g_signal_handlers_disconnect_by_func (l
->debugger
, G_CALLBACK (on_debugger_started
), l
);
176 g_signal_handlers_disconnect_by_func (l
->debugger
, G_CALLBACK (on_debugger_stopped
), l
);
177 g_signal_handlers_disconnect_by_func (l
->debugger
, G_CALLBACK (on_program_stopped
), l
);
178 g_object_unref (l
->debugger
);