source: view.c @ 7d4fbcd

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 7d4fbcd was 7d4fbcd, checked in by James M. Kretchmar <kretch@mit.edu>, 18 years ago
Initial check in
  • Property mode set to 100644
File size: 1.5 KB
Line 
1#include "owl.h"
2
3void owl_view_create(owl_view *v, owl_filter *f) {
4  v->filter=f;
5  owl_messagelist_create(&(v->ml));
6  owl_view_recalculate(v);
7}
8
9void owl_view_consider_message(owl_view *v, owl_message *m) {
10  /* if the message matches the filter then add to view */
11  if (owl_filter_message_match(v->filter, m)) {
12    owl_messagelist_append_element(&(v->ml), m);
13  }
14}
15
16void owl_view_recalculate(owl_view *v) {
17  /* add all the global messages that match the filter */
18  int i, j;
19  owl_messagelist *gml;
20  owl_messagelist *ml;
21  owl_message *m;
22
23  gml=owl_global_get_msglist(&g);
24  ml=&(v->ml);
25
26  /* nuke the old list */
27  owl_list_free_simple((owl_list *) ml);
28  owl_messagelist_create(&(v->ml));
29
30  /* find all the messages we want */
31  j=owl_messagelist_get_size(gml);
32  for (i=0; i<j; i++) {
33    m=owl_messagelist_get_element(gml, i);
34    if (owl_filter_message_match(v->filter, m)) {
35      owl_messagelist_append_element(ml, m);
36    }
37  }
38}
39
40owl_message *owl_view_get_element(owl_view *v, int index) {
41  return(owl_messagelist_get_element(&(v->ml), index));
42}
43
44void owl_view_delete_element(owl_view *v, int index) {
45  owl_messagelist_delete_element(&(v->ml), index);
46}
47
48void owl_view_undelete_element(owl_view *v, int index) {
49  owl_messagelist_undelete_element(&(v->ml), index);
50}
51
52int owl_view_get_size(owl_view *v) {
53  return(owl_messagelist_get_size(&(v->ml)));
54}
55
56char *owl_view_get_filtname(owl_view *v) {
57  return(owl_filter_get_name(v->filter));
58}
59
60void owl_view_free(owl_view *v) {
61  owl_list_free_simple((owl_list *) &(v->ml));
62}
Note: See TracBrowser for help on using the repository browser.