diff --git a/common/i18n.h b/common/i18n.h index fa7e7c64a..57430e51f 100644 --- a/common/i18n.h +++ b/common/i18n.h @@ -24,7 +24,7 @@ #define _I18N_H_ #ifdef HAVE_CONFIG_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #endif #ifdef ENABLE_NLS diff --git a/common/raptoptions.cc b/common/raptoptions.cc index 9da44114d..4cd85adc4 100644 --- a/common/raptoptions.cc +++ b/common/raptoptions.cc @@ -20,27 +20,32 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include "raptoptions.h" #include "i18n.h" #include "rconfiguration.h" -#include "raptoptions.h" -RAPTOptions *_roptions = new RAPTOptions; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; +RAPTOptions *_roptions = new RAPTOptions; + ostream &operator<<(ostream &os, const RAPTOptions::packageOptions &o) { os << o.isNew; diff --git a/common/raptoptions.h b/common/raptoptions.h index ea7ccc2af..235f9cfa7 100644 --- a/common/raptoptions.h +++ b/common/raptoptions.h @@ -23,11 +23,11 @@ #ifndef _RAPTOPTIONS_H_ #define _RAPTOPTIONS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include +#include #include -#include class RAPTOptions { public: diff --git a/common/rcacheactor.cc b/common/rcacheactor.cc index dbabc9027..9dae0bdbb 100644 --- a/common/rcacheactor.cc +++ b/common/rcacheactor.cc @@ -1,14 +1,21 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rcacheactor.h" + +#include "rpackage.h" #include "rpackagelister.h" +#include +#include #include -#include #include -#include -#include +#include +#include #include +#include +#include +#include +#include using namespace std; @@ -47,10 +54,6 @@ void RCacheActor::notifyCachePostChange() } } - - - - RCacheActorRecommends::RCacheActorRecommends(RPackageLister *lister, string fileName) : RCacheActor(lister) @@ -194,6 +197,4 @@ void RCacheActorRecommends::run(vector &PkgList, int Action) } } - - // vim:sts=3:sw=3 diff --git a/common/rcacheactor.h b/common/rcacheactor.h index 950340763..8211f91c4 100644 --- a/common/rcacheactor.h +++ b/common/rcacheactor.h @@ -25,10 +25,16 @@ #ifndef _RCACHEACTOR_H #define _RCACHEACTOR_H -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include "rpackage.h" #include "rpackagelister.h" + +#include +#include #include +#include +#include class RCacheActor:public RCacheObserver { public: diff --git a/common/rcdscanner.cc b/common/rcdscanner.cc index 5c87c61d8..7354bf626 100644 --- a/common/rcdscanner.cc +++ b/common/rcdscanner.cc @@ -20,27 +20,27 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifndef HAVE_APTPKG_CDROM -#include -#include -#include -#include -#include -#include -#include -#include +#include "rcdscanner.h" + +#include "i18n.h" +#include +#include +#include #include #include -#include -#include #include - -#include "i18n.h" -#include "rcdscanner.h" +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_RPM #include "rpmindexcopy.h" diff --git a/common/rcdscanner.h b/common/rcdscanner.h index 22041cf72..1b83dac52 100644 --- a/common/rcdscanner.h +++ b/common/rcdscanner.h @@ -23,7 +23,7 @@ #ifndef _RCDSCANNER_H_ #define _RCDSCANNER_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifndef HAVE_APTPKG_CDROM diff --git a/common/rconfiguration.cc b/common/rconfiguration.cc index 4a7181db5..67265f4e6 100644 --- a/common/rconfiguration.cc +++ b/common/rconfiguration.cc @@ -22,25 +22,26 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include - -#include -#include +#include "rconfiguration.h" -#include +#include "i18n.h" -#include -#include #include -#include +#include #include - -#include "rconfiguration.h" - -#include "i18n.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; diff --git a/common/rconfiguration.h b/common/rconfiguration.h index 704cfb4aa..1aecc7648 100644 --- a/common/rconfiguration.h +++ b/common/rconfiguration.h @@ -25,7 +25,7 @@ #ifndef _RCONFIGURATION_H_ #define _RCONFIGURATION_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include #include diff --git a/common/rinstallprogress.cc b/common/rinstallprogress.cc index 229550dde..c9fce7de5 100644 --- a/common/rinstallprogress.cc +++ b/common/rinstallprogress.cc @@ -22,26 +22,30 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include +#include "rinstallprogress.h" + +#include "i18n.h" + +#include +#include +#include +#include #include #include -#include -#include -#include -#include +#include + #ifdef HAVE_RPM #include +#include #endif -#include "rinstallprogress.h" +using namespace std; -#include "i18n.h" -std::string RInstallProgress::finishMsg = _("\nSuccessfully applied all changes. You can close the window now."); -std::string RInstallProgress::errorMsg = _("\nNot all changes and updates succeeded. For further details of the failure, please expand the 'Details' panel below."); -std::string RInstallProgress::incompleteMsg = +string RInstallProgress::finishMsg = _("\nSuccessfully applied all changes. You can close the window now."); +string RInstallProgress::errorMsg = _("\nNot all changes and updates succeeded. For further details of the failure, please expand the 'Details' panel below."); +string RInstallProgress::incompleteMsg = _("\nSuccessfully installed all packages of the current medium. " "To continue the installation with the next medium close " "this window."); @@ -64,7 +68,6 @@ const char* RInstallProgress::getResultStr(pkgPackageManager::OrderResult res) return "Unknown install result."; } - pkgPackageManager::OrderResult RInstallProgress::start(pkgPackageManager *pm, int numPackages, int numPackagesTotal) diff --git a/common/rinstallprogress.h b/common/rinstallprogress.h index bb37707ff..75f3ca8f1 100644 --- a/common/rinstallprogress.h +++ b/common/rinstallprogress.h @@ -25,10 +25,12 @@ #ifndef _RINSTALLPROGRESS_H_ #define _RINSTALLPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include +#include + class RInstallProgress { protected: int _stdout; diff --git a/common/rpackage.cc b/common/rpackage.cc index a0ebd5a2c..3925227a5 100644 --- a/common/rpackage.cc +++ b/common/rpackage.cc @@ -26,39 +26,43 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "i18n.h" #include "rpackage.h" + +#include "i18n.h" +#include "rconfiguration.h" +#include "rpackagecache.h" #include "rpackagelister.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include +#include #include -#include #include #include #include #include +#include +#include #include #include #include -#include -#include +#include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef WITH_LUA #include @@ -1146,26 +1150,23 @@ bool RPackage::isShallowDependency(RPackage *pkg) // format: first version, second archives -vector > RPackage::getAvailableVersions() +vector> RPackage::getAvailableVersions() { - string VerTag; - vector > versions; + vector> versions; // Get available Versions. - for (pkgCache::VerIterator Ver = _package->VersionList(); - Ver.end() == false; Ver++) { + for (pkgCache::VerIterator Ver = _package->VersionList(); Ver.end() == false; Ver++) { // We always take the first available version. pkgCache::VerFileIterator VF = Ver.FileList(); if (!VF.end()) { pkgCache::PkgFileIterator File = VF.File(); - - if (File.Archive() != 0) - versions.push_back(pair < string, - string > (Ver.VerStr(), File.Archive())); - else - versions.push_back(pair < string, - string > (Ver.VerStr(), File.Site())); + + if (File.Archive() != NULL) { + versions.push_back(pair(Ver.VerStr(), File.Archive())); + } else { + versions.push_back(pair(Ver.VerStr(), File.Site())); + } } } diff --git a/common/rpackage.h b/common/rpackage.h index c6fdc36ee..2f3d4ac3a 100644 --- a/common/rpackage.h +++ b/common/rpackage.h @@ -29,18 +29,19 @@ #ifndef _RPACKAGE_H_ #define _RPACKAGE_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include +#include "i18n.h" #include -#include -#include "rconfiguration.h" -#include "i18n.h" +#include +#include +#include +#include -class pkgDepCache; class RPackageLister; +class pkgAcquire; +class pkgDepCache; class pkgRecords; enum { NO_PARSER, DEB_PARSER, STRIP_WS_PARSER, RPM_PARSER }; diff --git a/common/rpackagecache.cc b/common/rpackagecache.cc index 36d4afc37..dfefa72f7 100644 --- a/common/rpackagecache.cc +++ b/common/rpackagecache.cc @@ -20,20 +20,24 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rpackagecache.h" -#include "rconfiguration.h" + #include "i18n.h" +#include "rconfiguration.h" -#include #include +#include #include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include + +class pkgIndexFile; using namespace std; diff --git a/common/rpackagecache.h b/common/rpackagecache.h index 4a40f5752..20885b51d 100644 --- a/common/rpackagecache.h +++ b/common/rpackagecache.h @@ -23,22 +23,18 @@ #ifndef _RPACKAGECACHE_H_ #define _RPACKAGECACHE_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include +#include #include #include #include -#include -#include -#include -#include -#include - class OpProgress; - -class pkgCache; - +class pkgDepCache; +class pkgIndexFile; +class pkgSourceList; class RPackageCache { pkgCacheFile cache; @@ -72,5 +68,4 @@ class RPackageCache { } }; - #endif diff --git a/common/rpackagefilter.cc b/common/rpackagefilter.cc index 94c9d6dc9..8145b1e8c 100644 --- a/common/rpackagefilter.cc +++ b/common/rpackagefilter.cc @@ -22,22 +22,33 @@ * USA */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include +#include "config.h" // IWYU pragma: associated #include "rpackagefilter.h" -#include "rpackagelister.h" -#include "rpackage.h" #include "i18n.h" +#include "rpackage.h" +#include "rpackagelister.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include using namespace std; diff --git a/common/rpackagefilter.h b/common/rpackagefilter.h index 74868597a..e8355e0ef 100644 --- a/common/rpackagefilter.h +++ b/common/rpackagefilter.h @@ -25,28 +25,20 @@ #ifndef _RPACKAGEFILTER_H_ #define _RPACKAGEFILTER_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include +#include #include -#include -#include - #include - -#include "rpackagelister.h" - -class RPackage; -class RPackageLister; +#include +#include +#include class Configuration; - +class RPackage; class RPackageFilter { - public: virtual const char *type() = 0; diff --git a/common/rpackagelistactor.cc b/common/rpackagelistactor.cc index 613a65b5f..74bc80bab 100644 --- a/common/rpackagelistactor.cc +++ b/common/rpackagelistactor.cc @@ -1,14 +1,11 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rpackagelistactor.h" + #include "rpackagelister.h" -#include -#include -#include -#include #include -#include +#include using namespace std; diff --git a/common/rpackagelistactor.h b/common/rpackagelistactor.h index fe86e0cac..632e54f81 100644 --- a/common/rpackagelistactor.h +++ b/common/rpackagelistactor.h @@ -23,10 +23,13 @@ #ifndef RPACKAGELISTACTOR_H #define RPACKAGELISTACTOR_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rpackagelister.h" -#include + +#include + +class RPackage; class RPackageListActor : public RPackageObserver { diff --git a/common/rpackagelister.cc b/common/rpackagelister.cc index e2bb23f77..f7246883a 100644 --- a/common/rpackagelister.cc +++ b/common/rpackagelister.cc @@ -25,67 +25,75 @@ * USA */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "config.h" // IWYU pragma: associated #include "rpackagelister.h" -#include "rpackagecache.h" -#include "rpackagefilter.h" -#include "rconfiguration.h" + +#include "i18n.h" #include "raptoptions.h" -#include "rinstallprogress.h" #include "rcacheactor.h" +#include "rconfiguration.h" +#include "rinstallprogress.h" +#include "rpackage.h" +#include "rpackagecache.h" +#include "rpackageview.h" +#include "ruserdialog.h" -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include #ifndef HAVE_RPM #include #endif +#ifdef WITH_QUICK_FILTER +#include +#endif + #ifdef WITH_LUA #include #endif -#include -#include - -#include "sections_trans.h" - -#include "i18n.h" - -const std::string APT_XAPIAN_INDEX_DIR = "/var/lib/apt-xapian-index"; - using namespace std; -RPackageLister::RPackageLister() - : _records(0), _progMeter(new OpProgress) -#ifdef HAVE_XAPIAN - , _xapianDatabase(0) -#endif +RPackageLister::RPackageLister() : _records(0), _progMeter(new OpProgress) { _cache = new RPackageCache(); @@ -105,9 +113,10 @@ RPackageLister::RPackageLister() _views.push_back(_searchView); // its import that we use "_packages" here instead of _nativeArchPackages _views.push_back(new RPackageViewArchitecture(_packages)); -#ifdef HAVE_XAPIAN - openXapianIndex(); -#endif + + #ifdef WITH_QUICK_FILTER + openQuickFilterDb(); + #endif if (_viewMode >= _views.size()) _viewMode = 0; @@ -128,6 +137,10 @@ RPackageLister::RPackageLister() RPackageLister::~RPackageLister() { + #ifdef WITH_QUICK_FILTER + sqlite3_close_v2(_quickFilterDb); + #endif + for (vector::iterator I = _actors.begin(); I != _actors.end(); I++) delete(*I); @@ -310,15 +323,15 @@ bool RPackageLister::openCache() _error->Discard(); // only lock if we run as root - bool lock = true; - if(getuid() != 0) - lock = false; + bool lock = (getuid() == 0); - if (!_cache->open(_progMeter,lock)) { + if (!_cache->open(_progMeter, lock)) + { _progMeter->Done(); _cacheValid = false; return _error->Error("_cache->open() failed, cannot continue."); } + _progMeter->Done(); pkgDepCache *deps = _cache->deps(); @@ -417,7 +430,21 @@ bool RPackageLister::openCache() sectionSet.insert(Ver.Section()); } } + + #ifdef WITH_QUICK_FILTER + + // Open and populate the quick search database. + if (openQuickFilterDb()) + { + if (!populateQuickFilterDb(_quickFilterDb, _packages)) + { + sqlite3_close_v2(_quickFilterDb); + _quickFilterDb = nullptr; + } + } + #endif + // refresh the views for (unsigned int i = 0; i != _views.size(); i++) _views[i]->refresh(); @@ -437,55 +464,192 @@ bool RPackageLister::openCache() return true; } -#ifdef HAVE_XAPIAN -time_t RPackageLister::xapianIndexTimestamp() +#ifdef WITH_QUICK_FILTER + +// Initializes the database and sets the _quickFilterDb pointer. +// In case of error returns false and _quickFilterDb is set to nullptr) +bool RPackageLister::openQuickFilterDb() { - std::string db = APT_XAPIAN_INDEX_DIR + "/update-timestamp"; - struct stat st; - int rv = stat(db.c_str(), &st); - return rv ? 0 : st.st_mtime; + if (_quickFilterDb == nullptr) + { + // First time initialization: Open the database (in memory) and create the tables. + + sqlite3 *db; // The _quickSearchDb pointer only gets updated after full successful initialization (otherwise it remains set to nullptr). + + if (sqlite3_open_v2("", &db, SQLITE_OPEN_MEMORY | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_PRIVATECACHE, NULL) != SQLITE_OK) + { + _error->Error(_("Unable to open the quick search database!")); + return false; + } + + // https://sqlite.org/pragma.html#pragma_journal_mode + if (sqlite3_exec(db, "PRAGMA journal_mode = OFF", nullptr, nullptr, nullptr) != SQLITE_OK) + { + _error->Warning(_("Unable to set the quick search database journal_mode!")); + } + + // https://sqlite.org/pragma.html#pragma_synchronous + if (sqlite3_exec(db, "PRAGMA synchronous = OFF", nullptr, nullptr, nullptr) != SQLITE_OK) + { + _error->Warning(_("Unable to set the quick search database synchronous mode!")); + } + + // SQLITE_LIMIT_WORKER_THREADS: The maximum number of auxiliary worker threads that a single prepared statement may start. + sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, 4); + + // Create the table for the text searches: + if (sqlite3_exec(db, "CREATE VIRTUAL TABLE fts USING fts5(name, description)", nullptr, nullptr, nullptr) != SQLITE_OK) + { + _error->Error(_("Unable to create the quick search database tables!")); + sqlite3_close(db); + return false; + } + + _quickFilterDb = db; + } + else + { + // Empty the database. + if (sqlite3_exec(_quickFilterDb, "DELETE FROM fts", nullptr, nullptr, nullptr) != SQLITE_OK) + { + _error->Error(_("Unable to empty the quick search database tables!")); + sqlite3_close(_quickFilterDb); + _quickFilterDb = nullptr; + return false; + } + } + + return true; } -bool RPackageLister::xapianIndexNeedsUpdate() +// Inform the database that a bulk insertion (transaction) is starting. +// Returns false in case of error. +bool RPackageLister::BeginQuickFilterDbInsertion(sqlite3 *db) { - struct stat buf; + if (db != nullptr) + { + static sqlite3_stmt *stmt = nullptr; + + if (stmt == nullptr) + { + if (sqlite3_prepare_v3(db, "BEGIN DEFERRED", -1, SQLITE_PREPARE_PERSISTENT, &stmt, nullptr) != SQLITE_OK) + { + fprintf(stderr, "Can't prepare the BEGIN statement!\n"); + stmt = nullptr; + return false; + } + } + + if (sqlite3_reset(stmt) != SQLITE_OK) + { + fprintf(stderr, "Can't reset the BEGIN statement!\n"); + return false; + } + + if (sqlite3_step(stmt) != SQLITE_DONE) + { + fprintf(stderr, "The execution of the BEGIN statement failed!\n"); + return false; + } + } - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "xapainIndexNeedsUpdate()" << std::endl; - - // check the xapian index - if(FileExists("/usr/sbin/update-apt-xapian-index") && - (!_xapianDatabase )) { - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "xapain index not build yet" << std::endl; - return true; - } - - // compare timestamps, rebuild everytime, its now cheap(er) - // because we use u-a-x-i --update - stat(_config->FindFile("Dir::Cache::pkgcache").c_str(), &buf); - if(xapianIndexTimestamp() < buf.st_mtime) { - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "xapian outdated " - << buf.st_mtime - xapianIndexTimestamp() << std::endl; - return true; + return true; +} + +// Inform the database that a bulk insertion (transaction) is finished. +// Returns false in case of error. +bool RPackageLister::EndQuickFilterDbInsertion(sqlite3 *db) +{ + if (db != nullptr) + { + static sqlite3_stmt *stmt = nullptr; + + if (stmt == nullptr) + { + if (sqlite3_prepare_v3(db, "END", -1, SQLITE_PREPARE_PERSISTENT, &stmt, nullptr) != SQLITE_OK) + { + _error->Error(_("Unable to prepare the END statement!")); + stmt = nullptr; + return false; + } + } + + if (sqlite3_reset(stmt) != SQLITE_OK) + { + _error->Error(_("Unable to reset the END statement!")); + return false; + } + + if (sqlite3_step(stmt) != SQLITE_DONE) + { + _error->Error(_("Unable to execute the END statement!")); + return false; + } } - return false; + return true; } -bool RPackageLister::openXapianIndex() +bool RPackageLister::AddPackageToQuickFilterDb(sqlite3 *db, const string_view &name, const string_view &description) { - if(_xapianDatabase) - delete _xapianDatabase; - try { - _xapianDatabase = new Xapian::Database(APT_XAPIAN_INDEX_DIR + "/index"); - } catch (Xapian::DatabaseOpeningError) { + static sqlite3_stmt *stmt = nullptr; + + if (stmt == nullptr) + { + if (sqlite3_prepare_v3(db, "INSERT INTO fts VALUES(?, ?)", -1, SQLITE_PREPARE_PERSISTENT, &stmt, nullptr) != SQLITE_OK) + { + _error->Error(_("Unable to prepare the INSERT statement!")); + stmt = nullptr; + return false; + } + } + + if (sqlite3_reset(stmt) != SQLITE_OK) + { + _error->Error(_("Unable to reset the INSERT statement!")); return false; - }; + } + + if (sqlite3_bind_text(stmt, 1, name.data(), name.length(), SQLITE_STATIC) != SQLITE_OK) + { + _error->Error(_("Unable to bind the name to the statement!")); + return false; + } + + if (sqlite3_bind_text(stmt, 2, description.data(), description.length(), SQLITE_STATIC) != SQLITE_OK) + { + _error->Error(_("Unable to bind the description to the statement!")); + return false; + } + + if (sqlite3_step(stmt) != SQLITE_DONE) + { + _error->Error(_("Unable to execute the INSERT statement!")); + return false; + } + return true; } -#endif + +bool RPackageLister::populateQuickFilterDb(sqlite3 *db, vector &packages) +{ + if (BeginQuickFilterDbInsertion(db)) + { + for (RPackage *package : packages) + { + if (!AddPackageToQuickFilterDb(db, package->name(), package->description())) + { + return false; + } + } + + EndQuickFilterDbInsertion(db); + } + + return true; +} + +#endif // WITH_QUICK_FILTER void RPackageLister::applyInitialSelection() { @@ -1968,136 +2132,65 @@ bool RPackageLister::addArchiveToCache(string archive, string &pkgname) #endif } +#ifdef WITH_QUICK_FILTER -#ifdef HAVE_XAPIAN -bool RPackageLister::limitBySearch(string searchString) -{ - //cerr << "limitBySearch(): " << searchString << endl; - if (xapianIndexTimestamp() == 0) - return false; - return xapianSearch(searchString); -} - -bool RPackageLister::xapianSearch(string unsplitSearchString) +bool RPackageLister::applyQuickFilter(string searchString) { - //std::cerr << "RPackageLister::xapianSearch()" << std::endl; - static const int defaultQualityCutoff = 15; - int qualityCutoff = _config->FindI("Synaptic::Xapian::qualityCutoff", - defaultQualityCutoff); - if (xapianIndexTimestamp() == 0) - return false; - - try { - int maxItems = _xapianDatabase->get_doccount(); - Xapian::Enquire enquire(*_xapianDatabase); - Xapian::QueryParser parser; - parser.set_database(*_xapianDatabase); - parser.add_prefix("name","XP"); - parser.add_prefix("section","XS"); - // default op is AND to narrow down the resultset - parser.set_default_op( Xapian::Query::OP_AND ); + if (_quickFilterDb == nullptr) + { + return false; // Quick search not available. + } - /* Workaround to allow searching an hyphenated package name using a prefix (name:) - * LP: #282995 - * Xapian currently doesn't support wildcard for boolean prefix and - * doesn't handle implicit wildcards at the end of hypenated phrases. - * - * e.g searching for name:ubuntu-res will be equivalent to 'name:ubuntu res*' - * however 'name:(ubuntu* res*) won't return any result because the - * index is built with the full package name - */ - // Always search for the package name - string xpString = "name:"; - string::size_type pos = unsplitSearchString.find_first_of(" ,;"); - if (pos > 0) { - xpString += unsplitSearchString.substr(0,pos); - } else { - xpString += unsplitSearchString; - } - Xapian::Query xpQuery = parser.parse_query(xpString); - - pos = 0; - while ( (pos = unsplitSearchString.find("-", pos)) != string::npos ) { - unsplitSearchString.replace(pos, 1, " "); - pos+=1; + _viewPackages.clear(); + + static sqlite3_stmt *selectStmt = nullptr; + + if (selectStmt == nullptr) + { + if (sqlite3_prepare_v2(_quickFilterDb, "SELECT DISTINCT name FROM fts(?)" , -1, &selectStmt, nullptr) != SQLITE_OK) + { + //fprintf(stderr, "Can't prepare the sql select statement!\n"); + selectStmt = nullptr; + return false; } - - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "searching for : " << unsplitSearchString << std::endl; + } + + sqlite3_reset(selectStmt); + + if (sqlite3_bind_text(selectStmt, 1, searchString.data(), searchString.size(), nullptr) != SQLITE_OK) + { + fprintf(stderr, "Can't bind the select statement!\n"); + return false; + } + + int rc; + while ((rc = sqlite3_step(selectStmt)) == SQLITE_ROW) + { + const char *name = (const char *) sqlite3_column_text(selectStmt, 0); + RPackage *pkg = getPackage(name); - // Build the query - // apply a weight factor to XP term to increase relevancy on package name - Xapian::Query query = parser.parse_query(unsplitSearchString, - Xapian::QueryParser::FLAG_WILDCARD | - Xapian::QueryParser::FLAG_BOOLEAN | - Xapian::QueryParser::FLAG_PARTIAL); - query = Xapian::Query(Xapian::Query::OP_OR, query, - Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, xpQuery, 3)); - enquire.set_query(query); - Xapian::MSet matches = enquire.get_mset(0, maxItems); - - if(_config->FindB("Debug::Synaptic::Xapian",false)) { - cerr << "enquire: " << enquire.get_description() << endl; - cerr << "matches estimated: " << matches.get_matches_estimated() << " results found" << endl; - } - - // Retrieve the results - int top_percent = 0; - _viewPackages.clear(); - for (Xapian::MSetIterator i = matches.begin(); i != matches.end(); ++i) + // Filter out results that apt doesn't know: + if ((pkg == nullptr) || !_selectedView->hasPackage(pkg)) { - RPackage* pkg = getPackage(i.get_document().get_data()); - // Filter out results that apt doesn't know - if (!pkg || !_selectedView->hasPackage(pkg)) - continue; + continue; + } - // Save the confidence interval of the top value, to use it as - // a reference to compute an adaptive quality cutoff - if (top_percent == 0) - top_percent = i.get_percent(); - - // Stop producing if the quality goes below a cutoff point - if (i.get_percent() < qualityCutoff * top_percent / 100) - { - cerr << "Discarding: " << i.get_percent() << " over " << qualityCutoff * top_percent / 100 << endl; - break; - } + _viewPackages.push_back(pkg); + } - if(_config->FindB("Debug::Synaptic::Xapian",false)) - cerr << i.get_rank() + 1 << ": " << i.get_percent() << "% docid=" << *i << " [" << i.get_document().get_data() << "]" << endl; - _viewPackages.push_back(pkg); - } - // re-apply sort criteria only if an explicit search is set - if (_sortMode != LIST_SORT_DEFAULT) - sortPackages(_sortMode); - return true; - } catch (const Xapian::Error & error) { - /* We are here if a Xapian call failed. The main cause is a parser exception. - * The error message is always in English currently. - * The possible parser errors are: - * Unknown range operation - * parse error - * Syntax: AND - * Syntax: AND NOT - * Syntax: NOT - * Syntax: OR - * Syntax: XOR - */ - cerr << "Exception in RPackageLister::xapianSearch():" << error.get_msg() << endl; + if (rc != SQLITE_DONE) + { + //fprintf(stderr, "The select statement finished with error!\n"); return false; } -} -#else -bool RPackageLister::limitBySearch(string searchString) -{ - return false; + + // re-apply sort criteria only if an explicit search is set + if (_sortMode != LIST_SORT_DEFAULT) sortPackages(_sortMode); + + return true; } -bool RPackageLister::xapianSearch(string searchString) -{ - return false; -} -#endif +#endif // WITH_QUICK_FILTER bool RPackageLister::isMultiarchSystem() { diff --git a/common/rpackagelister.h b/common/rpackagelister.h index 767c2b1c2..3cd0b59be 100644 --- a/common/rpackagelister.h +++ b/common/rpackagelister.h @@ -25,42 +25,40 @@ #ifndef _RPACKAGELISTER_H_ #define _RPACKAGELISTER_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "rpackagecache.h" +#include "rpackagestatus.h" + +#include +#include +#include +#include #include -#include -#include #include -#include -#include -#include +#include +#include +#include -#ifdef HAVE_XAPIAN -#include +#ifdef HAVE_RPM +#include #endif -#include "rpackagecache.h" -#include "rpackage.h" -#include "rpackagestatus.h" -#include "rpackageview.h" -#include "ruserdialog.h" +#ifdef WITH_QUICK_FILTER +#include +#endif +class FileFd; class OpProgress; -class RPackageCache; -class RPackageFilter; class RCacheActor; +class RInstallProgress; +class RPackage; +class RPackageView; class RPackageViewFilter; class RPackageViewSearch; -class pkgRecords; +class RUserDialog; class pkgAcquireStatus; -class pkgPackageManager; - - -struct RFilter; -class RPackageView; - -class RInstallProgress; +class pkgRecords; class RPackageObserver { public: @@ -93,7 +91,6 @@ class sortFunc { } }; - class RPackageLister { protected: @@ -103,10 +100,9 @@ class RPackageLister { pkgRecords *_records; OpProgress *_progMeter; -#ifdef HAVE_XAPIAN - Xapian::Database *_xapianDatabase; -#endif - + #ifdef WITH_QUICK_FILTER + sqlite3 *_quickFilterDb = nullptr; + #endif // Other members. std::vector _packages; @@ -134,12 +130,13 @@ class RPackageLister { RPackageViewFilter *_filterView; // the package view that does the filtering RPackageViewSearch *_searchView; // the package view that does the (simple) search - - // helper for the limitBySearch() code - bool xapianSearch(std::string searchString); - + public: +#ifdef WITH_QUICK_FILTER + bool applyQuickFilter(std::string searchString); +#endif + unsigned int _viewMode; typedef enum { @@ -205,8 +202,6 @@ class RPackageLister { std::list redoStack; public: - // limit what the current view displays - bool limitBySearch(std::string searchString); // clean files older than "Synaptic::delHistory" void cleanCommitLog(); @@ -344,18 +339,24 @@ class RPackageLister { bool writeSelections(std::ostream &out, bool fullState); RPackageCache* getCache() { return _cache; } -#ifdef HAVE_XAPIAN - Xapian::Database* xapiandatabase() { return _xapianDatabase; } - time_t xapianIndexTimestamp(); - bool xapianIndexNeedsUpdate(); - bool openXapianIndex(); -#endif + + #ifdef WITH_QUICK_FILTER + + // Use the sqlite based quick search feature. + + bool openQuickFilterDb(); + + static bool BeginQuickFilterDbInsertion(sqlite3 *db); + static bool EndQuickFilterDbInsertion(sqlite3 *db); + static bool AddPackageToQuickFilterDb(sqlite3 *db, const std::string_view &name, const std::string_view &description); + static bool populateQuickFilterDb(sqlite3 *db, std::vector &packages); + + #endif RPackageLister(); ~RPackageLister(); }; - #endif // vim:ts=3:sw=3:et diff --git a/common/rpackagestatus.cc b/common/rpackagestatus.cc index 6c4407d13..c8d4c269e 100644 --- a/common/rpackagestatus.cc +++ b/common/rpackagestatus.cc @@ -26,13 +26,22 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include +#include "rpackagestatus.h" #include "i18n.h" -#include "rpackagestatus.h" +#include "rpackage.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; @@ -68,7 +77,6 @@ void RPackageStatus::init() }; memcpy(PackageStatusLongString, status_long, sizeof(status_long)); - // check for unsupported stuff if(_config->FindB("Synaptic::mark-unsupported", true)) { string s, labels, origin, components; diff --git a/common/rpackagestatus.h b/common/rpackagestatus.h index 2b8636b53..268f24f2e 100644 --- a/common/rpackagestatus.h +++ b/common/rpackagestatus.h @@ -29,16 +29,12 @@ #ifndef _RPACKAGESTATUS_H_ #define _RPACKAGESTATUS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include #include -#include -#include -#include +#include -#include "rpackage.h" +class RPackage; class RPackageStatus { public: diff --git a/common/rpackageview.cc b/common/rpackageview.cc index 48e71eccd..acad04d00 100644 --- a/common/rpackageview.cc +++ b/common/rpackageview.cc @@ -22,23 +22,32 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include +#include "rpackageview.h" #include "i18n.h" -#include "rpackage.h" -#include "rpackageview.h" #include "rconfiguration.h" +#include "rpackage.h" +#include "rpackagefilter.h" +#include "sections_trans.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include -#include - -#include "sections_trans.h" +#include +#include +#include +#include using namespace std; @@ -393,7 +402,6 @@ vector RPackageViewFilter::getFilterNames() return filters; } - void RPackageViewFilter::addPackage(RPackage *pkg) { // nothing to do for now, may add some sort of caching later @@ -408,7 +416,6 @@ const set& RPackageViewFilter::getSections() return _sectionList; } - void RPackageViewFilter::storeFilters() { ofstream out; @@ -648,7 +655,6 @@ void RPackageViewOrigin::addPackage(RPackage *package) } } - void RPackageViewArchitecture::addPackage(RPackage *package) { string arch = "arch: " + package->arch(); @@ -660,6 +666,4 @@ void RPackageViewArchitecture::addPackage(RPackage *package) _view[arch].push_back(package); } - - // vim:sts=3:sw=3 diff --git a/common/rpackageview.h b/common/rpackageview.h index 442e227d3..d52067507 100644 --- a/common/rpackageview.h +++ b/common/rpackageview.h @@ -25,20 +25,19 @@ #ifndef RPACKAGEVIEW_H #define RPACKAGEVIEW_H -#include "config.h" - -#include -#include - -#ifdef HAVE_XAPIAN -#include -#endif +#include "config.h" // IWYU pragma: associated +#include "i18n.h" #include "rpackage.h" -#include "rpackagefilter.h" -#include "i18n.h" +#include +#include +#include +#include +#include +#include +class OpProgress; struct RFilter; enum {PACKAGE_VIEW_SECTION, @@ -168,10 +167,13 @@ class RPackageViewSearch : public RPackageView { std::map searchHistory; searchItem _currentSearchItem; int found; // nr of found pkgs for the last search + +public: + +#ifdef WITH_QUICK_FILTER + bool applyQuickFilter(); +#endif // WITH_QUICK_FILTER - bool xapianSearch(); - - public: RPackageViewSearch(std::vector &allPkgs) : RPackageView(allPkgs), found(0) {} diff --git a/common/rpmindexcopy.cc b/common/rpmindexcopy.cc index cd11cc2be..3278ba084 100644 --- a/common/rpmindexcopy.cc +++ b/common/rpmindexcopy.cc @@ -1,21 +1,22 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include "rpmindexcopy.h" + +#include "i18n.h" + +#include #include +#include #include #include -#include -#include -#include - -#include +#include +#include #include -#include -#include #include - -#include "rpmindexcopy.h" - -#include "i18n.h" +#include +#include +#include +#include using namespace std; diff --git a/common/rpmindexcopy.h b/common/rpmindexcopy.h index 9117a9ad8..207e8157a 100644 --- a/common/rpmindexcopy.h +++ b/common/rpmindexcopy.h @@ -1,4 +1,3 @@ - /* ###################################################################### Index Copying - Aid for copying and verifying the index files @@ -9,13 +8,10 @@ #ifndef RPMINDEXCOPY_H #define RPMINDEXCOPY_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include #include - -class pkgTagSection; -class FileFd; +#include class RPMIndexCopy { protected: diff --git a/common/rsources.cc b/common/rsources.cc index 8fa3946bb..43252f0fc 100644 --- a/common/rsources.cc +++ b/common/rsources.cc @@ -23,20 +23,26 @@ * USA */ -#include "config.h" - -#include -#include +#include "config.h" // IWYU pragma: associated #include "rsources.h" + +#include "i18n.h" + +#include #include +#include #include -#include #include -#include -#include +#include +#include +#include #include -#include "i18n.h" +#include +#include +#include +#include +#include using namespace std; @@ -217,7 +223,6 @@ bool SourcesList::ReadSourceDir(string Dir) return true; } - bool SourcesList::ReadSources() { //cout << "SourcesList::ReadSources() " << endl; diff --git a/common/rsources.h b/common/rsources.h index b17ad7ab1..4a753903d 100644 --- a/common/rsources.h +++ b/common/rsources.h @@ -26,10 +26,11 @@ #ifndef _RSOURCES_H #define _RSOURCES_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include #include +#include class SourcesList { public: diff --git a/common/rtagcollbuilder.cc b/common/rtagcollbuilder.cc index 7c6718cec..1bcdebee6 100644 --- a/common/rtagcollbuilder.cc +++ b/common/rtagcollbuilder.cc @@ -20,6 +20,6 @@ //#pragma implementation -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "rtagcollbuilder.h" +#include "rtagcollbuilder.h" // IWYU pragma: associated diff --git a/common/rtagcollbuilder.h b/common/rtagcollbuilder.h index 8b84514bf..0d3697266 100644 --- a/common/rtagcollbuilder.h +++ b/common/rtagcollbuilder.h @@ -23,7 +23,7 @@ #if 0 // PORTME -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef HAVE_DEBTAGS //#pragma interface @@ -34,6 +34,8 @@ #include "rpackage.h" #include "rpackagelister.h" +#include + // TagcollConsumer that builds a tagged collection for synaptic class RTagcollBuilder:public TagcollConsumer { protected: diff --git a/common/rtagcollfilter.cc b/common/rtagcollfilter.cc index 5d96cc7b5..ed5e03f47 100644 --- a/common/rtagcollfilter.cc +++ b/common/rtagcollfilter.cc @@ -20,6 +20,6 @@ //#pragma implementation -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "rtagcollfilter.h" +#include "rtagcollfilter.h" // IWYU pragma: associated diff --git a/common/rtagcollfilter.h b/common/rtagcollfilter.h index 7c0d18474..5b1232949 100644 --- a/common/rtagcollfilter.h +++ b/common/rtagcollfilter.h @@ -1,7 +1,7 @@ #ifndef RTAGCOLFILTER_H #define RTAGCOLFILTER_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef HAVE_DEBTAG @@ -30,7 +30,6 @@ #include #include -#include #include #include "rpackage.h" #include "rpackagelister.h" diff --git a/common/ruserdialog.cc b/common/ruserdialog.cc index 1cf0c5358..96ecb2f41 100644 --- a/common/ruserdialog.cc +++ b/common/ruserdialog.cc @@ -21,7 +21,7 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include #include diff --git a/common/ruserdialog.h b/common/ruserdialog.h index e0caaa02b..6fb67bf0c 100644 --- a/common/ruserdialog.h +++ b/common/ruserdialog.h @@ -24,7 +24,7 @@ #ifndef RUSERDIALOG_H #define RUSERDIALOG_H -#include "config.h" +#include "config.h" // IWYU pragma: associated class RUserDialog { public: diff --git a/common/sections_trans.cc b/common/sections_trans.cc index 8b287b2a1..887813fa5 100644 --- a/common/sections_trans.cc +++ b/common/sections_trans.cc @@ -3,12 +3,16 @@ * */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "sections_trans.h" #include "i18n.h" -#include "sections_trans.h" + +#include +#include +#include +#include using namespace std; diff --git a/common/sections_trans.h b/common/sections_trans.h index 7b4ab508d..75805cb4e 100644 --- a/common/sections_trans.h +++ b/common/sections_trans.h @@ -5,12 +5,9 @@ #ifndef _HAVE_SECTIONS_TRANS_H #define _HAVE_SECTIONS_TRANS_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include -#include -#include -#include std::string trans_section(std::string sec); diff --git a/configure.ac b/configure.ac index 8d5c001aa..e368f069d 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,9 @@ AM_INIT_AUTOMAKE([subdir-objects -Wno-portability]) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE +: ${CFLAGS="-O3 -flto -fuse-linker-plugin -pipe"} +: ${CXXFLAGS="-O3 -flto -fuse-linker-plugin -pipe"} + dnl Checks for programs. AC_ISC_POSIX AC_PROG_CC @@ -38,9 +41,6 @@ if test x"$GTK" = xno; then fi dnl fi - - - dnl Check for rpm version dnl ===================== rpm_version="none" @@ -111,16 +111,11 @@ AC_CHECK_HEADER(apt-pkg/metaindex.h, AC_DEFINE(WITH_APT_AUTH, 1, [build with apt # check if we have apts new-style cdrom.h AC_CHECK_HEADER(apt-pkg/cdrom.h, AC_DEFINE(HAVE_APTPKG_CDROM, 1, [whether apt-pkg/cdrom.h is present]) ) -# xapian based package search feature -AC_CHECK_PROG(HAVE_XAPIAN,xapian-config,yes,no) -AS_IF([test "x$HAVE_XAPIAN" = "xyes"],[ - XAPIAN_CXXFLAGS="$(xapian-config --cxxflags)" - XAPIAN_LIBS="$(xapian-config --libs)" - AC_DEFINE(HAVE_XAPIAN, 1, [xapian based package search feature]) - ]) - -AC_SUBST(XAPIAN_CXXFLAGS) -AC_SUBST(XAPIAN_LIBS) +# SQLITE dependencies: +AC_DEFINE(WITH_QUICK_FILTER, , [Sqlite based package quick filter feature]) +PKG_CHECK_MODULES([SQLITE], [sqlite3]) +AC_SUBST([SQLITE_CFLAGS]) +AC_SUBST([SQLITE_LIBS]) AC_LANG([C]) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index fb2c18348..022a3197a 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -7,7 +7,8 @@ AM_CPPFLAGS = -I@top_srcdir@ -I@top_srcdir@/common -I@top_srcdir@/gtk -I@top_bui @GTK_CFLAGS@ \ @VTE_CFLAGS@ \ @LP_CFLAGS@ \ - @APT_PKG_CFLAGS@ + @APT_PKG_CFLAGS@ \ + @SQLITE_CFLAGS@ bin_PROGRAMS = synaptic @@ -21,7 +22,7 @@ synaptic_LDADD = \ @VTE_LIBS@ \ @LP_LIBS@ \ @APT_PKG_LIBS@ \ - @XAPIAN_LIBS@ \ + @SQLITE_LIBS@ \ -lpthread \ -lutil \ -lX11 diff --git a/gtk/gsynaptic.cc b/gtk/gsynaptic.cc index c11a201cf..c0bb3e8b2 100644 --- a/gtk/gsynaptic.cc +++ b/gtk/gsynaptic.cc @@ -20,37 +20,41 @@ * USA */ -#include "config.h" - -#include +#include "config.h" // IWYU pragma: associated #include "i18n.h" - -#include "rconfiguration.h" #include "raptoptions.h" +#include "rconfiguration.h" +#include "rgmainwindow.h" +#include "rgpackagestatus.h" +#include "rguserdialog.h" +#include "rgutils.h" #include "rpackagelister.h" -#include +#include "rpackageview.h" + #include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include +#include +#include +#include +#include +#include #include - -#include "rgmainwindow.h" -#include "rguserdialog.h" -#include "locale.h" -#include "stdio.h" -#include "rgutils.h" -#include "rgpackagestatus.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; @@ -60,7 +64,6 @@ typedef enum { UPDATE_AUTO } UpdateType; - static gint applicationHandleLocalOptions(GApplication* app, GVariantDict* options, gpointer user_data); @@ -577,9 +580,11 @@ static void applicationActivate(GApplication* app, gpointer user_data) exit(0); } else { welcome_dialog(mainWindow); +#ifdef WITH_QUICK_FILTER gtk_widget_grab_focus( GTK_WIDGET(gtk_builder_get_object( mainWindow->getGtkBuilder(), "entry_fast_search"))); +#endif // WITH_QUICK_FILTER } } diff --git a/gtk/gtkpkglist.cc b/gtk/gtkpkglist.cc index fb1b0b18b..649ba2eec 100644 --- a/gtk/gtkpkglist.cc +++ b/gtk/gtkpkglist.cc @@ -17,18 +17,29 @@ * Boston, MA 02111-1307, USA. */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include -#include -#include #include "gtkpkglist.h" -#include "rgutils.h" + #include "rgpackagestatus.h" +#include "rgutils.h" +#include "rpackage.h" #include "rpackagelister.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace std; // #define DEBUG_LIST diff --git a/gtk/gtkpkglist.h b/gtk/gtkpkglist.h index ec50c3d16..80ddf4d36 100644 --- a/gtk/gtkpkglist.h +++ b/gtk/gtkpkglist.h @@ -20,14 +20,15 @@ #ifndef GTKPKGLIST_H #define GTKPKGLIST_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include "rpackagelister.h" #include "rcacheactor.h" -#include "rpackagelistactor.h" #include "rgutils.h" +#include "rpackagelistactor.h" +#include +#include +#include #define GTK_TYPE_PKG_LIST (gtk_pkg_list_get_type ()) #define GTK_PKG_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PKG_LIST, GtkPkgList)) @@ -36,10 +37,11 @@ #define GTK_IS_PKG_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PKG_LIST)) #define GTK_PKG_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PKG_LIST, GtkPkgListClass)) +class RPackageLister; + typedef struct _GtkPkgList GtkPkgList; typedef struct _GtkPkgListClass GtkPkgListClass; - struct _GtkPkgList { GObject parent; @@ -56,7 +58,6 @@ struct _GtkPkgListClass { GObjectClass parent_class; }; - GType gtk_pkg_list_get_type(); GtkPkgList *gtk_pkg_list_new(RPackageLister *lister); @@ -77,7 +78,6 @@ class RCacheActorPkgList : public RCacheActor { : RCacheActor(lister), _pkgList(pkgList), _pkgView(pkgView) {}; }; - class RPackageListActorPkgList:public RPackageListActor { protected: diff --git a/gtk/rgcacheprogress.cc b/gtk/rgcacheprogress.cc index d1969b084..156096266 100644 --- a/gtk/rgcacheprogress.cc +++ b/gtk/rgcacheprogress.cc @@ -20,13 +20,16 @@ * USA */ -#include "config.h" - -#include +#include "config.h" // IWYU pragma: associated #include "rgcacheprogress.h" + #include "rgutils.h" +#include +#include +#include + RGCacheProgress::RGCacheProgress(GtkWidget *parent, GtkWidget *label) : _parent(parent), _label(label) { @@ -42,13 +45,11 @@ RGCacheProgress::RGCacheProgress(GtkWidget *parent, GtkWidget *label) _mapped = false; } - RGCacheProgress::~RGCacheProgress() { //gtk_widget_destroy(_prog); } - void RGCacheProgress::Update() { if (!CheckChange()) { @@ -72,10 +73,8 @@ void RGCacheProgress::Update() (float)Percent / 100.0); RGFlushInterface(); - } - void RGCacheProgress::Done() { gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(_prog), 1.0); diff --git a/gtk/rgcacheprogress.h b/gtk/rgcacheprogress.h index eaaef552b..386bfe665 100644 --- a/gtk/rgcacheprogress.h +++ b/gtk/rgcacheprogress.h @@ -23,10 +23,9 @@ #ifndef _RGCACHEPROGRESS_H_ #define _RGCACHEPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include - #include class RGCacheProgress:public OpProgress { @@ -34,7 +33,6 @@ class RGCacheProgress:public OpProgress { GtkWidget *_label; GtkWidget *_prog; - bool _mapped; public: @@ -49,5 +47,4 @@ class RGCacheProgress:public OpProgress { virtual void Done(); }; - #endif diff --git a/gtk/rgcdscanner.cc b/gtk/rgcdscanner.cc index 7a6680d30..4fb60f12a 100644 --- a/gtk/rgcdscanner.cc +++ b/gtk/rgcdscanner.cc @@ -20,17 +20,19 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifndef HAVE_APTPKG_CDROM -#include "rgmainwindow.h" #include "rgcdscanner.h" -#include -#include - #include "i18n.h" +#include "rgmainwindow.h" + +#include +#include +#include +#include class RGDiscName:public RGGtkBuilderWindow { protected: @@ -47,7 +49,6 @@ class RGDiscName:public RGGtkBuilderWindow { bool run(string &name); }; - void RGCDScanner::update(string text, int current) { gtk_label_set_text(GTK_LABEL(_label), text.c_str()); diff --git a/gtk/rgcdscanner.h b/gtk/rgcdscanner.h index 79b13d46e..4e3694132 100644 --- a/gtk/rgcdscanner.h +++ b/gtk/rgcdscanner.h @@ -24,12 +24,19 @@ #ifndef RGCDSCANNER_H #define RGCDSCANNER_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifndef HAVE_APTPKG_CDROM #include "rcdscanner.h" -#include "rggtkbuilderwindow.h" + +#include "rgwindow.h" +#include "ruserdialog.h" + +#include +#include + +using namespace std; class RGMainWindow; diff --git a/gtk/rgchangelogdialog.cc b/gtk/rgchangelogdialog.cc index 61269b289..772e8a7b7 100644 --- a/gtk/rgchangelogdialog.cc +++ b/gtk/rgchangelogdialog.cc @@ -18,14 +18,25 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "i18n.h" #include "rgchangelogdialog.h" #include "rgfetchprogress.h" #include "rguserdialog.h" +#include "rgutils.h" +#include "rpackage.h" +#include #include +#include +#include +#include +#include +#include +#include + +class RGWindow; using namespace std; diff --git a/gtk/rgchangelogdialog.h b/gtk/rgchangelogdialog.h index 3bd2febfc..3872d04d5 100644 --- a/gtk/rgchangelogdialog.h +++ b/gtk/rgchangelogdialog.h @@ -21,10 +21,10 @@ #ifndef _GTK_RGCHANGELOGDIALOG_H #define _GTK_RGCHANGELOGDIALOG_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "rgwindow.h" -#include "rpackage.h" +class RGWindow; +class RPackage; void ShowChangelogDialog(RGWindow *me, RPackage *pkg); diff --git a/gtk/rgchangeswindow.cc b/gtk/rgchangeswindow.cc index 2de961694..674ab14a6 100644 --- a/gtk/rgchangeswindow.cc +++ b/gtk/rgchangeswindow.cc @@ -22,22 +22,24 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include - -#include -#include +#include "rgchangeswindow.h" -#include "rpackagelister.h" +#include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rpackage.h" -#include -#include #include +#include +#include +#include +#include +#include +#include -#include "rgchangeswindow.h" - -#include "i18n.h" +class RGWindow; +class RPackageLister; using namespace std; @@ -62,8 +64,6 @@ RGChangesWindow::RGChangesWindow(RGWindow *wwin) GTK_RESPONSE_OK); } - - void RGChangesWindow::confirm(RPackageLister *lister, vector &kept, vector &toInstall, diff --git a/gtk/rgchangeswindow.h b/gtk/rgchangeswindow.h index e6f521ee9..d3b893415 100644 --- a/gtk/rgchangeswindow.h +++ b/gtk/rgchangeswindow.h @@ -25,10 +25,15 @@ #ifndef _RGCHANGESWINDOW_H #define _RGCHANGESWINDOW_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +#include +#include + +class RGWindow; +class RPackage; class RPackageLister; class RGChangesWindow:public RGGtkBuilderWindow { diff --git a/gtk/rgdebinstallprogress.cc b/gtk/rgdebinstallprogress.cc index 5434d8382..af43e0a87 100644 --- a/gtk/rgdebinstallprogress.cc +++ b/gtk/rgdebinstallprogress.cc @@ -20,38 +20,48 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef WITH_DPKG_STATUSFD -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rgmainwindow.h" +#include "i18n.h" #include "rgdebinstallprogress.h" +#include "rggtkbuilderwindow.h" +#include "rgmainwindow.h" #include "rguserdialog.h" - +#include "rgutils.h" +#include "rinstallprogress.h" +#include "rpackagelister.h" #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include - #include -#include -#include - -#include "i18n.h" using namespace std; @@ -96,8 +106,6 @@ write_fd(int fd, void *ptr, size_t nbytes, int sendfd) return(sendmsg(fd, &msg, 0)); } - - ssize_t read_fd(int fd, void *ptr, size_t nbytes, int *recvfd) { @@ -204,7 +212,6 @@ int ipc_recv_fd() return fd; } - void RGDebInstallProgress::conffile(gchar *conffile, gchar *status) { string primary, secondary; @@ -301,10 +308,8 @@ void RGDebInstallProgress::cbCancel(GtkWidget *self, void *data) //kill(me->_child_id, SIGQUIT); kill(me->_child_id, SIGTERM); //kill(me->_child_id, SIGKILL); - } - void RGDebInstallProgress::cbClose(GtkWidget *self, void *data) { //cout << "cbCancel: sending SIGKILL to child" << endl; @@ -824,5 +829,4 @@ void RGDebInstallProgress::prepare(RPackageLister *lister) } -#endif - +#endif // WITH_DPKG_STATUSFD diff --git a/gtk/rgdebinstallprogress.h b/gtk/rgdebinstallprogress.h index 11e612e46..b9df27e38 100644 --- a/gtk/rgdebinstallprogress.h +++ b/gtk/rgdebinstallprogress.h @@ -23,19 +23,27 @@ #ifndef _RGDEBINSTALLPROGRESS_H_ #define _RGDEBINSTALLPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef WITH_DPKG_STATUSFD -#include "rinstallprogress.h" #include "rggtkbuilderwindow.h" -#include "rguserdialog.h" -#include -#include +#include "rinstallprogress.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include class RGMainWindow; - +class RGUserDialog; +class RPackageLister; class RGDebInstallProgress:public RInstallProgress, public RGGtkBuilderWindow { @@ -71,7 +79,6 @@ class RGDebInstallProgress:public RInstallProgress, public RGGtkBuilderWindow static char *reinstall_stages[NR_REINSTALL_STAGES]; static char *reinstall_stages_translations[NR_REINSTALL_STAGES]; - // widgets GtkWidget *_label_status; GtkWidget *_labelSummary; @@ -146,6 +153,6 @@ class RGDebInstallProgress:public RInstallProgress, public RGGtkBuilderWindow }; -#endif +#endif // WITH_DPKG_STATUSFD #endif diff --git a/gtk/rgdummyinstallprogress.cc b/gtk/rgdummyinstallprogress.cc index 39e86d7de..d0aabbcc6 100644 --- a/gtk/rgdummyinstallprogress.cc +++ b/gtk/rgdummyinstallprogress.cc @@ -20,20 +20,20 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rgdummyinstallprogress.h" + #include "rgutils.h" +#include #include -#include void RGDummyInstallProgress::startUpdate() { RGFlushInterface(); } - void RGDummyInstallProgress::finishUpdate() { RGFlushInterface(); diff --git a/gtk/rgdummyinstallprogress.h b/gtk/rgdummyinstallprogress.h index e91678944..fbe6301aa 100644 --- a/gtk/rgdummyinstallprogress.h +++ b/gtk/rgdummyinstallprogress.h @@ -23,11 +23,9 @@ #ifndef _RGDUMMYINSTALLPROGRESS_H_ #define _RGDUMMYINSTALLPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rinstallprogress.h" -#include "rgwindow.h" - class RGDummyInstallProgress:public RInstallProgress { protected: diff --git a/gtk/rgfetchprogress.cc b/gtk/rgfetchprogress.cc index 7f8410aae..2d5a917f6 100644 --- a/gtk/rgfetchprogress.cc +++ b/gtk/rgfetchprogress.cc @@ -22,25 +22,30 @@ * USA */ -#include "config.h" - -#include -#include -#include -#include -#include -#include +#include "config.h" // IWYU pragma: associated #include "rgfetchprogress.h" + +#include "i18n.h" +#include "rggtkbuilderwindow.h" #include "rguserdialog.h" #include "rgutils.h" -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include -#include "i18n.h" +class RGWindow; using namespace std; @@ -160,7 +165,6 @@ void RGFetchProgress::expanderActivate(GObject *object, gtk_window_set_resizable(GTK_WINDOW(win), FALSE); } - void RGFetchProgress::cursorChanged(GtkTreeView *self, void *data) { //cout << "cursor-changed" << endl; @@ -198,8 +202,6 @@ bool RGFetchProgress::MediaChange(string Media, string Drive) g_free(msg); return true; - - #if 0 // this code can be used when apt fixed ubuntu #2281 (patch pending) bool res = !userDialog.proceed(msg); //cout << "Media change " << res << endl; @@ -216,7 +218,6 @@ bool RGFetchProgress::MediaChange(string Media, string Drive) #endif } - void RGFetchProgress::updateStatus(pkgAcquire::ItemDesc & Itm, int status) { //cout << "void RGFetchProgress::updateStatus()" << endl; @@ -236,7 +237,6 @@ void RGFetchProgress::updateStatus(pkgAcquire::ItemDesc & Itm, int status) } } - void RGFetchProgress::IMSHit(pkgAcquire::ItemDesc & Itm) { //cout << "void RGFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm)" << endl; @@ -261,7 +261,6 @@ void RGFetchProgress::Done(pkgAcquire::ItemDesc &Itm) RGFlushInterface(); } - void RGFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) { if (Itm.Owner->Status == pkgAcquire::Item::StatIdle) @@ -272,7 +271,6 @@ void RGFetchProgress::Fail(pkgAcquire::ItemDesc &Itm) RGFlushInterface(); } - bool RGFetchProgress::Pulse(pkgAcquire *Owner) { //cout << "RGFetchProgress::Pulse(pkgAcquire *Owner)" << endl; @@ -353,7 +351,6 @@ bool RGFetchProgress::Pulse(pkgAcquire *Owner) return !_cancelled; } - void RGFetchProgress::Start() { //cout << "RGFetchProgress::Start()" << endl; @@ -363,7 +360,6 @@ void RGFetchProgress::Start() RGFlushInterface(); } - void RGFetchProgress::Stop() { //cout << "RGFetchProgress::Stop()" << endl; @@ -377,8 +373,6 @@ void RGFetchProgress::Stop() RGFlushInterface(); } - - void RGFetchProgress::stopDownload(GtkWidget *self, void *data) { RGFetchProgress *me = (RGFetchProgress *) data; @@ -386,7 +380,6 @@ void RGFetchProgress::stopDownload(GtkWidget *self, void *data) me->_cancelled = true; } - char* RGFetchProgress::getStatusStr(int status) { // special status @@ -425,7 +418,6 @@ int RGFetchProgress::getStatusPercent(int status) return status; } - void RGFetchProgress::refreshTable(int row, bool append) { //cout << "RGFetchProgress::refreshTable() " << row << endl; diff --git a/gtk/rgfetchprogress.h b/gtk/rgfetchprogress.h index 0be554815..19d3cf1ab 100644 --- a/gtk/rgfetchprogress.h +++ b/gtk/rgfetchprogress.h @@ -23,13 +23,19 @@ #ifndef _RGFETCHPROGRESS_H_ #define _RGFETCHPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "rggtkbuilderwindow.h" -#include +#include +#include +#include +#include #include -#include "rggtkbuilderwindow.h" +#include +#include + +class RGWindow; class RGFetchProgress : public pkgAcquireStatus, public RGGtkBuilderWindow { diff --git a/gtk/rgfiltermanager.cc b/gtk/rgfiltermanager.cc index 6f6f3824d..ae9df481d 100644 --- a/gtk/rgfiltermanager.cc +++ b/gtk/rgfiltermanager.cc @@ -22,15 +22,27 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include -#include "rpackageview.h" #include "rgfiltermanager.h" #include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rgutils.h" +#include "rgwindow.h" +#include "rpackagefilter.h" +#include "rpackageview.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; @@ -295,7 +307,6 @@ void RGFilterManagerWindow::statusInvertClicked(GObject *o, gpointer data) } } - void RGFilterManagerWindow::statusAllClicked(GObject *o, gpointer data) { RGFilterManagerWindow *me = (RGFilterManagerWindow *) data; @@ -315,15 +326,12 @@ void RGFilterManagerWindow::statusNoneClicked(GObject *o, gpointer data) } } - void RGFilterManagerWindow::patternNew(GObject *o, gpointer data) { //cout << "void RGFilterManagerWindow::patternNew()" << endl; RGFilterManagerWindow *me = (RGFilterManagerWindow *) data; me->setPatternRow(-1, false, (RPatternPackageFilter::DepType) 0, ""); - - } void RGFilterManagerWindow::patternDelete(GObject *o, gpointer data) @@ -341,7 +349,6 @@ void RGFilterManagerWindow::patternDelete(GObject *o, gpointer data) } } - void RGFilterManagerWindow::patternChanged(GObject *o, gpointer data) { RPatternPackageFilter::DepType type; @@ -447,7 +454,6 @@ gint RGFilterManagerWindow::deleteEventAction(GtkWidget *widget, return (TRUE); } - void RGFilterManagerWindow::readFilters() { _selectedFilter = NULL; @@ -490,7 +496,6 @@ void RGFilterManagerWindow::readFilters() RGWindow::show(); } - void RGFilterManagerWindow::selectAction(GtkTreeSelection *selection, gpointer data) { @@ -532,7 +537,6 @@ void RGFilterManagerWindow::selectAction(GtkTreeSelection *selection, } } - // mvo: helper function GtkTreePath *RGFilterManagerWindow::treeview_find_path_from_text(GtkTreeModel * model, @@ -561,7 +565,6 @@ GtkTreePath *RGFilterManagerWindow::treeview_find_path_from_text(GtkTreeModel * return NULL; } - void RGFilterManagerWindow::setSectionFilter(RSectionPackageFilter & f) { //cout << "RGFilterEditor::setSectionFilter()"<pattern); } - void RGFilterManagerWindow::applyChanges(RFilter *filter) { getSectionFilter(filter->section); @@ -792,7 +790,6 @@ void RGFilterManagerWindow::applyChanges(RFilter *filter) getPatternFilter(filter->pattern); } - void RGFilterManagerWindow::addFilterAction(GtkWidget *self, void *data) { RGFilterManagerWindow *me = (RGFilterManagerWindow *) data; @@ -826,8 +823,6 @@ void RGFilterManagerWindow::addFilterAction(GtkWidget *self, void *data) me->editFilter(); } - - void RGFilterManagerWindow::applyFilterAction(GtkWidget *self, void *data) { @@ -854,8 +849,6 @@ void RGFilterManagerWindow::applyFilterAction(GtkWidget *self, void *data) me->applyChanges(filter); } - - void RGFilterManagerWindow::removeFilterAction(GtkWidget *self, void *data) { RGFilterManagerWindow *me = (RGFilterManagerWindow *) data; @@ -879,8 +872,6 @@ void RGFilterManagerWindow::removeFilterAction(GtkWidget *self, void *data) } } - - void RGFilterManagerWindow::cancelAction(GtkWidget *self, void *data) { unsigned int i; @@ -915,9 +906,3 @@ void RGFilterManagerWindow::okAction(GtkWidget *self, void *data) me->_filterview->storeFilters(); me->close(); } - - - - - - diff --git a/gtk/rgfiltermanager.h b/gtk/rgfiltermanager.h index de6bb1cde..458017c20 100644 --- a/gtk/rgfiltermanager.h +++ b/gtk/rgfiltermanager.h @@ -25,17 +25,22 @@ #ifndef _RGFILTERMANAGER_H_ #define _RGFILTERMANAGER_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "i18n.h" #include "rggtkbuilderwindow.h" #include "rpackagefilter.h" -#include "rgutils.h" -#include "i18n.h" +#include +#include +#include +#include +#include +#include +#include +class RGWindow; class RPackageViewFilter; -class RGFilterManagerWindow; // must be in the same order as of the check buttons static const RStatusPackageFilter::Types StatusMasks[] = { @@ -66,7 +71,6 @@ static char *ActOptions[] = { NULL }; - static char *DepOptions[] = { _("Package name"), _("Description"), @@ -84,8 +88,6 @@ static char *DepOptions[] = { NULL }; - - typedef void RGFilterEditorCloseAction(void *self, bool okcancel); class RGFilterManagerWindow:public RGGtkBuilderWindow { @@ -211,5 +213,4 @@ class RGFilterManagerWindow:public RGGtkBuilderWindow { }; - #endif diff --git a/gtk/rgfindwindow.cc b/gtk/rgfindwindow.cc index 6880661d4..0c58146ed 100644 --- a/gtk/rgfindwindow.cc +++ b/gtk/rgfindwindow.cc @@ -20,15 +20,23 @@ * USA */ -#include "config.h" - -#include -#include +#include "config.h" // IWYU pragma: associated #include "rgfindwindow.h" -#include "rgutils.h" + #include "i18n.h" +#include "rggtkbuilderwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include + +class RGWindow; gchar* RGFindWindow::getFindString() { @@ -51,7 +59,6 @@ int RGFindWindow::getSearchType() return searchType; } - void RGFindWindow::doFind(GtkWindow *widget, void *data) { //cout << "RGFindWindow::doFind()"<_findB, FALSE); } - RGFindWindow::RGFindWindow(RGWindow *win) : RGGtkBuilderWindow(win, "find"), _prevSearches(0) { diff --git a/gtk/rgfindwindow.h b/gtk/rgfindwindow.h index 2ab514d89..ae22687ab 100644 --- a/gtk/rgfindwindow.h +++ b/gtk/rgfindwindow.h @@ -23,13 +23,17 @@ #ifndef _GTK_RGFINDWINDOW_H #define _GTK_RGFINDWINDOW_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "i18n.h" #include "rggtkbuilderwindow.h" -#include "rpackagefilter.h" + +#include +#include +#include class RGFindWindow; +class RGWindow; typedef void RGFindWindowFindAction(void *self, RGFindWindow * win); diff --git a/gtk/rggtkbuilderwindow.cc b/gtk/rggtkbuilderwindow.cc index 882b1ccef..a06703100 100644 --- a/gtk/rggtkbuilderwindow.cc +++ b/gtk/rggtkbuilderwindow.cc @@ -20,16 +20,28 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include +#include "rggtkbuilderwindow.h" -#include +#include "i18n.h" +#include "rgutils.h" +#include "rgwindow.h" +#include +#include #include -#include "i18n.h" -#include "rggtkbuilderwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; @@ -161,47 +173,34 @@ bool RGGtkBuilderWindow::setLabel(const char *widget_name, const long value) return true; } -bool RGGtkBuilderWindow::setTreeList(const char *widget_name, vector values, - bool use_markup) +bool RGGtkBuilderWindow::setTreeList(const char *widget_name, vector values, bool use_markup) { - const char *type; - string strVal; GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (_builder, widget_name)); if (widget == NULL) { cout << "widget == NULL with: " << widget_name << endl; return false; } + // create column (if needed) - if(gtk_tree_view_get_column(GTK_TREE_VIEW(widget), 0) == NULL) { - - // cell renderer - GtkCellRenderer *renderer; - renderer = gtk_cell_renderer_text_new(); - - if(use_markup) - type = "markup"; - else - type = "text"; - GtkTreeViewColumn *column; - column = gtk_tree_view_column_new_with_attributes("SubView", - renderer, - type, 0, - NULL); + if (gtk_tree_view_get_column(GTK_TREE_VIEW(widget), 0) == NULL) { + GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); // cell renderer + const char *type = use_markup ? "markup" : "text"; + GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("SubView", renderer, type, 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(widget), column); } // store stuff GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING); GtkTreeIter iter; - for(unsigned int i=0;i +#include #include #include -#include #include -#include "rgwindow.h" -#include "rgutils.h" - class RGGtkBuilderWindow:public RGWindow { protected: GtkBuilder *_builder; diff --git a/gtk/rgiconlegend.cc b/gtk/rgiconlegend.cc index d75102881..c92e5fd9c 100644 --- a/gtk/rgiconlegend.cc +++ b/gtk/rgiconlegend.cc @@ -20,14 +20,25 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include #include "rgiconlegend.h" -#include "rgutils.h" -#include "rgpackagestatus.h" #include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rgpackagestatus.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class RGWindow; static void closeWindow(GtkWidget *self, void *data) { @@ -36,7 +47,6 @@ static void closeWindow(GtkWidget *self, void *data) me->hide(); } - RGIconLegendPanel::RGIconLegendPanel(RGWindow *parent) : RGGtkBuilderWindow(parent, "iconlegend") { @@ -61,7 +71,6 @@ RGIconLegendPanel::RGIconLegendPanel(RGWindow *parent) gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); } - // package support status hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); GtkIconTheme *theme; diff --git a/gtk/rgiconlegend.h b/gtk/rgiconlegend.h index a76ed3074..5d1dc8395 100644 --- a/gtk/rgiconlegend.h +++ b/gtk/rgiconlegend.h @@ -23,10 +23,11 @@ #ifndef _RGICONLEGEND_H_ #define _RGICONLEGEND_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +class RGWindow; class RGIconLegendPanel:public RGGtkBuilderWindow { public: @@ -34,5 +35,4 @@ class RGIconLegendPanel:public RGGtkBuilderWindow { virtual ~RGIconLegendPanel() {}; }; - #endif diff --git a/gtk/rginstallprogress.cc b/gtk/rginstallprogress.cc index cdbe01f31..fb46e086f 100644 --- a/gtk/rginstallprogress.cc +++ b/gtk/rginstallprogress.cc @@ -20,21 +20,35 @@ * USA */ -#include "config.h" - -#include "rgmainwindow.h" +#include "config.h" // IWYU pragma: associated #include "rginstallprogress.h" +#include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rgmainwindow.h" +#include "rgslideshow.h" +#include "rgutils.h" +#include "rinstallprogress.h" +#include "rpackage.h" +#include "rpackagelister.h" + #include +#include +#include +#include +#include +#include #include - +#include +#include +#include +#include +#include #include -#include -#include -#include +#include -#include "i18n.h" +class RGWindow; using namespace std; diff --git a/gtk/rginstallprogress.h b/gtk/rginstallprogress.h index bddc7a392..77f7f129c 100644 --- a/gtk/rginstallprogress.h +++ b/gtk/rginstallprogress.h @@ -23,13 +23,20 @@ #ifndef _RGINSTALLPROGRESS_H_ #define _RGINSTALLPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "rinstallprogress.h" #include "rggtkbuilderwindow.h" -#include "rgslideshow.h" +#include "rinstallprogress.h" + +#include +#include +#include +#include class RGMainWindow; +class RGSlideShow; +class RGWindow; +class RPackageLister; class RGInstallProgressMsgs:public RGGtkBuilderWindow { diff --git a/gtk/rglogview.cc b/gtk/rglogview.cc index 93b87a5c1..8cdcce703 100644 --- a/gtk/rglogview.cc +++ b/gtk/rglogview.cc @@ -20,19 +20,29 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include "rglogview.h" + +#include "i18n.h" +#include "rconfiguration.h" +#include "rggtkbuilderwindow.h" +#include "rgutils.h" +#include "rgwindow.h" + +#include #include +#include #include +#include +#include +#include +#include +#include +#include #include +#include #include -#include - -#include "rglogview.h" -#include "rgutils.h" -#include "rconfiguration.h" - -#include "i18n.h" using namespace std; diff --git a/gtk/rglogview.h b/gtk/rglogview.h index ab15f9b22..c5f3233eb 100644 --- a/gtk/rglogview.h +++ b/gtk/rglogview.h @@ -23,10 +23,15 @@ #ifndef _RGLOGVIEW_H_ #define _RGLOGVIEW_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +#include +#include +#include + +class RGWindow; class RGLogView : public RGGtkBuilderWindow { protected: diff --git a/gtk/rgmainwindow.cc b/gtk/rgmainwindow.cc index 1191dbeb3..ce84652fc 100644 --- a/gtk/rgmainwindow.cc +++ b/gtk/rgmainwindow.cc @@ -24,62 +24,78 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include +#include "rgmainwindow.h" +#include "gtkpkglist.h" +#include "i18n.h" #include "raptoptions.h" #include "rconfiguration.h" -#include "rgmainwindow.h" -#include "rgfindwindow.h" -#include "rgfiltermanager.h" -#include "rpackagefilter.h" -#include "raptoptions.h" - -#include "rgrepositorywin.h" -#include "rgpreferenceswindow.h" -#include "rgsummarywindow.h" -#include "rgchangeswindow.h" -#include "rgcdscanner.h" -#include "rgpkgcdrom.h" -#include "rgsetoptwindow.h" +#include "rgcacheprogress.h" #include "rgchangelogdialog.h" +#include "rgchangeswindow.h" +#include "rgdebinstallprogress.h" #include "rgfetchprogress.h" +#include "rgfiltermanager.h" +#include "rgfindwindow.h" +#include "rggtkbuilderwindow.h" +#include "rgiconlegend.h" +#include "rglogview.h" +#include "rgpkgcdrom.h" #include "rgpkgdetails.h" -#include "rgcacheprogress.h" -#include "rguserdialog.h" -#include "rginstallprogress.h" -#include "rgdummyinstallprogress.h" -#include "rgdebinstallprogress.h" +#include "rgpkgtreeview.h" +#include "rgpreferenceswindow.h" +#include "rgrepositorywin.h" +#include "rgsetoptwindow.h" +#include "rgsummarywindow.h" +#include "rgtaskswin.h" #include "rgterminstallprogress.h" +#include "rguserdialog.h" #include "rgutils.h" -#include "sections_trans.h" -#include "rgpkgtreeview.h" +#include "rgwindow.h" +#include "rinstallprogress.h" +#include "rpackage.h" +#include "rpackagecache.h" +#include "rpackagelister.h" +#include "rpackageview.h" -#include "i18n.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // include it here because depcache.h hates us if we have it before #include @@ -215,7 +231,6 @@ void RGMainWindow::refreshSubViewList() } } - RPackage *RGMainWindow::selectedPackage() { if (_pkgList == NULL) @@ -274,7 +289,6 @@ string RGMainWindow::selectedSubView() return ret; } - bool RGMainWindow::showErrors() { return _userDialog->showErrors(); @@ -309,13 +323,15 @@ void RGMainWindow::refreshTable(RPackage *selectedPkg, bool setAdjustment) ioprintf(clog, "RGMainWindow::refreshTable(): pkg: '%s' adjust '%i'\n", selectedPkg != NULL ? selectedPkg->name() : "(no pkg)", setAdjustment); - + +#ifdef WITH_QUICK_FILTER const gchar *str = gtk_entry_get_text(GTK_ENTRY(_entry_fast_search)); if(str != NULL && strlen(str) > 1) { if(_config->FindB("Debug::Synaptic::View",false)) - cerr << "RGMainWindow::refreshTable: rerun limitBySearch" << endl; - _lister->limitBySearch(str); + cerr << "RGMainWindow::refreshTable: rerun doQuickSearch" << endl; + _lister->applyQuickFilter(str); } +#endif // WITH_QUICK_FILTER if(_pkgList == NULL) { @@ -884,6 +900,7 @@ RGMainWindow::RGMainWindow(GtkApplication *app, RPackageLister *packLister, stri { "icon-legend", cbShowIconLegendPanel }, { "about", cbShowAboutPanel } }; + GSimpleActionGroup *group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), this); gtk_widget_insert_action_group (GTK_WIDGET(_win), "win", G_ACTION_GROUP(group)); @@ -953,88 +970,12 @@ RGMainWindow::RGMainWindow(GtkApplication *app, RPackageLister *packLister, stri } g_value_unset(&value); - xapianDoIndexUpdate(this); - // apply the proxy settings RGPreferencesWindow::applyProxySettings(); } -#ifdef HAVE_XAPIAN -gboolean RGMainWindow::xapianDoIndexUpdate(void *data) -{ - RGMainWindow *me = (RGMainWindow *) data; - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "xapianDoIndexUpdate()" << std::endl; - - // no need to update if we run non-interactive - if(_config->FindB("Volatile::Non-Interactive", false) == true) - return false; - - // check if we need a update - if(!me->_lister->xapianIndexNeedsUpdate()) { - // if the cache is not open, check back when it is - if (me->_lister->packagesSize() == 0) - g_timeout_add_seconds(30, xapianDoIndexUpdate, me); - return false; - } - - // do not run if we don't have it - if(!FileExists("/usr/sbin/update-apt-xapian-index")) - return false; - // no permission - if (getuid() != 0) - return false; - - // if we make it to this point, we need a xapian update - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "running update-apt-xapian-index" << std::endl; - GPid pid; - const char *argp[] = {"/usr/bin/nice", - "/usr/bin/ionice","-c3", - "/usr/sbin/update-apt-xapian-index", - "--update", "-q", - NULL}; - if(g_spawn_async(NULL, const_cast(argp), NULL, - (GSpawnFlags)(G_SPAWN_DO_NOT_REAP_CHILD), - NULL, NULL, &pid, NULL)) { - g_child_watch_add(pid, (GChildWatchFunc)xapianIndexUpdateFinished, me); - gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(me->_builder, - "label_fast_search")), - _("Rebuilding search index")); - gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object - (me->_builder, "toolbar_filter")), FALSE); - - } - return false; -} -#else -gboolean RGMainWindow::xapianDoIndexUpdate(void *data) -{ - return false; -} -#endif - -void RGMainWindow::xapianIndexUpdateFinished(GPid pid, gint status, void* data) -{ - RGMainWindow *me = (RGMainWindow *) data; - if(_config->FindB("Debug::Synaptic::Xapian",false)) - std::cerr << "xapianIndexUpdateFinished: " - << WEXITSTATUS(status) << std::endl; -#ifdef HAVE_XAPIAN - me->_lister->openXapianIndex(); -#endif - gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(me->_builder, - "label_fast_search")), - _("Quick filter")); - gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object - (me->_builder, "toolbar_filter")), TRUE); - g_spawn_close_pid(pid); -} - - void RGMainWindow::buildTreeView() { - // remove old tree columns if (_treeView) { // unset model fist, otherwise the _remove_column takes *ages* @@ -1057,7 +998,6 @@ void RGMainWindow::buildTreeView() setupTreeView(_treeView); _pkgList = GTK_TREE_MODEL(gtk_pkg_list_new(_lister)); gtk_tree_view_set_model(GTK_TREE_VIEW(_treeView), _pkgList); - } void RGMainWindow::buildInterface() @@ -1091,10 +1031,12 @@ void RGMainWindow::buildInterface() G_MENU_MODEL(gtk_builder_get_object(_builder, "main_menu")), nullptr, false); - + +#ifdef WITH_QUICK_FILTER g_signal_connect(gtk_builder_get_object(_builder, "entry_fast_search"), "changed", G_CALLBACK(cbSearchEntryChanged), this); +#endif // WITH_QUICK_FILTER if (_config->FindB("Synaptic::NoUpgradeButtons", false) == true) { setActionEnabled("mark-all-upgrades", false); // TODO: hide? @@ -1283,18 +1225,11 @@ void RGMainWindow::buildInterface() GtkBindingSet *binding_set = gtk_binding_set_find("GtkTreeView"); gtk_binding_entry_add_signal(binding_set, GDK_s, GDK_CONTROL_MASK, "start_interactive_search", 0); - + +#ifdef WITH_QUICK_FILTER _entry_fast_search = GTK_WIDGET(gtk_builder_get_object (_builder, "entry_fast_search")); - - // only enable fast search if its usable -#ifdef HAVE_XAPIAN - if(!FileExists("/usr/sbin/update-apt-xapian-index")) -#endif - { - gtk_widget_hide(GTK_WIDGET( - gtk_builder_get_object(_builder, "toolbar_filter"))); - } +#endif // WITH_QUICK_FILTER // stuff for the non-root mode if(getuid() != 0) { @@ -1710,7 +1645,6 @@ void RGMainWindow::cbChangelogDialog(GSimpleAction *action, me->setInterfaceLocked(FALSE); } - void RGMainWindow::cbPackageListRowActivated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *arg2, @@ -1792,8 +1726,6 @@ void RGMainWindow::cbAddCDROM(GSimpleAction *action, me->setInterfaceLocked(FALSE); } - - void RGMainWindow::cbTasksClicked(GSimpleAction *action, GVariant *parameter, gpointer data) @@ -2155,10 +2087,12 @@ void RGMainWindow::cbFindToolClicked(GSimpleAction *action, me->_findWin->selectText(); int res = gtk_dialog_run(GTK_DIALOG(me->_findWin->window())); if (res == GTK_RESPONSE_OK) { - + +#ifdef WITH_QUICK_FILTER // clear the quick search, otherwise both apply and that is // confusing gtk_entry_set_text(GTK_ENTRY(me->_entry_fast_search), ""); +#endif // WITH_QUICK_FILTER string str = me->_findWin->getFindString(); me->setBusyCursor(true); @@ -2247,7 +2181,6 @@ void RGMainWindow::cbViewLogClicked(GSimpleAction *action, me->_logView->show(); } - void RGMainWindow::cbHelpAction(GSimpleAction *action, GVariant *parameter, gpointer data) @@ -2702,7 +2635,9 @@ void RGMainWindow::cbShowWelcomeDialog(GSimpleAction *action, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cb))); } -gboolean RGMainWindow::xapianDoSearch(void *data) +#ifdef WITH_QUICK_FILTER + +gboolean RGMainWindow::applyQuickFilter(void *data) { RGMainWindow *me = (RGMainWindow *) data; const gchar *str = gtk_entry_get_text(GTK_ENTRY(me->_entry_fast_search)); @@ -2711,7 +2646,7 @@ gboolean RGMainWindow::xapianDoSearch(void *data) me->_fastSearchEventID = -1; me->setBusyCursor(true); RGFlushInterface(); - if(str == NULL || strlen(str) <= 1) { + if (str == NULL || strlen(str) <= 1) { // reset the color gtk_style_context_remove_provider(styleContext, GTK_STYLE_PROVIDER(_fastSearchCssProvider)); // if the user has cleared the search, refresh the view @@ -2721,7 +2656,7 @@ gboolean RGMainWindow::xapianDoSearch(void *data) me->_lister->reapplyFilter(); me->refreshTable(); me->setBusyCursor(false); - } else if(strlen(str) > 1) { + } else if (strlen(str) > 1) { // only search when there is more than one char entered, single // char searches tend to be very slow me->setBusyCursor(true); @@ -2738,17 +2673,21 @@ gboolean RGMainWindow::xapianDoSearch(void *data) return FALSE; } -void RGMainWindow::cbSearchEntryChanged(GtkWidget *edit, void *data) +void RGMainWindow::cbSearchEntryChanged(GtkWidget *, void *data) { //cerr << "RGMainWindow::cbSearchEntryChanged()" << endl; RGMainWindow *me = (RGMainWindow *) data; - if(me->_fastSearchEventID > 0) { + if (me->_fastSearchEventID > 0) { g_source_remove(me->_fastSearchEventID); me->_fastSearchEventID = -1; } - me->_fastSearchEventID = g_timeout_add(500, xapianDoSearch, me); + + // Start the search task after a (500ms) timeout. + me->_fastSearchEventID = g_timeout_add(500, applyQuickFilter, me); } +#endif // WITH_QUICK_FILTER + void RGMainWindow::cbUpdateClicked(GSimpleAction *action, GVariant *parameter, gpointer data) @@ -2816,10 +2755,7 @@ void RGMainWindow::cbUpdateClicked(GSimpleAction *action, me->_lister->readSelections(in); unlink(file); g_free((void *)file); - - // check if the index needs to be rebuild - me->xapianDoIndexUpdate(me); - + me->setTreeLocked(FALSE); me->refreshTable(); me->refreshSubViewList(); diff --git a/gtk/rgmainwindow.h b/gtk/rgmainwindow.h index 1dd8505cc..79555beb2 100644 --- a/gtk/rgmainwindow.h +++ b/gtk/rgmainwindow.h @@ -26,22 +26,23 @@ #ifndef _RGMAINWINDOW_H_ #define _RGMAINWINDOW_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include "rggtkbuilderwindow.h" #include "rpackagelister.h" - +#include "rpackageview.h" + +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include -#include - -#include "rgtaskswin.h" -#include "rgfetchprogress.h" -#include "rinstallprogress.h" -#include "rggtkbuilderwindow.h" -#include "rgiconlegend.h" -#include "gtkpkglist.h" -#include "rgpkgdetails.h" -#include "rglogview.h" typedef enum { RG_TOOLBAR_HIDE = -1, @@ -51,16 +52,21 @@ typedef enum { RG_TOOLBAR_BOTH_HORIZ = 3 } RGToolbarStyle; -class RGSourcesWindow; -class RGPreferencesWindow; +class RGAboutPanel; +class RGFetchProgress; class RGFilterManagerWindow; class RGFilterWindow; class RGFindWindow; +class RGIconLegendPanel; +class RGLogView; +class RGPkgDetailsWindow; +class RGPreferencesWindow; class RGSetOptWindow; -class RGAboutPanel; - +class RGSourcesWindow; +class RGTasksWin; class RGUserDialog; -class RGCacheProgress; +class RGWindow; +class RPackage; typedef enum { PKG_KEEP, @@ -82,7 +88,6 @@ class RGMainWindow : public RGGtkBuilderWindow, public RPackageObserver { UPGRADE_DIST = 1 } UpgradeType; - bool _unsavedChanges; bool _blockActions; // block signals from the action and hold buttons int _interfaceLocked; @@ -116,11 +121,13 @@ class RGMainWindow : public RGGtkBuilderWindow, public RPackageObserver { RGUserDialog *_userDialog; RGFetchProgress *_fetchProgress; RGWindow *_installProgress; - + +#ifdef WITH_QUICK_FILTER // fast search stuff int _fastSearchEventID; GtkWidget *_entry_fast_search; static GtkCssProvider *_fastSearchCssProvider; +#endif // WITH_QUICK_FILTER // the buttons for the various views GtkWidget *_viewButtons[N_PACKAGE_VIEWS]; @@ -131,9 +138,11 @@ class RGMainWindow : public RGGtkBuilderWindow, public RPackageObserver { bool isActionEnabled(const char *action_name); void setActionEnabled(const char *action_name, bool enabled); void setActionState(const char *action_name, GVariant *value); + void setActionStateBool(const char *action_name, bool value) { setActionState(action_name, g_variant_new_boolean(value)); } + void setActionStateInt(const char *action_name, int value) { setActionState(action_name, g_variant_new_int32(value)); } @@ -183,16 +192,12 @@ class RGMainWindow : public RGGtkBuilderWindow, public RPackageObserver { // helpers for search-as-you-type static void cbSearchEntryChanged(GtkWidget *editable, void *data); - static void xapianIndexUpdateFinished(GPid pid, gint status, void* data); - static gboolean xapianDoSearch(void *data); - static gboolean xapianDoIndexUpdate(void *data); + static gboolean applyQuickFilter(void *data); // RPackageObserver virtual void notifyChange(RPackage *pkg); - virtual void notifyPreFilteredChange() { - }; - virtual void notifyPostFilteredChange() { - }; + virtual void notifyPreFilteredChange() {} + virtual void notifyPostFilteredChange() {} public: RGMainWindow(GtkApplication *app, RPackageLister *packLister, std::string name); diff --git a/gtk/rgpackagestatus.cc b/gtk/rgpackagestatus.cc index 1e2e3ad46..8f962441d 100644 --- a/gtk/rgpackagestatus.cc +++ b/gtk/rgpackagestatus.cc @@ -20,16 +20,21 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include -#include -#include +#include "rgpackagestatus.h" #include "rgutils.h" -#include "rgpackagestatus.h" +#include "rpackagestatus.h" + +#include +#include +#include +#include +#include +#include + +class RPackage; // RPackageStatus stuff RGPackageStatus RGPackageStatus::pkgStatus; @@ -84,7 +89,6 @@ void RGPackageStatus::init() initPixbufs(); } - GdkRGBA *RGPackageStatus::getBgColor(RPackage *pkg) { return StatusColors[getStatus(pkg)]; diff --git a/gtk/rgpackagestatus.h b/gtk/rgpackagestatus.h index 1b2da520a..7d7857f80 100644 --- a/gtk/rgpackagestatus.h +++ b/gtk/rgpackagestatus.h @@ -23,11 +23,15 @@ #ifndef _RGPACKAGESTATUS_H_ #define _RGPACKAGESTATUS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "rpackage.h" #include "rpackagestatus.h" +#include +#include + +class RPackage; + class RGPackageStatus : public RPackageStatus { protected: GdkPixbuf *StatusPixbuf[N_STATUS_COUNT]; diff --git a/gtk/rgpkgcdrom.cc b/gtk/rgpkgcdrom.cc index 476debb69..338bfef2a 100644 --- a/gtk/rgpkgcdrom.cc +++ b/gtk/rgpkgcdrom.cc @@ -22,17 +22,25 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef HAVE_APTPKG_CDROM -#include "rgmainwindow.h" #include "rgpkgcdrom.h" -#include -#include - #include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rgmainwindow.h" +#include "rgutils.h" +#include "rgwindow.h" +#include "ruserdialog.h" + +#include +#include +#include +#include +#include +#include using namespace std; @@ -52,7 +60,6 @@ class RGDiscName : public RGGtkBuilderWindow bool run(string &name); }; - void RGCDScanner::Update(string text, int current) { if(text.size() > 0) @@ -116,8 +123,6 @@ bool RGCDScanner::run() return scanner.Add(this); } - - RGDiscName::RGDiscName(RGWindow *wwin, const string defaultName) : RGGtkBuilderWindow(wwin, "disc_name") { diff --git a/gtk/rgpkgcdrom.h b/gtk/rgpkgcdrom.h index d4e9cedea..2b5184748 100644 --- a/gtk/rgpkgcdrom.h +++ b/gtk/rgpkgcdrom.h @@ -25,14 +25,18 @@ #ifndef RGPKGCDROM_H #define RGPKGCDROM_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef HAVE_APTPKG_CDROM -#include "rggtkbuilderwindow.h" +#include "rgwindow.h" + #include +#include +#include class RGMainWindow; +class RUserDialog; class RGCDScanner:public pkgCdromStatus, public RGWindow { protected: diff --git a/gtk/rgpkgdetails.cc b/gtk/rgpkgdetails.cc index 3fd1e0ee3..a6b1b0a6c 100644 --- a/gtk/rgpkgdetails.cc +++ b/gtk/rgpkgdetails.cc @@ -21,20 +21,37 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "rgpkgdetails.h" #include "i18n.h" -#include "rgwindow.h" -#include "rgmainwindow.h" -#include "rgpkgdetails.h" +#include "rgchangelogdialog.h" +#include "rgfetchprogress.h" #include "rggtkbuilderwindow.h" -#include "rpackage.h" +#include "rgmainwindow.h" #include "rgpackagestatus.h" -#include "rgchangelogdialog.h" +#include "rgutils.h" +#include "rpackage.h" #include "sections_trans.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class RGWindow; + using namespace std; RGPkgDetailsWindow::RGPkgDetailsWindow(RGWindow *parent) diff --git a/gtk/rgpkgdetails.h b/gtk/rgpkgdetails.h index d381ae853..4000fc800 100644 --- a/gtk/rgpkgdetails.h +++ b/gtk/rgpkgdetails.h @@ -24,11 +24,18 @@ #ifndef _RGPKGDETAILS_H #define _RGPKGDETAILS_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include "rpackage.h" #include "rggtkbuilderwindow.h" +#include "rpackage.h" + +#include +#include +#include +#include +#include + +class RGWindow; class RGPkgDetailsWindow : public RGGtkBuilderWindow { diff --git a/gtk/rgpkgtreeview.cc b/gtk/rgpkgtreeview.cc index d4d358a4a..39511c472 100644 --- a/gtk/rgpkgtreeview.cc +++ b/gtk/rgpkgtreeview.cc @@ -1,15 +1,19 @@ -#include "config.h" - -#include -#include -#include - -#include +#include "config.h" // IWYU pragma: associated #include "rgpkgtreeview.h" -#include "rgutils.h" #include "i18n.h" +#include "rgutils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include // needed for the buildTreeView function struct mysort { diff --git a/gtk/rgpkgtreeview.h b/gtk/rgpkgtreeview.h index 709400248..18e595668 100644 --- a/gtk/rgpkgtreeview.h +++ b/gtk/rgpkgtreeview.h @@ -1,9 +1,9 @@ #ifndef _GTK_RGPKGTREEVIEW_H #define _GTK_RGPKGTREEVIEW_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include void setupTreeView(GtkWidget *treeview); diff --git a/gtk/rgpreferenceswindow.cc b/gtk/rgpreferenceswindow.cc index 72cb01e3e..47f870030 100644 --- a/gtk/rgpreferenceswindow.cc +++ b/gtk/rgpreferenceswindow.cc @@ -22,22 +22,34 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include -#include -#include -#include -#include +#include "rgpreferenceswindow.h" +#include "i18n.h" #include "rconfiguration.h" -#include "rgpreferenceswindow.h" -#include "rguserdialog.h" +#include "rggtkbuilderwindow.h" +#include "rgmainwindow.h" #include "rgpackagestatus.h" +#include "rguserdialog.h" +#include "rgwindow.h" +#include "rpackagelister.h" -#include "i18n.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace std; diff --git a/gtk/rgpreferenceswindow.h b/gtk/rgpreferenceswindow.h index 4b8c16024..302a7b55b 100644 --- a/gtk/rgpreferenceswindow.h +++ b/gtk/rgpreferenceswindow.h @@ -23,10 +23,18 @@ #ifndef _GTK_RGPREFERENCESWINDOW_H #define _GTK_RGPREFERENCESWINDOW_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" -#include "rgmainwindow.h" + +#include "gtk/gtkcssprovider.h" +#include +#include +#include + +class RGMainWindow; +class RGWindow; +class RPackageLister; class RGPreferencesWindow:public RGGtkBuilderWindow { bool _blockAction; @@ -122,7 +130,6 @@ class RGPreferencesWindow:public RGGtkBuilderWindow { void readNetwork(); void readDistribution(); - static void closeAction(GtkWidget *self, void *data); static void doneAction(GtkWidget *self, void *data); static void clearCacheAction(GtkWidget *self, void *data); diff --git a/gtk/rgrepositorywin.cc b/gtk/rgrepositorywin.cc index 605a2bd40..dee11c34f 100644 --- a/gtk/rgrepositorywin.cc +++ b/gtk/rgrepositorywin.cc @@ -23,20 +23,29 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated + +#include "rgrepositorywin.h" + +#include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rguserdialog.h" +#include "rgutils.h" +#include "ruserdialog.h" #include -#include #include -#include #include - +#include #include +#include +#include +#include +#include +#include +#include -#include "rgrepositorywin.h" -#include "rguserdialog.h" -#include "rgutils.h" -#include "i18n.h" +class RGWindow; using namespace std; diff --git a/gtk/rgrepositorywin.h b/gtk/rgrepositorywin.h index 3b7f2ed15..187f821dc 100644 --- a/gtk/rgrepositorywin.h +++ b/gtk/rgrepositorywin.h @@ -26,13 +26,19 @@ #ifndef _RGREPOSITORYWIN_H #define _RGREPOSITORYWIN_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include "rsources.h" #include "rggtkbuilderwindow.h" +#include "rsources.h" + +#include +#include +#include +#include +#include -#include "rguserdialog.h" +class RGUserDialog; +class RGWindow; typedef std::list::iterator SourcesListIter; typedef std::list::iterator VendorsListIter; diff --git a/gtk/rgsetoptwindow.cc b/gtk/rgsetoptwindow.cc index d5a6f3a1c..ab3c4c710 100644 --- a/gtk/rgsetoptwindow.cc +++ b/gtk/rgsetoptwindow.cc @@ -20,11 +20,20 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated + +#include "rgsetoptwindow.h" + +#include "rggtkbuilderwindow.h" #include +#include +#include +#include +#include +#include -#include "rgsetoptwindow.h" +class RGWindow; void RGSetOptWindow::DoApply(GtkWindow *widget, void *data) { diff --git a/gtk/rgsetoptwindow.h b/gtk/rgsetoptwindow.h index a794037f8..fa619b42d 100644 --- a/gtk/rgsetoptwindow.h +++ b/gtk/rgsetoptwindow.h @@ -23,10 +23,14 @@ #ifndef _GTK_RGSETOPTWINDOW_H #define _GTK_RGSETOPTWINDOW_H -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +#include + +class RGWindow; + class RGSetOptWindow:public RGGtkBuilderWindow { static void DoApply(GtkWindow *widget, void *data); diff --git a/gtk/rgslideshow.cc b/gtk/rgslideshow.cc index 665b9336b..3583fba8d 100644 --- a/gtk/rgslideshow.cc +++ b/gtk/rgslideshow.cc @@ -1,16 +1,14 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include - -#include +#include "rgslideshow.h" #include +#include +#include +#include #include #include -#include "rgslideshow.h" - using namespace std; RGSlideShow::RGSlideShow(GtkImage * image, string imgPath) diff --git a/gtk/rgslideshow.h b/gtk/rgslideshow.h index b3b7ad36d..b7399dd6b 100644 --- a/gtk/rgslideshow.h +++ b/gtk/rgslideshow.h @@ -23,7 +23,11 @@ #ifndef _RGSLIDESHOW_H_ #define _RGSLIDESHOW_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated + +#include +#include +#include class RGSlideShow { diff --git a/gtk/rgsummarywindow.cc b/gtk/rgsummarywindow.cc index 81a60f63e..e38e9cef5 100644 --- a/gtk/rgsummarywindow.cc +++ b/gtk/rgsummarywindow.cc @@ -22,23 +22,29 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include - -#include -#include +#include "rgsummarywindow.h" +#include "i18n.h" +#include "rggtkbuilderwindow.h" +#include "rguserdialog.h" +#include "rpackage.h" #include "rpackagelister.h" -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include -#include "rgsummarywindow.h" -#include "rguserdialog.h" - -#include "i18n.h" +class RGWindow; using namespace std; @@ -101,7 +107,6 @@ void RGSummaryWindow::buildTree(RGSummaryWindow *me) } #endif - if (essential.size() > 0) { /* (Essentail) removed */ gtk_tree_store_append(me->_treeStore, &iter, NULL); @@ -194,7 +199,6 @@ void RGSummaryWindow::buildTree(RGSummaryWindow *me) } } - if (held.size() > 0) { gtk_tree_store_append(me->_treeStore, &iter, NULL); gtk_tree_store_set(me->_treeStore, &iter, @@ -206,12 +210,8 @@ void RGSummaryWindow::buildTree(RGSummaryWindow *me) PKG_COLUMN, (*p)->name(), -1); } } - - - } - void RGSummaryWindow::buildLabel(RGSummaryWindow *me) { GtkWidget *info; @@ -326,7 +326,6 @@ void RGSummaryWindow::clickedDetails(GtkWidget *self, void *data) } } - RGSummaryWindow::RGSummaryWindow(RGWindow *wwin, RPackageLister *lister) : RGGtkBuilderWindow(wwin, "summary") { @@ -479,8 +478,6 @@ RGSummaryWindow::RGSummaryWindow(RGWindow *wwin, RPackageLister *lister) skipTaskbar(false); } - - bool RGSummaryWindow::showAndConfirm() { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(_dlonlyB), diff --git a/gtk/rgsummarywindow.h b/gtk/rgsummarywindow.h index c32ed2977..f5b636cc9 100644 --- a/gtk/rgsummarywindow.h +++ b/gtk/rgsummarywindow.h @@ -25,14 +25,15 @@ #ifndef _RGSUMMARYWINDOW_H_ #define _RGSUMMARYWINDOW_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +#include +class RGWindow; class RPackageLister; - class RGSummaryWindow:public RGGtkBuilderWindow { GtkWidget *_topF; GtkWidget *_middleF; diff --git a/gtk/rgtaskswin.cc b/gtk/rgtaskswin.cc index 6d56f9ac7..c415d1aad 100644 --- a/gtk/rgtaskswin.cc +++ b/gtk/rgtaskswin.cc @@ -20,15 +20,27 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include -#include -#include #include "rgtaskswin.h" + +#include "i18n.h" +#include "rggtkbuilderwindow.h" #include "rgmainwindow.h" #include "rguserdialog.h" -#include "i18n.h" +#include "rgutils.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class RGWindow; using namespace std; @@ -156,7 +168,6 @@ void RGTasksWin::cbButtonDetailsClicked(GtkWidget *self, void *data) me->setBusyCursor(false); } - void RGTasksWin::cell_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer user_data) @@ -207,7 +218,6 @@ void RGTasksWin::selection_changed_callback(GtkTreeSelection *selection, gtk_widget_set_sensitive(me->_detailsButton, sensitiv); } - RGTasksWin::RGTasksWin(RGWindow *parent) : RGGtkBuilderWindow(parent, "tasks") { diff --git a/gtk/rgtaskswin.h b/gtk/rgtaskswin.h index 462913c81..b80e421f4 100644 --- a/gtk/rgtaskswin.h +++ b/gtk/rgtaskswin.h @@ -23,11 +23,15 @@ #ifndef _RGTASKSWIN_H_ #define _RGTASKSWIN_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #include "rggtkbuilderwindow.h" +#include +#include + class RGMainWindow; +class RGWindow; class RGTasksWin : public RGGtkBuilderWindow { protected: @@ -45,8 +49,6 @@ class RGTasksWin : public RGGtkBuilderWindow { static void selection_changed_callback(GtkTreeSelection *selection, gpointer user_data); - - public: RGTasksWin(RGWindow *parent); virtual ~ RGTasksWin() { diff --git a/gtk/rgterminstallprogress.cc b/gtk/rgterminstallprogress.cc index be13abef5..f759daf95 100644 --- a/gtk/rgterminstallprogress.cc +++ b/gtk/rgterminstallprogress.cc @@ -20,38 +20,39 @@ * USA */ -#include "config.h" - -#include +#include "config.h" // IWYU pragma: associated #ifdef HAVE_TERMINAL -#include "i18n.h" - #include "rgterminstallprogress.h" + +#include "i18n.h" +#include "rconfiguration.h" +#include "rggtkbuilderwindow.h" #include "rgmainwindow.h" #include "rguserdialog.h" -#include "rconfiguration.h" +#include "rgutils.h" +#include "rinstallprogress.h" -#include -#include -#include -#include -#include -#include -#include #include +#include #include -#include #include +#include +#include #include -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include - using namespace std; RGTermInstallProgress::RGTermInstallProgress(RGMainWindow *main) diff --git a/gtk/rgterminstallprogress.h b/gtk/rgterminstallprogress.h index 00ed70b75..67ed0d5d4 100644 --- a/gtk/rgterminstallprogress.h +++ b/gtk/rgterminstallprogress.h @@ -23,16 +23,21 @@ #ifndef _RGTERMINSTALLPROGRESS_H_ #define _RGTERMINSTALLPROGRESS_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated #ifdef HAVE_TERMINAL -#include "rgmainwindow.h" +#include "rggtkbuilderwindow.h" #include "rinstallprogress.h" -#include "rgwindow.h" +#include +#include +#include +#include #include +class RGMainWindow; + class RGTermInstallProgress : public RInstallProgress, public RGGtkBuilderWindow { GtkWidget *_term; GtkWidget *_scrollbar; diff --git a/gtk/rguserdialog.cc b/gtk/rguserdialog.cc index ae982d702..ca779d673 100644 --- a/gtk/rguserdialog.cc +++ b/gtk/rguserdialog.cc @@ -22,20 +22,27 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated + +#include "i18n.h" +#include "rguserdialog.h" +#include "rgutils.h" +#include "rgwindow.h" +#include "ruserdialog.h" #include #include #include - -#include +#include +#include +#include +#include #include - -#include +#include +#include +#include +#include #include -#include "i18n.h" -#include "rguserdialog.h" -#include "rgutils.h" using namespace std; diff --git a/gtk/rguserdialog.h b/gtk/rguserdialog.h index d6fa6974d..f82a014cd 100644 --- a/gtk/rguserdialog.h +++ b/gtk/rguserdialog.h @@ -25,10 +25,14 @@ #ifndef RGUSERDIALOG_H #define RGUSERDIALOG_H -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include "ruserdialog.h" #include "rgwindow.h" +#include "ruserdialog.h" + +#include +#include +#include class RGUserDialog : public RUserDialog { @@ -48,10 +52,8 @@ class RGUserDialog : public RUserDialog RUserDialog::DialogType dialog=RUserDialog::DialogInfo, RUserDialog::ButtonsType buttons=RUserDialog::ButtonsOk, bool defaultResponse=true); - }; - /* * A alternative interface for the ruserdialog, here is how it works: * the gtkbuilder file must called "dialog_$NAME.ui" diff --git a/gtk/rgutils.cc b/gtk/rgutils.cc index 05c7c4580..e94ff0ab4 100644 --- a/gtk/rgutils.cc +++ b/gtk/rgutils.cc @@ -20,21 +20,22 @@ * USA */ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "rgutils.h" -#include -#include -#include -#include +#include +#include #include #include -#include -#include +#include +#include +#include +#include #include - -#include "rgutils.h" +#include +#include +#include // helper GdkPixbuf * diff --git a/gtk/rgutils.h b/gtk/rgutils.h index 055a6c806..c0c64362d 100644 --- a/gtk/rgutils.h +++ b/gtk/rgutils.h @@ -23,8 +23,13 @@ #ifndef _RGMISC_H_ #define _RGMISC_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include +#include +#include +#include +#include #include enum { diff --git a/gtk/rgwindow.cc b/gtk/rgwindow.cc index aa479a747..5b33b9535 100644 --- a/gtk/rgwindow.cc +++ b/gtk/rgwindow.cc @@ -20,13 +20,20 @@ * USA */ -#include "config.h" - -#include +#include "config.h" // IWYU pragma: associated #include "rgwindow.h" + #include "rgutils.h" +#include +#include +#include +#include +#include +#include +#include + using namespace std; bool RGWindow::windowCloseCallback(GtkWidget *window, GdkEvent * event) diff --git a/gtk/rgwindow.h b/gtk/rgwindow.h index 1bb8f27f3..c072a3aee 100644 --- a/gtk/rgwindow.h +++ b/gtk/rgwindow.h @@ -25,8 +25,9 @@ #ifndef _RGWINDOW_H_ #define _RGWINDOW_H_ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include #include #include @@ -35,7 +36,7 @@ class RGWindow { GtkWidget *_win; GtkWidget *_topBox; - static bool windowCloseCallback(GtkWidget *widget, GdkEvent * event); + static bool windowCloseCallback(GtkWidget *widget, GdkEvent *event); virtual bool close(); public: diff --git a/tests/Makefile.am b/tests/Makefile.am index ef970baec..fb251f677 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,6 +6,7 @@ AM_CPPFLAGS = -I@top_srcdir@ -I@top_srcdir@/common -I@top_srcdir@/gtk -I@top_bui @VTE_CFLAGS@ \ @LP_CFLAGS@ \ @APT_PKG_CFLAGS@ \ + @APT_PKG_CFLAGS@ \ $(LIBTAGCOLL_CFLAGS) \ -O0 -g3 @@ -19,7 +20,7 @@ LDADD = \ @VTE_LIBS@ \ @LP_LIBS@ \ @APT_PKG_LIBS@ \ - @XAPIAN_LIBS@ \ + @SQLITE_LIBS@ \ -lpthread \ -lutil \ -lX11 diff --git a/tests/test_gtkpkglist.cc b/tests/test_gtkpkglist.cc index 75a697153..1670d148a 100644 --- a/tests/test_gtkpkglist.cc +++ b/tests/test_gtkpkglist.cc @@ -1,20 +1,16 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "gtkpkglist.h" +#include "rgpkgtreeview.h" +#include "rpackagelister.h" -#include #include +#include +#include +#include +#include #include - -#include "rpackagelister.h" -#include "rpackageview.h" -#include "rpackage.h" - -#include "gtk/gtkpkglist.h" -#include "gtk/rgmainwindow.h" -#include "gtk/rgpkgtreeview.h" - -using namespace std; +#include int main(int argc, char **argv) { diff --git a/tests/test_rpackage.cc b/tests/test_rpackage.cc index ab51aa63c..1089e3eb3 100644 --- a/tests/test_rpackage.cc +++ b/tests/test_rpackage.cc @@ -1,10 +1,15 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated +#include "rpackage.h" +#include "rpackagelister.h" + +#include #include +#include +#include #include - -#include "rpackagelister.h" -#include "rpackage.h" +#include +#include using namespace std; diff --git a/tests/test_rpackagefilter.cc b/tests/test_rpackagefilter.cc index c265ba6ae..d70420420 100644 --- a/tests/test_rpackagefilter.cc +++ b/tests/test_rpackagefilter.cc @@ -1,12 +1,19 @@ -#include "config.h" +#include "config.h" // IWYU pragma: associated -#include +#include "rconfiguration.h" +#include "rpackageview.h" +#include "rpackagefilter.h" + +#include #include -#include +#include +#include #include +#include +#include +#include -#include "rpackagelister.h" -#include "rpackage.h" +class RPackage; using namespace std; diff --git a/tests/test_rpackageview.cc b/tests/test_rpackageview.cc index 64f1ccd95..11a0596fd 100644 --- a/tests/test_rpackageview.cc +++ b/tests/test_rpackageview.cc @@ -1,12 +1,16 @@ -#include "config.h" - -#include -#include -#include +#include "config.h" // IWYU pragma: associated +#include "rpackagefilter.h" #include "rpackagelister.h" #include "rpackageview.h" -#include "rpackage.h" + +#include +#include +#include +#include +#include +#include +#include using namespace std;