aboutsummaryrefslogtreecommitdiffstats
path: root/kernel-shark.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-03-30 16:45:31 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-04-09 11:56:17 -0400
commit810abc5b84f2855cc328cb709e75046a646be463 (patch)
tree4fdd360cfb3bc31b24696d93d0803e1343bde99b /kernel-shark.c
parent395ef10599bb35b100ecf3a87bad9a22d010b178 (diff)
kernelshark: Created trace_get_file_dialog() to ask for filename
Added shortcut trace_get_file_dialog() to simplify the asking for a file name. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel-shark.c')
-rw-r--r--kernel-shark.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index 58aa860..d913ae0 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -141,28 +141,21 @@ load_clicked (gpointer data)
141{ 141{
142 struct shark_info *info = data; 142 struct shark_info *info = data;
143 struct tracecmd_input *handle; 143 struct tracecmd_input *handle;
144 GtkWidget *dialog;
145 gchar *filename; 144 gchar *filename;
146 145
147 dialog = gtk_file_chooser_dialog_new("Load File", 146 filename = trace_get_file_dialog("Load File");
148 NULL, 147 if (!filename)
149 GTK_FILE_CHOOSER_ACTION_OPEN, 148 return;
150 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 149
151 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 150 handle = tracecmd_open(filename);
152 NULL); 151 if (handle) {
153 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { 152 tracecmd_close(info->handle);
154 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 153 info->handle = handle;
155 handle = tracecmd_open(filename); 154 trace_graph_load_handle(info->ginfo, handle);
156 if (handle) { 155 trace_view_reload(info->treeview, handle, info->spin);
157 tracecmd_close(info->handle); 156 update_title(info->window, filename);
158 info->handle = handle;
159 trace_graph_load_handle(info->ginfo, handle);
160 trace_view_reload(info->treeview, handle, info->spin);
161 update_title(info->window, filename);
162 }
163 g_free(filename);
164 } 157 }
165 gtk_widget_destroy(dialog); 158 g_free(filename);
166} 159}
167 160
168/* Callback for the clicked signal of the Exit button */ 161/* Callback for the clicked signal of the Exit button */
@@ -763,12 +756,11 @@ void kernel_shark(int argc, char **argv)
763 756
764 /* --- File - Load Option --- */ 757 /* --- File - Load Option --- */
765 758
766 sub_item = gtk_menu_item_new_with_label("Load info"); 759 sub_item = gtk_menu_item_new_with_label("Load data");
767 760
768 /* Add them to the menu */ 761 /* Add them to the menu */
769 gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item); 762 gtk_menu_shell_append(GTK_MENU_SHELL (menu), sub_item);
770 763
771 /* We can attach the Quit menu item to our exit function */
772 g_signal_connect_swapped (G_OBJECT (sub_item), "activate", 764 g_signal_connect_swapped (G_OBJECT (sub_item), "activate",
773 G_CALLBACK (load_clicked), 765 G_CALLBACK (load_clicked),
774 (gpointer) info); 766 (gpointer) info);