Fix warning: excess elements in struct initializer
[claws.git] / src / plugins / python / python_plugin.c
index ada776a8bd12d75f6a56af1efd7bfe33e64dcc4e..03c2ea4e888800a54ca96150937ee8df40ec06bd 100644 (file)
@@ -56,7 +56,7 @@ static GSList *python_compose_scripts_names = NULL;
 
 static GtkWidget *python_console = NULL;
 
 
 static GtkWidget *python_console = NULL;
 
-static guint hook_compose_create;
+static gulong hook_compose_create = 0;
 
 static gboolean python_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
 
 static gboolean python_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
 {
@@ -355,7 +355,7 @@ static void create_compose_menus_and_items(GSList *filenames)
 }
 
 static GtkActionEntry compose_tools_python_actions[] = {
 }
 
 static GtkActionEntry compose_tools_python_actions[] = {
-    {"Tools/PythonScripts", NULL, N_("Python scripts") },
+    {"Tools/PythonScripts", NULL, N_("Python scripts"), NULL, NULL, NULL },
 };
 
 static void ComposeActionData_destroy_cb(gpointer data)
 };
 
 static void ComposeActionData_destroy_cb(gpointer data)
@@ -499,12 +499,12 @@ static GtkToggleActionEntry mainwindow_tools_python_toggle[] = {
 };
 
 static GtkActionEntry mainwindow_tools_python_actions[] = {
 };
 
 static GtkActionEntry mainwindow_tools_python_actions[] = {
-    {"Tools/PythonScripts", NULL, N_("Python scripts") },
+    {"Tools/PythonScripts", NULL, N_("Python scripts"), NULL, NULL, NULL },
     {"Tools/PythonScripts/Refresh", NULL, N_("Refresh"),
         NULL, NULL, G_CALLBACK(refresh_python_scripts_menus) },
     {"Tools/PythonScripts/Browse", NULL, N_("Browse"),
         NULL, NULL, G_CALLBACK(browse_python_scripts_dir) },
     {"Tools/PythonScripts/Refresh", NULL, N_("Refresh"),
         NULL, NULL, G_CALLBACK(refresh_python_scripts_menus) },
     {"Tools/PythonScripts/Browse", NULL, N_("Browse"),
         NULL, NULL, G_CALLBACK(browse_python_scripts_dir) },
-    {"Tools/PythonScripts/---", NULL, "---" },
+    {"Tools/PythonScripts/---", NULL, "---", NULL, NULL, NULL },
 };
 
 static int python_menu_init(char **error)
 };
 
 static int python_menu_init(char **error)
@@ -634,12 +634,17 @@ done:
   Py_XDECREF(meth_getvalue);
   Py_XDECREF(result_getvalue);
 
   Py_XDECREF(meth_getvalue);
   Py_XDECREF(result_getvalue);
 
-  return retval ? retval : g_strdup("Unspecified error occured");
+  return retval ? retval : g_strdup("Unspecified error occurred");
 }
 
 }
 
+static void log_func(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data)
+{
+}
 
 gint plugin_init(gchar **error)
 {
 
 gint plugin_init(gchar **error)
 {
+  guint log_handler;
+  int parasite_retval;
   PyObject *inst_StringIO = NULL;
 
   /* Version check */
   PyObject *inst_StringIO = NULL;
 
   /* Version check */
@@ -648,7 +653,7 @@ gint plugin_init(gchar **error)
 
   /* load hooks */
   hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
 
   /* load hooks */
   hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
-  if(hook_compose_create == (guint)-1) {
+  if(hook_compose_create == 0) {
     *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
     return -1;
   }
     *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
     return -1;
   }
@@ -662,7 +667,7 @@ gint plugin_init(gchar **error)
 
   /* The Python C API only offers to print an exception to sys.stderr. In order to catch it
    * in a string, a StringIO object is created, to which sys.stderr can be redirected in case
 
   /* The Python C API only offers to print an exception to sys.stderr. In order to catch it
    * in a string, a StringIO object is created, to which sys.stderr can be redirected in case
-   * an error occured. */
+   * an error occurred. */
   inst_StringIO = get_StringIO_instance();
 
   /* initialize Claws Mail Python module */
   inst_StringIO = get_StringIO_instance();
 
   /* initialize Claws Mail Python module */
@@ -678,7 +683,10 @@ gint plugin_init(gchar **error)
   }
 
   /* initialize python interactive shell */
   }
 
   /* initialize python interactive shell */
-  if(!parasite_python_init(error)) {
+  log_handler = g_log_set_handler(NULL, G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO, log_func, NULL);
+  parasite_retval = parasite_python_init(error);
+  g_log_remove_handler(NULL, log_handler);
+  if(!parasite_retval) {
     goto err;
   }
 
     goto err;
   }
 
@@ -716,6 +724,8 @@ gboolean plugin_done(void)
   /* finialize python interpreter */
   Py_Finalize();
 
   /* finialize python interpreter */
   Py_Finalize();
 
+  parasite_python_done();
+
   debug_print("Python plugin done and unloaded.\n");
   return FALSE;
 }
   debug_print("Python plugin done and unloaded.\n");
   return FALSE;
 }
@@ -728,23 +738,23 @@ const gchar *plugin_name(void)
 const gchar *plugin_desc(void)
 {
   return _("This plugin provides Python integration features.\n"
 const gchar *plugin_desc(void)
 {
   return _("This plugin provides Python integration features.\n"
-      "Python code can be entered interactively into an embedded Python console,"
-      " under Tools -> Show Python console, or stored in scripts.\n\n"
-      "These scripts are then available via the menu. You can assign"
-      " keyboard shortcuts to them just like it is done with other menu items."
-      " You can also put buttons for script invokation into the toolbars"
-      " using Claws Mail's builtin toolbar editor.\n\n"
-      "You can provide scripts working on the main window by placing files"
-      " into ~/.claws-mail/python-scripts/main.\n\n"
-      "You can also provide scripts working on an open compose window"
-      " by placing files into ~/.claws-mail/python-scripts/compose.\n\n"
-      "The folder ~/.claws-mail/python-scripts/auto/ may contain some"
-      " scripts that are automatically executed when certain events"
-      " occur. Currently, the following files in this directory"
-      " are recognised:\n\n"
+      "Python code can be entered interactively into an embedded Python console, "
+      "under Tools -> Show Python console, or stored in scripts.\n\n"
+      "These scripts are then available via the menu. You can assign "
+      "keyboard shortcuts to them just like it is done with other menu items. "
+      "You can also put buttons for script invocation into the toolbars "
+      "using Claws Mail's builtin toolbar editor.\n\n"
+      "You can provide scripts working on the main window by placing files "
+      "into ~/.claws-mail/python-scripts/main.\n\n"
+      "You can also provide scripts working on an open compose window "
+      "by placing files into ~/.claws-mail/python-scripts/compose.\n\n"
+      "The folder ~/.claws-mail/python-scripts/auto/ may contain some "
+      "scripts that are automatically executed when certain events "
+      "occur. Currently, the following files in this directory "
+      "are recognised:\n\n"
       "compose_any\n"
       "compose_any\n"
-      "Gets executed whenever a compose window is opened, no matter"
-      "if that opening happened as a result of composing a new message,"
+      "Gets executed whenever a compose window is opened, no matter "
+      "if that opening happened as a result of composing a new message, "
       "replying or forwarding a message.\n\n"
       "startup\n"
       "Executed at plugin load\n\n"
       "replying or forwarding a message.\n\n"
       "startup\n"
       "Executed at plugin load\n\n"