aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/e-addressbook-model.h
blob: 6558d94812809bd75dc7bd03e95152b05f0f0072 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>  
 *
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#ifndef _EAB_MODEL_H_
#define _EAB_MODEL_H_

#include <glib.h>
#include <glib-object.h>
#include <libebook/e-book.h>
#include <libebook/e-book-view.h>

#define EAB_TYPE_MODEL                  (eab_model_get_type ())
#define EAB_MODEL(o)                    (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_MODEL, EABModel))
#define EAB_MODEL_CLASS(k)              (G_TYPE_CHECK_CLASS_CAST((k), EAB_TYPE_MODEL, EABModelClass))
#define E_IS_ADDRESSBOOK_MODEL(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_MODEL))
#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_MODEL))

typedef struct _EABModel EABModel;
typedef struct _EABModelClass EABModelClass;

struct _EABModel {
    GObject parent;

    /* item specific fields */
    EBook *book;
    EBookQuery *query;
    EBookView *book_view;

    int book_view_idle_id;

    EContact **data;
    int data_count;
    int allocated_count;

    int create_contact_id, remove_contact_id, modify_contact_id;
    int status_message_id, writable_status_id, sequence_complete_id;
    int backend_died_id;

    guint search_in_progress : 1;
    guint editable : 1;
    guint editable_set : 1;
    guint first_get_view : 1;
};


struct _EABModelClass {
    GObjectClass parent_class;

    /*
     * Signals
     */
    void (*writable_status)    (EABModel *model, gboolean writable);
    void (*search_started)     (EABModel *model);
    void (*search_result)      (EABModel *model, EBookViewStatus status);
    void (*status_message)     (EABModel *model, const gchar *message);
    void (*folder_bar_message) (EABModel *model, const gchar *message);
    void (*contact_added)      (EABModel *model, gint index, gint count);
    void (*contacts_removed)    (EABModel *model, gpointer id_list);
    void (*contact_changed)    (EABModel *model, gint index);
    void (*model_changed)      (EABModel *model);
    void (*stop_state_changed) (EABModel *model);
    void (*backend_died)       (EABModel *model);
};


GType              eab_model_get_type                  (void);
EABModel          *eab_model_new                       (void);

/* Returns object with ref count of 1. */
EContact          *eab_model_get_contact               (EABModel *model,
                            int                row);
EBook             *eab_model_get_ebook                 (EABModel *model);

void               eab_model_stop                      (EABModel *model);
gboolean           eab_model_can_stop                  (EABModel *model);

void               eab_model_force_folder_bar_message  (EABModel *model);

int                eab_model_contact_count             (EABModel *model);
const EContact    *eab_model_contact_at                (EABModel *model,
                            int                index);
gboolean           eab_model_editable                  (EABModel *model);

#endif /* _EAB_MODEL_H_ */