📄 examplewindow.cc
字号:
#include "ExampleWindow.h"ExampleWindow::ExampleWindow( BaseObjectType* base_object, const Glib::RefPtr<Gnome::Glade::Xml>& glade_xml) : Gtk::Window(base_object){ // Get the GConf::Client, tell it we want to monitor /apps/metacity/general d_conf_client = Gnome::Conf::Client::get_default_client(); d_conf_client->add_dir("/apps/metacity/general"); // Get the check_button glade_xml->get_widget("Reduced Resources", d_checkbutton); // Connect the check_button to a callback that can toggle it when the option // is changed by some outside program. d_conf_client->notify_add("/apps/metacity/general/reduced_resources", sigc::mem_fun(*this, &ExampleWindow::key_changed)); // Connect the check_button's clicked callback up so that it can change the // gconf setting. d_checkbutton->signal_clicked().connect( sigc::mem_fun(*this, &ExampleWindow::checkbutton_toggled) ); // Determine whether button should start activated or not d_old_setting = d_conf_client->get_bool("/apps/metacity/general/reduced_resources"); d_checkbutton->set_active(d_old_setting); // Get the close button and connect it to hide Gtk::Button* close_button; glade_xml->get_widget("CloseButton", close_button); close_button->signal_clicked().connect( sigc::mem_fun(*this, &Gtk::Widget::hide));}ExampleWindow::~ExampleWindow(){}voidExampleWindow::key_changed(guint connection_id, Gnome::Conf::Entry entry){ // Make sure the preference has a valid value if (entry.get_value().get_type() == Gnome::Conf::VALUE_BOOL) { // Get the new value bool new_setting = entry.get_value().get_bool(); // Try to handle asynchronous-ness of GConf and prevent calling // checkbutton_toggled again if this function was called as a // result of the d_conf_client->set() function call. if (new_setting != d_old_setting) { d_old_setting = new_setting; d_checkbutton->set_active(new_setting); } }}voidExampleWindow::checkbutton_toggled(){ // Determine whether the checkbutton is already set or not bool is_set = d_checkbutton->get_active(); // Try to handle asynchronous-ness of GConf and prevent calling // key_changed again if this function was called as a result of the // d_checkbutton->set_active() function call. if (is_set != d_old_setting) { d_old_setting = is_set; d_conf_client->set("/apps/metacity/general/reduced_resources", is_set); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -