0

我最近开始用 Python 编程并为 Pidgin 制作脚本/插件,我需要访问PurpleConversationUiOps并使用 has_focus字段,基于 Pidgin 文档中的一些示例,我做了这个:

    #!/usr/bin/env python
    import dbus, gobject
    from dbus.mainloop.glib import DBusGMainLoop

    def view(conv):
     if conv == 1: #if has focus
       print "Has Focus"

    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    bus.add_signal_receiver(view,
                    dbus_interface="im.pidgin.purple.PurpleConversationUiOps",
                    signal_name="HasFocus")
    loop = gobject.MainLoop()
    loop.run()

他没有给出错误,但我没有收到任何信号,那么我如何访问 has_focus 字段?

4

1 回答 1

0

我已经用 d-feet 检查了我的 Pidgin 2.10.0 并且只有一个界面, im.pidgin.purple.PurpleInterface. 您正在寻找的 API 似乎是 method (not signal) PurpleConversationHasFocus(int32 conv) -> int32

要获得对话,有PurpleGetConversations -> Array of int32或 信号ConversationCreated(int32)

$ dbus-send --print-reply --dest=im.pidgin.purple.PurpleService  /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleGetConversations
method return sender=:1.165 -> dest=:1.172 reply_serial=2
   array [
      int32 22042
   ]
$ dbus-send --print-reply --dest=im.pidgin.purple.PurpleService  /im/pidgin/purple/PurpleObject im.pidgin.purple.PurpleInterface.PurpleConversationHasFocus int32:22042
method return sender=:1.165 -> dest=:1.174 reply_serial=2
   int32 0
于 2012-10-12T16:05:50.457 回答