[Galago-commits] r2772 - in trunk/notify-python: . src tests
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Tue Apr 25 02:06:47 PDT 2006
Author: chipx86
Date: 2006-04-25 02:06:44 -0700 (Tue, 25 Apr 2006)
New Revision: 2772
Added:
trunk/notify-python/tests/test-multi-actions.py
Modified:
trunk/notify-python/ChangeLog
trunk/notify-python/src/pynotify.override
trunk/notify-python/tests/Makefile.am
Log:
Get action support working. We may be leaking a reference, though, I can't really tell. Oh, and test-multi-actions cannot quit from inside an action handler. Huh.
Modified: trunk/notify-python/ChangeLog
===================================================================
--- trunk/notify-python/ChangeLog 2006-04-25 08:48:00 UTC (rev 2771)
+++ trunk/notify-python/ChangeLog 2006-04-25 09:06:44 UTC (rev 2772)
@@ -1,3 +1,12 @@
+Tue Apr 25 02:06:08 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/pynotify.override:
+ A tests/test-multi-actions.py:
+ * tests/Makefile.am:
+ - Get action support working. We may be leaking a reference, though,
+ I can't really tell. Oh, and test-multi-actions cannot quit from
+ inside an action handler. Huh.
+
Tue Apr 25 01:47:17 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* src/Makefile.am:
Modified: trunk/notify-python/src/pynotify.override
===================================================================
--- trunk/notify-python/src/pynotify.override 2006-04-25 08:48:00 UTC (rev 2771)
+++ trunk/notify-python/src/pynotify.override 2006-04-25 09:06:44 UTC (rev 2772)
@@ -107,7 +107,18 @@
{
PyObject *args;
- args = Py_BuildValue("OsO", data->notification, action, data->user_data);
+ if (data->user_data == Py_None)
+ {
+ printf("Case 1\n");
+ args = Py_BuildValue("Os", data->notification, action);
+ }
+ else
+ {
+ printf("Case 2\n");
+ args = Py_BuildValue("OsO", data->notification, action,
+ data->user_data);
+ }
+
PyEval_CallObject(data->callback, args);
Py_DECREF(args);
}
@@ -133,7 +144,6 @@
_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;
@@ -150,7 +160,7 @@
return NULL;
}
- first = PySequence_GetSlice(args, 0, 2);
+ first = PySequence_GetSlice(args, 0, 3);
if (!PyArg_ParseTuple(first, "ssO:NotifyNotification.add_action",
&action, &label, &callback))
@@ -167,11 +177,20 @@
return NULL;
}
- user_data = PySequence_GetSlice(args, 3, len);
+ first = PySequence_GetSlice(args, 3, len);
- if (user_data == NULL)
+ if (first == NULL)
return NULL;
+ if (!PyArg_ParseTuple(first, "O:NotifyNotification.add_action",
+ &user_data))
+ {
+ Py_INCREF(Py_None);
+ user_data = Py_None;
+ }
+
+ Py_DECREF(first);
+
action_cb_data = g_new0(ActionCbData, 1);
action_cb_data->callback = callback;
action_cb_data->user_data = user_data;
Modified: trunk/notify-python/tests/Makefile.am
===================================================================
--- trunk/notify-python/tests/Makefile.am 2006-04-25 08:48:00 UTC (rev 2771)
+++ trunk/notify-python/tests/Makefile.am 2006-04-25 09:06:44 UTC (rev 2772)
@@ -1,6 +1,7 @@
EXTRA_DIST = \
test-basic.py \
test-markup.py \
+ test-multi-actions.py \
test-replace.py \
test-server-info.py \
test-urgency.py \
Added: trunk/notify-python/tests/test-multi-actions.py
===================================================================
--- trunk/notify-python/tests/test-multi-actions.py 2006-04-25 08:48:00 UTC (rev 2771)
+++ trunk/notify-python/tests/test-multi-actions.py 2006-04-25 09:06:44 UTC (rev 2772)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import pynotify
+import sys
+
+def help_cb(n, action):
+ assert action == "help"
+ print "You clicked Help"
+ n.close()
+ sys.exit(0)
+
+def ignore_cb(n, action):
+ assert action == "ignore"
+ print "You clicked Ignore"
+ n.close()
+ sys.exit(0)
+
+def empty_cb(n, action):
+ assert action == "empty"
+ print "You clicked Empty Trash"
+ n.close()
+ sys.exit(0)
+
+if __name__ == '__main__':
+ if not pynotify.init("Multi Action Test"):
+ sys.exit(1)
+
+ n = pynotify.Notification("Low disk space",
+ "You can free up some disk space by " +
+ "emptying the trash can.")
+ n.set_urgency(pynotify.URGENCY_CRITICAL)
+ n.set_category("device")
+ n.add_action("help", "Help", help_cb)
+ n.add_action("ignore", "Ignore", ignore_cb)
+ n.add_action("empty", "Empty Trash", empty_cb)
+
+ if not n.show():
+ print "Failed to send notification"
+ sys.exit(1)
+
+ gtk.main()
Property changes on: trunk/notify-python/tests/test-multi-actions.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the galago-commits
mailing list