preferences.cc

来自「About: Paco (pacKAGE oRGANIZER) is a si」· CC 代码 · 共 130 行

CC
130
字号
//=======================================================================// Preferences.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 "globals.h"#include "Config.h"#include "Preferences.h"#include "MainWindow.h"#include "paco/paco.h"#include <gtkmm/stock.h>#include <gtkmm/frame.h>#include <gtkmm/tooltips.h>using namespace Gpaco;Preferences* Preferences::spPreferences = NULL;Preferences::Preferences():	Gtk::Dialog("gpaco :: Preferences", *gpMainWindow),	mButtonHour("Show _hour in date", true),	mButtonTips("Enable _tooltips", true),	mButtonHuman("Human _readable", true),	mButtonBytes("_Bytes", true),	mButtonKilobytes("_Kilobytes", true),	mButtonMegabytes("_Megabytes", true){	set_position(Gtk::WIN_POS_CENTER_ON_PARENT);	set_border_width(8);	set_has_separator();	set_resizable(false);	signal_response().connect(sigc::mem_fun(*this, &Preferences::response));		get_action_area()->set_layout(Gtk::BUTTONBOX_END);	add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);	Gtk::VButtonBox* pSizeUnitVButtonBox = Gtk::manage		(new Gtk::VButtonBox(Gtk::BUTTONBOX_START));	pSizeUnitVButtonBox->set_border_width(4);	pSizeUnitVButtonBox->pack_start(mButtonHuman);	pSizeUnitVButtonBox->pack_start(mButtonBytes);	pSizeUnitVButtonBox->pack_start(mButtonKilobytes);	pSizeUnitVButtonBox->pack_start(mButtonMegabytes);	gpTips->set_tip(mButtonHuman,		"Show sizes in human readable format (e.g. 13k 3M)");	Gtk::Frame* pSizeUnitFrame = Gtk::manage(new Gtk::Frame(" Size unit "));	pSizeUnitFrame->add(*pSizeUnitVButtonBox);	get_vbox()->set_spacing(8);	get_vbox()->pack_start(*pSizeUnitFrame);	get_vbox()->pack_start(mButtonTips);	get_vbox()->pack_start(mButtonHour);		mButtonHour.set_active(Config::hour());	mButtonTips.set_active(Config::tips());		Gtk::RadioButtonGroup sizeUnitGroup = mButtonHuman.get_group();	mButtonBytes.set_group(sizeUnitGroup);	mButtonKilobytes.set_group(sizeUnitGroup);	mButtonMegabytes.set_group(sizeUnitGroup);	switch (Config::sizeUnit()) {		case Paco::HUMAN_READABLE:	mButtonHuman.set_active(); break;		case Paco::BYTE:			mButtonBytes.set_active(); break;		case Paco::KILOBYTE:		mButtonKilobytes.set_active(); break;		case Paco::MEGABYTE:		mButtonMegabytes.set_active(); break;		default:					g_assert_not_reached();	}	show_all();}Preferences::~Preferences(){	g_assert(spPreferences != NULL);}// [static]void Preferences::instance(){	if (!spPreferences)		spPreferences = new Preferences();	spPreferences->present();}void Preferences::response(int id){	g_assert(spPreferences != NULL);	if (id == Gtk::RESPONSE_OK)		ok();		delete spPreferences;	spPreferences = NULL;;}void Preferences::ok(){	Config::hour(mButtonHour.get_active());	Config::tips(mButtonTips.get_active());		if (mButtonHuman.get_active())		Config::sizeUnit(Paco::HUMAN_READABLE);	else if (mButtonBytes.get_active())		Config::sizeUnit(Paco::BYTE);	else if (mButtonKilobytes.get_active())		Config::sizeUnit(Paco::KILOBYTE);	else if (mButtonMegabytes.get_active())		Config::sizeUnit(Paco::MEGABYTE);	else		g_assert_not_reached();		gpMainWindow->treeView().refresh();}

⌨️ 快捷键说明

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