dev.stuconnolly.com / svn / safaritabs

  1. /*
  2.  *  $Id: STUtilities.m 198 2010-01-06 23:05:30Z stuart $
  3.  *
  4.  *  SafariTabs
  5.  *  http://stuconnolly.com/projects/safaritabs/
  6.  *
  7.  *  Copyright (c) 2010 Stuart Connolly. All rights reserved.
  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 3 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, see <http://www.gnu.org/licenses/>.
  21.  */
  22.  
  23. #import "STUtilities.h"
  24. #import "STConstants.h"  
  25.  
  26. /*!
  27.  * Returns SafariTabs' bundle version.
  28.  *
  29.  * @return SafariTabs' bundle version as an integer.
  30.  */
  31. NSString *STBundleVersion(void)
  32. {
  33.     return [[STPluginBundle() infoDictionary] objectForKey:@"CFBundleVersion"];
  34. }
  35.  
  36. /*!
  37.  * Returns SafariTabs' version string.
  38.  *
  39.  * @return SafariTabs' version string
  40.  */
  41. NSString *STPluginVersion(void)
  42. {
  43.     return [[STPluginBundle() infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  44. }
  45.  
  46. /*!
  47.  * Returns Safari's version string.
  48.  *
  49.  * @return Safari's version string
  50.  */
  51. NSString *STSafariVersion(void)
  52. {
  53.     return [[STSafariBundle() infoDictionary] objectForKey:@"CFBundleShortVersionString"];
  54. }
  55.  
  56. /*!
  57.  * Returns Safari's bundle version.
  58.  *
  59.  * @return Safari's bundle version as an integer.
  60.  */
  61. NSString *STSafariBundleVersion(void)
  62. {
  63.     return [[STSafariBundle() infoDictionary] objectForKey:@"CFBundleVersion"];
  64. }
  65.  
  66. /*!
  67.  * Returns a pointer to SafariTabs' bundle.
  68.  *
  69.  * @return SafariTabs' bundle
  70.  */
  71. NSBundle *STPluginBundle(void)
  72. {
  73.     return [NSBundle bundleWithIdentifier:STBundleIdentifier];
  74. }
  75.  
  76. /*!
  77.  * Returns a pointer to Safari's bundle.
  78.  *
  79.  * @return Safari's bundle
  80.  */
  81. NSBundle *STSafariBundle(void)
  82. {
  83.     return [NSBundle mainBundle];
  84. }
  85.  
  86. /*!
  87.  * Returns the localized version of the string associated with the supplied key.
  88.  *
  89.  * @param key The key associated with the required string
  90.  *
  91.  * @return The localized version of the string associated with the supplied key
  92.  */
  93. NSString *STLocalizedString(NSString *key)
  94. {
  95.     return NSLocalizedStringFromTableInBundle(key, @"Localizable", STPluginBundle(), @"");
  96. }
  97.