diff options
-rw-r--r-- | trace-filter.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/trace-filter.c b/trace-filter.c index 62a17df..3c1e23b 100644 --- a/trace-filter.c +++ b/trace-filter.c | |||
@@ -191,8 +191,17 @@ void trace_filter_event_dialog(void *trace_tree) | |||
191 | struct cpu_filter_helper { | 191 | struct cpu_filter_helper { |
192 | gboolean allcpus; | 192 | gboolean allcpus; |
193 | guint64 *cpu_mask; | 193 | guint64 *cpu_mask; |
194 | GtkWidget **buttons; | ||
195 | int cpus; | ||
194 | }; | 196 | }; |
195 | 197 | ||
198 | static void destroy_cpu_helper(struct cpu_filter_helper *cpu_helper) | ||
199 | { | ||
200 | g_free(cpu_helper->cpu_mask); | ||
201 | g_free(cpu_helper->buttons); | ||
202 | g_free(cpu_helper); | ||
203 | } | ||
204 | |||
196 | /* Callback for the clicked signal of the CPUS filter button */ | 205 | /* Callback for the clicked signal of the CPUS filter button */ |
197 | static void | 206 | static void |
198 | cpu_dialog_response (gpointer data, gint response_id) | 207 | cpu_dialog_response (gpointer data, gint response_id) |
@@ -201,7 +210,7 @@ cpu_dialog_response (gpointer data, gint response_id) | |||
201 | struct cpu_filter_helper *cpu_helper = helper->data; | 210 | struct cpu_filter_helper *cpu_helper = helper->data; |
202 | GtkTreeView *view = GTK_TREE_VIEW(helper->trace_tree); | 211 | GtkTreeView *view = GTK_TREE_VIEW(helper->trace_tree); |
203 | TraceViewStore *store; | 212 | TraceViewStore *store; |
204 | gint cpus, cpu; | 213 | gint cpu; |
205 | 214 | ||
206 | store = TRACE_VIEW_STORE(gtk_tree_view_get_model(view)); | 215 | store = TRACE_VIEW_STORE(gtk_tree_view_get_model(view)); |
207 | 216 | ||
@@ -216,9 +225,8 @@ cpu_dialog_response (gpointer data, gint response_id) | |||
216 | g_object_unref(store); | 225 | g_object_unref(store); |
217 | break; | 226 | break; |
218 | } | 227 | } |
219 | cpus = trace_view_store_get_cpus(store); | ||
220 | 228 | ||
221 | for (cpu = 0; cpu < cpus; cpu++) { | 229 | for (cpu = 0; cpu < cpu_helper->cpus; cpu++) { |
222 | if (cpu_mask_isset(cpu_helper->cpu_mask, cpu)) | 230 | if (cpu_mask_isset(cpu_helper->cpu_mask, cpu)) |
223 | trace_view_store_set_cpu(store, cpu); | 231 | trace_view_store_set_cpu(store, cpu); |
224 | else | 232 | else |
@@ -236,8 +244,7 @@ cpu_dialog_response (gpointer data, gint response_id) | |||
236 | 244 | ||
237 | gtk_widget_destroy(GTK_WIDGET(helper->dialog)); | 245 | gtk_widget_destroy(GTK_WIDGET(helper->dialog)); |
238 | 246 | ||
239 | g_free(cpu_helper->cpu_mask); | 247 | destroy_cpu_helper(helper->data); |
240 | g_free(cpu_helper); | ||
241 | g_free(helper); | 248 | g_free(helper); |
242 | } | 249 | } |
243 | 250 | ||
@@ -255,16 +262,29 @@ void cpu_toggle(gpointer data, GtkWidget *widget) | |||
255 | 262 | ||
256 | if (strcmp(label, CPU_ALL_CPUS_STR) == 0) { | 263 | if (strcmp(label, CPU_ALL_CPUS_STR) == 0) { |
257 | cpu_helper->allcpus = active; | 264 | cpu_helper->allcpus = active; |
265 | if (active) { | ||
266 | /* enable all toggles */ | ||
267 | for (cpu = 0; cpu < cpu_helper->cpus; cpu++) | ||
268 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]), | ||
269 | TRUE); | ||
270 | } | ||
258 | return; | 271 | return; |
259 | } | 272 | } |
260 | 273 | ||
261 | /* Get the CPU # from the label. Pass "CPU " */ | 274 | /* Get the CPU # from the label. Pass "CPU " */ |
262 | cpu = atoi(label + 4); | 275 | cpu = atoi(label + 4); |
263 | if (active) | 276 | if (active) { |
264 | cpu_mask_set(cpu_helper->cpu_mask, cpu); | 277 | cpu_mask_set(cpu_helper->cpu_mask, cpu); |
265 | else | 278 | return; |
266 | cpu_mask_clear(cpu_helper->cpu_mask, cpu); | 279 | } |
280 | |||
281 | cpu_mask_clear(cpu_helper->cpu_mask, cpu); | ||
267 | 282 | ||
283 | if (!cpu_helper->allcpus) | ||
284 | return; | ||
285 | |||
286 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu_helper->cpus]), | ||
287 | FALSE); | ||
268 | } | 288 | } |
269 | 289 | ||
270 | void trace_filter_cpu_dialog(void *trace_tree) | 290 | void trace_filter_cpu_dialog(void *trace_tree) |
@@ -312,6 +332,10 @@ void trace_filter_cpu_dialog(void *trace_tree) | |||
312 | helper->dialog = dialog; | 332 | helper->dialog = dialog; |
313 | helper->trace_tree = tree_view; | 333 | helper->trace_tree = tree_view; |
314 | 334 | ||
335 | cpu_helper->cpus = cpus; | ||
336 | cpu_helper->buttons = g_new0(GtkWidget *, cpus + 1); | ||
337 | g_assert(cpu_helper->buttons); | ||
338 | |||
315 | g_signal_connect_swapped (dialog, "response", | 339 | g_signal_connect_swapped (dialog, "response", |
316 | G_CALLBACK (cpu_dialog_response), | 340 | G_CALLBACK (cpu_dialog_response), |
317 | (gpointer) helper); | 341 | (gpointer) helper); |
@@ -334,9 +358,12 @@ void trace_filter_cpu_dialog(void *trace_tree) | |||
334 | gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, FALSE, 0); | 358 | gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, FALSE, 0); |
335 | gtk_widget_show(vbox); | 359 | gtk_widget_show(vbox); |
336 | 360 | ||
337 | check = gtk_check_button_new_with_label("All CPUs"); | 361 | check = gtk_check_button_new_with_label(CPU_ALL_CPUS_STR); |
338 | gtk_box_pack_start(GTK_BOX(vbox), check, TRUE, TRUE, 0); | 362 | gtk_box_pack_start(GTK_BOX(vbox), check, TRUE, TRUE, 0); |
339 | 363 | ||
364 | /* The last button will be the all CPUs button */ | ||
365 | cpu_helper->buttons[cpus] = check; | ||
366 | |||
340 | allset = trace_view_store_get_all_cpus(store); | 367 | allset = trace_view_store_get_all_cpus(store); |
341 | if (allset) | 368 | if (allset) |
342 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE); | 369 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE); |
@@ -354,6 +381,7 @@ void trace_filter_cpu_dialog(void *trace_tree) | |||
354 | for (cpu = 0; cpu < cpus; cpu++) { | 381 | for (cpu = 0; cpu < cpus; cpu++) { |
355 | g_snprintf(counter, 100, "CPU %d", cpu); | 382 | g_snprintf(counter, 100, "CPU %d", cpu); |
356 | check = gtk_check_button_new_with_label(counter); | 383 | check = gtk_check_button_new_with_label(counter); |
384 | cpu_helper->buttons[cpu] = check; | ||
357 | gtk_box_pack_start(GTK_BOX(vbox), check, TRUE, FALSE, 0); | 385 | gtk_box_pack_start(GTK_BOX(vbox), check, TRUE, FALSE, 0); |
358 | if (allset || trace_view_store_cpu_isset(store, cpu)) { | 386 | if (allset || trace_view_store_cpu_isset(store, cpu)) { |
359 | cpu_mask_set(cpu_helper->cpu_mask, cpu); | 387 | cpu_mask_set(cpu_helper->cpu_mask, cpu); |