From fb6b01759d67d688447003048ea34d466dd9c035 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 13 May 2012 04:46:29 +0200 Subject: [PATCH] Calculate action name length for --help-execute Fixes: https://bugs.launchpad.net/midori/+bug/998597 --- midori/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/midori/main.c b/midori/main.c index cb4e1c4d..7db7522d 100644 --- a/midori/main.c +++ b/midori/main.c @@ -2020,11 +2020,21 @@ main (int argc, MidoriBrowser* browser = midori_browser_new (); GtkActionGroup* action_group = midori_browser_get_action_group (browser); GList* actions = gtk_action_group_list_actions (action_group); + GList* temp = actions; + guint length = 1; + gchar* space; + + for (; temp; temp = g_list_next (temp)) + { + GtkAction* action = temp->data; + length = MAX (length, 1 + strlen (gtk_action_get_name (action))); + } + + space = g_strnfill (length, ' '); for (; actions; actions = g_list_next (actions)) { GtkAction* action = actions->data; const gchar* name = gtk_action_get_name (action); - const gchar* space = " "; gchar* padding = g_strndup (space, strlen (space) - strlen (name)); gchar* label = katze_object_get_string (action, "label"); gchar* stripped = katze_strip_mnemonics (label); @@ -2036,6 +2046,7 @@ main (int argc, g_free (label); g_free (stripped); } + g_free (space); g_list_free (actions); gtk_widget_destroy (GTK_WIDGET (browser)); return 0; -- 2.39.5