⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pkg.cc

📁 About: Paco (pacKAGE oRGANIZER) is a simple, yet powerful tool to aid package management when insta
💻 CC
字号:
//=======================================================================// Pkg.cc//-----------------------------------------------------------------------// This file is part of the package paco// Copyright (C) 2004-2007 David Rosal <david.3r@gmail.com>// For more information visit http://paco.sourceforge.net//=======================================================================#include "config.h"#include "Config.h"#include "Pkg.h"#include "PkgWindow.h"#include "FilesTreeView.h"#include "FilesTab.h"#include "paco/File.h"#include <gdkmm/pixbuf.h>#include <fstream>using Glib::ustring;using std::string;using namespace Gpaco;Pkg::Pkg(ustring const& __name):	Paco::BasePkg(__name),	mSizePercent(0),	mFilesPercent(0),	mpIcon(),	mSummary(),	mpWindow(NULL),	mFileType(Pkg::INSTALLED_FILES),	mChanged(false){	readLog();}// [virtual]Pkg::~Pkg(){ }void Pkg::readLog(){	string buf;	std::ifstream f(mLog.c_str());	g_return_if_fail(f);		while (getline(f, buf) && buf[0] == '#') {		if (!buf.find("##:")) {			sscanf(buf.c_str(), "##:%ld|%ld|%ld|%ld",				&mSizeInst, &mSizeMiss, &mFilesInst, &mFilesMiss);		}		else if (!buf.find("#i:/"))			getIcon(buf.substr(3));		else if (!buf.find("#:Summary: ")) {			mSummary = buf.substr(11);			break;		}	}	f.close();	getFiles();	long total = mSizeInst + mSizeMiss;	mSizePercent = total ? (100.0 * mSizeInst / total) : 100.0;	total = mFilesInst + mFilesMiss;	mFilesPercent = total ? (100.0 * mFilesInst / total) : 0.0;}void Pkg::getIcon(ustring const& path)try {	if (Glib::RefPtr<Gdk::Pixbuf> p = Gdk::Pixbuf::create_from_file(path)) {		if (p->get_width() >= 72 || p->get_height() >= 72)			mpIcon = p->scale_simple(72, 72, Gdk::INTERP_BILINEAR);		else if (p->get_width() <= 24 || p->get_height() <= 24)			mpIcon = p->scale_simple(24, 24, Gdk::INTERP_BILINEAR);		else			mpIcon = p;	}} catch (...) { }void Pkg::presentWindow(int tab){	if (!mpWindow) {		mpWindow = new PkgWindow(*this);		mpWindow->filesTab().treeView().writeLabel();	}	mpWindow->presentTab(tab);}void Pkg::deleteWindow(){	g_assert(mpWindow != NULL);	delete mpWindow;	mpWindow = NULL;}void Pkg::refreshFilesTab(){	if (mpWindow)		mpWindow->filesTab().treeView().refresh();}void Pkg::switchRules(){	if (mpWindow)		mpWindow->filesTab().treeView().set_rules_hint(Config::rules());}bool Pkg::update(bool resetFilesModel /* = true */){	bool ret = true;		try {		if ((ret = updateLog(mLog))) {			readLog();			if (mpWindow && resetFilesModel)				mpWindow->filesTab().treeView().resetModel();		}	}	catch (...) { }	mChanged = true;	return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -