[Xfce4-commits] <midori:master> Implement --help-execute to list available commands

Christian Dywan noreply at xfce.org
Thu Oct 14 01:48:01 CEST 2010


Updating branch refs/heads/master
         to 2dbce1e327a5c17b213f49cd69f69eb8864b4847 (commit)
       from bcc622c45619ba805a0f73c4a302cd66935b6fb8 (commit)

commit 2dbce1e327a5c17b213f49cd69f69eb8864b4847
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Oct 14 01:18:15 2010 +0200

    Implement --help-execute to list available commands

 midori/main.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/midori/main.c b/midori/main.c
index b3ab80a..2a0499a 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -1527,6 +1527,7 @@ main (int    argc,
     gboolean run;
     gchar* snapshot;
     gboolean execute;
+    gboolean help_execute;
     gboolean version;
     gchar** uris;
     gchar* block_uris;
@@ -1552,6 +1553,8 @@ main (int    argc,
        #endif
        { "execute", 'e', 0, G_OPTION_ARG_NONE, &execute,
        N_("Execute the specified command"), NULL },
+       { "help-execute", 0, 0, G_OPTION_ARG_NONE, &help_execute,
+       N_("List available commands to execute with -e/ --execute"), NULL },
        { "version", 'V', 0, G_OPTION_ARG_NONE, &version,
        N_("Display program version"), NULL },
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &uris,
@@ -1636,6 +1639,7 @@ main (int    argc,
     run = FALSE;
     snapshot = NULL;
     execute = FALSE;
+    help_execute = FALSE;
     version = FALSE;
     uris = NULL;
     block_uris = NULL;
@@ -1676,6 +1680,29 @@ main (int    argc,
         return 0;
     }
 
+    if (help_execute)
+    {
+        MidoriBrowser* browser = midori_browser_new ();
+        GtkActionGroup* action_group = midori_browser_get_action_group (browser);
+        GList* actions = gtk_action_group_list_actions (action_group);
+        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_strip_mnemonics (gtk_action_get_label (action));
+            const gchar* tooltip = gtk_action_get_tooltip (action);
+            g_print ("%s%s%s%s%s\n", name, padding, label,
+                     tooltip ? ": " : "", tooltip ? tooltip : "");
+            g_free (padding);
+            g_free (label);
+        }
+        g_list_free (actions);
+        gtk_widget_destroy (GTK_WIDGET (browser));
+        return 0;
+    }
+
     #if WEBKIT_CHECK_VERSION (1, 1, 6)
     if (snapshot)
     {



More information about the Xfce4-commits mailing list