nautilus-python r58 - in trunk: . src
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-python r58 - in trunk: . src
- Date: Tue, 16 Sep 2008 19:02:27 +0000 (UTC)
Author: johan
Date: Tue Sep 16 19:02:27 2008
New Revision: 58
URL: http://svn.gnome.org/viewvc/nautilus-python?rev=58&view=rev
Log:
2008-09-16 Johan Dahlin <jdahlin async com br>
Bug 552534 â nautilus-python should support writing location widget providers
* src/nautilus-python-object.c (nautilus_python_object_get_widget),
(nautilus_python_object_location_widget_provider_iface_init),
(nautilus_python_object_get_type):
* src/nautilus-python.c (nautilus_python_load_file),
(nautilus_python_init_python):
* src/nautilus-python.h:
* src/nautilus.defs:
* src/nautilus.override:
Patch by Tim Cole
Modified:
trunk/ChangeLog
trunk/src/nautilus-python-object.c
trunk/src/nautilus-python.c
trunk/src/nautilus-python.h
trunk/src/nautilus.defs
trunk/src/nautilus.override
Modified: trunk/src/nautilus-python-object.c
==============================================================================
--- trunk/src/nautilus-python-object.c (original)
+++ trunk/src/nautilus-python-object.c Tue Sep 16 19:02:27 2008
@@ -33,6 +33,7 @@
#include <libnautilus-extension/nautilus-file-info.h>
#include <libnautilus-extension/nautilus-info-provider.h>
#include <libnautilus-extension/nautilus-column-provider.h>
+#include <libnautilus-extension/nautilus-location-widget-provider.h>
#include <libnautilus-extension/nautilus-menu-item.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-extension/nautilus-property-page-provider.h>
@@ -131,6 +132,51 @@
iface->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_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_iface_init (NautilusLocationWidgetProviderIface *iface)
+{
+ iface->get_widget = nautilus_python_object_get_widget;
+}
+
#define METHOD_NAME "get_file_items"
static GList *
nautilus_python_object_get_file_items (NautilusMenuProvider *provider,
@@ -364,6 +410,12 @@
NULL
};
+ static const GInterfaceInfo location_widget_provider_iface_info = {
+ (GInterfaceInitFunc) nautilus_python_object_location_widget_provider_iface_init,
+ NULL,
+ NULL
+ };
+
static const GInterfaceInfo menu_provider_iface_info = {
(GInterfaceInitFunc) nautilus_python_object_menu_provider_iface_init,
NULL,
@@ -406,6 +458,12 @@
NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER,
&property_page_provider_iface_info);
}
+
+ if (PyObject_IsSubclass(type, (PyObject*)&PyNautilusLocationWidgetProvider_Type)) {
+ g_type_module_add_interface (module, gtype,
+ NAUTILUS_TYPE_LOCATION_WIDGET_PROVIDER,
+ &location_widget_provider_iface_info);
+ }
if (PyObject_IsSubclass(type, (PyObject*)&PyNautilusMenuProvider_Type)) {
g_type_module_add_interface (module, gtype,
Modified: trunk/src/nautilus-python.c
==============================================================================
--- trunk/src/nautilus-python.c (original)
+++ trunk/src/nautilus-python.c Tue Sep 16 19:02:27 2008
@@ -139,6 +139,7 @@
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)) {
@@ -293,6 +294,9 @@
/* Extract types and interfaces from nautilus */
mdict = PyModule_GetDict(nautilus);
+ _PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
+ g_assert(_PyGtkWidget_Type != NULL);
+
#define IMPORT(x, y) \
_PyNautilus##x##_Type = (PyTypeObject *)PyDict_GetItemString(mdict, y); \
if (_PyNautilus##x##_Type == NULL) { \
@@ -303,6 +307,7 @@
IMPORT(Column, "Column");
IMPORT(ColumnProvider, "ColumnProvider");
IMPORT(InfoProvider, "InfoProvider");
+ IMPORT(LocationWidgetProvider, "LocationWidgetProvider");
IMPORT(Menu, "Menu");
IMPORT(MenuItem, "MenuItem");
IMPORT(MenuProvider, "MenuProvider");
Modified: trunk/src/nautilus-python.h
==============================================================================
--- trunk/src/nautilus-python.h (original)
+++ trunk/src/nautilus-python.h Tue Sep 16 19:02:27 2008
@@ -46,6 +46,9 @@
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,6 +58,9 @@
PyTypeObject *_PyNautilusInfoProvider_Type;
#define PyNautilusInfoProvider_Type (*_PyNautilusInfoProvider_Type)
+PyTypeObject *_PyNautilusLocationWidgetProvider_Type;
+#define PyNautilusLocationWidgetProvider_Type (*_PyNautilusLocationWidgetProvider_Type)
+
PyTypeObject *_PyNautilusMenu_Type;
#define PyNautilusMenu_Type (*_PyNautilusMenu_Type)
Modified: trunk/src/nautilus.defs
==============================================================================
--- trunk/src/nautilus.defs (original)
+++ trunk/src/nautilus.defs Tue Sep 16 19:02:27 2008
@@ -25,6 +25,12 @@
(gtype-id "NAUTILUS_TYPE_INFO_PROVIDER")
)
+(define-interface LocationWidgetProvider
+ (in-module "Nautilus")
+ (c-name "NautilusLocationWidgetProvider")
+ (gtype-id "NAUTILUS_TYPE_LOCATION_WIDGET_PROVIDER")
+)
+
(define-object Menu
(in-module "Nautilus")
(parent "GObject")
Modified: trunk/src/nautilus.override
==============================================================================
--- trunk/src/nautilus.override (original)
+++ trunk/src/nautilus.override Tue Sep 16 19:02:27 2008
@@ -28,6 +28,7 @@
#include <libnautilus-extension/nautilus-file-info.h>
#include <libnautilus-extension/nautilus-info-provider.h>
#include <libnautilus-extension/nautilus-column-provider.h>
+#include <libnautilus-extension/nautilus-location-widget-provider.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-extension/nautilus-property-page-provider.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]