[Galago-commits] r2768 - in trunk/notify-python: . src tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Tue Apr 25 00:59:57 PDT 2006
Author: chipx86
Date: 2006-04-25 00:59:51 -0700 (Tue, 25 Apr 2006)
New Revision: 2768
Added:
trunk/notify-python/tests/test-basic.py
Modified:
trunk/notify-python/ChangeLog
trunk/notify-python/src/Makefile.am
trunk/notify-python/src/pynotify.defs
trunk/notify-python/src/pynotify.override
trunk/notify-python/src/pynotifymodule.c
trunk/notify-python/tests/Makefile.am
Log:
- Wrap the remaining function.
- Add a test program.
- Absolutely nothing works.
Modified: trunk/notify-python/ChangeLog
===================================================================
--- trunk/notify-python/ChangeLog 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/ChangeLog 2006-04-25 07:59:51 UTC (rev 2768)
@@ -1,3 +1,15 @@
+Tue Apr 25 00:59:18 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/Makefile.am:
+ * src/pynotify.defs:
+ * src/pynotifymodule.c:
+ * src/pynotify.override:
+ * tests/Makefile.am:
+ A tests/test-basic.py:
+ - Wrap the remaining function.
+ - Add a test program.
+ - Absolutely nothing works.
+
Mon Apr 24 23:39:55 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* src/Makefile.am:
Modified: trunk/notify-python/src/Makefile.am
===================================================================
--- trunk/notify-python/src/Makefile.am 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/src/Makefile.am 2006-04-25 07:59:51 UTC (rev 2768)
@@ -39,5 +39,8 @@
DEFHEADERS = $(wildcard $(includedir)/libnotify/*.h)
update-defs:
- @python $(datadir)/pygtk/2.0/codegen/h2def.py $(DEFHEADERS) > pynotify.defs
+ @python $(datadir)/pygtk/2.0/codegen/h2def.py $(DEFHEADERS) > pynotify.defs.tmp
+ @sed -e 's/define-function notify_\(init\|uninit\|is_\|get\)/define-function \1/g' \
+ pynotify.defs.tmp > pynotify.defs
+ @rm -f pynotify.defs.tmp
@echo Definitions updated
Modified: trunk/notify-python/src/pynotify.defs
===================================================================
--- trunk/notify-python/src/pynotify.defs 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/src/pynotify.defs 2006-04-25 07:59:51 UTC (rev 2768)
@@ -205,7 +205,7 @@
;; From /usr/include/libnotify/notify.h
-(define-function notify_init
+(define-function init
(c-name "notify_init")
(return-type "gboolean")
(parameters
@@ -213,27 +213,27 @@
)
)
-(define-function notify_uninit
+(define-function uninit
(c-name "notify_uninit")
(return-type "none")
)
-(define-function notify_is_initted
+(define-function is_initted
(c-name "notify_is_initted")
(return-type "gboolean")
)
-(define-function notify_get_app_name
+(define-function get_app_name
(c-name "notify_get_app_name")
(return-type "const-gchar*")
)
-(define-function notify_get_server_caps
+(define-function get_server_caps
(c-name "notify_get_server_caps")
(return-type "GList*")
)
-(define-function notify_get_server_info
+(define-function get_server_info
(c-name "notify_get_server_info")
(return-type "gboolean")
(parameters
Modified: trunk/notify-python/src/pynotify.override
===================================================================
--- trunk/notify-python/src/pynotify.override 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/src/pynotify.override 2006-04-25 07:59:51 UTC (rev 2768)
@@ -4,6 +4,14 @@
#include <libnotify/notify.h>
#include "pygobject.h"
+typedef struct
+{
+ PyGObject *notification;
+ PyObject *callback;
+ PyObject *user_data;
+
+} ActionCbData;
+
static PyObject *
pygalago_wrap_gobj_list(GList *list)
{
@@ -64,6 +72,24 @@
return items;
}
+
+static void
+_notify_action_cb(NotifyNotification *n, const char *action,
+ ActionCbData *data)
+{
+ PyObject *args;
+
+ args = Py_BuildValue("OsO", data->notification, action, data->user_data);
+ PyEval_CallObject(data->callback, args);
+ Py_DECREF(args);
+}
+
+static void
+_action_cb_data_destroy(ActionCbData *data)
+{
+ Py_DECREF(data->callback);
+ g_free(data);
+}
%%
modulename pynotify
%%
@@ -74,6 +100,67 @@
ignore-glob
*_get_type
%%
+override notify_notification_add_action kwargs
+static PyObject *
+_wrap_notify_notification_add_action(PyGObject *self, PyObject *args,
+ PyObject *kwargs)
+{
+ static char *kwlist[] = { "action", "label", "func", "user_data", NULL };
+ ActionCbData *action_cb_data;
+ PyObject *first, *callback, *user_data;
+ char *action;
+ char *label;
+ size_t len;
+
+ len = PyTuple_Size(args);
+
+ if (len < 3)
+ {
+ PyErr_SetString(PyExc_TypeError,
+ "NotifyNotification.add_action requires at least "
+ "3 arguments");
+ return NULL;
+ }
+
+ first = PySequence_GetSlice(args, 0, 2);
+
+ if (!PyArg_ParseTuple(first, "ssO:NotifyNotification.add_action",
+ &action, &label, &callback))
+ {
+ Py_DECREF(first);
+ return NULL;
+ }
+
+ Py_DECREF(first);
+
+ if (!PyCallable_Check(callback))
+ {
+ PyErr_SetString(PyExc_TypeError, "third argument must be callable");
+ return NULL;
+ }
+
+ user_data = PySequence_GetSlice(args, 3, len);
+
+ if (user_data == NULL)
+ return NULL;
+
+ action_cb_data = g_new0(ActionCbData, 1);
+ action_cb_data->callback = callback;
+ action_cb_data->user_data = user_data;
+ action_cb_data->notification = self;
+
+ Py_INCREF(callback);
+
+ notify_notification_add_action(NOTIFY_NOTIFICATION(self->obj),
+ action, label,
+ NOTIFY_ACTION_CALLBACK(_notify_action_cb),
+ action_cb_data,
+ (GFreeFunc)_action_cb_data_destroy);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
override notify_get_server_caps
static PyObject *
_wrap_notify_get_server_caps(PyObject *self)
Modified: trunk/notify-python/src/pynotifymodule.c
===================================================================
--- trunk/notify-python/src/pynotifymodule.c 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/src/pynotifymodule.c 2006-04-25 07:59:51 UTC (rev 2768)
@@ -1,7 +1,7 @@
#include <pygobject.h>
void pynotify_register_classes(PyObject *d);
-extern PyMethodDef pynotify_functions[];
+extern PyMethodDef pypynotify_functions[];
DL_EXPORT(void)
init_pynotify(void)
@@ -10,11 +10,11 @@
init_pygobject();
- m = Py_InitModule("pynotify._pynotify", pynotify_functions);
+ m = Py_InitModule("pynotify._pynotify", pypynotify_functions);
d = PyModule_GetDict(m);
- pynotify_register_classes(d);
- pynotify_add_constants(m, "NOTIFY_");
+ pypynotify_register_classes(d);
+ pypynotify_add_constants(m, "NOTIFY_");
if (PyErr_Occurred()) {
Py_FatalError("can't initialize module pynotify");
Modified: trunk/notify-python/tests/Makefile.am
===================================================================
--- trunk/notify-python/tests/Makefile.am 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/tests/Makefile.am 2006-04-25 07:59:51 UTC (rev 2768)
@@ -1 +1,2 @@
-EXTRA_DIST =
+EXTRA_DIST = \
+ test-basic.py
Added: trunk/notify-python/tests/test-basic.py
===================================================================
--- trunk/notify-python/tests/test-basic.py 2006-04-25 06:40:48 UTC (rev 2767)
+++ trunk/notify-python/tests/test-basic.py 2006-04-25 07:59:51 UTC (rev 2768)
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+import pygtk
+pygtk.require('2.0')
+import pynotify
+import sys
+
+if __name__ == '__main__':
+ if not pynotify.init("Basics"):
+ sys.exit(1)
+
+ n = pynotify.Notification("Summary", "This is some sample content",
+ None, None)
+
+ if not n.show(None):
+ print "Failed to send notification"
+ sys.exit(1)
Property changes on: trunk/notify-python/tests/test-basic.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the galago-commits
mailing list