From cd4705a6aeaeeb144264f3ecce619d020c2a8e5b Mon Sep 17 00:00:00 2001 From: dpage Date: Tue, 27 Jan 2009 21:23:27 +0000 Subject: [PATCH] Add a KeyFile option to the utilities.ini config file. This option takes a filename, and only if that file exists, will the plugin be added to the menus. If the option is omitted, the plugin is always added. git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7574 a7884b65-44f6-0310-8a51-81a127f17b15 --- pgadmin/frm/plugins.cpp | 25 +++++++++++++++++++------ pgadmin/include/frm/frmMain.h | 1 + plugins/utilities.ini | 6 ++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/pgadmin/frm/plugins.cpp b/pgadmin/frm/plugins.cpp index 10847ea33..dd61bdf95 100644 --- a/pgadmin/frm/plugins.cpp +++ b/pgadmin/frm/plugins.cpp @@ -72,9 +72,13 @@ void frmMain::LoadPluginUtilities() // Add the previous app if required. if (!util->title.IsEmpty() && !util->command.IsEmpty()) { - CreatePluginUtility(util); - ClearPluginUtility(util); - pluginUtilityCount++; + // We're only going to add this if the keyfile exists or isn't specified + if (util->keyfile.IsEmpty() || wxFileExists(util->keyfile)) + { + CreatePluginUtility(util); + ClearPluginUtility(util); + pluginUtilityCount++; + } } util->title = token.AfterFirst('=').Trim(); @@ -88,6 +92,10 @@ void frmMain::LoadPluginUtilities() if (token.Lower().StartsWith(wxT("description="))) util->description = token.AfterFirst('=').Trim(); + // KeyFile + if (token.Lower().StartsWith(wxT("keyfile="))) + util->keyfile = token.AfterFirst('=').Trim(); + // Database if (token.Lower().StartsWith(wxT("database="))) { @@ -122,9 +130,13 @@ void frmMain::LoadPluginUtilities() // Add the last app if required. if (!util->title.IsEmpty() && !util->command.IsEmpty()) { - CreatePluginUtility(util); - ClearPluginUtility(util); - pluginUtilityCount++; + // We're only going to add this if the keyfile exists or isn't specified + if (util->keyfile.IsEmpty() || wxFileExists(util->keyfile)) + { + CreatePluginUtility(util); + ClearPluginUtility(util); + pluginUtilityCount++; + } } if (util) @@ -149,6 +161,7 @@ void frmMain::ClearPluginUtility(PluginUtility *util) util->title = wxEmptyString; util->command = wxEmptyString; util->description = wxEmptyString; + util->keyfile = wxEmptyString; util->database = false; util->applies_to.Clear(); util->set_password = false; diff --git a/pgadmin/include/frm/frmMain.h b/pgadmin/include/frm/frmMain.h index d19ebfa1a..ecdabece2 100644 --- a/pgadmin/include/frm/frmMain.h +++ b/pgadmin/include/frm/frmMain.h @@ -52,6 +52,7 @@ typedef struct PluginUtility { wxString title; wxString command; wxString description; + wxString keyfile; bool database; wxArrayString applies_to; bool set_password; diff --git a/plugins/utilities.ini b/plugins/utilities.ini index 2372ffb0e..77645beca 100644 --- a/plugins/utilities.ini +++ b/plugins/utilities.ini @@ -36,6 +36,9 @@ ; ; Description - A description of the utility for use in tooltips etc. ; +; KeyFile - If specified, this file must exist for the plugin to be shown +; on the menus. +; ; Database - Set to 'Yes' to indicate that the command needs to be executed ; where database connection is possible - ie. when the currently ; selected object in the treeview is a database or child object. @@ -63,6 +66,7 @@ ; ; Title=PSQL Console ; Command=/usr/bin/xterm -e /usr/local/pgsql/bin/psql -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE +; KeyFile=/usr/local/pgsql/bin/psql ; Description=Open a PSQL console to the current database. ; Database=Yes ; SetPassword=Yes @@ -81,6 +85,7 @@ ; Title=PSQL Console ; Command="C:\Program Files\PostgreSQL\8.3\bin\psql.exe" -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE ; Description=Open a PSQL console to the current database. +; KeyFile=C:\Program Files\PostgreSQL\8.3\bin\psql.exe ; Database=Yes ; SetPassword=Yes ; @@ -88,6 +93,7 @@ ; ; Title=PSQL Console ; Command=/usr/bin/osascript -e 'ignoring application responses' -e 'tell application "Terminal"' -e 'activate' -e 'do script with command "/usr/local/pgsql/bin/psql -h $$HOSTNAME -p $$PORT -U $$USERNAME $$DATABASE && exit || sleep 5 && exit"' -e 'end tell' -e 'end ignoring' +; KeyFile=/usr/local/pgsql/bin/psql ; Description=Open a PSQL console to the current database. ; Database=Yes ; SetPassword=Yes -- 2.39.5