1 /*
2 * Copyright (c) Tony Bybell 1999.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 */
9
10 #include "globals.h"
11 #include <config.h>
12 #include "currenttime.h"
13 #include "pixmaps.h"
14 #include "debug.h"
15
16
17 void
fetch_left(GtkWidget * text,gpointer data)18 fetch_left(GtkWidget *text, gpointer data)
19 {
20 (void)text;
21 (void)data;
22
23 TimeType newlo;
24 char fromstr[32];
25
26 if(GLOBALS->helpbox_is_active)
27 {
28 help_text_bold("\n\nFetch Left");
29 help_text(
30 " decreases the \"From\" time, which allows more of the trace"
31 " to be displayed if the \"From\" and \"To\" times do not match"
32 " the actual bounds of the trace."
33 );
34 return;
35 }
36
37
38 DEBUG(printf("Fetch Left\n"));
39
40 newlo=(GLOBALS->tims.first)-GLOBALS->fetchwindow;
41
42 if(newlo<=GLOBALS->min_time) newlo=GLOBALS->min_time;
43
44 reformat_time(fromstr, newlo, GLOBALS->time_dimension);
45
46 gtk_entry_set_text(GTK_ENTRY(GLOBALS->from_entry),fromstr);
47
48 if(newlo<(GLOBALS->tims.last))
49 {
50 GLOBALS->tims.first=newlo;
51 if(GLOBALS->tims.start<GLOBALS->tims.first) GLOBALS->tims.start=GLOBALS->tims.first;
52
53 time_update();
54 }
55 }
56
57
58 void
fetch_right(GtkWidget * text,gpointer data)59 fetch_right(GtkWidget *text, gpointer data)
60 {
61 (void)text;
62 (void)data;
63
64 TimeType newhi;
65 char tostr[32];
66
67 if(GLOBALS->helpbox_is_active)
68 {
69 help_text_bold("\n\nFetch Right");
70 help_text(
71 " increases the \"To\" time, which allows more of the trace"
72 " to be displayed if the \"From\" and \"To\" times do not match"
73 " the actual bounds of the trace."
74 );
75 return;
76 }
77
78
79 DEBUG(printf("Fetch Right\n"));
80
81 newhi=(GLOBALS->tims.last)+GLOBALS->fetchwindow;
82
83 if(newhi>=GLOBALS->max_time) newhi=GLOBALS->max_time;
84
85 reformat_time(tostr, newhi, GLOBALS->time_dimension);
86
87 gtk_entry_set_text(GTK_ENTRY(GLOBALS->to_entry),tostr);
88
89 if(newhi>(GLOBALS->tims.first))
90 {
91 GLOBALS->tims.last=newhi;
92 time_update();
93 }
94 }
95
96
97 void
discard_left(GtkWidget * text,gpointer data)98 discard_left(GtkWidget *text, gpointer data)
99 {
100 (void)text;
101 (void)data;
102
103 TimeType newlo;
104 char tostr[32];
105
106 if(GLOBALS->helpbox_is_active)
107 {
108 help_text_bold("\n\nDiscard Left");
109 help_text(
110 " increases the \"From\" time, which allows less of the trace"
111 " to be displayed."
112 );
113 return;
114 }
115
116
117 DEBUG(printf("Discard Left\n"));
118
119 newlo=(GLOBALS->tims.first)+GLOBALS->fetchwindow;
120
121 if(newlo<(GLOBALS->tims.last))
122 {
123 reformat_time(tostr, newlo, GLOBALS->time_dimension);
124 gtk_entry_set_text(GTK_ENTRY(GLOBALS->from_entry),tostr);
125
126 GLOBALS->tims.first=newlo;
127 time_update();
128 }
129 }
130
131 void
discard_right(GtkWidget * text,gpointer data)132 discard_right(GtkWidget *text, gpointer data)
133 {
134 (void)text;
135 (void)data;
136
137 TimeType newhi;
138 char tostr[32];
139
140 if(GLOBALS->helpbox_is_active)
141 {
142 help_text_bold("\n\nDiscard Right");
143 help_text(
144 " decreases the \"To\" time, which allows less of the trace"
145 " to be displayed."
146 );
147 return;
148 }
149
150
151 DEBUG(printf("Discard Right\n"));
152
153 newhi=(GLOBALS->tims.last)-GLOBALS->fetchwindow;
154
155 if(newhi>(GLOBALS->tims.first))
156 {
157 reformat_time(tostr, newhi, GLOBALS->time_dimension);
158 gtk_entry_set_text(GTK_ENTRY(GLOBALS->to_entry),tostr);
159
160 GLOBALS->tims.last=newhi;
161 time_update();
162 }
163 }
164
165 /* Create actual buttons */
166 GtkWidget *
create_fetch_buttons(void)167 create_fetch_buttons (void)
168 {
169 GtkWidget *table;
170 GtkWidget *table2;
171 GtkWidget *frame;
172 GtkWidget *main_vbox;
173 GtkWidget *b1;
174 GtkWidget *b2;
175 GtkWidget *pixmapwid1, *pixmapwid2;
176
177 GtkTooltips *tooltips;
178
179 tooltips=gtk_tooltips_new_2();
180 gtk_tooltips_set_delay_2(tooltips,1500);
181
182 pixmapwid1=gtk_pixmap_new(GLOBALS->larrow_pixmap, GLOBALS->larrow_mask);
183 gtk_widget_show(pixmapwid1);
184 pixmapwid2=gtk_pixmap_new(GLOBALS->rarrow_pixmap, GLOBALS->rarrow_mask);
185 gtk_widget_show(pixmapwid2);
186
187 /* Create a table to hold the text widget and scrollbars */
188 table = gtk_table_new (1, 1, FALSE);
189
190 main_vbox = gtk_vbox_new (FALSE, 1);
191 gtk_container_border_width (GTK_CONTAINER (main_vbox), 1);
192 gtk_container_add (GTK_CONTAINER (table), main_vbox);
193
194 frame = gtk_frame_new ("Fetch ");
195 gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
196
197 gtk_widget_show (frame);
198 gtk_widget_show (main_vbox);
199
200 table2 = gtk_table_new (2, 1, FALSE);
201
202 b1 = gtk_button_new();
203 gtk_container_add(GTK_CONTAINER(b1), pixmapwid1);
204 gtk_table_attach (GTK_TABLE (table2), b1, 0, 1, 0, 1,
205 GTK_FILL | GTK_EXPAND,
206 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);
207 gtk_signal_connect_object (GTK_OBJECT (b1), "clicked", GTK_SIGNAL_FUNC(fetch_left), GTK_OBJECT (table2));
208 gtk_tooltips_set_tip_2(tooltips, b1, "Decrease 'From' Time", NULL);
209 gtk_widget_show(b1);
210
211 b2 = gtk_button_new();
212 gtk_container_add(GTK_CONTAINER(b2), pixmapwid2);
213 gtk_table_attach (GTK_TABLE (table2), b2, 0, 1, 1, 2,
214 GTK_FILL | GTK_EXPAND,
215 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 1, 1);
216 gtk_signal_connect_object (GTK_OBJECT (b2), "clicked", GTK_SIGNAL_FUNC(fetch_right), GTK_OBJECT (table2));
217 gtk_tooltips_set_tip_2(tooltips, b2, "Increase 'To' Time", NULL);
218 gtk_widget_show(b2);
219
220 gtk_container_add (GTK_CONTAINER (frame), table2);
221 gtk_widget_show(table2);
222 return(table);
223 }
224
225