Re: How to add new Signals in a class



On Fri, 2004-10-29 at 12:45 +0100, Tim Müller wrote:
On Friday 29 October 2004 12:30, vasista sarma wrote:

Hi,

ok let me explain the exact situation i am in i have a GtkButtonClass
which i have used for "clicked" and "pressed" events .
The code would look something like this

GtkButtonClass * button_class= (GtkButtonClass *)kclass;
button_class->clicked = button_clicked;
button_class->pressed = button_pressed;
 (snip)
These two functions are getting invoked for button pressed and Click
events. Now i want to write something for drag motion as well
something like (this i want when other application is hovered over
button).

button_class->drag_motion= button_drag_motion;

How can i achieve this. Please give an example on how to do this

Just out of curiosity ... why are you trying to derive a new class from 
GtkButtonClass, instead of just connecting to the relevant signals? 

e.g.:

static void
on_button_clicked (GtkWidget *button, gpointer data)
{
  g_print ("click\n");
}

...

  GtkWidget *button = gtk_button_new_with_label ("clickme");
  
  g_signal_connect (button, "clicked", G_CALLBACK (on_button_clicked), NULL);
I wish i could connect signals this way but i am given a code that uses
GtkButtonClass instead of GtkButton (my life would have been much
simpler). I cannot change the declaration now again since it breaks much
of the code there and a lot of reworking needs to be done there, So i am
caught b/w devil and the deep blue sea. u suggest blue sea is
better :)) 
Cheers,
vasista

....

Cheers 
 -Tim




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