+ mw->current_tab = tab;
+}
+
+void checkbox_changed(GtkTreeView *treeview,
+ GtkTreePath *arg1,
+ GtkTreeViewColumn *arg2,
+ gpointer user_data)
+{
+ GtkTreeStore * store = (GtkTreeStore *)gtk_tree_view_get_model (treeview);
+ GtkTreeIter iter;
+ gboolean value;
+
+ if (gtk_tree_model_get_iter ((GtkTreeModel *)store, &iter, arg1)){
+ gtk_tree_model_get ((GtkTreeModel *)store, &iter, CHECKBOX_COLUMN, &value, -1);
+ value = value? FALSE : TRUE;
+ gtk_tree_store_set (GTK_TREE_STORE (store), &iter, CHECKBOX_COLUMN, value, -1);
+ }
+
+}
+
+void update_filter(LttvTracesetSelector *s, GtkTreeStore *store )
+{
+ GtkTreeIter iter, child_iter;
+ int i, j;
+ LttvTraceSelector * trace;
+ LttvTracefileSelector * tracefile;
+ gboolean value, value1;
+
+ if(gtk_tree_model_get_iter_first((GtkTreeModel*)store, &iter)){
+ i = 0;
+ do{
+ trace = lttv_traceset_selector_get(s, i);
+ gtk_tree_model_get ((GtkTreeModel*)store, &iter, CHECKBOX_COLUMN, &value,-1);
+ if(value){
+ j = 0;
+ if(gtk_tree_model_iter_children ((GtkTreeModel*)store, &child_iter, &iter)){
+ do{
+ tracefile = lttv_trace_selector_get(trace, j);
+ gtk_tree_model_get ((GtkTreeModel*)store, &child_iter, CHECKBOX_COLUMN, &value1,-1);
+ lttv_tracefile_selector_set_selected(tracefile,value1);
+ j++;
+ }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &child_iter));
+ }
+ }
+ lttv_trace_selector_set_selected(trace,value);
+ i++;
+ }while(gtk_tree_model_iter_next((GtkTreeModel*)store, &iter));
+ }
+}
+
+gboolean get_filter_selection(LttvTracesetSelector *s,char *title, char * column_title)
+{
+ GtkWidget * dialogue;
+ GtkTreeStore * store;
+ GtkWidget * tree;
+ GtkWidget * scroll_win;
+ GtkCellRenderer * renderer;
+ GtkTreeViewColumn * column;
+ GtkTreeIter iter, child_iter;
+ int i, j, id, nb_trace, nb_tracefile;
+ LttvTraceSelector * trace;
+ LttvTracefileSelector * tracefile;
+ char * name;
+ gboolean checked;
+
+ dialogue = gtk_dialog_new_with_buttons(title,
+ NULL,
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,GTK_RESPONSE_REJECT,
+ NULL);
+ gtk_window_set_default_size((GtkWindow*)dialogue, 300, 100);
+
+ store = gtk_tree_store_new (TOTAL_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING);
+ tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+ g_object_unref (G_OBJECT (store));
+ g_signal_connect (G_OBJECT (tree), "row-activated",
+ G_CALLBACK (checkbox_changed),
+ NULL);
+
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ gtk_cell_renderer_toggle_set_radio((GtkCellRendererToggle *)renderer, FALSE);
+
+ g_object_set (G_OBJECT (renderer),"activatable", TRUE, NULL);
+
+ column = gtk_tree_view_column_new_with_attributes ("Checkbox",
+ renderer,
+ "active", CHECKBOX_COLUMN,
+ NULL);
+ gtk_tree_view_column_set_alignment (column, 0.5);
+ gtk_tree_view_column_set_fixed_width (column, 20);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (column_title,
+ renderer,
+ "text", NAME_COLUMN,
+ NULL);
+ gtk_tree_view_column_set_alignment (column, 0.0);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (tree), FALSE);
+
+ scroll_win = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win),
+ GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (scroll_win), tree);
+
+ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialogue)->vbox), scroll_win,TRUE, TRUE,0);
+
+ gtk_widget_show(scroll_win);
+ gtk_widget_show(tree);
+
+ nb_trace = lttv_traceset_selector_number(s);
+ for(i=0;i<nb_trace;i++){
+ trace = lttv_traceset_selector_get(s, i);
+ name = lttv_trace_selector_get_name(trace);
+ gtk_tree_store_append (store, &iter, NULL);
+ checked = lttv_trace_selector_get_selected(trace);
+ gtk_tree_store_set (store, &iter,
+ CHECKBOX_COLUMN,checked,
+ NAME_COLUMN,name,
+ -1);
+ nb_tracefile = lttv_trace_selector_number(trace);
+ for(j=0;j<nb_tracefile;j++){
+ tracefile = lttv_trace_selector_get(trace, j);
+ name = lttv_tracefile_selector_get_name(tracefile);
+ gtk_tree_store_append (store, &child_iter, &iter);
+ checked = lttv_tracefile_selector_get_selected(tracefile);
+ gtk_tree_store_set (store, &child_iter,
+ CHECKBOX_COLUMN, checked,
+ NAME_COLUMN,name,
+ -1);
+ }
+ }
+
+ id = gtk_dialog_run(GTK_DIALOG(dialogue));
+ switch(id){
+ case GTK_RESPONSE_ACCEPT:
+ case GTK_RESPONSE_OK:
+ update_filter(s, store);
+ gtk_widget_destroy(dialogue);
+ return TRUE;
+ case GTK_RESPONSE_REJECT:
+ case GTK_RESPONSE_CANCEL:
+ default:
+ gtk_widget_destroy(dialogue);
+ break;
+ }
+ return FALSE;