removed debugging info
[claws.git] / src / addressbook.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999,2000 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __ADDRESSBOOK_H__
21 #define __ADDRESSBOOK_H__
22
23 #include <glib.h>
24 #include <gtk/gtkwidget.h>
25 #include <gtk/gtkitemfactory.h>
26 #include <gtk/gtkctree.h>
27
28 #define ADDRESS_OBJECT(obj)             ((AddressObject *)(obj))
29 #define ADDRESS_OBJECT_TYPE(obj)        (ADDRESS_OBJECT((obj))->type)
30 #define ADDRESS_ITEM(obj)               ((AddressItem *)(obj))
31 #define ADDRESS_GROUP(obj)              ((AddressGroup *)(obj))
32 #define ADDRESS_FOLDER(obj)             ((AddressFolder *)(obj))
33
34 typedef struct _AddressBook     AddressBook;
35 typedef struct _AddressObject   AddressObject;
36 typedef struct _AddressItem     AddressItem;
37 typedef struct _AddressGroup    AddressGroup;
38 typedef struct _AddressFolder   AddressFolder;
39
40 #include "compose.h"
41
42 typedef enum
43 {
44         ADDR_ITEM,
45         ADDR_GROUP,
46         ADDR_FOLDER
47 } AddressObjectType;
48
49 struct _AddressBook
50 {
51         GtkWidget *window;
52         GtkWidget *ctree;
53         GtkWidget *clist;
54         GtkWidget *entry;
55
56         GtkWidget *del_btn;
57         GtkWidget *reg_btn;
58         GtkWidget *lup_btn;
59         GtkWidget *to_btn;
60         GtkWidget *cc_btn;
61         GtkWidget *bcc_btn;
62
63         GtkWidget *tree_popup;
64         GtkWidget *list_popup;
65         GtkItemFactory *tree_factory;
66         GtkItemFactory *list_factory;
67
68         GtkCTreeNode *common;
69         GtkCTreeNode *personal;
70         GtkCTreeNode *selected;
71         GtkCTreeNode *opened;
72
73         gboolean open_folder;
74
75         Compose *target_compose;
76 };
77
78 struct _AddressObject
79 {
80         AddressObjectType type;
81 };
82
83 struct _AddressItem
84 {
85         AddressObject obj;
86
87         gchar *name;
88         gchar *address;
89         gchar *remarks;
90 };
91
92 struct _AddressGroup
93 {
94         AddressObject obj;
95
96         gchar *name;
97
98         /* Group contains only Items */
99         GList *items;
100 };
101
102 struct _AddressFolder
103 {
104         AddressObject obj;
105
106         gchar *name;
107
108         /* Folder contains Groups and Items */
109         GList *items;
110 };
111
112 void addressbook_open                   (Compose        *target);
113 void addressbook_set_target_compose     (Compose        *target);
114 Compose *addressbook_get_target_compose (void);
115 void addressbook_export_to_file         (void);
116
117 /* provisional API for accessing the address book */
118
119 void addressbook_access (void);
120 void addressbook_unaccess (void);
121
122 const gchar *addressbook_get_personal_folder_name (void);
123 const gchar *addressbook_get_common_folder_name (void);
124
125 AddressObject *addressbook_find_group_by_name (const gchar *name);
126 AddressObject *addressbook_find_contact (const gchar *name, const gchar *address);
127 GList *addressbook_get_group_list (void);
128 gint addressbook_add_contact  (const gchar *group, const gchar *name, 
129                                const gchar *address, const gchar *remarks); 
130
131 gboolean addressbook_add_contact_by_menu(GtkWidget   *submenu,
132                                                                                  const gchar *name, 
133                                                                                  const gchar *address, 
134                                                                                  const gchar *remarks);
135
136 #endif /* __ADDRESSBOOK_H__ */