Re: On key pulsation, again



Dear Olexiy,

Thanks a lot for interest... but, you attached me an example which use an other technique (the other): mnemonics. In fact, I'd like to understand the use of accelerators (like gtk_widget_add_accelerator()) for clicking buttons.

Could you help me, anyway ?

David

From: Olexiy Avramchenko <olexiy ctech cn ua>
To: David Gasa Castell <dgasacas7 hotmail com>
CC: gtk-list gnome org
Subject: Re: On key pulsation, again
Date: Mon, 18 Jul 2005 10:44:10 +0300

David Gasa Castell wrote:
Could anyone attach me a little example code that examplifies the using of the accelerators (especially associated in buttons (GTK_TYPE_BUTTON) for clicking them) ?
See the sample.

PD: I've seen a lot of code in this distribution list but I don't reach to understand a lot. I try to execute some but... cannot compile !.
Can you, please, point to it, maybe it have to be fixed ?

-- sample
#include <gtk/gtk.h>

static void
clicked(GtkButton *button)
{
static char *labels[]={"Press <Alt>+_a to activate", "Press <Alt>+_b to activate"};
	static int label=0;

        label ^= 1;
        g_print("button was clicked\n");
        gtk_button_set_label(button, labels[label]);
}

int
main(int argc, char **argv)
{
        GtkWidget *window;
        GtkWidget *button;

        gtk_init(&argc, &argv);

        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_set_border_width(GTK_CONTAINER(window), 4);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0);

button = gtk_button_new_with_mnemonic("Press <Alt>+_a to activate");
        gtk_container_add(GTK_CONTAINER(window), button);
        g_signal_connect(button, "clicked", G_CALLBACK(clicked), 0);

        gtk_widget_show_all(window);

        gtk_main();

        return 0;
}
sample --

	Olexiy





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]