Changeset c3ab155 for view.c


Ignore:
Timestamp:
Jun 17, 2003, 9:46:10 PM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b1299da
Parents:
65e3901
Message:
Really use just one view now, named 'main' and recalculate
  messages when its filter is changed.  This is in preperation for
  other design changes
Added the 'default_style' variable
Added the 'toggle-oneline' command
the 'o' key is bound to 'toggle-oneline'
File:
1 edited

Legend:

Unmodified
Added
Removed
  • view.c

    r3a2daac rc3ab155  
    44static const char fileIdent[] = "$Id$";
    55
    6 void owl_view_create(owl_view *v, owl_filter *f) {
     6void owl_view_create(owl_view *v, char *name, owl_filter *f, owl_style *s)
     7{
     8  v->name=owl_strdup(name);
    79  v->filter=f;
     10  v->style=s;
    811  owl_messagelist_create(&(v->ml));
    912  owl_view_recalculate(v);
    1013}
    1114
    12 void owl_view_consider_message(owl_view *v, owl_message *m) {
    13   /* if the message matches the filter then add to view */
     15
     16/* if the message matches the filter then add to view */
     17void owl_view_consider_message(owl_view *v, owl_message *m)
     18{
    1419  if (owl_filter_message_match(v->filter, m)) {
    1520    owl_messagelist_append_element(&(v->ml), m);
     
    1722}
    1823
    19 void owl_view_recalculate(owl_view *v) {
    20   /* add all the global messages that match the filter */
     24/* remove all messages, add all the global messages that match the
     25 * filter.
     26 */
     27void owl_view_recalculate(owl_view *v)
     28{
    2129  int i, j;
    2230  owl_messagelist *gml;
     
    4149}
    4250
    43 owl_message *owl_view_get_element(owl_view *v, int index) {
     51void owl_view_new_filter(owl_view *v, owl_filter *f)
     52{
     53  v->filter=f;
     54  owl_view_recalculate(v);
     55}
     56
     57void owl_view_set_style(owl_view *v, owl_style *s)
     58{
     59  v->style=s;
     60}
     61
     62owl_message *owl_view_get_element(owl_view *v, int index)
     63{
    4464  return(owl_messagelist_get_element(&(v->ml), index));
    4565}
    4666
    47 void owl_view_delete_element(owl_view *v, int index) {
     67void owl_view_delete_element(owl_view *v, int index)
     68{
    4869  owl_messagelist_delete_element(&(v->ml), index);
    4970}
    5071
    51 void owl_view_undelete_element(owl_view *v, int index) {
     72void owl_view_undelete_element(owl_view *v, int index)
     73{
    5274  owl_messagelist_undelete_element(&(v->ml), index);
    5375}
    5476
    55 int owl_view_get_size(owl_view *v) {
     77int owl_view_get_size(owl_view *v)
     78{
    5679  return(owl_messagelist_get_size(&(v->ml)));
    5780}
     
    5982/* Returns the position in the view with a message closest
    6083 * to the passed msgid. */
    61 int owl_view_get_nearest_to_msgid(owl_view *v, int targetid) {
     84int owl_view_get_nearest_to_msgid(owl_view *v, int targetid)
     85{
    6286  int i, bestdist=-1, bestpos=0, curid, curdist;
    6387
     
    7397}
    7498
    75 int owl_view_get_nearest_to_saved(owl_view *v) {
     99int owl_view_get_nearest_to_saved(owl_view *v)
     100{
    76101  int cachedid;
    77102
     
    83108/* saves the current message position in the filter so it can
    84109 * be restored later if we switch back to this filter. */
    85 void owl_view_save_curmsgid(owl_view *v, int curid) {
     110void owl_view_save_curmsgid(owl_view *v, int curid)
     111{
    86112  owl_filter_set_cachedmsgid(v->filter, curid);
    87113}
    88114
    89 char *owl_view_get_filtname(owl_view *v) {
     115char *owl_view_get_filtname(owl_view *v)
     116{
    90117  return(owl_filter_get_name(v->filter));
    91118}
    92119
    93 void owl_view_free(owl_view *v) {
     120void owl_view_free(owl_view *v)
     121{
    94122  owl_list_free_simple((owl_list *) &(v->ml));
     123  if (v->name) owl_free(v->name);
    95124}
Note: See TracChangeset for help on using the changeset viewer.