[Xfce4-commits] <thunarx-python:master> Added python libs code and initializing python code
Adam Plumb
noreply at xfce.org
Thu May 27 18:10:20 CEST 2010
Updating branch refs/heads/master
to 58591584187668cc8fdc57feb23d468870354a1f (commit)
from aa90e2535d5a7bad0987373b36bf5e124d148a90 (commit)
commit 58591584187668cc8fdc57feb23d468870354a1f
Author: Adam Plumb <adamplumb at gmail.com>
Date: Wed Dec 9 10:31:50 2009 -0500
Added python libs code and initializing python code
configure.ac.in | 6 +++++
src/Makefile.am | 6 +++-
src/thunarx-python.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++---
src/txp-provider.c | 11 ---------
4 files changed, 67 insertions(+), 17 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index 452910d..e5a63ef 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -72,6 +72,12 @@ XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.6.0])
+PYTHON_CFLAGS="`python-config --includes`"
+PYTHON_LIBS="`python-config --ldflags`"
+
+AC_SUBST(PYTHON_CFLAGS)
+AC_SUBST(PYTHON_LIBS)
+
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
diff --git a/src/Makefile.am b/src/Makefile.am
index 6aa92d5..d465e5a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,8 @@ thunarx_python_la_CFLAGS = \
$(PLATFORM_CFLAGS) \
$(THUNARX_CFLAGS) \
$(EXO_CFLAGS) \
- $(LIBXFCE4UTIL_CFLAGS)
+ $(LIBXFCE4UTIL_CFLAGS) \
+ $(PYTHON_CFLAGS)
thunarx_python_la_LDFLAGS = \
-avoid-version \
@@ -32,6 +33,7 @@ thunarx_python_la_LDFLAGS = \
$(PLATFORM_LDFLAGS) \
$(THUNARX_LDFLAGS) \
$(EXO_LDFLAGS) \
- $(LIBXFCE4UTIL_LDFLAGS)
+ $(LIBXFCE4UTIL_LDFLAGS) \
+ $(PYTHON_LIBS)
# vi:set ts=8 sw=8 noet ai nocindent:
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index 69dbf2c..ac4bece 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -21,6 +21,8 @@
#include <config.h>
#endif
+#include <Python.h>
+
#include <exo/exo.h>
#include <txp-provider.h>
@@ -29,11 +31,59 @@
static GType type_list[1];
-
-
/* delcare it here to make the compiler happy */
G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+static gboolean thunarx_python_init_python (void);
+
+
+static gboolean
+thunarx_python_init_python (void)
+{
+ GModule *libpython;
+ char *argv[] = { "thunarx", NULL };
+
+ g_print("thunarx_python_init_python\n");
+
+ if (Py_IsInitialized())
+ return TRUE;
+
+ g_print ("g_module_open libpython\n");
+ libpython = g_module_open ("/usr/lib/libpython2.6.so", 0);
+ if (!libpython)
+ g_warning ("g_module_open libpython failed: %s\n", g_module_error());
+
+ g_print ("Py_Initialize\n");
+ Py_Initialize();
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ g_print ("PySys_SetArgv\n");
+ PySys_SetArgv (1, argv);
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+static void
+thunarx_python_load_dir (const gchar *dirname)
+{
+ if(thunarx_python_init_python())
+ g_print ("python loaded\n");
+ else
+ g_print ("python not loaded\n");
+}
+
+
G_MODULE_EXPORT void
thunar_extension_initialize (ThunarxProviderPlugin *plugin)
{
@@ -48,7 +98,7 @@ thunar_extension_initialize (ThunarxProviderPlugin *plugin)
}
#ifdef G_ENABLE_DEBUG
- g_message ("Initializing thunar-vcs-plugin extension");
+ g_message ("Initializing thunarx-python extension");
#endif
/* register the types provided by this plugin */
@@ -67,8 +117,11 @@ G_MODULE_EXPORT void
thunar_extension_shutdown (void)
{
#ifdef G_ENABLE_DEBUG
- g_message ("Shutting down thunar-vcs-plugin extension");
+ g_message ("Shutting down thunarx-python extension");
#endif
+
+ if (Py_IsInitialized())
+ Py_Finalize();
}
diff --git a/src/txp-provider.c b/src/txp-provider.c
index c21bdca..e61dc11 100644
--- a/src/txp-provider.c
+++ b/src/txp-provider.c
@@ -107,17 +107,6 @@ txp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
GList *files)
{
GList *actions = NULL;
- GtkWidget *action = NULL;
-
- action = g_object_new (GTK_TYPE_ACTION,
- "name", "Txp::testitem1",
- "icon-name", NULL,
- "label", "TEST ITEM 1",
- NULL);
- g_signal_connect (action, "activate", NULL, NULL);
-
- actions = g_list_append (actions, action);
-
return actions;
}
More information about the Xfce4-commits
mailing list