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.
<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.
相关文章推荐
- 让Hibernate8IDE运行在JBuilder中
- SAS应用技巧-快速在CATALOG的SCL中查找某字符串的方法
- 用PHP开发GUI(一个简单的例子)
- ComponentArt Web.UI控件的bug及解决办法
- 学会将SYS_GUID和序列作为主关键字
- Quick .Net File Download Security
- WAP Push Quick Start
- C# Key Processing Techniques
- 实战dailybuild-cc.net的配置
- 软件测试实践系列之三、四已经完成
- JBuilder在编译时丢失源代码字符
- JBuilderX中文字体的问题
- Google desktop search VS msn toolbar suite.
- [原创] GUI原理2 - 矢量线条
- [理论] GUI原理1 - 色彩王国
- 2004.11.23,Tue - 很久没有喝酒了
- Question About Compile Xvid_Bench Please
- Question About Compile Xvid_Bench Please
- 通过CommandBuilder对DataSet数据进行添加、修改、删除
- J2ee学习流程