<xfce4-taskmanager:master> Display only installed programs in the “Execute” menu

Mike Massonnet noreply at xfce.org
Mon May 24 22:42:01 CEST 2010


Updating branch refs/heads/master
         to 1b6a226a81e0917c2a71bfdf3e5c4eb6b14d5658 (commit)
       from f929d83f372472fee824ac156a59019240454430 (commit)

commit 1b6a226a81e0917c2a71bfdf3e5c4eb6b14d5658
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Mon May 24 22:39:19 2010 +0200

    Display only installed programs in the “Execute” menu

 src/process-window.c |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/process-window.c b/src/process-window.c
index f1e7687..37c8d87 100644
--- a/src/process-window.c
+++ b/src/process-window.c
@@ -191,19 +191,39 @@ menu_execute_append_item (GtkMenu *menu, gchar *title, gchar *command, gchar *ic
 	g_signal_connect_swapped (mi, "activate", G_CALLBACK (execute_command), command);
 }
 
+static gboolean
+program_exists (gchar *program)
+{
+	gchar *program_path = g_find_program_in_path (program);
+	if (program_path == NULL)
+		return FALSE;
+	g_free (program_path);
+	return TRUE;
+}
+
 static void
 show_menu_execute_task (XtmProcessWindow *window)
 {
-	// TODO check if xfrun4, xfce4-appfinder, etc are installed and pull them in the menu
 	static GtkWidget *menu = NULL;
 
 	if (menu == NULL)
 	{
 		menu = gtk_menu_new ();
-		menu_execute_append_item (GTK_MENU (menu), _("Run Program..."), "xfrun4", "system-run");
-		menu_execute_append_item (GTK_MENU (menu), _("Application Finder"), "xfce4-appfinder", "xfce4-appfinder");
-		menu_execute_append_item (GTK_MENU (menu), _("Terminal emulator"), "exo-open --launch TerminalEmulator", "terminal");
-		menu_execute_append_item (GTK_MENU (menu), _("XTerm"), "xterm -fg grey -bg black", "terminal");
+		/* Find a runner program */
+		if (program_exists ("xfrun4"))
+			menu_execute_append_item (GTK_MENU (menu), _("Run Program..."), "xfrun4", "system-run");
+		else if (program_exists ("gmrun"))
+			menu_execute_append_item (GTK_MENU (menu), _("Run Program..."), "gmrun", "system-run");
+		else if (program_exists ("gexec"))
+			menu_execute_append_item (GTK_MENU (menu), _("Run Program..."), "gexec", "system-run");
+		/* Find an applications list program */
+		if (program_exists ("xfce4-appfinder"))
+			menu_execute_append_item (GTK_MENU (menu), _("Application Finder"), "xfce4-appfinder", "xfce4-appfinder");
+		/* Find a terminal emulator */
+		if (program_exists ("exo-open"))
+			menu_execute_append_item (GTK_MENU (menu), _("Terminal emulator"), "exo-open --launch TerminalEmulator", "terminal");
+		else if (program_exists ("xterm"))
+			menu_execute_append_item (GTK_MENU (menu), _("XTerm"), "xterm -fg grey -bg black", "terminal");
 		gtk_widget_show_all (menu);
 	}
 



More information about the Xfce4-commits mailing list