[gtk/shortcuts-rebased-again: 53/96] accelgroup: Add gtk_accel_group_print_label()



commit d51e9bb7beb3dab7ea6985193d66009a417140de
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 a71bf4366d..e58342e1bc 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]