1. In src/file-Manager/directory, add command section and menuitem section in nautilus-directory-view-ui.xml.
<Commands>
...
<Cmd name = "name convert"
_ Label = "name _ convert"
_ Tip = "convert the file name"/>
...
</Commands>
<Popup name = "selection" tearoff = "0">
....
<Placeholder name = "file actions" delimit = "TOP">
...
<Menuitem name = "name convert" verb = "name convert"/>
...
</Placeholder>
...
</Popup>
2. In fm-directory-view.c:
# Define fm_directory_view_command_name_convert "/commands/name convert"
In real_merge_menus () function, bonobouiverb verbs [] array, add the following item:
Bonobo_ui_verb ("name convert", name_convert_callback ),
You cocould use nautilus_bonobo_set_sensitive () or nautilus_bonobo_hidden () to show or hide this menuitem.
3. How to launch the corresponding program in callback function:
Gnomevfsmimeapplication * test;
Test = g_new0 (gnomevfsmimeapplication, 1 );
Test-> id = g_strdup ("test");
Test-> name = g_strdup ("this is a test");
Test-> command = g_strdup ("test");
Test-> expects_uris = gnome_vfs_mime_application_argument_type_paths;
File = nautilus_file (selection-> data );
Nautilus_launch_application (test, file, null );
G_free (test-> ID );
G_free (test-> name );
G_free (test-> name );
G_free (test );
You cocould use gnome_vfs-get_local_path_from_uri (nautilus_file_get_uri (File) to get the actuall file name.