/[svn]/gigedit/trunk/src/gigedit/global.h
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/global.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3123 by schoenebeck, Tue Apr 25 20:45:54 2017 UTC revision 3176 by schoenebeck, Thu May 11 11:36:33 2017 UTC
# Line 24  Line 24 
24  # include <config.h>  # include <config.h>
25  #endif  #endif
26    
27    #include <cstring>
28    
29    #include <glibmmconfig.h>
30    // threads.h must be included first to be able to build with
31    // G_DISABLE_DEPRECATED
32    #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \
33        (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2
34    #include <glibmm/threads.h>
35    #endif
36    
37  #if !defined(WIN32)  #if !defined(WIN32)
38  # include <unistd.h>  # include <unistd.h>
39  # include <errno.h>  # include <errno.h>
# Line 34  Line 44 
44    
45  #ifdef LIBGIG_HEADER_FILE  #ifdef LIBGIG_HEADER_FILE
46  # include LIBGIG_HEADER_FILE(gig.h)  # include LIBGIG_HEADER_FILE(gig.h)
47    # include LIBGIG_HEADER_FILE(Serialization.h)
48  #else  #else
49  # include <gig.h>  # include <gig.h>
50    # include <Serialization.h>
51  #endif  #endif
52    
53  //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?  //FIXME: for some reason AC GETTEXT check fails on the Mac cross compiler?
# Line 54  Line 66 
66    
67  #define UNICODE_RIGHT_ARROW     Glib::ustring(1, gunichar(0x2192))  #define UNICODE_RIGHT_ARROW     Glib::ustring(1, gunichar(0x2192))
68  #define UNICODE_LEFT_ARROW      Glib::ustring(1, gunichar(0x2190))  #define UNICODE_LEFT_ARROW      Glib::ustring(1, gunichar(0x2190))
69    #define UNICODE_SHIFT_KEY_SYMBOL    Glib::ustring("\xe2\x87\xa7")
70    #if defined(__APPLE__)
71    # define UNICODE_ALT_KEY_SYMBOL     Glib::ustring("\xe2\x8c\xa5")
72    #else
73    # define UNICODE_ALT_KEY_SYMBOL     Glib::ustring("Alt")
74    #endif
75    #define UNICODE_ERASE_KEY_SYMBOL    Glib::ustring("\xe2\x8c\xab")
76    #define UNICODE_CTRL_KEY_SYMBOL     Glib::ustring("Ctrl")
77    #define UNICODE_CMD_KEY_SYMBOL      Glib::ustring(1, gunichar(0x2318))
78    #if defined(__APPLE__)
79    # define UNICODE_PRIMARY_KEY_SYMBOL     UNICODE_CMD_KEY_SYMBOL
80    #else
81    # define UNICODE_PRIMARY_KEY_SYMBOL     UNICODE_CTRL_KEY_SYMBOL
82    #endif
83    
84  // taken from gdk/gdkkeysyms.h  // taken from gdk/gdkkeysyms.h
85  // (define on demand, to avoid unnecessary dev lib package build dependency)  // (define on demand, to avoid unnecessary dev lib package build dependency)
# Line 76  Line 102 
102  # define GDK_KEY_Down 0xff54  # define GDK_KEY_Down 0xff54
103  #endif  #endif
104    
105    #include <glibmm/convert.h>
106    
107    #define GIG_STR_ENCODING "CP1252"
108    
109    static inline
110    Glib::ustring gig_to_utf8(const gig::String& gig_string) {
111        return Glib::convert_with_fallback(gig_string, "UTF-8", GIG_STR_ENCODING, "?");
112    }
113    
114    static inline
115    gig::String gig_from_utf8(const Glib::ustring& utf8_string) {
116        return Glib::convert_with_fallback(utf8_string, GIG_STR_ENCODING, "UTF-8", "?");
117    }
118    
119  template<class T> inline std::string ToString(T o) {  template<class T> inline std::string ToString(T o) {
120      std::stringstream ss;      std::stringstream ss;
121      ss << o;      ss << o;
122      return ss.str();      return ss.str();
123  }  }
124    
125    inline static bool endsWith(const std::string& haystack, const std::string& needle, bool caseSensitive) {
126        if (haystack.size() < needle.size()) return false;
127        const std::string sub = haystack.substr(haystack.size() - needle.size(), needle.size());
128        return (caseSensitive) ? (sub == needle) : (!strcasecmp(sub.c_str(), needle.c_str()));
129    }
130    
131  inline int getDimensionIndex(gig::dimension_t type, gig::Region* rgn) {  inline int getDimensionIndex(gig::dimension_t type, gig::Region* rgn) {
132      for (uint i = 0; i < rgn->Dimensions; ++i)      for (uint i = 0; i < rgn->Dimensions; ++i)
133          if (rgn->pDimensionDefinitions[i].dimension == type)          if (rgn->pDimensionDefinitions[i].dimension == type)

Legend:
Removed from v.3123  
changed lines
  Added in v.3176

  ViewVC Help
Powered by ViewVC