/** * Fills the gui GtkTreeView with stored items from the GSList. */ static void chanlist_build_gui_list (server *serv) { GSList *rows; /* first check if the list is present */ if (serv->gui->chanlist_data_stored_rows == NULL) { /* start a download */ chanlist_do_refresh (serv); return; } custom_list_clear ((CustomList *)GET_MODEL (serv)); /* discard pending rows FIXME: free the structs? */ g_slist_free (serv->gui->chanlist_pending_rows); serv->gui->chanlist_pending_rows = NULL; /* Reset the counters */ chanlist_reset_counters (serv); /* Refill the list */ for (rows = serv->gui->chanlist_data_stored_rows; rows != NULL; rows = rows->next) { chanlist_place_row_in_gui (serv, rows->data, TRUE); } custom_list_resort ((CustomList *)GET_MODEL (serv)); }
/** * Accepts incoming channel data from inbound.c, allocates new space for a * chanlistrow, adds it to our linked list and calls chanlist_place_row_in_gui. */ void fe_add_chan_list (server *serv, char *chan, char *users, char *topic) { auto len = strlen (chan) + 1; chanlistrow * next_row = new chanlistrow; next_row->topic = strip_color(topic, STRIP_ALL); glib_string collation_key(g_utf8_collate_key(chan, len - 1)); next_row->collation_key = collation_key ? collation_key.get() : chan; next_row->users = atoi (users); /* add this row to the data */ serv->gui->chanlist_data_stored_rows = g_slist_prepend (serv->gui->chanlist_data_stored_rows, next_row); /* _possibly_ add the row to the gui */ chanlist_place_row_in_gui (*serv->gui, next_row, FALSE); }
/** * Accepts incoming channel data from inbound.c, allocates new space for a * chanlistrow, adds it to our linked list and calls chanlist_place_row_in_gui. */ void fe_add_chan_list (server *serv, char *chan, char *users, char *topic) { chanlistrow *next_row; int len = strlen (chan) + 1; /* we allocate the struct and channel string in one go */ next_row = malloc (sizeof (chanlistrow) + len); memcpy (((char *)next_row) + sizeof (chanlistrow), chan, len); next_row->topic = strip_color (topic, -1, STRIP_ALL); next_row->collation_key = g_utf8_collate_key (chan, len-1); if (!(next_row->collation_key)) next_row->collation_key = g_strdup (chan); next_row->users = atoi (users); /* add this row to the data */ serv->gui->chanlist_data_stored_rows = g_slist_prepend (serv->gui->chanlist_data_stored_rows, next_row); /* _possibly_ add the row to the gui */ chanlist_place_row_in_gui (serv, next_row, FALSE); }