diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-02-22 21:59:32 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-22 21:59:32 -0500 |
commit | fe67d919aaec589776817b52d7d1c49559cd2b53 (patch) | |
tree | de2ebfc12071ae359f13b2ae462e7187ffd4fd42 | |
parent | ad3eec12fc6035b49177f09d15b2f9fb466fe1fa (diff) |
trace-filter: Added op commbo box to show available ops
Added a ops combo box that lets the user know what ops are
allowed in the advanced filter.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-filter.c | 131 |
1 files changed, 70 insertions, 61 deletions
diff --git a/trace-filter.c b/trace-filter.c index befa209..faf1e89 100644 --- a/trace-filter.c +++ b/trace-filter.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #define DIALOG_WIDTH 400 | 35 | #define DIALOG_WIDTH 400 |
36 | #define DIALOG_HEIGHT 600 | 36 | #define DIALOG_HEIGHT 600 |
37 | 37 | ||
38 | #define TEXT_DIALOG_WIDTH 500 | 38 | #define TEXT_DIALOG_WIDTH 600 |
39 | #define TEXT_DIALOG_HEIGHT 400 | 39 | #define TEXT_DIALOG_HEIGHT 400 |
40 | 40 | ||
41 | int str_cmp(const void *a, const void *b) | 41 | int str_cmp(const void *a, const void *b) |
@@ -95,6 +95,7 @@ void trace_array_add(gint **array, gint *count, gint val) | |||
95 | struct event_combo_info { | 95 | struct event_combo_info { |
96 | struct pevent *pevent; | 96 | struct pevent *pevent; |
97 | GtkWidget *event_combo; | 97 | GtkWidget *event_combo; |
98 | GtkWidget *op_combo; | ||
98 | GtkWidget *field_combo; | 99 | GtkWidget *field_combo; |
99 | }; | 100 | }; |
100 | 101 | ||
@@ -142,6 +143,28 @@ static GtkTreeModel *create_event_combo_model(struct pevent *pevent) | |||
142 | return GTK_TREE_MODEL(tree); | 143 | return GTK_TREE_MODEL(tree); |
143 | } | 144 | } |
144 | 145 | ||
146 | static GtkTreeModel *create_op_combo_model(struct pevent *pevent) | ||
147 | { | ||
148 | GtkListStore *list; | ||
149 | GtkTreeIter iter; | ||
150 | int i; | ||
151 | const gchar *ops[] = {":", ",", "==", "!=", "<", ">", "<=", | ||
152 | ">=", "=~", "!~", "!", "(", ")", "+", | ||
153 | "-", "*", "/", "<<", ">>", "&&", "||", | ||
154 | "&", "|", NULL}; | ||
155 | |||
156 | list = gtk_list_store_new(1, G_TYPE_STRING); | ||
157 | |||
158 | for (i = 0; ops[i]; i++) { | ||
159 | gtk_list_store_append(list, &iter); | ||
160 | gtk_list_store_set(list, &iter, | ||
161 | 0, ops[i], | ||
162 | -1); | ||
163 | } | ||
164 | |||
165 | return GTK_TREE_MODEL(list); | ||
166 | } | ||
167 | |||
145 | static GtkTreeModel *create_field_combo_model(struct pevent *pevent) | 168 | static GtkTreeModel *create_field_combo_model(struct pevent *pevent) |
146 | { | 169 | { |
147 | GtkListStore *list; | 170 | GtkListStore *list; |
@@ -320,6 +343,8 @@ static void insert_combo_text(struct event_combo_info *info, | |||
320 | pos = gtk_editable_get_position(GTK_EDITABLE(entry)); | 343 | pos = gtk_editable_get_position(GTK_EDITABLE(entry)); |
321 | gtk_editable_insert_text(GTK_EDITABLE(entry), text, strlen(text), &pos); | 344 | gtk_editable_insert_text(GTK_EDITABLE(entry), text, strlen(text), &pos); |
322 | gtk_editable_set_position(GTK_EDITABLE(entry), pos); | 345 | gtk_editable_set_position(GTK_EDITABLE(entry), pos); |
346 | gtk_editable_insert_text(GTK_EDITABLE(entry), " ", 1, &pos); | ||
347 | gtk_editable_set_position(GTK_EDITABLE(entry), pos); | ||
323 | 348 | ||
324 | g_free(text); | 349 | g_free(text); |
325 | } | 350 | } |
@@ -332,6 +357,14 @@ static void event_insert_pressed(GtkButton *button, | |||
332 | insert_combo_text(info, GTK_COMBO_BOX(info->event_combo)); | 357 | insert_combo_text(info, GTK_COMBO_BOX(info->event_combo)); |
333 | } | 358 | } |
334 | 359 | ||
360 | static void op_insert_pressed(GtkButton *button, | ||
361 | gpointer data) | ||
362 | { | ||
363 | struct event_combo_info *info = data; | ||
364 | |||
365 | insert_combo_text(info, GTK_COMBO_BOX(info->op_combo)); | ||
366 | } | ||
367 | |||
335 | static void field_insert_pressed(GtkButton *button, | 368 | static void field_insert_pressed(GtkButton *button, |
336 | gpointer data) | 369 | gpointer data) |
337 | { | 370 | { |
@@ -340,50 +373,48 @@ static void field_insert_pressed(GtkButton *button, | |||
340 | insert_combo_text(info, GTK_COMBO_BOX(info->field_combo)); | 373 | insert_combo_text(info, GTK_COMBO_BOX(info->field_combo)); |
341 | } | 374 | } |
342 | 375 | ||
343 | static GtkWidget *event_info_box(struct event_combo_info *info) | 376 | static GtkWidget * |
377 | create_combo_box(struct event_combo_info *info, GtkWidget *hbox, const gchar *text, | ||
378 | GtkTreeModel *(*combo_model_create)(struct pevent *pevent), | ||
379 | void (*insert_pressed)(GtkButton *button, gpointer data)) | ||
344 | { | 380 | { |
345 | GtkWidget *hbox; | ||
346 | GtkWidget *hbox2; | ||
347 | GtkWidget *label; | ||
348 | GtkCellRenderer *renderer; | 381 | GtkCellRenderer *renderer; |
349 | GtkTreeModel *model; | 382 | GtkTreeModel *model; |
350 | GtkWidget *event_combo; | 383 | GtkWidget *label; |
351 | GtkWidget *field_combo; | 384 | GtkWidget *hbox2; |
385 | GtkWidget *combo; | ||
352 | GtkWidget *button; | 386 | GtkWidget *button; |
353 | 387 | ||
354 | hbox = gtk_hbox_new(FALSE, 0); | ||
355 | |||
356 | hbox2 = gtk_hbox_new(FALSE, 0); | 388 | hbox2 = gtk_hbox_new(FALSE, 0); |
357 | gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0); | 389 | gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0); |
358 | gtk_widget_show(hbox2); | 390 | gtk_widget_show(hbox2); |
359 | 391 | ||
360 | 392 | label = gtk_label_new(text); | |
361 | label = gtk_label_new("Event:"); | ||
362 | gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); | 393 | gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); |
363 | gtk_widget_show(label); | 394 | gtk_widget_show(label); |
364 | 395 | ||
365 | /* --- Set up the event selection combo box --- */ | 396 | /* --- Set up the selection combo box --- */ |
366 | 397 | ||
367 | model = create_event_combo_model(info->pevent); | 398 | model = combo_model_create(info->pevent); |
368 | 399 | ||
369 | renderer = gtk_cell_renderer_text_new(); | 400 | renderer = gtk_cell_renderer_text_new(); |
370 | 401 | ||
371 | event_combo = gtk_combo_box_new_with_model(model); | 402 | combo = gtk_combo_box_new_with_model(model); |
372 | gtk_box_pack_start(GTK_BOX(hbox2), event_combo, FALSE, FALSE, 0); | 403 | gtk_box_pack_start(GTK_BOX(hbox2), combo, FALSE, FALSE, 0); |
373 | gtk_widget_show(event_combo); | 404 | gtk_widget_show(combo); |
374 | 405 | ||
375 | /* Free model with combobox */ | 406 | /* Free model with combobox */ |
376 | g_object_unref(model); | 407 | g_object_unref(model); |
377 | 408 | ||
378 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(event_combo), | 409 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), |
379 | renderer, | 410 | renderer, |
380 | TRUE); | 411 | TRUE); |
381 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(event_combo), | 412 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), |
382 | renderer, | 413 | renderer, |
383 | "text", 0, | 414 | "text", 0, |
384 | NULL); | 415 | NULL); |
385 | 416 | ||
386 | gtk_combo_box_set_active(GTK_COMBO_BOX(event_combo), 0); | 417 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); |
387 | 418 | ||
388 | 419 | ||
389 | /* --- add insert button --- */ | 420 | /* --- add insert button --- */ |
@@ -392,56 +423,33 @@ static GtkWidget *event_info_box(struct event_combo_info *info) | |||
392 | gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); | 423 | gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); |
393 | gtk_widget_show(button); | 424 | gtk_widget_show(button); |
394 | 425 | ||
395 | |||
396 | g_signal_connect (button, "pressed", | 426 | g_signal_connect (button, "pressed", |
397 | G_CALLBACK (event_insert_pressed), | 427 | G_CALLBACK (insert_pressed), |
398 | (gpointer) info); | 428 | (gpointer) info); |
399 | 429 | ||
430 | return combo; | ||
431 | } | ||
400 | 432 | ||
401 | /* --- second hbox ---- */ | 433 | static GtkWidget *event_info_box(struct event_combo_info *info) |
402 | 434 | { | |
403 | hbox2 = gtk_hbox_new(FALSE, 0); | 435 | GtkWidget *hbox; |
404 | gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0); | 436 | GtkWidget *event_combo; |
405 | gtk_widget_show(hbox2); | 437 | GtkWidget *op_combo; |
406 | 438 | GtkWidget *field_combo; | |
407 | label = gtk_label_new("Field:"); | ||
408 | gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); | ||
409 | gtk_widget_show(label); | ||
410 | |||
411 | |||
412 | /* --- Set up the field selection combo box --- */ | ||
413 | |||
414 | model = create_field_combo_model(info->pevent); | ||
415 | |||
416 | renderer = gtk_cell_renderer_text_new(); | ||
417 | |||
418 | field_combo = gtk_combo_box_new_with_model(model); | ||
419 | gtk_box_pack_start(GTK_BOX(hbox2), field_combo, FALSE, FALSE, 0); | ||
420 | gtk_widget_show(field_combo); | ||
421 | |||
422 | /* Free model with combobox */ | ||
423 | g_object_unref(model); | ||
424 | |||
425 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(field_combo), | ||
426 | renderer, | ||
427 | TRUE); | ||
428 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(field_combo), | ||
429 | renderer, | ||
430 | "text", 0, | ||
431 | NULL); | ||
432 | |||
433 | gtk_combo_box_set_active(GTK_COMBO_BOX(field_combo), 0); | ||
434 | 439 | ||
440 | hbox = gtk_hbox_new(FALSE, 0); | ||
435 | 441 | ||
436 | /* --- add insert button --- */ | 442 | event_combo = create_combo_box(info, hbox, "Event:", |
443 | create_event_combo_model, | ||
444 | event_insert_pressed); | ||
437 | 445 | ||
438 | button = gtk_button_new_with_label("Insert"); | 446 | op_combo = create_combo_box(info, hbox, "Op:", |
439 | gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0); | 447 | create_op_combo_model, |
440 | gtk_widget_show(button); | 448 | op_insert_pressed); |
441 | 449 | ||
442 | g_signal_connect (button, "pressed", | 450 | field_combo = create_combo_box(info, hbox, "Field:", |
443 | G_CALLBACK (field_insert_pressed), | 451 | create_field_combo_model, |
444 | (gpointer) info); | 452 | field_insert_pressed); |
445 | 453 | ||
446 | 454 | ||
447 | g_signal_connect (event_combo, "changed", | 455 | g_signal_connect (event_combo, "changed", |
@@ -449,6 +457,7 @@ static GtkWidget *event_info_box(struct event_combo_info *info) | |||
449 | (gpointer) info); | 457 | (gpointer) info); |
450 | 458 | ||
451 | info->event_combo = event_combo; | 459 | info->event_combo = event_combo; |
460 | info->op_combo = op_combo; | ||
452 | info->field_combo = field_combo; | 461 | info->field_combo = field_combo; |
453 | 462 | ||
454 | return hbox; | 463 | return hbox; |