diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-06-11 18:29:45 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-06-11 18:29:45 -0400 |
| commit | f9c3158cafeb176f2c8e39103dfab835f0ee4c40 (patch) | |
| tree | 3eab6db9a663e534d6bd6582735bb7cb6955187f | |
| parent | 001e4d2dbc3a8d0304e3794edb27729817248b95 (diff) | |
kernelshark: Add helper function trace_create_combo_box()
Add helper function trace_create_combo_box() and use it for
in trace-filter.c. This will be used by other functions needing
to make a label followed by a combo box.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-dialog.c | 49 | ||||
| -rw-r--r-- | trace-filter.c | 42 | ||||
| -rw-r--r-- | trace-gui.h | 4 |
3 files changed, 61 insertions, 34 deletions
diff --git a/trace-dialog.c b/trace-dialog.c index f4348c9..4fab040 100644 --- a/trace-dialog.c +++ b/trace-dialog.c | |||
| @@ -302,3 +302,52 @@ gchar *trace_get_file_dialog(const gchar *title) | |||
| 302 | 302 | ||
| 303 | return filename; | 303 | return filename; |
| 304 | } | 304 | } |
| 305 | |||
| 306 | /** | ||
| 307 | * trace_create_combo_box - helper function to create a label and combo box | ||
| 308 | * @hbox: The hbox to add the label and combo box to | ||
| 309 | * @text: The text of the label | ||
| 310 | * @combo_model_create: The function used to create the combo model | ||
| 311 | * @data: data to pass to the combo_model_create. | ||
| 312 | * | ||
| 313 | * Returns the combo box in the hbox. | ||
| 314 | */ | ||
| 315 | GtkWidget * | ||
| 316 | trace_create_combo_box(GtkWidget *hbox, const gchar *text, | ||
| 317 | GtkTreeModel *(*combo_model_create)(gpointer data), | ||
| 318 | gpointer data) | ||
| 319 | { | ||
| 320 | GtkCellRenderer *renderer; | ||
| 321 | GtkTreeModel *model; | ||
| 322 | GtkWidget *label; | ||
| 323 | GtkWidget *combo; | ||
| 324 | |||
| 325 | label = gtk_label_new(text); | ||
| 326 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | ||
| 327 | gtk_widget_show(label); | ||
| 328 | |||
| 329 | /* --- Set up the selection combo box --- */ | ||
| 330 | |||
| 331 | model = combo_model_create(data); | ||
| 332 | |||
| 333 | renderer = gtk_cell_renderer_text_new(); | ||
| 334 | |||
| 335 | combo = gtk_combo_box_new_with_model(model); | ||
| 336 | gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0); | ||
| 337 | gtk_widget_show(combo); | ||
| 338 | |||
| 339 | /* Free model with combobox */ | ||
| 340 | g_object_unref(model); | ||
| 341 | |||
| 342 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), | ||
| 343 | renderer, | ||
| 344 | TRUE); | ||
| 345 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), | ||
| 346 | renderer, | ||
| 347 | "text", 0, | ||
| 348 | NULL); | ||
| 349 | |||
| 350 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
| 351 | |||
| 352 | return combo; | ||
| 353 | } | ||
diff --git a/trace-filter.c b/trace-filter.c index 9c220ee..7bdad15 100644 --- a/trace-filter.c +++ b/trace-filter.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include "trace-local.h" | 27 | #include "trace-local.h" |
| 28 | #include "trace-view-store.h" | 28 | #include "trace-view-store.h" |
| 29 | #include "trace-view.h" | 29 | #include "trace-view.h" |
| 30 | #include "trace-gui.h" | ||
| 30 | 31 | ||
| 31 | #include "cpu.h" | 32 | #include "cpu.h" |
| 32 | #include "util.h" | 33 | #include "util.h" |
| @@ -95,8 +96,9 @@ struct event_combo_info { | |||
| 95 | GtkWidget *entry; | 96 | GtkWidget *entry; |
| 96 | }; | 97 | }; |
| 97 | 98 | ||
| 98 | static GtkTreeModel *create_event_combo_model(struct pevent *pevent) | 99 | static GtkTreeModel *create_event_combo_model(gpointer data) |
| 99 | { | 100 | { |
| 101 | struct pevent *pevent = data; | ||
| 100 | GtkTreeStore *tree; | 102 | GtkTreeStore *tree; |
| 101 | GtkTreeIter sys_iter; | 103 | GtkTreeIter sys_iter; |
| 102 | GtkTreeIter iter; | 104 | GtkTreeIter iter; |
| @@ -131,7 +133,7 @@ static GtkTreeModel *create_event_combo_model(struct pevent *pevent) | |||
| 131 | return GTK_TREE_MODEL(tree); | 133 | return GTK_TREE_MODEL(tree); |
| 132 | } | 134 | } |
| 133 | 135 | ||
| 134 | static GtkTreeModel *create_op_combo_model(struct pevent *pevent) | 136 | static GtkTreeModel *create_op_combo_model(gpointer data) |
| 135 | { | 137 | { |
| 136 | GtkListStore *list; | 138 | GtkListStore *list; |
| 137 | GtkTreeIter iter; | 139 | GtkTreeIter iter; |
| @@ -153,8 +155,9 @@ static GtkTreeModel *create_op_combo_model(struct pevent *pevent) | |||
| 153 | return GTK_TREE_MODEL(list); | 155 | return GTK_TREE_MODEL(list); |
| 154 | } | 156 | } |
| 155 | 157 | ||
| 156 | static GtkTreeModel *create_field_combo_model(struct pevent *pevent) | 158 | static GtkTreeModel *create_field_combo_model(gpointer data) |
| 157 | { | 159 | { |
| 160 | struct pevent *pevent = data; | ||
| 158 | GtkListStore *list; | 161 | GtkListStore *list; |
| 159 | GtkTreeIter iter; | 162 | GtkTreeIter iter; |
| 160 | struct event_format **events; | 163 | struct event_format **events; |
| @@ -361,12 +364,9 @@ static void field_insert_pressed(GtkButton *button, | |||
| 361 | 364 | ||
| 362 | static GtkWidget * | 365 | static GtkWidget * |
| 363 | create_combo_box(struct event_combo_info *info, GtkWidget *hbox, const gchar *text, | 366 | create_combo_box(struct event_combo_info *info, GtkWidget *hbox, const gchar *text, |
| 364 | GtkTreeModel *(*combo_model_create)(struct pevent *pevent), | 367 | GtkTreeModel *(*combo_model_create)(gpointer data), |
| 365 | void (*insert_pressed)(GtkButton *button, gpointer data)) | 368 | void (*insert_pressed)(GtkButton *button, gpointer data)) |
| 366 | { | 369 | { |
| 367 | GtkCellRenderer *renderer; | ||
| 368 | GtkTreeModel *model; | ||
| 369 | GtkWidget *label; | ||
| 370 | GtkWidget *hbox2; | 370 | GtkWidget *hbox2; |
| 371 | GtkWidget *combo; | 371 | GtkWidget *combo; |
| 372 | GtkWidget *button; | 372 | GtkWidget *button; |
| @@ -375,33 +375,7 @@ create_combo_box(struct event_combo_info *info, GtkWidget *hbox, const gchar *te | |||
| 375 | gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0); | 375 | gtk_box_pack_start(GTK_BOX(hbox), hbox2, TRUE, TRUE, 0); |
| 376 | gtk_widget_show(hbox2); | 376 | gtk_widget_show(hbox2); |
| 377 | 377 | ||
| 378 | label = gtk_label_new(text); | 378 | combo = trace_create_combo_box(hbox, text, combo_model_create, info->pevent); |
| 379 | gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0); | ||
| 380 | gtk_widget_show(label); | ||
| 381 | |||
| 382 | /* --- Set up the selection combo box --- */ | ||
| 383 | |||
| 384 | model = combo_model_create(info->pevent); | ||
| 385 | |||
| 386 | renderer = gtk_cell_renderer_text_new(); | ||
| 387 | |||
| 388 | combo = gtk_combo_box_new_with_model(model); | ||
| 389 | gtk_box_pack_start(GTK_BOX(hbox2), combo, FALSE, FALSE, 0); | ||
| 390 | gtk_widget_show(combo); | ||
| 391 | |||
| 392 | /* Free model with combobox */ | ||
| 393 | g_object_unref(model); | ||
| 394 | |||
| 395 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), | ||
| 396 | renderer, | ||
| 397 | TRUE); | ||
| 398 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), | ||
| 399 | renderer, | ||
| 400 | "text", 0, | ||
| 401 | NULL); | ||
| 402 | |||
| 403 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||
| 404 | |||
| 405 | 379 | ||
| 406 | /* --- add insert button --- */ | 380 | /* --- add insert button --- */ |
| 407 | 381 | ||
diff --git a/trace-gui.h b/trace-gui.h index bcf8737..a2177b0 100644 --- a/trace-gui.h +++ b/trace-gui.h | |||
| @@ -41,5 +41,9 @@ void trace_dialog(GtkWindow *parent, enum trace_dialog_type type, | |||
| 41 | 41 | ||
| 42 | gchar *trace_get_file_dialog(const gchar *title); | 42 | gchar *trace_get_file_dialog(const gchar *title); |
| 43 | 43 | ||
| 44 | GtkWidget * | ||
| 45 | trace_create_combo_box(GtkWidget *hbox, const gchar *text, | ||
| 46 | GtkTreeModel *(*combo_model_create)(gpointer data), | ||
| 47 | gpointer data); | ||
| 44 | 48 | ||
| 45 | #endif /* _TRACE_GUI */ | 49 | #endif /* _TRACE_GUI */ |
