1 /********************************************************************\
2  * dialog-options.h -- GNOME option handling                        *
3  * Copyright (C) 1998-2000 Linas Vepstas                            *
4  *                                                                  *
5  * This program is free software; you can redistribute it and/or    *
6  * modify it under the terms of the GNU General Public License as   *
7  * published by the Free Software Foundation; either version 2 of   *
8  * the License, or (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, contact:                        *
17  *                                                                  *
18  * Free Software Foundation           Voice:  +1-617-542-5942       *
19  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
20  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
21 \********************************************************************/
22 
23 #ifndef OPTIONS_DIALOG_H
24 #define OPTIONS_DIALOG_H
25 
26 #include <libguile.h>
27 #include "option-util.h"
28 #include <gtk/gtk.h>
29 
30 /** A simple wrapper that casts the gpointer result of
31  * gnc_option_get_widget() already into a GtkWidget*. */
32 GtkWidget *gnc_option_get_gtk_widget (GNCOption *option);
33 
34 typedef struct gnc_option_win GNCOptionWin;
35 
36 typedef void (* GNCOptionWinCallback)(GNCOptionWin *, gpointer data);
37 
38 GNCOptionWin * gnc_options_dialog_new_modal (gboolean modal, gchar *title,
39                                              const char *component_class,
40                                              GtkWindow *parent);
41 GNCOptionWin * gnc_options_dialog_new (gchar *title, GtkWindow *parent);
42 GNCOptionWin * gnc_options_dialog_new_w_dialog (gchar *title, GtkWidget *dialog);
43 void gnc_options_dialog_destroy (GNCOptionWin * win);
44 void gnc_options_register_stocks (void);
45 
46 GtkWidget * gnc_options_dialog_widget (GNCOptionWin * win);
47 GtkWidget * gnc_options_page_list (GNCOptionWin * win);
48 GtkWidget * gnc_options_dialog_notebook (GNCOptionWin * win);
49 
50 void gnc_options_dialog_changed (GNCOptionWin *win);
51 
52 void gnc_option_changed_widget_cb (GtkWidget *widget, GNCOption *option);
53 void gnc_option_changed_option_cb (GtkWidget *dummy, GNCOption *option);
54 
55 void gnc_options_dialog_set_apply_cb (GNCOptionWin * win,
56                                       GNCOptionWinCallback thunk,
57                                       gpointer cb_data);
58 void gnc_options_dialog_set_help_cb (GNCOptionWin * win,
59                                      GNCOptionWinCallback thunk,
60                                      gpointer cb_data);
61 void gnc_options_dialog_set_close_cb (GNCOptionWin * win,
62                                       GNCOptionWinCallback thunk,
63                                       gpointer cb_data);
64 
65 void gnc_options_dialog_set_global_help_cb (GNCOptionWinCallback thunk,
66                                             gpointer cb_data);
67 
68 void gnc_options_dialog_build_contents (GNCOptionWin *win,
69                                         GNCOptionDB  *odb);
70 
71 void gnc_options_dialog_build_contents_full (GNCOptionWin *win,
72                                              GNCOptionDB  *odb,
73                                              gboolean show_dialog);
74 
75 /* Both apply_cb and close_cb should be scheme functions with 0 arguments.
76  * References to these functions will be held until the close_cb is called
77  */
78 void gnc_options_dialog_set_scm_callbacks (GNCOptionWin *win,
79                                            SCM apply_cb,
80                                            SCM close_cb);
81 
82 /*****************************************************************/
83 /* Option Registration                                           */
84 
85 /* Function to set the UI widget based upon the option */
86 typedef GtkWidget *
87 (*GNCOptionUISetWidget) (GNCOption *option, GtkGrid *page_box,
88                          GtkLabel *name_label, char *documentation,
89                          /* Return values */
90                          GtkWidget **enclosing, gboolean *packed);
91 
92 /* Function to set the UI Value for a particular option */
93 typedef gboolean
94 (*GNCOptionUISetValue)  (GNCOption *option, gboolean use_default,
95                          GtkWidget *widget, SCM value);
96 
97 /* Function to get the UI Value for a particular option */
98 typedef SCM
99 (*GNCOptionUIGetValue)  (GNCOption *option, GtkWidget *widget);
100 
101 
102 typedef struct gnc_option_def
103 {
104     const char *         option_name;
105     GNCOptionUISetWidget set_widget;
106     GNCOptionUISetValue  set_value;
107     GNCOptionUIGetValue  get_value;
108 } GNCOptionDef_t;
109 
110 
111 /* Register a new option type in the UI */
112 void gnc_options_ui_initialize (void);
113 void gnc_options_ui_register_option (GNCOptionDef_t *option);
114 GNCOptionDef_t * gnc_options_ui_get_option (const char *option_name);
115 
116 #endif /* OPTIONS_DIALOG_H */
117