Re: How to add new Signals in a class



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);

....

Cheers 
 -Tim



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