--- gtk/gtkappchooserdialog.c	2012-11-19 15:32:20.000000000 +0100
+++ gtk/gtkappchooserdialog.c	2013-04-05 07:10:25.134309114 +0200
@@ -53,6 +53,10 @@
 #include "gtkbutton.h"
 #include "gtkmenuitem.h"
 #include "gtkstock.h"
+#include "gtkentry.h"
+#include "gtkentrycompletion.h"
+#include "gtktreemodel.h"
+#include "gtkfilechooser.h"
 
 #include <string.h>
 #include <glib/gi18n-lib.h>
@@ -514,11 +518,92 @@
     }
 }
 
+static GtkTreeModel *
+create_completion_model (void)
+{
+  GtkListStore *store;
+  GtkTreeIter iter;
+  gchar **env, **path_elts;
+  const gchar *path;
+
+  store = gtk_list_store_new (1, G_TYPE_STRING);
+
+  /* retrieve the PATH variable */
+  env = g_get_environ ();
+  path = g_environ_getenv (env, "PATH");
+
+ /* split it and retrieve each folder's executable children */
+  path_elts = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 0);
+  for (; NULL != *path_elts; path_elts++)
+  {
+      //g_printf ("%s \n",*path_elts);
+    if (g_file_test (*path_elts, (G_FILE_TEST_IS_DIR)) == TRUE)
+    {
+      GError *error = NULL;
+      GFileInfo *info;
+      GFile *folder = g_file_new_for_path (*path_elts);
+      GFileEnumerator *enumerator = g_file_enumerate_children (folder,
+                                   G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE,
+                                   0, NULL, &error);
+
+      while ((info = g_file_enumerator_next_file (enumerator,
+                                             NULL, &error)) != NULL)
+      {
+         gtk_list_store_append (store, &iter);
+         gtk_list_store_set (store, &iter, 0, g_file_info_get_name (info), -1);
+      }
+
+      g_error_free (error);
+      g_object_unref (info);
+      g_object_unref (folder);
+      g_object_unref (enumerator);
+    }
+  }
+
+  /* g_free (path_elts);
+  g_free (env); */
+
+  return GTK_TREE_MODEL (store);
+}
+
+static void
+dialog_open_executable ()
+{
+  GtkWidget *dialog;
+  GtkFileFilter *filter;
+
+  dialog = gtk_file_chooser_dialog_new ("Choose executable file",
+                                         NULL,
+                                 GTK_FILE_CHOOSER_ACTION_OPEN,
+                                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                                 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+                                 NULL);
+
+  filter = gtk_file_filter_new ();
+  gtk_file_filter_set_name (filter, "Executable files");
+#ifdef G_OS_WIN32
+  gtk_file_filter_add_pattern (filter, "*.exe");
+#else
+  gtk_file_filter_add_mime_type (filter, "application/x-executable");
+#endif
+  gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+  {
+    /* TODO */
+  }
+
+  gtk_widget_destroy (dialog);
+}
+
 static void
 build_dialog_ui (GtkAppChooserDialog *self)
 {
   GtkWidget *vbox;
   GtkWidget *vbox2;
+  GtkEntryCompletion *completion;
+  GtkTreeModel *completion_model;
+  GtkWidget *expander, *hbox, *entry, *browse;
   GtkWidget *button, *w;
   GAppInfo *info;
 
@@ -555,6 +640,28 @@
   g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
                     G_CALLBACK (widget_populate_popup_cb), self);
 
+  expander = gtk_expander_new (_("Use a custom command :"));
+  entry = gtk_entry_new ();
+  completion = gtk_entry_completion_new ();
+  browse = gtk_button_new_with_label (_("Browse..."));
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
+  gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 2);
+  gtk_box_pack_start (GTK_BOX (hbox), browse, FALSE, FALSE, 2);
+  gtk_container_add (GTK_CONTAINER (expander), hbox);
+  gtk_box_pack_start (GTK_BOX (self->priv->app_chooser_widget), expander, TRUE, TRUE, 6);
+  gtk_entry_set_completion (GTK_ENTRY (entry), completion);
+  g_object_unref (completion);
+  completion_model = create_completion_model ();
+  gtk_entry_completion_set_model (completion, completion_model);
+  g_object_unref (completion_model);
+  gtk_entry_completion_set_text_column (completion, 0);
+  gtk_entry_set_icon_from_stock (entry, GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
+  gtk_entry_set_placeholder_text (entry, "command");
+  gtk_widget_show_all (expander);
+
+  g_signal_connect (browse, "clicked",
+                   G_CALLBACK (dialog_open_executable), self);
+
   button = gtk_button_new_with_label (_("Show other applications"));
   self->priv->show_more_button = button;
   w = gtk_image_new_from_stock (GTK_STOCK_ADD,
