2005-10-27 [paul] 1.9.15cvs116
[claws.git] / src / plugins / mathml_viewer / mathml_viewer.c
index 2565c141bd3da8a2d0e6f37f7f5736010464b53c..59ab0b0c8233205aee068137966cac219d5a4cf3 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <unistd.h>
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gtkmathview/gtkmathview.h>
 
-#include "common/plugin.h"
-#include "common/utils.h"
+#include "common/sylpheed.h"
+#include "common/version.h"
+#include "plugin.h"
+#include "utils.h"
 #include "mimeview.h"
 
 typedef struct _MathMLViewer MathMLViewer;
@@ -56,13 +63,13 @@ static void mathml_show_mimepart(MimeViewer *_viewer, const gchar *infile, MimeI
        debug_print("mathml_show_mimepart\n");
 
        if (viewer->filename != NULL) {
-               unlink(viewer->filename);
+               g_unlink(viewer->filename);
                g_free(viewer->filename);
        }
 
        viewer->filename = procmime_get_tmp_file_name(partinfo);
        
-       if (!(procmime_get_part(viewer->filename, infile, partinfo) < 0)) {
+       if (!(procmime_get_part(viewer->filename, partinfo) < 0)) {
                gchar *uri;
                
                uri = g_strconcat("file://", viewer->filename, NULL);
@@ -87,12 +94,12 @@ static void mathml_destroy_viewer(MimeViewer *_viewer)
        debug_print("mathml_destroy_viewer\n");
 
        gtk_widget_unref(GTK_WIDGET(viewer->scrollwin));
-       unlink(viewer->filename);
+       g_unlink(viewer->filename);
        g_free(viewer->filename);
        g_free(viewer);
 }
 
-static MimeViewer *mathml_viewer_create()
+static MimeViewer *mathml_viewer_create(void)
 {
        MathMLViewer *viewer;
 
@@ -119,9 +126,12 @@ static MimeViewer *mathml_viewer_create()
        return (MimeViewer *) viewer;
 }
 
+static gchar *content_types[] =
+       {"text/mathml", NULL};
+
 static MimeViewerFactory mathml_viewer_factory =
 {
-       "text/mathml",
+       content_types,
        0,
        
        mathml_viewer_create,
@@ -129,27 +139,37 @@ static MimeViewerFactory mathml_viewer_factory =
 
 gint plugin_init(gchar **error)
 {
+       if ((sylpheed_get_version() > VERSION_NUMERIC)) {
+               *error = g_strdup("Your version of Sylpheed-Claws is newer than the version the MathML plugin was built with");
+               return -1;
+       }
+
+       if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 9, 3, 86))) {
+               *error = g_strdup("Your version of Sylpheed-Claws is too old for the MathML plugin");
+               return -1;
+       }
+
        mimeview_register_viewer_factory(&mathml_viewer_factory);
        return 0;       
 }
 
-void plugin_done()
+void plugin_done(void)
 {
        mimeview_unregister_viewer_factory(&mathml_viewer_factory);
 }
 
-const gchar *plugin_name()
+const gchar *plugin_name(void)
 {
-       return "MathML Viewer";
+       return _("MathML Viewer");
 }
 
-const gchar *plugin_desc()
+const gchar *plugin_desc(void)
 {
-       return "This plugin uses the GtkMathView widget to render "
-              "MathML attachments (Content-Type: text/mathml)";
+       return _("This plugin uses the GtkMathView widget to render "
+                "MathML attachments (Content-Type: text/mathml)");
 }
 
-const gchar *plugin_type()
+const gchar *plugin_type(void)
 {
-       return "GTK";
+       return "GTK2";
 }