Re: Making Signal For A Widget.



Gustavo J. A. M. Carneiro wrote:

A Ter, 2003-06-03 às 13:03, B. Souliotis escreveu:
I would like to make a signal for a particular widget that will be emmited when you press the
first mouse button.
I don't want to use the
g_signal_connect(G_OBJECT(widget),"button_press_event",G_CALLBACK(callback),NULL);
for the widget Because i want the callback to called only when i press the First mouse button.

So I would like to make something like "clicked" signal for the gtk_button.
IN gtkbutton.c is called
g_signal_new("clicked",....);
but i don't undarstand how this signal is emmited only when the button pressed. So can anyone tell me how you pass the events to g_signal_new that will emmit the new signal.

        What you want to do is:
        1. register a new signal with signal_id = g_signal_new(...), but only
once per app!
        2. for each instance of the widget,
g_signal_connect(widget,"button_press_event", callback, NULL)
        3. In the 'callback' function, check if the first button has been
pressed..
        4. ..if so, g_signal_emit(signal_id, ...)

        Actually doing what I say becomes more complicated if you are not used
to such things.  Also, this is usually done by creating a new widget
class deriving from the first widget, but this is also a lot of work...
        Good luck.

As far as i know if you make a new widget class i can put in the structure of new widget
something like
widget->button1_pressed = callback_1_pressed

after make the signal

signal_id = g_signal_connect(widget,"button1_pressed",callback, NULL);

and in  callback_1_pressed(GtkWidgetNewClass *)
i'll emit the signal with
g_signal_emit(signal_id,......);

The same thing exactly is doing the GtkButtonClass
with the clicked signal.
But I could not Understand how the signal is emitted only for the first button.
So the question is how the signal_id is connected with a specific event like Button1_pressed
without using other signals like g_signal_connect(widget,"button_press_event", callback, NULL)
and after emiting the specific signal that you want.

Thanks In advance Bill Souliotis





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