mcconfig.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef MC__CONFIG_H
  2. #define MC__CONFIG_H
  3. #include "lib/vfs/vfs.h" /* vfs_path_t */
  4. /*** typedefs(not structures) and defined constants **********************************************/
  5. #define CONFIG_APP_SECTION "Midnight-Commander"
  6. #define CONFIG_PANELS_SECTION "Panels"
  7. #define CONFIG_LAYOUT_SECTION "Layout"
  8. #define CONFIG_MISC_SECTION "Misc"
  9. #define CONFIG_EXT_EDITOR_VIEWER_SECTION "External editor or viewer parameters"
  10. /*** enums ***************************************************************************************/
  11. /*** structures declarations (and typedefs of structures)*****************************************/
  12. typedef struct mc_config_t
  13. {
  14. GKeyFile *handle;
  15. gchar *ini_path;
  16. } mc_config_t;
  17. /*** global variables defined in .c file *********************************************************/
  18. extern int num_history_items_recorded;
  19. /*** declarations of public functions ************************************************************/
  20. /* mcconfig/common.c: */
  21. mc_config_t *mc_config_init (const gchar * ini_path, gboolean read_only);
  22. void mc_config_deinit (mc_config_t * mc_config);
  23. gboolean mc_config_has_param (const mc_config_t * mc_config, const char *group,
  24. const gchar * param);
  25. gboolean mc_config_has_group (mc_config_t * mc_config, const char *group);
  26. gboolean mc_config_del_key (mc_config_t * mc_config, const char *group, const gchar * param);
  27. gboolean mc_config_del_group (mc_config_t * mc_config, const char *group);
  28. gboolean mc_config_read_file (mc_config_t * mc_config, const gchar * ini_path, gboolean read_only,
  29. gboolean remove_empty);
  30. gboolean mc_config_save_file (mc_config_t * config, GError ** mcerror);
  31. gboolean mc_config_save_to_file (mc_config_t * mc_config, const gchar * ini_path,
  32. GError ** mcerror);
  33. /* mcconfig/get.c: */
  34. gchar **mc_config_get_groups (const mc_config_t * mc_config, gsize * len);
  35. gchar **mc_config_get_keys (const mc_config_t * mc_config, const gchar * group, gsize * len);
  36. gchar *mc_config_get_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
  37. const gchar * def);
  38. MC_MOCKABLE gchar *mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group,
  39. const gchar * param, const gchar * def);
  40. gboolean mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
  41. gboolean def);
  42. int mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def);
  43. gchar **mc_config_get_string_list (mc_config_t * mc_config, const gchar * group,
  44. const gchar * param, gsize * length);
  45. gboolean *mc_config_get_bool_list (mc_config_t * mc_config, const gchar * group,
  46. const gchar * param, gsize * length);
  47. int *mc_config_get_int_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
  48. gsize * length);
  49. /* mcconfig/set.c: */
  50. void mc_config_set_string_raw (mc_config_t * mc_config, const gchar * group, const gchar * param,
  51. const gchar * value);
  52. void mc_config_set_string_raw_value (mc_config_t * mc_config, const gchar * group,
  53. const gchar * param, const gchar * value);
  54. void mc_config_set_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
  55. const gchar * value);
  56. void mc_config_set_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
  57. gboolean value);
  58. void mc_config_set_int (mc_config_t * mc_config, const gchar * group, const gchar * param,
  59. int value);
  60. void
  61. mc_config_set_string_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
  62. const gchar * const value[], gsize length);
  63. void mc_config_set_bool_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
  64. gboolean value[], gsize length);
  65. void mc_config_set_int_list (mc_config_t * mc_config, const gchar * group, const gchar * param,
  66. int value[], gsize length);
  67. /* mcconfig/paths.c: */
  68. void mc_config_init_config_paths (GError ** error);
  69. void mc_config_deinit_config_paths (void);
  70. const char *mc_config_get_data_path (void);
  71. const char *mc_config_get_cache_path (void);
  72. MC_MOCKABLE const char *mc_config_get_home_dir (void);
  73. const char *mc_config_get_path (void);
  74. char *mc_config_get_full_path (const char *config_name);
  75. vfs_path_t *mc_config_get_full_vpath (const char *config_name);
  76. /* mcconfig/history.h */
  77. /* read history to the mc_config, but don't save config to file */
  78. GList *mc_config_history_get (const char *name);
  79. /* read recent item from the history */
  80. char *mc_config_history_get_recent_item (const char *name);
  81. /* load history from the mc_config */
  82. GList *mc_config_history_load (mc_config_t * cfg, const char *name);
  83. /* save history to the mc_config, but don't save config to file */
  84. void mc_config_history_save (mc_config_t * cfg, const char *name, GList * h);
  85. /*** inline functions ****************************************************************************/
  86. #endif /* MC__CONFIG_H */