How can I put my GTK application in the desktop menus?

孤街醉人 提交于 2019-12-25 09:55:33

问题


I started with programming a little time ago and I created my first running application with GTK 3.0. I did not use Glade, I do not know if worth highlight it. My code is working perfectly, but now I have a doubt, how can I make my own desktop menu application? I mean, I want that my application running up without compile in a terminal with GTK 3.0 compiler, but yes with a double click.

I have been seen these examples provided by GNOME Developer Center, but I confess that did not understand it: https://developer.gnome.org/integration-guide/stable/desktop-files.html.en#ex-sample-desktop-file

The idea is to create a file containing this sequence of lines:

[Desktop Entry]

Type=Application

Encoding=UTF-8

Name=Sample Application Name

Comment=A sample application

Exec=application

Icon=application.png

Terminal=false

This file is my executable or it is a different file which points to my executable? If it is my executable, where can I insert it?

Thank you!


回答1:


So basically this file will create a desktop entry for those configurations you provide for the corresponding directives in the file. Judging by your question, you are unable to find where to place your application executable in that directive.

Exec="/absolute/path/to/your/executable/file"

And the Name directive will hold the information of your application name. This is the one you will be querying for in your gnome applications search (which appears when you press the windows key).

This file will contain a .desktop extension. And this file itself is not executable. This will point to your application, making the gnome/ubuntu system understand that such application exists.

This will not directly create a desktop shortcut as in Windows, rather this will index your application which you can run from the application menu (ubuntu or gnome)

If you aren't sure where to place the file here's a hint from the documentation you linked.

Place this file in the /usr/share/applications directory so that it is accessible by everyone, or in ~/.local/share/applications if you only wish to make it accessible to a single user



来源:https://stackoverflow.com/questions/37815190/how-can-i-put-my-gtk-application-in-the-desktop-menus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!