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.
How to add a menuitem in Nautilus context menu.
最新推荐文章于 2024-09-09 10:16:12 发布
博客介绍了在文件管理器中添加命令和菜单项的操作,包括在nautilus - directory - view - ui.xml中添加命令和菜单项,在fm - directory - view.c的函数里添加相关项,还说明了如何在回调函数中启动对应程序,以及获取实际文件名的方法。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Dify
AI应用
Agent编排
Dify 是一款开源的大语言模型(LLM)应用开发平台,它结合了 后端即服务(Backend as a Service) 和LLMOps 的理念,让开发者能快速、高效地构建和部署生产级的生成式AI应用。 它提供了包含模型兼容支持、Prompt 编排界面、RAG 引擎、Agent 框架、工作流编排等核心技术栈,并且提供了易用的界面和API,让技术和非技术人员都能参与到AI应用的开发过程中
480

被折叠的 条评论
为什么被折叠?



