diff options
Diffstat (limited to 'trace-graph-main.c')
-rw-r--r-- | trace-graph-main.c | 124 |
1 files changed, 107 insertions, 17 deletions
diff --git a/trace-graph-main.c b/trace-graph-main.c index b373dd2..b4f05fb 100644 --- a/trace-graph-main.c +++ b/trace-graph-main.c | |||
@@ -29,6 +29,9 @@ | |||
29 | #include "trace-cmd.h" | 29 | #include "trace-cmd.h" |
30 | #include "trace-graph.h" | 30 | #include "trace-graph.h" |
31 | #include "trace-filter.h" | 31 | #include "trace-filter.h" |
32 | #include "trace-gui.h" | ||
33 | |||
34 | #include "version.h" | ||
32 | 35 | ||
33 | #define version "0.1.1" | 36 | #define version "0.1.1" |
34 | 37 | ||
@@ -52,26 +55,19 @@ load_clicked (gpointer data) | |||
52 | { | 55 | { |
53 | struct graph_info *ginfo = data; | 56 | struct graph_info *ginfo = data; |
54 | struct tracecmd_input *handle; | 57 | struct tracecmd_input *handle; |
55 | GtkWidget *dialog; | ||
56 | gchar *filename; | 58 | gchar *filename; |
57 | 59 | ||
58 | dialog = gtk_file_chooser_dialog_new("Load File", | 60 | filename = trace_get_file_dialog("Load File"); |
59 | NULL, | 61 | if (!filename) |
60 | GTK_FILE_CHOOSER_ACTION_OPEN, | 62 | return; |
61 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | 63 | |
62 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | 64 | handle = tracecmd_open(filename); |
63 | NULL); | 65 | if (handle) { |
64 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { | 66 | trace_graph_load_handle(ginfo, handle); |
65 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); | 67 | /* Free handle when freeing graph */ |
66 | handle = tracecmd_open(filename); | 68 | tracecmd_close(handle); |
67 | if (handle) { | ||
68 | trace_graph_load_handle(ginfo, handle); | ||
69 | /* Free handle when freeing graph */ | ||
70 | tracecmd_close(handle); | ||
71 | } | ||
72 | g_free(filename); | ||
73 | } | 69 | } |
74 | gtk_widget_destroy(dialog); | 70 | g_free(filename); |
75 | } | 71 | } |
76 | 72 | ||
77 | /* Callback for the clicked signal of the Exit button */ | 73 | /* Callback for the clicked signal of the Exit button */ |
@@ -158,6 +154,60 @@ plot_tasks_clicked (gpointer data) | |||
158 | free(selected); | 154 | free(selected); |
159 | } | 155 | } |
160 | 156 | ||
157 | /* Callback for the clicked signal of the Load Filters button */ | ||
158 | static void | ||
159 | load_filters_clicked (gpointer data) | ||
160 | { | ||
161 | struct graph_info *ginfo = data; | ||
162 | struct tracecmd_xml_handle *handle; | ||
163 | gchar *filename; | ||
164 | |||
165 | filename = trace_get_file_dialog("Load Filters"); | ||
166 | if (!filename) | ||
167 | return; | ||
168 | |||
169 | handle = tracecmd_xml_open(filename); | ||
170 | if (!handle) | ||
171 | warning("Could not open %s", filename); | ||
172 | g_free(filename); | ||
173 | |||
174 | trace_filter_load_filters(handle, | ||
175 | "GraphTaskFilter", | ||
176 | ginfo->task_filter, | ||
177 | ginfo->hide_tasks); | ||
178 | |||
179 | trace_graph_load_filters(ginfo, handle); | ||
180 | |||
181 | tracecmd_xml_close(handle); | ||
182 | } | ||
183 | |||
184 | /* Callback for the clicked signal of the Save Filters button */ | ||
185 | static void | ||
186 | save_filters_clicked (gpointer data) | ||
187 | { | ||
188 | struct graph_info *ginfo = data; | ||
189 | struct tracecmd_xml_handle *handle; | ||
190 | gchar *filename; | ||
191 | |||
192 | filename = trace_get_file_dialog("Save Filters"); | ||
193 | if (!filename) | ||
194 | return; | ||
195 | |||
196 | handle = tracecmd_xml_create(filename, VERSION_STRING); | ||
197 | if (!handle) | ||
198 | warning("Could not create %s", filename); | ||
199 | g_free(filename); | ||
200 | |||
201 | trace_filter_save_filters(handle, | ||
202 | "GraphTaskFilter", | ||
203 | ginfo->task_filter, | ||
204 | ginfo->hide_tasks); | ||
205 | |||
206 | trace_graph_save_filters(ginfo, handle); | ||
207 | |||
208 | tracecmd_xml_close(handle); | ||
209 | } | ||
210 | |||
161 | void trace_graph(int argc, char **argv) | 211 | void trace_graph(int argc, char **argv) |
162 | { | 212 | { |
163 | struct tracecmd_input *handle = NULL; | 213 | struct tracecmd_input *handle = NULL; |
@@ -170,6 +220,7 @@ void trace_graph(int argc, char **argv) | |||
170 | GtkWidget *menu_item; | 220 | GtkWidget *menu_item; |
171 | GtkWidget *sub_item; | 221 | GtkWidget *sub_item; |
172 | GtkWidget *widget; | 222 | GtkWidget *widget; |
223 | GtkWidget *statusbar; | ||
173 | int c; | 224 | int c; |
174 | int ret; | 225 | int ret; |
175 | 226 | ||
@@ -215,6 +266,8 @@ void trace_graph(int argc, char **argv) | |||
215 | 266 | ||
216 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 267 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
217 | 268 | ||
269 | trace_dialog_register_window(window); | ||
270 | |||
218 | /* --- Top Level Vbox --- */ | 271 | /* --- Top Level Vbox --- */ |
219 | 272 | ||
220 | vbox = gtk_vbox_new(FALSE, 0); | 273 | vbox = gtk_vbox_new(FALSE, 0); |
@@ -253,6 +306,35 @@ void trace_graph(int argc, char **argv) | |||
253 | gtk_widget_show(sub_item); | 306 | gtk_widget_show(sub_item); |
254 | 307 | ||
255 | 308 | ||
309 | /* --- File - Load Filter Option --- */ | ||
310 | |||
311 | sub_item = gtk_menu_item_new_with_label("Load filters"); | ||
312 | |||
313 | /* Add them to the menu */ | ||
314 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | ||
315 | |||
316 | g_signal_connect_swapped (G_OBJECT (sub_item), "activate", | ||
317 | G_CALLBACK (load_filters_clicked), | ||
318 | (gpointer) ginfo); | ||
319 | |||
320 | /* We do need to show menu items */ | ||
321 | gtk_widget_show(sub_item); | ||
322 | |||
323 | |||
324 | /* --- File - Save Filter Option --- */ | ||
325 | |||
326 | sub_item = gtk_menu_item_new_with_label("Save filters"); | ||
327 | |||
328 | /* Add them to the menu */ | ||
329 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); | ||
330 | |||
331 | g_signal_connect_swapped (G_OBJECT (sub_item), "activate", | ||
332 | G_CALLBACK (save_filters_clicked), | ||
333 | (gpointer) ginfo); | ||
334 | |||
335 | /* We do need to show menu items */ | ||
336 | gtk_widget_show(sub_item); | ||
337 | |||
256 | /* --- File - Quit Option --- */ | 338 | /* --- File - Quit Option --- */ |
257 | 339 | ||
258 | sub_item = gtk_menu_item_new_with_label("Quit"); | 340 | sub_item = gtk_menu_item_new_with_label("Quit"); |
@@ -380,6 +462,14 @@ void trace_graph(int argc, char **argv) | |||
380 | gtk_widget_show(widget); | 462 | gtk_widget_show(widget); |
381 | 463 | ||
382 | 464 | ||
465 | /* --- Set up Status Bar --- */ | ||
466 | |||
467 | statusbar = trace_status_bar_new(); | ||
468 | |||
469 | gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0); | ||
470 | gtk_widget_show(statusbar); | ||
471 | |||
472 | |||
383 | /********************************************** | 473 | /********************************************** |
384 | * Main Window | 474 | * Main Window |
385 | **********************************************/ | 475 | **********************************************/ |