Commit f83cb155 authored by winckel's avatar winckel
Browse files

Added a counter of filtered messages.

Corrected goto last signal function with filter activated.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4343 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 85e85fb9
......@@ -293,7 +293,7 @@ gboolean ui_callback_signal_go_to_last(GtkWidget *widget, GdkEvent *event, gpoin
{
GtkTreePath *path;
ui_tree_view_select_row (ui_main_data.nb_message_received - 1, &path);
ui_tree_view_select_row (ui_tree_view_get_filtered_number() - 1, &path);
ui_main_data.path_last = path;
return TRUE;
......@@ -318,9 +318,9 @@ gboolean ui_callback_on_menu_item_selected(GtkWidget *widget, gpointer data)
if (filter_entry->enabled != enabled)
{
filter_entry->enabled = enabled;
ui_tree_view_refilter();
ui_tree_view_refilter ();
}
// g_debug("ui_callback_on_menu_item_selected occurred %x %x %s %d", (int) widget, (int) data, filter_entry->name, enabled);
// g_debug("ui_callback_on_menu_item_selected occurred %x %x %s %d (%d messages to display)", (int) widget, (int) data, filter_entry->name, enabled, ui_tree_view_get_filtered_number());
return TRUE;
}
......
......@@ -214,6 +214,7 @@ static int xml_parse_filters(xmlDocPtr doc)
xmlNode *filter_node = NULL;
xmlNode *cur_node = NULL;
ui_filter_e filter;
guint filters_entries = 0;
int ret = RC_FAIL;
/* Get the root element node */
......@@ -265,7 +266,7 @@ static int xml_parse_filters(xmlDocPtr doc)
cur_node->properties->children->content[0] == '0' ?
ENTRY_ENABLED_FALSE : ENTRY_ENABLED_TRUE);
ret = RC_OK;
filters_entries++;
cur_node = cur_node->next;
}
}
......@@ -278,11 +279,15 @@ static int xml_parse_filters(xmlDocPtr doc)
ui_tree_view_refilter ();
}
}
/* Free the document */
xmlFreeDoc (doc);
g_message("Parsed XML filters definition");
if (filters_entries > 0)
{
ret = RC_OK;
}
g_message("Parsed XML filters definition found %d entries (%d messages to display)", filters_entries, ui_tree_view_get_filtered_number());
return ret;
}
......@@ -299,7 +304,6 @@ int ui_filters_read(const char *file_name)
}
doc = xmlReadFile (file_name, NULL, 0);
if (doc == NULL)
{
ui_notification_dialog (GTK_MESSAGE_ERROR, "open filters", "Failed to parse file \"%s\"", file_name);
......@@ -307,10 +311,10 @@ int ui_filters_read(const char *file_name)
}
ret = xml_parse_filters (doc);
if (ret != RC_OK)
{
ui_notification_dialog (GTK_MESSAGE_WARNING, "open filters", "Found no filter definitions in \"%s\"", file_name);
ui_notification_dialog (GTK_MESSAGE_WARNING, "open filters", "Found no filter definitions in \"%s\"",
file_name);
return RC_FAIL;
}
......
......@@ -15,6 +15,7 @@
#include "ui_notif_dlg.h"
#include "ui_callbacks.h"
#include "ui_filters.h"
#include "ui_tree_view.h"
#include "xml_parse.h"
......@@ -163,7 +164,7 @@ int ui_messages_read(char *filename)
ui_set_sensitive_move_buttons (TRUE);
}
g_message("Read %d messages from file \"%s\"\n", read_messages, filename);
g_message("Read %d messages (%d to display) from file \"%s\"\n", read_messages, ui_tree_view_get_filtered_number(), filename);
close (source);
}
......
......@@ -18,26 +18,39 @@ typedef struct
{
GtkListStore *store;
GtkTreeModelFilter *filtered;
guint filtered_last_msg;
guint filtered_msg_number;
} ui_store_t;
static ui_store_t ui_store;
static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ui_store_t *store)
{
char *msg_number;
guint number = 0;
char *message;
char *origin_task;
char *destination_task;
gboolean enabled;
gboolean enabled = FALSE;
gtk_tree_model_get (model, iter, COL_SIGNAL, &message, COL_FROM_TASK, &origin_task, COL_TO_TASK, &destination_task,
-1);
enabled = ui_filters_message_enabled (message, origin_task, destination_task);
// g_debug("%x %x %s %s %s %d", model, iter, message, origin_task, destination_task, enabled);
gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_SIGNAL, &message, COL_FROM_TASK, &origin_task,
COL_TO_TASK, &destination_task, -1);
if (msg_number != NULL)
{
number = atoi (msg_number);
enabled = ui_filters_message_enabled (message, origin_task, destination_task);
if ((enabled) && (ui_store.filtered_last_msg < number))
{
ui_store.filtered_last_msg = number;
ui_store.filtered_msg_number++;
}
// g_debug("%x %x %d %s %s %s %d %d", (int) model, (int) iter, number, message, origin_task, destination_task, enabled, ui_store.filtered_msg_number);
}
g_free(message);
g_free(origin_task);
g_free(destination_task);
g_free (message);
g_free (origin_task);
g_free (destination_task);
return enabled;
}
......@@ -115,6 +128,8 @@ void ui_tree_view_destroy_list(GtkWidget *list)
g_assert(list != NULL);
gtk_list_store_clear(ui_store.store);
ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0;
/* Reset number of messages */
ui_main_data.nb_message_received = 0;
......@@ -178,11 +193,8 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const char *signa
void ui_tree_view_select_row(gint row, GtkTreePath **path)
{
GtkTreePath *path_row;
gchar indice[10];
sprintf(indice, "%d", row);
path_row = gtk_tree_path_new_from_string(indice);
path_row = gtk_tree_path_new_from_indices(row, -1);
/* Select the message in requested row */
gtk_tree_view_set_cursor(GTK_TREE_VIEW(ui_main_data.signalslist), path_row, NULL, FALSE);
/* Center the message in the middle of the list if possible */
......@@ -196,5 +208,12 @@ void ui_tree_view_select_row(gint row, GtkTreePath **path)
void ui_tree_view_refilter(void)
{
gtk_tree_model_filter_refilter (ui_store.filtered);;
ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0;
gtk_tree_model_filter_refilter (ui_store.filtered);
}
guint ui_tree_view_get_filtered_number(void)
{
return ui_store.filtered_msg_number;
}
......@@ -22,4 +22,6 @@ void ui_tree_view_select_row(gint row, GtkTreePath **path);
void ui_tree_view_refilter(void);
guint ui_tree_view_get_filtered_number(void);
#endif /* UI_TREE_VIEW_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment