~ubuntu-branches/debian/sid/geany-plugins/sid

« back to all changes in this revision

Viewing changes to debugger/src/btnpanel.c

  • Committer: Package Import Robot
  • Author(s): Evgeni Golov, Evgeni Golov
  • Date: 2011-11-17 20:03:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111117200324-8qmu6tuwjtfpv3n7
Tags: 0.21.1-1
[ Evgeni Golov ]
* [f4007f2] Imported Upstream version 0.21.1
* [5ff622d] install plugins from/to /usr/lib/<arch-triplet>/geany
* [75411d7] bump build-dep to geany 0.21
* [db92155] depend on the virtual geany-abi-XX package
* [dd84769] switch to 3.0 (quilt)
* [3ab76d7] drop readme.source
* [233d44c] refresh patch against 0.21.1
* [030bec1] add lintian override for
            documentation-package-not-architecture-independent
* [aba43d7] use debhelper compat level 9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      btnpanel.c
 
3
 *      
 
4
 *      Copyright 2010 Alexander Petukhov <devel(at)apetukhov.ru>
 
5
 *      
 
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.
 
10
 *      
 
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.
 
15
 *      
 
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,
 
19
 *      MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
/*
 
23
 *              buttons panel
 
24
 */
 
25
 
 
26
#include <sys/stat.h>
 
27
 
 
28
#ifdef HAVE_CONFIG_H
 
29
        #include "config.h"
 
30
#endif
 
31
#include <geanyplugin.h>
 
32
 
 
33
extern GeanyFunctions   *geany_functions;
 
34
extern GeanyPlugin              *geany_plugin;
 
35
 
 
36
#include "gui.h"
 
37
#include "breakpoints.h"
 
38
#include "debug.h"
 
39
#include "dconfig.h"
 
40
#include "tpage.h"
 
41
#include "watch_model.h"
 
42
#include "wtree.h"
 
43
#include "dpaned.h"
 
44
#include "btnpanel.h"
 
45
 
 
46
#define CP_BUTTONS_PAD 5
 
47
 
 
48
static GtkWidget *runbtn = NULL;
 
49
static GtkWidget *restartbtn = NULL;
 
50
static GtkWidget *stopbtn = NULL;
 
51
 
 
52
static GtkWidget *stepoverbtn = NULL;
 
53
static GtkWidget *stepinbtn = NULL;
 
54
static GtkWidget *stepoutbtn = NULL;
 
55
static GtkWidget *runcursorbtn = NULL;
 
56
 
 
57
static GtkWidget *tabbtn = NULL;
 
58
static GtkWidget *optbtn = NULL;
 
59
 
 
60
/*
 
61
 * calls settings dialog
 
62
 */
 
63
void on_settings(GtkButton *button, gpointer user_data)
 
64
{
 
65
        plugin_show_configure(geany_plugin);
 
66
}
 
67
 
 
68
/*
 
69
 * gets current file and line and calls debug function
 
70
 */
 
71
void on_execute_until(GtkButton *button, gpointer user_data)
 
72
{
 
73
        GeanyDocument *doc = document_get_current();
 
74
        if (doc)
 
75
        {
 
76
                int line = sci_get_current_line(doc->editor->sci) + 1;
 
77
                debug_execute_until(DOC_FILENAME(doc), line);
 
78
        }
 
79
}
 
80
 
 
81
/*
 
82
 * create and initialize buttons panel
 
83
 */
 
84
GtkWidget* btnpanel_create(on_toggle cb)
 
85
{
 
86
        GtkWidget *vbox = gtk_vbox_new(FALSE, CP_BUTTONS_PAD);
 
87
 
 
88
        GtkWidget *hbutton_box = gtk_hbox_new(FALSE, CP_BUTTONS_PAD);
 
89
 
 
90
        runbtn = create_button("run.gif", _("Run"));
 
91
        g_signal_connect(G_OBJECT(runbtn), "clicked", G_CALLBACK (debug_run), (gpointer)TRUE);
 
92
 
 
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);
 
95
        
 
96
        hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
 
97
 
 
98
        restartbtn = create_button("restart.gif", _("Restart"));
 
99
        g_signal_connect(G_OBJECT(restartbtn), "clicked", G_CALLBACK (debug_restart), (gpointer)TRUE);
 
100
 
 
101
        stopbtn = create_button("stop.gif", _("Stop"));
 
102
        g_signal_connect(G_OBJECT(stopbtn), "clicked", G_CALLBACK (debug_stop), (gpointer)TRUE);
 
103
 
 
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);
 
107
 
 
108
        hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
 
109
 
 
110
        stepoverbtn = create_button("step_over.gif", _("Step over"));
 
111
        g_signal_connect(G_OBJECT(stepoverbtn), "clicked", G_CALLBACK (debug_step_over), (gpointer)TRUE);
 
112
 
 
113
        stepinbtn = create_button("step_in.png", _("Step into"));
 
114
        g_signal_connect(G_OBJECT(stepinbtn), "clicked", G_CALLBACK (debug_step_into), (gpointer)TRUE);
 
115
 
 
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);
 
119
 
 
120
        hbutton_box = gtk_hbox_new(TRUE, CP_BUTTONS_PAD);
 
121
 
 
122
        stepoutbtn = create_button("step_out.gif", _("Step out"));
 
123
        g_signal_connect(G_OBJECT(stepoutbtn), "clicked", G_CALLBACK (debug_step_out), (gpointer)TRUE);
 
124
 
 
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);
 
127
 
 
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);
 
131
 
 
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);
 
135
 
 
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);
 
140
 
 
141
        btnpanel_set_debug_state(DBS_IDLE);
 
142
 
 
143
        return vbox;
 
144
}
 
145
 
 
146
/*
 
147
 * set buttons sensitive based on debugger state
 
148
 */
 
149
void btnpanel_set_debug_state(enum dbs state)
 
150
{
 
151
        if (DBS_STOPPED == state)
 
152
        {
 
153
                set_button_image(runbtn, "continue.png");
 
154
                gtk_widget_set_tooltip_text(runbtn, _("Continue"));
 
155
        }
 
156
        else
 
157
        {
 
158
                set_button_image(runbtn, "run.gif");            
 
159
                gtk_widget_set_tooltip_text(runbtn, _("Run"));
 
160
        }
 
161
        
 
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);
 
165
        
 
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);
 
170
}