X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmodules%2Fgui%2Ffilter%2Ffilter.c;h=66108652e08061c69766f72a62cbf8c8e8afcd90;hb=0305fe774206ec12a98378be3cf891446b1b901c;hp=dab7d1f3125ac305d4a4a1a2babdf8721d209cf3;hpb=7b5f6cf19fe5b312dc0c5712b0fceddeed2fe11f;p=lttv.git diff --git a/ltt/branches/poly/lttv/modules/gui/filter/filter.c b/ltt/branches/poly/lttv/modules/gui/filter/filter.c index dab7d1f3..66108652 100644 --- a/ltt/branches/poly/lttv/modules/gui/filter/filter.c +++ b/ltt/branches/poly/lttv/modules/gui/filter/filter.c @@ -61,12 +61,12 @@ typedef struct _FilterViewerDataLine FilterViewerDataLine; * Prototypes */ GtkWidget *guifilter_get_widget(FilterViewerData *fvd); -FilterViewerData *gui_filter(Tab *tab); +FilterViewerData *gui_filter(LttvPlugin *plugin); void gui_filter_destructor(FilterViewerData *fvd); FilterViewerDataLine* gui_filter_add_line(FilterViewerData *fvd); void gui_filter_line_set_visible(FilterViewerDataLine *fvdl, gboolean v); void gui_filter_line_reset(FilterViewerDataLine *fvdl); -GtkWidget* h_guifilter(Tab *tab); +GtkWidget* h_guifilter(LttvPlugin *plugin); void filter_destroy_walk(gpointer data, gpointer user_data); /* @@ -79,6 +79,7 @@ gboolean callback_enter_check(GtkWidget *widget, void callback_add_button(GtkWidget *widget, gpointer data); void callback_logical_op_box(GtkWidget *widget, gpointer data); void callback_expression_field(GtkWidget *widget, gpointer data); +void callback_cancel_button(GtkWidget *widget, gpointer data); /** * @struct _FilterViewerDataLine @@ -105,7 +106,7 @@ struct _FilterViewerDataLine { * Main struct for the filter gui module */ struct _FilterViewerData { - Tab *tab; /**< current tab of module */ + LttvPlugin *plugin; /**< Plugin on which we interact. */ GtkWidget *f_window; /**< filter window */ @@ -125,6 +126,7 @@ struct _FilterViewerData { GPtrArray *f_math_op_options; /**< array of operators types for math_op box */ GtkWidget *f_add_button; /**< add expression to current expression (GtkButton) */ + GtkWidget *f_cancel_button; /**< cancel and close dialog (GtkButton) */ }; @@ -150,7 +152,7 @@ guifilter_get_widget(FilterViewerData *fvd) * @return The Filter viewer data created. */ FilterViewerData* -gui_filter(Tab *tab) +gui_filter(LttvPlugin *plugin) { g_debug("filter::gui_filter()"); @@ -160,7 +162,7 @@ gui_filter(Tab *tab) FilterViewerData* fvd = g_new(FilterViewerData,1); - fvd->tab = tab; + fvd->plugin = plugin; // lttvwindow_register_traceset_notify(fvd->tab, // filter_traceset_changed, @@ -189,6 +191,7 @@ gui_filter(Tab *tab) g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.category")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.time")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.tsc")); + g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.target_pid")); /* * TODO: Add core.xml fields here ! */ @@ -218,8 +221,9 @@ gui_filter(Tab *tab) fvd->f_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(fvd->f_window), "LTTV Filter"); gtk_window_set_transient_for(GTK_WINDOW(fvd->f_window), - GTK_WINDOW(main_window_get_widget(tab))); + GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(fvd->plugin->top_widget)))); gtk_window_set_destroy_with_parent(GTK_WINDOW(fvd->f_window), TRUE); + gtk_window_set_resizable(GTK_WINDOW(fvd->f_window), FALSE); /* * Initiating GtkTable layout @@ -267,7 +271,14 @@ gui_filter(Tab *tab) g_signal_connect (G_OBJECT (fvd->f_add_button), "clicked", G_CALLBACK (callback_add_button), (gpointer) fvd); - gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_add_button,6,7,1,2,GTK_FILL,GTK_FILL,0,0); + gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_add_button,6,7,2,3,GTK_FILL,GTK_FILL,0,0); + + fvd->f_cancel_button = gtk_button_new_with_label("Cancel"); + gtk_widget_show (fvd->f_cancel_button); + g_signal_connect (G_OBJECT (fvd->f_cancel_button), "clicked", + G_CALLBACK (callback_cancel_button), (gpointer) fvd); + + gtk_table_attach( GTK_TABLE(fvd->f_main_box),fvd->f_cancel_button,6,7,1,2,GTK_FILL,GTK_FILL,0,0); fvd->f_logical_op_junction_box = gtk_combo_box_new_text(); for(i=0;if_logical_op_options->len;i++) { @@ -423,8 +434,6 @@ gui_filter_line_reset(FilterViewerDataLine *fvdl) { void gui_filter_destructor(FilterViewerData *fvd) { - Tab *tab = fvd->tab; - /* May already been done by GTK window closing */ if(GTK_IS_WIDGET(guifilter_get_widget(fvd))){ g_info("widget still exists"); @@ -449,13 +458,13 @@ gui_filter_destructor(FilterViewerData *fvd) * * This constructor is given as a parameter to the menuitem and toolbar button * registration. It creates the list. - * @param tab A pointer to the parent window. + * @param obj Object to interact with. * @return The widget created. */ GtkWidget * -h_guifilter(Tab *tab) +h_guifilter(LttvPlugin *plugin) { - FilterViewerData* f = gui_filter(tab) ; + FilterViewerData* f = gui_filter(plugin) ; return NULL; } @@ -529,11 +538,28 @@ callback_process_button(GtkWidget *widget, gpointer data) { GString* s = g_string_new(gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))); lttv_filter_append_expression(filter,s->str); g_string_free(s,TRUE); - //SetFilter(fvd->tab,filter); } else { filter = NULL; } - lttvwindow_report_filter(fvd->tab, filter); + /* Remove the old filter if present */ + //g_object_set_data_full(fvd->obj, "filter", filter, + // (GDestroyNotify)lttv_filter_destroy); + //g_object_notify(fvd->obj, "filter"); + lttv_plugin_update_filter(fvd->plugin, filter); +} + +/** + * @fn void callback_cancel_button(GtkWidget*,gpointer) + * + * The Cancel Button callback function + * @param widget The Button widget passed to the callback function + * @param data Data sent along with the callback function + */ +void +callback_cancel_button(GtkWidget *widget, gpointer data) { + + FilterViewerData *fvd = (FilterViewerData*)data; + gtk_widget_destroy(fvd->f_window); } gboolean callback_enter_check(GtkWidget *widget, @@ -598,11 +624,11 @@ callback_add_button(GtkWidget *widget, gpointer data) { */ GString* s; s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box))); - g_string_append(a_filter_string,s->str); + a_filter_string = g_string_append(a_filter_string,s->str); gtk_combo_box_set_active(GTK_COMBO_BOX(fvd->f_logical_op_junction_box),0); /* begin expression */ - g_string_append_c(a_filter_string,'('); + a_filter_string = g_string_append_c(a_filter_string,'('); /* * For each simple expression, add the resulting string @@ -615,18 +641,18 @@ callback_add_button(GtkWidget *widget, gpointer data) { fvdl = (FilterViewerDataLine*)g_ptr_array_index(fvd->f_lines,i); s = g_ptr_array_index(fvd->f_not_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_not_op_box))); - g_string_append(a_filter_string,s->str); + a_filter_string = g_string_append(a_filter_string,s->str); s = g_ptr_array_index(fvd->f_field_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_field_box))); - g_string_append(a_filter_string,s->str); + a_filter_string = g_string_append(a_filter_string,s->str); s = g_ptr_array_index(fvd->f_math_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_math_op_box))); - g_string_append(a_filter_string,s->str); + a_filter_string = g_string_append(a_filter_string,s->str); - g_string_append(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvdl->f_value_field))); + a_filter_string = g_string_append(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvdl->f_value_field))); s = g_ptr_array_index(fvd->f_logical_op_options,gtk_combo_box_get_active(GTK_COMBO_BOX(fvdl->f_logical_op_box))); - g_string_append(a_filter_string,s->str); + a_filter_string = g_string_append(a_filter_string,s->str); /* * resetting simple expression lines @@ -636,7 +662,7 @@ callback_add_button(GtkWidget *widget, gpointer data) { } /* end expression */ - g_string_append_c(a_filter_string,')'); + a_filter_string = g_string_append_c(a_filter_string,')'); g_string_prepend(a_filter_string,gtk_entry_get_text(GTK_ENTRY(fvd->f_expression_field))); gtk_entry_set_text(GTK_ENTRY(fvd->f_expression_field),a_filter_string->str);