[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] KDE XML GUI ActionLists
From:       Gordon Tyler <gordon () doxxx ! net>
Date:       2003-04-22 3:14:18
[Download RAW message or body]

Hi all,

Continuing from my experiments with KDE's XML GUI stuff and popup menu's, I'm 
now trying to get ActionLists to work, but with no success.

In the attached ui.rc file, I have an ActionList defined in the "Open With..." 
submenu of File menu and in a popup menu. In the script, I'm attempting to 
update the contents of the ActionList with the following code (reformatted 
for email):

    def updateOpenWithActions(self, selectedFileItems):
        print "updateOpenWithActions"
        self.unplugActionList("file_open_with_list")
        self.openWithActions = []
        if len(selectedFileItems) == 1:
            fileItem = selectedFileItems[0]
            offers = KServiceTypeProfile.offers(fileItem.mimetype(), \
                    "Application")
            offers.sort(lambda x,y: cmp(x.preference(), y.preference()))
            for offer in offers:
                service = offer.service()
                print "updateOpenWithActions: service=%s, preference=%d" % \
                        (str(service.name()), offer.preference())
                action = KAction(service.name(), KShortcut(), \
                        self.fileOpenWith, None, "file_open_with_" + \
                        str(service.desktopEntryName()))
                self.openWithActions.append(action)
        self.plugActionList("file_open_with_list", self.openWithActions)

I've verified that the KActions are being created and added to the 
self.openWithActions list. However, when I run the scriptand open either of 
the menus that contain the ActionList, there are no items. No errors, just an 
empty menu.

Has anybody else used ActionLists in PyKDE?

Thanks,
Gordon

["finderui.rc" (text/plain)]

<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="finder" version="1">

    <MenuBar>
        <Menu name="file" noMerge="1"><text>&amp;File</text>
            <Action name="file_open"/>
            <Menu name="file_open_with"><text>Open &amp;With</text>
                <ActionList name="file_open_with_list"/>
                <Action name="file_open_with_choose"/>
            </Menu>
            <Separator/>
            <Action name="file_properties"/>
            <Separator/>
            <Action name="file_close_window"/>
        </Menu>
    </MenuBar>

    <Menu name="context">
        <Action name="file_open"/>
        <Menu name="file_open_with"><text>Open &amp;With</text>
            <ActionList name="file_open_with_list"/>
            <Action name="file_open_with_choose"/>
        </Menu>
        <Separator/>
        <Action name="file_properties"/>
    </Menu>

</kpartgui>

_______________________________________________
PyKDE mailing list    PyKDE@mats.gmd.de
http://mats.gmd.de/mailman/listinfo/pykde

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic