[gnumeric] Conf: inital non-compiling first cut.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Conf: inital non-compiling first cut.
- Date: Mon, 29 Jun 2009 02:37:28 +0000 (UTC)
commit 603546aade7c9faa36c96c2e428851a5f6645977
Author: Morten Welinder <terra gnome org>
Date: Fri Jun 26 23:37:58 2009 -0400
Conf: inital non-compiling first cut.
schemas/gnumeric-general.schemas.in | 11 +
src/dialogs/dialog-cell-sort.c | 8 +-
src/dialogs/dialog-function-select.c | 17 +-
src/dialogs/dialog-plugin-manager.c | 38 ++--
src/dialogs/dialog-preferences.c | 125 +++++----
src/gnumeric-gconf.h | 455 ++++++++++++++++++++--------------
tools/handle-conf-options | 421 +++++++++++++++++++++++++++++++
7 files changed, 800 insertions(+), 275 deletions(-)
---
diff --git a/schemas/gnumeric-general.schemas.in b/schemas/gnumeric-general.schemas.in
index b945bef..7e92a3e 100644
--- a/schemas/gnumeric-general.schemas.in
+++ b/schemas/gnumeric-general.schemas.in
@@ -135,6 +135,17 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/gnumeric/core/workbook/autosave_time</key>
+ <applyto>/apps/gnumeric/core/workbook/autosave_time</applyto>
+ <owner>Gnumeric</owner>
+ <type>int</type>
+ <default>0</default>
+ <locale name="C">
+ <short>Autosave frequency</short>
+ <long>The number of seconds between autosaves.</long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/gnumeric/core/gui/screen/horizontaldpi</key>
<applyto>/apps/gnumeric/core/gui/screen/horizontaldpi</applyto>
<owner>Gnumeric</owner>
diff --git a/src/dialogs/dialog-cell-sort.c b/src/dialogs/dialog-cell-sort.c
index 468d2d7..5ea1d2b 100644
--- a/src/dialogs/dialog-cell-sort.c
+++ b/src/dialogs/dialog-cell-sort.c
@@ -229,7 +229,7 @@ append_data (SortFlowState *state, int i, int index)
gchar *str, *header;
GtkTreeIter iter;
Sheet *sheet = state->sel->v_range.cell.a.sheet;
- gboolean sort_asc = gnm_app_prefs->sort_default_ascending;
+ gboolean sort_asc = gnm_conf_get_core_sort_default_ascending ();
header = state->is_cols
? header_name (sheet, i, index)
@@ -244,7 +244,7 @@ append_data (SortFlowState *state, int i, int index)
ITEM_DESCENDING, !sort_asc,
ITEM_DESCENDING_IMAGE, sort_asc ? state->image_ascending
: state->image_descending,
- ITEM_CASE_SENSITIVE, gnm_app_prefs->sort_default_by_case,
+ ITEM_CASE_SENSITIVE, gnm_conf_get_core_sort_default_by_case (),
ITEM_SORT_BY_VALUE, TRUE,
ITEM_MOVE_FORMAT, TRUE,
ITEM_NUMBER, i,
@@ -359,7 +359,7 @@ load_model_data (SortFlowState *state)
int end;
int index;
int i;
- int limit = gnm_app_prefs->sort_max_initial_clauses;
+ int limit = gnm_conf_get_core_sort_dialog_max_initial_clauses ();
if (state->is_cols) {
start = state->sel->v_range.cell.a.col;
@@ -1004,7 +1004,7 @@ dialog_init (SortFlowState *state)
state->retain_format_check = glade_xml_get_widget (state->gui,
"retain_format_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->retain_format_check),
- gnm_app_prefs->sort_default_retain_formats);
+ gnm_conf_get_core_sort_default_retain_formats ());
/* Set-up buttons */
diff --git a/src/dialogs/dialog-function-select.c b/src/dialogs/dialog-function-select.c
index 9f0950e..fbcb56d 100644
--- a/src/dialogs/dialog-function-select.c
+++ b/src/dialogs/dialog-function-select.c
@@ -80,15 +80,17 @@ enum {
static void
dialog_function_load_recent_funcs (FunctionSelectState *state)
{
- GnmFunc *fd;
- GSList const *recent_funcs, *this_funcs;
+ GSList const *recent_funcs;
- recent_funcs = gnm_app_prefs->recent_funcs;
+ for (recent_funcs = gnm_conf_get_functionselector_recentfunctions ();
+ recent_funcs;
+ recent_funcs = recent_funcs->next) {
+ char const *name = recent_funcs->data;
+ GnmFunc *fd;
- for (this_funcs = recent_funcs; this_funcs; this_funcs = this_funcs->next) {
- char const *name = this_funcs->data;
if (name == NULL)
continue;
+
fd = gnm_func_lookup (name, NULL);
if (fd)
state->recent_funcs = g_slist_prepend (state->recent_funcs, fd);
@@ -100,7 +102,7 @@ dialog_function_write_recent_func (FunctionSelectState *state, GnmFunc const *fd
{
GSList *rec_funcs;
GSList *gconf_value_list = NULL;
- guint ulimit = gnm_app_prefs->num_of_recent_funcs;
+ guint ulimit = gnm_conf_get_functionselector_num_of_recent ();
state->recent_funcs = g_slist_remove (state->recent_funcs, (gpointer) fd);
state->recent_funcs = g_slist_prepend (state->recent_funcs, (gpointer) fd);
@@ -113,7 +115,8 @@ dialog_function_write_recent_func (FunctionSelectState *state, GnmFunc const *fd
gconf_value_list = g_slist_prepend
(gconf_value_list, g_strdup (gnm_func_get_name (rec_funcs->data)));
}
- gnm_gconf_set_recent_funcs (gconf_value_list);
+ gnm_conf_set_functionselector_recentfunctions (gconf_value_list);
+ go_slist_free_custom (gconf_value_list, g_free);
go_conf_sync (NULL);
}
diff --git a/src/dialogs/dialog-plugin-manager.c b/src/dialogs/dialog-plugin-manager.c
index 76c8772..d105739 100644
--- a/src/dialogs/dialog-plugin-manager.c
+++ b/src/dialogs/dialog-plugin-manager.c
@@ -201,7 +201,7 @@ static void
cb_pm_checkbutton_install_new_toggled (GtkCheckButton *checkbutton,
G_GNUC_UNUSED PluginManagerGUI *pm_gui)
{
- gnm_gconf_set_activate_new_plugins (
+ gnm_conf_set_plugins_activate_new (
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton)));
}
@@ -257,7 +257,7 @@ pm_gui_load_directory_page (PluginManagerGUI *pm_gui)
pm_gui_load_directories (pm_gui, plugin_dirs, FALSE);
go_slist_free_custom (plugin_dirs, g_free);
}
- pm_gui_load_directories (pm_gui, gnm_app_prefs->plugin_extra_dirs, TRUE);
+ pm_gui_load_directories (pm_gui, gnm_conf_get_plugins_extra_dirs (), TRUE);
}
static void
@@ -288,14 +288,16 @@ cb_pm_button_directory_add_clicked (PluginManagerGUI *pm_gui)
path = dir_name;
}
- if (g_slist_find_custom ((GSList *)gnm_app_prefs->plugin_extra_dirs,
+ if (g_slist_find_custom (gnm_conf_get_plugins_extra_dirs (),
path, go_str_compare) == NULL) {
- GSList *extra_dirs = go_string_slist_copy (
- gnm_app_prefs->plugin_extra_dirs);
+ GSList *extra_dirs = go_string_slist_copy
+ (gnm_conf_get_plugins_extra_dirs ());
+
GO_SLIST_PREPEND (extra_dirs, path);
- GO_SLIST_SORT (extra_dirs, go_str_compare);
- gnm_gconf_set_plugin_extra_dirs (extra_dirs);
+ gnm_conf_set_plugins_extra_dirs (extra_dirs);
+ go_slist_free_custom (extra_dirs, g_free);
+
pm_gui_load_directory_page (pm_gui);
cb_pm_button_rescan_directories_clicked (pm_gui);
} else
@@ -311,6 +313,7 @@ cb_pm_button_directory_delete_clicked (PluginManagerGUI *pm_gui)
GtkTreeIter iter;
char *dir_name = NULL;
gboolean is_system = TRUE;
+ GSList *extra_dirs, *res;
if (!gtk_tree_selection_get_selected (pm_gui->selection_directory, NULL, &iter))
return;
@@ -320,20 +323,23 @@ cb_pm_button_directory_delete_clicked (PluginManagerGUI *pm_gui)
DIR_IS_SYSTEM, &is_system,
-1);
- if (!is_system
- && g_slist_find_custom ((GSList *)gnm_app_prefs->plugin_extra_dirs,
- dir_name, go_str_compare) != NULL) {
-
- GSList *extra_dirs = go_string_slist_copy (gnm_app_prefs->plugin_extra_dirs);
- GSList *res = g_slist_find_custom (extra_dirs, dir_name, go_str_compare);
+ extra_dirs = go_string_slist_copy (gnm_conf_get_plugins_extra_dirs ());
+ res = is_system
+ ? NULL
+ : g_slist_find_custom (extra_dirs, dir_name, go_str_compare);
+ if (res) {
+ extra_dirs = g_slist_remove_link (extra_dirs, res);
g_free (res->data);
- extra_dirs = g_slist_remove (extra_dirs, res->data);
+ g_slist_free_1 (res);
+
+ gnm_conf_set_plugins_extra_dirs (extra_dirs);
- gnm_gconf_set_plugin_extra_dirs (extra_dirs);
pm_gui_load_directory_page (pm_gui);
cb_pm_button_rescan_directories_clicked (pm_gui);
}
+
+ go_slist_free_custom (extra_dirs, g_free);
g_free (dir_name);
}
@@ -511,7 +517,7 @@ pm_dialog_init (PluginManagerGUI *pm_gui)
G_CALLBACK (cb_pm_checkbutton_install_new_toggled), pm_gui);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pm_gui->checkbutton_install_new),
- gnm_app_prefs->activate_new_plugins);
+ gnm_conf_get_plugins_activate_new ());
/* initialize plugin list */
gtk_list_store_clear (pm_gui->model_plugins);
diff --git a/src/dialogs/dialog-preferences.c b/src/dialogs/dialog-preferences.c
index 350d118..4d4a912 100644
--- a/src/dialogs/dialog-preferences.c
+++ b/src/dialogs/dialog-preferences.c
@@ -402,16 +402,16 @@ cb_pref_font_set_fonts (GOConfNode *node, char const *key, GtkWidget *page)
{
if (!key || g_str_has_suffix (key, GNM_CONF_FONT_NAME))
font_selector_set_name (FONT_SELECTOR (page),
- gnm_app_prefs->default_font.name);
+ gnm_conf_get_core_defaultfont_name ());
if (!key || g_str_has_suffix (key, GNM_CONF_FONT_SIZE))
font_selector_set_points (FONT_SELECTOR (page),
- gnm_app_prefs->default_font.size);
+ gnm_conf_get_core_defaultfont_size ());
if (!key ||
g_str_has_suffix (key, GNM_CONF_FONT_BOLD) ||
g_str_has_suffix (key, GNM_CONF_FONT_ITALIC))
font_selector_set_style (FONT_SELECTOR (page),
- gnm_app_prefs->default_font.is_bold,
- gnm_app_prefs->default_font.is_italic);
+ gnm_conf_get_core_defaultfont_bold (),
+ gnm_conf_get_core_defaultfont_italic ());
}
static gboolean
@@ -419,16 +419,16 @@ cb_pref_font_has_changed (G_GNUC_UNUSED FontSelector *fs,
GnmStyle *mstyle, PrefState *state)
{
if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_SIZE))
- gnm_gconf_set_default_font_size
+ gnm_conf_set_core_defaultfont_size
(gnm_style_get_font_size (mstyle));
if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_NAME))
- gnm_gconf_set_default_font_name (
+ gnm_conf_set_core_defaultfont_name (
gnm_style_get_font_name (mstyle));
if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_BOLD))
- gnm_gconf_set_default_font_bold (
+ gnm_conf_set_core_defaultfont_bold (
gnm_style_get_font_bold (mstyle));
if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_ITALIC))
- gnm_gconf_set_default_font_italic (
+ gnm_conf_set_core_defaultfont_italic (
gnm_style_get_font_italic (mstyle));
return TRUE;
}
@@ -460,36 +460,49 @@ pref_font_initializer (PrefState *state,
/*******************************************************************************************/
static void
-cb_pref_font_hf_set_fonts (GOConfNode *node, char const *key, GtkWidget *page)
+cb_pref_font_hf_set_fonts (G_GNUC_UNUSED GOConfNode *node,
+ char const *key, GtkWidget *page)
{
- node = gnm_conf_get_root ();
+ FontSelector *fs = FONT_SELECTOR (page);
+
if (!key ||
g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_NAME)) {
- gchar *name = go_conf_load_string (
- node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_NAME);
- font_selector_set_name (FONT_SELECTOR (page), name);
- g_free (name);
+ const char *name = gnm_conf_get_printsetup_hf_font_name ();
+ font_selector_set_name (fs, name);
}
- if (!key ||
- g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_SIZE))
- font_selector_set_points (FONT_SELECTOR (page),
- go_conf_get_double (
- node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_SIZE));
+
+ if (!key ||
+ g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_SIZE)) {
+ double size = gnm_conf_get_printsetup_hf_font_size ();
+ font_selector_set_points (fs, size);
+ }
+
if (!key ||
g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_BOLD) ||
- g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_ITALIC))
- font_selector_set_style (FONT_SELECTOR (page),
- go_conf_get_bool (
- node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_BOLD),
- go_conf_get_bool (
- node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_ITALIC));
+ g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_ITALIC)) {
+ gboolean bold = gnm_conf_get_printsetup_hf_font_bold ();
+ gboolean italic = gnm_conf_get_printsetup_hf_font_italic ();
+ font_selector_set_style (fs, bold, italic);
+ }
}
static gboolean
cb_pref_font_hf_has_changed (G_GNUC_UNUSED FontSelector *fs,
GnmStyle *mstyle, PrefState *state)
{
- gnm_gconf_set_hf_font (mstyle);
+ if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_SIZE))
+ gnm_conf_set_printsetup_hf_font_size
+ (gnm_style_get_font_size (mstyle));
+ if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_NAME))
+ gnm_conf_set_printsetup_hf_font_name
+ (gnm_style_get_font_name (mstyle));
+ if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_BOLD))
+ gnm_conf_set_printsetup_hf_font_bold
+ (gnm_style_get_font_bold (mstyle));
+ if (gnm_style_is_element_set (mstyle, MSTYLE_FONT_ITALIC))
+ gnm_conf_set_printsetup_hf_font_italic
+ (gnm_style_get_font_italic (mstyle));
+
return TRUE;
}
@@ -531,19 +544,19 @@ pref_undo_page_initializer (PrefState *state,
node = go_conf_get_node (state->root, GNM_CONF_UNDO_DIR);
int_pref_create_widget (node, GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH,
page, row++, 5, 5, 200, 1,
- gnm_gconf_set_max_descriptor_width,
+ gnm_conf_set_undo_max_descriptor_width,
_("Length of Undo Descriptors"));
int_pref_create_widget (node, GNM_CONF_UNDO_SIZE,
page, row++, 1000, 0, 30000, 100,
- gnm_gconf_set_undo_size,
+ gnm_conf_set_undo_size,
_("Maximal Undo Size"));
int_pref_create_widget (node, GNM_CONF_UNDO_MAXNUM,
page, row++, 20, 1, 200, 1,
- gnm_gconf_set_undo_max_number,
+ gnm_conf_set_undo_maxnum,
_("Number of Undo Items"));
bool_pref_create_widget (node, GNM_CONF_UNDO_SHOW_SHEET_NAME,
page, row++,
- gnm_gconf_set_show_sheet_name,
+ gnm_conf_set_undo_show_sheet_name,
_("Show Sheet Name in Undo List"));
go_conf_free_node (node);
@@ -568,19 +581,19 @@ pref_sort_page_initializer (PrefState *state,
node = go_conf_get_node (state->root, GNM_CONF_SORT_DIR);
int_pref_create_widget (node, GNM_CONF_SORT_DIALOG_MAX_INITIAL,
page, row++, 10, 0, 50, 1,
- gnm_gconf_set_sort_dialog_max_initial,
+ gnm_conf_set_core_sort_dialog_max_initial_clauses,
_("Number of Automatic Clauses"));
bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_RETAIN_FORM,
page, row++,
- gnm_gconf_set_sort_retain_form,
+ gnm_conf_set_core_sort_default_retain_formats,
_("Sorting Preserves Formats"));
bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_BY_CASE,
page, row++,
- gnm_gconf_set_sort_by_case,
+ gnm_conf_set_core_sort_default_by_case,
_("Sorting is Case-Sensitive"));
bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_ASCENDING,
page, row++,
- gnm_gconf_set_sort_ascending,
+ gnm_conf_set_core_sort_default_ascending,
_("Sort Ascending"));
go_conf_free_node (node);
@@ -606,38 +619,38 @@ pref_window_page_initializer (PrefState *state,
node = go_conf_get_node (state->root, GNM_CONF_GUI_DIR);
double_pref_create_widget (node, GNM_CONF_GUI_WINDOW_Y,
page, row++, 0.75, 0.25, 1, 0.05, 2,
- gnm_gconf_set_gui_window_y,
+ gnm_conf_set_core_gui_window_y,
_("Default Vertical Window Size"));
double_pref_create_widget (node, GNM_CONF_GUI_WINDOW_X,
page, row++, 0.75, 0.25, 1, 0.05, 2,
- gnm_gconf_set_gui_window_x,
+ gnm_conf_set_core_gui_window_x,
_("Default Horizontal Window Size"));
double_pref_create_widget (node, GNM_CONF_GUI_ZOOM,
page, row++, 1.00, 0.10, 5.00, 0.05, 2,
- gnm_gconf_set_gui_zoom,
+ gnm_conf_set_core_gui_window_zoom,
_("Default Zoom Factor"));
int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NSHEETS,
page, row++, 1, 1, 64, 1,
- gnm_gconf_set_workbook_nsheets,
+ gnm_conf_set_core_workbook_n_sheet,
_("Default Number of Sheets"));
w = int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NROWS,
page, row++,
GNM_DEFAULT_ROWS, GNM_MIN_ROWS, GNM_MAX_ROWS, 1,
- gnm_gconf_set_workbook_nrows,
- _("Default Number of Rows in a Sheet"));
+ gnm_conf_set_core_workbook_n_rows,
+ _("Default Number of Rows in a Sheet"));
power_of_2_handlers (w);
w = int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NCOLS,
page, row++,
GNM_DEFAULT_COLS, GNM_MIN_COLS, GNM_MAX_COLS, 1,
- gnm_gconf_set_workbook_ncols,
- _("Default Number of Columns in a Sheet"));
+ gnm_conf_set_core_workbook_n_cols,
+ _("Default Number of Columns in a Sheet"));
power_of_2_handlers (w);
bool_pref_create_widget (node, GNM_CONF_GUI_ED_LIVESCROLLING,
page, row++,
- gnm_gconf_set_gui_livescrolling,
+ gnm_conf_set_core_gui_editing_livescrolling,
_("Live Scrolling"));
go_conf_free_node (node);
@@ -662,26 +675,26 @@ pref_file_page_initializer (PrefState *state,
node = go_conf_get_node (state->root, GNM_CONF_FILE_DIR);
int_pref_create_widget (state->root, GNM_CONF_XML_COMPRESSION,
page, row++, 9, 0, 9, 1,
- gnm_gconf_set_xml_compression,
+ gnm_conf_set_core_xml_compression_level,
_("Default Compression Level For "
"Gnumeric Files"));
int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_AUTOSAVE_TIME,
page, row++, 0, 0, 365*24*60*60, 60,
- gnm_gconf_set_workbook_autosave_time,
+ gnm_conf_set_core_workbook_autosave_time,
_("Default autosave frequency in seconds"));
bool_pref_create_widget (node, GNM_CONF_FILE_OVERWRITE_DEFAULT,
page, row++,
- gnm_gconf_set_file_overwrite,
+ gnm_conf_set_core_file_save_def_overwrite,
_("Default To Overwriting Files"));
bool_pref_create_widget (node, GNM_CONF_FILE_SINGLE_SHEET_SAVE,
page, row++,
- gnm_gconf_set_file_single_sheet_save,
+ gnm_conf_set_core_file_save_single_sheet,
_("Warn When Exporting Into Single "
"Sheet Format"));
bool_pref_create_widget (state->root,
PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8,
page, row++,
- gnm_gconf_set_latex_use_utf8,
+ gnm_conf_set_plugin_latex_use_utf8,
_("Use UTF-8 in LaTeX Export"));
go_conf_free_node (node);
@@ -706,11 +719,11 @@ pref_screen_page_initializer (PrefState *state,
node = go_conf_get_node (state->root, GNM_CONF_GUI_DIR);
double_pref_create_widget (node, GNM_CONF_GUI_RES_H, page, row++,
96, 50, 250, 1, 1,
- gnm_gconf_set_gui_resolution_h,
+ gnm_conf_set_core_gui_screen_horizontaldpi,
_("Horizontal DPI"));
double_pref_create_widget (node, GNM_CONF_GUI_RES_V, page, row++,
96, 50, 250, 1, 1,
- gnm_gconf_set_gui_resolution_v,
+ gnm_conf_set_core_gui_screen_verticaldpi,
_("Vertical DPI"));
go_conf_free_node (node);
@@ -735,27 +748,27 @@ pref_tool_page_initializer (PrefState *state,
GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_ENTER_MOVES_DIR,
page, row++,
GO_TYPE_DIRECTION,
- (enum_conf_setter_t) gnm_gconf_set_enter_moves_dir,
+ (enum_conf_setter_t)gnm_conf_set_core_gui_editing_enter_moves_dir,
_("Enter _Moves Selection"));
bool_pref_create_widget (state->root,
GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_TRANSITION_KEYS,
page, row++,
- gnm_gconf_set_gui_transition_keys,
+ gnm_conf_set_core_gui_editing_transitionkeys,
_("Transition Keys"));
bool_pref_create_widget (state->root,
GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_AUTOCOMPLETE,
page, row++,
- gnm_gconf_set_autocomplete,
+ gnm_conf_set_core_gui_editing_autocomplete,
_("Autocomplete"));
bool_pref_create_widget (state->root,
DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS,
page, row++,
- gnm_gconf_set_unfocused_rs,
+ gnm_conf_set_dialogs_rs_unfocused,
_("Allow Unfocused Range Selections"));
int_pref_create_widget (state->root,
FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_NUM_OF_RECENT,
page, row++, 10, 0, 40, 1,
- gnm_gconf_set_num_recent_functions,
+ gnm_conf_set_functionselector_num_of_recent,
_("Maximum Length of Recently "
"Used Functions List"));
@@ -779,7 +792,7 @@ pref_copypaste_page_initializer (PrefState *state,
bool_pref_create_widget (state->root,
GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD,
page, row++,
- gnm_gconf_set_prefer_clipboard,
+ gnm_conf_set_cut_and_paste_prefer_clipboard,
_("Prefer CLIPBOARD Over PRIMARY Selection"));
gtk_widget_show_all (page);
diff --git a/src/gnumeric-gconf.h b/src/gnumeric-gconf.h
index e170c4f..d4da674 100644
--- a/src/gnumeric-gconf.h
+++ b/src/gnumeric-gconf.h
@@ -2,206 +2,277 @@
#ifndef _GNM_GCONF_H_
# define _GNM_GCONF_H_
-#include "numbers.h"
-#include <gnumeric.h>
-#include <glib-object.h>
-#include <print-info.h>
-#include <libgnumeric.h>
#include <goffice/goffice.h>
-#include <gtk/gtk.h>
G_BEGIN_DECLS
-typedef struct {
- struct {
- GSList const *extra_dirs;
- char *sys_dir;
- char *usr_dir;
- } autoformat;
-
- struct {
- char const *name;
- float size;
- gboolean is_bold, is_italic;
- } default_font;
-
- guint num_of_recent_funcs;
- GSList const *recent_funcs;
-
- GSList const *plugin_file_states;
- GSList const *plugin_extra_dirs;
- GSList const *active_plugins;
- gboolean activate_new_plugins;
-
- gboolean show_sheet_name;
- guint max_descriptor_width;
- gint undo_size;
- gint undo_max_number;
-
- gint initial_sheet_number;
- gint row_number;
- gint col_number;
- gint autosave_time;
- float horizontal_window_fraction;
- float vertical_window_fraction;
- float zoom;
-
- gint xml_compression_level;
- gboolean file_overwrite_default_answer;
- gboolean file_ask_single_sheet_save;
-
- gboolean sort_default_by_case;
- gboolean sort_default_retain_formats;
- gboolean sort_default_ascending;
- gint sort_max_initial_clauses;
-
- gboolean print_all_sheets; /* vs print only selected */
- GSList const *printer_header;
- GSList const *printer_footer;
- GSList const *printer_header_formats_left;
- GSList const *printer_header_formats_middle;
- GSList const *printer_header_formats_right;
- GnmStyle *printer_decoration_font;
- gboolean print_center_horizontally;
- gboolean print_center_vertically;
- gboolean print_grid_lines;
- gboolean print_even_if_only_styles;
- gboolean print_black_and_white;
- gboolean print_titles;
- gboolean print_order_across_then_down;
- gboolean print_scale_percentage;
- float print_scale_percentage_value;
- gint print_scale_width;
- gint print_scale_height;
- gchar *print_repeat_top;
- gchar *print_repeat_left;
- double print_margin_top;
- double print_margin_bottom;
- GtkUnit desired_display;
-
- /* Also acts as flag whether the print defaults are loaded */
- GtkPrintSettings *print_settings;
- GtkPageSetup *page_setup;
-
-
- float horizontal_dpi;
- float vertical_dpi;
-
- gboolean auto_complete;
- GODirection enter_moves_dir; /* Which way does hitting <Enter> go */
- gboolean transition_keys;
-
- gboolean live_scrolling;
- gboolean detachable_toolbars;
- GHashTable *toolbars;
- GHashTable *toolbar_positions;
- gint recalc_lag;
- gboolean unfocused_range_selection;
- gboolean prefer_clipboard_selection; /* As opposed to "primary". */
- gboolean latex_use_utf8;
-} GnmAppPrefs;
-GNM_VAR_DECL GnmAppPrefs const *gnm_app_prefs;
-
void gnm_conf_init (gboolean fast);
void gnm_conf_shutdown (void);
GOConfNode *gnm_conf_get_root (void);
-/* autocomplete */
-void gnm_gconf_set_autocomplete (gboolean val);
-
-/* autoformat */
-void gnm_gconf_set_autoformat_sys_dirs (char const * string);
-void gnm_gconf_set_autoformat_usr_dirs (char const * string);
-
-/* plugins */
-void gnm_gconf_set_plugin_file_states (GSList *list);
-void gnm_gconf_set_plugin_extra_dirs (GSList *list);
-void gnm_gconf_set_active_plugins (GSList *list);
-void gnm_gconf_set_activate_new_plugins (gboolean val);
-
-/* undo */
-void gnm_gconf_set_show_sheet_name (gboolean val);
-void gnm_gconf_set_max_descriptor_width (gint val);
-void gnm_gconf_set_undo_size (gint val);
-void gnm_gconf_set_undo_max_number (gint val);
-
-/* xml/files */
-void gnm_gconf_set_recent_funcs (GSList *list);
-void gnm_gconf_set_xml_compression (gint value);
-void gnm_gconf_set_file_overwrite (gboolean value);
-void gnm_gconf_set_file_single_sheet_save (gboolean value);
-
-/* print-setup & printing */
-void gnm_gconf_init_printer_defaults (void);
-
-void gnm_gconf_set_all_sheets (gboolean val);
-void gnm_gconf_set_printer_header (gchar const *left, gchar const *middle,
- gchar const *right);
-void gnm_gconf_set_printer_footer (gchar const *left, gchar const *middle,
- gchar const *right);
-void gnm_gconf_set_print_center_horizontally (gboolean val);
-void gnm_gconf_set_print_center_vertically (gboolean val);
-void gnm_gconf_set_print_grid_lines (gboolean val);
-void gnm_gconf_set_print_even_if_only_styles (gboolean val);
-void gnm_gconf_set_print_black_and_white (gboolean val);
-void gnm_gconf_set_print_titles (gboolean val);
-void gnm_gconf_set_print_order_across_then_down (gboolean val);
-void gnm_gconf_set_print_scale_percentage (gboolean val);
-void gnm_gconf_set_print_scale_percentage_value (gnm_float val);
-void gnm_gconf_set_print_tb_margins (double edge_to_header,
- double edge_to_footer,
- GtkUnit unit);
-void gnm_gconf_set_print_header_formats (GSList *left, GSList *middle,
- GSList *right);
-void gnm_gconf_set_print_settings (GtkPrintSettings *settings);
-void gnm_gconf_set_page_setup (GtkPageSetup *setup);
-GtkPrintSettings *gnm_gconf_get_print_settings (void);
-GtkPageSetup *gnm_gconf_get_page_setup (void);
-
-/* gui */
-void gnm_gconf_set_gui_window_x (gnm_float val);
-void gnm_gconf_set_gui_window_y (gnm_float val);
-void gnm_gconf_set_gui_zoom (gnm_float val);
-void gnm_gconf_set_gui_transition_keys (gboolean value);
-void gnm_gconf_set_gui_livescrolling (gboolean value);
-void gnm_gconf_set_gui_resolution_h (gnm_float val);
-void gnm_gconf_set_gui_resolution_v (gnm_float val);
-gboolean gnm_gconf_get_toolbar_visible (char const *name);
-void gnm_gconf_set_toolbar_visible (char const *name, gboolean vis);
-int gnm_gconf_get_toolbar_position (char const *name);
-void gnm_gconf_set_toolbar_position (char const *name, int pos);
-void gnm_gconf_set_enter_moves_dir (GODirection val);
-
-/* default font */
-void gnm_gconf_set_default_font_size (gnm_float val);
-void gnm_gconf_set_default_font_name (char const *str);
-void gnm_gconf_set_default_font_bold (gboolean val);
-void gnm_gconf_set_default_font_italic (gboolean val);
-
-/* hf font */
-void gnm_gconf_set_hf_font (GnmStyle const *mstyle);
-
-/* sorting */
-void gnm_gconf_set_sort_dialog_max_initial (gint value);
-void gnm_gconf_set_sort_retain_form (gboolean value);
-void gnm_gconf_set_sort_by_case (gboolean value);
-void gnm_gconf_set_sort_ascending (gboolean value);
-
-/* workbook */
-void gnm_gconf_set_workbook_nsheets (gint value);
-void gnm_gconf_set_workbook_nrows (gint value);
-void gnm_gconf_set_workbook_ncols (gint value);
-void gnm_gconf_set_workbook_autosave_time (gint value);
-void gnm_gconf_set_unfocused_rs (gboolean value);
-
-/* function selector and formula guru */
-void gnm_gconf_set_num_recent_functions (gint value);
-
-/* standard plugins */
-void gnm_gconf_set_latex_use_utf8 (gboolean value);
-
-/* application interface */
-void gnm_gconf_set_prefer_clipboard (gboolean value);
+const char *gnm_conf_get_toolbar_style (void);
+void gnm_conf_set_toolbar_style (const char *);
+
+gboolean gnm_conf_get_autocorrect_first_letter (void);
+void gnm_conf_set_autocorrect_first_letter (gboolean);
+
+GSList *gnm_conf_get_autocorrect_first_letter_list (void);
+void gnm_conf_set_autocorrect_first_letter_list (GSList *);
+
+gboolean gnm_conf_get_autocorrect_init_caps (void);
+void gnm_conf_set_autocorrect_init_caps (gboolean);
+
+GSList *gnm_conf_get_autocorrect_init_caps_list (void);
+void gnm_conf_set_autocorrect_init_caps_list (GSList *);
+
+gboolean gnm_conf_get_autocorrect_names_of_days (void);
+void gnm_conf_set_autocorrect_names_of_days (gboolean);
+
+gboolean gnm_conf_get_autocorrect_replace (void);
+void gnm_conf_set_autocorrect_replace (gboolean);
+
+GSList *gnm_conf_get_autoformat_extra_dirs (void);
+void gnm_conf_set_autoformat_extra_dirs (GSList *);
+
+const char *gnm_conf_get_autoformat_sys_dir (void);
+void gnm_conf_set_autoformat_sys_dir (const char *);
+
+const char *gnm_conf_get_autoformat_usr_dir (void);
+void gnm_conf_set_autoformat_usr_dir (const char *);
+
+gboolean gnm_conf_get_core_defaultfont_bold (void);
+void gnm_conf_set_core_defaultfont_bold (gboolean);
+
+gboolean gnm_conf_get_core_defaultfont_italic (void);
+void gnm_conf_set_core_defaultfont_italic (gboolean);
+
+const char *gnm_conf_get_core_defaultfont_name (void);
+void gnm_conf_set_core_defaultfont_name (const char *);
+
+double gnm_conf_get_core_defaultfont_size (void);
+void gnm_conf_set_core_defaultfont_size (double);
+
+gboolean gnm_conf_get_core_file_save_def_overwrite (void);
+void gnm_conf_set_core_file_save_def_overwrite (gboolean);
+
+gboolean gnm_conf_get_core_file_save_single_sheet (void);
+void gnm_conf_set_core_file_save_single_sheet (gboolean);
+
+gboolean gnm_conf_get_core_gui_editing_autocomplete (void);
+void gnm_conf_set_core_gui_editing_autocomplete (gboolean);
+
+GODirection gnm_conf_get_core_gui_editing_enter_moves_dir (void);
+void gnm_conf_set_core_gui_editing_enter_moves_dir (GODirection);
+
+gboolean gnm_conf_get_core_gui_editing_livescrolling (void);
+void gnm_conf_set_core_gui_editing_livescrolling (gboolean);
+
+int gnm_conf_get_core_gui_editing_recalclag (void);
+void gnm_conf_set_core_gui_editing_recalclag (int);
+
+gboolean gnm_conf_get_core_gui_editing_transitionkeys (void);
+void gnm_conf_set_core_gui_editing_transitionkeys (gboolean);
+
+double gnm_conf_get_core_gui_screen_horizontaldpi (void);
+void gnm_conf_set_core_gui_screen_horizontaldpi (double);
+
+double gnm_conf_get_core_gui_screen_verticaldpi (void);
+void gnm_conf_set_core_gui_screen_verticaldpi (double);
+
+gboolean gnm_conf_get_core_gui_toolbars_FormatToolbar (void);
+void gnm_conf_set_core_gui_toolbars_FormatToolbar (gboolean);
+
+int gnm_conf_get_core_gui_toolbars_FormatToolbar_position (void);
+void gnm_conf_set_core_gui_toolbars_FormatToolbar_position (int);
+
+gboolean gnm_conf_get_core_gui_toolbars_ObjectToolbar (void);
+void gnm_conf_set_core_gui_toolbars_ObjectToolbar (gboolean);
+
+int gnm_conf_get_core_gui_toolbars_ObjectToolbar_position (void);
+void gnm_conf_set_core_gui_toolbars_ObjectToolbar_position (int);
+
+gboolean gnm_conf_get_core_gui_toolbars_StandardToolbar (void);
+void gnm_conf_set_core_gui_toolbars_StandardToolbar (gboolean);
+
+int gnm_conf_get_core_gui_toolbars_StandardToolbar_position (void);
+void gnm_conf_set_core_gui_toolbars_StandardToolbar_position (int);
+
+double gnm_conf_get_core_gui_window_x (void);
+void gnm_conf_set_core_gui_window_x (double);
+
+double gnm_conf_get_core_gui_window_y (void);
+void gnm_conf_set_core_gui_window_y (double);
+
+double gnm_conf_get_core_gui_window_zoom (void);
+void gnm_conf_set_core_gui_window_zoom (double);
+
+gboolean gnm_conf_get_core_sort_default_ascending (void);
+void gnm_conf_set_core_sort_default_ascending (gboolean);
+
+gboolean gnm_conf_get_core_sort_default_by_case (void);
+void gnm_conf_set_core_sort_default_by_case (gboolean);
+
+gboolean gnm_conf_get_core_sort_default_retain_formats (void);
+void gnm_conf_set_core_sort_default_retain_formats (gboolean);
+
+int gnm_conf_get_core_sort_dialog_max_initial_clauses (void);
+void gnm_conf_set_core_sort_dialog_max_initial_clauses (int);
+
+int gnm_conf_get_core_workbook_autosave_time (void);
+void gnm_conf_set_core_workbook_autosave_time (int);
+
+int gnm_conf_get_core_workbook_n_cols (void);
+void gnm_conf_set_core_workbook_n_cols (int);
+
+int gnm_conf_get_core_workbook_n_rows (void);
+void gnm_conf_set_core_workbook_n_rows (int);
+
+int gnm_conf_get_core_workbook_n_sheet (void);
+void gnm_conf_set_core_workbook_n_sheet (int);
+
+int gnm_conf_get_core_xml_compression_level (void);
+void gnm_conf_set_core_xml_compression_level (int);
+
+gboolean gnm_conf_get_cut_and_paste_prefer_clipboard (void);
+void gnm_conf_set_cut_and_paste_prefer_clipboard (gboolean);
+
+gboolean gnm_conf_get_dialogs_rs_unfocused (void);
+void gnm_conf_set_dialogs_rs_unfocused (gboolean);
+
+int gnm_conf_get_functionselector_num_of_recent (void);
+void gnm_conf_set_functionselector_num_of_recent (int);
+
+GSList *gnm_conf_get_functionselector_recentfunctions (void);
+void gnm_conf_set_functionselector_recentfunctions (GSList *);
+
+gboolean gnm_conf_get_plugin_latex_use_utf8 (void);
+void gnm_conf_set_plugin_latex_use_utf8 (gboolean);
+
+gboolean gnm_conf_get_plugins_activate_new (void);
+void gnm_conf_set_plugins_activate_new (gboolean);
+
+GSList *gnm_conf_get_plugins_active (void);
+void gnm_conf_set_plugins_active (GSList *);
+
+GSList *gnm_conf_get_plugins_extra_dirs (void);
+void gnm_conf_set_plugins_extra_dirs (GSList *);
+
+GSList *gnm_conf_get_plugins_file_states (void);
+void gnm_conf_set_plugins_file_states (GSList *);
+
+GSList *gnm_conf_get_plugins_known (void);
+void gnm_conf_set_plugins_known (GSList *);
+
+gboolean gnm_conf_get_printsetup_across_then_down (void);
+void gnm_conf_set_printsetup_across_then_down (gboolean);
+
+gboolean gnm_conf_get_printsetup_all_sheets (void);
+void gnm_conf_set_printsetup_all_sheets (gboolean);
+
+gboolean gnm_conf_get_printsetup_center_horizontally (void);
+void gnm_conf_set_printsetup_center_horizontally (gboolean);
+
+gboolean gnm_conf_get_printsetup_center_vertically (void);
+void gnm_conf_set_printsetup_center_vertically (gboolean);
+
+GSList *gnm_conf_get_printsetup_footer (void);
+void gnm_conf_set_printsetup_footer (GSList *);
+
+GSList *gnm_conf_get_printsetup_gtk_setting (void);
+void gnm_conf_set_printsetup_gtk_setting (GSList *);
+
+GSList *gnm_conf_get_printsetup_header (void);
+void gnm_conf_set_printsetup_header (GSList *);
+
+gboolean gnm_conf_get_printsetup_hf_font_bold (void);
+void gnm_conf_set_printsetup_hf_font_bold (gboolean);
+
+gboolean gnm_conf_get_printsetup_hf_font_italic (void);
+void gnm_conf_set_printsetup_hf_font_italic (gboolean);
+
+const char *gnm_conf_get_printsetup_hf_font_name (void);
+void gnm_conf_set_printsetup_hf_font_name (const char *);
+
+double gnm_conf_get_printsetup_hf_font_size (void);
+void gnm_conf_set_printsetup_hf_font_size (double);
+
+GSList *gnm_conf_get_printsetup_hf_left (void);
+void gnm_conf_set_printsetup_hf_left (GSList *);
+
+GSList *gnm_conf_get_printsetup_hf_middle (void);
+void gnm_conf_set_printsetup_hf_middle (GSList *);
+
+GSList *gnm_conf_get_printsetup_hf_right (void);
+void gnm_conf_set_printsetup_hf_right (GSList *);
+
+double gnm_conf_get_printsetup_margin_bottom (void);
+void gnm_conf_set_printsetup_margin_bottom (double);
+
+double gnm_conf_get_printsetup_margin_gtk_bottom (void);
+void gnm_conf_set_printsetup_margin_gtk_bottom (double);
+
+double gnm_conf_get_printsetup_margin_gtk_left (void);
+void gnm_conf_set_printsetup_margin_gtk_left (double);
+
+double gnm_conf_get_printsetup_margin_gtk_right (void);
+void gnm_conf_set_printsetup_margin_gtk_right (double);
+
+double gnm_conf_get_printsetup_margin_gtk_top (void);
+void gnm_conf_set_printsetup_margin_gtk_top (double);
+
+double gnm_conf_get_printsetup_margin_top (void);
+void gnm_conf_set_printsetup_margin_top (double);
+
+const char *gnm_conf_get_printsetup_paper (void);
+void gnm_conf_set_printsetup_paper (const char *);
+
+int gnm_conf_get_printsetup_paper_orientation (void);
+void gnm_conf_set_printsetup_paper_orientation (int);
+
+const char *gnm_conf_get_printsetup_preferred_unit (void);
+void gnm_conf_set_printsetup_preferred_unit (const char *);
+
+gboolean gnm_conf_get_printsetup_print_black_n_white (void);
+void gnm_conf_set_printsetup_print_black_n_white (gboolean);
+
+gboolean gnm_conf_get_printsetup_print_even_if_only_styles (void);
+void gnm_conf_set_printsetup_print_even_if_only_styles (gboolean);
+
+gboolean gnm_conf_get_printsetup_print_grid_lines (void);
+void gnm_conf_set_printsetup_print_grid_lines (gboolean);
+
+gboolean gnm_conf_get_printsetup_print_titles (void);
+void gnm_conf_set_printsetup_print_titles (gboolean);
+
+const char *gnm_conf_get_printsetup_repeat_left (void);
+void gnm_conf_set_printsetup_repeat_left (const char *);
+
+const char *gnm_conf_get_printsetup_repeat_top (void);
+void gnm_conf_set_printsetup_repeat_top (const char *);
+
+int gnm_conf_get_printsetup_scale_height (void);
+void gnm_conf_set_printsetup_scale_height (int);
+
+gboolean gnm_conf_get_printsetup_scale_percentage (void);
+void gnm_conf_set_printsetup_scale_percentage (gboolean);
+
+double gnm_conf_get_printsetup_scale_percentage_value (void);
+void gnm_conf_set_printsetup_scale_percentage_value (double);
+
+int gnm_conf_get_printsetup_scale_width (void);
+void gnm_conf_set_printsetup_scale_width (int);
+
+int gnm_conf_get_undo_max_descriptor_width (void);
+void gnm_conf_set_undo_max_descriptor_width (int);
+
+int gnm_conf_get_undo_maxnum (void);
+void gnm_conf_set_undo_maxnum (int);
+
+gboolean gnm_conf_get_undo_show_sheet_name (void);
+void gnm_conf_set_undo_show_sheet_name (gboolean);
+
+int gnm_conf_get_undo_size (void);
+void gnm_conf_set_undo_size (int);
G_END_DECLS
diff --git a/tools/handle-conf-options b/tools/handle-conf-options
new file mode 100644
index 0000000..a3c2d39
--- /dev/null
+++ b/tools/handle-conf-options
@@ -0,0 +1,421 @@
+#!/usr/bin/perl -w
+
+use strict;
+use XML::Parser;
+
+my @schemas = ();
+
+for my $filename (@ARGV) {
+ my $parser = new XML::Parser ('Style' => 'Tree');
+ my $tree = $parser->parsefile ($filename);
+
+ &walk_tree ([], [{},@$tree]);
+}
+ schemas = sort { $a->{'applyto'} cmp $b->{'applyto'} } @schemas;
+my $N = @schemas;
+
+# Number the schemas and decide on a variable name.
+{
+ my $i = 0;
+ foreach my $schema (@schemas) {
+ $schema->{'i'} = $i++;
+
+ my $var = $schema->{'applyto'};
+ $var =~ s{^/apps/gnumeric/}{};
+ $var =~ s{^/apps/gnome-settings/gnumeric/}{};
+ $var =~ s{[^a-zA-Z0-9_]}{_}g;
+ $schema->{'var'} = $var;
+ }
+}
+
+my $cfile = "";
+my $hfile = "";
+
+my %type_to_ctype =
+ ('bool' => 'gboolean',
+ 'int' => 'int',
+ 'float' => 'double',
+ 'string' => 'const char *',
+ 'list:string' => 'GSList *',
+ 'GO_TYPE_DIRECTION' => 'GODirection',
+ );
+
+my %extra_attributes =
+ ('/apps/gnumeric/core/gui/editing/enter_moves_dir' => {
+ 'gtype' => 'GO_TYPE_DIRECTION',
+ },
+
+ '/apps/gnumeric/core/gui/editing/recalclag' => {
+ 'min' => -5000,
+ 'max' => 5000
+ },
+
+ '/apps/gnumeric/core/gui/toolbars/FormatToolbar-position' => {
+ 'min' => 0,
+ 'max' => 3,
+ },
+
+ '/apps/gnumeric/core/gui/toolbars/ObjectToolbar-position' => {
+ 'min' => 0,
+ 'max' => 3,
+ },
+
+ '/apps/gnumeric/core/gui/toolbars/StandardToolbar-position' => {
+ 'min' => 0,
+ 'max' => 3,
+ },
+
+ '/apps/gnumeric/core/sort/dialog/max-initial-clauses' => {
+ 'min' => 0,
+ 'max' => 256,
+ },
+
+ '/apps/gnumeric/core/workbook/n-cols' => {
+ 'min' => 'GNM_MIN_COLS',
+ 'max' => 'GNM_MAX_COLS',
+ },
+
+ '/apps/gnumeric/core/workbook/n-rows' => {
+ 'min' => 'GNM_MIN_ROWS',
+ 'max' => 'GNM_MAX_ROWS',
+ },
+
+ '/apps/gnumeric/core/workbook/n-sheet' => {
+ 'min' => 1,
+ 'max' => 64,
+ },
+
+ '/apps/gnumeric/core/workbook/autosave_time' => {
+ 'min' => 0,
+ 'max' => '365 * 24 * 60 * 60',
+ },
+
+ '/apps/gnumeric/core/xml/compression-level' => {
+ 'min' => 0,
+ 'max' => 9,
+ },
+
+ '/apps/gnumeric/functionselector/num-of-recent' => {
+ 'min' => 0,
+ 'max' => 40,
+ },
+
+ '/apps/gnumeric/printsetup/paper-orientation' => {
+ 'min' => 'GTK_PAGE_ORIENTATION_PORTRAIT',
+ 'max' => 'GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE',
+ },
+
+ '/apps/gnumeric/printsetup/scale-height' => {
+ 'min' => 0,
+ 'max' => 100,
+ },
+
+ '/apps/gnumeric/printsetup/scale-width' => {
+ 'min' => 0,
+ 'max' => 100,
+ },
+
+ '/apps/gnumeric/undo/max_descriptor_width' => {
+ 'min' => 5,
+ 'max' => 256,
+ },
+
+ '/apps/gnumeric/undo/maxnum' => {
+ 'min' => 0,
+ 'max' => 10000,
+ },
+
+ '/apps/gnumeric/undo/size' => {
+ 'min' => 1,
+ 'max' => 1000000
+ },
+
+ '/apps/gnumeric/core/defaultfont/size' => {
+ 'min' => 1,
+ 'max' => 100,
+ },
+
+ '/apps/gnumeric/core/gui/screen/horizontaldpi' => {
+ 'min' => 10,
+ 'max' => 1000,
+ },
+
+ '/apps/gnumeric/core/gui/screen/verticaldpi' => {
+ 'min' => 10,
+ 'max' => 1000,
+ },
+
+ '/apps/gnumeric/core/gui/window/x' => {
+ 'min' => 0.1,
+ 'max' => 1,
+ },
+
+ '/apps/gnumeric/core/gui/window/y' => {
+ 'min' => 0.1,
+ 'max' => 1,
+ },
+
+ '/apps/gnumeric/core/gui/window/zoom' => {
+ 'min' => 0.1,
+ 'max' => 5,
+ },
+
+ '/apps/gnumeric/printsetup/hf-font-size' => {
+ 'min' => 1,
+ 'max' => 100,
+ },
+
+ '/apps/gnumeric/printsetup/margin-bottom' => {
+ 'min' => 0,
+ 'max' => 10000,
+ },
+
+ '/apps/gnumeric/printsetup/margin-gtk-bottom' => {
+ 'min' => 0,
+ 'max' => 720,
+ },
+
+ '/apps/gnumeric/printsetup/margin-gtk-left' => {
+ 'min' => 0,
+ 'max' => 720,
+ },
+
+ '/apps/gnumeric/printsetup/margin-gtk-right' => {
+ 'min' => 0,
+ 'max' => 720,
+ },
+
+ '/apps/gnumeric/printsetup/margin-gtk-top' => {
+ 'min' => 0,
+ 'max' => 720,
+ },
+
+ '/apps/gnumeric/printsetup/margin-top' => {
+ 'min' => 0,
+ 'max' => 10000,
+ },
+
+ '/apps/gnumeric/printsetup/scale-percentage-value' => {
+ 'min' => 1,
+ 'max' => 500,
+ },
+
+ );
+
+foreach my $schema (@schemas) {
+ my $key = $schema->{'applyto'};
+ my $e = $extra_attributes{$key};
+ next unless $e;
+ foreach my $k (keys %$e) {
+ $schema->{$k} = $e->{$k};
+ }
+}
+
+# -----------------------------------------------------------------------------
+
+foreach my $schema (@schemas) {
+ my $i = $schema->{'i'};
+ my $var = $schema->{'var'};
+ my $key = $schema->{'applyto'};
+ my $type = $schema->{'type'};
+ $type .= ":" . $schema->{'list_type'} if $type eq 'list';
+ my $default = $schema->{'default'};
+ my $min = $schema->{'min'};
+ my $max = $schema->{'max'};
+ my $gtype = ($schema->{'gtype'} || '0');
+
+ my $ctype = $type_to_ctype{$gtype || $type};
+ my $ctypes = "$ctype "; $ctypes =~ s/\*\s/\*/;
+
+ $hfile .= "${ctypes}gnm_conf_get_$var (void);\n";
+ $hfile .= "void gnm_conf_set_$var ($ctype);\n\n";
+
+ my $get_head = "$ctype\ngnm_conf_get_$var (void)";
+ my $set_head = "void\ngnm_conf_set_$var (${ctypes}x)";
+
+
+ if ($type eq 'bool') {
+ $default = uc $default;
+
+ $cfile .= "$get_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\treturn go_conf_load_bool (root, key, $default);\n";
+ $cfile .= "}\n\n";
+
+ $cfile .= "$set_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tgo_conf_set_bool (root, key, x != FALSE);\n";
+ $cfile .= "}\n\n";
+ } elsif ($type eq 'int' || $type eq 'float') {
+ die "$0: No min for $key\n" unless defined $min;
+ die "$0: No max for $key\n" unless defined $max;
+
+ $cfile .= "$get_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\treturn go_conf_load_$ctype (root, key, $min, $max, $default);\n";
+ $cfile .= "}\n\n";
+
+ $cfile .= "void\n";
+ $cfile .= "gnm_conf_set_$var ($ctype x)\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tgo_conf_set_$ctype (root, key, CLAMP (x, $min, $max));\n";
+ $cfile .= "}\n\n";
+ } elsif ($type eq 'string' && $gtype eq '0') {
+ $cfile .= "$get_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tchar *res = go_conf_load_string (root, key, \"$default\");\n";
+ $cfile .= "\tg_hash_table_replace (string_pool, key, res);\n";
+ $cfile .= "\treturn res;\n";
+ $cfile .= "}\n\n";
+
+ $cfile .= "$set_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tgo_conf_set_string (root, key, x);\n";
+ $cfile .= "\tg_hash_table_remove (string_pool, key);\n";
+ $cfile .= "}\n\n";
+ } elsif ($type eq 'string' && $gtype ne '0') {
+ $cfile .= "$get_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\treturn go_conf_load_enum (root, key, $gtype, $default);\n";
+ $cfile .= "}\n\n";
+
+ $cfile .= "$set_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tgo_conf_set_enum (root, key, $gtype, x);\n";
+ $cfile .= "}\n\n";
+ } elsif ($type eq 'list:string') {
+ $cfile .= "$get_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tGSList *res = go_conf_load_str_list (root, key);\n";
+ $cfile .= "\tg_hash_table_replace (string_list_pool, key, res);\n";
+ $cfile .= "\treturn res;\n";
+ $cfile .= "}\n\n";
+
+ $cfile .= "$set_head\n";
+ $cfile .= "{\n";
+ $cfile .= "\tconst char *key = \"$key\";\n";
+ $cfile .= "\tgo_conf_set_str_list (root, key, x);\n";
+ $cfile .= "\tg_hash_table_remove (string_list_pool, key);\n";
+ $cfile .= "}\n\n";
+ } else {
+ die "$0: Unhandled type $type\n";
+ }
+}
+
+print $hfile;
+print $cfile;
+
+# -----------------------------------------------------------------------------
+
+my $schema;
+sub walk_tree {
+ my ($parents,$contents) = @_;
+
+ if (ref ($contents) eq 'ARRAY') {
+ my @items = @$contents;
+ my $attrs = shift @items;
+
+ while (@items) {
+ my $tag = shift @items;
+ my $args = shift @items;
+
+ if ($tag eq '0') {
+ # Text
+ if (@$parents > 2 && $parents->[-2] eq 'schema') {
+ my $key = $parents->[-1];
+ next if $key eq 'locale';
+ $schema->{$key} = $args;
+ }
+ if (@$parents > 3 &&
+ $parents->[-3] eq 'schema' &&
+ $parents->[-2] eq 'locale') {
+ my $key = $parents->[-1];
+ next if $key ne 'default';
+ $schema->{$key} = $args;
+ }
+ } else {
+ $schema = {} if $tag eq 'schema';
+ if (@$parents > 1 && $parents->[-1] eq 'schema') {
+ # This handles empty defaults.
+ $schema->{$tag} = '';
+ }
+ &walk_tree ([ $parents,$tag],$args);
+ push @schemas, $schema if $tag eq 'schema';
+ }
+ }
+ }
+}
+
+# -----------------------------------------------------------------------------
+
+__END__
+
+print "static unsigned char key_loaded[$N];\n\n";
+print "static const char *key_names[$N] = {\n";
+foreach my $schema (@schemas) {
+ my $comma = ($schema->{'i'} == $N - 1) ? "" : ",";
+ print "\t\"", $schema->{'applyto'}, "\"$comma\n";
+}
+print "};\n\n";
+
+print "static void\n";
+print "load_one_option (int i)\n";
+print "{\n";
+print "\tconst char *key;\n";
+print "\tg_return_if_fail (i >= 0 && i < $N);\n";
+print "\n";
+print "\tkey = key_names[i];\n";
+print "\n";
+print "\tswitch (i) {\n";
+foreach my $schema (@schemas) {
+ my $i = $schema->{'i'};
+ my $var = "prefs." . $schema->{'var'};
+ my $key = $schema->{'applyto'};
+ my $type = $schema->{'type'};
+ $type .= ":" . $schema->{'list_type'} if $type eq 'list';
+ my $default = $schema->{'default'};
+
+ print "\tcase $i:\n";
+ if ($type eq 'bool') {
+ $default = uc $default;
+ print "\t\t$var =\n";
+ print "\t\t\tgo_conf_load_bool (node, key, $default);\n";
+ } elsif ($type eq 'int') {
+ my $min = 42; # FIXME
+ my $max = 42; # FIXME
+ print "\t\t$var =\n";
+ print "\t\t\tgo_conf_load_int (node, key, $min, $max, $default);\n";
+ } elsif ($type eq 'float') {
+ my $min = 42; # FIXME
+ my $max = 42; # FIXME
+ print "\t\t$var =\n";
+ print "\t\t\tgo_conf_load_double (node, key, $min, $max, $default);\n";
+ } elsif ($type eq 'string') {
+ print "\t\tg_free ($var);\n";
+ print "\t\t$var =\n";
+ print "\t\t\tgo_conf_load_string (node, key);\n";
+ } elsif ($type eq 'list:string') {
+ print "\t\tgo_slist_free_custom ($var, g_free);\n";
+ print "\t\t$var =\n";
+ print "\t\t\tgo_conf_load_str_list (node, key);\n";
+ } else {
+ print "\t\t/* Unhandled type $type */\n";
+ }
+
+ print "\t\tbreak;\n";
+}
+print "\tdefault:\n";
+print "\t\tg_assert_not_reached ();\n";
+print "\t}\n";
+print "\n";
+print "\tkey_loaded[i] = TRUE;\n";
+print "};\n\n";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]