]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkaccellabel.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gtk / gtkaccellabel.c
index 5ea999499ab3e5805381e17dd85ab7fe9b95e950..cb57aaa9269d9e037f6e90aeef8eae92d4504cc6 100644 (file)
@@ -27,7 +27,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <string.h>
 
 #include "gtkaccellabel.h"
@@ -36,6 +36,7 @@
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
+#include <gdk/gdkkeysyms.h>
 
 enum {
   PROP_0,
@@ -80,6 +81,8 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
 
   class->signal_quote1 = g_strdup ("<:");
   class->signal_quote2 = g_strdup (":>");
+
+#ifndef GDK_WINDOWING_QUARTZ
   /* This is the text that should appear next to menu accelerators
    * that use the shift key. If the text on this key isn't typically
    * translated on keyboards used for your language, don't translate
@@ -105,6 +108,18 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
    */
   class->mod_name_alt = g_strdup (Q_("keyboard label|Alt"));
   class->mod_separator = g_strdup ("+");
+#else /* GDK_WINDOWING_QUARTZ */
+
+  /* U+21E7 UPWARDS WHITE ARROW */
+  class->mod_name_shift = g_strdup ("\xe2\x87\xa7");
+  /* U+2303 UP ARROWHEAD */
+  class->mod_name_control = g_strdup ("\xe2\x8c\x83");
+  /* U+2325 OPTION KEY */
+  class->mod_name_alt = g_strdup ("\xe2\x8c\xa5");
+  class->mod_separator = g_strdup ("");
+
+#endif /* GDK_WINDOWING_QUARTZ */
+
   class->accel_seperator = g_strdup (" / ");
   class->latin1_to_char = TRUE;
   
@@ -504,6 +519,90 @@ substitute_underscores (char *str)
       *p = ' ';
 }
 
+/* On Mac, if the key has symbolic representation (e.g. arrow keys),
+ * append it to gstring and return TRUE; otherwise return FALSE.
+ * See http://docs.info.apple.com/article.html?path=Mac/10.5/en/cdb_symbs.html 
+ * for the list of special keys. */
+static gboolean
+append_keyval_symbol (guint    accelerator_key,
+                      GString *gstring)
+{
+#ifdef GDK_WINDOWING_QUARTZ
+  switch (accelerator_key)
+  {
+  case GDK_Return:
+    /* U+21A9 LEFTWARDS ARROW WITH HOOK */
+    g_string_append (gstring, "\xe2\x86\xa9");
+    return TRUE;
+
+  case GDK_ISO_Enter:
+    /* U+2324 UP ARROWHEAD BETWEEN TWO HORIZONTAL BARS */
+    g_string_append (gstring, "\xe2\x8c\xa4");
+    return TRUE;
+
+  case GDK_Left:
+    /* U+2190 LEFTWARDS ARROW */
+    g_string_append (gstring, "\xe2\x86\x90");
+    return TRUE;
+
+  case GDK_Up:
+    /* U+2191 UPWARDS ARROW */
+    g_string_append (gstring, "\xe2\x86\x91");
+    return TRUE;
+
+  case GDK_Right:
+    /* U+2192 RIGHTWARDS ARROW */
+    g_string_append (gstring, "\xe2\x86\x92");
+    return TRUE;
+
+  case GDK_Down:
+    /* U+2193 DOWNWARDS ARROW */
+    g_string_append (gstring, "\xe2\x86\x93");
+    return TRUE;
+
+  case GDK_Page_Up:
+    /* U+21DE UPWARDS ARROW WITH DOUBLE STROKE */
+    g_string_append (gstring, "\xe2\x87\x9e");
+    return TRUE;
+
+  case GDK_Page_Down:
+    /* U+21DF DOWNWARDS ARROW WITH DOUBLE STROKE */
+    g_string_append (gstring, "\xe2\x87\x9f");
+    return TRUE;
+
+  case GDK_Home:
+    /* U+2196 NORTH WEST ARROW */
+    g_string_append (gstring, "\xe2\x86\x96");
+    return TRUE;
+
+  case GDK_End:
+    /* U+2198 SOUTH EAST ARROW */
+    g_string_append (gstring, "\xe2\x86\x98");
+    return TRUE;
+
+  case GDK_Escape:
+    /* U+238B BROKEN CIRCLE WITH NORTHWEST ARROW */
+    g_string_append (gstring, "\xe2\x8e\x8b");
+    return TRUE;
+
+  case GDK_BackSpace:
+    /* U+232B ERASE TO THE LEFT */
+    g_string_append (gstring, "\xe2\x8c\xab");
+    return TRUE;
+
+  case GDK_Delete:
+    /* U+2326 ERASE TO THE RIGHT */
+    g_string_append (gstring, "\xe2\x8c\xa6");
+    return TRUE;
+
+  default:
+    return FALSE;
+  }
+#else /* !GDK_WINDOWING_QUARTZ */
+  return FALSE;
+#endif
+}
+
 gchar *
 _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
                                              guint               accelerator_key,
@@ -599,6 +698,7 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
       if (seen_mod)
        g_string_append (gstring, klass->mod_separator);
 
+#ifndef GDK_WINDOWING_QUARTZ
       /* This is the text that should appear next to menu accelerators
        * that use the meta key. If the text on this key isn't typically
        * translated on keyboards used for your language, don't translate
@@ -606,6 +706,10 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
        * And do not translate the part before the |.
        */
       g_string_append (gstring, Q_("keyboard label|Meta"));
+#else
+      /* Command key symbol U+2318 PLACE OF INTEREST SIGN */
+      g_string_append (gstring, "\xe2\x8c\x98");
+#endif
       seen_mod = TRUE;
     }
   if (seen_mod)
@@ -630,7 +734,7 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
          break;
        }
     }
-  else
+  else if (!append_keyval_symbol (accelerator_key, gstring))
     {
       gchar *tmp;
 
@@ -646,7 +750,7 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
              
              strcpy (msg, "keyboard label|");
              g_strlcat (msg, tmp, 128);
-             str = dgettext (GETTEXT_PACKAGE, msg);
+             str = _(msg);
              if (str == msg)
                {
                  g_string_append (gstring, tmp);
@@ -664,6 +768,8 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass,
 gboolean
 gtk_accel_label_refetch (GtkAccelLabel *accel_label)
 {
+  gboolean enable_accels;
+
   g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), FALSE);
 
   if (accel_label->accel_string)
@@ -672,7 +778,11 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
       accel_label->accel_string = NULL;
     }
 
-  if (accel_label->accel_closure)
+  g_object_get (gtk_widget_get_settings (GTK_WIDGET (accel_label)),
+                "gtk-enable-accels", &enable_accels,
+                NULL);
+
+  if (enable_accels && accel_label->accel_closure)
     {
       GtkAccelKey *key = gtk_accel_group_find (accel_label->accel_group, find_accel, accel_label->accel_closure);