gnome-commander r1837 - in trunk: . doc/C src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r1837 - in trunk: . doc/C src
- Date: Thu, 12 Jun 2008 21:54:00 +0000 (UTC)
Author: epiotr
Date: Thu Jun 12 21:54:00 2008
New Revision: 1837
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=1837&view=rev
Log:
Added support for user defined shortcuts to arbitrary programs
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/TODO
trunk/doc/C/gnome-commander.xml
trunk/src/gnome-cmd-user-actions.cc
trunk/src/gnome-cmd-user-actions.h
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Thu Jun 12 21:54:00 2008
@@ -7,6 +7,7 @@
* Build fixes
New features:
+ * User defined shortcuts to arbitrary programs
* Updated help docs
* New or updated translations: cs, de, es
* New key bindings:
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Thu Jun 12 21:54:00 2008
@@ -20,17 +20,6 @@
* Support for SSH+FTP and WebDAV
* Editing remote files
* Optional file deselection after completed action (copy, rename, ...)
-* User defined shortcuts to arbitrary programs
- with the following parameters substitution:
- %f file name (or list for multiple selections)
- %F escaped filename (or list for multiple selections)
- %p full file system path (or list for multiple selections)
- %P escaped full file system path (or list for multiple selections)
- %u fully qualified URI for the file (or list for multiple selections)
- %d full path to the directory containg file
- %D escaped full path to the directory containg file
- %s synonym for %P (for compatibility with previous versions of gcmd)
- %% percent sign
* More plugins:
- creating tarballs from selected files
- compressing/decompressing (gz & bz2)
Modified: trunk/doc/C/gnome-commander.xml
==============================================================================
--- trunk/doc/C/gnome-commander.xml (original)
+++ trunk/doc/C/gnome-commander.xml Thu Jun 12 21:54:00 2008
@@ -4409,6 +4409,45 @@
<entry><para></para></entry>
</row>
<row valign="top">
+ <entry><para>command.execute<option>|user_command</option></para></entry>
+ <entry><para>Execute user defined command. &app; replaces found placeholders with:</para>
+ <para></para>
+ <itemizedlist>
+ <listitem>
+ <para><guilabel>%f</guilabel> file name (or list for multiple selections)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%F</guilabel> quoted filename (or list for multiple selections)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%p</guilabel> full file system path (or list for multiple selections)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%P</guilabel> quoted full file system path (or list for multiple selections)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%u</guilabel> fully qualified URI for the file (or list for multiple selections)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%d</guilabel> full path to the directory containg file</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%D</guilabel> quoted full path to the directory containing file</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%s</guilabel> synonym for <guilabel>%P</guilabel> (for compatibility with previous versions of &app;)</para>
+ </listitem>
+ <listitem>
+ <para><guilabel>%%</guilabel> percent sign</para>
+ </listitem>
+ </itemizedlist>
+ <note>
+ <para>Unknown placeholders are copied verbatim without any substitution.</para>
+ </note>
+ </entry>
+ <entry><para></para></entry>
+ </row>
+ <row valign="top">
<entry><para>command.open_folder</para></entry>
<entry><para>Open the current location in Nautilus file manager</para></entry>
<entry><para></para></entry>
@@ -5890,7 +5929,7 @@
<para>
<itemizedlist>
<listitem>
- <para>...</para>
+ <para>User defined shortcuts to arbitrary programs</para>
</listitem>
<listitem>
<para>Updated help docs</para>
Modified: trunk/src/gnome-cmd-user-actions.cc
==============================================================================
--- trunk/src/gnome-cmd-user-actions.cc (original)
+++ trunk/src/gnome-cmd-user-actions.cc Thu Jun 12 21:54:00 2008
@@ -132,6 +132,7 @@
{bookmarks_add_current, "bookmarks.add_current", N_("Bookmark current directory")},
{bookmarks_edit, "bookmarks.edit", N_("Manage bookmarks")},
{bookmarks_goto, "bookmarks.goto", N_("Go to bookmarked location")},
+ {command_execute, "command.execute", N_("Execute command")},
{command_open_nautilus, "command.open_folder", N_("Open folder")},
{command_open_terminal, "command.open_terminal", N_("Open terminal")},
{command_root_mode, "command.root_mode", N_("Start GNOME Commander as root")},
@@ -926,6 +927,116 @@
/************** Command Menu **************/
+template <typename F>
+inline void get_file_list (string &s, GList *sfl, F f)
+{
+ vector<string> a;
+
+ for (GList *i = sfl; i; i = i->next)
+ a.push_back ((*f) (GNOME_CMD_FILE (i->data)));
+
+ join (s, a.begin(), a.end());
+}
+
+
+void command_execute (GtkMenuItem *menuitem, gpointer command)
+{
+ g_return_if_fail (command != NULL);
+
+ DEBUG ('g', "invoking: %s\n", command);
+
+ string cmd;
+ string filename = "[f]";
+ string quoted_filename = "[F]";
+ string file_path = "[p]";
+ string quoted_file_path = "[P]";
+ string dir_path = "[d]";
+ string quoted_dir_path = "[D]";
+ string uri = "[U]";
+
+ GnomeCmdFileList *fl = get_fl (ACTIVE);
+ GList *sfl = gnome_cmd_file_list_get_selected_files (fl);
+ sfl = gnome_cmd_file_list_sort_selection (sfl, fl);
+
+ get_file_list (filename, sfl, gnome_cmd_file_get_name);
+ get_file_list (quoted_filename, sfl, gnome_cmd_file_get_quoted_name);
+ get_file_list (file_path, sfl, gnome_cmd_file_get_real_path);
+ get_file_list (quoted_file_path, sfl, gnome_cmd_file_get_quoted_real_path);
+ get_file_list (uri, sfl, gnome_cmd_file_get_uri_str);
+
+ g_list_free (sfl);
+
+ GnomeCmdDir *dir = gnome_cmd_file_selector_get_directory (get_fs (ACTIVE));
+
+ stringify (dir_path, gnome_cmd_file_get_real_path (GNOME_CMD_FILE (dir)));
+ stringify (quoted_dir_path, gnome_cmd_file_get_quoted_real_path (GNOME_CMD_FILE (dir)));
+
+ gboolean percent = FALSE;
+
+ cmd.reserve(2000);
+
+ for (const char *s=(const char *) command; *s; ++s)
+ {
+ if (!percent)
+ {
+ percent = *s=='%';
+
+ if (!percent)
+ cmd += *s;
+
+ continue;
+ }
+
+ switch (*s)
+ {
+ case 'f': // %f file name (or list for multiple selections)
+ cmd += filename;
+ break;
+
+ case 'F': // %F quoted filename (or list for multiple selections)
+ cmd += quoted_filename;
+ break;
+
+ case 'p': // %p full file system path (or list for multiple selections)
+ cmd += file_path;
+ break;
+
+ case 'P': // %P quoted full file system path (or list for multiple selections)
+ case 's': // %s synonym for %P (for compatibility with previous versions of gcmd)
+ cmd += quoted_file_path;
+ break;
+
+ case 'u': // %u fully qualified URI for the file (or list for multiple selections)
+ cmd += uri;
+ break;
+
+ case 'd': // %d full path to the directory containing file
+ cmd += dir_path;
+ break;
+
+ case 'D': // %D quoted full path to the directory containg file
+ cmd += quoted_dir_path;
+ break;
+
+ default:
+ cmd += '%';
+ case '%': // %% percent sign
+ cmd += *s;
+ break;
+ }
+
+ percent = FALSE;
+ }
+
+ if (percent)
+ cmd += '%';
+
+ DEBUG ('g', "running: %s\n", cmd.c_str());
+
+ gnome_execute_shell (gnome_cmd_dir_is_local (dir) ? dir_path.c_str() : NULL, cmd.c_str());
+}
+
+
void command_open_terminal (GtkMenuItem *menuitem, gpointer not_used)
{
gchar *dpath = gnome_cmd_file_get_real_path (GNOME_CMD_FILE (gnome_cmd_file_selector_get_directory (get_fs (ACTIVE))));
Modified: trunk/src/gnome-cmd-user-actions.h
==============================================================================
--- trunk/src/gnome-cmd-user-actions.h (original)
+++ trunk/src/gnome-cmd-user-actions.h Thu Jun 12 21:54:00 2008
@@ -259,6 +259,7 @@
GNOME_CMD_USER_ACTION(edit_copy_fnames);
/************** Command Menu **************/
+GNOME_CMD_USER_ACTION(command_execute);
GNOME_CMD_USER_ACTION(command_open_terminal);
GNOME_CMD_USER_ACTION(command_open_nautilus);
GNOME_CMD_USER_ACTION(command_open_nautilus_in_cwd);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]