Commit bdcf5346 authored by winckel's avatar winckel

Fixed a bad row (-1) selection issue.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4450 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 496e81ef
...@@ -37,8 +37,8 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ...@@ -37,8 +37,8 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter,
gboolean enabled = FALSE; gboolean enabled = FALSE;
gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID,
COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1); &origin_task_id, COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1);
if (msg_number != 0) if (msg_number != 0)
{ {
enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id, instance); enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id, instance);
...@@ -63,113 +63,104 @@ static gboolean onButtonPressed(GtkWidget *treeview, GdkEventButton *event, gpoi ...@@ -63,113 +63,104 @@ static gboolean onButtonPressed(GtkWidget *treeview, GdkEventButton *event, gpoi
} }
/* /*
static gboolean onButtonRelease(GtkWidget *treeview, GdkEventButton *event, gpointer userdata) static gboolean onButtonRelease(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
{ {
g_debug("onButtonRelease %p %p %p %d %d", treeview, event, userdata, event->type, event->button); g_debug("onButtonRelease %p %p %p %d %d", treeview, event, userdata, event->type, event->button);
// last_event = event; // last_event = event;
return FALSE; return FALSE;
} }
*/ */
static void static void ui_tree_view_init_list(GtkWidget *list)
ui_tree_view_init_list(GtkWidget *list)
{ {
GtkCellRenderer *renderer_left; GtkCellRenderer *renderer_left;
GtkCellRenderer *renderer_right; GtkCellRenderer *renderer_right;
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
renderer_left = gtk_cell_renderer_text_new(); renderer_left = gtk_cell_renderer_text_new ();
gtk_cell_renderer_set_padding (renderer_left, 5, 0); gtk_cell_renderer_set_padding (renderer_left, 5, 0);
renderer_right = gtk_cell_renderer_text_new(); renderer_right = gtk_cell_renderer_text_new ();
gtk_cell_renderer_set_alignment (renderer_right, 1, 0.5); gtk_cell_renderer_set_alignment (renderer_right, 1, 0.5);
gtk_cell_renderer_set_padding (renderer_right, 5, 0); gtk_cell_renderer_set_padding (renderer_right, 5, 0);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("MN", renderer_right, "text", COL_MSG_NUM, NULL);
"MN", renderer_right, "text", COL_MSG_NUM, NULL);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("LTE Time", renderer_right, "text", COL_LTE_TIME, NULL);
"LTE Time", renderer_right, "text", COL_LTE_TIME, NULL);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("Signal", renderer_left, "text", COL_MESSAGE, NULL);
"Signal", renderer_left, "text", COL_MESSAGE, NULL);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
g_signal_connect(G_OBJECT(column), "clicked", g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(ui_callback_on_tree_column_header_click),
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_MESSAGE); (gpointer) COL_MESSAGE);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("From", renderer_left, "text", COL_FROM_TASK, NULL);
"From", renderer_left, "text", COL_FROM_TASK, NULL);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
g_signal_connect(G_OBJECT(column), "clicked", g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(ui_callback_on_tree_column_header_click),
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_FROM_TASK); (gpointer) COL_FROM_TASK);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("To", renderer_left, "text", COL_TO_TASK, NULL);
"To", renderer_left, "text", COL_TO_TASK, NULL);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
g_signal_connect(G_OBJECT(column), "clicked", g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(ui_callback_on_tree_column_header_click),
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_TO_TASK); (gpointer) COL_TO_TASK);
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes ("Ins", renderer_right, "text", COL_INSTANCE, NULL);
"Ins", renderer_right, "text", COL_INSTANCE, NULL);
gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
g_signal_connect(G_OBJECT(column), "clicked", g_signal_connect(G_OBJECT(column), "clicked", G_CALLBACK(ui_callback_on_tree_column_header_click),
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_INSTANCE); (gpointer) COL_INSTANCE);
ui_store.store = gtk_list_store_new(NUM_COLS, ui_store.store = gtk_list_store_new (NUM_COLS, // Number of columns
// Displayed columns
G_TYPE_UINT, // COL_MSG_NUM G_TYPE_UINT, // COL_MSG_NUM
G_TYPE_STRING, // COL_LTE_TIME G_TYPE_STRING, // COL_LTE_TIME
G_TYPE_STRING, // COL_SIGNAL G_TYPE_STRING, // COL_MESSAGE
G_TYPE_STRING, // COL_FROM_TASK G_TYPE_STRING, // COL_FROM_TASK
G_TYPE_STRING, // COL_TO_TASK G_TYPE_STRING, // COL_TO_TASK
G_TYPE_UINT, // COL_INSTANCE G_TYPE_UINT, // COL_INSTANCE
/* HACK: add id of message fields to speed-up filtering // Not displayed columns
*/ // Id of some message fields to speed-up filtering
G_TYPE_UINT, // COL_SIGNAL_ID G_TYPE_UINT, // COL_MESSAGE_ID
G_TYPE_UINT, // COL_FROM_TASK_ID G_TYPE_UINT, // COL_FROM_TASK_ID
G_TYPE_UINT, // COL_TO_TASK_ID G_TYPE_UINT, // COL_TO_TASK_ID
/* HACK: add a reference to the buffer here // Reference to the buffer here to avoid maintaining multiple lists.
* to avoid maintining multiple lists.
* The reference is not displayed
*/
G_TYPE_POINTER); G_TYPE_POINTER);
if(ui_store.store == NULL) if (ui_store.store == NULL)
{ {
g_error("gtk_list_store_new failed"); g_error("gtk_list_store_new failed");
} }
ui_store.filtered = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (ui_store.store), NULL)); ui_store.filtered = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (GTK_TREE_MODEL (ui_store.store), NULL));
gtk_tree_model_filter_set_visible_func (ui_store.filtered, gtk_tree_model_filter_set_visible_func (ui_store.filtered, (GtkTreeModelFilterVisibleFunc) ui_tree_filter_messages,
(GtkTreeModelFilterVisibleFunc) ui_tree_filter_messages,
&ui_store, NULL); &ui_store, NULL);
gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(ui_store.filtered)); gtk_tree_view_set_model (GTK_TREE_VIEW(list), GTK_TREE_MODEL(ui_store.filtered));
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list)); gtk_tree_view_columns_autosize (GTK_TREE_VIEW(list));
} }
static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, const uint32_t message_number, const uint32_t message_id, const gchar *signal_name, static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, const uint32_t message_number,
const uint32_t origin_task_id, const char *origin_task, const uint32_t message_id, const gchar *signal_name, const uint32_t origin_task_id,
const uint32_t destination_task_id, const char *destination_task, uint32_t instance, gpointer buffer) const char *origin_task, const uint32_t destination_task_id,
const char *destination_task, uint32_t instance, gpointer buffer)
{ {
GtkTreeIter iter; GtkTreeIter iter;
gtk_list_store_append(ui_store.store, &iter); gtk_list_store_append (ui_store.store, &iter);
gtk_list_store_set(ui_store.store, &iter, gtk_list_store_set (ui_store.store, &iter,
/* Columns */ /* Columns */
COL_MSG_NUM , message_number, COL_MSG_NUM , message_number,
COL_LTE_TIME , lte_time, COL_LTE_TIME , lte_time,
...@@ -189,7 +180,7 @@ void ui_tree_view_destroy_list(GtkWidget *list) ...@@ -189,7 +180,7 @@ void ui_tree_view_destroy_list(GtkWidget *list)
{ {
g_assert(list != NULL); g_assert(list != NULL);
gtk_list_store_clear(ui_store.store); gtk_list_store_clear (ui_store.store);
ui_store.filtered_last_msg = 0; ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0; ui_store.filtered_msg_number = 0;
ui_store.instance_number = 0; ui_store.instance_number = 0;
...@@ -199,15 +190,15 @@ void ui_tree_view_destroy_list(GtkWidget *list) ...@@ -199,15 +190,15 @@ void ui_tree_view_destroy_list(GtkWidget *list)
} }
/* Search for the message with its message number equal to the given value or the previous one */ /* Search for the message with its message number equal to the given value or the previous one */
static gboolean ui_tree_view_search (GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, static gboolean ui_tree_view_search(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter,
gpointer search_data) gpointer search_data)
{ {
uint32_t msg_number; uint32_t msg_number;
uint32_t key_value = atoi(key); uint32_t key_value = atoi (key);
gtk_tree_model_get (model, iter, column, &msg_number, -1); gtk_tree_model_get (model, iter, column, &msg_number, -1);
g_debug ("ui_tree_view_search %d %d", key_value, msg_number); g_debug("ui_tree_view_search %d %d", key_value, msg_number);
if (key_value == msg_number) if (key_value == msg_number)
{ {
...@@ -218,7 +209,7 @@ static gboolean ui_tree_view_search (GtkTreeModel *model, gint column, const gch ...@@ -218,7 +209,7 @@ static gboolean ui_tree_view_search (GtkTreeModel *model, gint column, const gch
{ {
GtkTreeIter iter_next = *iter; GtkTreeIter iter_next = *iter;
if (gtk_tree_model_iter_next(model, &iter_next)) if (gtk_tree_model_iter_next (model, &iter_next))
{ {
gtk_tree_model_get (model, &iter_next, column, &msg_number, -1); gtk_tree_model_get (model, &iter_next, column, &msg_number, -1);
...@@ -243,39 +234,38 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -243,39 +234,38 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkWidget *scrolled_window; GtkWidget *scrolled_window;
scrolled_window = gtk_scrolled_window_new(NULL, NULL); scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ui_main_data.messages_list = gtk_tree_view_new(); ui_main_data.messages_list = gtk_tree_view_new ();
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(ui_main_data.messages_list), TRUE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(ui_main_data.messages_list), TRUE);
gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(ui_main_data.messages_list), ui_tree_view_search, NULL, NULL); gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW(ui_main_data.messages_list), ui_tree_view_search, NULL, NULL);
gtk_tree_view_set_search_entry (GTK_TREE_VIEW(ui_main_data.messages_list), GTK_ENTRY(ui_main_data.signals_go_to_entry)); gtk_tree_view_set_search_entry (GTK_TREE_VIEW(ui_main_data.messages_list),
GTK_ENTRY(ui_main_data.signals_go_to_entry));
/* Disable multiple selection */ /* Disable multiple selection */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ui_main_data.messages_list)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(ui_main_data.messages_list));
gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
hbox = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); hbox = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
gtk_container_add(GTK_CONTAINER(scrolled_window), ui_main_data.messages_list); gtk_container_add (GTK_CONTAINER(scrolled_window), ui_main_data.messages_list);
ui_tree_view_init_list(ui_main_data.messages_list); ui_tree_view_init_list (ui_main_data.messages_list);
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(ui_main_data.messages_list), TRUE); gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW(ui_main_data.messages_list), TRUE);
gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(scrolled_window), 620); gtk_scrolled_window_set_min_content_width (GTK_SCROLLED_WINDOW(scrolled_window), 620);
gtk_paned_pack1 (GTK_PANED (hbox), scrolled_window, FALSE, TRUE); gtk_paned_pack1 (GTK_PANED (hbox), scrolled_window, FALSE, TRUE);
ui_main_data.text_view = ui_signal_dissect_new(hbox); ui_main_data.text_view = ui_signal_dissect_new (hbox);
gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 5); gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 5);
g_signal_connect(G_OBJECT(ui_main_data.messages_list), "button-press-event", G_CALLBACK (onButtonPressed), NULL); g_signal_connect(G_OBJECT(ui_main_data.messages_list), "button-press-event", G_CALLBACK (onButtonPressed), NULL);
// g_signal_connect(G_OBJECT(ui_main_data.signalslist), "button-release-event", G_CALLBACK (onButtonRelease), NULL); // g_signal_connect(G_OBJECT(ui_main_data.signalslist), "button-release-event", G_CALLBACK (onButtonRelease), NULL);
/* Connect callback on row selection */ /* Connect callback on row selection */
gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal, gtk_tree_selection_set_select_function (selection, ui_callback_on_select_signal, ui_main_data.text_view, NULL);
ui_main_data.text_view, NULL);
ui_store.filtered_last_msg = 0; ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0; ui_store.filtered_msg_number = 0;
...@@ -286,13 +276,12 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -286,13 +276,12 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
return 0; return 0;
} }
int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_time, int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_time, const uint32_t message_id,
const uint32_t message_id, const char *message_name, const char *message_name, const uint32_t origin_task_id, const char *origin_task,
const uint32_t origin_task_id, const char *origin_task, const uint32_t destination_task_id, const char *destination_task, uint32_t instance,
const uint32_t destination_task_id, const char *destination_task, gpointer buffer)
uint32_t instance, gpointer buffer)
{ {
if(ui_store.instance_number < (instance + 1)) if (ui_store.instance_number < (instance + 1))
{ {
int i; int i;
char name[10]; char name[10];
...@@ -303,11 +292,12 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_ ...@@ -303,11 +292,12 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, const gchar *lte_
ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE); ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE);
} }
ui_store.instance_number = (instance + 1); ui_store.instance_number = (instance + 1);
ui_destroy_filter_menu(FILTER_INSTANCES); ui_destroy_filter_menu (FILTER_INSTANCES);
} }
ui_tree_view_add_to_list(ui_main_data.messages_list, lte_time, message_number, message_id, message_name, ui_tree_view_add_to_list (ui_main_data.messages_list, lte_time, message_number, message_id, message_name,
origin_task_id, origin_task, destination_task_id, destination_task, instance, (buffer_t *)buffer); origin_task_id, origin_task, destination_task_id, destination_task, instance,
(buffer_t *) buffer);
return RC_OK; return RC_OK;
} }
...@@ -316,14 +306,19 @@ void ui_tree_view_select_row(gint row) ...@@ -316,14 +306,19 @@ void ui_tree_view_select_row(gint row)
{ {
GtkTreePath *path_row; GtkTreePath *path_row;
path_row = gtk_tree_path_new_from_indices(row, -1); if (row >= 0)
{
path_row = gtk_tree_path_new_from_indices (row, -1);
if (path_row != NULL) if ((ui_main_data.messages_list != NULL) && (path_row != NULL))
{ {
g_debug("Select row %d", row);
/* Select the message in requested row */ /* Select the message in requested row */
gtk_tree_view_set_cursor(GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, FALSE); gtk_tree_view_set_cursor (GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, FALSE);
/* Center the message in the middle of the list if possible */ /* Center the message in the middle of the list if possible */
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, TRUE, 0.5, 0.0); gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW(ui_main_data.messages_list), path_row, NULL, TRUE, 0.5, 0.0);
}
} }
} }
......
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