pygtk r3042 - in trunk: . gtk
- From: paulp svn gnome org
- To: svn-commits-list gnome org
- Subject: pygtk r3042 - in trunk: . gtk
- Date: Thu, 11 Sep 2008 19:42:27 +0000 (UTC)
Author: paulp
Date: Thu Sep 11 19:42:26 2008
New Revision: 3042
URL: http://svn.gnome.org/viewvc/pygtk?rev=3042&view=rev
Log:
2008-09-11 Michiel de Hoon <mjldehoon yahoo com>
Bug 524327 â Interactive PyGTK
* gtk/gtk.override (_main_quit, _loop, _wrap_set_interactive): New
functions.
* gtk/__init__.py: Make PyGTK interactive.
Modified:
trunk/ChangeLog
trunk/gtk/__init__.py
trunk/gtk/gtk.override
Modified: trunk/gtk/__init__.py
==============================================================================
--- trunk/gtk/__init__.py (original)
+++ trunk/gtk/__init__.py Thu Sep 11 19:42:26 2008
@@ -138,6 +138,9 @@
# everything above
from gtk._gtk import *
+# Make PyGTK interactive
+set_interactive(1)
+
# # For testing, so you can just turn off dynamicnamespace in gtk.override
# if hasattr(_gtk, '_get_symbol_names'):
# import gtk
Modified: trunk/gtk/gtk.override
==============================================================================
--- trunk/gtk/gtk.override (original)
+++ trunk/gtk/gtk.override Thu Sep 11 19:42:26 2008
@@ -104,6 +104,31 @@
return TRUE;
}
+static gboolean
+_main_quit(GIOChannel* source, GIOCondition condition, gpointer data)
+{
+ gtk_main_quit();
+ return FALSE;
+}
+
+static int _loop(void)
+{
+ PyGILState_STATE gstate;
+ GIOChannel* channel;
+
+ /* Watch for input on stdin */
+ channel = g_io_channel_unix_new(fileno(stdin));
+ g_io_add_watch(channel, G_IO_IN, _main_quit, NULL);
+ g_io_channel_unref(channel);
+
+ /* Start the main loop */
+ gstate = PyGILState_Ensure();
+ gtk_main();
+ PyGILState_Release(gstate);
+
+ return 0;
+}
+
%%
include
gtkbuilder.override
@@ -437,6 +462,31 @@
return Py_None;
}
%%
+define set_interactive
+static PyObject *
+_wrap_set_interactive(PyGObject *self, PyObject *args)
+{
+ int flag = 1;
+ if (!PyArg_ParseTuple(args, "|i", &flag)) return NULL;
+ if (flag)
+ {
+ if (PyOS_InputHook == NULL) {
+ PyOS_InputHook = _loop;
+ }
+ else if (PyOS_InputHook != _loop)
+ PyErr_Warn(PyExc_RuntimeWarning, "PyOS_InputHook is not available for interactive use of PyGTK");
+ }
+ else
+ {
+ if (PyOS_InputHook == _loop)
+ PyOS_InputHook = NULL;
+ else if (PyOS_InputHook != NULL)
+ PyErr_Warn(PyExc_RuntimeWarning, "PyOS_InputHook was set by a module other than PyGTK");
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+%%
define add_log_handlers
static PyObject *
_wrap_add_log_handlers(PyGObject *self, PyObject *args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]