[haiku-commits] haiku: hrev46231 - src/add-ons/translators/gif

  • From: stpere@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 15 Oct 2013 03:18:21 +0200 (CEST)

hrev46231 adds 1 changeset to branch 'master'
old head: aeee1f7ec7eaad6c0eba6d7892c11b8e2197fe4c
new head: abfe23dcf33fc8172f5deb50980ff6c6c8fd8a53
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=abfe23d+%5Eaeee1f7

----------------------------------------------------------------------------

abfe23d: It now also uses the shared TranslatorSettings class, and localise its 
name
  to be used in DataTranslations preflet.

                                [ Philippe Saint-Pierre <stpere@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46231
Commit:      abfe23dcf33fc8172f5deb50980ff6c6c8fd8a53
URL:         http://cgit.haiku-os.org/haiku/commit/?id=abfe23d
Author:      Philippe Saint-Pierre <stpere@xxxxxxxxx>
Date:        Tue Oct 15 01:15:10 2013 UTC

----------------------------------------------------------------------------

12 files changed, 338 insertions(+), 434 deletions(-)
src/add-ons/translators/gif/GIFSave.cpp        | 112 +++++++------
src/add-ons/translators/gif/GIFSave.h          |   7 +-
src/add-ons/translators/gif/GIFTranslator.cpp  | 163 +++++++++++--------
src/add-ons/translators/gif/GIFTranslator.h    |  43 ++++-
src/add-ons/translators/gif/GIFTranslator.rdef |   4 +-
src/add-ons/translators/gif/GIFView.cpp        | 173 ++++++++++++++-------
src/add-ons/translators/gif/GIFView.h          |  10 +-
src/add-ons/translators/gif/GIFWindow.cpp      |  34 ----
src/add-ons/translators/gif/GIFWindow.h        |  30 ----
src/add-ons/translators/gif/Jamfile            |   5 +-
src/add-ons/translators/gif/Prefs.cpp          | 149 ------------------
src/add-ons/translators/gif/Prefs.h            |  42 -----

----------------------------------------------------------------------------

diff --git a/src/add-ons/translators/gif/GIFSave.cpp 
b/src/add-ons/translators/gif/GIFSave.cpp
index 7627ecd..04e973b 100644
--- a/src/add-ons/translators/gif/GIFSave.cpp
+++ b/src/add-ons/translators/gif/GIFSave.cpp
@@ -14,6 +14,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 
 // Additional authors: Stephan Aßmus, <superstippi@xxxxxx>
+//                                             Philippe Saint-Pierre, 
<stpere@xxxxxxxxx>
 
 #include "GIFSave.h"
 #include <stdio.h>
@@ -35,21 +36,26 @@ class ColorCache : public HashItem {
 };
 
 // constructor
-GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
+GIFSave::GIFSave(BBitmap* bitmap, BPositionIO* output,
+       TranslatorSettings* settings)
 {
+       fSettings = settings;
        color_space cs = bitmap->ColorSpace();
-    if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs != 
B_RGBA32_BIG) {
-       if (debug) syslog(LOG_ERR, "GIFSave::GIFSave() - Unknown color 
space\n");
-       fatalerror = true;
-       return;
-    }
+       if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG
+               && cs != B_RGBA32_BIG) {
+               if (debug)
+                       syslog(LOG_ERR, "GIFSave::GIFSave() - Unknown color 
space\n");
+               fatalerror = true;
+               return;
+       }
     
        fatalerror = false;
-       prefs = new Prefs();
-       if (prefs->palettemode == OPTIMAL_PALETTE)
-               palette = new SavePalette(bitmap, prefs->palette_size_in_bits);
+       if (fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE) == OPTIMAL_PALETTE)
+               palette = new SavePalette(bitmap,
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE));
        else
-               palette = new SavePalette(prefs->palettemode);
+               palette = new SavePalette(
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE));
        if (!palette->IsValid()) {
                fatalerror = true;
                return;
@@ -58,12 +64,12 @@ GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
        width = bitmap->Bounds().IntegerWidth() + 1;
        height = bitmap->Bounds().IntegerHeight() + 1;
        if (debug)
-          syslog(LOG_ERR, "GIFSave::GIFSave() - Image dimensions are %d by 
%d\n",
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Image dimensions are %d 
by %d\n",
                                        width, height);
        
-       if (prefs->usedithering) {
+       if (fSettings->SetGetBool(GIF_SETTING_USE_DITHERING)) {
                if (debug)
-                  syslog(LOG_ERR, "GIFSave::GIFSave() - Using dithering\n");
+                       syslog(LOG_ERR, "GIFSave::GIFSave() - Using 
dithering\n");
                red_error = new int32[width + 2];
                red_error = &red_error[1]; // Allow index of -1 too
                green_error = new int32[width + 2];
@@ -77,16 +83,15 @@ GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
                        green_error[x] = 0;
                        blue_error[x] = 0;
                }
-       } else {
-               if (debug)
-                  syslog(LOG_ERR, "GIFSave::GIFSave() - Not using 
dithering\n");
-       }
+       } else if (debug)
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Not using dithering\n");
        
        if (debug) {
-               if (prefs->interlaced)
-                  syslog(LOG_ERR, "GIFSave::GIFSave() - Interlaced, ");
-               else syslog(LOG_ERR, "GIFSave::GIFSave() - Not interlaced, ");
-               switch (prefs->palettemode) {
+               if (fSettings->SetGetBool(GIF_SETTING_INTERLACED))
+                       syslog(LOG_ERR, "GIFSave::GIFSave() - Interlaced, ");
+               else
+                       syslog(LOG_ERR, "GIFSave::GIFSave() - Not interlaced, 
");
+               switch (fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE)) {
                        case WEB_SAFE_PALETTE:
                                syslog(LOG_ERR, "web safe palette\n");
                                break;
@@ -103,20 +108,23 @@ GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
                }
        }
        
-       if (prefs->usetransparent) {
-               if (prefs->usetransparentauto) {
+       if (fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT)) {
+               if (fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO)) {
                        palette->PrepareForAutoTransparency();
                        if (debug)
                                syslog(LOG_ERR, "GIFSave::GIFSave() - Using 
transparent index %d\n", 
                                        palette->TransparentIndex());
                } else {
-                       
palette->SetTransparentColor((uint8)prefs->transparentred,
-                                                                            
(uint8)prefs->transparentgreen,
-                                                                            
(uint8)prefs->transparentblue);
+                       palette->SetTransparentColor(
+                               
(uint8)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_RED),
+                               
(uint8)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_GREEN),
+                               
(uint8)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_BLUE));
                        if (debug) {
                                syslog(LOG_ERR, "GIFSave::GIFSave() - Found 
transparent color %d,%d,%d "
-                                       "at index %d\n", prefs->transparentred, 
-                                       prefs->transparentgreen, 
prefs->transparentblue,
+                                       "at index %d\n", 
+                                       
fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_RED),
+                                       
fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_GREEN),
+                                       
fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_BLUE),
                                        palette->TransparentIndex());
                        }
                }
@@ -128,17 +136,21 @@ GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
        this->output = output;
        this->bitmap = bitmap;
        WriteGIFHeader();
-       if (debug) syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif header\n");
+       if (debug)
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif header\n");
                
        hash = new SFHash(1 << 16);
        WriteGIFControlBlock();
-       if (debug) syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif control 
block\n");
+       if (debug)
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif control 
block\n");
        WriteGIFImageHeader();
-       if (debug) syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif image 
header\n");
+       if (debug)
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif image 
header\n");
        WriteGIFImageData();
-       if (debug) syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif image 
data\n");
+       if (debug)
+               syslog(LOG_ERR, "GIFSave::GIFSave() - Wrote gif image data\n");
        
-       if (prefs->usedithering) {
+       if (fSettings->SetGetBool(GIF_SETTING_USE_DITHERING)) {
                delete [] &red_error[-1];
                delete [] &green_error[-1];
                delete [] &blue_error[-1];
@@ -154,7 +166,7 @@ GIFSave::GIFSave(BBitmap *bitmap, BPositionIO *output)
 GIFSave::~GIFSave()
 {
        delete palette;
-       delete prefs;
+       fSettings->Release();
 }
 
 // WriteGIFHeader
@@ -204,8 +216,10 @@ void GIFSave::WriteGIFImageHeader()
        header[7] = height & 0xff;
        header[8] = (height & 0xff00) >> 8;
 
-       if (prefs->interlaced) header[9] = 0x40;
-       else header[9] = 0x00;
+       if (fSettings->SetGetBool(GIF_SETTING_INTERLACED))
+               header[9] = 0x40;
+       else
+               header[9] = 0x00;
        output->Write(header, 10);
 }
 
@@ -336,7 +350,9 @@ GIFSave::NextPixel(int pixel)
 {
        int bpr = bitmap->BytesPerRow();
        color_space cs = bitmap->ColorSpace();
-       bool useAlphaForTransparency = (prefs->usetransparentauto && cs == 
B_RGBA32) || cs == B_RGBA32_BIG;
+       bool useAlphaForTransparency = 
+               (fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO) 
+                       && cs == B_RGBA32) || cs == B_RGBA32_BIG;
        unsigned char r, g, b, a;
 
        if (cs == B_RGB32 || cs == B_RGBA32) {
@@ -353,22 +369,23 @@ GIFSave::NextPixel(int pixel)
        gifbits += 4;
        pos += 4;
 
-       if (!prefs->usetransparent || prefs->usetransparentauto ||
-               r != prefs->transparentred ||
-               g != prefs->transparentgreen ||
-               b != prefs->transparentblue) {
+       if (!fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT) 
+               || fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO)
+               || r != fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_RED)
+               || g != fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_GREEN) 
+               || b != fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_BLUE)) {
        
-               if (prefs->usedithering) {
-                       if (pixel % width == 0) {
+               if (fSettings->SetGetBool(GIF_SETTING_USE_DITHERING)) {
+                       if (pixel % width == 0)
                                red_side_error = green_side_error = 
blue_side_error = 0;
-                       }
+
                        b = min_c(255, max_c(0, b - blue_side_error));
                        g = min_c(255, max_c(0, g - green_side_error));
                        r = min_c(255, max_c(0, r - red_side_error));
                }
        }
        
-       if (prefs->interlaced) {
+       if (fSettings->SetGetBool(GIF_SETTING_INTERLACED)) {
                if (pos >= bpr) {
                        pos = 0;
                        row += gs_increment_pass_by[pass];
@@ -426,11 +443,12 @@ GIFSave::NextPixel(int pixel)
 
        int index = palette->IndexForColor(r, g, b, useAlphaForTransparency ? a 
: 255);
 
-       if (index != palette->TransparentIndex() && prefs->usedithering) {
+       if (index != palette->TransparentIndex()
+               && fSettings->SetGetBool(GIF_SETTING_USE_DITHERING)) {
                int x = pixel % width;
                // Don't carry error on to next line when interlaced because
                // that line won't be adjacent, hence error is meaningless
-               if (prefs->interlaced && x == width - 1) {
+               if (fSettings->SetGetBool(GIF_SETTING_INTERLACED) && x == width 
- 1) {
                        for (int32 y = -1; y < width + 1; y++) {
                                red_error[y] = 0;
                                green_error[y] = 0;
diff --git a/src/add-ons/translators/gif/GIFSave.h 
b/src/add-ons/translators/gif/GIFSave.h
index 882c714..856c35b 100644
--- a/src/add-ons/translators/gif/GIFSave.h
+++ b/src/add-ons/translators/gif/GIFSave.h
@@ -20,7 +20,8 @@
 #include <Bitmap.h>
 #include "SavePalette.h"
 #include "SFHash.h"
-#include "Prefs.h"
+
+#include "GIFTranslator.h"
 
 #define HASHSIZE 9973
 #define HASHSTEP 2039
@@ -29,7 +30,7 @@
 
 class GIFSave {
        public:
-               GIFSave(BBitmap *bitmap, BPositionIO *output);
+               GIFSave(BBitmap* bitmap, BPositionIO* output, 
TranslatorSettings* settings);
                ~GIFSave();
 
                bool fatalerror;
@@ -51,7 +52,7 @@ class GIFSave {
                BBitmap *bitmap;
                SavePalette *palette;
                SFHash *hash;
-               Prefs *prefs;
+               TranslatorSettings *fSettings;
                
                short *code_value, *prefix_code;
                unsigned char *append_char;
diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp 
b/src/add-ons/translators/gif/GIFTranslator.cpp
index 2867e13..91854de 100644
--- a/src/add-ons/translators/gif/GIFTranslator.cpp
+++ b/src/add-ons/translators/gif/GIFTranslator.cpp
@@ -12,14 +12,14 @@
 //     original author in any about box using this software.
 //
 
////////////////////////////////////////////////////////////////////////////////
+// Additional authors:  Stephan Aßmus, <superstippi@xxxxxx>
 
 #include "GIFTranslator.h"
-#include "GIFWindow.h"
 #include "GIFView.h"
 #include "GIFSave.h"
 #include "GIFLoad.h"
 
-
+#include <Application.h>
 #include <ByteOrder.h>
 #include <Catalog.h>
 #include <DataIO.h>
@@ -33,6 +33,8 @@
 #include <string.h>
 #include <syslog.h>
 
+#include "TranslatorWindow.h"
+
 #ifndef GIF_TYPE
 #define GIF_TYPE 'GIF '
 #endif
@@ -48,38 +50,38 @@ bool debug = false;
 bool DetermineType(BPositionIO *source, bool *is_gif);
 status_t GetBitmap(BPositionIO *in, BBitmap **out);
 
-/* Required data */
-char translatorName[] = "GIF images";
-char translatorInfo[] = "GIF image translator v1.4";
-int32 translatorVersion = 0x140;
-
-translation_format inputFormats[] = {
-       { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", 
-               "GIF image" },
-       { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, 
"image/x-be-bitmap", 
-               "Be Bitmap Format (GIFTranslator)" },
-       { 0 }
+static const translation_format sInputFormats[] = {
+       { GIF_TYPE, B_TRANSLATOR_BITMAP, GIF_IN_QUALITY, GIF_IN_CAPABILITY,
+               "image/gif", "GIF image" },
+       { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, BBM_IN_QUALITY, 
BBM_IN_CAPABILITY,
+               "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" }
 };
 
-translation_format outputFormats[] = {
-       { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", 
+static const translation_format sOutputFormats[] = {
+       { GIF_TYPE, B_TRANSLATOR_BITMAP, GIF_OUT_QUALITY, GIF_OUT_CAPABILITY, 
"image/gif", 
                "GIF image" },
-       { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, 
"image/x-be-bitmap", 
-               "Be Bitmap Format (GIFTranslator)" },
-       { 0 }
+       { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, BBM_OUT_QUALITY, 
BBM_OUT_CAPABILITY,
+               "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" }
 };
 
+// Default settings for the Translator
+static const TranSetting sDefaultSettings[] = {
+        {B_TRANSLATOR_EXT_HEADER_ONLY, TRAN_SETTING_BOOL, false},
+        {B_TRANSLATOR_EXT_DATA_ONLY, TRAN_SETTING_BOOL, false},
+       {GIF_SETTING_INTERLACED, TRAN_SETTING_BOOL, false},
+       {GIF_SETTING_USE_TRANSPARENT, TRAN_SETTING_BOOL, false},
+       {GIF_SETTING_USE_TRANSPARENT_AUTO, TRAN_SETTING_BOOL, false},
+       {GIF_SETTING_USE_DITHERING, TRAN_SETTING_BOOL, false},
+       {GIF_SETTING_PALETTE_MODE, TRAN_SETTING_INT32, 0},
+       {GIF_SETTING_PALETTE_SIZE, TRAN_SETTING_INT32, 8},
+       {GIF_SETTING_TRANSPARENT_RED, TRAN_SETTING_INT32, 0},
+       {GIF_SETTING_TRANSPARENT_GREEN, TRAN_SETTING_INT32, 0},
+       {GIF_SETTING_TRANSPARENT_BLUE, TRAN_SETTING_INT32, 0}
+};
 
-/* Build a pretty view for DataTranslations */
-status_t
-MakeConfig(BMessage *ioExtension, BView **outView, BRect *outExtent)
-{
-       GIFView *gifview = new GIFView("TranslatorView");
-       *outView = gifview;
-       gifview->ResizeTo(gifview->ExplicitPreferredSize());
-       *outExtent = gifview->Bounds();
-       return B_OK;
-}
+const uint32 kNumInputFormats = sizeof(sInputFormats) / 
sizeof(translation_format);
+const uint32 kNumOutputFormats = sizeof(sOutputFormats) / 
sizeof(translation_format);
+const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / 
sizeof(TranSetting);
 
 
 /* Look at first few bytes in stream to determine type - throw it back
@@ -89,7 +91,8 @@ DetermineType(BPositionIO *source, bool *is_gif)
 {
        unsigned char header[7];
        *is_gif = true;
-       if (source->Read(header, 6) != 6) return false;
+       if (source->Read(header, 6) != 6)
+               return false;
        header[6] = 0x00;
 
        if (strcmp((char *)header, "GIF87a") != 0 && strcmp((char *)header, 
@@ -97,13 +100,16 @@ DetermineType(BPositionIO *source, bool *is_gif)
                *is_gif = false;
                int32 magic = (header[0] << 24) + (header[1] << 16) + 
(header[2] << 8) 
                        + header[3];
-               if (magic != B_TRANSLATOR_BITMAP) return false;
+               if (magic != B_TRANSLATOR_BITMAP)
+                       return false;
                source->Seek(5 * 4 - 2, SEEK_CUR);
                color_space cs;
-               if (source->Read(&cs, 4) != 4) return false;
+               if (source->Read(&cs, 4) != 4)
+                       return false;
                cs = (color_space)B_BENDIAN_TO_HOST_INT32(cs);
-               if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs 
-                       != B_RGBA32_BIG) return false;
+               if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG
+                       && cs != B_RGBA32_BIG)
+                       return false;
        }
 
        source->Seek(0, SEEK_SET);
@@ -130,16 +136,18 @@ GetBitmap(BPositionIO *in, BBitmap **out)
        header.colors = (color_space)B_BENDIAN_TO_HOST_INT32(header.colors);
        header.dataSize = B_BENDIAN_TO_HOST_INT32(header.dataSize);
 
-       BBitmap *bitmap = new BBitmap(header.bounds, header.colors);
+       BBitmap* bitmap = new(std::nothrow) BBitmap(header.bounds, 
header.colors);
        *out = bitmap;
-       if (bitmap == NULL) return B_NO_MEMORY;
+       if (bitmap == NULL)
+               return B_NO_MEMORY;
        unsigned char *bits = (unsigned char *)bitmap->Bits();
        if (bits == NULL) {
                delete bitmap;
                return B_NO_MEMORY;
        }
        err = in->Read(bits, header.dataSize);
-       if (err == (status_t)header.dataSize) return B_OK;
+       if (err == (status_t)header.dataSize)
+               return B_OK;
        else {
                delete bitmap;
                return B_IO_ERROR;
@@ -149,34 +157,36 @@ GetBitmap(BPositionIO *in, BBitmap **out)
 
 /* Required Identify function - may need to read entire header, not sure */
 status_t
-Identify(BPositionIO *inSource, const translation_format *inFormat,
-       BMessage *ioExtension, translator_info *outInfo, uint32 outType)
+GIFTranslator::DerivedIdentify(BPositionIO* inSource,
+       const translation_format* inFormat, BMessage* ioExtension,
+       translator_info* outInfo, uint32 outType)
 {
-
        const char *debug_text = getenv("GIF_TRANSLATOR_DEBUG");
-       if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true;
+       if (debug_text != NULL && atoi(debug_text) != 0)
+               debug = true;
 
-       if (outType == 0) outType = B_TRANSLATOR_BITMAP;
+       if (outType == 0)
+               outType = B_TRANSLATOR_BITMAP;
        if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) 
                return B_NO_TRANSLATOR;
 
        bool is_gif;
-       if (!DetermineType(inSource, &is_gif)) return B_NO_TRANSLATOR;
+       if (!DetermineType(inSource, &is_gif))
+               return B_NO_TRANSLATOR;
        if (!is_gif && inFormat != NULL && inFormat->type != 
B_TRANSLATOR_BITMAP)
                return B_NO_TRANSLATOR;
 
        outInfo->group = B_TRANSLATOR_BITMAP;
        if (is_gif) {
                outInfo->type = GIF_TYPE;
-               outInfo->quality = 0.8;
-               outInfo->capability = 0.8;
+               outInfo->quality = GIF_IN_QUALITY;
+               outInfo->capability = GIF_IN_CAPABILITY;
                strlcpy(outInfo->name, B_TRANSLATE("GIF image"), 
sizeof(outInfo->name));
                strcpy(outInfo->MIME, "image/gif");
-       }
-       else {
+       } else {
                outInfo->type = B_TRANSLATOR_BITMAP;
-               outInfo->quality = 0.3;
-               outInfo->capability = 0.3;
+               outInfo->quality = BBM_IN_QUALITY;
+               outInfo->capability = BBM_IN_CAPABILITY;
                strlcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format 
(GIFTranslator)"),
                        sizeof(outInfo->name));
                strcpy(outInfo->MIME, "image/x-be-bitmap");
@@ -188,11 +198,11 @@ Identify(BPositionIO *inSource, const translation_format 
*inFormat,
 /* Main required function - assumes that an incoming GIF must be translated
    to a BBitmap, and vice versa - this could be improved */
 status_t
-Translate(BPositionIO *inSource, const translator_info *inInfo,
-       BMessage *ioExtension, uint32 outType, BPositionIO *outDestination)
+GIFTranslator::DerivedTranslate(BPositionIO* inSource,
+       const translator_info* inInfo, BMessage* ioExtension, uint32 outType,
+       BPositionIO* outDestination, int32 baseType)
 {
-
-       const char *debug_text = getenv("GIF_TRANSLATOR_DEBUG");
+       const char* debug_text = getenv("GIF_TRANSLATOR_DEBUG");
        if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true;
 
        if (outType == 0) outType = B_TRANSLATOR_BITMAP;
@@ -212,7 +222,7 @@ Translate(BPositionIO *inSource, const translator_info 
*inInfo,
                err = GetBitmap(inSource, &bitmap);
                if (err != B_OK)
                        return err;
-               GIFSave *gs = new GIFSave(bitmap, outDestination);
+               GIFSave* gs = new GIFSave(bitmap, outDestination, fSettings);
                if (gs->fatalerror) {
                        delete gs;
                        delete bitmap;
@@ -237,20 +247,51 @@ Translate(BPositionIO *inSource, const translator_info 
*inInfo,
 }
 
 
+BTranslator*
+make_nth_translator(int32 n, image_id you, uint32 flags, ...)
+{
+        if (n == 0)
+                return new GIFTranslator();
+
+        return NULL;
+}
+
+
 GIFTranslator::GIFTranslator()
-       : BApplication("application/x-vnd.Haiku-GIFTranslator")
+       : BaseTranslator(B_TRANSLATE("GIF images"),
+               B_TRANSLATE("GIF image translator"),
+               GIF_TRANSLATOR_VERSION,
+               sInputFormats, kNumInputFormats,
+               sOutputFormats, kNumOutputFormats,
+               "GIFTranslator_Settings",
+               sDefaultSettings, kNumDefaultSettings,
+               B_TRANSLATOR_BITMAP, B_GIF_FORMAT)
+{
+}
+
+
+GIFTranslator::~GIFTranslator()
+{
+}
+
+
+BView*
+GIFTranslator::NewConfigView(TranslatorSettings *settings)
 {
-       BRect rect(100, 100, 339, 339);
-       gifwindow = new GIFWindow(rect, B_TRANSLATE("GIF Settings"));
-       gifwindow->Show();
+       return new GIFView(settings);
 }
 
 
 int
 main()
 {
-       GIFTranslator myapp;
-       myapp.Run();
-       return 0;
+        BApplication app("application/x-vnd.Haiku-GIFTranslator");
+        status_t result;
+        result = LaunchTranslatorWindow(new GIFTranslator,
+                B_TRANSLATE("GIF Settings"), kRectView);
+        if (result == B_OK) {
+                app.Run();
+                return 0;
+        } else
+                return 1;
 }
-
diff --git a/src/add-ons/translators/gif/GIFTranslator.h 
b/src/add-ons/translators/gif/GIFTranslator.h
index 613f9c6..5ce0562 100644
--- a/src/add-ons/translators/gif/GIFTranslator.h
+++ b/src/add-ons/translators/gif/GIFTranslator.h
@@ -16,13 +16,48 @@
 #ifndef GIFTRANSLATOR_H
 #define GIFTRANSLATOR_H
 
-#include <Application.h>
-class GIFWindow;
+#include "BaseTranslator.h"
 
-class GIFTranslator : public BApplication {
+#define GIF_IN_QUALITY         0.8
+#define GIF_IN_CAPABILITY      0.8
+#define BBM_IN_QUALITY         0.3
+#define BBM_IN_CAPABILITY      0.3
+
+#define GIF_OUT_QUALITY                0.8
+#define GIF_OUT_CAPABILITY     0.8
+#define BBM_OUT_QUALITY                0.3
+#define BBM_OUT_CAPABILITY     0.3
+
+// settings
+
+#define GIF_SETTING_INTERLACED                 "interlaced"
+#define GIF_SETTING_USE_TRANSPARENT            "use transparent"
+#define GIF_SETTING_USE_TRANSPARENT_AUTO       "use transparent auto"
+#define GIF_SETTING_USE_DITHERING              "use dithering"
+#define GIF_SETTING_PALETTE_MODE               "palette mode"
+#define GIF_SETTING_PALETTE_SIZE               "palette size"
+#define GIF_SETTING_TRANSPARENT_RED            "transparent red"
+#define GIF_SETTING_TRANSPARENT_GREEN          "transparent green"
+#define GIF_SETTING_TRANSPARENT_BLUE           "transparent blue"
+
+
+#define GIF_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1,5,0)
+
+class GIFTranslator : public BaseTranslator {
        public:
                GIFTranslator();
-               GIFWindow *gifwindow;
+               virtual status_t DerivedIdentify(BPositionIO* inSource,
+                       const translation_format* inFormat, BMessage* 
ioExtension,
+                       translator_info* outInfo, uint32 outType);
+
+               virtual status_t DerivedTranslate(BPositionIO* inSource,
+                       const translator_info* inInfo, BMessage* ioExtension,
+                       uint32 outType, BPositionIO* outDestination, int32 
baseType);
+               
+               virtual BView* NewConfigView(TranslatorSettings* settings);
+               
+       protected:
+               virtual ~GIFTranslator();
 };
 
 #endif
diff --git a/src/add-ons/translators/gif/GIFTranslator.rdef 
b/src/add-ons/translators/gif/GIFTranslator.rdef
index 6227ffe..dd5ce8b 100644
--- a/src/add-ons/translators/gif/GIFTranslator.rdef
+++ b/src/add-ons/translators/gif/GIFTranslator.rdef
@@ -6,10 +6,10 @@ resource app_signature 
"application/x-vnd.Haiku-GIFTranslator";
 
 resource app_version {
        major  = 1,
-       middle = 4,
+       middle = 5,
        minor  = 0,
        variety = 0,
        internal = 0,
-       short_info = "1.4.0",
+       short_info = "1.5.0",
        long_info = "Haiku GIFTranslator Add-Ons."
 };
diff --git a/src/add-ons/translators/gif/GIFView.cpp 
b/src/add-ons/translators/gif/GIFView.cpp
index e54c3bd..1e7f0a5 100644
--- a/src/add-ons/translators/gif/GIFView.cpp
+++ b/src/add-ons/translators/gif/GIFView.cpp
@@ -15,6 +15,10 @@
 
 // Additional authors: Stephan Aßmus, <superstippi@xxxxxx>
 //                      Maxime Simon, <maxime.simon@xxxxxxxxx>
+//                     Philippe Saint-Pierre, <stpere@xxxxxxxxx>
+
+#include "GIFView.h"
+#include "GIFTranslator.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -24,31 +28,30 @@
 #include <LayoutBuilder.h>
 #include <String.h>
 
-#include "Prefs.h"
 #include "SavePalette.h"
 
-#include "GIFView.h"
-
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "GIFView"
 
 
-extern int32 translatorVersion;
-extern char translatorName[];
-
 // constructor
-GIFView::GIFView(const char *name)
-       : BView(name, B_WILL_DRAW)
+GIFView::GIFView(TranslatorSettings* settings)
+       : 
+       BView("GIFView", B_WILL_DRAW),
+       fSettings(settings)
 {
        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 
        BStringView *title = new BStringView("Title", B_TRANSLATE("GIF image 
translator"));
        title->SetFont(be_bold_font);
 
-       char version_string[100];
-       sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8),
-               (int)((translatorVersion >> 4) & 0xf), (int)(translatorVersion 
& 0xf),
-               __DATE__);
+        char version_string[100];
+        snprintf(version_string, sizeof(version_string), 
B_TRANSLATE("v%d.%d.%d %s"),
+                int(B_TRANSLATION_MAJOR_VERSION(GIF_TRANSLATOR_VERSION)),
+                int(B_TRANSLATION_MINOR_VERSION(GIF_TRANSLATOR_VERSION)),
+                int(B_TRANSLATION_REVISION_VERSION(GIF_TRANSLATOR_VERSION)),
+                __DATE__);
+
        BStringView *version = new BStringView("Version", version_string);
 
        const char *copyrightString = "©2003 Daniel Switkin, 
software@xxxxxxxxxxx";
@@ -74,7 +77,7 @@ GIFView::GIFView(const char *name)
        int32 count = 2;
        for (int32 i = 0; i < 8; i++) {
                BMessage* message = new BMessage(GV_SET_COLOR_COUNT);
-               message->AddInt32("size in bits", i + 1);
+               message->AddInt32(GIF_SETTING_PALETTE_SIZE, i + 1);
                BString label;
                label << count;
                fColorCountMI[i] = new BMenuItem(label.String(), message, 0, 0);
@@ -105,9 +108,7 @@ GIFView::GIFView(const char *name)
                new BMessage(GV_USE_TRANSPARENT_COLOR));
 
        fTransparentRedTC = new BTextControl("", "0", new 
BMessage(GV_TRANSPARENT_RED));
-
        fTransparentGreenTC = new BTextControl("", "0", new 
BMessage(GV_TRANSPARENT_GREEN));
-
        fTransparentBlueTC = new BTextControl("", "0", new 
BMessage(GV_TRANSPARENT_BLUE));
 
        BTextView *tr = fTransparentRedTC->TextView();
@@ -163,19 +164,17 @@ GIFView::GIFView(const char *name)
 
 GIFView::~GIFView()
 {
-       delete fPrefs;
+       fSettings->Release();
 }
 
 
 void
 GIFView::RestorePrefs()
 {
-       fPrefs = new Prefs();
-
        fColorCountMF->SetEnabled(false);
        fUseDitheringCB->SetEnabled(true);
 
-       switch (fPrefs->palettemode) {
+       switch (fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE)) {
                case WEB_SAFE_PALETTE:
                        fWebSafeMI->SetMarked(true);
                        break;
@@ -191,35 +190,49 @@ GIFView::RestorePrefs()
                        fColorCountMF->SetEnabled(true);
                        break;
                default:
-                       fPrefs->palettemode = WEB_SAFE_PALETTE;
+                       int32 value = WEB_SAFE_PALETTE;
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE, 
&value);
+                       fSettings->SaveSettings();
                        fWebSafeMI->SetMarked(true);
                        break;
        }
 
-       if (fColorCountMF->IsEnabled() &&
-               fPrefs->palette_size_in_bits > 0 &&
-               fPrefs->palette_size_in_bits <= 8) {
+       if (fColorCountMF->IsEnabled()
+               && fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE) > 0
+               && fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE) <= 8) {
                // display the stored color count
-               fColorCountMI[fPrefs->palette_size_in_bits - 
1]->SetMarked(true);
+               fColorCountMI[fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE) 
- 1]
+                       ->SetMarked(true);
        } else {
                // display 256 colors
                fColorCount256MI->SetMarked(true);
-               fPrefs->palette_size_in_bits = 8;
+               int32 value = 8;
+               fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE, &value);
+               fSettings->SaveSettings();
        }
 
-       fInterlacedCB->SetValue(fPrefs->interlaced);
-
-       if (fGreyScaleMI->IsMarked()) fUseDitheringCB->SetValue(false);
-       else fUseDitheringCB->SetValue(fPrefs->usedithering);
-       fUseTransparentCB->SetValue(fPrefs->usetransparent);
-       fUseTransparentAutoRB->SetValue(fPrefs->usetransparentauto);
-       fUseTransparentColorRB->SetValue(!fPrefs->usetransparentauto);
-       if (fPrefs->usetransparent) {
+       fInterlacedCB->SetValue(fSettings->SetGetBool(GIF_SETTING_INTERLACED));
+
+       if (fGreyScaleMI->IsMarked()) 
+               fUseDitheringCB->SetValue(false);
+       else 
+               fUseDitheringCB->SetValue(
+                       fSettings->SetGetBool(GIF_SETTING_USE_DITHERING));
+       fUseTransparentCB->SetValue(
+               fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT));
+       fUseTransparentAutoRB->SetValue(
+               fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO));
+       fUseTransparentColorRB->SetValue(
+               !fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO));
+       if (fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT)) {
                fUseTransparentAutoRB->SetEnabled(true);
                fUseTransparentColorRB->SetEnabled(true);
-               fTransparentRedTC->SetEnabled(!fPrefs->usetransparentauto);
-               fTransparentGreenTC->SetEnabled(!fPrefs->usetransparentauto);
-               fTransparentBlueTC->SetEnabled(!fPrefs->usetransparentauto);
+               fTransparentRedTC->SetEnabled(
+                       
!fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO));
+               fTransparentGreenTC->SetEnabled(
+                       
!fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO));
+               fTransparentBlueTC->SetEnabled(
+                       
!fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO));
        } else {
                fUseTransparentAutoRB->SetEnabled(false);
                fUseTransparentColorRB->SetEnabled(false);
@@ -229,14 +242,18 @@ GIFView::RestorePrefs()
        }
 
        char temp[4];
-       sprintf(temp, "%d", fPrefs->transparentred);
+       sprintf(temp, "%d",
+               (int)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_RED));
        fTransparentRedTC->SetText(temp);
-       sprintf(temp, "%d", fPrefs->transparentgreen);
+       sprintf(temp, "%d",
+               (int)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_GREEN));
        fTransparentGreenTC->SetText(temp);
-       sprintf(temp, "%d", fPrefs->transparentblue);
+       sprintf(temp, "%d",
+               (int)fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_BLUE));
        fTransparentBlueTC->SetText(temp);
 }
 
+
 // AllAttached
 void
 GIFView::AllAttached()
@@ -255,55 +272,80 @@ GIFView::AllAttached()
        fColorCountM->SetTargetForItems(msgr);
 }
 
+
 // MessageReceived
 void
 GIFView::MessageReceived(BMessage *message)
 {
        switch (message->what) {
                case GV_WEB_SAFE:
-                       fPrefs->palettemode = WEB_SAFE_PALETTE;
+               {
+                       int32 value = WEB_SAFE_PALETTE;
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE, 
&value);
                        fUseDitheringCB->SetEnabled(true);
                        fColorCountMF->SetEnabled(false);
                        fColorCount256MI->SetMarked(true);
                        break;
+               }
                case GV_BEOS_SYSTEM:
-                       fPrefs->palettemode = BEOS_SYSTEM_PALETTE;
+               {
+                       int32 value = BEOS_SYSTEM_PALETTE;
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE, 
&value);
                        fUseDitheringCB->SetEnabled(true);
                        fColorCountMF->SetEnabled(false);
                        fColorCount256MI->SetMarked(true);
                        break;
+               }
                case GV_GREYSCALE:
-                       fPrefs->palettemode = GREYSCALE_PALETTE;
+               {
+                       int32 value = GREYSCALE_PALETTE;
+                       bool usedithering = false;
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE, 
&value);
+                       fSettings->SetGetBool(GIF_SETTING_USE_DITHERING, 
&usedithering);
                        fUseDitheringCB->SetEnabled(false);
                        fUseDitheringCB->SetValue(false);
                        fColorCountMF->SetEnabled(false);
                        fColorCount256MI->SetMarked(true);
-                       fPrefs->usedithering = false;
                        break;
+               }
                case GV_OPTIMAL:
-                       fPrefs->palettemode = OPTIMAL_PALETTE;
+               {
+                       int32 value = OPTIMAL_PALETTE;
+                       fSettings->SetGetInt32(GIF_SETTING_PALETTE_MODE, 
&value);
                        fUseDitheringCB->SetEnabled(true);
                        fColorCountMF->SetEnabled(true);
-                       fColorCountMI[fPrefs->palette_size_in_bits - 
1]->SetMarked(true);
+                       
fColorCountMI[fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE) - 1]
+                               ->SetMarked(true);
                        break;
+               }
                case GV_SET_COLOR_COUNT:
                        if (fColorCountMF->IsEnabled()) {
                                int32 sizeInBits;
-                               if (message->FindInt32("size in bits", 
&sizeInBits) >= B_OK) {
+                               if 
(message->FindInt32(GIF_SETTING_PALETTE_SIZE, &sizeInBits)
+                                       >= B_OK) {
                                        if (sizeInBits > 0 && sizeInBits <= 8)
-                                               fPrefs->palette_size_in_bits = 
sizeInBits;
+                                               
fSettings->SetGetInt32(GIF_SETTING_PALETTE_SIZE,
+                                                       &sizeInBits);
                                }
                        }
                        break;
                case GV_INTERLACED:
-                       fPrefs->interlaced = fInterlacedCB->Value();
+               {
+                       bool value = fInterlacedCB->Value();
+                       fSettings->SetGetBool(GIF_SETTING_INTERLACED, &value);
                        break;
+               }
                case GV_USE_DITHERING:
-                       fPrefs->usedithering = fUseDitheringCB->Value();
+               {
+                       bool value = fUseDitheringCB->Value();
+                       fSettings->SetGetBool(GIF_SETTING_USE_DITHERING, 
&value);
                        break;
+               }
                case GV_USE_TRANSPARENT:
-                       fPrefs->usetransparent = fUseTransparentCB->Value();
-                       if (fPrefs->usetransparent) {
+               {
+                       bool value = fUseTransparentCB->Value();
+                       fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT, 
&value);
+                       if (value) {
                                fUseTransparentAutoRB->SetEnabled(true);
                                fUseTransparentColorRB->SetEnabled(true);
                                
fTransparentRedTC->SetEnabled(fUseTransparentColorRB->Value());
@@ -317,34 +359,51 @@ GIFView::MessageReceived(BMessage *message)
                                fTransparentBlueTC->SetEnabled(false);
                        }
                        break;
+               }
                case GV_USE_TRANSPARENT_AUTO:
-                       fPrefs->usetransparentauto = true;
+               {
+                       bool value = true;
+                       fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO, 
&value);
                        fTransparentRedTC->SetEnabled(false);
                        fTransparentGreenTC->SetEnabled(false);
                        fTransparentBlueTC->SetEnabled(false);
                        break;
+               }
                case GV_USE_TRANSPARENT_COLOR:
-                       fPrefs->usetransparentauto = false;
+               {
+                       bool value = false;
+                       fSettings->SetGetBool(GIF_SETTING_USE_TRANSPARENT_AUTO, 
&value);
                        fTransparentRedTC->SetEnabled(true);
                        fTransparentGreenTC->SetEnabled(true);
                        fTransparentBlueTC->SetEnabled(true);
                        break;
+               }
                case GV_TRANSPARENT_RED:
-                       fPrefs->transparentred = CheckInput(fTransparentRedTC);
+               {       
+                       int32 value = CheckInput(fTransparentRedTC);
+                       fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_RED, 
&value);
                        break;
+               }
                case GV_TRANSPARENT_GREEN:
-                       fPrefs->transparentgreen = 
CheckInput(fTransparentGreenTC);
+               {
+                       int32 value = CheckInput(fTransparentGreenTC);
+                       fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_GREEN, 
&value);
                        break;
+               }
                case GV_TRANSPARENT_BLUE:
-                       fPrefs->transparentblue = 
CheckInput(fTransparentBlueTC);
+               {
+                       int32 value = CheckInput(fTransparentBlueTC);
+                       fSettings->SetGetInt32(GIF_SETTING_TRANSPARENT_BLUE, 
&value);
                        break;
+               }
                default:
                        BView::MessageReceived(message);
                        break;
        }
-       fPrefs->Save();
+       fSettings->SaveSettings();
 }
 
+
 int GIFView::CheckInput(BTextControl *control) {
        int value = atoi(control->Text());
        if (value < 0 || value > 255) {
diff --git a/src/add-ons/translators/gif/GIFView.h 
b/src/add-ons/translators/gif/GIFView.h
index 9ff5310..f9172ce 100644
--- a/src/add-ons/translators/gif/GIFView.h
+++ b/src/add-ons/translators/gif/GIFView.h
@@ -14,11 +14,13 @@
 
////////////////////////////////////////////////////////////////////////////////
 
 // Additional authors: Stephan Aßmus, <superstippi@xxxxxx>
+//                     Philippe Saint-Pierre, 2013, <stpere@xxxxxxxxx>
 
 #ifndef GIFVIEW_H
 #define GIFVIEW_H
 
 #include <View.h>
+#include "TranslatorSettings.h"
 
 class BMenuField;
 class BPopUpMenu;
@@ -26,7 +28,6 @@ class BMenuItem;
 class BCheckBox;
 class BRadioButton;
 class BTextControl;
-class Prefs;
 
 #define GV_WEB_SAFE                                    'gvws'
 #define GV_BEOS_SYSTEM                         'gvbe'
@@ -42,9 +43,12 @@ class Prefs;
 #define GV_TRANSPARENT_BLUE                    'gvtb'
 #define GV_SET_COLOR_COUNT                     'gvcc'
 
+
+const BRect kRectView(110, 110, 339, 339);
+
 class GIFView : public BView {
  public:
-                                                       GIFView(const char* 
name);
+                                                       
GIFView(TranslatorSettings* settings);
        virtual                                 ~GIFView();
 
        virtual void                    MessageReceived(BMessage* message);
@@ -54,7 +58,7 @@ class GIFView : public BView {
                        void                    RestorePrefs();
                        int                             
CheckInput(BTextControl* control);
 
-               Prefs*                          fPrefs;
+               TranslatorSettings*             fSettings;
 
                BMenuField*                     fPaletteMF;
                BPopUpMenu*                     fPaletteM;
diff --git a/src/add-ons/translators/gif/GIFWindow.cpp 
b/src/add-ons/translators/gif/GIFWindow.cpp
deleted file mode 100644
index b318897..0000000
--- a/src/add-ons/translators/gif/GIFWindow.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//     File: GIFWindow.cpp
-//
-//     Date: December 1999
-//
-//     Author: Daniel Switkin
-//
-//     Copyright 2003 (c) by Daniel Switkin. This file is made publically 
available
-//     under the BSD license, with the stipulations that this complete header 
must
-//     remain at the top of the file indefinitely, and credit must be given to 
the
-//     original author in any about box using this software.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#include "GIFWindow.h"
-#include "GIFView.h"
-#include <Application.h>
-#include <LayoutBuilder.h>
-
-GIFWindow::GIFWindow(BRect rect, const char *name) :
-       BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
-       | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE) {
-
-       gifview = new GIFView("GIFView");
-       BLayoutBuilder::Group<>(this, B_HORIZONTAL)
-               .Add(gifview);
-}
-
-bool GIFWindow::QuitRequested() {
-       be_app->PostMessage(B_QUIT_REQUESTED);
-       return true;
-}
-
diff --git a/src/add-ons/translators/gif/GIFWindow.h 
b/src/add-ons/translators/gif/GIFWindow.h
deleted file mode 100644
index b05150d..0000000
--- a/src/add-ons/translators/gif/GIFWindow.h
+++ /dev/null
@@ -1,30 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//     File: GIFWindow.h
-//
-//     Date: December 1999
-//
-//     Author: Daniel Switkin
-//
-//     Copyright 2003 (c) by Daniel Switkin. This file is made publically 
available
-//     under the BSD license, with the stipulations that this complete header 
must
-//     remain at the top of the file indefinitely, and credit must be given to 
the
-//     original author in any about box using this software.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#ifndef GIFWINDOW_H
-#define GIFWINDOW_H
-
-#include <Window.h>
-class GIFView;
-
-class GIFWindow : public BWindow {
-       public:
-               GIFWindow(BRect rect, const char *name);
-               bool QuitRequested();
-               GIFView *gifview;
-};
-
-#endif
-
diff --git a/src/add-ons/translators/gif/Jamfile 
b/src/add-ons/translators/gif/Jamfile
index 794c5f1..11ba11e 100644
--- a/src/add-ons/translators/gif/Jamfile
+++ b/src/add-ons/translators/gif/Jamfile
@@ -2,14 +2,14 @@ SubDir HAIKU_TOP src add-ons translators gif ;
 
 SetSubDirSupportedPlatformsBeOSCompatible ;
 
+SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ;
+
 AddResources GIFTranslator : GIFTranslator.rdef ;
 
 Translator GIFTranslator :
        # Main Source
        GIFTranslator.cpp
        GIFView.cpp
-       GIFWindow.cpp
-       Prefs.cpp
 
        # Real Work
        GIFLoad.cpp
@@ -19,6 +19,7 @@ Translator GIFTranslator :
        SFHash.cpp
        :
        be translation $(TARGET_LIBSUPC++) localestub
+       libtranslatorsutils.a
        : true
 ;
 
diff --git a/src/add-ons/translators/gif/Prefs.cpp 
b/src/add-ons/translators/gif/Prefs.cpp
deleted file mode 100644
index da31cda..0000000
--- a/src/add-ons/translators/gif/Prefs.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//     File: Prefs.cpp
-//
-//     Date: December 1999
-//
-//     Author: Daniel Switkin
-//
-//     Copyright 2003 (c) by Daniel Switkin. This file is made publically 
available
-//     under the BSD license, with the stipulations that this complete header 
must
-//     remain at the top of the file indefinitely, and credit must be given to 
the
-//     original author in any about box using this software.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-// Additional authors: Stephan Aßmus, <superstippi@xxxxxx>
-
-#include "Prefs.h"
-#include <File.h>
-#include <Path.h>
-#include <FindDirectory.h>
-#include <stdio.h>
-
-extern bool debug;
-
-// constructor
-Prefs::Prefs()
-       : interlaced(false),
-         usetransparent(false),
-         usetransparentauto(false),
-         usedithering(false),
-         transparentred(0),
-         transparentgreen(0),
-         transparentblue(0),
-         palettemode(0),
-         palette_size_in_bits(8),
-         file(NULL)
-{
-       BPath path;
-       find_directory(B_USER_SETTINGS_DIRECTORY, &path);
-       path.Append("GIFTranslator_settings");
-       file = new BFile(path.Path(), B_READ_WRITE | B_CREATE_FILE);
-       
-       if (file->InitCheck() != B_OK) {
-               if (debug) printf("Bad filename for attributes\n");
-               return;
-       }
-       
-       bool db = false;
-       if (!GetBool("interlaced", &interlaced, &db)) return;
-       db = false;
-       if (!GetBool("usetransparent", &usetransparent, &db)) return;
-       db = false;
-       if (!GetBool("usetransparentauto", &usetransparentauto, &db)) return;
-       db = true;
-       if (!GetBool("usedithering", &usedithering, &db)) return;
-       int di = 0;
-       if (!GetInt("palettemode", &palettemode, &di)) return;
-       di = 8;
-       if (!GetInt("palettesize", &palette_size_in_bits, &di)) return;
-       di = 0;
-       if (!GetInt("transparentred", &transparentred, &di)) return;
-       di = 0;
-       if (!GetInt("transparentgreen", &transparentgreen, &di)) return;
-       di = 0;
-       if (!GetInt("transparentblue", &transparentblue, &di)) return;
-}
-
-// destructor
-Prefs::~Prefs()
-{
-       delete file;
-}
-
-// GetInt
-bool
-Prefs::GetInt(const char *name, int *value, int *defaultvalue)
-{
-       status_t err = file->ReadAttr(name, B_INT32_TYPE, 0, value, 4);
-       if (err == B_ENTRY_NOT_FOUND) {
-               *value = *defaultvalue;
-               if (file->WriteAttr(name, B_INT32_TYPE, 0, defaultvalue, 4) < 
0) {
-                       if (debug) printf("WriteAttr on %s died\n", name);
-                       return false;
-               }
-       } else if  (err < 0) {
-               if (debug) printf("Unknown error reading %s\n", name);
-               return false;
-       }
-       return true;
-}
-
-// GetBool
-bool
-Prefs::GetBool(const char *name, bool *value, bool *defaultvalue)
-{
-       status_t err = file->ReadAttr(name, B_BOOL_TYPE, 0, value, 1);
-       if (err == B_ENTRY_NOT_FOUND) {
-               *value = *defaultvalue;
-               if (file->WriteAttr(name, B_BOOL_TYPE, 0, defaultvalue, 1) < 0) 
{
-                       if (debug) printf("WriteAttr on %s died\n", name);
-                       return false;
-               }
-       } else if (err < 0) {
-               if (debug) printf("Unknown error reading %s\n", name);
-               return false;
-       }
-       return true;
-}
-
-// PutInt
-bool
-Prefs::PutInt(const char *name, int *value)
-{
-       status_t err = file->WriteAttr(name, B_INT32_TYPE, 0, value, 4);
-       if (err < 0) {
-               if (debug) printf("WriteAttr on %s died\n", name);
-               return false;
-       }
-       return true;
-}
-
-// PutBool
-bool
-Prefs::PutBool(const char *name, bool *value)
-{
-       status_t err = file->WriteAttr(name, B_BOOL_TYPE, 0, value, 1);
-       if (err < 0) {
-               if (debug) printf("WriteAttr on %s died\n", name);
-               return false;
-       }
-       return true;
-}
-
-// Save
-void
-Prefs::Save()
-{
-       if (!PutBool("interlaced", &interlaced)) return;
-       if (!PutBool("usetransparent", &usetransparent)) return;
-       if (!PutBool("usetransparentauto", &usetransparentauto)) return;
-       if (!PutBool("usedithering", &usedithering)) return;
-       if (!PutInt("palettemode", &palettemode)) return;
-       if (!PutInt("palettesize", &palette_size_in_bits)) return;
-       if (!PutInt("transparentred", &transparentred)) return;
-       if (!PutInt("transparentgreen", &transparentgreen)) return;
-       if (!PutInt("transparentblue", &transparentblue)) return;
-}
-
diff --git a/src/add-ons/translators/gif/Prefs.h 
b/src/add-ons/translators/gif/Prefs.h
deleted file mode 100644
index d410023..0000000
--- a/src/add-ons/translators/gif/Prefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-//     File: Prefs.h
-//
-//     Date: December 1999
-//
-//     Author: Daniel Switkin
-//
-//     Copyright 2003 (c) by Daniel Switkin. This file is made publically 
available
-//     under the BSD license, with the stipulations that this complete header 
must
-//     remain at the top of the file indefinitely, and credit must be given to 
the
-//     original author in any about box using this software.
-//
-////////////////////////////////////////////////////////////////////////////////
-
-// Additional authors: Stephan Aßmus, <superstippi@xxxxxx>
-
-#ifndef PREFS_H
-#define PREFS_H
-
-class BNode;
-
-class Prefs {
-       public:
-               Prefs();
-               void Save();
-               ~Prefs();
-               bool interlaced, usetransparent, usetransparentauto,
-                       usedithering;
-               int transparentred, transparentgreen,
-                       transparentblue, palettemode, palette_size_in_bits;
-       private:
-               bool GetInt(const char *name, int *value, int *defaultvalue);
-               bool GetBool(const char *name, bool *value, bool *defaultvalue);
-               bool PutInt(const char *name, int *value);
-               bool PutBool(const char *name, bool *value);
-               
-               BNode *file;
-};
-
-#endif
-


Other related posts:

  • » [haiku-commits] haiku: hrev46231 - src/add-ons/translators/gif - stpere