[Anjuta-list] Signals can't connect
- From: Brian Lavender <brian brie com>
- To: anjuta-list lists sourceforge net
- Subject: [Anjuta-list] Signals can't connect
- Date: Fri, 11 Jan 2008 23:01:40 -0800
I created a new gtk project using anjuta. I used the glade designer
to create my app. It is a simple window with a button in it. Then I
wrote my callback functions. But when it runs, it says it can't find
the signal handlers. What am I doing wrong?
brian night-ranger:~/Projects/gtk-salsa/src$ ./gtk-salsa
(gtk-salsa:5053): libglade-WARNING **: could not find signal handler 'on_button1_clicked'.
(gtk-salsa:5053): libglade-WARNING **: could not find signal handler 'on_window_destroy'.
Here is the source code for main.c and callbacks.c . I didn't include
the glade xml, but I created a window (callback named on_window_destroy
for destroy signal) and a button1 (callback named on_button1_clicked for
clicked signal).
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* callbacks.c
* Copyright (C) brian 2008 <brian brie com>
*
* callbacks.c 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.
*
* callbacks.c 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 callbacks.c. If not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "callbacks.h"
void on_button1_clicked(GtkWidget *widget, gpointer gdata)
{
g_print("Saclug button pressed!!!!\n");
}
gint destroyapp (GtkWidget *widget, gpointer gdata)
{
g_print ("Quitting...\n");
gtk_main_quit();
return (TRUE);
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* main.c
* Copyright (C) brian 2008 <brian brie com>
*
* main.c 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.c 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.c. If not, write to:
* The Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <config.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
#include "callbacks.h"
/* For testing propose use the local (not installed) glade file */
/* #define GLADE_FILE PACKAGE_DATA_DIR"/gtk-salsa/glade/gtk-salsa.glade" */
#define GLADE_FILE "gtk-salsa.glade"
GtkWidget*
create_window (void)
{
GtkWidget *window;
GladeXML *gxml;
gxml = glade_xml_new (GLADE_FILE, NULL, NULL);
/* This is important */
glade_xml_signal_autoconnect (gxml);
window = glade_xml_get_widget (gxml, "window");
return window;
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
gtk_set_locale ();
gtk_init (&argc, &argv);
window = create_window ();
gtk_widget_show (window);
gtk_main ();
return 0;
}
--
Brian Lavender
http://www.brie.com/brian/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]