From 81b7cc6b1815ec6f0f0c42d6a826d56c8b35033b Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 9 Nov 2010 23:21:28 +0100 Subject: add virtual baseclass for data sources (iDataSource) let eRawFile inherit from iDataSource --- lib/base/rawfile.cpp | 20 ++++++++++++++++++++ lib/base/rawfile.h | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/lib/base/rawfile.cpp b/lib/base/rawfile.cpp index c7e11feb..1552203a 100644 --- a/lib/base/rawfile.cpp +++ b/lib/base/rawfile.cpp @@ -4,7 +4,10 @@ #include #include +DEFINE_REF(eRawFile); + eRawFile::eRawFile() + :m_lock(true) { m_fd = -1; m_file = 0; @@ -232,3 +235,20 @@ off_t eRawFile::length() { return m_totallength; } + +off_t eRawFile::position() +{ + if (m_nrfiles < 2) + { + if (!m_cached) + return ::lseek(m_fd, 0, SEEK_CUR); + else + return ::fseeko(m_file, 0, SEEK_CUR); + } + return m_current_offset; +} + +eSingleLock &eRawFile::getLock() +{ + return m_lock; +} diff --git a/lib/base/rawfile.h b/lib/base/rawfile.h index a1c73d6a..bb39dc6e 100644 --- a/lib/base/rawfile.h +++ b/lib/base/rawfile.h @@ -2,24 +2,58 @@ #define __lib_base_rawfile_h #include +#include -class eRawFile +class iDataSource: public iObject { +public: + virtual off_t lseek(off_t offset, int whence)=0; + virtual ssize_t read(void *buf, size_t count)=0; /* NOTE: you must be able to handle short reads! */ + virtual off_t length()=0; + virtual off_t position()=0; + virtual int valid()=0; + virtual eSingleLock &getLock()=0; + virtual bool is_shared()=0; +}; + +class iDataSourcePositionRestorer +{ + ePtr &m_source; + off_t m_position; +public: + iDataSourcePositionRestorer(ePtr &source) + :m_source(source) + { + if (m_source->is_shared()) + m_position = m_source->position(); + } + ~iDataSourcePositionRestorer() + { + if (m_source->is_shared()) + m_source->lseek(m_position, SEEK_SET); + } +}; + +class eRawFile: public iDataSource +{ + DECLARE_REF(eRawFile); + eSingleLock m_lock; public: eRawFile(); ~eRawFile(); - int open(const char *filename, int cached = 0); void setfd(int fd); off_t lseek(off_t offset, int whence); int close(); ssize_t read(void *buf, size_t count); /* NOTE: you must be able to handle short reads! */ off_t length(); + off_t position(); int valid(); + eSingleLock &getLock(); + bool is_shared() { return ref.count > 1; } private: int m_fd; /* for uncached */ FILE *m_file; /* for cached */ - int m_cached; std::string m_basename; off_t m_splitsize, m_totallength, m_current_offset, m_base_offset, m_last_offset; -- cgit v1.2.3 From a7175f3218cbb81c7c1cd07a8092e5a2b30dac44 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 10 Nov 2010 17:20:56 +0100 Subject: Revert "add virtual baseclass for data sources (iDataSource)" This reverts commit 81b7cc6b1815ec6f0f0c42d6a826d56c8b35033b. --- lib/base/rawfile.cpp | 20 -------------------- lib/base/rawfile.h | 40 +++------------------------------------- 2 files changed, 3 insertions(+), 57 deletions(-) diff --git a/lib/base/rawfile.cpp b/lib/base/rawfile.cpp index 1552203a..c7e11feb 100644 --- a/lib/base/rawfile.cpp +++ b/lib/base/rawfile.cpp @@ -4,10 +4,7 @@ #include #include -DEFINE_REF(eRawFile); - eRawFile::eRawFile() - :m_lock(true) { m_fd = -1; m_file = 0; @@ -235,20 +232,3 @@ off_t eRawFile::length() { return m_totallength; } - -off_t eRawFile::position() -{ - if (m_nrfiles < 2) - { - if (!m_cached) - return ::lseek(m_fd, 0, SEEK_CUR); - else - return ::fseeko(m_file, 0, SEEK_CUR); - } - return m_current_offset; -} - -eSingleLock &eRawFile::getLock() -{ - return m_lock; -} diff --git a/lib/base/rawfile.h b/lib/base/rawfile.h index bb39dc6e..a1c73d6a 100644 --- a/lib/base/rawfile.h +++ b/lib/base/rawfile.h @@ -2,58 +2,24 @@ #define __lib_base_rawfile_h #include -#include -class iDataSource: public iObject +class eRawFile { -public: - virtual off_t lseek(off_t offset, int whence)=0; - virtual ssize_t read(void *buf, size_t count)=0; /* NOTE: you must be able to handle short reads! */ - virtual off_t length()=0; - virtual off_t position()=0; - virtual int valid()=0; - virtual eSingleLock &getLock()=0; - virtual bool is_shared()=0; -}; - -class iDataSourcePositionRestorer -{ - ePtr &m_source; - off_t m_position; -public: - iDataSourcePositionRestorer(ePtr &source) - :m_source(source) - { - if (m_source->is_shared()) - m_position = m_source->position(); - } - ~iDataSourcePositionRestorer() - { - if (m_source->is_shared()) - m_source->lseek(m_position, SEEK_SET); - } -}; - -class eRawFile: public iDataSource -{ - DECLARE_REF(eRawFile); - eSingleLock m_lock; public: eRawFile(); ~eRawFile(); + int open(const char *filename, int cached = 0); void setfd(int fd); off_t lseek(off_t offset, int whence); int close(); ssize_t read(void *buf, size_t count); /* NOTE: you must be able to handle short reads! */ off_t length(); - off_t position(); int valid(); - eSingleLock &getLock(); - bool is_shared() { return ref.count > 1; } private: int m_fd; /* for uncached */ FILE *m_file; /* for cached */ + int m_cached; std::string m_basename; off_t m_splitsize, m_totallength, m_current_offset, m_base_offset, m_last_offset; -- cgit v1.2.3 From 29788aa82abe81b63571066daff593db95695423 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 11 Nov 2010 10:24:34 +0100 Subject: add template handling to pixmap progress listboxmulticontent refs #539 --- lib/gui/elistboxcontent.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index dbf96375..2eea1466 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -962,6 +962,9 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c if (ppixmap) { ePtr pixmap; + if (PyInt_Check(ppixmap) && data) /* if the pixmap is in fact a number, it refers to the data list */ + ppixmap = PyTuple_GetItem(data, PyInt_AsLong(ppixmap)); + if (SwigFromPython(pixmap, ppixmap)) { eDebug("eListboxPythonMultiContent (Pixmap) get pixmap failed"); -- cgit v1.2.3