4
* Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru>
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,
31
#include <geanyplugin.h>
33
extern GeanyFunctions *geany_functions;
34
extern GeanyPlugin *geany_plugin;
37
#include "breakpoints.h"
41
#include "watch_model.h"
46
#define CP_BUTTONS_PAD 5
48
static GtkWidget *runbtn = NULL;
49
static GtkWidget *restartbtn = NULL;
50
static GtkWidget *stopbtn = NULL;
52
static GtkWidget *stepoverbtn = NULL;
53
static GtkWidget *stepinbtn = NULL;
54
static GtkWidget *stepoutbtn = NULL;
55
static GtkWidget *runcursorbtn = NULL;
57
static GtkWidget *tabbtn = NULL;
58
static GtkWidget *optbtn = NULL;
61
* calls settings dialog
63
void on_settings(GtkButton *button, gpointer user_data)
65
plugin_show_configure(geany_plugin);
69
* gets current file and line and calls debug function
71
void on_execute_until(GtkButton *button, gpointer user_data)
73
GeanyDocument *doc = document_get_current();
76
int line = sci_get_current_line(doc->editor->sci) + 1;
77
debug_execute_until(DOC_FILENAME(doc), line);
82
* create and initialize buttons panel
84
GtkWidget* btnpanel_create(on_toggle cb)
86
GtkWidget *vbox = gtk_vbox_new(FALSE, CP_BUTTONS_PAD);
88
GtkWidget *hbutton_box = gtk_hbox_new(FALSE, CP_BUTTONS_PAD);
90
runbtn = create_button("run.gif", _("Run"));
91
g_signal_connect(G_OBJECT(runbtn), "clicked", G_CALLBACK (debug_run), (gpointer)TRUE);
93
gtk_box_pack_start(GTK_BOX(hbutton_box), runbtn, TRUE, TRUE, 0);
94
gtk_box_pack_start(GTK_BOX(vbox), hbutton_box, FALSE, TRUE, 0);
96
hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
98
restartbtn = create_button("restart.gif", _("Restart"));
99
g_signal_connect(G_OBJECT(restartbtn), "clicked", G_CALLBACK (debug_restart), (gpointer)TRUE);
101
stopbtn = create_button("stop.gif", _("Stop"));
102
g_signal_connect(G_OBJECT(stopbtn), "clicked", G_CALLBACK (debug_stop), (gpointer)TRUE);
104
gtk_box_pack_start(GTK_BOX(hbutton_box), restartbtn, FALSE, TRUE, 0);
105
gtk_box_pack_start(GTK_BOX(hbutton_box), stopbtn, FALSE, TRUE, 0);
106
gtk_box_pack_start(GTK_BOX(vbox), hbutton_box, FALSE, TRUE, 0);
108
hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
110
stepoverbtn = create_button("step_over.gif", _("Step over"));
111
g_signal_connect(G_OBJECT(stepoverbtn), "clicked", G_CALLBACK (debug_step_over), (gpointer)TRUE);
113
stepinbtn = create_button("step_in.png", _("Step into"));
114
g_signal_connect(G_OBJECT(stepinbtn), "clicked", G_CALLBACK (debug_step_into), (gpointer)TRUE);
116
gtk_box_pack_start(GTK_BOX(hbutton_box), stepoverbtn, FALSE, TRUE, 0);
117
gtk_box_pack_start(GTK_BOX(hbutton_box), stepinbtn, FALSE, TRUE, 0);
118
gtk_box_pack_start(GTK_BOX(vbox), hbutton_box, FALSE, TRUE, 0);
120
hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
122
stepoutbtn = create_button("step_out.gif", _("Step out"));
123
g_signal_connect(G_OBJECT(stepoutbtn), "clicked", G_CALLBACK (debug_step_out), (gpointer)TRUE);
125
runcursorbtn = create_button("run_to_cursor.gif", _("Run to cursor"));
126
g_signal_connect(G_OBJECT(runcursorbtn), "clicked", G_CALLBACK (on_execute_until), (gpointer)TRUE);
128
gtk_box_pack_start(GTK_BOX(hbutton_box), stepoutbtn, FALSE, TRUE, 0);
129
gtk_box_pack_start(GTK_BOX(hbutton_box), runcursorbtn, FALSE, TRUE, 0);
130
gtk_box_pack_start(GTK_BOX(vbox), hbutton_box, FALSE, TRUE, 0);
132
optbtn = create_stock_button(GTK_STOCK_PREFERENCES, _("Settings"));
133
g_signal_connect(G_OBJECT(optbtn), "clicked", G_CALLBACK (on_settings), NULL);
134
gtk_box_pack_end(GTK_BOX(vbox), optbtn, FALSE, FALSE, 0);
136
tabbtn = create_toggle_button("tabs.gif", _("Two panel mode"));
137
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tabbtn), config_get_tabbed());
138
g_signal_connect(G_OBJECT(tabbtn), "toggled", G_CALLBACK(cb), NULL);
139
gtk_box_pack_end(GTK_BOX(vbox), tabbtn, FALSE, FALSE, 0);
141
btnpanel_set_debug_state(DBS_IDLE);
147
* set buttons sensitive based on debugger state
149
void btnpanel_set_debug_state(enum dbs state)
151
if (DBS_STOPPED == state)
153
set_button_image(runbtn, "continue.png");
154
gtk_widget_set_tooltip_text(runbtn, _("Continue"));
158
set_button_image(runbtn, "run.gif");
159
gtk_widget_set_tooltip_text(runbtn, _("Run"));
162
gtk_widget_set_sensitive(runbtn, DBS_IDLE == state || DBS_STOPPED == state);
163
gtk_widget_set_sensitive(restartbtn, DBS_STOPPED == state);
164
gtk_widget_set_sensitive(stopbtn, DBS_IDLE != state);
166
gtk_widget_set_sensitive(stepoverbtn, DBS_STOPPED == state);
167
gtk_widget_set_sensitive(stepinbtn, DBS_STOPPED == state);
168
gtk_widget_set_sensitive(stepoutbtn, DBS_STOPPED == state);
169
gtk_widget_set_sensitive(runcursorbtn, DBS_STOPPED == state);