gnome-commander r1655 - in trunk: . src



Author: epiotr
Date: Wed Mar 19 16:30:15 2008
New Revision: 1655
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=1655&view=rev

Log:
Move key2str() and str2key() out of GnomeCmdUserActions class

Modified:
   trunk/ChangeLog
   trunk/src/gnome-cmd-user-actions.h

Modified: trunk/src/gnome-cmd-user-actions.h
==============================================================================
--- trunk/src/gnome-cmd-user-actions.h	(original)
+++ trunk/src/gnome-cmd-user-actions.h	Wed Mar 19 16:30:15 2008
@@ -56,6 +56,76 @@
     return event.keyval<=G_MAXUINT8 && g_ascii_isupper (event.keyval);
 }
 
+inline std::string key2str(guint state, guint key_val)
+{
+    std::string key_name;
+
+    if (state & GDK_SHIFT_MASK)    key_name += gdk_modifiers_names[GDK_SHIFT_MASK];
+    if (state & GDK_CONTROL_MASK)  key_name += gdk_modifiers_names[GDK_CONTROL_MASK];
+    if (state & GDK_MOD1_MASK)     key_name += gdk_modifiers_names[GDK_MOD1_MASK];
+    if (state & GDK_MOD4_MASK)     key_name += gdk_modifiers_names[GDK_MOD4_MASK];
+
+    if (ascii_isalnum (key_val))
+        key_name += g_ascii_tolower (key_val);
+    else
+        key_name += gdk_key_names[key_val];
+
+    return key_name;
+}
+
+inline std::string key2str(const GdkEventKey &event)
+{
+    return key2str(event.state, event.keyval);
+}
+
+inline GdkEventKey str2key(gchar *s, guint &state, guint &key_val)
+{
+    g_strdown (s);
+
+    gchar *key = strrchr(s, '>');       // find last '>'
+    key = key ? key+1 : s;
+
+    key_val = gdk_key_names[key];
+    state = 0;
+
+     if (key_val==GDK_VoidSymbol)
+        if (strlen(key)==1 && ascii_isalnum (*key))
+            key_val = *key;
+
+    for (const gchar *beg=s; (beg=strchr(beg, '<')); ++beg)
+    {
+        if (const gchar *end = strchr(beg, '>'))
+            if (guint modifier = gdk_modifiers_names[std::string(beg,end-beg+1)])
+            {
+                state |= modifier;
+                beg = end;
+                continue;
+            }
+
+        key_val = GDK_VoidSymbol;
+        break;
+    }
+
+    GdkEventKey event;
+
+    event.keyval = key_val;
+    event.state = state;
+
+    return event;
+}
+
+inline GdkEventKey str2key(gchar *s, GdkEventKey &event)
+{
+    return str2key(s, event.state, event.keyval);
+}
+
+inline GdkEventKey str2key(gchar *s)
+{
+    GdkEventKey event;
+
+    return str2key(s, event);
+}
+
 
 class GnomeCmdUserActions
 {
@@ -100,16 +170,6 @@
 
     gboolean handle_key_event(GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs, GnomeCmdFileList *fl, GdkEventKey *event);
 
-  private:
-
-    std::string key2str(guint state, guint key_val);
-    std::string key2str(const GdkEventKey &event)                           {  return key2str(event.state, event.keyval);     }
-    GdkEventKey str2key(gchar *s, guint &state, guint &key_val);
-    GdkEventKey str2key(gchar *s, GdkEventKey &event)                       {  return str2key(s, event.state, event.keyval);  }
-    GdkEventKey str2key(gchar *s);
-
-  public:
-
     struct const_iterator: ACTIONS_COLL::iterator
     {
         const_iterator (const ACTIONS_COLL::iterator &i): ACTIONS_COLL::iterator(i)   {}
@@ -136,66 +196,6 @@
     return register_action(0, keyval, name, user_data);
 }
 
-inline std::string GnomeCmdUserActions::key2str(guint state, guint key_val)
-{
-    std::string key_name;
-
-    if (state & GDK_SHIFT_MASK)    key_name += gdk_modifiers_names[GDK_SHIFT_MASK];
-    if (state & GDK_CONTROL_MASK)  key_name += gdk_modifiers_names[GDK_CONTROL_MASK];
-    if (state & GDK_MOD1_MASK)     key_name += gdk_modifiers_names[GDK_MOD1_MASK];
-    if (state & GDK_MOD4_MASK)     key_name += gdk_modifiers_names[GDK_MOD4_MASK];
-
-    if (ascii_isalnum (key_val))
-        key_name += g_ascii_tolower (key_val);
-    else
-        key_name += gdk_key_names[key_val];
-
-    return key_name;
-}
-
-inline GdkEventKey GnomeCmdUserActions::str2key(gchar *s, guint &state, guint &key_val)
-{
-    g_strdown (s);
-
-    gchar *key = strrchr(s, '>');       // find last '>'
-    key = key ? key+1 : s;
-
-    key_val = gdk_key_names[key];
-    state = 0;
-
-     if (key_val==GDK_VoidSymbol)
-        if (strlen(key)==1 && ascii_isalnum (*key))
-            key_val = *key;
-
-    for (const gchar *beg=s; (beg=strchr(beg, '<')); ++beg)
-    {
-        if (const gchar *end = strchr(beg, '>'))
-            if (guint modifier = gdk_modifiers_names[std::string(beg,end-beg+1)])
-            {
-                state |= modifier;
-                beg = end;
-                continue;
-            }
-
-        key_val = GDK_VoidSymbol;
-        break;
-    }
-
-    GdkEventKey event;
-
-    event.keyval = key_val;
-    event.state = state;
-
-    return event;
-}
-
-inline GdkEventKey GnomeCmdUserActions::str2key(gchar *s)
-{
-    GdkEventKey event;
-
-    return str2key(s, event);
-}
-
 
 extern GnomeCmdUserActions gcmd_user_actions;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]