Re: delete_event
- From: weijie <weijie90 gmail com>
- To: Pavlo Korzhyk <pavlo korzhyk gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: delete_event
- Date: Sun, 26 Nov 2006 09:57:26 +0800
Hi,
I have attached the source, main.cc
It works with and without &
Thanks!
On Sat, 2006-11-25 at 16:32 +0200, Pavlo Korzhyk wrote:
> For me these errors are not enough to understand your problem. You
> should provide the source code.
> It seems like you use sigc++ templates the wrong way.
> Is on_prefs_cancel_btn_clicked a member of a class? how is it
> declared?
>
> There is an example in book:
>
> #include <gtkmm/button.h>
>
> void on_button_clicked()
> {
> std::cout << "Hello World" << std::endl;
> }
>
>
> main()
> {
> Gtk::Button button("Hello World");
> button.signal_clicked().connect(sigc::ptr_fun(&on_button_clicked));
> }
>
>
> Maybe you missed &. Try compiling this sample code: if you get errors - your dev environment
>
> is not configured right.
>
>
>
>
> --
> WBR, Pavlo Korzhyk
> ICQ#155870780
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.cc
* Copyright (C) weijie 2006 <di@>
*
* Special Thanks to Deadchip from #gtk+ @irc.gnome.org
* He helped me find a pretty obvious bug which i couldn't spot, haha
*
* And Sheryl wants a special mention too. haha
*
* main.cc is free software.
*
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* main.cc 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 main.cc. If not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <libglademm/xml.h>
#include <gtkmm.h>
#include <iostream>
#include <stdlib.h>
#ifdef ENABLE_NLS
# include <libintl.h>
#endif
/* For testing propose use the local (not installed) glade file */
/* #define GLADE_FILE PACKAGE_DATA_DIR"/xamoz/glade/xamoz.glade" */
#define GLADE_FILE "xamoz.glade"
//-----------------------------------------Pointers to windows and dialogs--------------------------------------------------------------
Gtk::Window* main_win;
Gtk::Dialog* prefs_diag;
Gtk::Dialog* test_diag;
//------------------------------------------Signal handler declarations--------------------------------------------------------------
void on_prefs_btn_clicked();
void on_quit_btn_clicked();
void on_prefs_cancel_btn_clicked();
void on_prefs_test_btn_clicked();
void on_test_close_btn_clicked();
//-------------------------------------signal handlers-----------------------------------------------------------------------------------------
void on_prefs_btn_clicked() {
prefs_diag->run(); //kit.run(*prefs_diag);, seems to be the same?
}
////////////////////////////
void on_quit_btn_clicked() {
main_win->hide();
}
////////////////////////////
void on_prefs_cancel_btn_clicked() {
prefs_diag->hide();
}
///////////////////////////
void on_prefs_test_btn_clicked() {
test_diag->run();
}
//////////////////////////
void on_test_close_btn_clicked() {
test_diag->hide();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------
int
main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
//Load the Glade file and instiate its widgets:
Glib::RefPtr<Gnome::Glade::Xml> refXml;
refXml = Gnome::Glade::Xml::create(GLADE_FILE);
///------------------------------------------------------------link windows here----------------------------------------------------------------
refXml->get_widget("main_window", main_win);
refXml->get_widget("prefs_diag", prefs_diag);
refXml->get_widget("test_diag", test_diag);
//-------------declare buttons here, and conncet them to their glade counterparts,--------------------------------
//------------------------------------and connect them to signal handlers.-----------------------------------------------------------
//prefs_diag->signal_delete_event().connect( sigc::ptr_fun(&on_prefs_cancel_btn_clicked) );
Gtk::Button* quit_btn;
refXml->get_widget("quit_btn", quit_btn);
quit_btn->signal_clicked().connect( sigc::ptr_fun(&on_quit_btn_clicked) );
/////////////////
Gtk::Button* prefs_btn;
refXml->get_widget("prefs_btn", prefs_btn);
prefs_btn->signal_clicked().connect( sigc::ptr_fun(on_prefs_btn_clicked) );
/////////////////
Gtk::Button* prefs_cancel_btn;
refXml->get_widget("prefs_cancel_btn", prefs_cancel_btn);
prefs_cancel_btn->signal_clicked().connect( sigc::ptr_fun(on_prefs_cancel_btn_clicked) );
/////////////////
Gtk::Button* prefs_test_btn;
refXml->get_widget("prefs_test_btn", prefs_test_btn);
prefs_test_btn->signal_clicked().connect( sigc::ptr_fun(on_prefs_test_btn_clicked) );
/////////////////
Gtk::Button* test_close_btn;
refXml->get_widget("test_close_btn", test_close_btn);
test_close_btn->signal_clicked().connect( sigc::ptr_fun(on_test_close_btn_clicked) );
//--------------------------------------------------------Main-------------------------------------------------------------------------------------------------
if (main_win) {
kit.run(*main_win);
}
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]