[Xfce4-commits] [bindings/thunarx-python] 01/03: Updated to use gobject instrospection and new thunarx menu items
noreply at xfce.org
noreply at xfce.org
Thu Nov 30 03:31:19 CET 2017
This is an automated email from the git hooks/post-receive script.
a d a m p l u m b p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository bindings/thunarx-python.
commit a54a7e7cf6f8e9c752f67e775ac07fbd01e56dc5
Author: Adam Plumb <adamplumb at gmail.com>
Date: Wed Nov 22 08:12:36 2017 -0500
Updated to use gobject instrospection and new thunarx menu items
---
INSTALL | 19 +-
NEWS | 4 +
README | 11 +-
configure.ac.in | 58 +---
examples/thunarx-menu-plugin.py | 21 +-
examples/thunarx-preferences-plugin.py | 37 ++-
examples/thunarx-property-page-plugin.py | 27 +-
examples/thunarx-renamer-plugin.py | 20 +-
examples/thunarx-submenu-plugin.py | 84 +++---
src/Makefile.am | 51 +---
src/thunarx-python-object.c | 40 +--
src/thunarx-python.c | 155 ++---------
src/thunarx-python.h | 9 +-
src/thunarx.defs | 453 -------------------------------
src/thunarx.override | 412 ----------------------------
src/thunarxmodule.c | 60 ----
16 files changed, 179 insertions(+), 1282 deletions(-)
diff --git a/INSTALL b/INSTALL
index 7d1c323..2099840 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,8 +1,8 @@
Installation Instructions
*************************
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
+Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
@@ -12,8 +12,8 @@ without warranty of any kind.
Basic Installation
==================
- Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package. The following
+ Briefly, the shell command `./configure && make && make install'
+should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
@@ -226,6 +226,11 @@ order to use an ANSI C compiler:
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+ HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved. Use GNU `make'
+instead.
+
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
@@ -304,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug. Until the bug is fixed you can use this workaround:
+an Autoconf limitation. Until the limitation is lifted, you can use
+this workaround:
- CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+ CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
@@ -362,4 +368,3 @@ operates.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
-
diff --git a/NEWS b/NEWS
index 1cb3291..5ac3b71 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+1.0.0:
+ - Updated to work with Thunarx-3 which requires uses gobject introspection
+ and required Gtk+3 and PyGObject3.
+
0.3.0:
- Look for python extensions in $XDG_DATA_DIR/thunarx-python/extensions now. No longer look in /usr/lib/thunarx-1/python.
- Fix PyCapsule support for the pygobject module
diff --git a/README b/README
index ce120da..b70ad42 100644
--- a/README
+++ b/README
@@ -1,6 +1,8 @@
Thunarx Python Bindings
-These bindings allow one to create python plugins for Thunar.
+These bindings allow one to create python plugins for Thunar. As of v1.0.0
+the bindings will only work with Gtk+3 and the version of Thunar that supports Gtk+3. To use these
+with Gtk+2, using v0.3.0 of the bindings.
Install
-----------
@@ -24,10 +26,9 @@ set to). Simply copy your python scripts into that folder and restart thunar.
Dependencies
------------
- * thunar (0.4.0 or later)
- * pygtk (2.6.0 or later)
- * pygobject (2.6.0 or later)
- * gnome-python (2.12.0 or later)
+ * thunar (1.6.0 or later)
+ * pygobject (3.20.0 or later)
+ * gtk+3 (3.20.0 or later)
Debugging
-----------
diff --git a/configure.ac.in b/configure.ac.in
index c920c18..3cd4a9a 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -1,6 +1,6 @@
dnl $Id: configure.in.in 2439 2007-01-20 10:41:39Z benny $
dnl
-dnl Copyright (c) 2006-2009
+dnl Copyright (c) 2006-2017
dnl The Thunar development team. All rights reserved.
dnl
dnl Originally written for Thunar by Benedikt Meurer <benny at xfce.org>.
@@ -21,7 +21,7 @@ m4_define([txp_version], [txp_version_major().txp_version_minor().txp_version_mi
dnl ***************************
dnl *** Initialize autoconf ***
dnl ***************************
-AC_COPYRIGHT([Copyright (c) 2010 Adam Plumb <adamplumb at gmail.com>.])
+AC_COPYRIGHT([Copyright (c) 2017 Adam Plumb <adamplumb at gmail.com>.])
AC_INIT([thunarx-python], [txp_version], [thunar-dev at xfce.org])
AC_PREREQ([2.50])
AC_CANONICAL_TARGET()
@@ -56,8 +56,8 @@ AM_PROG_CC_C_O()
dnl **************************
dnl *** Initialize libtool ***
dnl **************************
-AC_DISABLE_STATIC()
-AC_PROG_LIBTOOL()
+LT_PREREQ([2.4])
+LT_INIT([disable-static])
dnl **************************************************
@@ -72,27 +72,20 @@ GTK_DOC_CHECK(1.9)
dnl ***************************
dnl *** Determine the installed thunarx version ***
dnl ***************************
-if test "`pkg-config --variable prefix thunarx-2`" != ""; then
- THUNARX_API_VERSION=2
- prefix=`pkg-config --variable prefix thunarx-2`
- XDT_CHECK_PACKAGE([THUNARX], [thunarx-2], [1.1.0])
+if test "`pkg-config --variable prefix thunarx-3`" != ""; then
+ THUNARX_API_VERSION=3
+ prefix=`pkg-config --variable prefix thunarx-3`
+ XDT_CHECK_PACKAGE([THUNARX], [thunarx-3], [1.6.0])
+
+ XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.20.0])
+ XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.30.0])
+ XDT_CHECK_PACKAGE([PYGOBJECT], [pygobject-3.0], [3.20.0])
else
- THUNARX_API_VERSION=1
- prefix=`pkg-config --variable prefix thunarx-1`
- XDT_CHECK_PACKAGE([THUNARX], [thunarx-1], [0.4.0])
+ echo "thunarx-3 is required";
+ exit 1;
fi
AC_SUBST(THUNARX_API_VERSION)
-
-dnl ***********************************
-dnl *** Check for required packages ***
-dnl ***********************************
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([PYGTK], [pygtk-2.0], [2.6.0])
-XDT_CHECK_PACKAGE([PYGOBJECT], [pygobject-2.0], [2.16.0])
-
PYTHON_CFLAGS="`python-config --includes`"
PYTHON_LIBS="`python-config --libs`"
PYTHON_LDFLAGS="`python-config --ldflags`"
@@ -105,29 +98,6 @@ THUNARX_LIBDIR=`pkg-config --variable=libdir thunarx-${THUNARX_API_VERSION}`
AC_SUBST(THUNARX_LIBDIR)
AC_DEFINE_UNQUOTED(THUNARX_LIBDIR, "$THUNARX_LIBDIR", [Thunarx libdir])
-AC_MSG_CHECKING(for pygtk defs)
-PYGTK_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygtk-2.0`
-AC_SUBST(PYGTK_DEFSDIR)
-AC_MSG_RESULT($PYGTK_DEFSDIR)
-
-AC_MSG_CHECKING(for pygobject defs)
-PYGOBJECT_DEFSDIR=`$PKG_CONFIG --variable=defsdir pygobject-2.0`
-AC_SUBST(PYGOBJECT_DEFSDIR)
-AC_MSG_RESULT($PYGOBJECT_DEFSDIR)
-
-AC_MSG_CHECKING(for pygtk codegen)
-PYGTK_CODEGEN="/usr/bin/python `$PKG_CONFIG --variable=codegendir pygobject-2.0`/codegen.py"
-AC_SUBST(PYGTK_CODEGEN)
-AC_MSG_RESULT($PYGTK_CODEGEN)
-
-PYGOBJECT_DATADIR=`$PKG_CONFIG --variable=datadir pygobject-2.0`
-AC_SUBST(PYGOBJECT_DATADIR)
-
-PYGOBJECT_PYGDOCS="`$PKG_CONFIG --variable=pygdocs pygobject-2.0`"
-AC_SUBST(PYGOBJECT_PYGDOCS)
-
-PYGOBJECT_FIXXREF="$PYTHON `$PKG_CONFIG --variable=fixxref pygobject-2.0`"
-AC_SUBST(PYGOBJECT_FIXXREF)
dnl ---------------------------------
dnl Get thunar extensions directory
diff --git a/examples/thunarx-menu-plugin.py b/examples/thunarx-menu-plugin.py
index de19d5a..5b83e5b 100644
--- a/examples/thunarx-menu-plugin.py
+++ b/examples/thunarx-menu-plugin.py
@@ -1,12 +1,17 @@
-import thunarx
-import gtk
+from gi.repository import GObject, Gtk, Thunarx
-class ThunarxMenuProviderPlugin(thunarx.MenuProvider):
+class ThunarxMenuProviderPlugin(GObject.GObject, Thunarx.MenuProvider):
def __init__(self):
pass
- def get_file_actions(self, window, files):
- return [gtk.Action("TMP:TestFileAction", "PyFileAction", "Python File Action", gtk.STOCK_FILE)]
-
- def get_folder_actions(self, window, folder):
- return [gtk.Action("TMP:TestFolderAction", "PyFolderAction", "Python Folder Action", gtk.STOCK_DIRECTORY)]
+ def get_file_menu_items(self, window, files):
+ item = Thunarx.MenuItem(name="TMP:TestFileAction", label="Python File Action", tooltip='', icon=Gtk.STOCK_FILE)
+ item.connect("activate", self.__do_something, window)
+
+ return [item]
+
+ def get_folder_menu_items(self, window, folder):
+ return [Thunarx.MenuItem(name="TMP:TestFolderAction", label="Python Folder Action", tooltip='', icon=Gtk.STOCK_OPEN)]
+
+ def __do_something(self, item, window):
+ print "Doing something"
diff --git a/examples/thunarx-preferences-plugin.py b/examples/thunarx-preferences-plugin.py
index 2f2587d..30868c1 100644
--- a/examples/thunarx-preferences-plugin.py
+++ b/examples/thunarx-preferences-plugin.py
@@ -1,22 +1,29 @@
-import thunarx
-import gtk
+from gi.repository import GObject, Gtk, Thunarx
-class ThunarxPreferencesPlugin(thunarx.PreferencesProvider):
+class DialogExample(Gtk.Dialog):
+ def __init__(self, parent):
+ Gtk.Dialog.__init__(self, "My Dialog", parent, 0,
+ (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
+ Gtk.STOCK_OK, Gtk.ResponseType.OK))
+
+ self.set_default_size(150, 100)
+
+ label = Gtk.Label("This is a dialog to display additional information")
+
+ box = self.get_content_area()
+ box.add(label)
+ self.show_all()
+
+class ThunarxPreferencesPlugin(GObject.GObject, Thunarx.PreferencesProvider):
def __init__(self):
pass
- def get_preferences_actions(self, window):
- action = gtk.Action("TPP:PrefItem", "My Example Preferences", None, None)
- action.connect("activate", self.__open_preferences, window)
- return action,
+ def get_preferences_menu_items(self, window):
+ item = Thunarx.MenuItem(name="TPP:PrefItem", label="My Example Preferences", tooltip=None, icon=None)
+ item.connect("activate", self.__open_preferences, window)
+ return item,
def __open_preferences(self, action, window):
- dialog = gtk.Dialog("My dialog",
- window,
- gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
- gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
-
- dialog.show()
- dialog.run()
+ dialog = DialogExample(window)
+ response = dialog.run()
dialog.destroy()
diff --git a/examples/thunarx-property-page-plugin.py b/examples/thunarx-property-page-plugin.py
index 2d45147..5a15cf2 100644
--- a/examples/thunarx-property-page-plugin.py
+++ b/examples/thunarx-property-page-plugin.py
@@ -1,10 +1,9 @@
import hashlib
import urllib
-import thunarx
-import gtk
+from gi.repository import GObject, Gtk, Thunarx
-class ThunarxPropertyPagePlugin(thunarx.PropertyPageProvider):
+class ThunarxPropertyPagePlugin(GObject.GObject, Thunarx.PropertyPageProvider):
def __init__(self):
pass
@@ -21,22 +20,22 @@ class ThunarxPropertyPagePlugin(thunarx.PropertyPageProvider):
filename = urllib.unquote(file.get_uri()[7:])
- self.hbox = gtk.HBox(0, False)
- self.hbox.show()
+ hbox = Gtk.HBox(0, False)
+ hbox.show()
- label = gtk.Label('MD5Sum:')
+ label = Gtk.Label('MD5Sum:')
label.show()
- self.hbox.pack_start(label)
+ hbox.pack_start(label, True, True, 0)
- self.value_label = gtk.Label()
- self.hbox.pack_start(self.value_label)
+ value_label = Gtk.Label()
+ hbox.pack_start(value_label, True, True, 0)
md5sum = hashlib.md5(filename).hexdigest()
- self.value_label.set_text(md5sum)
- self.value_label.show()
+ value_label.set_text(md5sum)
+ value_label.show()
- page = thunarx.PropertyPage("MD5")
-
- page.add(self.hbox)
+ page = Thunarx.PropertyPage()
+ page.set_label("MD5")
+ page.add(hbox)
return [page]
diff --git a/examples/thunarx-renamer-plugin.py b/examples/thunarx-renamer-plugin.py
index 046b5de..6ed4a65 100644
--- a/examples/thunarx-renamer-plugin.py
+++ b/examples/thunarx-renamer-plugin.py
@@ -1,13 +1,11 @@
-import thunarx
-import gtk
-import gobject
+from gi.repository import GObject, Gtk, Thunarx
-class ThunarxPythonRenamer(thunarx.Renamer):
+class ThunarxPythonRenamer(Thunarx.Renamer):
__gtype_name__ = "ThunarxPythonRenamer"
- prefix = gobject.property(type=str)
+ prefix = GObject.property(type=str)
def __init__(self):
- thunarx.Renamer.__init__(self)
+ Thunarx.Renamer.__init__(self)
# Set properties to be saved in the settings files
self.set_property("prefix", "__")
@@ -15,12 +13,12 @@ class ThunarxPythonRenamer(thunarx.Renamer):
self.set_name("Example Python Renamer")
self.set_help_url("http://www.google.com")
- hbox = gtk.HBox(0, False)
+ hbox = Gtk.HBox(0, False)
- label = gtk.Label("Prefix:")
+ label = Gtk.Label("Prefix:")
hbox.pack_start(label, False, False, 0)
- self.entry = gtk.Entry()
+ self.entry = Gtk.Entry()
self.entry.set_text(self.get_property("prefix"))
self.entry.connect("changed", self.entry_changed)
hbox.pack_start(self.entry, False, False, 0)
@@ -41,7 +39,7 @@ class ThunarxPythonRenamer(thunarx.Renamer):
self.emit("changed")
def do_get_actions(self, window, files):
- return [gtk.Action("TPR:SomeAction", "Some Action", None, gtk.STOCK_OPEN)]
+ return [Gtk.MenuItem(name="TPR:SomeAction", label="Some Action", tooltip=None, icon=Gtk.STOCK_OPEN)]
def do_load(self, settings):
"""
@@ -59,7 +57,7 @@ class ThunarxPythonRenamer(thunarx.Renamer):
settings["Prefix"] = self.get_property("prefix")
return settings
-class ThunarxRenamerPlugin(thunarx.RenamerProvider):
+class ThunarxRenamerPlugin(GObject.GObject, Thunarx.RenamerProvider):
def __init__(self):
pass
diff --git a/examples/thunarx-submenu-plugin.py b/examples/thunarx-submenu-plugin.py
index aaace55..b97297d 100644
--- a/examples/thunarx-submenu-plugin.py
+++ b/examples/thunarx-submenu-plugin.py
@@ -1,63 +1,45 @@
-import thunarx
-import gtk
+from gi.repository import GObject, Gtk, Thunarx
"""
Thunarx Submenu Plugin
This plugin shows an example of a MenuProvider plugin that implements
sub-menus. The example used here requires the developer to sub-class
gtk.Action and override the create_menu_item virtual method.
-
"""
-class MyAction(gtk.Action):
- __gtype_name__ = "MyAction"
-
- def __init__(self, name, label, tooltip=None, stock_id=None, menu_handler=None):
- gtk.Action.__init__(self, name, label, tooltip, stock_id)
- self.menu_handler = menu_handler
-
- def create_menu_item(self):
- menuitem = gtk.MenuItem(self.get_label())
-
- if self.menu_handler is not None:
- menu = gtk.Menu()
- menuitem.set_submenu(menu)
- self.menu_handler(menu)
-
- return menuitem
-
- do_create_menu_item = create_menu_item
-
-def PyFileActionMenu(menu):
- action = gtk.Action("TMP:Submenuitem1", "Submenuitem 1", None, None)
- subitem = action.create_menu_item()
- menu.append(subitem)
- subitem.show()
-
- action = MyAction("TMP:Submenuitem2", "Submenuitem 2", None, None, menu_handler=PyFileActionSubmenu)
- subitem = action.create_menu_item()
- menu.append(subitem)
- subitem.show()
-
-def PyFileActionSubmenu(menu):
- action = gtk.Action("TMP:SubSubmenuitem1", "Subsubmenuitem 1", None, None)
- subitem = action.create_menu_item()
- menu.append(subitem)
- subitem.show()
-
- action = gtk.Action("TMP:SubSubmenuitem2", "Subsubmenuitem 2", None, None)
- subitem = action.create_menu_item()
- menu.append(subitem)
- subitem.show()
-
-class ThunarxSubMenuProviderPlugin(thunarx.MenuProvider):
+class ThunarxSubMenuProviderPlugin(GObject.GObject, Thunarx.MenuProvider):
def __init__(self):
pass
- def get_file_actions(self, window, files):
- return [MyAction("TMP:TestFileAction", "PyFileAction", "Python File Action",
- gtk.STOCK_FILE, menu_handler=PyFileActionMenu)]
+ def get_file_menu_items(self, window, files):
+ item = Thunarx.MenuItem(name="TMP:Item1", label="Python File Action", tooltip='', icon=Gtk.STOCK_FILE)
+
+ submenu = Thunarx.Menu()
+ subitem1 = Thunarx.MenuItem(name='TMP::Subitem1',
+ label='Subitem1',
+ tooltip='First tip',
+ icon=Gtk.STOCK_DND)
+ subitem1.connect("activate", self.__subitem1_callback, window)
+ submenu.append_item(subitem1)
+
+ subitem2 = Thunarx.MenuItem(name='TMP::Subitem2',
+ label='Subitem2',
+ tooltip='Second tip',
+ icon=Gtk.STOCK_FULLSCREEN)
+ subitem2.connect("activate", self.__subitem2_callback, window)
+ submenu.append_item(subitem2)
+
+ item.set_menu(submenu)
+
+ item2 = Thunarx.MenuItem(name='TMP::Item2',
+ label='Another item',
+ tooltip='',
+ icon=Gtk.STOCK_OK)
- def get_folder_actions(self, window, folder):
- return [MyAction("TMP:TestFolderAction", "PyFolderAction",
- "Python Folder Action", gtk.STOCK_DIRECTORY)]
+ return item,item2
+
+ def __subitem1_callback(self, item, window):
+ print "Subitem1 call"
+
+ def __subitem2_callback(self, item, window):
+ print "Subitem2 call"
diff --git a/src/Makefile.am b/src/Makefile.am
index c621c3c..53c72c3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,3 @@
-
AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir) \
@@ -8,7 +7,10 @@ AM_CPPFLAGS = \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DPY_LIB_LOC=\"$(PYTHON_LIB_LOC)\" \
-DPYTHON_VERSION=\"$(PYTHON_VERSION)\" \
- -DTHUNARX_API_VERSION=$(THUNARX_API_VERSION)
+ $(THUNARX_PYTHON_CFLAGS) \
+ -DTHUNARX_API_VERSION=$(THUNARX_API_VERSION) \
+ -DGI_TYPELIB_PATH=\"$(libdir)/girepository-1.0\"
+
extensionsdir = $(THUNARX_LIBDIR)/thunarx-$(THUNARX_API_VERSION)
extensions_LTLIBRARIES = \
@@ -23,53 +25,16 @@ thunarx_python_la_SOURCES = \
thunarx_python_la_CFLAGS = \
$(THUNARX_CFLAGS) \
$(PYTHON_CFLAGS) \
- $(PYGTK_CFLAGS)
+ $(PYGOBJECT_CFLAGS)
thunarx_python_la_LDFLAGS = \
-avoid-version \
- -export-dynamic \
- -module \
- $(THUNARX_LDFLAGS) \
- $(PYTHON_LDFLAGS) \
- $(PYGTK_LDFLAGS)
-
-pyexec_LTLIBRARIES = thunarx.la
-pyexecdir = $(THUNARX_LIBDIR)/thunarx-python
-
-thunarx_la_LDFLAGS = \
-module \
- -avoid-version \
- -export-symbols-regex \
- initthunarx \
$(THUNARX_LDFLAGS) \
$(PYTHON_LDFLAGS) \
- $(PYGTK_LDFLAGS)
-
-thunarx_la_LIBADD = \
- $(THUNARX_LIBS) \
- $(PYTHON_LIBS) \
- $(PYGTK_LIBS)
+ $(PYGOBJECT_CFLAGS)
-thunarx_la_CFLAGS = \
+thunarx_python_la_LIBADD = \
$(THUNARX_CFLAGS) \
$(PYTHON_CFLAGS) \
- $(PYGTK_CFLAGS)
-
-thunarx_la_SOURCES = thunarxmodule.c
-nodist_thunarx_la_SOURCES = thunarx.c
-thunarx.c: thunarx.defs thunarx.override
-CLEANFILES = thunarx.c
-EXTRA_DIST = thunarx.override thunarx.defs
-
-.defs.c:
- (cd $(srcdir)\
- && $(PYGTK_CODEGEN) \
- --register $(PYGTK_DEFSDIR)/pango-types.defs \
- --register $(PYGTK_DEFSDIR)/gdk-types.defs \
- --register $(PYGTK_DEFSDIR)/gtk-types.defs \
- --override $*.override \
- --prefix py$* $*.defs) > gen-$*.c \
- && cp gen-$*.c $*.c \
- && rm -f gen-$*.c
-
-# vi:set ts=8 sw=8 noet ai nocindent:
+ $(PYGOBJECT_CFLAGS)
diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
index e588b98..b2e4b0c 100644
--- a/src/thunarx-python-object.c
+++ b/src/thunarx-python-object.c
@@ -43,13 +43,13 @@ thunarx_python_object_class_init (ThunarxPythonObjectClass *klass,
static void thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface);
-static GList *thunarx_python_object_get_file_actions (ThunarxMenuProvider *provider,
+static GList *thunarx_python_object_get_file_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
GList *files);
-static GList *thunarx_python_object_get_folder_actions (ThunarxMenuProvider *provider,
+static GList *thunarx_python_object_get_folder_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder);
-static GList *thunarx_python_object_get_dnd_actions (ThunarxMenuProvider *provider,
+static GList *thunarx_python_object_get_dnd_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder,
GList *files);
@@ -60,7 +60,7 @@ static GList *thunarx_python_object_get_property_pages (ThunarxProp
GList *files);
static void thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface);
-static GList *thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provider,
+static GList *thunarx_python_object_get_preferences_menu_items (ThunarxPreferencesProvider *provider,
GtkWidget *window);
static void thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface);
@@ -131,9 +131,9 @@ static GList *thunarx_python_object_get_renamers (ThunarxRenamerP
}
-#define METHOD_NAME "get_file_actions"
+#define METHOD_NAME "get_file_menu_items"
static GList *
-thunarx_python_object_get_file_actions (ThunarxMenuProvider *provider,
+thunarx_python_object_get_file_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
GList *files)
{
@@ -154,7 +154,7 @@ thunarx_python_object_get_file_actions (ThunarxMenuProvider *provider,
HANDLE_RETVAL(py_ret);
- HANDLE_LIST(py_ret, GtkAction, "gtk.Action");
+ HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
beach:
Py_XDECREF(py_ret);
@@ -165,9 +165,9 @@ beach:
-#define METHOD_NAME "get_folder_actions"
+#define METHOD_NAME "get_folder_menu_items"
static GList *
-thunarx_python_object_get_folder_actions (ThunarxMenuProvider *provider,
+thunarx_python_object_get_folder_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder)
{
@@ -188,7 +188,7 @@ thunarx_python_object_get_folder_actions (ThunarxMenuProvider *provider,
HANDLE_RETVAL(py_ret);
- HANDLE_LIST(py_ret, GtkAction, "gtk.Action");
+ HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
beach:
Py_XDECREF(py_ret);
@@ -199,9 +199,9 @@ beach:
-#define METHOD_NAME "get_dnd_actions"
+#define METHOD_NAME "get_dnd_menu_items"
static GList *
-thunarx_python_object_get_dnd_actions (ThunarxMenuProvider *provider,
+thunarx_python_object_get_dnd_menu_items (ThunarxMenuProvider *provider,
GtkWidget *window,
ThunarxFileInfo *folder,
GList *files)
@@ -226,7 +226,7 @@ thunarx_python_object_get_dnd_actions (ThunarxMenuProvider *provider,
HANDLE_RETVAL(py_ret);
- HANDLE_LIST(py_ret, GtkAction, "gtk.Action");
+ HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
beach:
Py_XDECREF(py_ret);
@@ -240,9 +240,9 @@ beach:
static void
thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface)
{
- iface->get_file_actions = thunarx_python_object_get_file_actions;
- iface->get_folder_actions = thunarx_python_object_get_folder_actions;
- iface->get_dnd_actions = thunarx_python_object_get_dnd_actions;
+ iface->get_file_menu_items = thunarx_python_object_get_file_menu_items;
+ iface->get_folder_menu_items = thunarx_python_object_get_folder_menu_items;
+ iface->get_dnd_menu_items = thunarx_python_object_get_dnd_menu_items;
}
@@ -325,9 +325,9 @@ thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *
-#define METHOD_NAME "get_preferences_actions"
+#define METHOD_NAME "get_preferences_menu_items"
static GList *
-thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provider,
+thunarx_python_object_get_preferences_menu_items (ThunarxPreferencesProvider *provider,
GtkWidget *window)
{
ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
@@ -345,7 +345,7 @@ thunarx_python_object_get_preferences_actions (ThunarxPreferencesProvider *provi
HANDLE_RETVAL(py_ret);
- HANDLE_LIST(py_ret, GtkAction, "Gtk.Action");
+ HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
beach:
Py_XDECREF(py_ret);
@@ -359,7 +359,7 @@ beach:
static void
thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface)
{
- iface->get_actions = thunarx_python_object_get_preferences_actions;
+ iface->get_menu_items = thunarx_python_object_get_preferences_menu_items;
}
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index b33dcdf..a06dc1f 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -23,7 +23,8 @@
#include <Python.h>
#include <pygobject.h>
-#include <pygtk/pygtk.h>
+#include <gmodule.h>
+#include <gtk/gtk.h>
#include "thunarx-python.h"
#include "thunarx-python-object.h"
@@ -41,96 +42,27 @@ G_MODULE_EXPORT void thunar_extension_shutdown (void);
G_MODULE_EXPORT void thunar_extension_list_types (const GType **types, gint *n_types);
static gboolean thunarx_python_init_pygobject (void);
-static gboolean thunarx_python_init_pygtk (void);
static gboolean thunarx_python_init_python (void);
static inline gboolean
thunarx_python_init_pygobject(void)
{
-#ifdef Py_CAPSULE_H
- void *capsule = PyCapsule_Import("gobject._PyGObject_API", 1);
- if (capsule)
- {
- _PyGObject_API = (struct _PyGObject_Functions *)capsule;
- return TRUE;
- }
-#endif
+ PyObject *gobject = pygobject_init (3, 0, 0);
- PyObject *gobject = PyImport_ImportModule("gobject");
- if (gobject != NULL)
- {
- PyObject *mdict = PyModule_GetDict(gobject);
- PyObject *cobject = PyDict_GetItemString(mdict, "_PyGObject_API");
- if (PyCObject_Check(cobject))
- {
- _PyGObject_API = (struct _PyGObject_Functions *)PyCObject_AsVoidPtr(cobject);
- }
- else
- {
- PyErr_SetString(PyExc_RuntimeError,
- "could not find _PyGObject_API object");
- PyErr_Print();
- return FALSE;
- }
- }
- else
- {
- PyErr_Print();
- g_warning("could not import gobject");
+ if (gobject == NULL) {
+ PyErr_Print ();
return FALSE;
}
- return TRUE;
-}
-
-
-static inline gboolean
-thunarx_python_init_pygtk(void)
-{
-#ifdef Py_CAPSULE_H
- void *capsule = PyCapsule_Import("gtk._gtk._PyGtk_API", 0);
- if (capsule)
- {
- _PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule;
- return TRUE;
- }
-#endif
-
- PyObject *pygtk = PyImport_ImportModule("gtk._gtk");
- if (pygtk != NULL)
- {
- PyObject *module_dict = PyModule_GetDict(pygtk);
- PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
- if (PyCObject_Check(cobject))
- {
- _PyGtk_API = (struct _PyGtk_FunctionStruct*)
- PyCObject_AsVoidPtr(cobject);
- }
- else
- {
- PyErr_SetString(PyExc_RuntimeError,
- "could not find _PyGtk_API object");
- PyErr_Print();
- return FALSE;
- }
- }
- else
- {
- PyErr_Print();
- g_warning("could not import gtk._gtk");
- return FALSE;
- }
- return TRUE;
+ return TRUE;
}
-
static gboolean
thunarx_python_init_python (void)
{
- PyObject *pygtk, *mdict, *require;
- PyObject *sys_path, *tmp, *thunarx, *gtk, *pygtk_version, *pygtk_required_version;
+ PyObject *thunarx;
GModule *libpython;
char *argv[] = { "thunarx", NULL };
@@ -138,6 +70,10 @@ thunarx_python_init_python (void)
if (Py_IsInitialized())
return TRUE;
+
+ debug("Setting GI_TYPELIB_PATH to " GI_TYPELIB_PATH);
+ gchar *typelib_env = g_strdup_printf("GI_TYPELIB_PATH=$GI_TYPELIB_PATH:%s", GI_TYPELIB_PATH);
+ putenv(typelib_env);
debug ("g_module_open " PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0");
libpython = g_module_open (PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0", 0);
@@ -167,24 +103,6 @@ thunarx_python_init_python (void)
return FALSE;
}
- /* pygtk.require("2.0") */
- debug("pygtk.require(\"2.0\")");
- pygtk = PyImport_ImportModule("pygtk");
- if (!pygtk)
- {
- PyErr_Print();
- return FALSE;
- }
-
- mdict = PyModule_GetDict(pygtk);
- require = PyDict_GetItemString(mdict, "require");
- PyObject_CallObject(require, Py_BuildValue("(S)", PyString_FromString("2.0")));
- if (PyErr_Occurred())
- {
- PyErr_Print();
- return FALSE;
- }
-
/* import gobject */
debug("init_pygobject");
if (!thunarx_python_init_pygobject())
@@ -193,65 +111,30 @@ thunarx_python_init_python (void)
return FALSE;
}
- /* import gtk */
- debug("init_pygtk");
- if (!thunarx_python_init_pygtk())
- {
- g_warning("pygtk initialization failed");
- return FALSE;
- }
-
- /* gobject.threads_init() */
- debug("pyg_enable_threads");
- setenv("PYGTK_USE_GIL_STATE_API", "", 0);
- pyg_enable_threads();
-
- /* gtk.pygtk_version < (2, 4, 0) */
- gtk = PyImport_ImportModule("gtk");
- mdict = PyModule_GetDict(gtk);
- pygtk_version = PyDict_GetItemString(mdict, "pygtk_version");
- pygtk_required_version = Py_BuildValue("(iii)", 2, 4, 0);
- if (PyObject_Compare(pygtk_version, pygtk_required_version) == -1)
- {
- g_warning("PyGTK %s required, but %s found.",
- PyString_AsString(PyObject_Repr(pygtk_required_version)),
- PyString_AsString(PyObject_Repr(pygtk_version)));
- Py_DECREF(pygtk_required_version);
- return FALSE;
- }
- Py_DECREF(pygtk_required_version);
-
- debug("sys.path.insert(0, ...)");
- sys_path = PySys_GetObject("path");
- PyList_Insert(sys_path, 0, (tmp = PyString_FromString(THUNARX_LIBDIR "/thunarx-python")));
- Py_DECREF(tmp);
-
g_setenv("INSIDE_THUNARX_PYTHON", "", FALSE);
- debug("import thunarx");
- thunarx = PyImport_ImportModule("thunarx");
+ debug("import Thunarx");
+ PyRun_SimpleString("import gi; gi.require_version('Thunarx', '3.0')");
+ thunarx = PyImport_ImportModule("gi.repository.Thunarx");
if (!thunarx)
{
PyErr_Print();
return FALSE;
}
-
- /* Extract types and interfaces from thunarx */
- mdict = PyModule_GetDict(thunarx);
-
+
_PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
g_assert(_PyGtkWidget_Type != NULL);
- _PyGtkAction_Type = pygobject_lookup_class(GTK_TYPE_ACTION);
- g_assert(_PyGtkAction_Type != NULL);
-
#define IMPORT(x, y) \
- _PyThunarx##x##_Type = (PyTypeObject *)PyDict_GetItemString(mdict, y); \
+ _PyThunarx##x##_Type = (PyTypeObject *)PyObject_GetAttrString(thunarx, y); \
if (_PyThunarx##x##_Type == NULL) { \
+ debug("hi " y); \
PyErr_Print(); \
return FALSE; \
}
IMPORT(FileInfo, "FileInfo");
+ IMPORT(MenuItem, "MenuItem");
+ IMPORT(Menu, "Menu");
IMPORT(MenuProvider, "MenuProvider");
IMPORT(PreferencesProvider, "PreferencesProvider");
IMPORT(PropertyPage, "PropertyPage");
diff --git a/src/thunarx-python.h b/src/thunarx-python.h
index 0d9b51b..cc239d6 100644
--- a/src/thunarx-python.h
+++ b/src/thunarx-python.h
@@ -46,12 +46,15 @@ extern ThunarxPythonDebug thunarx_python_debug;
PyTypeObject *_PyGtkWidget_Type;
#define PyGtkWidget_Type (*_PyGtkWidget_Type)
-PyTypeObject *_PyGtkAction_Type;
-#define PyGtkAction_Type (*_PyGtkAction_Type)
-
PyTypeObject *_PyThunarxFileInfo_Type;
#define PyThunarxFileInfo_Type (*_PyThunarxFileInfo_Type)
+PyTypeObject *_PyThunarxMenuItem_Type;
+#define PyThunarxMenuItem_Type (*_PyThunarxMenuItem_Type)
+
+PyTypeObject *_PyThunarxMenu_Type;
+#define PyThunarxMenu_Type (*_PyThunarxMenu_Type)
+
PyTypeObject *_PyThunarxMenuProvider_Type;
#define PyThunarxMenuProvider_Type (*_PyThunarxMenuProvider_Type)
diff --git a/src/thunarx.defs b/src/thunarx.defs
deleted file mode 100644
index dd94103..0000000
--- a/src/thunarx.defs
+++ /dev/null
@@ -1,453 +0,0 @@
-;; -*- scheme -*-
-; object definitions ...
-(define-interface FileInfo
- (in-module "Thunarx")
- (c-name "ThunarxFileInfo")
- (gtype-id "THUNARX_TYPE_FILE_INFO")
-)
-
-(define-interface MenuProvider
- (in-module "Thunarx")
- (c-name "ThunarxMenuProvider")
- (gtype-id "THUNARX_TYPE_MENU_PROVIDER")
-)
-
-(define-interface PreferencesProvider
- (in-module "Thunarx")
- (c-name "ThunarxPreferencesProvider")
- (gtype-id "THUNARX_TYPE_PREFERENCES_PROVIDER")
-)
-
-(define-object PropertyPage
- (in-module "Thunarx")
- (parent "GtkBin")
- (c-name "ThunarxPropertyPage")
- (gtype-id "THUNARX_TYPE_PROPERTY_PAGE")
-)
-
-(define-interface PropertyPageProvider
- (in-module "Thunarx")
- (c-name "ThunarxPropertyPageProvider")
- (gtype-id "THUNARX_TYPE_PROPERTY_PAGE_PROVIDER")
-)
-
-(define-interface ProviderPlugin
- (in-module "Thunarx")
- (c-name "ThunarxProviderPlugin")
- (gtype-id "THUNARX_TYPE_PROVIDER_PLUGIN")
-)
-
-(define-object Renamer
- (in-module "Thunarx")
- (parent "GtkVBox")
- (c-name "ThunarxRenamer")
- (gtype-id "THUNARX_TYPE_RENAMER")
-)
-
-(define-interface RenamerProvider
- (in-module "Thunarx")
- (c-name "ThunarxRenamerProvider")
- (gtype-id "THUNARX_TYPE_RENAMER_PROVIDER")
-)
-
-;; Enumerations and flags ...
-
-
-;; From thunarx-config.h
-
-(define-function thunarx_check_version
- (c-name "thunarx_check_version")
- (return-type "const-gchar*")
- (parameters
- '("guint" "required_major")
- '("guint" "required_minor")
- '("guint" "required_micro")
- )
-)
-
-
-
-;; From thunarx-file-info.h
-
-(define-function thunarx_file_info_get_type
- (c-name "thunarx_file_info_get_type")
- (return-type "GType")
-)
-
-(define-method get_name
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_get_name")
- (return-type "gchar*")
-)
-
-(define-method get_uri
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_get_uri")
- (return-type "gchar*")
-)
-
-(define-method get_parent_uri
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_get_parent_uri")
- (return-type "gchar*")
-)
-
-(define-method get_uri_scheme
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_get_uri_scheme")
- (return-type "gchar*")
-)
-
-(define-method get_mime_type
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_get_mime_type")
- (return-type "gchar*")
-)
-
-(define-method has_mime_type
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_has_mime_type")
- (return-type "gboolean")
- (parameters
- '("const-gchar*" "mime_type")
- )
-)
-
-(define-method is_directory
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_is_directory")
- (return-type "gboolean")
-)
-
-(define-method changed
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_changed")
- (return-type "none")
-)
-
-(define-method renamed
- (of-object "ThunarxFileInfo")
- (c-name "thunarx_file_info_renamed")
- (return-type "none")
-)
-
-(define-function thunarx_file_info_list_get_type
- (c-name "thunarx_file_info_list_get_type")
- (return-type "GType")
-)
-
-(define-function thunarx_file_info_list_copy
- (c-name "thunarx_file_info_list_copy")
- (return-type "GList*")
- (parameters
- '("GList*" "file_infos")
- )
-)
-
-(define-function thunarx_file_info_list_free
- (c-name "thunarx_file_info_list_free")
- (return-type "none")
- (parameters
- '("GList*" "file_infos")
- )
-)
-
-
-
-;; From thunarx-menu-provider.h
-
-(define-function thunarx_menu_provider_get_type
- (c-name "thunarx_menu_provider_get_type")
- (return-type "GType")
-)
-
-(define-method get_file_actions
- (of-object "ThunarxMenuProvider")
- (c-name "thunarx_menu_provider_get_file_actions")
- (return-type "GList*")
- (parameters
- '("GtkWidget*" "window")
- '("GList*" "files")
- )
-)
-
-(define-method get_folder_actions
- (of-object "ThunarxMenuProvider")
- (c-name "thunarx_menu_provider_get_folder_actions")
- (return-type "GList*")
- (parameters
- '("GtkWidget*" "window")
- '("ThunarxFileInfo*" "folder")
- )
-)
-
-(define-method get_dnd_actions
- (of-object "ThunarxMenuProvider")
- (c-name "thunarx_menu_provider_get_dnd_actions")
- (return-type "GList*")
- (parameters
- '("GtkWidget*" "window")
- '("ThunarxFileInfo*" "folder")
- '("GList*" "files")
- )
-)
-
-
-
-;; From thunarx-preferences-provider.h
-
-(define-function thunarx_preferences_provider_get_type
- (c-name "thunarx_preferences_provider_get_type")
- (return-type "GType")
-)
-
-(define-method get_preferences_actions
- (of-object "ThunarxPreferencesProvider")
- (c-name "thunarx_preferences_provider_get_actions")
- (return-type "GList*")
- (parameters
- '("GtkWidget*" "window")
- )
-)
-
-
-;; From thunarx-property-page.h
-
-(define-function thunarx_property_page_get_type
- (c-name "thunarx_property_page_get_type")
- (return-type "GType")
-)
-
-(define-function thunarx_property_page_new
- (c-name "thunarx_property_page_new")
- (is-constructor-of "ThunarxPropertyPage")
- (return-type "ThunarxPropertyPage*")
- (parameters
- '("const-gchar*" "label")
- )
-)
-
-(define-method get_label
- (of-object "ThunarxPropertyPage")
- (c-name "thunarx_property_page_get_label")
- (return-type "const-gchar*")
-)
-
-(define-method set_label
- (of-object "ThunarxPropertyPage")
- (c-name "thunarx_property_page_set_label")
- (return-type "none")
- (parameters
- '("const-gchar*" "label")
- )
-)
-
-(define-method get_label_widget
- (of-object "ThunarxPropertyPage")
- (c-name "thunarx_property_page_get_label_widget")
- (return-type "GtkWidget*")
-)
-
-(define-method set_label_widget
- (of-object "ThunarxPropertyPage")
- (c-name "thunarx_property_page_set_label_widget")
- (return-type "none")
- (parameters
- '("GtkWidget*" "label_widget")
- )
-)
-
-
-
-;; From thunarx-provider-factory.h
-
-(define-function thunarx_provider_factory_get_type
- (c-name "thunarx_provider_factory_get_type")
- (return-type "GType")
-)
-
-(define-function thunarx_provider_factory_get_default
- (c-name "thunarx_provider_factory_get_default")
- (return-type "ThunarxProviderFactory*")
-)
-
-(define-method list_providers
- (of-object "ThunarxProviderFactory")
- (c-name "thunarx_provider_factory_list_providers")
- (return-type "GList*")
- (parameters
- '("GType" "type")
- )
-)
-
-
-
-;; From thunarx-provider-plugin.h
-
-(define-function thunarx_provider_plugin_get_type
- (c-name "thunarx_provider_plugin_get_type")
- (return-type "GType")
-)
-
-(define-method get_resident
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_get_resident")
- (return-type "gboolean")
-)
-
-(define-method set_resident
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_set_resident")
- (return-type "none")
- (parameters
- '("gboolean" "resident")
- )
-)
-
-(define-method register_type
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_register_type")
- (return-type "GType")
- (parameters
- '("GType" "type_parent")
- '("const-gchar*" "type_name")
- '("const-GTypeInfo*" "type_info")
- '("GTypeFlags" "type_flags")
- )
-)
-
-(define-method add_interface
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_add_interface")
- (return-type "none")
- (parameters
- '("GType" "instance_type")
- '("GType" "interface_type")
- '("const-GInterfaceInfo*" "interface_info")
- )
-)
-
-(define-method register_enum
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_register_enum")
- (return-type "GType")
- (parameters
- '("const-gchar*" "name")
- '("const-GEnumValue*" "const_static_values")
- )
-)
-
-(define-method register_flags
- (of-object "ThunarxProviderPlugin")
- (c-name "thunarx_provider_plugin_register_flags")
- (return-type "GType")
- (parameters
- '("const-gchar*" "name")
- '("const-GFlagsValue*" "const_static_values")
- )
-)
-
-
-
-;; From thunarx-renamer-provider.h
-
-(define-function thunarx_renamer_provider_get_type
- (c-name "thunarx_renamer_provider_get_type")
- (return-type "GType")
-)
-
-(define-method get_renamers
- (of-object "ThunarxRenamerProvider")
- (c-name "thunarx_renamer_provider_get_renamers")
- (return-type "GList*")
-)
-
-
-
-;; From thunarx-renamer.h
-
-(define-function thunarx_renamer_get_type
- (c-name "thunarx_renamer_get_type")
- (return-type "GType")
-)
-
-(define-method get_help_url
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_get_help_url")
- (return-type "const-gchar*")
-)
-
-(define-method set_help_url
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_set_help_url")
- (return-type "none")
- (parameters
- '("const-gchar*" "help_url")
- )
-)
-
-(define-method get_name
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_get_name")
- (return-type "const-gchar*")
-)
-
-(define-method set_name
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_set_name")
- (return-type "none")
- (parameters
- '("const-gchar*" "name")
- )
-)
-
-(define-virtual process
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_process")
- (return-type "gchar*")
- (parameters
- '("ThunarxFileInfo*" "file")
- '("const-gchar*" "text")
- '("guint" "index")
- )
-)
-
-(define-virtual load
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_load")
- (return-type "none")
- (parameters
- '("GHashTable*" "settings")
- )
-)
-
-(define-virtual save
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_save")
- (return-type "none")
- (parameters
- '("GHashTable*" "settings")
- )
-)
-
-(define-virtual get_actions
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_get_actions")
- (return-type "GList*")
- (parameters
- '("GtkWindow*" "window")
- '("GList*" "files")
- )
-)
-
-(define-virtual changed
- (of-object "ThunarxRenamer")
- (c-name "thunarx_renamer_changed")
- (return-type "none")
-)
-
-
-
-;; From thunarx.h
-
-
diff --git a/src/thunarx.override b/src/thunarx.override
deleted file mode 100644
index 0f4127e..0000000
--- a/src/thunarx.override
+++ /dev/null
@@ -1,412 +0,0 @@
-/*-
- * Copyright (c) 2009 Adam Plumb <adamplumb at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-%%
-headers
-#define NO_IMOPRT_PYGOBJECT
-#include "pygobject.h"
-
-#include <thunarx/thunarx.h>
-
-GHashTable *
-_pyobject_to_ghashtable (PyObject *py_dict,
- GHashTable *hashtable)
-{
- Py_ssize_t pos = 0;
- PyObject *py_key, *py_value;
-
- g_return_val_if_fail (py_dict != NULL, NULL);
-
- while (PyDict_Next (py_dict, &pos, &py_key, &py_value))
- {
- if (PyString_Check (py_key) < 0)
- {
- PyErr_SetString (PyExc_TypeError, "key must be a string");
- continue;
- }
- if (PyString_Check (py_value) < 0)
- {
- PyErr_SetString (PyExc_TypeError, "value must be a string");
- continue;
- }
-
- g_hash_table_replace (hashtable, g_strdup (PyString_AsString (py_key)), g_strdup (PyString_AsString (py_value)));
- }
-
- return hashtable;
-}
-
-static PyObject*
-_ghashtable_to_pyobject (GHashTable *hashtable)
-{
- GList *keys;
- PyObject *dict;
- gpointer *value;
-
- dict = PyDict_New ();
-
- keys = g_hash_table_get_keys (hashtable);
- for (; keys; keys = g_list_next (keys))
- {
- value = g_hash_table_lookup (hashtable, keys->data);
- if (value)
- {
- PyDict_SetItemString (dict, g_strdup ((char*)keys->data), PyString_FromString ((char *)value));
- }
- else
- {
- PyErr_Warn (PyExc_RuntimeWarning, "hashtable contains a null value");
- }
- }
- g_list_free (keys);
-
- return dict;
-}
-
-%%
-modulename thunarx
-%%
-import gobject.GObject as PyGObject_Type
-import gtk.Bin as PyGtkBin_Type
-import gtk.VBox as PyGtkVBox_Type
-import gtk.Widget as PyGtkWidget_Type
-import gtk.Window as PyGtkWindow_Type
-import gtk.Action as PyGtkAction_Type
-%%
-ignore-glob
- *_get_type
-%%
-override ThunarxRenamer__proxy_do_get_actions noargs
-static GList*
-_wrap_ThunarxRenamer__proxy_do_get_actions(ThunarxRenamer *self,
- GtkWindow *window,
- GList *files)
-{
- PyGILState_STATE __py_state;
- PyObject *py_self;
- PyObject *py_window;
- PyObject *py_files;
- GList *retval = NULL;
- PyObject *py_retval;
- PyObject *py_args;
- PyObject *py_method;
-
- __py_state = pyg_gil_state_ensure();
- py_self = pygobject_new((GObject *) self);
- if (!py_self) {
- if (PyErr_Occurred())
- PyErr_Print();
- pyg_gil_state_release(__py_state);
- return NULL;
- }
-
- if (window)
- {
- py_window = pygobject_new((GObject *) window);
- }
- else
- {
- Py_INCREF(Py_None);
- py_window = Py_None;
- }
-
- GList *l;
- py_files = PyList_New(0);
- for (l = files; l; l = l->next)
- {
- PyObject *obj = pygobject_new((GObject*)l->data);
- PyList_Append(py_files, obj);
- Py_DECREF(obj);
- }
-
- py_args = PyTuple_New(2);
- PyTuple_SET_ITEM(py_args, 0, py_window);
- PyTuple_SET_ITEM(py_args, 1, py_files);
-
- py_method = PyObject_GetAttrString(py_self, "do_get_actions");
- if (!py_method)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return NULL;
- }
-
- py_retval = PyObject_CallObject(py_method, py_args);
- if (!py_retval)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_XDECREF(py_retval);
- Py_DECREF(py_method);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return NULL;
- }
-
- Py_ssize_t i = 0;
- if (!PySequence_Check(py_retval) || PyString_Check(py_retval))
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_XDECREF(py_retval);
- Py_DECREF(py_method);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return NULL;
- }
-
- for (i = 0; i < PySequence_Size (py_retval); i++) {
- PyGObject *py_item;
- py_item = (PyGObject*)PySequence_GetItem (py_retval, i);
- if (!pygobject_check(py_item, &PyGtkAction_Type))
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_XDECREF(py_retval);
- Py_DECREF(py_method);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return NULL;
- }
-
- retval = g_list_append (retval, g_object_ref(py_item->obj));
- Py_DECREF(py_item);
- }
-
- Py_XDECREF(py_retval);
- Py_DECREF(py_method);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
-
- return retval;
-}
-%%
-override ThunarxRenamer__proxy_do_load noargs
-static void
-_wrap_ThunarxRenamer__proxy_do_load(ThunarxRenamer *self,
- GHashTable *settings)
-{
- PyGILState_STATE __py_state;
- PyObject *py_self;
- PyObject *py_settings;
- PyObject *py_args;
- PyObject *py_method;
-
- __py_state = pyg_gil_state_ensure();
- py_self = pygobject_new((GObject *) self);
- if (!py_self)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- pyg_gil_state_release(__py_state);
- return;
- }
-
- py_settings = _ghashtable_to_pyobject(settings);
-
- py_args = PyTuple_New(1);
- PyTuple_SET_ITEM(py_args, 0, py_settings);
-
- py_method = PyObject_GetAttrString(py_self, "do_load");
- if (!py_method)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return;
- }
-
- PyObject_CallObject(py_method, py_args);
-
- Py_DECREF(py_settings);
- Py_DECREF(py_method);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
-}
-%%
-override ThunarxRenamer__proxy_do_save noargs
-static void
-_wrap_ThunarxRenamer__proxy_do_save(ThunarxRenamer *self,
- GHashTable *settings)
-{
- PyGILState_STATE __py_state;
- PyObject *py_self;
- PyObject *py_settings;
- PyObject *py_args;
- PyObject *py_method;
- PyObject *py_ret;
-
- __py_state = pyg_gil_state_ensure();
- py_self = pygobject_new((GObject *) self);
- if (!py_self)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- pyg_gil_state_release(__py_state);
- return;
- }
-
- py_settings = _ghashtable_to_pyobject(settings);
-
- py_args = PyTuple_New(1);
- PyTuple_SET_ITEM(py_args, 0, py_settings);
-
- py_method = PyObject_GetAttrString(py_self, "do_save");
- if (!py_method)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_DECREF(py_settings);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return;
- }
-
- py_ret = PyObject_CallObject(py_method, py_args);
- if (!py_ret)
- {
- if (PyErr_Occurred())
- PyErr_Print();
- Py_DECREF(py_method);
- Py_DECREF(py_settings);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
- return;
- }
-
- settings = _pyobject_to_ghashtable(py_ret, settings);
-
- Py_DECREF(py_ret);
- Py_DECREF(py_method);
- Py_DECREF(py_settings);
- Py_DECREF(py_args);
- Py_DECREF(py_self);
- pyg_gil_state_release(__py_state);
-}
-%%
-define ThunarxFileInfo.get_file_info
-static PyObject *
-_wrap_thunarx_file_info_get_file_info(PyGObject *self)
-{
-#if THUNARX_API_VERSION >= 2
- GFileInfo *ret;
-
- ret = thunarx_file_info_get_file_info(THUNARX_FILE_INFO(self->obj));
-
- /* pygobject_new handles NULL checking */
- return pygobject_new((GObject *)ret);
-#else
- g_warning("thunarx_file_info.get_file_info is not implemented for your version of Thunar");
-
- Py_DECREF(Py_None);
- return Py_None;
-#endif
-}
-%%
-define ThunarxFileInfo.get_filesystem_info
-static PyObject *
-_wrap_thunarx_file_info_get_filesystem_info(PyGObject *self)
-{
-#if THUNARX_API_VERSION >= 2
- GFileInfo *ret;
-
- ret = thunarx_file_info_get_filesystem_info(THUNARX_FILE_INFO(self->obj));
-
- /* pygobject_new handles NULL checking */
- return pygobject_new((GObject *)ret);
-#else
- g_warning("thunarx_file_info.get_filesystem_info is not implemented for your version of Thunar");
-
- Py_DECREF(Py_None);
- return Py_None;
-#endif
-}
-%%
-define ThunarxFileInfo.get_location
-static PyObject *
-_wrap_thunarx_file_info_get_location(PyGObject *self)
-{
-#if THUNARX_API_VERSION >= 2
- GFile *ret;
-
- ret = thunarx_file_info_get_location(THUNARX_FILE_INFO(self->obj));
-
- /* pygobject_new handles NULL checking */
- return pygobject_new((GObject *)ret);
-#else
- g_warning("thunarx_file_info.get_location is not implemented for your version of Thunar");
-
- Py_DECREF(Py_None);
- return Py_None;
-#endif
-}
-%%
-define ThunarxFileInfo.get_vfs_info
-static PyObject *
-_wrap_thunarx_file_info_get_vfs_info(PyGObject *self)
-{
- g_warning("thunarx_file_info.get_vfs_info is not implemented for your version of Thunar");
-
- Py_DECREF(Py_None);
- return Py_None;
-}
-%%
-override thunarx_property_page_new
-static int
-_wrap_thunarx_property_page_new(PyGObject *self, PyObject *args)
-{
- PyGObject *arg;
- char *label;
- GtkWidget *label_widget;
-
- if (!PyArg_ParseTuple(args,"O:ThunarxPropertyPage.__init__", &arg))
- return -1;
-
- if (PyObject_TypeCheck(arg, &PyString_Type))
- {
- label = PyString_AsString((PyObject *)arg);
- Py_DECREF(arg);
- self->obj = (GObject *)thunarx_property_page_new(label);
- }
- else if (PyObject_TypeCheck(arg, &PyGtkWidget_Type))
- {
- label_widget = GTK_WIDGET(arg->obj);
- Py_DECREF(arg);
- self->obj = (GObject *)thunarx_property_page_new_with_label_widget(label_widget);
- }
-
- if (!self->obj) {
- PyErr_SetString(PyExc_RuntimeError, "could not create ThunarxPropertyPage object");
- return -1;
- }
- pygobject_register_wrapper((PyObject *)self);
- return 0;
-}
diff --git a/src/thunarxmodule.c b/src/thunarxmodule.c
deleted file mode 100644
index bebe6c8..0000000
--- a/src/thunarxmodule.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * Copyright (c) 2009 Adam Plumb <adamplumb at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* include this first, before NO_IMPORT_PYGOBJECT is defined */
-#include <pygobject.h>
-#include <pygtk/pygtk.h>
-
-void pythunarx_register_classes(PyObject *d);
-
-extern PyMethodDef pythunarx_functions[];
-
-DL_EXPORT(void)
-initthunarx(void)
-{
- PyObject *m, *d;
-
- if (!g_getenv("INSIDE_THUNARX_PYTHON"))
- {
- Py_FatalError("This module can only be used from thunarx");
- return;
- }
-
- if (!pygobject_init(-1, -1, -1))
- {
- PyErr_Print();
- Py_FatalError("Can't initialize module gobject");
- }
- init_pygtk ();
-
- m = Py_InitModule ("thunarx", pythunarx_functions);
- d = PyModule_GetDict (m);
-
- pythunarx_register_classes(d);
-
- if (PyErr_Occurred())
- {
- PyErr_Print();
- Py_FatalError("Can't initialize module thunarx");
- }
-}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list