Revision 7f8678f11ddbdcb952362443dad1179b76a85810
sadrul at pidgin.im
sadrul at pidgin.im
Mon Mar 26 00:19:51 EDT 2007
o -----------------------------------------------------------------
| Revision: 7f8678f11ddbdcb952362443dad1179b76a85810
| Ancestor: b5335fc89e560b1c28b13cbe7ac6a7abb077762e
| Author: sadrul at pidgin.im
| Date: 2007-03-26T04:19:35
| Branch: im.pidgin.pidgin
|
| Added files:
| finch/libgnt/pygnt/Files.txt finch/libgnt/pygnt/README.txt
| finch/libgnt/pygnt/dbus-gnt finch/libgnt/pygnt/gendef.sh
| finch/libgnt/pygnt/gnt.override
| finch/libgnt/pygnt/gntmodule.c finch/libgnt/pygnt/test.py
| Added directories:
| finch/libgnt/pygnt
| Modified attrs:
| finch/libgnt/pygnt/dbus-gnt finch/libgnt/pygnt/gendef.sh
| finch/libgnt/pygnt/test.py
|
| ChangeLog:
|
| python bindings for libgnt. dbus-gnt is a gnt-ui (sort of) for gaim over dbus. It allows continuing with the currently opened conversations. pygnt/README.txt explains what to do. Use at your own risk.
|
| ============================================================
| --- finch/libgnt/pygnt/Files.txt 5838d1dec407797b417733d6a230bddd677dc341
| +++ finch/libgnt/pygnt/Files.txt 5838d1dec407797b417733d6a230bddd677dc341
| @@ -0,0 +1,6 @@
| +gendef.sh
| +gnt.override
| +Makefile
| +test.py
| +dbus-gnt
| +gntmodule.c
| ============================================================
| --- finch/libgnt/pygnt/README.txt 73bf414050774aa1f0d864959e05e5f9ab2d3bfb
| +++ finch/libgnt/pygnt/README.txt 73bf414050774aa1f0d864959e05e5f9ab2d3bfb
| @@ -0,0 +1,4 @@
| +Run these in sequence:
| +
| +./gendef.sh
| +make gnt.so
| ============================================================
| --- finch/libgnt/pygnt/dbus-gnt 6debd44131ca876b10b8ae8f3a9b908f3c94b4e1
| +++ finch/libgnt/pygnt/dbus-gnt 6debd44131ca876b10b8ae8f3a9b908f3c94b4e1
| @@ -0,0 +1,103 @@
| +#!/usr/bin/env python
| +
| +# This script requires Python 2.4 and pygnt bindings
| +#
| +# Note that all function names are resolved dynamically, no
| +# purple-specific library is needed.
| +
| +import dbus
| +import dbus.glib
| +import dbus.decorators
| +import gobject
| +import os
| +import gnt
| +
| +from time import strftime
| +
| +convwins = {}
| +
| +def buddysignedon():
| + pass
| +
| +def conv_closed(conv):
| + key = get_dict_key(conv)
| + stuff = convwins[key]
| + stuff[0].destroy()
| + convwins[key] = None
| +
| +def wrote_msg(account, who, msg, conv, flags):
| + stuff = show_conversation(conv)
| + tv = stuff[1]
| + tv.append_text_with_flags("\n", 0)
| + tv.append_text_with_flags(strftime("(%X) "), 8)
| + tv.append_text_with_flags(who + ": ", 1)
| + tv.append_text_with_flags(msg, 0)
| + tv.scroll(0)
| +
| +gnt.gnt_init()
| +
| +bus = dbus.SessionBus()
| +obj = bus.get_object("net.sf.purple.PurpleService", "/net/sf/purple/PurpleObject")
| +purple = dbus.Interface(obj, "net.sf.purple.PurpleInterface")
| +
| +bus.add_signal_receiver(buddysignedon,
| + dbus_interface = "net.sf.purple.PurpleInterface",
| + signal_name = "BuddySignedOn")
| +
| +bus.add_signal_receiver(wrote_msg,
| + dbus_interface = "net.sf.purple.PurpleInterface",
| + signal_name = "WroteImMsg")
| +
| +bus.add_signal_receiver(wrote_msg,
| + dbus_interface = "net.sf.purple.PurpleInterface",
| + signal_name = "WroteChatMsg")
| +
| +bus.add_signal_receiver(conv_closed,
| + dbus_interface = "net.sf.purple.PurpleInterface",
| + signal_name = "DeletingConversation")
| +
| +def get_dict_key(conv):
| + val = purple.PurpleConversationGetName(conv)
| + return val
| +
| +def send_im_cb(entry, key, conv):
| + if key[0] == '\r':
| + # XXX: do something about the / commands
| + type = purple.PurpleConversationGetType(conv)
| + if type == 1:
| + imdata = purple.PurpleConversationGetImData(conv)
| + purple.PurpleConvImSend(imdata, entry.get_text())
| + else:
| + chatdata = purple.PurpleConversationGetChatData(conv)
| + purple.PurpleConvChatSend(chatdata, entry.get_text())
| + entry.clear()
| +
| +def show_conversation(conv):
| + key = get_dict_key(conv)
| + if key in convwins:
| + return convwins[key]
| + win = gnt.Window()
| + vbox = gnt.Box(0, 1)
| + win.add_widget(vbox)
| + win.set_title(purple.PurpleConversationGetName(conv))
| + win.set_pad(0)
| + vbox.set_pad(0)
| + tv = gnt.TextView()
| + entry = gnt.Entry("")
| + vbox.add_widget(tv)
| + entry.set_size(40, 1)
| + vbox.add_widget(entry)
| + entry.connect("key_pressed", send_im_cb, conv)
| + tv.clear()
| + win.show()
| + convwins[key] = [win, tv, entry]
| + return convwins[key]
| +
| +convs = purple.PurpleGetConversations()
| +for conv in convs:
| + show_conversation(conv)
| +
| +gnt.gnt_main()
| +
| +gnt.gnt_quit()
| +
| ============================================================
| --- finch/libgnt/pygnt/gendef.sh 348731ecdffc02087ad6aa3b457ce43595d3b1ff
| +++ finch/libgnt/pygnt/gendef.sh 348731ecdffc02087ad6aa3b457ce43595d3b1ff
| @@ -0,0 +1,51 @@
| +#!/bin/sh
| +FILES="
| + gntwidget.h
| + gntbindable.h
| + gntbox.h
| + gntbutton.h
| + gntcheckbox.h
| + gntclipboard.h
| + gntcolors.h
| + gntcombobox.h
| + gntentry.h
| + gntfilesel.h
| + gntkeys.h
| + gntlabel.h
| + gntline.h
| + gntmarshal.h
| + gntmenu.h
| + gntmenuitem.h
| + gntmenuitemcheck.h
| + gntstyle.h
| + gnttextview.h
| + gnttree.h
| + gntutils.h
| + gntwindow.h
| + gntwm.h
| + gnt.h"
| +
| +# Generate the def file
| +rm gnt.def
| +for file in $FILES
| +do
| + python /usr/share/pygtk/2.0/codegen/h2def.py ../$file >> gnt.def
| +done
| +
| +# Remove the definitions about the enums
| +ENUMS="
| +GNT_TYPE_ALIGNMENT
| +GNT_TYPE_COLOR_TYPE
| +GNT_TYPE_MENU_TYPE
| +GNT_TYPE_STYLE
| +GNT_TYPE_KEY_PRESS_MODE
| +GNT_TYPE_ENTRY_FLAG
| +GNT_TYPE_TEXT_FORMAT_FLAGS
| +"
| +
| +for enum in $ENUMS
| +do
| + sed -ie s/^.*gtype-id\ \"$enum\".*$//g gnt.def
| +done
| +
| +
| ============================================================
| --- finch/libgnt/pygnt/gnt.override 04e09064b3f3c76cc54ef1fa1df308c39453d16f
| +++ finch/libgnt/pygnt/gnt.override 04e09064b3f3c76cc54ef1fa1df308c39453d16f
| @@ -0,0 +1,34 @@
| +%%
| +headers
| +#include <Python.h>
| +#include "pygobject.h"
| +#include "gnt.h"
| +#include "gntbindable.h"
| +#include "gntwidget.h"
| +#include "gntbox.h"
| +#include "gntbutton.h"
| +#include "gntcheckbox.h"
| +#include "gntcolors.h"
| +#include "gntcombobox.h"
| +#include "gntentry.h"
| +#include "gntfilesel.h"
| +#include "gntkeys.h"
| +#include "gntlabel.h"
| +#include "gntline.h"
| +#include "gntmenu.h"
| +#include "gntmenuitem.h"
| +#include "gntmenuitemcheck.h"
| +#include "gntstyle.h"
| +#include "gnttextview.h"
| +#include "gnttree.h"
| +#include "gntutils.h"
| +#include "gntwindow.h"
| +#include "gntwm.h"
| +%%
| +modulename gnt
| +%%
| +import gobject.GObject as PyGObject_Type
| +%%
| +ignore-glob
| + *_get_gtype
| +%%
| ============================================================
| --- finch/libgnt/pygnt/gntmodule.c 7bcb542fecc7da290e774de5d17f4340a1d628d3
| +++ finch/libgnt/pygnt/gntmodule.c 7bcb542fecc7da290e774de5d17f4340a1d628d3
| @@ -0,0 +1,22 @@
| +#include <pygobject.h>
| +
| +void gnt_register_classes (PyObject *d);
| +extern PyMethodDef gnt_functions[];
| +
| +DL_EXPORT(void)
| +initgnt(void)
| +{
| + PyObject *m, *d;
| +
| + init_pygobject ();
| +
| + m = Py_InitModule ("gnt", gnt_functions);
| + d = PyModule_GetDict (m);
| +
| + gnt_register_classes (d);
| +
| + if (PyErr_Occurred ()) {
| + Py_FatalError ("can't initialise module sad");
| + }
| +}
| +
| ============================================================
| --- finch/libgnt/pygnt/test.py 279fed43aab0b6f739f83f665772ee93afc0c389
| +++ finch/libgnt/pygnt/test.py 279fed43aab0b6f739f83f665772ee93afc0c389
| @@ -0,0 +1,26 @@
| +#!/usr/bin/python
| +import gnt
| +
| +def button_activate(button, entry):
| + entry.set_text("clicked!!!")
| +
| +gnt.gnt_init()
| +
| +win = gnt.Window()
| +
| +entry = gnt.Entry("")
| +
| +win.add_widget(entry)
| +win.set_title("Entry")
| +
| +button = gnt.Button("Click!")
| +win.add_widget(button)
| +
| +button.connect("activate", button_activate, entry)
| +
| +win.show()
| +
| +gnt.gnt_main()
| +
| +gnt.gnt_quit()
| +
To get the patch for this revision, please do this:
mtn log --last 1 --diffs --from 7f8678f11ddbdcb952362443dad1179b76a85810
More information about the Commits
mailing list