/usr/share/doc/libglademm-2.4-doc/examples/variablesmap/examplewindow.cc is in libglademm-2.4-doc 2.6.7-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | //$Id: examplewindow.cc 1099 2007-09-27 15:23:49Z arminb $ -*- c++ -*-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "examplewindow.h"
#include <iostream>
#include <gtkmm.h>
ExampleWindow::ExampleWindow()
: m_bCheckBox(0)
{
// Sets the border width of the window.
set_border_width(10);
//Get Glade UI:
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
m_refGlade = Gnome::Glade::Xml::create("example.glade");
}
catch(const Gnome::Glade::XmlError& ex)
{
std::cerr << ex.what() << std::endl;
return;
}
#else
std::auto_ptr<Gnome::Glade::XmlError> error;
m_refGlade = Gnome::Glade::Xml::create("example.glade", "", "", error);
if(error.get())
{
std::cerr << error->what() << std::endl;
return;
}
#endif
m_refGlade->reparent_widget("vbox", *this);
m_pVariablesMap = new Gnome::Glade::VariablesMap(m_refGlade);
m_pVariablesMap->connect_widget("entry", m_strEntry);
m_pVariablesMap->connect_widget("checkbox", m_bCheckBox);
m_pVariablesMap->connect_widget("comboboxentry", m_strCombo);
m_pVariablesMap->connect_widget("spinbutton", m_strSpinButton);
m_pVariablesMap->connect_widget("hscale", m_dHScale);
m_pVariablesMap->connect_widget("vscale", m_dVScale);
m_pVariablesMap->connect_widget("calendar", m_dateCalendar);
//Connect button's signal handler:
//Glade::Xml::connect_clicked() is a convenience method, which has nothing to do with the VariablesMap.
m_refGlade->connect_clicked("button", sigc::mem_fun(*this, &ExampleWindow::on_button_clicked));
m_refGlade->connect_clicked("file_new", sigc::mem_fun(*this, &ExampleWindow::on_file_new));
m_refGlade->connect_clicked("file_exit", sigc::mem_fun(*this, &ExampleWindow::on_file_exit));
m_refGlade->connect_clicked("help_info", sigc::mem_fun(*this, &ExampleWindow::on_info));
show_all_children();
}
ExampleWindow::~ExampleWindow()
{
if(m_pVariablesMap)
{
delete m_pVariablesMap;
m_pVariablesMap = 0;
}
}
void ExampleWindow::on_button_clicked()
{
if(m_pVariablesMap)
m_pVariablesMap->transfer_widgets_to_variables();
std::cout << "Variable values: " << std::endl <<
" m_strEntry: " << m_strEntry << std::endl <<
" m_strCombo: " << m_strCombo << std::endl <<
" m_strSpinButton: " << m_strSpinButton << std::endl <<
" m_dHScale: " << m_dHScale << std::endl <<
" m_dVScale: " << m_dVScale << std::endl <<
" m_dateCalendar: " << m_dateCalendar.format_string("%d-%m-%y") << std::endl <<
" m_bCheckBox: " << (m_bCheckBox ? "true" : "false") << std::endl;
}
void ExampleWindow::on_file_exit()
{
hide();
}
void ExampleWindow::on_file_new()
{
m_strEntry.clear();
m_strCombo.clear();
m_strSpinButton.clear();
m_dHScale = 50;
m_dVScale = 50;
m_dateCalendar.set_dmy(22, Glib::Date::OCTOBER, 1977); // Alberto's birthday :-)
m_bCheckBox = true;
if(m_pVariablesMap)
m_pVariablesMap->transfer_variables_to_widgets();
}
void ExampleWindow::on_info()
{
std::cout << "Info Selected" << std::endl;
}
|