1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail Team
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 3 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, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef PREFSWINDOW_H
21 #define PREFSWINDOW_H 1
22 
23 #include <glib.h>
24 #include <gtk/gtk.h>
25 
26 typedef struct _PrefsPage PrefsPage;
27 typedef struct _PrefsWindow PrefsWindow;
28 
29 typedef void (*PrefsCreateWidgetFunc) (PrefsPage *, GtkWindow *window, gpointer);
30 typedef void (*PrefsDestroyWidgetFunc) (PrefsPage *);
31 typedef void (*PrefsSavePageFunc) (PrefsPage *);
32 typedef gboolean (*PrefsCanClosePageFunc) (PrefsPage *);
33 typedef void (*PrefsOpenCallbackFunc) (PrefsWindow *);
34 typedef void (*PrefsApplyCallbackFunc) (PrefsWindow *);
35 typedef void (*PrefsCloseCallbackFunc) (PrefsWindow *);
36 
37 struct _PrefsPage
38 {
39 	gchar 			**path;
40 	gboolean		  page_open;
41 	GtkWidget		 *widget;
42 	gfloat			  weight;
43 
44 	PrefsCreateWidgetFunc	  create_widget;
45 	PrefsDestroyWidgetFunc	  destroy_widget;
46 	PrefsSavePageFunc	  save_page;
47 	PrefsCanClosePageFunc	  can_close;
48 };
49 
50 enum {
51 	PREFS_PAGE_TITLE,		/* page title */
52 	PREFS_PAGE_DATA,		/* PrefsTreeNode data */
53 	PREFS_PAGE_DATA_AUTO_FREE,	/* auto free for PREFS_PAGE_DATA */
54 	PREFS_PAGE_WEIGHT,		/* weight */
55 	PREFS_PAGE_INDEX,		/* index in original page list */
56 	N_PREFS_PAGE_COLUMNS
57 };
58 
59 typedef struct _PrefsTreeNode PrefsTreeNode;
60 
61 struct _PrefsWindow
62 {
63 	GtkWidget *window;
64 	GtkWidget *vbox;
65 	GtkWidget *paned;
66 	GtkWidget *scrolledwindow1;
67 	GtkWidget *tree_view;
68 	GtkWidget *table2;
69 	GtkWidget *pagelabel;
70 	GtkWidget *labelframe;
71 	GtkWidget *vbox2;
72 	GtkWidget *notebook;
73 	GtkWidget *confirm_area;
74 	GtkWidget *ok_btn;
75 	GtkWidget *cancel_btn;
76 	GtkWidget *apply_btn;
77 	gint *save_width;
78 	gint *save_height;
79 	PrefsCloseCallbackFunc open_cb;
80 	PrefsApplyCallbackFunc apply_cb;
81 	PrefsCloseCallbackFunc close_cb;
82 	gint dialog_response; /* Useful for close_cb callbacks */
83 
84 	GtkWidget *empty_page;
85 
86 	gpointer   	 data;
87 	GSList	  	*prefs_pages;
88 	GDestroyNotify func;
89 };
90 
91 enum
92 {
93 	PREFSWINDOW_RESPONSE_CANCEL,
94 	PREFSWINDOW_RESPONSE_OK,
95 	PREFSWINDOW_RESPONSE_APPLY
96 };
97 
98 struct _PrefsTreeNode
99 {
100 	PrefsPage *page;
101 	gfloat     treeweight; /* GTK2: not used */
102 };
103 
104 void prefswindow_open_full		(const gchar *title,
105 					 GSList *prefs_pages,
106 					 gpointer data,
107 					 GDestroyNotify func,
108 					 gint *save_width, gint *save_height,
109 					 gboolean preload_pages,
110 					 PrefsOpenCallbackFunc open_cb,
111 					 PrefsApplyCallbackFunc apply_cb,
112 					 PrefsCloseCallbackFunc close_cb);
113 
114 void prefswindow_open			(const gchar *title,
115 					 GSList *prefs_pages,
116 					 gpointer data,
117 					 gint *save_width, gint *save_height,
118 					 PrefsOpenCallbackFunc open_cb,
119 					 PrefsApplyCallbackFunc apply_cb,
120 					 PrefsCloseCallbackFunc close_cb);
121 
122 #endif
123