[Xfce4-commits] [bindings/thunarx-python] 02/02: Remove tabs and switch to spaces, also move to same-line open curly braces

noreply at xfce.org noreply at xfce.org
Sat Dec 23 02:09:25 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 4ae064cbaa620671203bcd0f9907c2a630d94505
Author: Adam Plumb <adamplumb at gmail.com>
Date:   Fri Dec 22 20:09:16 2017 -0500

    Remove tabs and switch to spaces, also move to same-line open curly braces
---
 src/thunarx-python-object.c | 385 ++++++++++++++++++++------------------------
 src/thunarx-python.c        | 227 +++++++++++---------------
 2 files changed, 275 insertions(+), 337 deletions(-)

diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
index d7758a6..4d561c9 100644
--- a/src/thunarx-python-object.c
+++ b/src/thunarx-python-object.c
@@ -38,40 +38,34 @@ static void
 thunarx_python_object_finalize (GObject *object);
 static void
 thunarx_python_object_class_init (ThunarxPythonObjectClass *klass,
-								  gpointer                  class_data);
-								                  
-								                  
+                                  gpointer                  class_data);
+                                                  
+                                                  
 
 static void thunarx_python_object_menu_provider_iface_init      (ThunarxMenuProviderIface *iface);
 static GList *thunarx_python_object_get_file_menu_items            (ThunarxMenuProvider      *provider,
                                                                  GtkWidget                *window,
                                                                  GList                    *files);
 static GList *thunarx_python_object_get_folder_menu_items          (ThunarxMenuProvider      *provider,
-                              									 GtkWidget                *window,
-	                         		 							 ThunarxFileInfo          *folder);
+                                                                   GtkWidget                *window,
+                                                                   ThunarxFileInfo          *folder);
 static GList *thunarx_python_object_get_dnd_menu_items             (ThunarxMenuProvider      *provider,
-                       		  									 GtkWidget                *window,
-	                        									 ThunarxFileInfo          *folder,
-	                        									 GList                    *files);
+                                                                      GtkWidget                *window,
+                                                                 ThunarxFileInfo          *folder,
+                                                                 GList                    *files);
 
 
 static void thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface   *iface);
 static GList *thunarx_python_object_get_property_pages              (ThunarxPropertyPageProvider        *provider,
-										                             GList                              *files);
+                                                                     GList                              *files);
 
 static void   thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface    *iface);
 static GList *thunarx_python_object_get_preferences_menu_items         (ThunarxPreferencesProvider         *provider,
-										                             GtkWidget                          *window);
+                                                                     GtkWidget                          *window);
 
 static void   thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface  *iface);
 static GList *thunarx_python_object_get_renamers                (ThunarxRenamerProvider       *provider);
 
-/* These macros assumes the following things:
- *   a METHOD_NAME is defined with is a string
- *   a goto label called beach
- *   the return value is called ret
- */
-
 int __PyString_Check(PyObject *obj) {
 #if PY_MAJOR_VERSION >= 3
     return PyUnicode_Check(obj);
@@ -88,62 +82,68 @@ char* __PyString_AsString(PyObject *obj) {
 #endif
 }
 
+/* These macros assumes the following things:
+ *   a METHOD_NAME is defined with is a string
+ *   a goto label called beach
+ *   the return value is called ret
+ */
+ 
 #define CHECK_METHOD_NAME(self)                                             \
-	if (!PyObject_HasAttrString(self, METHOD_NAME))                         \
-		goto beach;
-
-#define CHECK_OBJECT(object)										        \
-  	if (object->instance == NULL)									        \
-  	{																        \
-  		g_object_unref (object);									        \
-  		goto beach;													        \
-  	}																        \
-	
+    if (!PyObject_HasAttrString(self, METHOD_NAME))                         \
+        goto beach;
+
+#define CHECK_OBJECT(object)                                                \
+      if (object->instance == NULL)                                            \
+      {                                                                        \
+          g_object_unref (object);                                            \
+          goto beach;                                                            \
+      }                                                                        \
+    
 #define CONVERT_LIST(py_files, files)                                       \
-	{                                                                       \
-		GList *l;                                                           \
+    {                                                                       \
+        GList *l;                                                           \
         py_files = PyList_New(0);                                           \
-		for (l = files; l; l = l->next)                                     \
-		{                                                                   \
-			PyList_Append(py_files, pygobject_new((GObject*)l->data));		\
-		}                                                                   \
-	}
+        for (l = files; l; l = l->next)                                     \
+        {                                                                   \
+            PyList_Append(py_files, pygobject_new((GObject*)l->data));        \
+        }                                                                   \
+    }
 
 #define HANDLE_RETVAL(py_ret)                                               \
     if (!py_ret)                                                            \
     {                                                                       \
         PyErr_Print();                                                      \
-		goto beach;                                                         \
- 	}                                                                       \
- 	else if (py_ret == Py_None)                                             \
- 	{                                                                       \
- 		goto beach;                                                         \
-	}
+        goto beach;                                                         \
+     }                                                                       \
+     else if (py_ret == Py_None)                                             \
+     {                                                                       \
+         goto beach;                                                         \
+    }
 
 #define HANDLE_LIST(py_ret, type, type_name)                                \
     {                                                                       \
         Py_ssize_t i = 0;                                                   \
-    	if (!PySequence_Check(py_ret) || __PyString_Check(py_ret))            \
-    	{                                                                   \
-    		PyErr_SetString(PyExc_TypeError,                                \
-    						METHOD_NAME " must return a sequence");         \
-    		goto beach;                                                     \
-    	}                                                                   \
-    	for (i = 0; i < PySequence_Size (py_ret); i++)                      \
-    	{                                                                   \
-    		PyGObject *py_item;                                             \
-    		py_item = (PyGObject*)PySequence_GetItem (py_ret, i);           \
-    		if (!pygobject_check(py_item, &Py##type##_Type))                \
-    		{                                                               \
-    			PyErr_SetString(PyExc_TypeError,                            \
-    							METHOD_NAME                                 \
-    							" must return a sequence of "               \
-    							type_name);                                 \
-    			goto beach;                                                 \
-    		}                                                               \
-    		ret = g_list_append (ret, (type*) g_object_ref(py_item->obj));  \
+        if (!PySequence_Check(py_ret) || __PyString_Check(py_ret))            \
+        {                                                                   \
+            PyErr_SetString(PyExc_TypeError,                                \
+                            METHOD_NAME " must return a sequence");         \
+            goto beach;                                                     \
+        }                                                                   \
+        for (i = 0; i < PySequence_Size (py_ret); i++)                      \
+        {                                                                   \
+            PyGObject *py_item;                                             \
+            py_item = (PyGObject*)PySequence_GetItem (py_ret, i);           \
+            if (!pygobject_check(py_item, &Py##type##_Type))                \
+            {                                                               \
+                PyErr_SetString(PyExc_TypeError,                            \
+                                METHOD_NAME                                 \
+                                " must return a sequence of "               \
+                                type_name);                                 \
+                goto beach;                                                 \
+            }                                                               \
+            ret = g_list_append (ret, (type*) g_object_ref(py_item->obj));  \
             Py_DECREF(py_item);                                             \
-    	}                                                                   \
+        }                                                                   \
     }
 
 
@@ -151,8 +151,7 @@ char* __PyString_AsString(PyObject *obj) {
 static GList *
 thunarx_python_object_get_file_menu_items (ThunarxMenuProvider *provider,
                                         GtkWidget *window,
-                                        GList *files)
-{
+                                        GList *files) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     GList *ret = NULL;
     PyObject *py_ret = NULL, *py_files;
@@ -166,7 +165,7 @@ thunarx_python_object_get_file_menu_items (ThunarxMenuProvider *provider,
     CONVERT_LIST(py_files, files);
 
     py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
-							     "(NN)", pygobject_new((GObject *)window), py_files);
+                                 "(NN)", pygobject_new((GObject *)window), py_files);
 
     HANDLE_RETVAL(py_ret);
 
@@ -184,13 +183,11 @@ beach:
 #undef METHOD_NAME
 
 
-
 #define METHOD_NAME "get_folder_menu_items"
 static GList *
 thunarx_python_object_get_folder_menu_items (ThunarxMenuProvider   *provider,
- 		  								  GtkWidget             *window,
-	  									  ThunarxFileInfo       *folder)
-{
+                                             GtkWidget             *window,
+                                            ThunarxFileInfo       *folder) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     GList *ret = NULL;
     PyObject *py_ret = NULL;
@@ -202,14 +199,14 @@ thunarx_python_object_get_folder_menu_items (ThunarxMenuProvider   *provider,
     CHECK_METHOD_NAME(object->instance);
 
     py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
-						         "(NN)",
-						         pygobject_new((GObject *)window),
-						         pygobject_new((GObject *)folder));
-						     
+                                 "(NN)",
+                                 pygobject_new((GObject *)window),
+                                 pygobject_new((GObject *)folder));
+                             
     HANDLE_RETVAL(py_ret);
 
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
-	
+    
 beach:
     if (PyErr_Occurred()) {
 	PyErr_Print();
@@ -228,8 +225,7 @@ static GList *
 thunarx_python_object_get_dnd_menu_items (ThunarxMenuProvider  *provider,
                                        GtkWidget            *window,
                                        ThunarxFileInfo      *folder,
-                                       GList                *files)
-{
+                                       GList                *files) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     GList *ret = NULL;
     PyObject *py_ret = NULL, *py_files;
@@ -243,10 +239,10 @@ thunarx_python_object_get_dnd_menu_items (ThunarxMenuProvider  *provider,
     CONVERT_LIST(py_files, files);
 
     py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
-							     "(NN)", 
-							     pygobject_new((GObject *)window), 
-							     pygobject_new((GObject *)folder),
-							     py_files);
+                                 "(NN)", 
+                                 pygobject_new((GObject *)window), 
+                                 pygobject_new((GObject *)folder),
+                                 py_files);
 
     HANDLE_RETVAL(py_ret);
 
@@ -266,11 +262,10 @@ beach:
 
 
 static void
-thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface)
-{
-	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;
+thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface) {
+    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;
 }
 
 
@@ -278,8 +273,7 @@ thunarx_python_object_menu_provider_iface_init (ThunarxMenuProviderIface *iface)
 #define METHOD_NAME "get_property_pages"
 static GList *
 thunarx_python_object_get_property_pages (ThunarxPropertyPageProvider *provider,
-										  GList                       *files)
-{
+                                          GList                       *files) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     PyObject *py_files, *py_ret = NULL;
     GList *ret = NULL;
@@ -293,12 +287,12 @@ thunarx_python_object_get_property_pages (ThunarxPropertyPageProvider *provider,
     CONVERT_LIST(py_files, files);
 
     py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
-							     "(N)", py_files);
+                                 "(N)", py_files);
 
     HANDLE_RETVAL(py_ret);
 
     HANDLE_LIST(py_ret, ThunarxPropertyPage, "Thunarx.PropertyPage");
-	
+    
 beach:
     if (PyErr_Occurred()) {
 	PyErr_Print();
@@ -314,8 +308,7 @@ beach:
 
 #define METHOD_NAME "get_renamers"
 static GList *
-thunarx_python_object_get_renamers (ThunarxRenamerProvider *provider)
-{
+thunarx_python_object_get_renamers (ThunarxRenamerProvider *provider) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     PyObject *py_ret = NULL;
     GList *ret = NULL;
@@ -343,29 +336,20 @@ beach:
 }
 #undef METHOD_NAME
 
-
-
 static void
-thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface *iface)
-{
-	iface->get_pages = thunarx_python_object_get_property_pages;
+thunarx_python_object_property_page_provider_iface_init (ThunarxPropertyPageProviderIface *iface) {
+    iface->get_pages = thunarx_python_object_get_property_pages;
 }
 
-
-
 static void
-thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface)
-{
-	iface->get_renamers = thunarx_python_object_get_renamers;
+thunarx_python_object_renamer_provider_iface_init (ThunarxRenamerProviderIface *iface) {
+    iface->get_renamers = thunarx_python_object_get_renamers;
 }
 
-
-
 #define METHOD_NAME "get_preferences_menu_items"
 static GList *
 thunarx_python_object_get_preferences_menu_items (ThunarxPreferencesProvider *provider,
-										       GtkWidget                  *window)
-{
+                                               GtkWidget                  *window) {
     ThunarxPythonObject *object = (ThunarxPythonObject*)provider;
     PyObject *py_ret = NULL;
     GList *ret = NULL;
@@ -377,12 +361,12 @@ thunarx_python_object_get_preferences_menu_items (ThunarxPreferencesProvider *pr
     CHECK_METHOD_NAME(object->instance);
 
     py_ret = PyObject_CallMethod(object->instance, METHOD_PREFIX METHOD_NAME,
-						        "(N)", pygobject_new((GObject *)window));
+                                "(N)", pygobject_new((GObject *)window));
 
     HANDLE_RETVAL(py_ret);
 
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
-	
+    
 beach:
     if (PyErr_Occurred()) {
 	PyErr_Print();
@@ -394,19 +378,13 @@ beach:
 }
 #undef METHOD_NAME
 
-
-
 static void
-thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface)
-{
-	iface->get_menu_items = thunarx_python_object_get_preferences_menu_items;
+thunarx_python_object_preferences_provider_iface_init (ThunarxPreferencesProviderIface *iface) {
+    iface->get_menu_items = thunarx_python_object_get_preferences_menu_items;
 }
 
-
-
 static void 
-thunarx_python_object_instance_init (ThunarxPythonObject *object)
-{
+thunarx_python_object_instance_init (ThunarxPythonObject *object) {
     ThunarxPythonObjectClass *class;
     debug_enter();
 
@@ -414,12 +392,11 @@ thunarx_python_object_instance_init (ThunarxPythonObject *object)
 
     object->instance = PyObject_CallObject(class->type, NULL);
     if (object->instance == NULL)
-	    PyErr_Print();
+        PyErr_Print();
 }
 
 static void
-thunarx_python_object_finalize (GObject *object)
-{
+thunarx_python_object_finalize (GObject *object) {
     debug_enter();
 
     if (((ThunarxPythonObject *)object)->instance != NULL)
@@ -428,98 +405,94 @@ thunarx_python_object_finalize (GObject *object)
 
 static void
 thunarx_python_object_class_init (ThunarxPythonObjectClass *klass,
-								  gpointer                  class_data)
-{
-	debug_enter();
-
-	parent_class = g_type_class_peek_parent (klass);
-	
-	klass->type = (PyObject*)class_data;
-	
-	G_OBJECT_CLASS (klass)->finalize = thunarx_python_object_finalize;
-}
-
+                                  gpointer                  class_data) {
+    debug_enter();
 
+    parent_class = g_type_class_peek_parent (klass);
+    
+    klass->type = (PyObject*)class_data;
+    
+    G_OBJECT_CLASS (klass)->finalize = thunarx_python_object_finalize;
+}
 
 GType 
 thunarx_python_object_get_type (ThunarxProviderPlugin   *plugin, 
-                                PyObject                *type)
-{
-	GTypeInfo *info;
-	const char *type_name;
-	GType gtype;
-
-	static const GInterfaceInfo property_page_provider_iface_info = {
-		(GInterfaceInitFunc) thunarx_python_object_property_page_provider_iface_init,
-		NULL,
-		NULL
-	};
-
-	static const GInterfaceInfo menu_provider_iface_info = {
-		(GInterfaceInitFunc) thunarx_python_object_menu_provider_iface_init,
-		NULL,
-		NULL
-	};
-
-	static const GInterfaceInfo renamer_provider_iface_info = {
-		(GInterfaceInitFunc) thunarx_python_object_renamer_provider_iface_init,
-		NULL,
-		NULL
-	};
-
-	static const GInterfaceInfo preferences_provider_iface_info = {
-		(GInterfaceInitFunc) thunarx_python_object_preferences_provider_iface_init,
-		NULL,
-		NULL
-	};
-
-	debug_enter_args("type=%s", __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
-
-	info = g_new0 (GTypeInfo, 1);
-	
-	info->class_size = sizeof (ThunarxPythonObjectClass);
-	info->class_init = (GClassInitFunc)thunarx_python_object_class_init;
-	info->instance_size = sizeof (ThunarxPythonObject);
-	info->instance_init = (GInstanceInitFunc)thunarx_python_object_instance_init;
-
-	info->class_data = type;
-	Py_INCREF(type);
-
-	type_name = g_strdup_printf("%s+ThunarxPython",
-	    __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
-
-	gtype = thunarx_provider_plugin_register_type (plugin, 
-										 G_TYPE_OBJECT,
-										 type_name,
-										 info, 0);
-
-	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPropertyPageProvider_Type))
-	{
-		thunarx_provider_plugin_add_interface (plugin, gtype, 
-									 THUNARX_TYPE_PROPERTY_PAGE_PROVIDER,
-									 &property_page_provider_iface_info);
-	}
-
-	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxMenuProvider_Type))
-	{
-		thunarx_provider_plugin_add_interface (plugin, gtype, 
-									 THUNARX_TYPE_MENU_PROVIDER,
-									 &menu_provider_iface_info);
-	}
-
-	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxRenamerProvider_Type))
-	{
-		thunarx_provider_plugin_add_interface (plugin, gtype, 
-									 THUNARX_TYPE_RENAMER_PROVIDER,
-									 &renamer_provider_iface_info);
-	}
-
-	if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPreferencesProvider_Type))
-	{
-		thunarx_provider_plugin_add_interface (plugin, gtype, 
-									 THUNARX_TYPE_PREFERENCES_PROVIDER,
-									 &preferences_provider_iface_info);
-	}
-	
-	return gtype;
+                                PyObject                *type) {
+    GTypeInfo *info;
+    const char *type_name;
+    GType gtype;
+
+    static const GInterfaceInfo property_page_provider_iface_info = {
+        (GInterfaceInitFunc) thunarx_python_object_property_page_provider_iface_init,
+        NULL,
+        NULL
+    };
+
+    static const GInterfaceInfo menu_provider_iface_info = {
+        (GInterfaceInitFunc) thunarx_python_object_menu_provider_iface_init,
+        NULL,
+        NULL
+    };
+
+    static const GInterfaceInfo renamer_provider_iface_info = {
+        (GInterfaceInitFunc) thunarx_python_object_renamer_provider_iface_init,
+        NULL,
+        NULL
+    };
+
+    static const GInterfaceInfo preferences_provider_iface_info = {
+        (GInterfaceInitFunc) thunarx_python_object_preferences_provider_iface_init,
+        NULL,
+        NULL
+    };
+
+    debug_enter_args("type=%s", __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+
+    info = g_new0 (GTypeInfo, 1);
+    
+    info->class_size = sizeof (ThunarxPythonObjectClass);
+    info->class_init = (GClassInitFunc)thunarx_python_object_class_init;
+    info->instance_size = sizeof (ThunarxPythonObject);
+    info->instance_init = (GInstanceInitFunc)thunarx_python_object_instance_init;
+
+    info->class_data = type;
+    Py_INCREF(type);
+
+    type_name = g_strdup_printf("%s+ThunarxPython",
+        __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+
+    gtype = thunarx_provider_plugin_register_type (plugin, 
+                                         G_TYPE_OBJECT,
+                                         type_name,
+                                         info, 0);
+
+    if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPropertyPageProvider_Type))
+    {
+        thunarx_provider_plugin_add_interface (plugin, gtype, 
+                                     THUNARX_TYPE_PROPERTY_PAGE_PROVIDER,
+                                     &property_page_provider_iface_info);
+    }
+
+    if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxMenuProvider_Type))
+    {
+        thunarx_provider_plugin_add_interface (plugin, gtype, 
+                                     THUNARX_TYPE_MENU_PROVIDER,
+                                     &menu_provider_iface_info);
+    }
+
+    if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxRenamerProvider_Type))
+    {
+        thunarx_provider_plugin_add_interface (plugin, gtype, 
+                                     THUNARX_TYPE_RENAMER_PROVIDER,
+                                     &renamer_provider_iface_info);
+    }
+
+    if (PyObject_IsSubclass(type, (PyObject*)&PyThunarxPreferencesProvider_Type))
+    {
+        thunarx_provider_plugin_add_interface (plugin, gtype, 
+                                     THUNARX_TYPE_PREFERENCES_PROVIDER,
+                                     &preferences_provider_iface_info);
+    }
+    
+    return gtype;
 }
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index 1662814..91b3bcf 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -46,9 +46,8 @@ static gboolean thunarx_python_init_python (void);
 
 
 static inline gboolean 
-thunarx_python_init_pygobject(void)
-{
-	PyObject *gobject = pygobject_init (3, 0, 0);
+thunarx_python_init_pygobject(void) {
+    PyObject *gobject = pygobject_init (3, 0, 0);
 
     if (gobject == NULL) {
         PyErr_Print ();
@@ -60,10 +59,9 @@ thunarx_python_init_pygobject(void)
 
 
 static gboolean 
-thunarx_python_init_python (void)
-{
-	PyObject *thunarx;
-	GModule *libpython;
+thunarx_python_init_python (void) {
+    PyObject *thunarx;
+    GModule *libpython;
 
     debug_enter();
 
@@ -78,12 +76,11 @@ thunarx_python_init_python (void)
     libpython = g_module_open (PY_LIB_LOC "/lib" PYTHON_LIB_NAME "." G_MODULE_SUFFIX ".1.0", 0);
     if (!libpython) {
         g_warning ("g_module_open libpython failed: %s", g_module_error());
-	}
+    }
 
     debug ("Py_Initialize");
     Py_Initialize();
-    if (PyErr_Occurred())
-    {
+    if (PyErr_Occurred()) {
         PyErr_Print();
         return FALSE;
     }
@@ -95,189 +92,164 @@ thunarx_python_init_python (void)
     char *argv[] = { "thunar", NULL };
 #endif
     PySys_SetArgv (1, argv);
-    if (PyErr_Occurred())
-    {
+    if (PyErr_Occurred()) {
         PyErr_Print();
         return FALSE;
     }
 
-	debug("Sanitize the python search path");
-	PyRun_SimpleString("import sys; sys.path = [path for path in sys.path if path]");
-	if (PyErr_Occurred())
-	{
-		PyErr_Print();
-		return FALSE;
-	}
+    debug("Sanitize the python search path");
+    PyRun_SimpleString("import sys; sys.path = [path for path in sys.path if path]");
+    if (PyErr_Occurred()) {
+        PyErr_Print();
+        return FALSE;
+    }
 
-	/* import gobject */
+    /* import gobject */
     debug("init_pygobject");
-	if (!thunarx_python_init_pygobject())
-	{
-		g_warning("pygobject initialization failed");
-		return FALSE;
-	}
+    if (!thunarx_python_init_pygobject()) {
+        g_warning("pygobject initialization failed");
+        return FALSE;
+    }
 
     g_setenv("INSIDE_THUNARX_PYTHON", "", FALSE);
     debug("import Thunarx");
     PyRun_SimpleString("import gi; gi.require_version('Thunarx', '3.0')");
     thunarx = PyImport_ImportModule("gi.repository.Thunarx");
-    if (!thunarx)
-    {
+    if (!thunarx) {
         PyErr_Print();
         return FALSE;
     }
-    	
-	_PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
-	g_assert(_PyGtkWidget_Type != NULL);
+        
+    _PyGtkWidget_Type = pygobject_lookup_class(GTK_TYPE_WIDGET);
+    g_assert(_PyGtkWidget_Type != NULL);
 
 #define IMPORT(x, y) \
     _PyThunarx##x##_Type = (PyTypeObject *)PyObject_GetAttrString(thunarx, y); \
-	if (_PyThunarx##x##_Type == NULL) { \
-		PyErr_Print(); \
-		return FALSE; \
-	}
+    if (_PyThunarx##x##_Type == NULL) { \
+        PyErr_Print(); \
+        return FALSE; \
+    }
 
-	IMPORT(FileInfo, "FileInfo");
+    IMPORT(FileInfo, "FileInfo");
     IMPORT(MenuItem, "MenuItem");
     IMPORT(Menu, "Menu");
-	IMPORT(MenuProvider, "MenuProvider");
-	IMPORT(PreferencesProvider, "PreferencesProvider");
-	IMPORT(PropertyPage, "PropertyPage");
-	IMPORT(PropertyPageProvider, "PropertyPageProvider");
-	IMPORT(ProviderPlugin, "ProviderPlugin");
-	IMPORT(Renamer, "Renamer");
-	IMPORT(RenamerProvider, "RenamerProvider");
-	
+    IMPORT(MenuProvider, "MenuProvider");
+    IMPORT(PreferencesProvider, "PreferencesProvider");
+    IMPORT(PropertyPage, "PropertyPage");
+    IMPORT(PropertyPageProvider, "PropertyPageProvider");
+    IMPORT(ProviderPlugin, "ProviderPlugin");
+    IMPORT(Renamer, "Renamer");
+    IMPORT(RenamerProvider, "RenamerProvider");
+    
 #undef IMPORT
   
     return TRUE;
 }
 
-
-
 static void
 thunarx_python_load_file (ThunarxProviderPlugin *plugin, 
-                          const gchar           *filename)
-{
+                          const gchar           *filename) {
     PyObject *main_module, *main_locals, *locals, *key, *value;
     PyObject *module;
     Py_ssize_t pos = 0;
     GType new_type;
 
     main_module = PyImport_AddModule("__main__");
-    if (main_module == NULL)
-    {
+    if (main_module == NULL) {
         g_warning ("Could not get __main__");
         return;
     }
 
     main_locals = PyModule_GetDict(main_module);
     module = PyImport_ImportModuleEx((char *) filename, main_locals, main_locals, NULL);
-    if (!module)
-    {
+    if (!module) {
         PyErr_Print();
         return;
     }
 
     locals = PyModule_GetDict(module);
   
-    while (PyDict_Next(locals, &pos, &key, &value))
-    {
+    while (PyDict_Next(locals, &pos, &key, &value)) {
         if (!PyType_Check(value))
             continue;
 
         if (PyObject_IsSubclass(value, (PyObject*)&PyThunarxMenuProvider_Type) ||
-            PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type) ||
-            PyObject_IsSubclass(value, (PyObject*)&PyThunarxPreferencesProvider_Type) ||
-            PyObject_IsSubclass(value, (PyObject*)&PyThunarxRenamerProvider_Type))
-        {
+				PyObject_IsSubclass(value, (PyObject*)&PyThunarxPropertyPageProvider_Type) ||
+				PyObject_IsSubclass(value, (PyObject*)&PyThunarxPreferencesProvider_Type) ||
+				PyObject_IsSubclass(value, (PyObject*)&PyThunarxRenamerProvider_Type)) {
             new_type = thunarx_python_object_get_type(plugin, value);
             g_array_append_val(all_types, new_type);
         }
     }
-
-    debug ("python modules loaded");
 }
 
-
-
 static void
 thunarx_python_load_dir (ThunarxProviderPlugin  *plugin, 
-                         const char             *dirname)
-{
-	GDir *dir;
-	const char *name;
-	gboolean initialized = FALSE;
-
-	debug_enter_args("dirname=%s", dirname);
-	
-	dir = g_dir_open (dirname, 0, NULL);
-	if (!dir)
-		return;
-			
-	while ((name = g_dir_read_name(dir)))
-	{
-		if (g_str_has_suffix(name, ".py"))
-		{
-			char *modulename;
-			int len;
-
-			len = strlen(name) - 3;
-			modulename = g_new0(char, len + 1);
-			strncpy(modulename, name, len);
-
-			if (!initialized)
-			{
-			    PyObject *sys_path, *py_path;
+                         const char             *dirname) {
+    GDir *dir;
+    const char *name;
+    gboolean initialized = FALSE;
+
+    debug_enter_args("dirname=%s", dirname);
+    
+    dir = g_dir_open (dirname, 0, NULL);
+    if (!dir)
+        return;
+            
+    while ((name = g_dir_read_name(dir))) {
+        if (g_str_has_suffix(name, ".py")) {
+            char *modulename;
+            int len;
+
+            len = strlen(name) - 3;
+            modulename = g_new0(char, len + 1);
+            strncpy(modulename, name, len);
+
+            if (!initialized) {
+                PyObject *sys_path, *py_path;
 
                 /* n-p python part is initialized on demand (or not
                 * at all if no extensions are found) */
-				if (!thunarx_python_init_python())
-				{
-					g_warning("thunarx_python_init_python failed");
-					g_dir_close(dir);
-				}
+                if (!thunarx_python_init_python()) {
+                    g_warning("thunarx_python_init_python failed");
+                    g_dir_close(dir);
+                }
                 
                 /* sys.path.insert(0, dirname) */
-				sys_path = PySys_GetObject("path");
+                sys_path = PySys_GetObject("path");
 #if PY_MAJOR_VERSION >= 3
-				py_path = PyUnicode_FromString(dirname);
+                py_path = PyUnicode_FromString(dirname);
 #else
-				py_path = PyString_FromString(dirname);
+                py_path = PyString_FromString(dirname);
 #endif
-				PyList_Insert(sys_path, 0, py_path);
-				Py_DECREF(py_path);
-			}
+                PyList_Insert(sys_path, 0, py_path);
+                Py_DECREF(py_path);
+            }
 
-			thunarx_python_load_file(plugin, modulename);
-		}
-	}
+            thunarx_python_load_file(plugin, modulename);
+        }
+    }
 }
 
-
-
 G_MODULE_EXPORT void
-thunar_extension_initialize (ThunarxProviderPlugin *plugin)
-{
+thunar_extension_initialize (ThunarxProviderPlugin *plugin) {
     gchar *user_extensions_dir;
     const gchar *mismatch;
     const gchar *env_string;
 
-	env_string = g_getenv("THUNARX_PYTHON_DEBUG");
-	if (env_string != NULL)
-	{
-		thunarx_python_debug = g_parse_debug_string(env_string,
-													 thunarx_python_debug_keys,
-													 thunarx_python_ndebug_keys);
-		env_string = NULL;
+    env_string = g_getenv("THUNARX_PYTHON_DEBUG");
+    if (env_string != NULL) {
+        thunarx_python_debug = g_parse_debug_string(env_string,
+                                                     thunarx_python_debug_keys,
+                                                     thunarx_python_ndebug_keys);
+        env_string = NULL;
     }
 
     debug_enter();
 
     /* verify that the thunarx versions are compatible */
     mismatch = thunarx_check_version (THUNARX_MAJOR_VERSION, THUNARX_MINOR_VERSION, THUNARX_MICRO_VERSION);
-    if (G_UNLIKELY (mismatch != NULL))
-    {
+    if (G_UNLIKELY (mismatch != NULL)) {
         g_warning ("Version mismatch: %s", mismatch);
         return;
     }
@@ -286,23 +258,20 @@ thunar_extension_initialize (ThunarxProviderPlugin *plugin)
 
     thunarx_provider_plugin_set_resident (plugin, TRUE);
 
-	// Look in the new global path, $DATADIR/thunarx-python/extensions
-	thunarx_python_load_dir(plugin, DATADIR "/thunarx-python/extensions");
+    // Look in the new global path, $DATADIR/thunarx-python/extensions
+    thunarx_python_load_dir(plugin, DATADIR "/thunarx-python/extensions");
 
-	// Look in XDG_DATA_DIR, ~/.local/share/thunarx-python/extensions
-	user_extensions_dir = g_build_filename(g_get_user_data_dir(), 
-		"thunarx-python", "extensions", NULL);
-	thunarx_python_load_dir(plugin, user_extensions_dir);
-	g_free(user_extensions_dir);
-	
+    // Look in XDG_DATA_DIR, ~/.local/share/thunarx-python/extensions
+    user_extensions_dir = g_build_filename(g_get_user_data_dir(), 
+        "thunarx-python", "extensions", NULL);
+    thunarx_python_load_dir(plugin, user_extensions_dir);
+    g_free(user_extensions_dir);
+    
     thunarx_python_load_dir(plugin, THUNARX_EXTENSION_DIR "/python");
 }
 
-
-
 G_MODULE_EXPORT void
-thunar_extension_shutdown (void)
-{
+thunar_extension_shutdown (void) {
     debug_enter();
 
     if (Py_IsInitialized())
@@ -311,15 +280,11 @@ thunar_extension_shutdown (void)
     g_array_free (all_types, TRUE);
 }
 
-
-
 G_MODULE_EXPORT void
 thunar_extension_list_types (const GType **types,
-                             gint         *n_types)
-{
+                             gint         *n_types) {
     debug_enter();
 
     *types = (GType*)all_types->data;
     *n_types = all_types->len;
 }
-

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list