1 /*
2  * Copyright (C) 2002 2003 2008 2010 2012, Magnus Hjorth
3  *
4  * This file is part of mhWaveEdit.
5  *
6  * mhWaveEdit is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * mhWaveEdit is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with mhWaveEdit; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 
22 /* This module handles the runtime configuration of the program. */
23 
24 #ifndef INIFILE_H_INCLUDED
25 #define INIFILE_H_INCLUDED
26 
27 #include <gtk/gtk.h>
28 
29 /* Some keys and default values that are used in different places of the
30  * program */
31 
32 #define INI_SETTING_SOUNDDRIVER "soundDriver"
33 #define INI_SETTING_REALMAX "diskEditingThreshold"
34 #define INI_SETTING_REALMAX_DEFAULT (1024*128)
35 #define INI_SETTING_SOUNDBUFSIZE "soundBufferSize"
36 #define INI_SETTING_SOUNDBUFSIZE_DEFAULT 65536
37 #define INI_SETTING_TIMESCALE "showTimeScale"
38 #define INI_SETTING_TIMESCALE_DEFAULT TRUE
39 #define INI_SETTING_VZOOM "showVerticalZoom"
40 #define INI_SETTING_VZOOM_DEFAULT TRUE
41 #define INI_SETTING_HZOOM "showHorizontalZoom"
42 #define INI_SETTING_HZOOM_DEFAULT TRUE
43 #define INI_SETTING_SPEED "showSpeed"
44 #define INI_SETTING_SPEED_DEFAULT inifile_get_gboolean("varispeed",TRUE)
45 #define INI_SETTING_SLABELS "showSliderLabels"
46 #define INI_SETTING_SLABELS_DEFAULT FALSE
47 #define INI_SETTING_BUFPOS "showBufpos"
48 #define INI_SETTING_BUFPOS_DEFAULT FALSE
49 #define INI_SETTING_MIXER "mixerUtility"
50 #define INI_SETTING_MIXER_DEFAULT DEFAULT_MIXERAPP
51 #define INI_SETTING_VIEW_QUALITY "viewQuality"
52 #define INI_SETTING_VIEW_QUALITY_DEFAULT 128
53 #define INI_SETTING_VIEW_QUALITY_HIGH "viewQualityHigh"
54 #define INI_SETTING_VIEW_QUALITY_HIGH_DEFAULT 5000
55 #define INI_SETTING_TIME_DISPLAY "timeDisplay"
56 #define INI_SETTING_TIME_DISPLAY_SCALE "timeDisplayScale"
57 
58 /* This function must be called before any other of these functions. It will
59  * initialize the inifile system and load the settings file ~/.mhwaveedit/config
60  * if available.
61  */
62 
63 void inifile_init(void);
64 
65 
66 /* Reads a setting.
67  * setting - Name of the setting.
68  * defaultValue - Default value returned if no such setting exists.
69  * Returns: A read-only string of the setting's value or defaultValue if the
70  *          setting doesn't exist.
71  */
72 
73 gchar *inifile_get(gchar *setting, gchar *defaultValue);
74 
75 
76 /* Same as inifile_get excepts requires that the value is a guint32 value.
77  * Returns: The value converted into a guint32 or defaultValue if setting
78  * doesn't exist or is not a valid number.
79  */
80 
81 guint32 inifile_get_guint32(gchar *setting, guint32 defaultValue);
82 gint32 inifile_get_gint32(gchar *setting, gint32 defaultValue);
83 
84 /* Same as inifile_get except requires that the value is a boolean value.
85  * 'y','yes','1','true','enabled','on' are interpreted as TRUE.
86  * 'n','no','0','false','disabled','off' are interpreted as FALSE.
87  * Returns: The value converted into a boolean or defaultValue if setting
88  * doesn't exist or is not a valid boolean.
89  */
90 
91 gboolean inifile_get_gboolean(gchar *setting, gboolean defaultValue);
92 
93 /* Same as inifile_get except requires that the value is a floating-point
94  * number.
95  */
96 
97 gfloat inifile_get_gfloat(gchar *setting, gfloat defaultValue);
98 
99 /* Changes a setting.
100  * setting - Name of the setting.
101  * value - The new value.
102  * Returns: TRUE if the setting was modified, FALSE if it already had that
103  *          value.
104  */
105 
106 gboolean inifile_set(gchar *setting, gchar *value);
107 gboolean inifile_set_guint32(gchar *setting, guint32 value);
108 gboolean inifile_set_gint32(gchar *setting, gint32 value);
109 gboolean inifile_set_gboolean(gchar *setting, gboolean value);
110 gboolean inifile_set_gfloat(gchar *setting, gfloat value);
111 
112 
113 /* Save the settings into the config file. */
114 void inifile_save(void);
115 
116 /* Free all resources and save the settings if they were changed. */
117 void inifile_quit(void);
118 
119 #endif
120