1 /* 2 | Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users sourceforge net> 3 | Copyright (C) 2006 James Liggett <jrliggett at cox.net> 4 | Part of the gtkpod project. 5 | 6 | URL: http://www.gtkpod.org/ 7 | URL: http://gtkpod.sourceforge.net/ 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | 23 | iTunes and iPod are trademarks of Apple 24 | 25 | This product is not supported/written/published by Apple! 26 | 27 | $Id$ 28 */ 29 30 #ifndef __PREFS_H__ 31 #define __PREFS_H__ 32 33 #ifdef HAVE_CONFIG_H 34 # include <config.h> 35 #endif 36 37 #include <gtk/gtk.h> 38 #include "sort_window.h" 39 #include "display.h" 40 41 42 43 /* Not sure where to put these (maybe prefkeys.h?): prefs keys used */ 44 /* repository.c */ 45 extern const gchar *KEY_CONCAL_AUTOSYNC; 46 extern const gchar *KEY_SYNC_DELETE_TRACKS; 47 extern const gchar *KEY_SYNC_CONFIRM_DIRS; 48 extern const gchar *KEY_SYNC_CONFIRM_DELETE; 49 extern const gchar *KEY_SYNC_SHOW_SUMMARY; 50 extern const gchar *KEY_MOUNTPOINT; 51 extern const gchar *KEY_IPOD_MODEL; 52 extern const gchar *KEY_FILENAME; 53 extern const gchar *KEY_PATH_SYNC_CONTACTS; 54 extern const gchar *KEY_PATH_SYNC_CALENDAR; 55 extern const gchar *KEY_PATH_SYNC_NOTES; 56 extern const gchar *KEY_SYNCMODE; 57 extern const gchar *KEY_MANUAL_SYNCDIR; 58 extern const gchar *KEY_DISPLAY_COVERART; 59 60 /* New prefs backend. Will replace the stuff above */ 61 enum conv_target_format 62 { 63 TARGET_FORMAT_MP3 = 0, 64 TARGET_FORMAT_AAC, 65 }; 66 67 /* 68 * Wrapper data types for temp preferences 69 */ 70 71 /* A wrapper around a GTree for regular temporary preferences */ 72 typedef struct 73 { 74 GTree *tree; 75 } TempPrefs; 76 77 /* A wrapper around a GTree for variable-length list */ 78 typedef struct 79 { 80 GTree *tree; 81 } TempLists; 82 83 /* Preferences setup and cleanup */ 84 void prefs_init (int argc, char *argv[]); 85 void prefs_save (void); 86 void prefs_shutdown (void); 87 88 /* 89 * Functions that are used to manipulate preferences. 90 * The preferences table shouldn't be modified directly. 91 */ 92 93 /* Functions that set preference values */ 94 95 void prefs_set_string(const gchar *key, const gchar *value); 96 void prefs_set_int(const gchar *key, const gint value); 97 void prefs_set_int64(const gchar *key, const gint64 value); 98 void prefs_set_double(const gchar *key, gdouble value); 99 100 /* The index parameter is used for numbered preference keys. 101 * (i.e. pref0, pref1, etc) */ 102 void prefs_set_string_index(const gchar *key, const guint index, 103 const gchar *value); 104 void prefs_set_int_index(const gchar *key, const guint index, 105 const gint value); 106 void prefs_set_int64_index(const gchar *key, guint index, 107 const gint64 value); 108 void prefs_set_double_index(const gchar *key, guint index, 109 gdouble value); 110 111 /* Functions that get preference values */ 112 gchar *prefs_get_string(const gchar *key); 113 gboolean prefs_get_string_value(const gchar *key, gchar **value); 114 gint prefs_get_int(const gchar *key); 115 gboolean prefs_get_int_value(const gchar *key, gint *value); 116 gint64 prefs_get_int64(const gchar *key); 117 gboolean prefs_get_int64_value(const gchar *key, gint64 *value); 118 gdouble prefs_get_double(const gchar *key); 119 gboolean prefs_get_double_value(const gchar *key, gdouble *value); 120 121 /* Numbered prefs functions */ 122 gchar *prefs_get_string_index(const gchar *key, const guint index); 123 gboolean prefs_get_string_value_index(const gchar *key, 124 const guint index, gchar **value); 125 gint prefs_get_int_index(const gchar *key, const guint index); 126 gboolean prefs_get_int_value_index(const gchar *key, const guint index, 127 gint *value); 128 gint64 prefs_get_int64_index(const gchar *key, const guint index); 129 gboolean prefs_get_int64_value_index(const gchar *key, 130 const guint index, gint64 *value); 131 gdouble prefs_get_double_index(const gchar *key, 132 guint index); 133 gboolean prefs_get_double_value_index(const gchar *key, guint index, 134 gdouble *value); 135 /* Special functions */ 136 TempPrefs *prefs_create_subset (const gchar *subkey); 137 void prefs_flush_subkey (const gchar *subkey); 138 void prefs_rename_subkey (const gchar *subkey_old, const gchar *subkey_new); 139 void temp_prefs_rename_subkey (TempPrefs *temp_prefs, 140 const gchar *subkey_old, 141 const gchar *subkey_new); 142 gboolean temp_prefs_subkey_exists (TempPrefs *temp_prefs, 143 const gchar *subkey); 144 145 /* 146 * Temp prefs functions 147 */ 148 TempPrefs *temp_prefs_create (void); 149 void temp_prefs_copy_prefs (TempPrefs *temp_prefs); 150 TempPrefs *temp_prefs_load (const gchar *filename, GError **error); 151 gboolean temp_prefs_save (TempPrefs *temp_prefs, 152 const gchar *filename, 153 GError **error); 154 TempPrefs *temp_prefs_create_subset (TempPrefs *temp_prefs, 155 const gchar *subkey); 156 void temp_prefs_destroy (TempPrefs *temp_prefs); 157 void temp_prefs_apply (TempPrefs *temp_prefs); 158 void temp_prefs_flush(TempPrefs *temp_prefs); 159 gint temp_prefs_size (TempPrefs *temp_prefs); 160 161 /* 162 * Functions that add various types of info to the temp prefs tree. 163 */ 164 void temp_prefs_remove_key (TempPrefs *temp_prefs, const gchar *key); 165 void temp_prefs_set_string(TempPrefs *temp_prefs, const gchar *key, 166 const gchar *value); 167 void temp_prefs_set_int(TempPrefs *temp_prefs, const gchar *key, 168 const gint value); 169 void temp_prefs_set_int64(TempPrefs *temp_prefs, const gchar *key, 170 const gint64 value); 171 void temp_prefs_set_double(TempPrefs *temp_prefs, const gchar *key, 172 gdouble value); 173 174 /* 175 * Functions that retrieve various types of info from the temp prefs tree. 176 */ 177 gchar *temp_prefs_get_string(TempPrefs *temp_prefs, const gchar *key); 178 gboolean temp_prefs_get_string_value(TempPrefs *temp_prefs, 179 const gchar *key, gchar **value); 180 gint temp_prefs_get_int(TempPrefs *temp_prefs, const gchar *key); 181 gboolean temp_prefs_get_int_value(TempPrefs *temp_prefs, 182 const gchar *key, gint *value); 183 gdouble temp_prefs_get_double(TempPrefs *temp_prefs, const gchar *key); 184 gboolean temp_prefs_get_double_value(TempPrefs *temp_prefs, const gchar *key, 185 gdouble *value); 186 187 /* Numbered preferences functions */ 188 void temp_prefs_set_string_index(TempPrefs *temp_prefs, const gchar *key, 189 const guint index, const gchar *value); 190 void temp_prefs_set_int_index(TempPrefs *temp_prefs, const gchar *key, 191 const guint index, const gint value); 192 void temp_prefs_set_int64_index(TempPrefs *temp_prefs, const gchar *key, 193 const guint index, const gint64 value); 194 void temp_prefs_set_double_index(TempPrefs *temp_prefs, const gchar *key, 195 guint index, gdouble value); 196 197 198 /* 199 * Functions for variable-length lists 200 */ 201 202 TempLists *temp_lists_create (void); 203 void temp_lists_destroy(TempLists *temp_lists); 204 void temp_list_add(TempLists *temp_lists, const gchar *key, GList *list); 205 void temp_lists_apply(TempLists *temp_lists); 206 void prefs_apply_list(gchar *key, GList *list); 207 GList *prefs_get_list(const gchar *key); 208 void prefs_free_list(GList *list); 209 GList *get_list_from_buffer(GtkTextBuffer *buffer); 210 211 gchar *prefs_get_cfgdir (void); 212 #endif 213