GNOME Bugzilla – Bug 336841
make gmenu usable for alacarte
Last modified: 2006-05-08 08:53:42 UTC
That bug has been opened on https://launchpad.net/distros/ubuntu/+source/gnome-menus/+bug/36523 "This patch adds gmenu_tree_entry_get_terminal() with python binding and exposes the is_nodisplay() method and FLAGS_INCLUDE_NODISPLAY flag in the python bindings. This is needed for alacarte to use gmenu. ... http://librarian.launchpad.net/1848628/expose_more_python.diff this patch adds the python bits" Patch by Travis Watkins <alleykat@gmail.com>
Created attachment 62546 [details] [review] Patch by Travis Watkins <alleykat@gmail.com>
Created attachment 62550 [details] [review] get_terminal() This patch needs to be applied before the python one.
Patch looks fine, but I'm a little curious why you want to expose this flag in the API. The idea is that we don't expose every item from the .desktop files in the gnome-menus API - we only expose the the items for which you need to know the value of across *all* entries in the menus. What are you going to use it for? I think I'd prefer get_launch_in_terminal() even though it's a bit long Apart from that, just need to fix the alignment of the prototypes in the headers
I'm using the flag to show non-visible menu items in alacarte. Old versions of alacarte (and some distros) use NoDisplay to hide menu items instead of <Exclude> so there needs to be a way to get these. The get_terminal() method is needed to show in the menu item properties (as it can be changed).
Right, so you only use get_terminal() when you want to show the properties of a menu item? i.e. you only use the value of get_terminal() for those items which someone looks at the properties of ... My thinking was that for details like this you'd use a desktop file parser to parse the file (returned by get_desktop_file_path()) - e.g. the panel does this when you click on a menu entry. I guess it's silly to have to parse the desktop file for a single flag, though. So if this is the only additional bit you need, then we should probably add it. So ... - rename get_terminal() to get_launch_in_terminal() - fix alignment of prototypes in headers
Not quite sure what you mean about "fix alignment of prototypes in headers".
Created attachment 62693 [details] [review] try #2 This is a combination of the two patches with the new function name and (I hope) the spacing changes you wanted.
Any comments?
Created attachment 64412 [details] [review] gmenu_tree_directory_get_desktop_file_path Updated patch. Adds gmenu_tree_directory_get_desktop_file_path(), needed for editing .directory files. Would also like to have gmenu_tree_directory_get_desktop_file_id() but that looks to be too intrusive to add. I'm pretty sure the spacing is off again but I'm not sure what to do in this situation (line over 80 chars).
I applied the latest patch from http://bugzilla.gnome.org/show_bug.cgi?id=336841#c9 to gnome-menus on x86_64 and typing alacarte in gnome-terminal produces Segmentation fault. Same thing happens without the patched gnome-menus, alacarte just segfaults. I am using the latest alacarte 0.9 on SLAMD64 64bit distro with the latest 2.14.1 release of GNOME.
Do the menus themselves still work with the patch? Also, can you get a backtrace? I'm not doing anything that would cause problems with x86 vs amd64. Also, alacarte shouldn't segfault without this patch, it would just give a python traceback saying it can't find the new API. Sounds like something might be wrong with your python installation.
Looks good apart from various nitpicks. Please go ahead and commit after fixing them Line up variables names like the rest of the code: char *exec; + gboolean terminal; Broken indentation: +pygmenu_tree_directory_get_desktop_file_path (PyObject *self, + PyObject *args) Fix alignment of things here: { "get_icon", pygmenu_tree_directory_get_icon, METH_VARARGS }, + { "get_desktop_file_path", pygmenu_tree_directory_get_desktop_file_path, METH_VARARGS }, Do this: if (gmenu_tree_entry_get_launch_in_terminal (GMENU_TREE_ENTRY (entry->item)) retval = Py_True else retval = Py_False; instead of a single statement. Ditto in get_is_nodisplay()
In HEAD: 2006-05-05 Travis Watkins <alleykat@gmail.com> * libmenu/desktop-entries.[ch]: add desktop_entry_get_launch_in_terminal * libmenu/gmenu-tree.[ch]: add gmenu_tree_directory_get_desktop_file_path, gmenu_tree_entry_get_launch_in_terminal * python/gmenu.c: add pygmenu_tree_directory_get_desktop_file_path, pygmenu_tree_entry_get_launch_in_terminal, pygmenu_tree_entry_get_is_nodisplay, FLAGS_INCLUDE_NO_DISPLAY
(In reply to comment #11) > Do the menus themselves still work with the patch? Also, can you get a > backtrace? I'm not doing anything that would cause problems with x86 vs amd64. > Also, alacarte shouldn't segfault without this patch, it would just give a > python traceback saying it can't find the new API. Sounds like something might > be wrong with your python installation. > Yes, the menus work OK. How do i go about getting backtrace with python/gdb? Perhaps the python provided by the distro is improperly built? where do i look for a cause to narrow the problem? Here is two things i noticed with different versions of gnome-menus: 1. gnome-menus 2.14.0 + gmenu_tree_directory_get_desktop_file_path patch + alacarte 0.9 root@blaze:~/devel/tmp/PACKAGES# alacarte /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py: inconsistent use of tabs and spaces in indentation Segmentation fault strace alacarte shows: munmap(0x2afda6b6a000, 4096) = 0 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ 2. gnome-menus CVS HEAD + alacarte 0.9 root@blaze:~# alacarte Traceback (most recent call last):
+ Trace 68043
app = MainWindow(datadir, version, sys.argv)
self.editor = MenuEditor()
self.__loadMenus()
self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
name = tree.root.get_menu_id()
Tried with some debugging and this is what i got: root@blaze:~# python /usr/bin/alacarte > /usr/bin/alacarte(24)?() -> from Alacarte.MainWindow import MainWindow (Pdb) l 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 21 import sys 22 import pdb 23 pdb.set_trace() 24 -> from Alacarte.MainWindow import MainWindow 25 26 if __name__ == '__main__': 27 try: 28 from Alacarte import config 29 datadir = config.pkgdatadir (Pdb) p *** SyntaxError: <exceptions.SyntaxError instance at 0x2ae8a76536c8> (Pdb) s --Call-- > /usr/lib64/python2.4/site-packages/Alacarte/__init__.py(0)?() (Pdb) p *** SyntaxError: <exceptions.SyntaxError instance at 0x2ae8a76536c8> (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/__init__.py(0)?() (Pdb) l [EOF] (Pdb) p *** SyntaxError: <exceptions.SyntaxError instance at 0x2ae8a76536c8> (Pdb) n --Return-- > /usr/lib64/python2.4/site-packages/Alacarte/__init__.py(0)?()->None (Pdb) n --Call-- > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(19)?() -> import gtk, gtk.glade, gmenu, gobject (Pdb) l 14 # 15 # You should have received a copy of the GNU Library General Public 16 # License along with this library; if not, write to the Free Software 17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 -> import gtk, gtk.glade, gmenu, gobject 20 import cgi, os 21 import gettext 22 gettext.bindtextdomain('alacarte') 23 gettext.textdomain('alacarte') 24 gtk.glade.bindtextdomain('alacarte') (Pdb) s > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(19)?() -> import gtk, gtk.glade, gmenu, gobject (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(20)?() -> import cgi, os (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(21)?() -> import gettext (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(22)?() -> gettext.bindtextdomain('alacarte') (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(23)?() -> gettext.textdomain('alacarte') (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(24)?() -> gtk.glade.bindtextdomain('alacarte') (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(25)?() -> gtk.glade.textdomain('alacarte') (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(26)?() -> _ = gettext.gettext (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(27)?() -> from Alacarte.MenuEditor import MenuEditor (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(28)?() -> from Alacarte.DialogHandler import DialogHandler (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(29)?() -> from Alacarte import util (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(30)?() -> import time (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(32)?() -> class MainWindow: (Pdb) n --Return-- > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(32)?()->None -> class MainWindow: (Pdb) n > /usr/bin/alacarte(26)?() -> if __name__ == '__main__': (Pdb) n > /usr/bin/alacarte(27)?() -> try: (Pdb) n > /usr/bin/alacarte(28)?() -> from Alacarte import config (Pdb) n > /usr/bin/alacarte(29)?() -> datadir = config.pkgdatadir (Pdb) n > /usr/bin/alacarte(30)?() -> version = config.VERSION (Pdb) n > /usr/bin/alacarte(34)?() -> app = MainWindow(datadir, version, sys.argv) (Pdb) n > /usr/bin/alacarte(35)?() -> app.run() (Pdb) s --Call-- > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(125)run() -> def run(self): (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(126)run() -> self.loadMenus() (Pdb) n > /usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py(127)run() -> self.editor.applications.tree.add_monitor(self.menuChanged) (Pdb) n Segmentation fault
Odd, but neither alacarte nor this patch has anything to do with it. It's either another part of gnome-menus or your distro. Please open a new bug for this.