[gtk/wip/ebassi/shortcut: 158/203] accelgroup: Add gtk_accel_group_print_label()



commit 9156dc259afcfdc85e746488e7685b07089cf7de
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 13 05:19:05 2018 +0200

    accelgroup: Add gtk_accel_group_print_label()

 gtk/gtkaccelgroup.c        | 17 +++++++++++++----
 gtk/gtkaccelgroupprivate.h |  9 ++++++---
 2 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index 0e95d26926..0dea8cd6f7 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -1812,11 +1812,22 @@ gtk_accelerator_get_label (guint           accelerator_key,
                            GdkModifierType accelerator_mods)
 {
   GString *gstring;
+
+  gstring = g_string_new (NULL);
+
+  gtk_accelerator_print_label (gstring, accelerator_key, accelerator_mods);
+
+  return g_string_free (gstring, FALSE);
+}
+
+void
+gtk_accelerator_print_label (GString        *gstring,
+                             guint           accelerator_key,
+                             GdkModifierType accelerator_mods)
+{
   gboolean seen_mod = FALSE;
   gunichar ch;
 
-  gstring = g_string_sized_new (10); /* ~len('backspace') */
-
   if (accelerator_mods & GDK_SHIFT_MASK)
     {
 #ifndef GDK_WINDOWING_QUARTZ
@@ -1996,8 +2007,6 @@ gtk_accelerator_get_label (guint           accelerator_key,
            }
        }
     }
-
-  return g_string_free (gstring, FALSE);
 }
 
 /**
diff --git a/gtk/gtkaccelgroupprivate.h b/gtk/gtkaccelgroupprivate.h
index 15da43ae2b..e2b166378d 100644
--- a/gtk/gtkaccelgroupprivate.h
+++ b/gtk/gtkaccelgroupprivate.h
@@ -34,10 +34,13 @@ struct _GtkAccelGroupPrivate
   GtkAccelGroupEntry *priv_accels;
 };
 
-void   _gtk_accel_group_reconnect        (GtkAccelGroup *accel_group,
-                                           GQuark         accel_path_quark);
-GSList* _gtk_accel_group_get_accelerables (GtkAccelGroup *accel_group);
+void   _gtk_accel_group_reconnect              (GtkAccelGroup          *accel_group,
+                                                 GQuark                  accel_path_quark);
+GSList* _gtk_accel_group_get_accelerables       (GtkAccelGroup          *accel_group);
 
+void    gtk_accelerator_print_label             (GString                *gstring,
+                                                 guint                   accelerator_key,
+                                                 GdkModifierType         accelerator_mods);
 G_END_DECLS
 
 #endif /* __GTK_ACCEL_GROUP_PRIVATE_H__ */


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