您的位置:首页 > 产品设计 > UI/UE

How to add a menuitem in Nautilus context menu.

2004-11-26 19:23 736 查看
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 could 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 could use gnome_vfs-get_local_path_from_uri (nautilus_file_get_uri (file)) to get the actuall file name.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: