After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 336841 - make gmenu usable for alacarte
make gmenu usable for alacarte
Status: RESOLVED FIXED
Product: gnome-menus
Classification: Core
Component: general
2.13.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-menus dummy account
gnome-menus dummy account
Depends on:
Blocks:
 
 
Reported: 2006-04-01 14:55 UTC by Sebastien Bacher
Modified: 2006-05-08 08:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch by Travis Watkins <alleykat@gmail.com> (3.63 KB, patch)
2006-04-01 14:56 UTC, Sebastien Bacher
needs-work Details | Review
get_terminal() (3.44 KB, patch)
2006-04-01 15:32 UTC, Travis Watkins
needs-work Details | Review
try #2 (9.32 KB, patch)
2006-04-03 19:23 UTC, Travis Watkins
none Details | Review
gmenu_tree_directory_get_desktop_file_path (12.19 KB, patch)
2006-04-27 18:42 UTC, Travis Watkins
accepted-commit_now Details | Review

Description Sebastien Bacher 2006-04-01 14:55:41 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>
Comment 1 Sebastien Bacher 2006-04-01 14:56:34 UTC
Created attachment 62546 [details] [review]
Patch by Travis Watkins <alleykat@gmail.com>
Comment 2 Travis Watkins 2006-04-01 15:32:02 UTC
Created attachment 62550 [details] [review]
get_terminal()

This patch needs to be applied before the python one.
Comment 3 Mark McLoughlin 2006-04-02 14:31:18 UTC
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
Comment 4 Travis Watkins 2006-04-02 17:19:15 UTC
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).
Comment 5 Mark McLoughlin 2006-04-02 17:58:42 UTC
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
Comment 6 Travis Watkins 2006-04-02 19:23:17 UTC
Not quite sure what you mean about "fix alignment of prototypes in headers".
Comment 7 Travis Watkins 2006-04-03 19:23:28 UTC
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.
Comment 8 Travis Watkins 2006-04-05 19:29:14 UTC
Any comments?
Comment 9 Travis Watkins 2006-04-27 18:42:14 UTC
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).
Comment 10 Paul Blazejowski 2006-04-29 20:12:39 UTC
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.
Comment 11 Travis Watkins 2006-04-29 20:29:49 UTC
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.
Comment 12 Mark McLoughlin 2006-05-04 18:49:02 UTC
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()
Comment 13 Travis Watkins 2006-05-05 15:30:06 UTC
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
Comment 14 Paul Blazejowski 2006-05-05 18:20:58 UTC
(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):
  • File "/usr/bin/alacarte", line 32 in ?
    app = MainWindow(datadir, version, sys.argv)
  • File "/usr/lib64/python2.4/site-packages/Alacarte/MainWindow.py", line 45 in __init__
    self.editor = MenuEditor()
  • File "/usr/lib64/python2.4/site-packages/Alacarte/MenuEditor.py", line 32 in __init__
    self.__loadMenus()
  • File "/usr/lib64/python2.4/site-packages/Alacarte/MenuEditor.py", line 40 in __loadMenus
    self.applications.dom = xml.dom.minidom.parseString(util.getUserMenuXml(self.applications.tree))
  • File "/usr/lib64/python2.4/site-packages/Alacarte/util.py", line 157 in getUserMenuXml
    name = tree.root.get_menu_id()
AttributeError: 'NoneType' object has no attribute '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
Comment 15 Travis Watkins 2006-05-05 18:37:35 UTC
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.