1 /*  This file is part of Cawbird, a Gtk+ linux Twitter client forked from Corebird.
2  *  Copyright (C) 2017 Timm Bäder (Corebird)
3  *
4  *  Cawbird is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 3 of the License, or
7  *  (at your option) any later version.
8  *
9  *  Cawbird is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with cawbird.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef CB_TWEET_MODEL_H
19 #define CB_TWEET_MODEL_H
20 
21 #include <glib-object.h>
22 #include <gio/gio.h>
23 
24 #include "CbTweet.h"
25 
26 
27 typedef struct _CbTweetModel      CbTweetModel;
28 typedef struct _CbTweetModelClass CbTweetModelClass;
29 
30 #define CB_TYPE_TWEET_MODEL           (cb_tweet_model_get_type ())
31 #define CB_TWEET_MODEL(obj)           (G_TYPE_CHECK_INSTANCE_CAST(obj, CB_TYPE_TWEET_MODEL, CbTweetModel))
32 #define CB_TWEET_MODEL_CLASS(cls)     (G_TYPE_CHECK_CLASS_CAST(cls, CB_TYPE_TWEET_MODEL, CbTweetModelClass))
33 #define CB_IS_TWEET_MODEL(obj)        (G_TYPE_CHECK_INSTANCE_TYPE(obj, CB_TYPE_TWEET_MODEL))
34 #define CB_IS_TWEET_MODEL_CLASS(cls)   (G_TYPE_CHECK_CLASS_TYPE(cls, CB_TYPE_TWEET_MODEL))
35 #define CB_TWEET_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS(obj, CB_TYPE_TWEET_MODEL, CbTweetModelClass))
36 
37 struct _CbTweetModel
38 {
39   GObject parent_instance;
40 
41   gboolean thread_mode;
42 
43   GPtrArray *tweets;
44   GPtrArray *hidden_tweets;
45   gint64 min_id;
46   gint64 max_id;
47 };
48 
49 struct _CbTweetModelClass
50 {
51   GObjectClass parent_class;
52 };
53 
54 GType    cb_tweet_model_get_type     (void) G_GNUC_CONST;
55 
56 CbTweetModel *cb_tweet_model_new (void);
57 
58 int cb_tweet_model_index_of (CbTweetModel *self, gint64 id);
59 
60 gboolean cb_tweet_model_contains_id  (CbTweetModel *self,
61                                       gint64        id);
62 
63 void     cb_tweet_model_clear        (CbTweetModel *self);
64 
65 void     cb_tweet_model_set_thread_mode (CbTweetModel *self, gboolean thread_mode);
66 
67 CbTweet *cb_tweet_model_get_for_id   (CbTweetModel *self,
68                                       gint64        id,
69                                       int           diff);
70 
71 gboolean cb_tweet_model_delete_id    (CbTweetModel *self,
72                                       gint64        id,
73                                       gboolean     *seen);
74 
75 void     cb_tweet_model_remove_tweet (CbTweetModel *self,
76                                       CbTweet      *tweet);
77 
78 void     cb_tweet_model_toggle_flag_on_user_tweets (CbTweetModel *self,
79                                                     gint64        user_id,
80                                                     CbTweetState  flag,
81                                                     gboolean      active);
82 
83 void     cb_tweet_model_toggle_flag_on_user_retweets (CbTweetModel *self,
84                                                       gint64        user_id,
85                                                       CbTweetState  flag,
86                                                       gboolean      active);
87 
88 gboolean cb_tweet_model_set_tweet_flag (CbTweetModel *self,
89                                         CbTweet      *tweet,
90                                         CbTweetState  flag);
91 
92 gboolean cb_tweet_model_unset_tweet_flag (CbTweetModel *self,
93                                           CbTweet      *tweet,
94                                           CbTweetState  flag);
95 
96 void     cb_tweet_model_add (CbTweetModel *self,
97                              CbTweet      *tweet);
98 
99 void     cb_tweet_model_remove_oldest_n_visible (CbTweetModel *self,
100                                                guint         amount);
101 
102 void     cb_tweet_model_remove_tweets_later_than (CbTweetModel *self,
103                                                   gint64        id);
104 
105 
106 
107 #endif
108