Re: [Gtk-osx-users] [gtk-osx-users] "Application Not Responding" and set_dock_menu
Status: Beta
Brought to you by:
jralls
From: John R. <jr...@ce...> - 2011-10-30 17:40:36
|
<html><body class="ApplePlainTextBody" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br>On Oct 24, 2011, at 12:34 AM, Antoine Martin wrote:<br><br><blockquote type="cite">Hi,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I must be doing something wrong but I just can't see what.<br></blockquote><blockquote type="cite">Running the attached sample code gives two problems:<br></blockquote><blockquote type="cite">1) "Application Not Responding" is shown in the dock, despite the fact<br></blockquote><blockquote type="cite">that the app runs fine and responds to main menu clicks and events...<br></blockquote><blockquote type="cite">2) The menu I want to use for the dock is ignored.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any ideas?<br></blockquote><br><br>Seems to be an odd scoping problem, though I didn't try to replicate it in C, so I don't know where exactly the problem is. If I change your test program like this:<br><br>--- test_dockmenu.py~<span class="Apple-tab-span" style="white-space:pre"> </span>2011-10-29 17:26:02.000000000 -0700<br>+++ test_dockmenu.py<span class="Apple-tab-span" style="white-space:pre"> </span>2011-10-30 10:21:54.000000000 -0700<br>@@ -1,10 +1,13 @@<br>import os.path<br>import gtk.gdk<br><br>+def disconnect_cb(arg):<br>+ print "disconnect"<br>+<br>def setup_macdock():<br> import gtk_osxapplication<br> macapp = gtk_osxapplication.OSXApplication()<br>@@ -21,15 +24,6 @@<br> quit_item.hide()<br><br> macapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 1)<br>-<br>- print "setting up dock"<br>- dockmenu = gtk.Menu()<br>- quit_item = gtk.MenuItem("Disconnect")<br>- quit_item.connect("activate", gtk.main_quit)<br>- dockmenu.add(quit_item)<br>- dockmenu.show_all()<br>- macapp.set_dock_menu(dockmenu)<br>-<br> macapp.connect("NSApplicationBlockTermination", quit)<br> def active(*args):<br> print "active"<br>@@ -37,7 +31,17 @@<br> print "inactive"<br> macapp.connect("NSApplicationDidBecomeActive", active)<br> macapp.connect("NSApplicationWillResignActive", inactive)<br>- macapp.ready()<br>+ return macapp<br>+<br>+macapp = setup_macdock()<br>+<br>+print "setting up dock"<br>+dockmenu = gtk.Menu()<br>+quit_item = gtk.MenuItem("Disconnect")<br>+quit_item.connect("activate", disconnect_cb)<br>+dockmenu.add(quit_item)<br>+dockmenu.show_all()<br>+macapp.set_dock_menu(dockmenu)<br><br>-setup_macdock()<br>+macapp.ready()<br>gtk.main()<br><br>It works.<br><br>BTW, you shouldn't connect "quit" to NSApplicationBlockTermination. You should either not connect anything to it or you should connect a function that returns a boolean (which should be False if you want it to quit). The simplest way is to connect "lambda foo: False". <br><br>I never saw an "Application Not Responding" in the Dock menu, though, even with your original version.<br><br>Regards,<br>John Ralls<br><br></body></html> |