简体   繁体   English

Linux薄荷拖放我程序桌面图标上的文件

[英]Linux mint drag & drop files on my program's desktop icon

I am using Linux Mint. 我正在使用Linux Mint。

I wrote a small program in C and want to drag and drop a file onto its desktop or caja icon. 我在C中编写了一个小程序,想要将文件拖放到桌面或caja图标上。 When I drag a file over the icon of an installed application, that app icon highlights showing that it will launch, but my program's icon does not highlight. 当我将文件拖到已安装应用程序的图标上时,该应用程序图标会突出显示它将启动,但我的程序图标不会突出显示。 How do I enable the launch? 如何启动发布?

In windows all programs launch, even if they don't handle a dropped file. 在Windows中,所有程序都会启动,即使它们不处理丢弃的文件。

The program "executable" permission is set, and double clicking the icon does launch it. 设置程序“可执行”权限,双击该图标确实启动它。

I am thinking that it is not something I do "in" the program code, but some configuration for the icon or Linux. 我认为这不是我在“程序代码”中所做的事情,而是对图标或Linux的一些配置。 The program code accepts command line arguments when run from a terminal. 从终端运行时,程序代码接受命令行参数。 But dropping files on its icon does nothing at all except moves the files to the desktop piled on top of the program icon. 但是删除其图标上的文件什么都不做,除了将文件移动到堆积在程序图标顶部的桌面上。 Never even attempts to launch the program. 甚至从未试图启动该计划。

What am I missing? 我错过了什么?

Now I understand! 现在我明白了!

I must create a "launcher" for the program. 我必须为该程序创建一个“启动器”。 This is done by right-clicking on the desktop blank area to get the context menu, and choose "Create Launcher...". 通过右键单击桌面空白区域以获取上下文菜单,然后选择“创建启动器...”即可完成此操作。 Then fill in the fields, and especially the "Command:" field with a valid pathname (or just a name if the program is in a directory that is included in the PATH environment variable). 然后填写字段,尤其是带有有效路径名的“Command:”字段(如果程序位于PATH环境变量中包含的目录中,则只填写一个名称)。 AND include at the end of that command line %F to accept the file(s) to be dropped. 并在该命令行%F的末尾包含接受要删除的文件。 Also give it a name and click OK. 同时为其命名,然后单击“确定”。

If you leave off the %F and drop more than one file, each file will launch its own instance of the program. 如果您不使用%F并删除多个文件,则每个文件都将启动自己的程序实例。 The %F causes all the files to be passed to one instance of the program. %F会将所有文件传递给程序的一个实例。 For example if you want to drop two files onto a compare program. 例如,如果要将两个文件放到比较程序中。

If it doesn't work, you can edit the command and other fields by right-clicking on its icon and choose Properties. 如果它不起作用,您可以通过右键单击其图标并选择“属性”来编辑命令和其他字段。

It has a generic springboard icon. 它有一个通用的跳板图标。

In a terminal, the ls command shows the launch file for "prog" (for example) as prog.desktop but on the desktop just prog. 在终端中,ls命令将“prog”(例如)的启动文件显示为prog.desktop,但在桌面上只显示prog。 The launcher file can be moved or copied into a folder (other than desktop) and they work the same (although the icon is different). 可以将启动器文件移动或复制到文件夹(桌面除外)中,它们的工作方式相同(尽管图标不同)。

Hope this helps others. 希望这有助于其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM