You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

141 lines
3.6 KiB

  1. /* $Id$ */
  2. /*-
  3. * Copyright (c) 2003-2004 Benedikt Meurer <benny@xfce.org>
  4. * All rights reserved.
  5. *
  6. * This program 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, or (at your option)
  9. * any later version.
  10. *
  11. * This program 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 this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. * MA 02110-1301 USA.
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <libxfsm/xfsm-splash-rc.h>
  25. #define PROP_FROM_KEY(varname, key) \
  26. gchar varname[4096]; \
  27. g_strlcpy(varname, "/", sizeof(varname)); \
  28. g_strlcat(varname, key, sizeof(varname))
  29. struct _XfsmSplashRc
  30. {
  31. XfconfChannel *channel;
  32. };
  33. XfsmSplashRc*
  34. xfsm_splash_rc_new (XfconfChannel *channel)
  35. {
  36. XfsmSplashRc *splash_rc;
  37. splash_rc = g_new (XfsmSplashRc, 1);
  38. splash_rc->channel = g_object_ref (channel);
  39. return splash_rc;
  40. }
  41. gchar*
  42. xfsm_splash_rc_read_entry (XfsmSplashRc *splash_rc,
  43. const gchar *key,
  44. const gchar *fallback)
  45. {
  46. PROP_FROM_KEY(prop, key);
  47. return xfconf_channel_get_string (splash_rc->channel, prop, fallback);
  48. }
  49. gint
  50. xfsm_splash_rc_read_int_entry (XfsmSplashRc *splash_rc,
  51. const gchar *key,
  52. gint fallback)
  53. {
  54. PROP_FROM_KEY(prop, key);
  55. return xfconf_channel_get_int (splash_rc->channel, prop, fallback);
  56. }
  57. gboolean
  58. xfsm_splash_rc_read_bool_entry (XfsmSplashRc *splash_rc,
  59. const gchar *key,
  60. gboolean fallback)
  61. {
  62. PROP_FROM_KEY(prop, key);
  63. return xfconf_channel_get_bool (splash_rc->channel, prop, fallback);
  64. }
  65. gchar**
  66. xfsm_splash_rc_read_list_entry (XfsmSplashRc *splash_rc,
  67. const gchar *key,
  68. const gchar *delimiter)
  69. {
  70. PROP_FROM_KEY(prop, key);
  71. return xfconf_channel_get_string_list (splash_rc->channel, prop);
  72. }
  73. void
  74. xfsm_splash_rc_write_entry (XfsmSplashRc *splash_rc,
  75. const gchar *key,
  76. const gchar *value)
  77. {
  78. PROP_FROM_KEY(prop, key);
  79. xfconf_channel_set_string (splash_rc->channel, prop, value);
  80. }
  81. void
  82. xfsm_splash_rc_write_int_entry (XfsmSplashRc *splash_rc,
  83. const gchar *key,
  84. gint value)
  85. {
  86. PROP_FROM_KEY(prop, key);
  87. xfconf_channel_set_int (splash_rc->channel, prop, value);
  88. }
  89. void
  90. xfsm_splash_rc_write_bool_entry (XfsmSplashRc *splash_rc,
  91. const gchar *key,
  92. gboolean value)
  93. {
  94. PROP_FROM_KEY(prop, key);
  95. xfconf_channel_set_bool (splash_rc->channel, prop, value);
  96. }
  97. void
  98. xfsm_splash_rc_write_list_entry (XfsmSplashRc *splash_rc,
  99. const gchar *key,
  100. gchar **value,
  101. const gchar *delimiter)
  102. {
  103. PROP_FROM_KEY(prop, key);
  104. xfconf_channel_set_string_list (splash_rc->channel, prop, (gchar const **)value);
  105. }
  106. void
  107. xfsm_splash_rc_free (XfsmSplashRc *splash_rc)
  108. {
  109. g_object_unref (splash_rc->channel);
  110. g_free (splash_rc);
  111. }