[nautilus-python/wip/jtojnar/nautilus-4: 3/4] Port to libnautilus-extension-4
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-python/wip/jtojnar/nautilus-4: 3/4] Port to libnautilus-extension-4
- Date: Wed, 10 Aug 2022 21:10:05 +0000 (UTC)
commit c9b987c6e1f55e2e0b8fce71d7d3060a655a3a72
Author: Jan Tojnar <jtojnar gmail com>
Date: Wed Aug 10 21:31:32 2022 +0200
Port to libnautilus-extension-4
Mostly removed GTK-based API:
https://gitlab.gnome.org/GNOME/nautilus/-/merge_requests/927
docs/reference/nautilus-python-class-reference.xml | 1 -
.../nautilus-python-location-widget-provider.xml | 98 ---------------
docs/reference/nautilus-python-overview.xml | 4 +-
.../nautilus-python-property-page-provider.xml | 124 -------------------
docs/reference/nautilus-python-property-page.xml | 135 ---------------------
.../nautilus-python-provider-reference.xml | 2 -
examples/background-image.py | 4 +-
examples/location-widget-provider.py | 11 --
examples/md5sum-property-page.py | 42 -------
examples/meson.build | 2 -
examples/open-terminal.py | 4 +-
meson.build | 2 +-
src/nautilus-python-object.c | 109 -----------------
src/nautilus-python.c | 13 +-
src/nautilus-python.h | 12 --
15 files changed, 9 insertions(+), 554 deletions(-)
---
diff --git a/docs/reference/nautilus-python-class-reference.xml
b/docs/reference/nautilus-python-class-reference.xml
index 5117239..bc4a751 100644
--- a/docs/reference/nautilus-python-class-reference.xml
+++ b/docs/reference/nautilus-python-class-reference.xml
@@ -9,6 +9,5 @@
<xi:include href="nautilus-python-file-info.xml"/>
<xi:include href="nautilus-python-menu.xml"/>
<xi:include href="nautilus-python-menu-item.xml"/>
- <xi:include href="nautilus-python-property-page.xml"/>
</chapter>
diff --git a/docs/reference/nautilus-python-overview.xml b/docs/reference/nautilus-python-overview.xml
index 9827d78..ccdc291 100644
--- a/docs/reference/nautilus-python-overview.xml
+++ b/docs/reference/nautilus-python-overview.xml
@@ -10,8 +10,8 @@
One simply imports the Nautilus module from the gobject introspection repository and creates a class
which is derived from a gobject.GObject and
one of the Nautilus module's classes. When an extension derives a class, it becomes a "provider",
telling Nautilus to ask it for information. There are several types of providers
- available for extensions to use: there is MenuProvider, LocationWidgetProvider,
- ColumnProvider, PropertyPageProvider, and InfoProvider, all of which will be explained
+ available for extensions to use: there is MenuProvider,
+ ColumnProvider, and InfoProvider, all of which will be explained
in more detail below. Your class can be derived from multiple providers.</para>
<para>Here are the basic steps:</para>
diff --git a/docs/reference/nautilus-python-provider-reference.xml
b/docs/reference/nautilus-python-provider-reference.xml
index 3abb323..3c0d335 100644
--- a/docs/reference/nautilus-python-provider-reference.xml
+++ b/docs/reference/nautilus-python-provider-reference.xml
@@ -7,8 +7,6 @@
<title>Provider Interfaces</title>
<xi:include href="nautilus-python-column-provider.xml"/>
<xi:include href="nautilus-python-info-provider.xml"/>
- <xi:include href="nautilus-python-location-widget-provider.xml"/>
<xi:include href="nautilus-python-menu-provider.xml"/>
- <xi:include href="nautilus-python-property-page-provider.xml"/>
</chapter>
diff --git a/examples/background-image.py b/examples/background-image.py
index f5fca3c..298b4da 100644
--- a/examples/background-image.py
+++ b/examples/background-image.py
@@ -14,7 +14,7 @@ class BackgroundImageExtension(GObject.GObject, Nautilus.MenuProvider):
self.bgsettings[BACKGROUND_KEY] = file.get_uri()
- def get_file_items(self, window, files):
+ def get_file_items(self, files):
if len(files) != 1:
return
@@ -37,5 +37,5 @@ class BackgroundImageExtension(GObject.GObject, Nautilus.MenuProvider):
# Current versions of Nautilus will throw a warning if get_background_items
# isn't present
- def get_background_items(self, window, file):
+ def get_background_items(self, file):
return None
diff --git a/examples/meson.build b/examples/meson.build
index 5c79afc..266c0eb 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -9,9 +9,7 @@ install_data(
[
'background-image.py',
'block-size-column.py',
- 'location-widget-provider.py',
'open-terminal.py',
- 'md5sum-property-page.py',
'submenu.py',
'update-file-info-async.py',
],
diff --git a/examples/open-terminal.py b/examples/open-terminal.py
index 9ec8c39..c27f9ec 100644
--- a/examples/open-terminal.py
+++ b/examples/open-terminal.py
@@ -18,7 +18,7 @@ class OpenTerminalExtension(Nautilus.MenuProvider, GObject.GObject):
def menu_background_activate_cb(self, menu, file):
self._open_terminal(file)
- def get_file_items(self, window, files):
+ def get_file_items(self, files):
if len(files) != 1:
return
@@ -32,7 +32,7 @@ class OpenTerminalExtension(Nautilus.MenuProvider, GObject.GObject):
item.connect('activate', self.menu_activate_cb, file)
return item,
- def get_background_items(self, window, file):
+ def get_background_items(self, file):
item = Nautilus.MenuItem(name='NautilusPython::openterminal_file_item2',
label='Open Terminal' ,
tip='Open Terminal In %s' % file.get_name())
diff --git a/meson.build b/meson.build
index 6d6d937..b2ad7f4 100644
--- a/meson.build
+++ b/meson.build
@@ -20,7 +20,7 @@ pygobject_major_version = 3
pygobject_minor_version = 0
pygobject_micro_version = 0
pygobject = dependency('pygobject-3.0', version: f'>=
@pygobject_major_version@.@pygobject_minor_version@.@pygobject_micro_version@')
-libnautilus_extension = dependency('libnautilus-extension', version: '>= 3.27.90')
+libnautilus_extension = dependency('libnautilus-extension-4')
python_dep = python3.dependency(embed: true)
nautilus_extension_dir = libnautilus_extension.get_variable('extensiondir', pkgconfig_define: ['libdir',
libdir])
diff --git a/src/nautilus-python-object.c b/src/nautilus-python-object.c
index 1fe1098..3ee2a0a 100644
--- a/src/nautilus-python-object.c
+++ b/src/nautilus-python-object.c
@@ -156,89 +156,9 @@ nautilus_python_boxed_new (PyTypeObject *type, gpointer boxed, gboolean free_on_
return (PyObject *) self;
}
-#define METHOD_NAME "get_property_pages"
-static GList *
-nautilus_python_object_get_property_pages (NautilusPropertyPageProvider *provider,
- GList *files) {
- NautilusPythonObject *object = (NautilusPythonObject*)provider;
- PyObject *py_files, *py_ret = NULL;
- GList *ret = NULL;
- PyGILState_STATE state = pyg_gil_state_ensure();
-
- debug_enter();
-
- CHECK_OBJECT(object);
- CHECK_METHOD_NAME(object->instance);
-
- CONVERT_LIST(py_files, files);
-
- py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
- "(N)", py_files);
- HANDLE_RETVAL(py_ret);
-
- HANDLE_LIST(py_ret, NautilusPropertyPage, "Nautilus.PropertyPage");
-
-beach:
- Py_XDECREF(py_ret);
- pyg_gil_state_release(state);
- return ret;
-}
-#undef METHOD_NAME
-
-static void
-nautilus_python_object_property_page_provider_interface_init (NautilusPropertyPageProviderInterface
*interface) {
- interface->get_pages = nautilus_python_object_get_property_pages;
-}
-
-#define METHOD_NAME "get_widget"
-static GtkWidget *
-nautilus_python_object_get_widget (NautilusLocationWidgetProvider *provider,
- const char *uri,
- GtkWidget *window) {
- NautilusPythonObject *object = (NautilusPythonObject*)provider;
- GtkWidget *ret = NULL;
- PyObject *py_ret = NULL;
- PyGObject *py_ret_gobj;
- PyObject *py_uri = NULL;
- PyGILState_STATE state = pyg_gil_state_ensure();
-
- debug_enter();
-
- CHECK_OBJECT(object);
- CHECK_METHOD_NAME(object->instance);
-
- py_uri = __PyString_FromString(uri);
-
- py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
- "(NN)", py_uri,
- pygobject_new((GObject *)window));
- HANDLE_RETVAL(py_ret);
-
- py_ret_gobj = (PyGObject *)py_ret;
- if (!pygobject_check(py_ret_gobj, &PyGtkWidget_Type)) {
- PyErr_SetString(PyExc_TypeError,
- METHOD_NAME "should return a gtk.Widget");
- goto beach;
- }
-
- ret = (GtkWidget *)g_object_ref(py_ret_gobj->obj);
-
-beach:
- Py_XDECREF(py_ret);
- pyg_gil_state_release(state);
- return ret;
-}
-#undef METHOD_NAME
-
-static void
-nautilus_python_object_location_widget_provider_interface_init (NautilusLocationWidgetProviderInterface
*interface) {
- interface->get_widget = nautilus_python_object_get_widget;
-}
-
#define METHOD_NAME "get_file_items"
static GList *
nautilus_python_object_get_file_items (NautilusMenuProvider *provider,
- GtkWidget *window,
GList *files) {
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
@@ -254,14 +174,12 @@ nautilus_python_object_get_file_items (NautilusMenuProvider *provider,
py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_file_items_full",
"(NNN)",
pygobject_new((GObject *)provider),
- pygobject_new((GObject *)window),
py_files);
}
else if (PyObject_HasAttrString(object->instance, "get_file_items")) {
CONVERT_LIST(py_files, files);
py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
"(NN)",
- pygobject_new((GObject *)window),
py_files);
}
else {
@@ -283,7 +201,6 @@ beach:
#define METHOD_NAME "get_background_items"
static GList *
nautilus_python_object_get_background_items (NautilusMenuProvider *provider,
- GtkWidget *window,
NautilusFileInfo *file) {
NautilusPythonObject *object = (NautilusPythonObject*)provider;
GList *ret = NULL;
@@ -298,13 +215,11 @@ nautilus_python_object_get_background_items (NautilusMenuProvider *provider,
py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX "get_background_items_full",
"(NNN)",
pygobject_new((GObject *)provider),
- pygobject_new((GObject *)window),
pygobject_new((GObject *)file));
}
else if (PyObject_HasAttrString(object->instance, "get_background_items")) {
py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
"(NN)",
- pygobject_new((GObject *)window),
pygobject_new((GObject *)file));
}
else {
@@ -485,18 +400,6 @@ nautilus_python_object_get_type (GTypeModule *module,
GTypeInfo *info;
const char *type_name;
GType gtype;
-
- static const GInterfaceInfo property_page_provider_interface_info = {
- (GInterfaceInitFunc) nautilus_python_object_property_page_provider_interface_init,
- NULL,
- NULL
- };
-
- static const GInterfaceInfo location_widget_provider_interface_info = {
- (GInterfaceInitFunc) nautilus_python_object_location_widget_provider_interface_init,
- NULL,
- NULL
- };
static const GInterfaceInfo menu_provider_interface_info = {
(GInterfaceInitFunc) nautilus_python_object_menu_provider_interface_init,
@@ -535,18 +438,6 @@ nautilus_python_object_get_type (GTypeModule *module,
type_name,
info, 0);
- if (PyObject_IsSubclass(type, (PyObject*)&PyNautilusPropertyPageProvider_Type)) {
- g_type_module_add_interface (module, gtype,
- NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER,
- &property_page_provider_interface_info);
- }
-
- if (PyObject_IsSubclass(type, (PyObject*)&PyNautilusLocationWidgetProvider_Type)) {
- g_type_module_add_interface (module, gtype,
- NAUTILUS_TYPE_LOCATION_WIDGET_PROVIDER,
- &location_widget_provider_interface_info);
- }
-
if (PyObject_IsSubclass(type, (PyObject*)&PyNautilusMenuProvider_Type)) {
g_type_module_add_interface (module, gtype,
NAUTILUS_TYPE_MENU_PROVIDER,
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index 0db7234..39b27a0 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -24,7 +24,6 @@
#include <Python.h>
#include <pygobject.h>
#include <gmodule.h>
-#include <gtk/gtk.h>
#include "nautilus-python.h"
#include "nautilus-python-object.h"
@@ -85,9 +84,7 @@ nautilus_python_load_file(GTypeModule *type_module,
if (PyObject_IsSubclass(value, (PyObject*)&PyNautilusColumnProvider_Type) ||
PyObject_IsSubclass(value, (PyObject*)&PyNautilusInfoProvider_Type) ||
- PyObject_IsSubclass(value, (PyObject*)&PyNautilusLocationWidgetProvider_Type)
||
- PyObject_IsSubclass(value, (PyObject*)&PyNautilusMenuProvider_Type) ||
- PyObject_IsSubclass(value, (PyObject*)&PyNautilusPropertyPageProvider_Type)) {
+ PyObject_IsSubclass(value, (PyObject*)&PyNautilusMenuProvider_Type)) {
gtype = nautilus_python_object_get_type(type_module, value);
g_array_append_val(all_types, gtype);
}
@@ -194,16 +191,13 @@ nautilus_python_init_python (void) {
/* import nautilus */
g_setenv("INSIDE_NAUTILUS_PYTHON", "", FALSE);
debug("import nautilus");
- PyRun_SimpleString("import gi; gi.require_version('Nautilus', '3.0')");
+ PyRun_SimpleString("import gi; gi.require_version('Nautilus', '4.0')");
nautilus = PyImport_ImportModule("gi.repository.Nautilus");
if (!nautilus) {
PyErr_Print();
return FALSE;
}
- _PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
- g_assert(_PyGtkWidget_Type != NULL);
-
#define IMPORT(x, y) \
_PyNautilus##x##_Type = (PyTypeObject *)PyObject_GetAttrString(nautilus, y); \
if (_PyNautilus##x##_Type == NULL) { \
@@ -214,12 +208,9 @@ nautilus_python_init_python (void) {
IMPORT(Column, "Column");
IMPORT(ColumnProvider, "ColumnProvider");
IMPORT(InfoProvider, "InfoProvider");
- IMPORT(LocationWidgetProvider, "LocationWidgetProvider");
IMPORT(Menu, "Menu");
IMPORT(MenuItem, "MenuItem");
IMPORT(MenuProvider, "MenuProvider");
- IMPORT(PropertyPage, "PropertyPage");
- IMPORT(PropertyPageProvider, "PropertyPageProvider");
IMPORT(OperationHandle, "OperationHandle");
#undef IMPORT
diff --git a/src/nautilus-python.h b/src/nautilus-python.h
index 4c181f8..652f470 100644
--- a/src/nautilus-python.h
+++ b/src/nautilus-python.h
@@ -43,9 +43,6 @@ extern NautilusPythonDebug nautilus_python_debug;
#define debug_enter_args(x, y) { if (nautilus_python_debug & NAUTILUS_PYTHON_DEBUG_MISC) \
g_printf("%s: entered " x "\n", __FUNCTION__, y); }
-PyTypeObject *_PyGtkWidget_Type;
-#define PyGtkWidget_Type (*_PyGtkWidget_Type)
-
PyTypeObject *_PyNautilusColumn_Type;
#define PyNautilusColumn_Type (*_PyNautilusColumn_Type)
@@ -55,9 +52,6 @@ PyTypeObject *_PyNautilusColumnProvider_Type;
PyTypeObject *_PyNautilusInfoProvider_Type;
#define PyNautilusInfoProvider_Type (*_PyNautilusInfoProvider_Type)
-PyTypeObject *_PyNautilusLocationWidgetProvider_Type;
-#define PyNautilusLocationWidgetProvider_Type (*_PyNautilusLocationWidgetProvider_Type)
-
PyTypeObject *_PyNautilusMenu_Type;
#define PyNautilusMenu_Type (*_PyNautilusMenu_Type)
@@ -67,12 +61,6 @@ PyTypeObject *_PyNautilusMenuItem_Type;
PyTypeObject *_PyNautilusMenuProvider_Type;
#define PyNautilusMenuProvider_Type (*_PyNautilusMenuProvider_Type)
-PyTypeObject *_PyNautilusPropertyPage_Type;
-#define PyNautilusPropertyPage_Type (*_PyNautilusPropertyPage_Type)
-
-PyTypeObject *_PyNautilusPropertyPageProvider_Type;
-#define PyNautilusPropertyPageProvider_Type (*_PyNautilusPropertyPageProvider_Type)
-
PyTypeObject *_PyNautilusOperationHandle_Type;
#define PyNautilusOperationHandle_Type (*_PyNautilusOperationHandle_Type)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]