1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2000 Kh. Naba Kumar Singh
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <libanjuta/resources.h>
33 #include "utilities.h"
37 static GtkWidget
* create_signals_set_dialog (Signals
*s
);
40 signals_update_controls (Signals
* ew
)
44 R
= dma_debugger_queue_get_state (ew
->debugger
) == IANJUTA_DEBUGGER_OK
;
45 Pr
= dma_debugger_queue_get_state (ew
->debugger
) == IANJUTA_DEBUGGER_PROGRAM_RUNNING
;
46 gtk_widget_set_sensitive (ew
->widgets
.menu_signal
, Pr
);
47 gtk_widget_set_sensitive (ew
->widgets
.menu_modify
, R
);
48 gtk_widget_set_sensitive (ew
->widgets
.menu_update
, R
);
52 signals_update (const GList
* lines
, gpointer data
)
57 gchar sig
[32], stop
[10], print
[10], pass
[10];
60 sg
= (Signals
*) data
;
62 list
= gdb_util_remove_blank_lines (lines
);
63 if (g_list_length (list
) < 2)
68 gtk_clist_freeze (GTK_CLIST(sg
->widgets
.clist
));
73 sscanf ((char *) node
->data
, "%s %s %s %s", sig
, stop
, print
, pass
);
75 node
= g_list_next (node
);
79 /* Do not worry. This is used to avoid the last line */
86 for (j
= 0; j
< 4; j
++)
88 while (isspace (*str
))
90 while (!isspace (*str
))
93 while (isspace (*str
))
96 gtk_clist_append (GTK_CLIST (sg
->widgets
.clist
), row
);
99 gtk_clist_thaw (GTK_CLIST(sg
->widgets
.clist
));
103 on_signals_clist_select_row (GtkCList
*clist
, gint row
,
104 gint column
, GdkEvent
*event
, gpointer user_data
)
106 Signals
*s
= (Signals
*)user_data
;
111 on_signals_delete_event(GtkWidget
* w
, GdkEvent
*event
, gpointer data
)
113 Signals
* cr
= (Signals
*) data
;
119 on_signals_key_press_event(GtkWidget
*widget
, GdkEventKey
*event
,
122 if (event
->keyval
== GDK_Escape
)
124 Signals
* cr
= (Signals
*) data
;
132 on_signals_modify_activate (GtkMenuItem
*menuitem
, gpointer user_data
)
135 Signals
*s
= (Signals
*)user_data
;
137 dialog
= create_signals_set_dialog (s
);
139 gtk_widget_show (dialog
);
143 on_signals_send_activate (GtkMenuItem
*menuitem
, gpointer user_data
)
147 Signals
*s
= (Signals
*)user_data
;
149 if (debugger_program_is_running (s
->debugger
) == FALSE
) return;
152 gtk_clist_get_text(GTK_CLIST (s
->widgets
.clist
), s
->idx
, 0, &sig
);
153 debugger_signal(sig
, TRUE
);
158 on_signals_update_activate (GtkMenuItem
*menuitem
, gpointer user_data
)
160 Signals
*s
= (Signals
*)user_data
;
161 dma_queue_info_signal (
163 (IAnjutaDebuggerCallback
)signals_update
,
168 on_signals_event (GtkWidget
*widget
, GdkEvent
*event
, gpointer user_data
)
170 GdkEventButton
*bevent
;
171 Signals
*ew
= (Signals
*)user_data
;
173 if (event
->type
!= GDK_BUTTON_PRESS
) return FALSE
;
174 if (((GdkEventButton
*)event
)->button
!= 3) return FALSE
;
176 bevent
= (GdkEventButton
*)event
;
178 signals_update_controls(ew
);
179 gtk_menu_popup (GTK_MENU(ew
->widgets
.menu
), NULL
,
181 bevent
->button
, bevent
->time
);
186 on_signals_togglebutton1_toggled (GtkToggleButton
*togglebutton
,
189 Signals
*sig
= (Signals
*) user_data
;
191 sig
->stop
= gtk_toggle_button_get_active (togglebutton
);
193 gtk_label_set_text (GTK_LABEL(GTK_BIN (togglebutton
)->child
), _("Yes"));
195 gtk_label_set_text (GTK_LABEL(GTK_BIN (togglebutton
)->child
), _("No"));
199 on_signals_togglebutton2_toggled (GtkToggleButton
*togglebutton
,
202 Signals
*sig
= (Signals
*) user_data
;
204 sig
->print
= gtk_toggle_button_get_active(togglebutton
);
206 gtk_label_set_text (GTK_LABEL(GTK_BIN(togglebutton
)->child
), _("Yes"));
208 gtk_label_set_text (GTK_LABEL(GTK_BIN(togglebutton
)->child
), _("No"));
212 on_signals_togglebutton3_toggled (GtkToggleButton
*togglebutton
,
215 Signals
*sig
= (Signals
*) user_data
;
217 sig
->pass
= gtk_toggle_button_get_active (togglebutton
);
219 gtk_label_set_text (GTK_LABEL(GTK_BIN(togglebutton
)->child
), _("Yes"));
221 gtk_label_set_text (GTK_LABEL(GTK_BIN(togglebutton
)->child
), _("No"));
225 on_signals_set_ok_clicked (GtkButton
*button
,
228 Signals
*s
= (Signals
*) user_data
;
232 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 1, "Yes");
236 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 1, "No");
240 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 2, "Yes");
244 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 2, "No");
248 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 3, "Yes");
252 gtk_clist_set_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
, 3, "No");
254 dma_queue_handle_signal (s
->debugger
, s
->signal
, s
->stop
, s
->print
, s
->pass
);
257 static GnomeUIInfo signals_menu_uiinfo
[] =
260 GNOME_APP_UI_ITEM
, N_("Modify Signal"),
262 on_signals_modify_activate
, NULL
, NULL
,
263 GNOME_APP_PIXMAP_NONE
, NULL
,
267 GNOME_APP_UI_ITEM
, N_("Send to process"),
269 on_signals_send_activate
, NULL
, NULL
,
270 GNOME_APP_PIXMAP_NONE
, NULL
,
274 GNOME_APP_UI_ITEM
, N_("Update"),
276 on_signals_update_activate
, NULL
, NULL
,
277 GNOME_APP_PIXMAP_NONE
, NULL
,
284 create_signals_menu (Signals
*s
)
286 GtkWidget
*signals_menu
;
288 signals_menu
= gtk_menu_new ();
290 signals_menu_uiinfo
[0].user_data
= s
;
291 signals_menu_uiinfo
[1].user_data
= s
;
292 signals_menu_uiinfo
[2].user_data
= s
;
294 gnome_app_fill_menu (GTK_MENU_SHELL (signals_menu
), signals_menu_uiinfo
,
300 create_signals_gui (Signals
*cr
)
303 GtkWidget
*scrolledwindow4
;
305 GtkWidget
*label6
, *label7
, *label8
, *label9
, *label10
;
307 window3
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
308 gtk_widget_set_usize (window3
, 170, -2);
309 gtk_window_set_title (GTK_WINDOW (window3
), _("Kernel signals"));
310 gtk_window_set_wmclass (GTK_WINDOW (window3
), "signals", "Anjuta");
311 gtk_window_set_default_size (GTK_WINDOW (window3
), 240, 230);
312 gnome_window_icon_set_from_default(GTK_WINDOW(window3
));
314 scrolledwindow4
= gtk_scrolled_window_new (NULL
, NULL
);
315 gtk_widget_show (scrolledwindow4
);
316 gtk_container_add (GTK_CONTAINER (window3
), scrolledwindow4
);
317 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow4
),
318 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
320 clist4
= gtk_clist_new (5);
321 gtk_widget_show (clist4
);
322 gtk_container_add (GTK_CONTAINER (scrolledwindow4
), clist4
);
323 gtk_clist_set_column_width (GTK_CLIST (clist4
), 0, 100);
324 gtk_clist_set_column_width (GTK_CLIST (clist4
), 1, 50);
325 gtk_clist_set_column_width (GTK_CLIST (clist4
), 2, 50);
326 gtk_clist_set_column_width (GTK_CLIST (clist4
), 3, 50);
327 gtk_clist_set_column_width (GTK_CLIST (clist4
), 4, 80);
328 gtk_clist_set_selection_mode (GTK_CLIST (clist4
), GTK_SELECTION_BROWSE
);
329 gtk_clist_column_titles_show (GTK_CLIST (clist4
));
330 gtk_clist_set_column_auto_resize (GTK_CLIST(clist4
), 4, TRUE
);
332 label6
= gtk_label_new (_("Signal"));
333 gtk_widget_show (label6
);
334 gtk_clist_set_column_widget (GTK_CLIST (clist4
), 0, label6
);
336 label7
= gtk_label_new (_("Stop"));
337 gtk_widget_show (label7
);
338 gtk_clist_set_column_widget (GTK_CLIST (clist4
), 1, label7
);
340 label8
= gtk_label_new (_("Print"));
341 gtk_widget_show (label8
);
342 gtk_clist_set_column_widget (GTK_CLIST (clist4
), 2, label8
);
344 label9
= gtk_label_new (_("Pass"));
345 gtk_widget_show (label9
);
346 gtk_clist_set_column_widget (GTK_CLIST (clist4
), 3, label9
);
348 label10
= gtk_label_new (_("Description"));
349 gtk_widget_show (label10
);
350 gtk_clist_set_column_widget (GTK_CLIST (clist4
), 4, label10
);
352 gtk_signal_connect (GTK_OBJECT (window3
), "delete_event",
353 GTK_SIGNAL_FUNC (on_signals_delete_event
), cr
);
354 gtk_signal_connect (GTK_OBJECT (window3
), "key-press-event",
355 GTK_SIGNAL_FUNC (on_signals_key_press_event
), cr
);
357 gtk_signal_connect (GTK_OBJECT (clist4
), "event",
358 GTK_SIGNAL_FUNC (on_signals_event
),
360 gtk_signal_connect (GTK_OBJECT (clist4
), "select_row",
361 GTK_SIGNAL_FUNC (on_signals_clist_select_row
),
364 cr
->widgets
.window
= window3
;
365 cr
->widgets
.clist
= clist4
;
366 cr
->widgets
.menu
= create_signals_menu (cr
);
367 cr
->widgets
.menu_modify
= signals_menu_uiinfo
[0].widget
;
368 cr
->widgets
.menu_signal
= signals_menu_uiinfo
[1].widget
;
369 cr
->widgets
.menu_update
= signals_menu_uiinfo
[2].widget
;
373 create_signals_set_dialog (Signals
*s
)
376 GtkWidget
*dialog_vbox1
;
383 GtkWidget
*hseparator1
;
389 GtkWidget
*togglebutton1
;
390 GtkWidget
*togglebutton2
;
391 GtkWidget
*togglebutton3
;
392 GtkWidget
*dialog_action_area1
;
401 gtk_clist_get_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
,0, &row
[0]);
402 gtk_clist_get_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
,1, &row
[1]);
403 gtk_clist_get_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
,2, &row
[2]);
404 gtk_clist_get_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
,3, &row
[3]);
405 gtk_clist_get_text(GTK_CLIST(s
->widgets
.clist
), s
->idx
,4, &row
[4]);
408 if(strcasecmp(row
[1], "Yes")==0)
413 if(strcasecmp(row
[2], "Yes")==0)
418 if(strcasecmp(row
[3], "Yes")==0)
423 dialog1
= gnome_dialog_new (_("Set Signal Property"), NULL
);
424 gtk_window_set_transient_for (GTK_WINDOW(dialog1
),
425 GTK_WINDOW(s
->widgets
.window
));
426 GTK_WINDOW (dialog1
)->type
= GTK_WINDOW_TOPLEVEL
;
427 gtk_window_set_position (GTK_WINDOW (dialog1
), GTK_WIN_POS_MOUSE
);
428 gtk_window_set_policy (GTK_WINDOW (dialog1
), FALSE
, FALSE
, FALSE
);
429 gtk_window_set_wmclass (GTK_WINDOW (dialog1
), "set_signal", "Anjuta");
430 gnome_dialog_set_close (GNOME_DIALOG (dialog1
), TRUE
);
432 dialog_vbox1
= GNOME_DIALOG (dialog1
)->vbox
;
433 gtk_widget_show (dialog_vbox1
);
435 hbox1
= gtk_hbox_new (FALSE
, 0);
436 gtk_widget_show (hbox1
);
437 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox1
, TRUE
, TRUE
, 0);
439 label1
= gtk_label_new ("Signal: ");
440 gtk_widget_show (label1
);
441 gtk_box_pack_start (GTK_BOX (hbox1
), label1
, FALSE
, FALSE
, 0);
443 label2
= gtk_label_new (row
[0]);
444 gtk_widget_show (label2
);
445 gtk_box_pack_start (GTK_BOX (hbox1
), label2
, FALSE
, FALSE
, 0);
447 hbox2
= gtk_hbox_new (FALSE
, 0);
448 gtk_widget_show (hbox2
);
449 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox2
, TRUE
, TRUE
, 0);
451 label3
= gtk_label_new ("Description: ");
452 gtk_widget_show (label3
);
453 gtk_box_pack_start (GTK_BOX (hbox2
), label3
, FALSE
, FALSE
, 0);
455 label4
= gtk_label_new (row
[4]);
456 gtk_widget_show (label4
);
457 gtk_box_pack_start (GTK_BOX (hbox2
), label4
, FALSE
, FALSE
, 0);
459 hseparator1
= gtk_hseparator_new ();
460 gtk_widget_show (hseparator1
);
461 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hseparator1
, TRUE
, TRUE
, 0);
463 hbox4
= gtk_hbox_new (FALSE
, 0);
464 gtk_widget_show (hbox4
);
465 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox4
, TRUE
, TRUE
, 0);
467 label5
= gtk_label_new (_(" Stop: "));
468 gtk_widget_show (label5
);
469 gtk_box_pack_start (GTK_BOX (hbox4
), label5
, TRUE
, TRUE
, 0);
471 label6
= gtk_label_new (_(" Print: "));
472 gtk_widget_show (label6
);
473 gtk_box_pack_start (GTK_BOX (hbox4
), label6
, TRUE
, TRUE
, 0);
475 label7
= gtk_label_new (_("Pass:"));
476 gtk_widget_show (label7
);
477 gtk_box_pack_start (GTK_BOX (hbox4
), label7
, TRUE
, TRUE
, 0);
479 hbox3
= gtk_hbox_new (FALSE
, 0);
480 gtk_widget_show (hbox3
);
481 gtk_box_pack_start (GTK_BOX (dialog_vbox1
), hbox3
, TRUE
, TRUE
, 0);
483 togglebutton1
= gtk_toggle_button_new_with_label (row
[1]);
484 gtk_widget_show (togglebutton1
);
485 gtk_box_pack_start (GTK_BOX (hbox3
), togglebutton1
, TRUE
, TRUE
, 0);
486 gtk_container_set_border_width (GTK_CONTAINER (togglebutton1
), 3);
487 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(togglebutton1
), s
->stop
);
489 togglebutton2
= gtk_toggle_button_new_with_label (row
[2]);
490 gtk_widget_show (togglebutton2
);
491 gtk_box_pack_start (GTK_BOX (hbox3
), togglebutton2
, TRUE
, TRUE
, 0);
492 gtk_container_set_border_width (GTK_CONTAINER (togglebutton2
), 3);
493 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(togglebutton2
), s
->print
);
495 togglebutton3
= gtk_toggle_button_new_with_label (row
[3]);
496 gtk_widget_show (togglebutton3
);
497 gtk_box_pack_start (GTK_BOX (hbox3
), togglebutton3
, TRUE
, TRUE
, 0);
498 gtk_container_set_border_width (GTK_CONTAINER (togglebutton3
), 3);
499 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(togglebutton3
), s
->pass
);
501 dialog_action_area1
= GNOME_DIALOG (dialog1
)->action_area
;
502 gtk_widget_show (dialog_action_area1
);
503 gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1
),
504 GTK_BUTTONBOX_SPREAD
);
505 gtk_button_box_set_spacing (GTK_BUTTON_BOX (dialog_action_area1
), 8);
507 gnome_dialog_append_button (GNOME_DIALOG (dialog1
),
508 GNOME_STOCK_BUTTON_HELP
);
509 button1
= g_list_last (GNOME_DIALOG (dialog1
)->buttons
)->data
;
510 gtk_widget_show (button1
);
511 GTK_WIDGET_SET_FLAGS (button1
, GTK_CAN_DEFAULT
);
513 gnome_dialog_append_button (GNOME_DIALOG (dialog1
), GNOME_STOCK_BUTTON_OK
);
514 button2
= g_list_last (GNOME_DIALOG (dialog1
)->buttons
)->data
;
515 gtk_widget_show (button2
);
516 GTK_WIDGET_SET_FLAGS (button2
, GTK_CAN_DEFAULT
);
518 gnome_dialog_append_button (GNOME_DIALOG (dialog1
),
519 GNOME_STOCK_BUTTON_CANCEL
);
520 button3
= g_list_last (GNOME_DIALOG (dialog1
)->buttons
)->data
;
521 gtk_widget_show (button3
);
522 GTK_WIDGET_SET_FLAGS (button3
, GTK_CAN_DEFAULT
);
524 gtk_signal_connect (GTK_OBJECT (togglebutton1
), "toggled",
525 GTK_SIGNAL_FUNC (on_signals_togglebutton1_toggled
),
527 gtk_signal_connect (GTK_OBJECT (togglebutton2
), "toggled",
528 GTK_SIGNAL_FUNC (on_signals_togglebutton2_toggled
),
530 gtk_signal_connect (GTK_OBJECT (togglebutton3
), "toggled",
531 GTK_SIGNAL_FUNC (on_signals_togglebutton3_toggled
),
533 gtk_signal_connect (GTK_OBJECT (button2
), "clicked",
534 GTK_SIGNAL_FUNC (on_signals_set_ok_clicked
),
540 signals_new (DebugManagerPlugin
*plugin
)
543 ew
= g_malloc (sizeof (Signals
));
546 ew
->debugger
= dma_debug_manager_get_queue (plugin
);
547 ew
->is_showing
= FALSE
;
549 ew
->win_height
= 320;
553 create_signals_gui (ew
);
559 signals_clear (Signals
* sg
)
561 if (GTK_IS_CLIST (sg
->widgets
.clist
))
562 gtk_clist_clear (GTK_CLIST (sg
->widgets
.clist
));
567 signals_show (Signals
* ew
)
573 gdk_window_raise (ew
->widgets
.window
->window
);
577 gtk_widget_set_uposition (ew
->widgets
.window
, ew
->win_pos_x
,
579 gtk_window_set_default_size (GTK_WINDOW (ew
->widgets
.window
),
580 ew
->win_width
, ew
->win_height
);
581 gtk_widget_show (ew
->widgets
.window
);
582 ew
->is_showing
= TRUE
;
583 dma_queue_info_signal (
585 (IAnjutaDebuggerCallback
)signals_update
,
592 signals_hide (Signals
* ew
)
596 if (ew
->is_showing
== FALSE
)
598 gdk_window_get_root_origin (ew
->widgets
.window
->window
, &ew
->win_pos_x
,
600 gdk_window_get_size (ew
->widgets
.window
->window
, &ew
->win_width
,
602 gtk_widget_hide (ew
->widgets
.window
);
603 ew
->is_showing
= FALSE
;
608 signals_free (Signals
* sg
)
613 gtk_widget_destroy (sg
->widgets
.window
);
614 gtk_widget_destroy (sg
->widgets
.menu
);