Re: Accel group on buttons?
- From: "David Necas (Yeti)" <yeti physics muni cz>
- To: Radoslaw Grzanka <praca_lodz op pl>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Accel group on buttons?
- Date: Wed, 7 Jul 2004 12:09:45 +0200
On Wed, Jul 07, 2004 at 11:33:56AM +0200, Radoslaw Grzanka wrote:
Anyway. My other question is how to catch this "clicked" signal. It
seems that button doesn't get this signal (or at least it doesn't
work for me) which I believe in C++ is "signal_clicked()". I have to
catch this signal from AccelGroup but then I can't find out from
which button it came. Surely I am missing something.
Well, I don't know how thigs work in C++/Gtkmm. But
I attach a working C code (both F1 and clicking on the
button runs button_callback()), so I hope you'll be able to
translate it to C++
=============================================================================
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
static void
button_callback(void)
{
g_print("Clicked!\n");
}
int main(int argc, char *argv[])
{
GtkWidget *win, *button;
GtkAccelGroup *accel_group;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label("Hello!");
gtk_container_add(GTK_CONTAINER(win), button);
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group(GTK_WINDOW(win), accel_group);
gtk_widget_add_accelerator(button, "clicked", accel_group, GDK_F1, 0, 0);
g_signal_connect(G_OBJECT(win), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(button_callback), NULL);
gtk_widget_show_all(win);
gtk_main();
return 0;
}
=============================================================================
Regards,
Yeti
--
Do not use tab characters. Their effect is not predictable.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]