File indexing completed on 2024-04-28 05:32:11

0001 /*
0002     this file is part of the oxygen gtk engine
0003     SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0004 
0005     based on the Null Theme Engine for Gtk+.
0006     SPDX-FileCopyrightText: 2008 Robert Staudinger <robert.staudinger@gmail.com>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #include "oxygengtktypenames.h"
0012 
0013 namespace Oxygen
0014 {
0015 
0016     //_______________________________________________
0017     typedef Gtk::TypeNames::Entry<GtkStateType> StateMap;
0018     static const StateMap stateMap[] =
0019     {
0020 
0021         { GTK_STATE_NORMAL, "normal" },
0022         { GTK_STATE_ACTIVE, "active" },
0023         { GTK_STATE_PRELIGHT, "prelight" },
0024         { GTK_STATE_SELECTED, "selected" },
0025         { GTK_STATE_INSENSITIVE, "insensitive" }
0026 
0027     };
0028 
0029     //___________________________________________________________
0030     GtkStateType Gtk::TypeNames::matchState( const char*  cssState )
0031     { return Gtk::TypeNames::Finder<GtkStateType>( stateMap, 5 ).findGtk( cssState, GTK_STATE_NORMAL ); }
0032 
0033     //___________________________________________________________
0034     const char*  Gtk::TypeNames::state( GtkStateType gtkState )
0035     { return Gtk::TypeNames::Finder<GtkStateType>( stateMap, 5 ).findCss( gtkState ); }
0036 
0037     //___________________________________________________________
0038     // Map between shadow types in gtk and css format.
0039     typedef Gtk::TypeNames::Entry<GtkShadowType> ShadowMap;
0040     static const ShadowMap shadowMap[] =
0041     {
0042         { GTK_SHADOW_NONE, "none" },
0043         { GTK_SHADOW_IN, "in" },
0044         { GTK_SHADOW_OUT, "out" },
0045         { GTK_SHADOW_ETCHED_IN, "etched-in" },
0046         { GTK_SHADOW_ETCHED_OUT, "etched-out" }
0047     };
0048 
0049     //___________________________________________________________
0050     GtkShadowType Gtk::TypeNames::matchShadow( const char*  cssShadow )
0051     { return Gtk::TypeNames::Finder<GtkShadowType>( shadowMap, 5 ).findGtk( cssShadow, GTK_SHADOW_NONE ); }
0052 
0053     //___________________________________________________________
0054     const char* Gtk::TypeNames::shadow( GtkShadowType gtkShadow )
0055     { return Gtk::TypeNames::Finder<GtkShadowType>( shadowMap, 5 ).findCss( gtkShadow ); }
0056 
0057     //___________________________________________________________
0058     typedef Gtk::TypeNames::Entry<GtkArrowType> ArrowMap;
0059     static const ArrowMap arrowMap[] =
0060     {
0061         { GTK_ARROW_UP, "up" },
0062         { GTK_ARROW_DOWN, "down" },
0063         { GTK_ARROW_LEFT, "left" },
0064         { GTK_ARROW_RIGHT, "right" },
0065         { GTK_ARROW_NONE, "none" }
0066     };
0067 
0068     //___________________________________________________________
0069     GtkArrowType Gtk::TypeNames::matchArrow( const char*  cssArrow )
0070     { return Gtk::TypeNames::Finder<GtkArrowType>( arrowMap, 5 ).findGtk( cssArrow, GTK_ARROW_NONE ); }
0071 
0072     //___________________________________________________________
0073     const char* Gtk::TypeNames::arrow( GtkArrowType gtkArrow )
0074     { return Gtk::TypeNames::Finder<GtkArrowType>( arrowMap, 5 ).findCss( gtkArrow ); }
0075 
0076     //___________________________________________________________
0077     typedef Gtk::TypeNames::Entry<GtkPositionType> PositionMap;
0078     static const PositionMap positionMap[] =
0079     {
0080         { GTK_POS_LEFT, "left" },
0081         { GTK_POS_RIGHT, "right" },
0082         { GTK_POS_TOP, "top" },
0083         { GTK_POS_BOTTOM, "bottom" },
0084     };
0085 
0086     //___________________________________________________________
0087     GtkPositionType Gtk::TypeNames::matchPosition( const char* cssPosition )
0088     { return Gtk::TypeNames::Finder<GtkPositionType>( positionMap, 4 ).findGtk( cssPosition, GTK_POS_LEFT ); }
0089 
0090     //__________________________________________________________________
0091     const char* Gtk::TypeNames::position( GtkPositionType gtkPosition )
0092     { return Gtk::TypeNames::Finder<GtkPositionType>( positionMap, 4 ).findCss( gtkPosition ); }
0093 
0094     //__________________________________________________________________
0095     typedef Gtk::TypeNames::Entry<GdkWindowEdge> WindowEdgeMap;
0096     static const WindowEdgeMap windowEdgeMap[] =
0097     {
0098         { GDK_WINDOW_EDGE_NORTH, "north" },
0099         { GDK_WINDOW_EDGE_SOUTH, "south" },
0100         { GDK_WINDOW_EDGE_WEST, "west" },
0101         { GDK_WINDOW_EDGE_EAST, "east" },
0102         { GDK_WINDOW_EDGE_NORTH_WEST, "north-west" },
0103         { GDK_WINDOW_EDGE_NORTH_EAST, "north-east" },
0104         { GDK_WINDOW_EDGE_SOUTH_WEST, "south-west" },
0105         { GDK_WINDOW_EDGE_SOUTH_EAST, "south-east" },
0106     };
0107 
0108     //__________________________________________________________________
0109     GdkWindowEdge Gtk::TypeNames::matchWindowEdge( const char*  cssWindowEdge )
0110     { return Gtk::TypeNames::Finder<GdkWindowEdge>( windowEdgeMap, 8 ).findGtk( cssWindowEdge, GDK_WINDOW_EDGE_SOUTH_EAST ); }
0111 
0112     //__________________________________________________________________
0113     const char*  Gtk::TypeNames::windowEdge( GdkWindowEdge gdkWindowEdge )
0114     { return Gtk::TypeNames::Finder<GdkWindowEdge>( windowEdgeMap, 8 ).findCss( gdkWindowEdge ); }
0115 
0116     //__________________________________________________________________
0117     typedef Gtk::TypeNames::Entry<GdkWindowTypeHint> WindowTypeHintMap;
0118     static const WindowTypeHintMap windowTypeHintMap[] =
0119     {
0120         { GDK_WINDOW_TYPE_HINT_COMBO, "combobox list" },
0121         { GDK_WINDOW_TYPE_HINT_DESKTOP, "desktop" },
0122         { GDK_WINDOW_TYPE_HINT_DIALOG, "dialog" },
0123         { GDK_WINDOW_TYPE_HINT_DND, "drag-and-drop" },
0124         { GDK_WINDOW_TYPE_HINT_DOCK, "dock" },
0125         { GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU, "dropdown menu" },
0126         { GDK_WINDOW_TYPE_HINT_MENU, "menu" },
0127         { GDK_WINDOW_TYPE_HINT_NORMAL, "normal" },
0128         { GDK_WINDOW_TYPE_HINT_NOTIFICATION, "notification" },
0129         { GDK_WINDOW_TYPE_HINT_POPUP_MENU, "popup menu" },
0130         { GDK_WINDOW_TYPE_HINT_SPLASHSCREEN, "splashscreen" },
0131         { GDK_WINDOW_TYPE_HINT_TOOLBAR, "toolbar" },
0132         { GDK_WINDOW_TYPE_HINT_TOOLTIP, "tooltip" },
0133         { GDK_WINDOW_TYPE_HINT_UTILITY, "utility" }
0134     };
0135 
0136     //__________________________________________________________________
0137     GdkWindowTypeHint Gtk::TypeNames::matchWindowTypeHint( const char*  cssWindowTypeHint )
0138     { return Gtk::TypeNames::Finder<GdkWindowTypeHint>( windowTypeHintMap, 14 ).findGtk( cssWindowTypeHint, GDK_WINDOW_TYPE_HINT_NORMAL ); }
0139 
0140     //__________________________________________________________________
0141     const char*  Gtk::TypeNames::windowTypeHint( GdkWindowTypeHint gdkWindowTypeHint )
0142     { return Gtk::TypeNames::Finder<GdkWindowTypeHint>( windowTypeHintMap, 14 ).findCss( gdkWindowTypeHint ); }
0143 
0144     //__________________________________________________________________
0145     typedef Gtk::TypeNames::Entry<GtkOrientation> OrientationMap;
0146     static const OrientationMap orientationMap[] =
0147     {
0148         { GTK_ORIENTATION_HORIZONTAL, "horizontal" },
0149         { GTK_ORIENTATION_VERTICAL, "vertical" }
0150     };
0151 
0152     //__________________________________________________________________
0153     GtkOrientation Gtk::TypeNames::matchOrientation( const char*  cssOrientation )
0154     { return Gtk::TypeNames::Finder<GtkOrientation>( orientationMap, 2 ).findGtk( cssOrientation, GTK_ORIENTATION_HORIZONTAL ); }
0155 
0156     //__________________________________________________________________
0157     const char* Gtk::TypeNames::orientation( GtkOrientation gtkOrientation )
0158     { return Gtk::TypeNames::Finder<GtkOrientation>( orientationMap, 2 ).findCss( gtkOrientation ); }
0159 
0160     //__________________________________________________________________
0161     typedef Gtk::TypeNames::Entry<GtkExpanderStyle> EpanderStyleMap;
0162     static const EpanderStyleMap expanderStyleMap[] =
0163     {
0164         { GTK_EXPANDER_COLLAPSED, "collapsed" },
0165         { GTK_EXPANDER_SEMI_COLLAPSED, "semi-collapsed" },
0166         { GTK_EXPANDER_SEMI_EXPANDED, "semi-expanded" },
0167         { GTK_EXPANDER_EXPANDED, "expanded" }
0168     };
0169 
0170     //__________________________________________________________________
0171     GtkExpanderStyle Gtk::TypeNames::matchExpanderStyle( const char*  cssExpanderStyle )
0172     { return Gtk::TypeNames::Finder<GtkExpanderStyle>( expanderStyleMap, 4 ).findGtk( cssExpanderStyle, GTK_EXPANDER_COLLAPSED ); }
0173 
0174     //__________________________________________________________________
0175     const char*  Gtk::TypeNames::expanderStyle( GtkExpanderStyle gtkExpanderStyle )
0176     { return Gtk::TypeNames::Finder<GtkExpanderStyle>( expanderStyleMap, 4 ).findCss( gtkExpanderStyle ); }
0177 
0178     //__________________________________________________________________
0179     typedef Gtk::TypeNames::Entry<GtkResponseType> ResponseTypeMap;
0180     static const ResponseTypeMap responseTypeMap[] =
0181     {
0182         { GTK_RESPONSE_NONE, "none" },
0183         { GTK_RESPONSE_REJECT, "reject" },
0184         { GTK_RESPONSE_ACCEPT, "accept" },
0185         { GTK_RESPONSE_DELETE_EVENT, "delete" },
0186         { GTK_RESPONSE_OK, "ok" },
0187         { GTK_RESPONSE_CANCEL, "cancel" },
0188         { GTK_RESPONSE_CLOSE, "close" },
0189         { GTK_RESPONSE_YES, "yes" },
0190         { GTK_RESPONSE_NO, "no" },
0191         { GTK_RESPONSE_APPLY, "apply" },
0192         { GTK_RESPONSE_HELP, "help" },
0193         { (GtkResponseType)1, "id 1" }
0194     };
0195     const int responseTypeMapSize=sizeof(responseTypeMap)/sizeof(responseTypeMap[0]);
0196 
0197     //__________________________________________________________________
0198     GtkResponseType Gtk::TypeNames::matchResponse( const char*  cssResponseType )
0199     { return Gtk::TypeNames::Finder<GtkResponseType>( responseTypeMap, responseTypeMapSize ).findGtk( cssResponseType, GTK_RESPONSE_NONE ); }
0200 
0201     //__________________________________________________________________
0202     const char*  Gtk::TypeNames::response( GtkResponseType gtkResponseType )
0203     { return Gtk::TypeNames::Finder<GtkResponseType>( responseTypeMap, responseTypeMapSize ).findCss( gtkResponseType ); }
0204 
0205     //__________________________________________________________________
0206     typedef Gtk::TypeNames::Entry<GtkIconSize> IconSizeMap;
0207     static const IconSizeMap iconSizeMap[] =
0208     {
0209         { GTK_ICON_SIZE_INVALID, "invalid" },
0210         { GTK_ICON_SIZE_MENU, "menu" },
0211         { GTK_ICON_SIZE_SMALL_TOOLBAR, "small toolbar" },
0212         { GTK_ICON_SIZE_LARGE_TOOLBAR, "large toolbar" },
0213         { GTK_ICON_SIZE_BUTTON, "button" },
0214         { GTK_ICON_SIZE_DND, "drag and drop" },
0215         { GTK_ICON_SIZE_DIALOG, "dialog" }
0216      };
0217     const int iconSizeMapSize=sizeof(iconSizeMap)/sizeof(iconSizeMap[0]);
0218 
0219     //__________________________________________________________________
0220     GtkIconSize Gtk::TypeNames::matchIconSize( const char*  cssIconSize )
0221     { return Gtk::TypeNames::Finder<GtkIconSize>( iconSizeMap, iconSizeMapSize ).findGtk( cssIconSize, GTK_ICON_SIZE_INVALID ); }
0222 
0223     //__________________________________________________________________
0224     const char*  Gtk::TypeNames::iconSize( GtkIconSize gtkIconSize )
0225     { return Gtk::TypeNames::Finder<GtkIconSize>( iconSizeMap, iconSizeMapSize ).findCss( gtkIconSize ); }
0226 
0227     //__________________________________________________________________
0228     typedef Gtk::TypeNames::Entry<GFileMonitorEvent> FileMonitorEventMap;
0229     static const FileMonitorEventMap fileMonitorEventMap[] =
0230     {
0231         { G_FILE_MONITOR_EVENT_CHANGED, "changed" },
0232         { G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, "changes done" },
0233         { G_FILE_MONITOR_EVENT_DELETED, "deleted" },
0234         { G_FILE_MONITOR_EVENT_CREATED, "created" },
0235         { G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED, "attribute changed" },
0236         { G_FILE_MONITOR_EVENT_PRE_UNMOUNT, "pre_mount" },
0237         { G_FILE_MONITOR_EVENT_UNMOUNTED, "unmount" },
0238         { G_FILE_MONITOR_EVENT_MOVED, "move" }
0239     };
0240 
0241     const int fileMonitorEventMapSize=sizeof(fileMonitorEventMap)/sizeof(fileMonitorEventMap[0]);
0242 
0243     //__________________________________________________________________
0244     GFileMonitorEvent Gtk::TypeNames::matchFileMonitorEvent( const char*  monitorEvent )
0245     { return Gtk::TypeNames::Finder<GFileMonitorEvent>( fileMonitorEventMap, fileMonitorEventMapSize ).findGtk( monitorEvent, G_FILE_MONITOR_EVENT_CHANGED ); }
0246 
0247     //__________________________________________________________________
0248     const char*  Gtk::TypeNames::fileMonitorEvent( GFileMonitorEvent movitorEvent )
0249     { return Gtk::TypeNames::Finder<GFileMonitorEvent>( fileMonitorEventMap, fileMonitorEventMapSize ).findCss( movitorEvent ); }
0250 
0251 }