Sergey Politov
Sergey Politov

Reputation: 59

Quit via dock menu and GTK

Every application in Mac OS X has Quit menu item in dock menu and in Application menu at menubar. But this item does no work in GTK applications. Even in such simple applications like this one http://www.levien.com/gimp/hello.html

I tried to handle Quit manually using NSApplicationDelegate applicationShouldTerminate:, but it is not invoked in such case.

Is there any way to support quit via Dock menu?

Upvotes: 2

Views: 672

Answers (2)

totaam
totaam

Reputation: 1311

The answer above is almost correct, you do want to use GtkOSXApplication, but since you are asking about the dock's quit entry you want to connect to "NSApplicationBlockTermination" the signal. Here's how I use it in python to catch the quit action:

macapp = gtk_osxapplication.OSXApplication()
macapp.set_dock_icon_pixbuf(some_pixbuf)
macapp.set_menu_bar(my_menubar)
macapp.connect("NSApplicationBlockTermination", your_exit_callback)

Then just call gtk.main_quit() from your_exit_callback when you are done. Note: there are some more tricks you will need for the quit menu item in the main menu - not covered here.

Upvotes: 0

L. Lopez
L. Lopez

Reputation: 71

ige-mac-integration provides Dock, Menu and bundle integration for gtk applications in OSX

You can use GtkOSXApplication to integrate your GtkMenu into OSX global menu.

Take a look to those functions:

  • gtk_osxapplication_set_use_quartz_accelerators()
  • gtk_osxapplication_set_menu_bar()

Upvotes: 0

Related Questions