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.
 
 
 
 
 

145 lines
4.7 KiB

  1. /*
  2. * Copyright (C) 2009-2010 Nick Schermer <nick@xfce.org>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. #include <config.h>
  20. #endif
  21. #include <libxfce4panel/libxfce4panel-config.h>
  22. #include <libxfce4panel/libxfce4panel-alias.h>
  23. /**
  24. * SECTION: config
  25. * @title: Version Information
  26. * @short_description: Information about the panel version in use.
  27. * @include: libxfce4panel/libxfce4panel.h
  28. *
  29. * The panel library provides version information, which could be used
  30. * by plugins to handle new API.
  31. **/
  32. /**
  33. * libxfce4panel_major_version:
  34. *
  35. * The major version number of the libxfce4panel library (e.g. in
  36. * version 4.8.0 this is 4).
  37. *
  38. * This variable is in the library, so represents the
  39. * libxfce4panel library you have linked against. Contrast with the
  40. * #LIBXFCE4PANEL_MAJOR_VERSION macro, which represents the major
  41. * version of the libxfce4panel headers you have included.
  42. *
  43. * Since: 4.8
  44. **/
  45. const guint libxfce4panel_major_version = LIBXFCE4PANEL_MAJOR_VERSION;
  46. /**
  47. * libxfce4panel_minor_version:
  48. *
  49. * The minor version number of the libxfce4panel library (e.g. in
  50. * version 4.8.0 this is 8).
  51. *
  52. * This variable is in the library, so represents the
  53. * libxfce4panel library you have linked against. Contrast with the
  54. * #LIBXFCE4PANEL_MINOR_VERSION macro, which represents the minor
  55. * version of the libxfce4panel headers you have included.
  56. *
  57. * Since: 4.8
  58. **/
  59. const guint libxfce4panel_minor_version = LIBXFCE4PANEL_MINOR_VERSION;
  60. /**
  61. * libxfce4panel_micro_version:
  62. *
  63. * The micro version number of the libxfce4panel library (e.g. in
  64. * version 4.8.0 this is 0).
  65. *
  66. * This variable is in the library, so represents the
  67. * libxfce4panel library you have linked against. Contrast with the
  68. * #LIBXFCE4PANEL_MICRO_VERSION macro, which represents the micro
  69. * version of the libxfce4panel headers you have included.
  70. *
  71. * Since: 4.8
  72. **/
  73. const guint libxfce4panel_micro_version = LIBXFCE4PANEL_MICRO_VERSION;
  74. /**
  75. * libxfce4panel_check_version:
  76. * @required_major: the required major version.
  77. * @required_minor: the required minor version.
  78. * @required_micro: the required micro version.
  79. *
  80. * Checks that the libxfce4panel library in use is compatible with
  81. * the given version. Generally you would pass in the constants
  82. * #LIBXFCE4PANEL_MAJOR_VERSION, #LIBXFCE4PANEL_MINOR_VERSION and
  83. * #LIBXFCE4PANEL_MICRO_VERSION as the three arguments to this
  84. * function; that produces a check that the library in use is
  85. * compatible with the version of libxfce4panel the extension was
  86. * compiled against.
  87. *
  88. * <example>
  89. * <title>Checking the runtime version of the Libxfce4panel library</title>
  90. * <programlisting>
  91. * const gchar *mismatch;
  92. * mismatch = libxfce4panel_check_version (LIBXFCE4PANEL_MAJOR_VERSION,
  93. * LIBXFCE4PANEL_MINOR_VERSION,
  94. * LIBXFCE4PANEL_MICRO_VERSION);
  95. * if (G_UNLIKELY (mismatch != NULL))
  96. * g_error ("Version mismatch: %<!---->s", mismatch);
  97. * </programlisting>
  98. * </example>
  99. *
  100. * Returns: %NULL if the library is compatible with the given version,
  101. * or a string describing the version mismatch. The returned
  102. * string is owned by the library and must not be freed or
  103. * modified by the caller.
  104. *
  105. * Since: 4.8
  106. **/
  107. const gchar *
  108. libxfce4panel_check_version (guint required_major,
  109. guint required_minor,
  110. guint required_micro)
  111. {
  112. if (required_major > LIBXFCE4PANEL_MAJOR_VERSION)
  113. return "Xfce Panel version too old (major mismatch)";
  114. if (required_major < LIBXFCE4PANEL_MAJOR_VERSION)
  115. return "Xfce Panel version too new (major mismatch)";
  116. if (required_minor > LIBXFCE4PANEL_MINOR_VERSION)
  117. return "Xfce Panel version too old (minor mismatch)";
  118. if (required_minor == LIBXFCE4PANEL_MINOR_VERSION
  119. && required_micro > LIBXFCE4PANEL_MICRO_VERSION)
  120. return "Xfce Panel version too old (micro mismatch)";
  121. return NULL;
  122. }
  123. #define __LIBXFCE4PANEL_CONFIG_C__
  124. #include <libxfce4panel/libxfce4panel-aliasdef.c>